Re #2671: fixes difference between top and main LCD TX battery bars, code made more readable with macros

This commit is contained in:
Damjan Adamic
2015-08-17 13:55:41 +02:00
committed by Bertrand Songis
parent 00a5437dde
commit 5b4f0a0bbb
9 changed files with 29 additions and 23 deletions
+1 -1
View File
@@ -587,7 +587,7 @@ void drawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat, Lc
void lcdDrawTelemetryTopBar()
{
putsModelName(0, 0, g_model.header.name, g_eeGeneral.currModel, 0);
uint8_t att = (g_vbat100mV < g_eeGeneral.vBatWarn ? BLINK : 0);
uint8_t att = (IS_TXBATT_WARNING() ? BLINK : 0);
putsVBat(14*FW,0,att);
if (g_model.timers[0].mode) {
att = (timersStates[0].val<0 ? BLINK : 0);
+8 -8
View File
@@ -208,13 +208,13 @@ void displayBattVoltage()
putsVBat(VBATT_X-8, VBATT_Y+1, 0);
drawFilledRect(VBATT_X-25, VBATT_Y+9, 22, 5);
lcd_vline(VBATT_X-3, VBATT_Y+10, 3);
uint8_t count = limit<uint8_t>(2, 20 * (g_vbat100mV - g_eeGeneral.vBatMin - 90) / (30 + g_eeGeneral.vBatMax - g_eeGeneral.vBatMin), 20);
uint8_t count = GET_TXBATT_BARS();
for (uint8_t i=0; i<count; i+=2)
lcd_vline(VBATT_X-24+i, VBATT_Y+10, 3);
if (g_vbat100mV > g_eeGeneral.vBatWarn || BLINK_ON_PHASE)
if (!IS_TXBATT_WARNING() || BLINK_ON_PHASE)
drawFilledRect(VBATT_X-26, VBATT_Y, 25, 15);
#else
LcdFlags att = (g_vbat100mV <= g_eeGeneral.vBatWarn ? BLINK|INVERS : 0) | BIGSIZE;
LcdFlags att = (IS_TXBATT_WARNING() ? BLINK|INVERS : 0) | BIGSIZE;
putsVBat(VBATT_X-1, VBATT_Y, att|NO_UNIT);
lcd_putc(VBATT_X, VBATTUNIT_Y, 'V');
#endif
@@ -223,15 +223,15 @@ void displayBattVoltage()
#if defined(PCBSKY9X)
void displayVoltageOrAlarm()
{
if (g_vbat100mV > g_eeGeneral.vBatWarn && g_eeGeneral.temperatureWarn && getTemperature() >= g_eeGeneral.temperatureWarn) {
if (IS_TXBATT_WARNING()) {
displayBattVoltage();
}
else if (g_eeGeneral.temperatureWarn && getTemperature() >= g_eeGeneral.temperatureWarn) {
putsValueWithUnit(6*FW-1, 2*FH, getTemperature(), UNIT_TEMPERATURE, BLINK|INVERS|DBLSIZE);
}
else if (g_vbat100mV > g_eeGeneral.vBatWarn && g_eeGeneral.mAhWarn && (g_eeGeneral.mAhUsed + Current_used * (488 + g_eeGeneral.currentCalib)/8192/36) / 500 >= g_eeGeneral.mAhWarn) {
else if (g_eeGeneral.mAhWarn && (g_eeGeneral.mAhUsed + Current_used * (488 + g_eeGeneral.currentCalib)/8192/36) / 500 >= g_eeGeneral.mAhWarn) {
putsValueWithUnit(7*FW-1, 2*FH, (g_eeGeneral.mAhUsed + Current_used*(488 + g_eeGeneral.currentCalib)/8192/36)/10, UNIT_MAH, BLINK|INVERS|DBLSIZE);
}
else {
displayBattVoltage();
}
}
#else
#define displayVoltageOrAlarm() displayBattVoltage()
+1 -1
View File
@@ -547,7 +547,7 @@ void drawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat, Lc
void lcdDrawTelemetryTopBar()
{
putsModelName(0, 0, g_model.header.name, g_eeGeneral.currModel, 0);
uint8_t att = (g_vbat100mV < g_eeGeneral.vBatWarn ? BLINK : 0);
uint8_t att = (IS_TXBATT_WARNING() ? BLINK : 0);
putsVBat(16*FW+1,0,att);
if (g_model.timers[0].mode) {
att = (timersStates[0].val<0 ? BLINK : 0);
+1 -3
View File
@@ -209,7 +209,6 @@ void displayTopBarGauge(coord_t x, int count, bool blinking=false)
{
if (!blinking || BLINK_ON_PHASE)
drawFilledRect(x+1, BAR_Y+2, 11, 5, SOLID, ERASE);
count = min(10, count);
for (int i=0; i<count; i+=2)
lcd_vline(x+2+i, BAR_Y+3, 3);
}
@@ -300,8 +299,7 @@ void displayTopBar()
drawFilledRect(BAR_X, BAR_Y, BAR_W, BAR_H, SOLID, FILL_WHITE|GREY(12)|ROUND);
/* The inside of the Batt gauge */
int count = 10 * (g_vbat100mV - g_eeGeneral.vBatMin - 90) / (30 + g_eeGeneral.vBatMax - g_eeGeneral.vBatMin);
displayTopBarGauge(batt_icon_x+FW, count, g_vbat100mV <= g_eeGeneral.vBatWarn);
displayTopBarGauge(batt_icon_x+FW, GET_TXBATT_BARS(), IS_TXBATT_WARNING());
/* The inside of the RSSI gauge */
if (TELEMETRY_RSSI() > 0) {