Telemetry screen cosmetics

This commit is contained in:
Bertrand Songis
2019-08-29 11:51:11 +02:00
parent fa0ffd6d42
commit 3f9a863b00
9 changed files with 70 additions and 46 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ class FlightModeGroup: public FormGroup
{ {
} }
void checkEvents() void checkEvents() override
{ {
FormGroup::checkEvents(); FormGroup::checkEvents();
bool newActive = (getFlightMode() == index); bool newActive = (getFlightMode() == index);
+2 -2
View File
@@ -26,7 +26,7 @@
class OutputEditWindow : public Page { class OutputEditWindow : public Page {
public: public:
OutputEditWindow(uint8_t channel) : explicit OutputEditWindow(uint8_t channel) :
Page(ICON_MODEL_OUTPUTS), Page(ICON_MODEL_OUTPUTS),
channel(channel) channel(channel)
{ {
@@ -118,7 +118,7 @@ class OutputLineButton : public Button {
} }
} }
virtual void paint(BitmapBuffer * dc) override void paint(BitmapBuffer * dc) override
{ {
// first line // first line
drawNumber(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, output->min - 1000, PREC1); drawNumber(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, output->min - 1000, PREC1);
+16 -4
View File
@@ -413,7 +413,7 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
new StaticText(window, grid.getLabelSlot(true), STR_CRITICALALARM); new StaticText(window, grid.getLabelSlot(true), STR_CRITICALALARM);
edit = new NumberEdit(window, grid.getFieldSlot(), -30, 30, GET_SET_DEFAULT(g_model.rssiAlarms.critical)); edit = new NumberEdit(window, grid.getFieldSlot(), -30, 30, GET_SET_DEFAULT(g_model.rssiAlarms.critical));
edit->setDisplayHandler([](BitmapBuffer * dc, LcdFlags flags, int32_t value) { edit->setDisplayHandler([](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
drawNumber(dc, 2, 2, g_model.rssiAlarms.getCriticalRssi(), flags); drawNumber(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, g_model.rssiAlarms.getCriticalRssi(), flags);
}); });
grid.nextLine(); grid.nextLine();
@@ -424,9 +424,15 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
// Sensors // Sensors
grid.setLabelWidth(140); grid.setLabelWidth(140);
new Subtitle(window, grid.getLineSlot(), STR_TELEMETRY_SENSORS); new Subtitle(window, grid.getLineSlot(), STR_TELEMETRY_SENSORS);
// Sensors columns titles
uint8_t sensorsCount = getTelemetrySensorsCount();
if (sensorsCount > 0) {
new StaticText(window, {SENSOR_COL2, grid.getWindowHeight() + 3, SENSOR_COL3 - SENSOR_COL2, PAGE_LINE_HEIGHT}, STR_VALUE, SMLSIZE | TEXT_DISABLE_COLOR); new StaticText(window, {SENSOR_COL2, grid.getWindowHeight() + 3, SENSOR_COL3 - SENSOR_COL2, PAGE_LINE_HEIGHT}, STR_VALUE, SMLSIZE | TEXT_DISABLE_COLOR);
if (!g_model.ignoreSensorIds && !IS_SPEKTRUM_PROTOCOL()) if (!g_model.ignoreSensorIds && !IS_SPEKTRUM_PROTOCOL())
new StaticText(window, {SENSOR_COL3, grid.getWindowHeight() + 3, LCD_W - SENSOR_COL3, PAGE_LINE_HEIGHT}, STR_ID, SMLSIZE | TEXT_DISABLE_COLOR); new StaticText(window, {SENSOR_COL3, grid.getWindowHeight() + 3, LCD_W - SENSOR_COL3, PAGE_LINE_HEIGHT}, STR_ID, SMLSIZE | TEXT_DISABLE_COLOR);
}
grid.nextLine(); grid.nextLine();
for (uint8_t idx = 0; idx < MAX_TELEMETRY_SENSORS; idx++) { for (uint8_t idx = 0; idx < MAX_TELEMETRY_SENSORS; idx++) {
@@ -467,8 +473,12 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
} }
} }
grid.setLabelWidth(250);
// Autodiscover button // Autodiscover button
auto discover = new TextButton(window, grid.getLineSlot(), STR_DISCOVER_SENSORS); auto rect = grid.getLabelSlot(true);
rect.w -= MENUS_MARGIN_LEFT;
auto discover = new TextButton(window, rect, STR_DISCOVER_SENSORS);
discover->setPressHandler([=]() { discover->setPressHandler([=]() {
allowNewSensors = !allowNewSensors; allowNewSensors = !allowNewSensors;
if (allowNewSensors) { if (allowNewSensors) {
@@ -480,10 +490,9 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
return 0; return 0;
} }
}); });
grid.nextLine();
// New sensor button // New sensor button
new TextButton(window, grid.getLineSlot(), STR_TELEMETRY_NEWSENSOR, new TextButton(window, grid.getFieldSlot(), STR_TELEMETRY_NEWSENSOR,
[=]() -> uint8_t { [=]() -> uint8_t {
int idx = availableTelemetryIndex(); int idx = availableTelemetryIndex();
if (idx >= 0) if (idx >= 0)
@@ -494,6 +503,7 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
}); });
grid.nextLine(); grid.nextLine();
if (sensorsCount > 0) {
// Delete all sensors button // Delete all sensors button
new TextButton(window, grid.getLineSlot(), STR_DELETE_ALL_SENSORS, new TextButton(window, grid.getLineSlot(), STR_DELETE_ALL_SENSORS,
[]() -> uint8_t { []() -> uint8_t {
@@ -505,6 +515,7 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
return 0; return 0;
}); });
grid.nextLine(); grid.nextLine();
}
// Ignore instance button // Ignore instance button
new StaticText(window, grid.getLabelSlot(true), STR_IGNORE_INSTANCE); new StaticText(window, grid.getLabelSlot(true), STR_IGNORE_INSTANCE);
@@ -540,5 +551,6 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
grid.nextLine(); grid.nextLine();
window->setLastField();
window->setInnerHeight(grid.getWindowHeight()); window->setInnerHeight(grid.getWindowHeight());
} }
+1 -1
View File
@@ -29,7 +29,7 @@ class RadioToolsPage: public PageTab {
void checkEvents() override; void checkEvents() override;
protected: protected:
void rebuild(FormWindow * window); static void rebuild(FormWindow * window);
FormWindow * window = nullptr; FormWindow * window = nullptr;
uint8_t waiting = 0; uint8_t waiting = 0;
}; };
+11
View File
@@ -121,6 +121,17 @@ bool isTelemetryFieldAvailable(int index)
return sensor.isAvailable(); return sensor.isAvailable();
} }
uint8_t getTelemetrySensorsCount()
{
uint8_t count = 0;
for (auto telemetrySensor : g_model.telemetrySensors) {
if (telemetrySensor.isAvailable()) {
++count;
}
}
return count;
}
bool isTelemetryFieldComparisonAvailable(int index) bool isTelemetryFieldComparisonAvailable(int index)
{ {
if (!isTelemetryFieldAvailable(index)) if (!isTelemetryFieldAvailable(index))
+1
View File
@@ -89,6 +89,7 @@ bool isAltSensor(int sensor);
bool isVoltsSensor(int sensor); bool isVoltsSensor(int sensor);
bool isCurrentSensor(int sensor); bool isCurrentSensor(int sensor);
bool isTelemetryFieldAvailable(int index); bool isTelemetryFieldAvailable(int index);
uint8_t getTelemetrySensorsCount();
bool isTelemetryFieldComparisonAvailable(int index); bool isTelemetryFieldComparisonAvailable(int index);
bool isSensorAvailable(int sensor); bool isSensorAvailable(int sensor);
bool isRssiSensorAvailable(int sensor); bool isRssiSensorAvailable(int sensor);
+6 -6
View File
@@ -494,7 +494,7 @@ void hallStick_GetTxDataFromUSB( void )
break; break;
case TRANSFER_DIR_HALLSTICK: case TRANSFER_DIR_HALLSTICK:
onFlySkyUsbDownloadStart(TRANSFER_DIR_HALLSTICK); // onFlySkyUsbDownloadStart(TRANSFER_DIR_HALLSTICK);
if ( 0xA2 == HallProtocolTx.hallID.ID ) if ( 0xA2 == HallProtocolTx.hallID.ID )
{ {
@@ -513,17 +513,17 @@ void hallStick_GetTxDataFromUSB( void )
break; break;
case TRANSFER_DIR_RFMODULE: case TRANSFER_DIR_RFMODULE:
onFlySkyUsbDownloadStart(TRANSFER_DIR_RFMODULE); // onFlySkyUsbDownloadStart(TRANSFER_DIR_RFMODULE);
if ( 0xAE == HallProtocolTx.hallID.ID && HallProtocolTx.length == 0 ) if ( 0xAE == HallProtocolTx.hallID.ID && HallProtocolTx.length == 0 )
{ // 55 AE 00 D3 47 { // 55 AE 00 D3 47
onIntmoduleUsbDownloadStart(INTERNAL_MODULE); // onIntmoduleUsbDownloadStart(INTERNAL_MODULE);
break; break;
} }
//if ( isFlySkyUsbDownload() ) //if ( isFlySkyUsbDownload() )
{ {
intmoduleSendBufferDMA( pt, HallProtocolTx.length + 3 + 2 ); // intmoduleSendBufferDMA( pt, HallProtocolTx.length + 3 + 2 );
} }
break; break;
} }
@@ -532,7 +532,7 @@ void hallStick_GetTxDataFromUSB( void )
if ( !usbPlugged() ) if ( !usbPlugged() )
{ {
onFlySkyUsbDownloadStart(0); // onFlySkyUsbDownloadStart(0);
} }
} }
@@ -586,7 +586,7 @@ void hall_stick_loop(void)
//TRACE("HALL: %02X %02X %02X ...%04X", pt[0], pt[1], pt[2], HallProtocol.checkSum); //TRACE("HALL: %02X %02X %02X ...%04X", pt[0], pt[1], pt[2], HallProtocol.checkSum);
pt[HallProtocol.length + 3] = HallProtocol.checkSum & 0xFF; pt[HallProtocol.length + 3] = HallProtocol.checkSum & 0xFF;
pt[HallProtocol.length + 4] = HallProtocol.checkSum >> 8; pt[HallProtocol.length + 4] = HallProtocol.checkSum >> 8;
usbDownloadTransmit( pt, HallProtocol.length + 5 ); // usbDownloadTransmit( pt, HallProtocol.length + 5 );
break; break;
} }
//printf_log_now = 1; //printf_log_now = 1;
+1 -1
View File
@@ -51,7 +51,7 @@ uint32_t readTrims()
return result; return result;
} }
uint8_t trimDown(uint8_t idx) bool trimDown(uint8_t idx)
{ {
return readTrims() & (1 << idx); return readTrims() & (1 << idx);
} }
+1 -1
View File
@@ -90,7 +90,7 @@ void pwrOff()
GPIO_ResetBits(PWR_GPIO, PWR_ON_GPIO_PIN); GPIO_ResetBits(PWR_GPIO, PWR_ON_GPIO_PIN);
} }
uint32_t pwrPressed() bool pwrPressed()
{ {
return GPIO_ReadInputDataBit(PWR_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET; return GPIO_ReadInputDataBit(PWR_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
} }