Skip to content

Commit e9beb68

Browse files
committed
Added support for huge font sizes
1 parent 0994e28 commit e9beb68

File tree

5 files changed

+42
-34
lines changed

5 files changed

+42
-34
lines changed

fontconvert/main.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include FT_GLYPH_H
2323
#include FT_MODULE_H
2424
#include FT_TRUETYPE_DRIVER_H
25-
#include "../../../src/g5enc.inl" // Group5 image compression library
25+
#include "../src/g5enc.inl" // Group5 image compression library
2626
G5ENCIMAGE g5enc; // Group5 encoder state
2727

2828
#define DPI 141 // Approximate resolution of common displays
@@ -259,21 +259,6 @@ int main(int argc, char *argv[])
259259
bitmap = &face->glyph->bitmap;
260260
g = (FT_BitmapGlyphRec *)glyph;
261261

262-
// Minimal font and per-glyph information is stored to
263-
// reduce flash space requirements. Glyph bitmaps are
264-
// fully bit-packed; no per-scanline pad, though end of
265-
// each character may be padded to next byte boundary
266-
// when needed. 16-bit offset means 64K max for bitmaps,
267-
// code currently doesn't check for overflow. (Doesn't
268-
// check that size & offsets are within bounds either for
269-
// that matter...please convert fonts responsibly.)
270-
271-
// Check that the requested font size fits within the limits
272-
// of the 8-bit member variables
273-
if (bitmap->width > 255 || (face->glyph->advance.x>>6) > 255) {
274-
printf("The requested size is too large to fit in the BB_GLYPH member vars\nEither request a smaller size or change the member variables to be 16-bits\n");
275-
return -1;
276-
}
277262
pGlyphs[index].bitmapOffset = iOffset;
278263
pGlyphs[index].width = bitmap->width;
279264
pGlyphs[index].height = bitmap->rows;

