feat(radio): refactor of switch handling to better support customisable switches (#6095)
Co-authored-by: philmoz <phil.a.mitchell@gmail.com> Co-authored-by: 3djc <3djc@gh.com> Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
co-authored by
philmoz
3djc
elecpower
parent
28833f42e6
commit
0c8c39b134
@@ -30,6 +30,7 @@
|
||||
#include "hal/adc_driver.h"
|
||||
#include "hal/rotary_encoder.h"
|
||||
#include "os/time.h"
|
||||
#include "boards/generic_stm32/rgb_leds.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QElapsedTimer>
|
||||
@@ -90,6 +91,16 @@ void firmwareTraceCb(const char * text)
|
||||
}
|
||||
}
|
||||
|
||||
void fsLedOn(uint8_t idx)
|
||||
{
|
||||
rgbSetLedColor(idx, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
|
||||
void fsLedOff(uint8_t idx)
|
||||
{
|
||||
rgbSetLedColor(idx, 0, 0, 0);
|
||||
}
|
||||
|
||||
// Serial port handling needs to know about OpenTxSimulator, so we we
|
||||
// need to update what's in simpgmspace.cpp when we have a simulator
|
||||
// to point at.
|
||||
@@ -751,6 +762,7 @@ void OpenTxSimulator::run()
|
||||
++loops;
|
||||
|
||||
checkLcdChanged();
|
||||
checkFuncSwitchChanged();
|
||||
|
||||
if (!(loops % 5)) {
|
||||
checkOutputsChanged();
|
||||
@@ -783,6 +795,19 @@ bool OpenTxSimulator::checkLcdChanged()
|
||||
return false;
|
||||
}
|
||||
|
||||
void OpenTxSimulator::checkFuncSwitchChanged()
|
||||
{
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
for (int i = 0; i < CPN_MAX_SWITCHES; i += 1) {
|
||||
if (switchIsCustomSwitch(i)) {
|
||||
uint8_t cfs = switchGetCustomSwitchIdx(i);
|
||||
uint32_t c = rgbGetLedColor(cfs);
|
||||
emit fsColorChange(i, c);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenTxSimulator::checkOutputsChanged()
|
||||
{
|
||||
static TxOutputs lastOutputs;
|
||||
|
||||
Reference in New Issue
Block a user