diff --git a/fw/Makefile b/fw/Makefile index 58e37a6..b914619 100644 --- a/fw/Makefile +++ b/fw/Makefile @@ -6,8 +6,8 @@ TARGET_MCU_PACKAGE := CH32X035F8U6 # include u8g2 U8G2_DIR:=u8g2/csrc -# U8G2_SRC:=u8g2/csrc/u8x8_d_ssd1312.c $(filter-out $(U8G2_DIR)/u8x8_d_%.c, $(wildcard $(U8G2_DIR)/*.c)) -U8G2_SRC:=u8g2/csrc/u8x8_d_ssd1306_128x32.c $(filter-out $(U8G2_DIR)/u8x8_d_%.c, $(wildcard $(U8G2_DIR)/*.c)) +U8G2_SRC:=u8g2/csrc/u8x8_d_ssd1312.c $(filter-out $(U8G2_DIR)/u8x8_d_%.c, $(wildcard $(U8G2_DIR)/*.c)) +# U8G2_SRC:=u8g2/csrc/u8x8_d_ssd1306_128x32.c $(filter-out $(U8G2_DIR)/u8x8_d_%.c, $(wildcard $(U8G2_DIR)/*.c)) EXTRA_CFLAGS += -I$(U8G2_DIR) diff --git a/fw/display.c b/fw/display.c index 7299060..d0f7844 100644 --- a/fw/display.c +++ b/fw/display.c @@ -165,7 +165,7 @@ u8g2_t* display_init(void) u8g2_Setup_ssd1306_i2c_128x32_univision_f(&u8g2, U8G2_R0, u8x8_byte_i2c, u8x8_gpio_and_delay); #elif SSD1312_96X16 && SSD1312_96X16 == 1 // NOTE: display size is wrong, hardware is 96x16, but driver is configured for 120x28 - u8g2_Setup_ssd1312_i2c_120x28_f(&u8g2, U8G2_R0, u8x8_byte_i2c, u8x8_gpio_and_delay); + u8g2_Setup_ssd1312_i2c_128x32_f(&u8g2, U8G2_R0, u8x8_byte_i2c, u8x8_gpio_and_delay); #else static_assert(0, "unsupported display size"); #endif diff --git a/fw/display.h b/fw/display.h index 1e74fb7..635f4da 100644 --- a/fw/display.h +++ b/fw/display.h @@ -3,8 +3,8 @@ #include -#define SSD1306_128X32 1 -// #define SSD1312_96X16 1 +// #define SSD1306_128X32 1 +#define SSD1312_96X16 1 #define PIN_DISP_RST PA7 // display reset u8g2_t* display_init(void); diff --git a/fw/main.c b/fw/main.c index c390a3e..725ee53 100644 --- a/fw/main.c +++ b/fw/main.c @@ -6,6 +6,7 @@ #include "lib_i2c.h" #include "display.h" #include "filter.h" +#include "u8g2.h" // Pin definitions @@ -215,18 +216,17 @@ __attribute__((noreturn)) int main(void) u8g2_SetBitmapMode(u8g2, 1); u8g2_SetFontMode(u8g2, 1); u8g2_SetFont(u8g2, u8g2_font_5x8_tr); - u8g2_DrawStr(u8g2, 0, 7, "TIP:"); - u8g2_DrawStr(u8g2, 20, 7, u8x8_u16toa(tip_mv, 4)); - u8g2_DrawStr(u8g2, 0, 15, "VBUS:"); - u8g2_DrawStr(u8g2, 25, 15, u8x8_u16toa(vbus_mv, 4)); - u8g2_DrawLine(u8g2, 62, 19, 62, 0); - u8g2_DrawStr(u8g2, 71, 6, "TEMP:"); - u8g2_DrawStr(u8g2, 96, 6, u8x8_u16toa(temp_k, 2)); - u8g2_DrawFrame(u8g2, 0, 22, 128, 10); - encoder = encoder < -61 ? -61 : (encoder > 61 ? 61 : encoder); - u8g2_DrawBox(u8g2, 61+encoder, 23, 4, 8); +#define x_off 0 +#define y_off 8 + u8g2_DrawStr(u8g2, x_off+0, y_off+7, "TIP:"); + u8g2_DrawStr(u8g2, x_off+20, y_off+7, u8x8_u16toa(tip_mv, 4)); + u8g2_DrawStr(u8g2, x_off+0, y_off+15, "VBUS:"); + u8g2_DrawStr(u8g2, x_off+25, y_off+15, u8x8_u16toa(vbus_mv, 4)); + u8g2_DrawStr(u8g2, x_off+51, y_off+7, "TEMP:"); + u8g2_DrawStr(u8g2, x_off+75, y_off+7, u8x8_u16toa(temp_k, 2)); u8g2_SendBuffer(u8g2); + printf("VBUS=%d, CURRENT=%d, TEMP=%d, TIP=%d, COUNTER=%d\n", vbus_mv, current_ma, temp_k, tip_mv, encoder); u32 elapsed = funSysTick32() - start;