src/FastEPD.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ enum {
7575
// Pre-configured displays
7676
enum {
7777
BBEP_DISPLAY_EC060TC1,
78+
BBEP_DISPLAY_EC060KD1,
7879
BBEP_DISPLAY_ED0970TC1,
7980
BBEP_DISPLAY_ED103TC2,
8081
BBEP_DISPLAY_ED052TC4,

src/FastEPD.inl

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ static uint8_t bSlowSPH = 0;
246246

247247
static bool s3_notify_dma_ready(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx)
248248
{
249-
dma_is_done = true;
250249
if (bSlowSPH) {
251250
gpio_set_level(u8SPH, 1); // CS deactivate
252251
}
252+
dma_is_done = true;
253253
return false;
254254
}
255255

@@ -1088,7 +1088,7 @@ void bbepWriteRow(FASTEPDSTATE *pState, uint8_t *pData, int iLen, int bRowStep)
10881088
}
10891089
if (bSlowSPH) {
10901090
gpio_set_level(u8SPH, 0); // SPH/CS active
1091-
gpio_set_level(u8CKV, 1); // CKV on
1091+
// gpio_set_level(u8CKV, 1); // CKV on
10921092
}
10931093
dma_is_done = false;
10941094
gpio_set_level((gpio_num_t)pState->panelDef.ioCKV, 1); // CKV on
@@ -1157,6 +1157,10 @@ int bbepSetDefinedPanel(FASTEPDSTATE *pState, int iPanel)
11571157
bbepSetPanelSize(pState, 1024, 758, BB_PANEL_FLAG_NONE);
11581158
bbepSetCustomMatrix(pState, u8SixInchMatrix, sizeof(u8SixInchMatrix));
11591159
break;
1160+
case BBEP_DISPLAY_EC060KD1:
1161+
bbepSetPanelSize(pState, 1448, 1072, BB_PANEL_FLAG_NONE);
1162+
bbepSetCustomMatrix(pState, u8SixInchMatrix, sizeof(u8SixInchMatrix));
1163+
break;
11601164
case BBEP_DISPLAY_ED0970TC1:
11611165
bbepSetPanelSize(pState, 1280, 825, BB_PANEL_FLAG_NONE);
11621166
bbepSetCustomMatrix(pState, u8NineInchMatrix, sizeof(u8NineInchMatrix));
@@ -1250,10 +1254,17 @@ return BBEP_SUCCESS;
12501254
//
12511255
void bbepSetBrightness(FASTEPDSTATE *pState, uint8_t led1, uint8_t led2)
12521256
{
1257+
#if (ESP_IDF_VERSION_MAJOR > 4)
12531258
ledcWrite(pState->u8LED1, led1); // PWM (0-255)
12541259
if (pState->u8LED2 != 0xff) {
12551260
ledcWrite(pState->u8LED2, led2);
12561261
}
1262+
#else // old API
1263+
ledcWrite(0, led1);
1264+
if (pState->u8LED2 != 0xff) {
1265+
ledcWrite(1, led2);
1266+
}
1267+
#endif
12571268
} /* bbepSetBrightness() */
12581269

12591270
//
@@ -1263,12 +1274,23 @@ void bbepInitLights(FASTEPDSTATE *pState, uint8_t led1, uint8_t led2)
12631274
{
12641275
pState->u8LED1 = led1;
12651276
pState->u8LED2 = led2;
1277+
#if (ESP_IDF_VERSION_MAJOR > 4)
12661278
ledcAttach(led1, 5000, 8); // attach pin to channel 0
12671279
ledcWrite(led1, 0); // set to off to start
12681280
if (led2 != 0xff) {
12691281
ledcAttach(led2, 5000, 8);
12701282
ledcWrite(led2, 0); // set to off
12711283
}
1284+
#else // old API
1285+
ledcSetup(0, 5000, 8);
1286+
ledcAttachPin(led1, 0);
1287+
ledcWrite(0, 0);
1288+
if (led2 != 0xff) {
1289+
ledcSetup(1, 5000, 8);
1290+
ledcAttachPin(led2, 1);
1291+
ledcWrite(1, 0);
1292+
}
1293+
#endif
12721294
} /* bbepInitLights() */
12731295

12741296
//
@@ -1565,26 +1587,26 @@ int bbepFullUpdate(FASTEPDSTATE *pState, int iClearMode, bool bKeepOn, BBEPRECT
15651587
if (bbepEinkPower(pState, 1) != BBEP_SUCCESS) return BBEP_IO_ERROR;
15661588
switch (iClearMode) {
15671589
case CLEAR_SLOW:
1568-
bbepClear(pState, BB_CLEAR_DARKEN, 10, pRect);
1569-
bbepClear(pState, BB_CLEAR_LIGHTEN, 10, pRect);
1570-
bbepClear(pState, BB_CLEAR_DARKEN, 10, pRect);
1571-
bbepClear(pState, BB_CLEAR_LIGHTEN, 10, pRect);
1590+
bbepClear(pState, BB_CLEAR_DARKEN, 4, pRect);
1591+
bbepClear(pState, BB_CLEAR_LIGHTEN, 8, pRect);
1592+
bbepClear(pState, BB_CLEAR_DARKEN, 4, pRect);
1593+
bbepClear(pState, BB_CLEAR_LIGHTEN, 8, pRect);
15721594
break;
15731595
case CLEAR_FAST:
1574-
bbepClear(pState, BB_CLEAR_DARKEN, 8, pRect);
1596+
bbepClear(pState, BB_CLEAR_DARKEN, 2, pRect);
15751597
bbepClear(pState, BB_CLEAR_LIGHTEN, 8, pRect);
15761598
break;
15771599
case CLEAR_WHITE:
1578-
bbepClear(pState, BB_CLEAR_LIGHTEN, 5, pRect);
1600+
bbepClear(pState, BB_CLEAR_LIGHTEN, 8, pRect);
15791601
break;
15801602
case CLEAR_BLACK: // probably a mistake
1581-
bbepClear(pState, BB_CLEAR_DARKEN, 5, pRect);
1603+
bbepClear(pState, BB_CLEAR_DARKEN, 8, pRect);
15821604
break;
15831605
case CLEAR_NONE: // nothing to do
15841606
default:
15851607
break;
15861608
}
1587-
1609+
bbepClear(pState, BB_CLEAR_NEUTRAL, 1, pRect);
15881610
#ifdef SHOW_TIME
15891611
l = millis() - l;
15901612
Serial.printf("clear time = %dms\n", (int)l);

src/Group5.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ typedef struct g5_enc_image_tag
150150
// Font info per character (glyph)
151151
typedef struct {
152152
uint16_t bitmapOffset; // Offset to compressed bitmap data for this glyph (starting from the end of the BB_GLYPH[] array)
153-
uint8_t width; // bitmap width in pixels
154-
uint8_t xAdvance; // total width in pixels (bitmap + padding)
153+
uint16_t width; // bitmap width in pixels
154+
uint16_t xAdvance; // total width in pixels (bitmap + padding)
155155
uint16_t height; // bitmap height in pixels
156156
int16_t xOffset; // left padding to upper left corner
157157
int16_t yOffset; // padding from baseline to upper left corner (usually negative)

src/bb_ep_gfx.inl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ int bbepWriteStringCustom(FASTEPDSTATE *pBBEP, BB_FONT *pFont, int x, int y, cha
892892
continue; // skip it
893893
c -= first; // first char of font defined
894894
pGlyph = &pFont->glyphs[c]; // glyph info for this character
895-
dx += pgm_read_byte(&pGlyph->xAdvance);
895+
dx += pgm_read_word(&pGlyph->xAdvance);
896896
}
897897
x = (pBBEP->width - dx)/2;
898898
if (x < 0) x = 0;
@@ -908,17 +908,17 @@ int bbepWriteStringCustom(FASTEPDSTATE *pBBEP, BB_FONT *pFont, int x, int y, cha
908908
continue; // skip it
909909
c -= first; // first char of font defined
910910
pGlyph = &pFont->glyphs[c]; // glyph info for this character
911-
if (pgm_read_byte(&pGlyph->width) > 1) { // skip this if drawing a space
911+
if (pgm_read_word(&pGlyph->width) > 1) { // skip this if drawing a space
912912
x_off = pGlyph->xOffset;
913913
s = pBits + pgm_read_word(&pGlyph->bitmapOffset); // start of compressed bitmap data
914914
if (pgm_read_dword(&pFont->rotation) == 0 || pgm_read_dword(&pFont->rotation) == 180) {
915915
h = pgm_read_word(&pGlyph->height);
916-
w = pgm_read_byte(&pGlyph->width);
916+
w = pgm_read_word(&pGlyph->width);
917917
dx = x + (int16_t)pgm_read_word(&pGlyph->xOffset); // offset from character UL to start drawing
918918
dy = y + (int16_t)pgm_read_word(&pGlyph->yOffset);
919919
} else { // rotated
920920
w = pgm_read_word(&pGlyph->height);
921-
h = pgm_read_byte(&pGlyph->width);
921+
h = pgm_read_word(&pGlyph->width);
922922
n = (int16_t)pgm_read_word(&pGlyph->yOffset); // offset from character UL to start drawing
923923
dx = x;
924924
if (-n < w) dx -= (w+n); // since we draw from the baseline
@@ -993,9 +993,9 @@ int bbepWriteStringCustom(FASTEPDSTATE *pBBEP, BB_FONT *pFont, int x, int y, cha
993993
} // non-antialased
994994
} // if not drawing a space
995995
if (pgm_read_dword(&pFont->rotation) == 0 || pgm_read_dword(&pFont->rotation) == 180) {
996-
x += pgm_read_byte(&pGlyph->xAdvance); // width of this character
996+
x += pgm_read_word(&pGlyph->xAdvance); // width of this character
997997
} else {
998-
y += pgm_read_byte(&pGlyph->xAdvance);
998+
y += pgm_read_word(&pGlyph->xAdvance);
999999
}
10001000
} // while drawing characters
10011001
pBBEP->iCursorX = x;

0 commit comments

Comments
 (0)