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();
bool newActive = (getFlightMode() == index);
+2 -2
View File
@@ -26,7 +26,7 @@
class OutputEditWindow : public Page {
public:
OutputEditWindow(uint8_t channel) :
explicit OutputEditWindow(uint8_t channel) :
Page(ICON_MODEL_OUTPUTS),
channel(channel)
{
@@ -118,7 +118,7 @@ class OutputLineButton : public Button {
}
}
virtual void paint(BitmapBuffer * dc) override
void paint(BitmapBuffer * dc) override
{
// first line
drawNumber(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, output->min - 1000, PREC1);
+46 -34
View File
@@ -140,23 +140,23 @@ class SensorEditWindow : public Page {
new StaticText(sensorOneWindow, grid.getLabelSlot(), STR_FORMULA);
new Choice(sensorOneWindow, grid.getFieldSlot(), STR_VFORMULAS, 0, TELEM_FORMULA_LAST, GET_DEFAULT(sensor->formula),
[=](uint8_t newValue) {
sensor->formula = newValue;
sensor->param = 0;
if (sensor->formula == TELEM_FORMULA_CELL) {
sensor->unit = UNIT_VOLTS;
sensor->prec = 2;
}
else if (sensor->formula == TELEM_FORMULA_DIST) {
sensor->unit = UNIT_DIST;
sensor->prec = 0;
}
else if (sensor->formula == TELEM_FORMULA_CONSUMPTION) {
sensor->unit = UNIT_MAH;
sensor->prec = 0;
}
SET_DIRTY();
telemetryItems[index].clear();
updateSensorOneWindow();
sensor->formula = newValue;
sensor->param = 0;
if (sensor->formula == TELEM_FORMULA_CELL) {
sensor->unit = UNIT_VOLTS;
sensor->prec = 2;
}
else if (sensor->formula == TELEM_FORMULA_DIST) {
sensor->unit = UNIT_DIST;
sensor->prec = 0;
}
else if (sensor->formula == TELEM_FORMULA_CONSUMPTION) {
sensor->unit = UNIT_MAH;
sensor->prec = 0;
}
SET_DIRTY();
telemetryItems[index].clear();
updateSensorOneWindow();
});
grid.nextLine();
}
@@ -413,7 +413,7 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
new StaticText(window, grid.getLabelSlot(true), STR_CRITICALALARM);
edit = new NumberEdit(window, grid.getFieldSlot(), -30, 30, GET_SET_DEFAULT(g_model.rssiAlarms.critical));
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();
@@ -424,9 +424,15 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
// Sensors
grid.setLabelWidth(140);
new Subtitle(window, grid.getLineSlot(), STR_TELEMETRY_SENSORS);
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())
new StaticText(window, {SENSOR_COL3, grid.getWindowHeight() + 3, LCD_W - SENSOR_COL3, PAGE_LINE_HEIGHT}, STR_ID, SMLSIZE | TEXT_DISABLE_COLOR);
// 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);
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);
}
grid.nextLine();
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
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([=]() {
allowNewSensors = !allowNewSensors;
if (allowNewSensors) {
@@ -480,10 +490,9 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
return 0;
}
});
grid.nextLine();
// New sensor button
new TextButton(window, grid.getLineSlot(), STR_TELEMETRY_NEWSENSOR,
new TextButton(window, grid.getFieldSlot(), STR_TELEMETRY_NEWSENSOR,
[=]() -> uint8_t {
int idx = availableTelemetryIndex();
if (idx >= 0)
@@ -494,17 +503,19 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
});
grid.nextLine();
// Delete all sensors button
new TextButton(window, grid.getLineSlot(), STR_DELETE_ALL_SENSORS,
[]() -> uint8_t {
new FullScreenDialog(WARNING_TYPE_CONFIRM, STR_CONFIRMDELETE, "", [=]() {
for (int i = 0; i < MAX_TELEMETRY_SENSORS; i++) {
delTelemetryIndex(i);
}
if (sensorsCount > 0) {
// Delete all sensors button
new TextButton(window, grid.getLineSlot(), STR_DELETE_ALL_SENSORS,
[]() -> uint8_t {
new FullScreenDialog(WARNING_TYPE_CONFIRM, STR_CONFIRMDELETE, "", [=]() {
for (int i = 0; i < MAX_TELEMETRY_SENSORS; i++) {
delTelemetryIndex(i);
}
});
return 0;
});
return 0;
});
grid.nextLine();
grid.nextLine();
}
// Ignore instance button
new StaticText(window, grid.getLabelSlot(true), STR_IGNORE_INSTANCE);
@@ -540,5 +551,6 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
grid.nextLine();
window->setLastField();
window->setInnerHeight(grid.getWindowHeight());
}
+1 -1
View File
@@ -29,7 +29,7 @@ class RadioToolsPage: public PageTab {
void checkEvents() override;
protected:
void rebuild(FormWindow * window);
static void rebuild(FormWindow * window);
FormWindow * window = nullptr;
uint8_t waiting = 0;
};
+11
View File
@@ -121,6 +121,17 @@ bool isTelemetryFieldAvailable(int index)
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)
{
if (!isTelemetryFieldAvailable(index))
+1
View File
@@ -89,6 +89,7 @@ bool isAltSensor(int sensor);
bool isVoltsSensor(int sensor);
bool isCurrentSensor(int sensor);
bool isTelemetryFieldAvailable(int index);
uint8_t getTelemetrySensorsCount();
bool isTelemetryFieldComparisonAvailable(int index);
bool isSensorAvailable(int sensor);
bool isRssiSensorAvailable(int sensor);
+6 -6
View File
@@ -494,7 +494,7 @@ void hallStick_GetTxDataFromUSB( void )
break;
case TRANSFER_DIR_HALLSTICK:
onFlySkyUsbDownloadStart(TRANSFER_DIR_HALLSTICK);
// onFlySkyUsbDownloadStart(TRANSFER_DIR_HALLSTICK);
if ( 0xA2 == HallProtocolTx.hallID.ID )
{
@@ -513,17 +513,17 @@ void hallStick_GetTxDataFromUSB( void )
break;
case TRANSFER_DIR_RFMODULE:
onFlySkyUsbDownloadStart(TRANSFER_DIR_RFMODULE);
// onFlySkyUsbDownloadStart(TRANSFER_DIR_RFMODULE);
if ( 0xAE == HallProtocolTx.hallID.ID && HallProtocolTx.length == 0 )
{ // 55 AE 00 D3 47
onIntmoduleUsbDownloadStart(INTERNAL_MODULE);
// onIntmoduleUsbDownloadStart(INTERNAL_MODULE);
break;
}
//if ( isFlySkyUsbDownload() )
{
intmoduleSendBufferDMA( pt, HallProtocolTx.length + 3 + 2 );
// intmoduleSendBufferDMA( pt, HallProtocolTx.length + 3 + 2 );
}
break;
}
@@ -532,7 +532,7 @@ void hallStick_GetTxDataFromUSB( void )
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);
pt[HallProtocol.length + 3] = HallProtocol.checkSum & 0xFF;
pt[HallProtocol.length + 4] = HallProtocol.checkSum >> 8;
usbDownloadTransmit( pt, HallProtocol.length + 5 );
// usbDownloadTransmit( pt, HallProtocol.length + 5 );
break;
}
//printf_log_now = 1;
+1 -1
View File
@@ -51,7 +51,7 @@ uint32_t readTrims()
return result;
}
uint8_t trimDown(uint8_t idx)
bool trimDown(uint8_t idx)
{
return readTrims() & (1 << idx);
}
+1 -1
View File
@@ -90,7 +90,7 @@ void pwrOff()
GPIO_ResetBits(PWR_GPIO, PWR_ON_GPIO_PIN);
}
uint32_t pwrPressed()
bool pwrPressed()
{
return GPIO_ReadInputDataBit(PWR_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
}