Forráskód Böngészése

allow definition of font and display tables in an external file

devsaurus 6 éve
szülő
commit
eba5d57db7
3 módosított fájl, 41 hozzáadás és 1 törlés
  1. 22 1
      app/include/u8g2_displays.h
  2. 9 0
      app/include/u8g2_fonts.h
  3. 10 0
      docs/en/modules/u8g2.md

+ 22 - 1
app/include/u8g2_displays.h

@@ -10,7 +10,9 @@
 // Uncomment the U8G2_DISPLAY_TABLE_ENTRY for the device(s) you want to
 // compile into the firmware.
 // Stick to the assignments to *_I2C and *_SPI tables.
-//
+
+#ifndef U8G2_DISPLAY_TABLE_I2C_EXTRA
+
 // I2C based displays go into here:
 //  U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1610_i2c_ea_dogxl160_f, uc1610_i2c_ea_dogxl160) \
 //  U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1325_i2c_nhd_128x64_f, ssd1325_i2c_nhd_128x64) \
@@ -38,6 +40,17 @@
 #define U8G2_DISPLAY_TABLE_I2C \
   U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x64_noname_f, ssd1306_i2c_128x64_noname) \
 
+#else
+
+// I2C displays can be defined in an external file. 
+#define U8G2_DISPLAY_TABLE_I2C \
+   U8G2_DISPLAY_TABLE_I2C_EXTRA
+
+#endif
+
+
+#ifndef U8G2_DISPLAY_TABLE_SPI_EXTRA
+
 // SPI based displays go into here:
 //  U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1606_172x72_f, ssd1606_172x72) \
 //  U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_240x128_f, uc1608_240x128) \
@@ -93,6 +106,14 @@
 #define U8G2_DISPLAY_TABLE_SPI \
   U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x64_noname_f, ssd1306_128x64_noname) \
 
+#else
+
+// SPI displays can be defined in an external file. 
+#define U8G2_DISPLAY_TABLE_SPI \
+   U8G2_DISPLAY_TABLE_SPI_EXTRA
+
+#endif
+
 //
 // ***************************************************************************
 

+ 9 - 0
app/include/u8g2_fonts.h

@@ -7,11 +7,20 @@
 // ***************************************************************************
 // Configure U8glib fonts
 //
+#ifndef U8G2_FONT_TABLE_EXTRA
+//
 // Add a U8G2_FONT_TABLE_ENTRY for each font you want to compile into the image
 #define U8G2_FONT_TABLE \
   U8G2_FONT_TABLE_ENTRY(font_6x10_tf) \
   U8G2_FONT_TABLE_ENTRY(font_unifont_t_symbols) \
+
+#else
 //
+// The font table can be defined in an external file. 
+#define U8G2_FONT_TABLE \
+  U8G2_FONT_TABLE_EXTRA
+
+#endif
 // ***************************************************************************
 
 

+ 10 - 0
docs/en/modules/u8g2.md

@@ -80,6 +80,11 @@ Add the desired entries to the I²C or SPI display tables in [app/include/u8g2_d
   U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_pcf8812_96x65_f, pcf8812_96x65) \
 ```
 
+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:
+```
+make EXTRA_CCFLAGS='-include $(TOP_DIR)/my_extras.h'
+```
+
 #### ESP32
 Enable the desired entries for I²C and SPI displays in u8g2's sub-menu (run `make menuconfig`).
 
@@ -96,6 +101,11 @@ Add the desired fonts to the font table in [app/include/u8g2_fonts.h](../../../a
   U8G2_FONT_TABLE_ENTRY(font_unifont_t_symbols) \
 ```
 
+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:
+```
+make EXTRA_CCFLAGS='-include $(TOP_DIR)/my_extras.h'
+```
+
 #### ESP32
 Add the desired fonts to the font selection sub-entry via `make menuconfig`.