Skip to content

Commit f50f7c1

Browse files
committed
allow definition of font and display tables in an external file
1 parent 01c621f commit f50f7c1

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

app/include/u8g2_displays.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
// Uncomment the U8G2_DISPLAY_TABLE_ENTRY for the device(s) you want to
1111
// compile into the firmware.
1212
// Stick to the assignments to *_I2C and *_SPI tables.
13-
//
13+
14+
#ifndef U8G2_DISPLAY_TABLE_I2C_EXTRA
15+
1416
// I2C based displays go into here:
1517
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1610_i2c_ea_dogxl160_f, uc1610_i2c_ea_dogxl160) \
1618
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1325_i2c_nhd_128x64_f, ssd1325_i2c_nhd_128x64) \
@@ -38,6 +40,17 @@
3840
#define U8G2_DISPLAY_TABLE_I2C \
3941
U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x64_noname_f, ssd1306_i2c_128x64_noname) \
4042

43+
#else
44+
45+
// I2C displays can be defined in an external file.
46+
#define U8G2_DISPLAY_TABLE_I2C \
47+
U8G2_DISPLAY_TABLE_I2C_EXTRA
48+
49+
#endif
50+
51+
52+
#ifndef U8G2_DISPLAY_TABLE_SPI_EXTRA
53+
4154
// SPI based displays go into here:
4255
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1606_172x72_f, ssd1606_172x72) \
4356
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_240x128_f, uc1608_240x128) \
@@ -93,6 +106,14 @@
93106
#define U8G2_DISPLAY_TABLE_SPI \
94107
U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x64_noname_f, ssd1306_128x64_noname) \
95108

109+
#else
110+
111+
// SPI displays can be defined in an external file.
112+
#define U8G2_DISPLAY_TABLE_SPI \
113+
U8G2_DISPLAY_TABLE_SPI_EXTRA
114+
115+
#endif
116+
96117
//
97118
// ***************************************************************************
98119

app/include/u8g2_fonts.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@
77
// ***************************************************************************
88
// Configure U8glib fonts
99
//
10+
#ifndef U8G2_FONT_TABLE_EXTRA
11+
//
1012
// Add a U8G2_FONT_TABLE_ENTRY for each font you want to compile into the image
1113
#define U8G2_FONT_TABLE \
1214
U8G2_FONT_TABLE_ENTRY(font_6x10_tf) \
1315
U8G2_FONT_TABLE_ENTRY(font_unifont_t_symbols) \
16+
17+
#else
1418
//
19+
// The font table can be defined in an external file.
20+
#define U8G2_FONT_TABLE \
21+
U8G2_FONT_TABLE_EXTRA
22+
23+
#endif
1524
// ***************************************************************************
1625

1726

docs/en/modules/u8g2.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ Add the desired entries to the I²C or SPI display tables in [app/include/u8g2_d
8080
U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_pcf8812_96x65_f, pcf8812_96x65) \
8181
```
8282
83+
Alternatively, you can define them as `U8G2_DISPLAY_TABLE_I2C_EXTRA` and `U8G2_DISPLAY_TABLE_SPI_EXTRA` in an external file to avoid changing the source tree. Include the extra file on the `make` command line:
84+
```
85+
make EXTRA_CCFLAGS='-include $(TOP_DIR)/my_extras.h'
86+
```
87+
8388
#### ESP32
8489
Enable the desired entries for I²C and SPI displays in u8g2's sub-menu (run `make menuconfig`).
8590

@@ -96,6 +101,11 @@ Add the desired fonts to the font table in [app/include/u8g2_fonts.h](../../../a
96101
U8G2_FONT_TABLE_ENTRY(font_unifont_t_symbols) \
97102
```
98103
104+
Alternatively, you can define this as `U8G2_FONT_TABLE_EXTRA` in an external file to avoid changing the source tree. Include the extra file on the `make` command line:
105+
```
106+
make EXTRA_CCFLAGS='-include $(TOP_DIR)/my_extras.h'
107+
```
108+
99109
#### ESP32
100110
Add the desired fonts to the font selection sub-entry via `make menuconfig`.
101111

0 commit comments

Comments
 (0)