3djc/add logicial switches monitor (#3611)
* Prep work for Logic Switches * Feature complete * Fixe for sometime needing two RTN to get out of logical switchs monitor All monitors title bar in upper case for consistency with the rest of OpenTX * Cosmetics * Add translations support to the MONITORS screens * Add the right icon to the logical switch monitor * Cosmetics * uncrustify * Cosmetics
This commit is contained in:
@@ -36,68 +36,66 @@ const BitmapBuffer * outR_bmp = NULL;
|
||||
|
||||
bool menuOutputs1(evt_t);
|
||||
bool menuOutputs2(evt_t);
|
||||
bool menuMixers1(evt_t);
|
||||
bool menuMixers2(evt_t);
|
||||
|
||||
extern bool menuLogicSwitches1(evt_t);
|
||||
extern bool menuLogicSwitches2(evt_t);
|
||||
extern bool menuMixers1(evt_t);
|
||||
extern bool menuMixers2(evt_t);
|
||||
extern bool menuLogicalSwitches(evt_t);
|
||||
|
||||
const MenuHandlerFunc menuTabMonitors[] PROGMEM = {
|
||||
menuOutputs1,
|
||||
menuOutputs2,
|
||||
menuMixers1,
|
||||
menuMixers2,
|
||||
/* menuLogicSwitches1,
|
||||
menuLogicSwitches2*/
|
||||
menuLogicalSwitches
|
||||
};
|
||||
|
||||
uint8_t lastMonitorPage = 0;
|
||||
|
||||
uint16_t posOnBar(int16_t value_to100){
|
||||
return divRoundClosest((value_to100 + (g_model.extendedLimits ? 150 : 100)) * COLUMN_SIZE, (g_model.extendedLimits ? 150 : 100)*2);
|
||||
uint16_t posOnBar(int16_t value_to100)
|
||||
{
|
||||
return divRoundClosest((value_to100 + (g_model.extendedLimits ? 150 : 100)) * COLUMN_SIZE, (g_model.extendedLimits ? 150 : 100) * 2);
|
||||
}
|
||||
|
||||
|
||||
void drawSingleMixerBar(uint16_t x, uint16_t y, uint8_t Chan)
|
||||
void drawSingleMixerBar(coord_t x, coord_t y, uint8_t chan)
|
||||
{
|
||||
char chanString[] = "CH 32";
|
||||
char chanString[] = "Ch 32";
|
||||
int16_t chanVal = calcRESXto100(ex_chans[chan]);
|
||||
|
||||
int16_t chanVal = calcRESXto100(ex_chans[Chan]);
|
||||
|
||||
strAppend(chanString, "Ch ");
|
||||
strAppendSigned(&chanString[3], Chan + 1, 2);
|
||||
strAppendSigned(&chanString[3], chan + 1, 2);
|
||||
lcdDrawText(x + X_OFFSET, y + 1, chanString, TINSIZE | TEXT_COLOR | LEFT);
|
||||
|
||||
lcdDrawSizedText(x + X_OFFSET + 50, y + 1, g_model.limitData[Chan].name, sizeof(g_model.limitData[Chan].name), TINSIZE | TEXT_COLOR | LEFT | ZCHAR);
|
||||
|
||||
lcdColorTable[CUSTOM_COLOR_INDEX]= RGB(222, 222, 222);
|
||||
lcdDrawSizedText(x + X_OFFSET + 50, y + 1, g_model.limitData[chan].name, sizeof(g_model.limitData[chan].name), TINSIZE | TEXT_COLOR | LEFT | ZCHAR);
|
||||
|
||||
lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(222, 222, 222);
|
||||
lcdDrawSolidFilledRect(x + X_OFFSET, y + 11, COLUMN_SIZE, BAR_HEIGHT, CUSTOM_COLOR);
|
||||
|
||||
lcd->drawSolidVerticalLine(x + X_OFFSET + posOnBar(chanVal), y + 11, BAR_HEIGHT , HEADER_BGCOLOR);
|
||||
lcd->drawSolidVerticalLine(x + X_OFFSET + posOnBar(chanVal), y + 11, BAR_HEIGHT, HEADER_BGCOLOR);
|
||||
|
||||
strAppendSigned(chanString, chanVal);
|
||||
lcdDrawText(x + X_OFFSET + COLUMN_SIZE - 2, y + 1, chanString, TINSIZE | TEXT_COLOR | RIGHT);
|
||||
|
||||
lcdColorTable[CUSTOM_COLOR_INDEX]= RGB(25, 150, 50);
|
||||
if(chanVal > 0){
|
||||
lcdDrawSolidFilledRect(x + X_OFFSET + COLUMN_SIZE / 2, y + 11, divRoundClosest(chanVal * COLUMN_SIZE, 200) , BAR_HEIGHT, CUSTOM_COLOR);
|
||||
|
||||
lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(25, 150, 50);
|
||||
if (chanVal > 0) {
|
||||
lcdDrawSolidFilledRect(x + X_OFFSET + COLUMN_SIZE / 2, y + 11, divRoundClosest(chanVal * COLUMN_SIZE, 200), BAR_HEIGHT, CUSTOM_COLOR);
|
||||
}
|
||||
else if (chanVal < 0) {
|
||||
uint16_t endpoint = x + X_OFFSET + COLUMN_SIZE / 2;
|
||||
uint16_t size = divRoundClosest(-chanVal * COLUMN_SIZE, 200);
|
||||
lcdDrawSolidFilledRect(endpoint - size, y + 11, size, BAR_HEIGHT, CUSTOM_COLOR);
|
||||
lcdDrawSolidFilledRect(endpoint - size, y + 11, size, BAR_HEIGHT, CUSTOM_COLOR);
|
||||
}
|
||||
|
||||
lcd->drawSolidVerticalLine(x + X_OFFSET + COLUMN_SIZE / 2, y + 11, BAR_HEIGHT , TEXT_COLOR);
|
||||
lcd->drawSolidVerticalLine(x + X_OFFSET + COLUMN_SIZE / 2, y + 11, BAR_HEIGHT, TEXT_COLOR);
|
||||
}
|
||||
|
||||
void drawSingleOutputBar(uint16_t x, uint16_t y, uint8_t channel)
|
||||
void drawSingleOutputBar(coord_t x, coord_t y, uint8_t channel)
|
||||
{
|
||||
char chanString[] = "Ch 32";
|
||||
uint16_t limits = (g_model.extendedLimits ? 300 : 200);
|
||||
int16_t chanVal = calcRESXto100(channelOutputs[channel]);
|
||||
LimitData * ld = limitAddress(channel);
|
||||
|
||||
|
||||
if (!locked_bmp) locked_bmp = BitmapBuffer::load(getThemePath("mask_monitor_lockch.png"));
|
||||
if (!inver_bmp) inver_bmp = BitmapBuffer::load(getThemePath("mask_monitor_inver.png"));
|
||||
if (!outL_bmp) outL_bmp = BitmapBuffer::load(getThemePath("mask_monitor_outL.png"));
|
||||
@@ -105,22 +103,22 @@ void drawSingleOutputBar(uint16_t x, uint16_t y, uint8_t channel)
|
||||
|
||||
strAppendSigned(&chanString[3], channel + 1, 2);
|
||||
lcdDrawText(x + X_OFFSET, y + 1, chanString, TINSIZE | TEXT_COLOR | LEFT);
|
||||
|
||||
|
||||
lcdDrawSizedText(x + X_OFFSET + 50, y + 1, g_model.limitData[channel].name, sizeof(g_model.limitData[channel].name), TINSIZE | TEXT_COLOR | LEFT | ZCHAR);
|
||||
|
||||
lcdColorTable[CUSTOM_COLOR_INDEX]= RGB(222, 222, 222);
|
||||
lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(222, 222, 222);
|
||||
lcdDrawSolidFilledRect(x + X_OFFSET, y + 11, COLUMN_SIZE, BAR_HEIGHT, CUSTOM_COLOR);
|
||||
|
||||
lcdDrawText(x + X_OFFSET + posOnBar(-100 + ld->min/10)+2, y + 10, "]",TINSIZE| TEXT_COLOR | RIGHT);
|
||||
lcdDrawText(x + X_OFFSET + posOnBar(100 + ld->max/10), y + 10, "[",TINSIZE| TEXT_COLOR);
|
||||
|
||||
lcd->drawSolidVerticalLine(x + X_OFFSET + posOnBar(calcRESXto100(ld->offset)), y + 11, BAR_HEIGHT , MAINVIEW_GRAPHICS_COLOR);
|
||||
lcd->drawSolidVerticalLine(x + X_OFFSET + posOnBar(chanVal), y + 11, BAR_HEIGHT , HEADER_BGCOLOR);
|
||||
lcdDrawText(x + X_OFFSET + posOnBar(-100 + ld->min / 10) + 2, y + 10, "]", TINSIZE | TEXT_COLOR | RIGHT);
|
||||
lcdDrawText(x + X_OFFSET + posOnBar(100 + ld->max / 10), y + 10, "[", TINSIZE | TEXT_COLOR);
|
||||
|
||||
lcd->drawSolidVerticalLine(x + X_OFFSET + posOnBar(calcRESXto100(ld->offset)), y + 11, BAR_HEIGHT, MAINVIEW_GRAPHICS_COLOR);
|
||||
lcd->drawSolidVerticalLine(x + X_OFFSET + posOnBar(chanVal), y + 11, BAR_HEIGHT, HEADER_BGCOLOR);
|
||||
|
||||
strAppendSigned(chanString, chanVal);
|
||||
if (chanVal < -limits / 2) {
|
||||
lcd->drawBitmap(x + X_OFFSET + COLUMN_SIZE / 2 - 55, y + 8, outL_bmp);
|
||||
chanVal = - limits / 2;
|
||||
chanVal = -limits / 2;
|
||||
lcdDrawText(x + X_OFFSET + COLUMN_SIZE - 2, y + 1, chanString, TINSIZE | TEXT_COLOR | RIGHT | INVERS);
|
||||
}
|
||||
else if (chanVal > limits / 2) {
|
||||
@@ -131,31 +129,31 @@ void drawSingleOutputBar(uint16_t x, uint16_t y, uint8_t channel)
|
||||
else {
|
||||
lcdDrawText(x + X_OFFSET + COLUMN_SIZE - 2, y + 1, chanString, TINSIZE | TEXT_COLOR | RIGHT);
|
||||
}
|
||||
|
||||
if(posOnBar(chanVal) > posOnBar(calcRESXto100(ld->offset))){
|
||||
lcdDrawSolidFilledRect(x + X_OFFSET + posOnBar(calcRESXto100(ld->offset)), y + 11, posOnBar(chanVal) - posOnBar(calcRESXto100(ld->offset)), BAR_HEIGHT, MAINVIEW_GRAPHICS_COLOR);
|
||||
|
||||
if (posOnBar(chanVal) > posOnBar(calcRESXto100(ld->offset))) {
|
||||
lcdDrawSolidFilledRect(x + X_OFFSET + posOnBar(calcRESXto100(ld->offset)), y + 11, posOnBar(chanVal) - posOnBar(calcRESXto100(ld->offset)), BAR_HEIGHT, MAINVIEW_GRAPHICS_COLOR);
|
||||
}
|
||||
else if (posOnBar(chanVal) < posOnBar(calcRESXto100(ld->offset))) {
|
||||
uint16_t endpoint = x + X_OFFSET + posOnBar(calcRESXto100(ld->offset));
|
||||
uint16_t size = posOnBar(calcRESXto100(ld->offset)) - posOnBar(chanVal);
|
||||
lcdDrawSolidFilledRect(endpoint - size, y + 11, size, BAR_HEIGHT, MAINVIEW_GRAPHICS_COLOR);
|
||||
lcdDrawSolidFilledRect(endpoint - size, y + 11, size, BAR_HEIGHT, MAINVIEW_GRAPHICS_COLOR);
|
||||
}
|
||||
|
||||
|
||||
if (safetyCh[channel] != OVERRIDE_CHANNEL_UNDEFINED) lcd->drawBitmap(x + 3, y + 5, locked_bmp);
|
||||
if (ld->revert) lcd->drawBitmap(x + 16, y + 5, inver_bmp);
|
||||
lcd->drawSolidVerticalLine(x + X_OFFSET + COLUMN_SIZE / 2, y + 11, BAR_HEIGHT , TEXT_COLOR);
|
||||
lcd->drawSolidVerticalLine(x + X_OFFSET + COLUMN_SIZE / 2, y + 11, BAR_HEIGHT, TEXT_COLOR);
|
||||
}
|
||||
|
||||
bool menuOutputsMonitor(evt_t event, uint8_t page)
|
||||
{
|
||||
uint8_t channel = 16*page;
|
||||
uint16_t x=1, y=Y_OFFSET;
|
||||
for (uint8_t i=0; i<8; i++, channel++, y+=ROW_HEIGHT) {
|
||||
uint8_t channel = 16 * page;
|
||||
uint16_t x = 1, y = Y_OFFSET;
|
||||
for (uint8_t i = 0; i < 8; i++, channel++, y += ROW_HEIGHT) {
|
||||
drawSingleOutputBar(x, y, channel);
|
||||
}
|
||||
x = 1 + LCD_W/2;
|
||||
x = 1 + LCD_W / 2;
|
||||
y = Y_OFFSET;
|
||||
for(uint8_t i=0; i<8; i++, channel++, y+=ROW_HEIGHT) {
|
||||
for (uint8_t i = 0; i < 8; i++, channel++, y += ROW_HEIGHT) {
|
||||
drawSingleOutputBar(x, y, channel);
|
||||
}
|
||||
return true;
|
||||
@@ -163,28 +161,28 @@ bool menuOutputsMonitor(evt_t event, uint8_t page)
|
||||
|
||||
bool menuOutputs1(evt_t event)
|
||||
{
|
||||
MENU("Output monitor 1-16", MONITOR_ICONS, menuTabMonitors, e_Outputs1, 0, { 0 });
|
||||
lastMonitorPage = e_Outputs1;
|
||||
MENU(STR_MONITOR_OUTPUTS1, MONITOR_ICONS, menuTabMonitors, e_MonOutputs1, 0, { 0 });
|
||||
lastMonitorPage = e_MonOutputs1;
|
||||
return menuOutputsMonitor(event, 0);
|
||||
}
|
||||
|
||||
bool menuOutputs2(evt_t event)
|
||||
{
|
||||
MENU("Output monitor 17-32", MONITOR_ICONS, menuTabMonitors, e_Outputs2, 0, { 0 });
|
||||
lastMonitorPage = e_Outputs2;
|
||||
MENU(STR_MONITOR_OUTPUTS2, MONITOR_ICONS, menuTabMonitors, e_MonOutputs2, 0, { 0 });
|
||||
lastMonitorPage = e_MonOutputs2;
|
||||
return menuOutputsMonitor(event, 1);
|
||||
}
|
||||
|
||||
bool menuMixersMonitor(evt_t event, uint8_t page)
|
||||
{
|
||||
uint8_t channel = 16*page;
|
||||
uint16_t x=1, y=Y_OFFSET;
|
||||
for (uint8_t i=0; i<8; i++, channel++, y+=ROW_HEIGHT) {
|
||||
uint8_t channel = 16 * page;
|
||||
uint16_t x = 1, y = Y_OFFSET;
|
||||
for (uint8_t i = 0; i < 8; i++, channel++, y += ROW_HEIGHT) {
|
||||
drawSingleMixerBar(x, y, channel);
|
||||
}
|
||||
x = 1 + LCD_W/2;
|
||||
x = 1 + LCD_W / 2;
|
||||
y = Y_OFFSET;
|
||||
for(uint8_t i=0; i<8; i++, channel++, y+=ROW_HEIGHT) {
|
||||
for (uint8_t i = 0; i < 8; i++, channel++, y += ROW_HEIGHT) {
|
||||
drawSingleMixerBar(x, y, channel);
|
||||
}
|
||||
return true;
|
||||
@@ -192,14 +190,14 @@ bool menuMixersMonitor(evt_t event, uint8_t page)
|
||||
|
||||
bool menuMixers1(evt_t event)
|
||||
{
|
||||
MENU("Mixer monitor 1-16", MONITOR_ICONS, menuTabMonitors, e_Mixers1, 0, { 0 });
|
||||
lastMonitorPage = e_Mixers1;
|
||||
MENU(STR_MONITOR_MIXERS1, MONITOR_ICONS, menuTabMonitors, e_MonMixers1, 0, { 0 });
|
||||
lastMonitorPage = e_MonMixers1;
|
||||
return menuMixersMonitor(event, 0);
|
||||
}
|
||||
|
||||
bool menuMixers2(evt_t event)
|
||||
{
|
||||
MENU("Mixer monitor 1-16", MONITOR_ICONS, menuTabMonitors, e_Mixers2, 0, { 0 });
|
||||
lastMonitorPage = e_Mixers2;
|
||||
MENU(STR_MONITOR_MIXERS2, MONITOR_ICONS, menuTabMonitors, e_MonMixers2, 0, { 0 });
|
||||
lastMonitorPage = e_MonMixers2;
|
||||
return menuMixersMonitor(event, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user