feat(simu): add support for (RGB!!) customisable switches (#6129)
This commit is contained in:
+54
-1
@@ -74,6 +74,7 @@ class OpenTxSim: public FXMainWindow
|
||||
void doEvents();
|
||||
void refreshDisplay();
|
||||
void setPixel(int x, int y, FXColor color);
|
||||
void fsLedRGB(uint8_t idx, uint32_t color);
|
||||
|
||||
private:
|
||||
FXImage * bmp;
|
||||
@@ -82,6 +83,9 @@ class OpenTxSim: public FXMainWindow
|
||||
public:
|
||||
FXSlider * sliders[MAX_STICKS];
|
||||
FXKnob * knobs[MAX_POTS];
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
FXButton * fctButtons[NUM_FUNCTIONS_SWITCHES] = {0};
|
||||
#endif
|
||||
};
|
||||
|
||||
// Message Map
|
||||
@@ -109,6 +113,9 @@ OpenTxSim::OpenTxSim(FXApp* a):
|
||||
#endif
|
||||
|
||||
FXHorizontalFrame * hf11 = new FXHorizontalFrame(this, LAYOUT_CENTER_X);
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
FXHorizontalFrame * hf12 = new FXHorizontalFrame(this, LAYOUT_CENTER_X);
|
||||
#endif
|
||||
FXHorizontalFrame * hf1 = new FXHorizontalFrame(this, LAYOUT_FILL_X);
|
||||
|
||||
//rh lv rv lh
|
||||
@@ -142,7 +149,7 @@ OpenTxSim::OpenTxSim(FXApp* a):
|
||||
knobs[i]->setRange(0, 4095);
|
||||
knobs[i]->setValue(2047);
|
||||
|
||||
#if defined(PCBHORUS)
|
||||
#if defined(PCBHORUS) && !defined(FUNCTION_SWITCHES)
|
||||
if (i == 1) { // 6-pos switch
|
||||
knobs[i]->setIncrement(4095 / 5);
|
||||
knobs[i]->setTickDelta(4095 / 5);
|
||||
@@ -152,6 +159,14 @@ OpenTxSim::OpenTxSim(FXApp* a):
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
for(int i = 0; i < NUM_FUNCTIONS_SWITCHES; ++i)
|
||||
{
|
||||
fctButtons[i] = new FXButton(hf12, " ", nullptr, nullptr, 123, LAYOUT_LEFT|BUTTON_NORMAL, 0, 0, 50, 0, 15, 15);
|
||||
fctButtons[i]->setBorderColor(FXColor(0));
|
||||
}
|
||||
#endif
|
||||
|
||||
bmf = new FXImageFrame(this, bmp);
|
||||
bmf->enable();
|
||||
bmf->setTarget(this);
|
||||
@@ -465,6 +480,19 @@ void OpenTxSim::updateKeysAndSwitches(bool start)
|
||||
SWITCH_KEY(Q, 16, 3);
|
||||
SWITCH_KEY(R, 17, 3);
|
||||
#endif
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
for(int i = 0; i < NUM_FUNCTIONS_SWITCHES; ++i)
|
||||
{
|
||||
int8_t newState = -1;
|
||||
if(fctButtons[i]->getState()==STATE_DOWN)
|
||||
{
|
||||
newState = 1;
|
||||
}
|
||||
|
||||
simuSetSwitch(switchGetMaxSwitches() + i, newState);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
extern volatile rotenc_t rotencValue;
|
||||
@@ -596,6 +624,15 @@ void OpenTxSim::refreshDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
void OpenTxSim::fsLedRGB(uint8_t idx, uint32_t color)
|
||||
{
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
uint32_t col = (color&0x00FF0000)>>16 | (color&0x0000FF00) | (color&0x000000FF)<<16;
|
||||
fctButtons[idx]->setBaseColor(col);
|
||||
fctButtons[idx]->setBackColor(col);
|
||||
#endif
|
||||
}
|
||||
|
||||
OpenTxSim * opentxSim;
|
||||
|
||||
void doFxEvents()
|
||||
@@ -671,3 +708,19 @@ void createBitmap(int index, uint16_t *data, int x, int y, int w, int h)
|
||||
{
|
||||
opentxSim->createBitmap(index, data, x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
void fsLedRGB(uint8_t idx, uint32_t color)
|
||||
{
|
||||
opentxSim->fsLedRGB(idx, color);
|
||||
}
|
||||
|
||||
void fsLedOn(uint8_t idx)
|
||||
{
|
||||
opentxSim->fsLedRGB(idx, 0x00ffffff);
|
||||
}
|
||||
|
||||
void fsLedOff(uint8_t idx)
|
||||
{
|
||||
opentxSim->fsLedRGB(idx, 0);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ void ledRed() {}
|
||||
void ledGreen() {}
|
||||
void ledBlue() {}
|
||||
void ledOff() {}
|
||||
void fsLedOn(uint8_t) {}
|
||||
void fsLedOff(uint8_t) {}
|
||||
void fsLedRGB(uint8_t, uint32_t) {}
|
||||
__attribute__((weak)) void fsLedOn(uint8_t) {}
|
||||
__attribute__((weak)) void fsLedOff(uint8_t) {}
|
||||
__attribute__((weak)) void fsLedRGB(uint8_t, uint32_t) {}
|
||||
bool fsLedState(uint8_t) { return false;}
|
||||
void rgbSetLedColor(unsigned char, unsigned char, unsigned char, unsigned char) {}
|
||||
void rgbLedColorApply() {}
|
||||
|
||||
@@ -66,8 +66,8 @@ SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx)
|
||||
idx = get_switch_index(cat, idx);
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
if (IS_SWITCH_FS(idx + n_switches)) {
|
||||
if (bfSingleBitGet(functionSwitchFunctionState, idx))
|
||||
if (IS_SWITCH_FS(idx)) {
|
||||
if (bfSingleBitGet(functionSwitchFunctionState, idx - n_switches))
|
||||
return SWITCH_HW_DOWN;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user