diff --git a/code/main.c b/code/main.c index a4e9b28..ea33198 100644 --- a/code/main.c +++ b/code/main.c @@ -22,6 +22,7 @@ #define BATTERY_TEMP 8 #define BATTERY_MILLIOHM 30 +#define BATTERY_CAPACITY_MAH 2200 #define BATTERY_CHARGE_MULT 67 #define BATTERY_CHARGE_DIV (10 * BATTERY_MILLIOHM) @@ -1019,6 +1020,38 @@ void print_option(uint8_t option) void print_battery_icon() { +// Battery Percent +#if 0 + static uint8_t old_symbols[3] = {0xFF, 0xFF, 0xFF}; + uint32_t percent = BATTERY_CAPACITY_MAH; + uint8_t i; + uint8_t symbol; + uint8_t is_first = 1; + + // Calculate percent + percent -= battery_mAh; + percent *= 100; + percent /= BATTERY_CAPACITY_MAH; + + // Print percent top to bot + for (i = 3; i > 0; --i) + { + symbol = extract_digit(percent, i); + if ((0 == symbol) && (is_first) && (i != 1)) + { + symbol = 0xFF; + } + + // 3,2,1 -> 1,2,3 + if (symbol != old_symbols[3 - i + 1]) + { + print_symbol(symbol, OLED_X_SIZE - (CHAR_SIZE + 1) * 2, 3 - i + 1, 0); + old_symbols[3 - i + 1] = symbol; + } + } +#endif + +// EEPROM IDX #if 0 uint32_t idx = (uint32_t) eeprom_idx; @@ -1029,6 +1062,7 @@ void print_battery_icon() } #endif +// Graphic Icon #if 0 static uint8_t old_percent = 0xFF; uint8_t buf[BUFF_SIZE];