Skip to content

Commit bcd4f93

Browse files
committed
Added dirty text align crutch for 24x32 (GFX is off by a few pixels)
1 parent 4378ef1 commit bcd4f93

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

neomatrix_config.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,8 +1150,17 @@ uint16_t text_width(char *text, Adafruit_GFX *gfx = NULL) {
11501150
}
11511151

11521152
uint16_t text_xcenter(char *text, Adafruit_GFX *gfx = NULL) {
1153+
uint8_t fudge = 0;
1154+
11531155
if (!gfx) gfx = matrix;
1154-
return((gfx->width() - text_width(text, gfx)) / 2);
1156+
// workaround for bug in adafruit::gfx that returns a width too large?
1157+
if (gfx->width() == 24) fudge = 2;
1158+
//Serial.print(gfx->width() );
1159+
//Serial.print(" ");
1160+
//Serial.print(text_width(text, gfx));
1161+
//Serial.print(" ");
1162+
//Serial.println((gfx->width() - text_width(text, gfx)) / 2);
1163+
return(fudge + (gfx->width() - text_width(text, gfx)) / 2);
11551164
}
11561165

11571166
void matrix_setup(bool initserial=true, int reservemem = 40000) {

0 commit comments

Comments
 (0)