draw degrees C or F
This commit is contained in:
parent
bee70b76b9
commit
288aa914e9
@ -262,6 +262,8 @@ static const uint8_t seg_right_xbm[] = {0x02,0x03,0x03,0x03,0x03,0x02};
|
||||
static const uint8_t seg_top_xbm[] = {0x3f,0x1e};
|
||||
static const uint8_t seg_bot_xbm[] = {0x1e,0x3f};
|
||||
static const uint8_t seg_center_xbm[] = {0x1e,0x3f,0x1e};
|
||||
static const uint8_t image_degc_xbm[] = {0x02,0x05,0x1a,0x24,0x04,0x04,0x24,0x18};
|
||||
static const uint8_t image_degf_xbm[] = {0x02,0x05,0x3a,0x08,0x18,0x08,0x08,0x08};
|
||||
|
||||
static void draw_7seg(u8g2_t *u8g2, uint8_t x, uint8_t y, uint8_t n)
|
||||
{
|
||||
@ -341,11 +343,12 @@ static void draw_7seg(u8g2_t *u8g2, uint8_t x, uint8_t y, uint8_t n)
|
||||
}
|
||||
|
||||
|
||||
void draw_temp(u8g2_t *u8g2, uint8_t x, uint8_t y, int16_t temp)
|
||||
void draw_temp(u8g2_t *u8g2, uint8_t x, uint8_t y, int16_t temp, bool degc)
|
||||
{
|
||||
if (temp > 999 || temp < 0) temp = 0;
|
||||
const char *s = u8x8_u16toa(temp, 3);
|
||||
draw_7seg(u8g2, x+0, y+0, s[0]-'0');
|
||||
draw_7seg(u8g2, x+9, y+0, s[1]-'0');
|
||||
draw_7seg(u8g2, x+18, y+0, s[2]-'0');
|
||||
u8g2_DrawXBM(u8g2, x+27, y+8, 6, 8, degc ? image_degc_xbm : image_degf_xbm);
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ const char* i16toa(int16_t value);
|
||||
const char* u16toa(uint16_t value);
|
||||
int buf_putc(char c);
|
||||
const char* buf_get(void);
|
||||
void draw_temp(u8g2_t *u8g2, uint8_t x, uint8_t y, int16_t temp);
|
||||
void draw_temp(u8g2_t *u8g2, uint8_t x, uint8_t y, int16_t temp, bool degc);
|
||||
|
||||
|
||||
#endif // _DISPLAY_H
|
||||
|
||||
@ -596,14 +596,14 @@ __attribute__((noreturn)) int main(void)
|
||||
u8g2_DrawStr(u8g2, x_off+45, y_off+15, "W:");
|
||||
u8g2_DrawStr(u8g2, x_off+55, y_off+15, u16toa(power));
|
||||
#else
|
||||
draw_temp(u8g2, x_off+0, y_off+0, tip_temp_c);
|
||||
draw_temp(u8g2, x_off+0, y_off+0, tip_temp_c, true);
|
||||
u8g2_DrawStr(u8g2, x_off+32, y_off+6, "W:");
|
||||
u8g2_DrawStr(u8g2, x_off+42, y_off+6, u16toa(power));
|
||||
u8g2_DrawStr(u8g2, x_off+60, y_off+6, "V:");
|
||||
u8g2_DrawStr(u8g2, x_off+70, y_off+6, u16toa((vbus_mv+500)/1000));
|
||||
uint8_t p = (power*100)/pd_profile.set_power;
|
||||
uint8_t w = (uint16_t)(p*64)/100;
|
||||
u8g2_DrawBox(u8g2, x_off+32, y_off+14, w, 5);
|
||||
uint8_t w = (uint16_t)(p*54)/100;
|
||||
u8g2_DrawBox(u8g2, x_off+42, y_off+14, w, 5);
|
||||
#endif
|
||||
|
||||
if (enabled) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user