From 7c192910d12f775cf78061a9647705136fc48a28 Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 29 Nov 2012 20:27:21 +0000 Subject: [PATCH] [X9D] Tiny font added (numbers only) [X9D] Channels monitor [X9D] Switches main view --- src/Makefile | 9 +- src/font_tiny.lbm | 1 + src/font_tiny.xbm | 6 + src/lcd.cpp | 25 +++ src/lcd.h | 5 +- src/main_views.cpp | 391 ++++++++++++++++++++++++--------------- src/menus.h | 2 + src/model_menus.cpp | 16 ++ src/monitors_views.cpp | 84 +++++++++ src/myeeprom.h | 2 +- src/open9x.cpp | 2 +- src/open9x.h | 17 +- src/statistics_views.cpp | 3 + src/translations.cpp | 5 + src/translations.h | 2 + src/translations/cz.h | 1 + src/translations/de.h | 1 + src/translations/en.h | 1 + src/translations/es.h | 1 + src/translations/fr.h | 1 + src/translations/it.h | 1 + src/translations/pt.h | 2 +- src/translations/se.h | 1 + 23 files changed, 410 insertions(+), 169 deletions(-) create mode 100644 src/font_tiny.lbm create mode 100644 src/font_tiny.xbm create mode 100644 src/monitors_views.cpp diff --git a/src/Makefile b/src/Makefile index 4b21a62f2..00c28db33 100644 --- a/src/Makefile +++ b/src/Makefile @@ -460,7 +460,7 @@ ifeq ($(PCB), X9D) PULSESSRC = pulses_arm.cpp CPPSRC += sky9x/audio.cpp haptic.cpp CPPSRC += sky9x/sound_driver.cpp sky9x/haptic_driver.cpp sky9x/sdcard_driver.cpp - CPPSRC += bmp.cpp + CPPSRC += bmp.cpp monitors_views.cpp ifeq ($(SDCARD), YES) EXTRABOARDSRC += FatFs/ff.c FatFs/fattime.c FatFs/option/ccsbcs.c sky9x/diskio.cpp @@ -750,7 +750,7 @@ eep: $(TARGET).eep lss: $(TARGET).lss sym: $(TARGET).sym -lbm: font.lbm font_small.lbm font_midsize.lbm font_dblsize.lbm sticks.lbm splash_9x.lbm splash_X9D.lbm asterisk.lbm +lbm: font.lbm font_tiny.lbm font_small.lbm font_midsize.lbm font_dblsize.lbm sticks.lbm splash_9x.lbm splash_X9D.lbm asterisk.lbm # Build stamp-file stamp_header: @@ -798,6 +798,11 @@ font.lbm: font.xbm font_extra.xbm translations/font_se.xbm translations/font_de. $(IMG2LBM) translations/font_fr.xbm translations/font_fr.lbm 5x7 $(IMG2LBM) translations/font_es.xbm translations/font_es.lbm 5x7 +font_tiny.lbm: font_tiny.xbm + @echo + @echo "Convert font from xbm to lbm:" + $(IMG2LBM) $< $@ 3x5 + font_small.lbm: font_small.xbm @echo @echo "Convert font from xbm to lbm:" diff --git a/src/font_tiny.lbm b/src/font_tiny.lbm new file mode 100644 index 000000000..1ac27d88d --- /dev/null +++ b/src/font_tiny.lbm @@ -0,0 +1 @@ +0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x11,0x0e,0x12,0x1f,0x10,0x19,0x15,0x13,0x11,0x15,0x1f,0x07,0x04,0x1f,0x17,0x15,0x1d,0x1f,0x15,0x1d,0x01,0x1d,0x03,0x1f,0x15,0x1f,0x17,0x15,0x1f, diff --git a/src/font_tiny.xbm b/src/font_tiny.xbm new file mode 100644 index 000000000..fb9f4598a --- /dev/null +++ b/src/font_tiny.xbm @@ -0,0 +1,6 @@ +#define font_tiny_width 39 +#define font_tiny_height 5 +static unsigned char font_tiny_bits[] = { + 0x00, 0xa4, 0xbf, 0xff, 0x7f, 0x00, 0x3a, 0xb2, 0x09, 0x5b, 0x07, 0x2a, + 0xf9, 0xbf, 0x7e, 0x00, 0xaa, 0x90, 0xac, 0x4a, 0x00, 0xf4, 0x9f, 0xbf, + 0x7e }; diff --git a/src/lcd.cpp b/src/lcd.cpp index a2c35d459..57d35ff1a 100644 --- a/src/lcd.cpp +++ b/src/lcd.cpp @@ -164,6 +164,26 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags mode) p--; } } + else if (mode & TINSIZE) { + q = &font_3x5[((uint16_t)c-0x2D)*3+2]; + uint8_t ym8 = (y % 8); + p += 2; + for (int8_t i=2; i>=0; i--) { + uint8_t b = pgm_read_byte(q--); + if (inv) b = ~b & 0x3f; + + if (p> (8-ym8)))) + (b >> (8-ym8)); + } + } + p--; + } + } #endif else { uint8_t condense=0; @@ -308,8 +328,10 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, int16_t val, LcdFlags flags, uint8_t bool dblsize = flags & DBLSIZE; #if defined(PCBX9D) bool midsize = flags & MIDSIZE; + bool tinsize = flags & TINSIZE; #else #define midsize 0 +#define tinsize 0 #endif bool neg = false; @@ -337,6 +359,9 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, int16_t val, LcdFlags flags, uint8_t flags |= CONDENSED; fw += FWNUM-3; } + else if (tinsize) { + fw -= 1; + } else { if (flags & LEFT) { if (mode > 0) diff --git a/src/lcd.h b/src/lcd.h index 5ad993c38..93ef89ced 100644 --- a/src/lcd.h +++ b/src/lcd.h @@ -96,9 +96,11 @@ #if defined(PCBX9D) #define MIDSIZE 0x0100 #define SMLSIZE 0x0200 +#define TINSIZE 0x0400 #else #define MIDSIZE DBLSIZE #define SMLSIZE 0x00 +#define TINSIZE 0x00 #endif #if defined(CPUARM) @@ -125,8 +127,9 @@ extern void lcd_putsAtt(xcoord_t x, uint8_t y, const pm_char * s, LcdFlags mode) extern void lcd_putsiAtt(xcoord_t x, uint8_t y, const pm_char * s,uint8_t idx, LcdFlags mode); extern void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s,unsigned char len, LcdFlags mode); extern void lcd_puts(xcoord_t x, uint8_t y, const pm_char * s); -extern void lcd_putsLeft(uint8_t y, const pm_char * s); extern void lcd_putsn(xcoord_t x, uint8_t y, const pm_char * s, unsigned char len); +extern void lcd_putsLeft(uint8_t y, const pm_char * s); +#define lcd_putsCenter(y, s) lcd_puts((DISPLAY_W-sizeof(TR_##s)*FW+FW-2)/2, y, STR_##s) extern void lcd_outhex4(xcoord_t x, uint8_t y, uint16_t val); extern void lcd_outdezAtt(xcoord_t x, uint8_t y, int16_t val, LcdFlags mode=0); diff --git a/src/main_views.cpp b/src/main_views.cpp index 73aae5e50..f2f061a82 100644 --- a/src/main_views.cpp +++ b/src/main_views.cpp @@ -51,8 +51,13 @@ #define TIMERS_X 144 #define TIMERS_R 192 #define REBOOT_X (DISPLAY_W-FW) -#define VSWITCH_X(i) ((i >= NUM_CSW/2 ? BITMAP_X+26 : 19) + 3*i) +#define VSWITCH_X(i) (((i>=NUM_CSW*3/4) ? BITMAP_X+28 : ((i>=NUM_CSW/2) ? BITMAP_X+25 : ((i>=NUM_CSW/4) ? 21 : 18))) + 3*i) #define VSWITCH_Y (DISPLAY_H-9) +#define BAR_HEIGHT (31-9) +#define TRIM_LH_X (32+9) +#define TRIM_LV_X 10 +#define TRIM_RV_X (DISPLAY_W-11) +#define TRIM_RH_X (DISPLAY_W-32-9) #else #define BOX_WIDTH 23 #define LBOX_CENTERX (DISPLAY_W/4 + 10) @@ -69,9 +74,14 @@ #define REBOOT_X (20*FW-3) #define VSWITCH_X(i) (16 + 3*i) #define VSWITCH_Y (DISPLAY_H-8) +#define BAR_HEIGHT (BOX_WIDTH-1l) +#define TRIM_LH_X (DISPLAY_W*1/4+2) +#define TRIM_LV_X 3 +#define TRIM_RV_X (DISPLAY_W-4) +#define TRIM_RH_X (DISPLAY_W*3/4-2) #endif -#define BAR_HEIGHT (BOX_WIDTH-1l) +#define TRIM_LEN 27 #define MARKER_WIDTH 5 #define BOX_LIMIT (BOX_WIDTH-MARKER_WIDTH) @@ -104,6 +114,130 @@ void doMainScreenGraphics() #endif } +void displayTrims(uint8_t phase) +{ + for (uint8_t i=0; i<4; i++) { + static xcoord_t x[4] = {TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X}; + static uint8_t vert[4] = {0,1,1,0}; + uint8_t xm, ym; + xm = x[CONVERT_MODE(i+1)-1]; + + uint8_t att = ROUND; + int16_t val = getTrimValue(phase, i); + + if (val < -125 || val > 125) + att = BLINK|INVERS|ROUND; + + if (val < -(TRIM_LEN+1)*4) + val = -(TRIM_LEN+1); + else if (val > (TRIM_LEN+1)*4) + val = TRIM_LEN+1; + else + val /= 4; + + if (vert[i]) { + ym = 31; + lcd_vline(xm, ym-TRIM_LEN, TRIM_LEN*2); + if (i!=2 || !g_model.thrTrim) { + lcd_vline(xm-1, ym-1, 3); + lcd_vline(xm+1, ym-1, 3); + } + ym -= val; + } + else { + ym = 60; + lcd_hline(xm-TRIM_LEN, ym, TRIM_LEN*2); + lcd_hline(xm-1, ym-1, 3); + lcd_hline(xm-1, ym+1, 3); + xm += val; + } + lcd_square(xm-3, ym-3, 7, att); + } +} + +#if defined(PCBX9D) +void displaySliders() +{ + for (uint8_t i=NUM_STICKS; iNUM_STICKS+1 ? DISPLAY_W-5 : 3); + int8_t y = (i%2 ? DISPLAY_H/2+1 : 1); + lcd_vline(x, y, DISPLAY_H/2-2); + lcd_vline(x+1, y, DISPLAY_H/2-2); + y += ((calibratedStick[i]+RESX)*(DISPLAY_H/2-4)/(RESX*2)); // calculate once per loop + lcd_vline(x-1, y, 2); + lcd_vline(x+2, y, 2); + } +} +#endif + +#if defined(LCD212) +void displayTimers() +{ + // Main timer + if (g_model.timers[0].mode) { + putsTime(TIMERS_X, 0, s_timerVal[0], MIDSIZE, MIDSIZE); + putsTmrMode(TIMERS_X-16, 5, g_model.timers[0].mode, SWCONDENSED|SMLSIZE); + if (g_model.timers[0].remanent) lcd_putcAtt(TIMERS_R, 1, 'R', SMLSIZE); + if (s_timerState[0]==TMR_BEEPING) { + lcd_hline(TIMERS_X-6, 2, 4); + if (BLINK_ON_PHASE) + lcd_filled_rect(TIMERS_X-17, 0, 69, 12); + } + } + + // Second timer + if (g_model.timers[1].mode) { + putsTime(TIMERS_X, FH+3, s_timerVal[1], MIDSIZE, MIDSIZE); + putsTmrMode(TIMERS_X-16, FH+8, g_model.timers[1].mode, SWCONDENSED|SMLSIZE); + if (g_model.timers[1].remanent) lcd_putcAtt(TIMERS_R, FH+4, 'R', SMLSIZE); + if (s_timerState[1]==TMR_BEEPING) { + lcd_hline(TIMERS_X-6, FH+5, 4); + if (BLINK_ON_PHASE) + lcd_filled_rect(TIMERS_X-17, FH+3, 69, 12); + } + } +} +#else +void displayTimers() +{ + // Main timer + if (g_model.timers[0].mode) { + uint8_t att = DBLSIZE | (s_timerState[0]==TMR_BEEPING ? BLINK|INVERS : 0); + putsTime(12*FW+2, FH*2, s_timerVal[0], att, att); + putsTmrMode(s_timerVal[0] >= 0 ? 9*FW-FW/2+3 : 9*FW-FW/2-4, FH*3, g_model.timers[0].mode, SWCONDENSED); + } +} +#endif + + +#if defined(PCBSKY9X) +void displayVoltage() +{ + if (g_vbat100mV > g_eeGeneral.vBatWarn && g_eeGeneral.temperatureWarn && getTemperature() >= g_eeGeneral.temperatureWarn) { + putsTelemetryValue(6*FW-1, 3*FH, getTemperature(), UNIT_DEGREES, BLINK|INVERS|DBLSIZE); + } + else if (g_vbat100mV > g_eeGeneral.vBatWarn && g_eeGeneral.mAhWarn && (g_eeGeneral.mAhUsed + Current_used * (488 + g_eeGeneral.currentCalib)/8192/36) / 500 >= g_eeGeneral.mAhWarn) { + putsTelemetryValue(7*FW-1, 3*FH, (g_eeGeneral.mAhUsed + Current_used*(488 + g_eeGeneral.currentCalib)/8192/36)/10, UNIT_MAH, BLINK|INVERS|DBLSIZE); + } + else { + LcdFlags att = (g_vbat100mV <= g_eeGeneral.vBatWarn ? BLINK|INVERS : 0) | MIDSIZE; + putsVBat(VBATT_X-1, VBATT_Y, att|NO_UNIT); +#if defined(PCBX9D) + lcd_putcAtt(VBATTUNIT_X, VBATTUNIT_Y, 'v', MIDSIZE); +#else + lcd_putc(VBATT_X, VBATTUNIT_Y, 'V'); +#endif + } +} +#else +void displayVoltage() +{ + LcdFlags att = (g_vbat100mV <= g_eeGeneral.vBatWarn ? BLINK|INVERS : 0) | MIDSIZE; + putsVBat(VBATT_X-1, VBATT_Y, att|NO_UNIT); + lcd_putc(VBATT_X, VBATTUNIT_Y, 'V'); +} +#endif + #if defined(PCBX9D) #define EVT_KEY_MODEL_MENU EVT_KEY_BREAK(KEY_MENU) #define EVT_KEY_GENERAL_MENU EVT_KEY_LONG(KEY_MENU) @@ -116,10 +250,26 @@ void doMainScreenGraphics() #define EVT_KEY_STATISTICS EVT_KEY_LONG(KEY_UP) #endif +#if defined(PCBX9D) +void menuMainViewChannelsMonitor(uint8_t event) +{ + switch(event) { + case EVT_KEY_BREAK(KEY_PAGE): + case EVT_KEY_BREAK(KEY_EXIT): + chainMenu(menuMainView); + return; + } + + return menuChannelsMonitor(event); +} +#endif + void menuMainView(uint8_t event) { +#if !defined(PCBX9D) uint8_t view = g_eeGeneral.view; uint8_t view_base = view & 0x0f; +#endif uint8_t _event = event; if (s_global_warning) { @@ -128,6 +278,13 @@ void menuMainView(uint8_t event) switch(event) { + case EVT_ENTRY: + killEvents(KEY_EXIT); + killEvents(KEY_UP); + killEvents(KEY_DOWN); + break; + +#if !defined(PCBX9D) /* TODO if timer2 is OFF, it's possible to use this timer2 as in er9x... case EVT_KEY_BREAK(KEY_MENU): if (view_base == VIEW_TIMER2) { @@ -137,13 +294,6 @@ void menuMainView(uint8_t event) break; */ -#if !defined(PCBX9D) && !defined(READONLY) - case EVT_KEY_LONG(KEY_MENU):// go to last menu - pushMenu(lastPopMenu()); - killEvents(event); - break; -#endif - case EVT_KEY_BREAK(KEY_RIGHT): case EVT_KEY_BREAK(KEY_LEFT): if (view_base <= VIEW_INPUTS) { @@ -159,12 +309,21 @@ void menuMainView(uint8_t event) AUDIO_KEYPAD_UP(); } break; +#endif #if !defined(READONLY) +#if !defined(PCBX9D) + case EVT_KEY_LONG(KEY_MENU):// go to last menu + pushMenu(lastPopMenu()); + killEvents(event); + break; +#endif + case EVT_KEY_MODEL_MENU: pushMenu(menuModelSelect); killEvents(event); break; + case EVT_KEY_GENERAL_MENU: pushMenu(menuGeneralSetup); killEvents(event); @@ -173,18 +332,28 @@ void menuMainView(uint8_t event) #if defined(PCBX9D) case EVT_KEY_BREAK(KEY_PAGE): + eeDirty(EE_GENERAL); + g_eeGeneral.view += 1; + if (g_eeGeneral.view >= VIEW_COUNT) { + g_eeGeneral.view = 0; + chainMenu(menuMainViewChannelsMonitor); + return; + } + break; #else case EVT_KEY_BREAK(KEY_UP): case EVT_KEY_BREAK(KEY_DOWN): -#endif g_eeGeneral.view = (event == EVT_KEY_BREAK(KEY_UP) ? (view_base == VIEW_COUNT-1 ? 0 : view_base+1) : (view_base == 0 ? VIEW_COUNT-1 : view_base-1)); eeDirty(EE_GENERAL); AUDIO_KEYPAD_UP(); break; +#endif + case EVT_KEY_STATISTICS: chainMenu(menuStatisticsView); killEvents(event); return; + case EVT_KEY_TELEMETRY: #if defined(FRSKY) chainMenu(menuTelemetryFrsky); @@ -204,6 +373,7 @@ void menuMainView(uint8_t event) #endif killEvents(event); return; + case EVT_KEY_FIRST(KEY_EXIT): if (s_timerState[0]==TMR_BEEPING) { s_timerState[0] = TMR_STOPPED; @@ -226,15 +396,11 @@ void menuMainView(uint8_t event) } AUDIO_KEYPAD_UP(); break; + case EVT_KEY_LONG(KEY_EXIT): resetAll(); AUDIO_KEYPAD_UP(); break; - case EVT_ENTRY: - killEvents(KEY_EXIT); - killEvents(KEY_UP); - killEvents(KEY_DOWN); - break; } { @@ -245,124 +411,62 @@ void menuMainView(uint8_t event) // Model Name putsModelName(MODELNAME_X, 0*FH, g_model.name, g_eeGeneral.currModel, MIDSIZE); - // Voltage (or alarm if any) -#if defined(PCBSKY9X) - if (g_vbat100mV > g_eeGeneral.vBatWarn && g_eeGeneral.temperatureWarn && getTemperature() >= g_eeGeneral.temperatureWarn) { - putsTelemetryValue(6*FW-1, 3*FH, getTemperature(), UNIT_DEGREES, BLINK|INVERS|DBLSIZE); - } - else if (g_vbat100mV > g_eeGeneral.vBatWarn && g_eeGeneral.mAhWarn && (g_eeGeneral.mAhUsed + Current_used * (488 + g_eeGeneral.currentCalib)/8192/36) / 500 >= g_eeGeneral.mAhWarn) { - putsTelemetryValue(7*FW-1, 3*FH, (g_eeGeneral.mAhUsed + Current_used*(488 + g_eeGeneral.currentCalib)/8192/36)/10, UNIT_MAH, BLINK|INVERS|DBLSIZE); - } - else -#endif - { - LcdFlags att = (g_vbat100mV <= g_eeGeneral.vBatWarn ? BLINK|INVERS : 0) | MIDSIZE; - putsVBat(VBATT_X-1, VBATT_Y, att|NO_UNIT); -#if defined(PCBX9D) - lcd_putcAtt(VBATTUNIT_X, VBATTUNIT_Y, 'v', MIDSIZE); -#else - lcd_putc(VBATT_X, VBATTUNIT_Y, 'V'); -#endif - } + // Main Voltage (or alarm if any) + displayVoltage(); -#if defined(LCD212) - // Main timer - if (g_model.timers[0].mode) { - putsTime(TIMERS_X, 0, s_timerVal[0], MIDSIZE, MIDSIZE); - putsTmrMode(TIMERS_X-16, 5, g_model.timers[0].mode, SWCONDENSED|SMLSIZE); - if (g_model.timers[0].remanent) lcd_putcAtt(TIMERS_R, 1, 'R', SMLSIZE); - if (s_timerState[0]==TMR_BEEPING) { - lcd_hline(TIMERS_X-6, 2, 4); - // lcd_hline(TIMERS_X-6, 3, 4); - if (BLINK_ON_PHASE) - lcd_filled_rect(TIMERS_X-17, 0, 69, 12); - } - } + // Timers + displayTimers(); - // Second timer - if (g_model.timers[1].mode) { - putsTime(TIMERS_X, FH+3, s_timerVal[1], MIDSIZE, MIDSIZE); - putsTmrMode(TIMERS_X-16, FH+8, g_model.timers[1].mode, SWCONDENSED|SMLSIZE); - if (g_model.timers[1].remanent) lcd_putcAtt(TIMERS_R, FH+4, 'R', SMLSIZE); - if (s_timerState[1]==TMR_BEEPING) { - lcd_hline(TIMERS_X-6, FH+5, 4); - // lcd_hline(TIMERS_X-6, FH+6, 4); - if (BLINK_ON_PHASE) - lcd_filled_rect(TIMERS_X-17, FH+3, 69, 12); - } - } -#else - // Main timer - if (g_model.timers[0].mode) { - uint8_t att = DBLSIZE | (s_timerState[0]==TMR_BEEPING ? BLINK|INVERS : 0); - putsTime(12*FW+2, FH*2, s_timerVal[0], att, att); - putsTmrMode(s_timerVal[0] >= 0 ? 9*FW-FW/2+3 : 9*FW-FW/2-4, FH*3, g_model.timers[0].mode, SWCONDENSED); - } -#endif - - // Trim sliders - for (uint8_t i=0; i<4; i++) { -#define TL 27 - // LH LV RV RH -#if defined(LCD212) - static xcoord_t x[4] = {32+9, 10, DISPLAY_W-11, DISPLAY_W-32-9}; -#else - static uint8_t x[4] = {DISPLAY_W*1/4+2, 3, DISPLAY_W-4, DISPLAY_W*3/4-2}; -#endif - static uint8_t vert[4] = {0,1,1,0}; - uint8_t xm, ym; - xm = x[CONVERT_MODE(i+1)-1]; - - uint8_t att = ROUND; - int16_t val = getTrimValue(phase, i); - - if (val < -125 || val > 125) - att = BLINK|INVERS|ROUND; - - if (val < -(TL+1)*4) - val = -(TL+1); - else if (val > (TL+1)*4) - val = TL+1; - else - val /= 4; - - if (vert[i]) { - ym = 31; - lcd_vline(xm, ym-TL, TL*2); - if (i!=2 || !g_model.thrTrim) { - lcd_vline(xm-1, ym-1, 3); - lcd_vline(xm+1, ym-1, 3); - } - ym -= val; - } - else { - ym = 60; - lcd_hline(xm-TL, ym, TL*2); - lcd_hline(xm-1, ym-1, 3); - lcd_hline(xm-1, ym+1, 3); - xm += val; - } - lcd_square(xm-3, ym-3, 7, att); - } + // Trims sliders + displayTrims(phase); } #if defined(PCBX9D) - for (uint8_t i=NUM_STICKS; iNUM_STICKS+1 ? DISPLAY_W-5 : 3); - int8_t y = (i%2 ? DISPLAY_H/2+1 : 1); - lcd_vline(x, y, DISPLAY_H/2-2); - lcd_vline(x+1, y, DISPLAY_H/2-2); - y += ((calibratedStick[i]+RESX)*(DISPLAY_H/2-4)/(RESX*2)); // calculate once per loop - lcd_vline(x-1, y, 2); - lcd_vline(x+2, y, 2); - } -#endif + // Sliders (Pots / Sliders) + displaySliders(); -#if defined(LCD212) - if (view_base == VIEW_OUTPUTS) { + // Model Bitmap + lcd_img(BITMAP_X, BITMAP_Y, modelBitmap, 0, 0); + // Switches + for (uint8_t i=0; i<8; i++) { + uint8_t sw; + switch(i) { + case 0: + sw = getValue(MIXSRC_SA) > 0 ? 2 : 1; + break; + case 7: + sw = getValue(MIXSRC_SH) > 0 ? 2+2+3*6 : 1+3*6; + break; + default: + { + int8_t val = getValue(MIXSRC_SA+i); + sw = ((val > 0) ? 3*i+2 : ((val < 0) ? 3*i+1 : 3*i)); + break; + } + } + putsSwitches((g_eeGeneral.view == VIEW_SWITCHES) ? (i<4 ? 3*FW+2 : 8*FW-1) : (i<4 ? 8*FW+3 : 24*FW+1), (i%4)*FH+3*FH, sw, 0); } -#else + + if (g_eeGeneral.view == VIEW_INPUTS) { + // Sticks + doMainScreenGraphics(); + } + else { + // Custom Switches + uint8_t sw = 0; + for (uint8_t line=0; line<4; line++) { + for (uint8_t col=0; col<8; col++) { + uint8_t x = DISPLAY_W/2+7*FW+col*FW; + uint8_t y = DISPLAY_H/2-7+line*8; + lcd_putcAtt(x, y, sw>=9 ? 'A'+sw-9 : '1'+sw, SMLSIZE); + if (getSwitch(DSW(SW_SW1+sw), 0)) + lcd_filled_rect(x-1, y-1, 6, 8); + sw++; + } + } + } +#else // PCBX9D if (view_base < VIEW_INPUTS) { // scroll bar lcd_hlineStip(38, 34, 54, DOTTED); @@ -415,41 +519,17 @@ void menuMainView(uint8_t event) } } } -#endif else if (view_base == VIEW_INPUTS) { -#if defined(PCBX9D) - lcd_img(BITMAP_X, BITMAP_Y, modelBitmap, 0, 0); -#endif - if (view == VIEW_INPUTS) { - // hardware inputs + // Sticks + Pots doMainScreenGraphics(); -#if defined(PCBX9D) - for (uint8_t i=0; i<8; i++) { - uint8_t sw; - switch(i) { - case 0: - sw = getValue(MIXSRC_SA) > 0 ? 2 : 1; - break; - case 7: - sw = getValue(MIXSRC_SH) > 0 ? 2+2+3*6 : 1+3*6; - break; - default: - { - int8_t val = getValue(MIXSRC_SA+i); - sw = ((val > 0) ? 3*i+2 : ((val < 0) ? 3*i+1 : 3*i)); - break; - } - } - putsSwitches(i<4 ? 8*FW+3: 24*FW+1, (i%4)*FH+3*FH, sw, 0); - } -#else + + // Switches for (uint8_t i=0; i<6; i++) { int8_t sw1 = (i<3 ? 1+i : 4+i); int8_t sw2 = (sw1 == 9 ? (getSwitch(4, 0) ? 4 : (getSwitch(5, 0) ? 5 : 6)) : sw1); putsSwitches(i<3 ? 2*FW-3: 17*FW+2, (i%3)*FH+4*FH+1, sw2, getSwitch(sw1, 0) ? INVERS : 0); } -#endif } else { #if defined(PCBGRUVIN9X) && defined(ROTARY_ENCODERS) @@ -464,7 +544,9 @@ void menuMainView(uint8_t event) V_BAR(DISPLAY_W/2-3+V_BAR_W*i, DISPLAY_H-8, len) #endif //EXTRA_ROTARY_ENCODERS } -#endif // ROTARY_ENCODERS +#endif // PCBGRUVIN9X && ROTARY_ENCODERS + + // Curstom Switches #if defined(PCBSKY9X) for (uint8_t i=0; i= 0 ? 20-FW/2+5 : 20-FW/2-2, FH*6, g_model.timers[1].mode, SWCONDENSED); // lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s } +#endif // PCBX9D // And ! in case of unexpected shutdown if (unexpectedShutdown) { @@ -523,5 +606,5 @@ void menuMainView(uint8_t event) if (s_bind_mode) // Issue 98 lcd_putsAtt(15*FW, 0, PSTR("BIND"), 0); #endif - } + diff --git a/src/menus.h b/src/menus.h index 269b3e30e..72d16c5c0 100644 --- a/src/menus.h +++ b/src/menus.h @@ -242,4 +242,6 @@ void drawStatusLine(); #define drawStatusLine() #endif +void menuChannelsMonitor(uint8_t event); + #endif diff --git a/src/model_menus.cpp b/src/model_menus.cpp index bcd31ac04..3e32b7308 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -1796,6 +1796,14 @@ enum MixFields { void menuModelMixOne(uint8_t event) { +#if defined(PCBX9D) + if (event == EVT_KEY_LONG(KEY_PAGE)) { + pushMenu(menuChannelsMonitor); + killEvents(event); + return; + } +#endif + TITLE(s_currCh ? STR_INSERTMIX : STR_EDITMIX); MixData *md2 = mixaddress(s_currIdx) ; putsChn(lcdLastPos+1*FW,0,md2->destCh+1,0); @@ -2210,6 +2218,14 @@ void menuModelExposAll(uint8_t event) void menuModelMixAll(uint8_t event) { +#if defined(PCBX9D) + if (event == EVT_KEY_LONG(KEY_PAGE)) { + pushMenu(menuChannelsMonitor); + killEvents(event); + return; + } +#endif + return menuModelExpoMix(0, event); } diff --git a/src/monitors_views.cpp b/src/monitors_views.cpp new file mode 100644 index 000000000..aabce9f09 --- /dev/null +++ b/src/monitors_views.cpp @@ -0,0 +1,84 @@ +/* + * Authors (alphabetical order) + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * open9x is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "open9x.h" + +void menuChannelsMonitor(uint8_t event) +{ + switch(event) + { + case EVT_KEY_BREAK(KEY_EXIT): + popMenu(); + return; + } + + lcd_putsCenter(0*FH, CHANNELS_MONITOR); + lcd_invert_line(0); + + uint8_t ch = 0; + + for (uint8_t col=0; col<4; col++) { + + uint8_t x = col*DISPLAY_W/4; + + // Column title + lcd_outdezNAtt(col==0 ? 25 : (col == 1 ? 73 : x+DISPLAY_W/8-5*FWNUM/2+2), 1*FH+1, ch+1, LEFT|SMLSIZE); + lcd_putcAtt(lcdLastPos-1, 1*FH+1, '-', SMLSIZE); + lcd_outdezNAtt(lcdLastPos+FW-1, 1*FH+1, ch+8, LEFT|SMLSIZE); + + // Column separator + if (col != 0) + lcd_vline(x, FH, DISPLAY_H-FH); + + // Channels + for (uint8_t line=0; line<8; line++) { + uint8_t y = 16+line*6; + int16_t val = g_chans512[ch]; + + lcd_outdezNAtt(x+18, y, calcRESXto100(val), TINSIZE); + +#define WBAR 32 + + lcd_rect(x+18, y, WBAR+2, 5); + uint16_t lim = g_model.extendedLimits ? 640*2 : 512*2; + uint8_t len = limit((uint8_t)1, uint8_t((abs(val) * WBAR/2 + lim/2) / lim), uint8_t(WBAR/2)); + uint8_t x0 = (val>0) ? x+19+WBAR/2 : x+19+WBAR/2-len; + lcd_hline(x0, y+1, len); + lcd_hline(x0, y+2, len); + lcd_hline(x0, y+3, len); + ch++; + +#undef WBAR + } + } +} diff --git a/src/myeeprom.h b/src/myeeprom.h index 5757c6638..5cafd4dc1 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -78,8 +78,8 @@ PACK(typedef struct t_FrSkyRSSIAlarm { #if defined(LCD212) enum MainViews { - VIEW_OUTPUTS, VIEW_INPUTS, + VIEW_SWITCHES, VIEW_COUNT }; #else diff --git a/src/open9x.cpp b/src/open9x.cpp index c98af60ed..72a959fad 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -602,7 +602,7 @@ int16_t applyLimits(uint8_t channel, int32_t value) } int16_t calibratedStick[NUM_STICKS+NUM_POTS]; -int16_t g_chans512[NUM_CHNOUT]; +int16_t g_chans512[NUM_CHNOUT] = {0}; int16_t ex_chans[NUM_CHNOUT] = {0}; // Outputs (before LIMITS) of the last perMain #ifdef HELI int16_t cyc_anas[3] = {0}; diff --git a/src/open9x.h b/src/open9x.h index ede6140c0..ae2752110 100644 --- a/src/open9x.h +++ b/src/open9x.h @@ -1008,23 +1008,22 @@ void resetProto(); #if defined(PCBSKY9X) inline int32_t calc100toRESX(register int8_t x) { - return ((uint32_t)x*655)>>6 ; + return x * 1024 / 100; } inline int16_t calc1000toRESX(register int32_t x) // improve calc time by Pat MacKenzie { - register int32_t y = x>>5; - x+=y; - y=y>>2; - x-=y; - return x+(y>>2); - // return x + x/32 - x/128 + x/512; + return x * 1024 / 1000; } inline int16_t calcRESXto1000(register int32_t x) { -// *1000/1024 = x - x/32 + x/128 - return (x - x/32 + x/128 - x/512); + return x * 1000 / 1024; +} + +inline int16_t calcRESXto100(register int32_t x) +{ + return x * 100 / 1024; } #else diff --git a/src/statistics_views.cpp b/src/statistics_views.cpp index 682f08544..9e14dc9d0 100644 --- a/src/statistics_views.cpp +++ b/src/statistics_views.cpp @@ -36,6 +36,7 @@ void menuStatisticsView(uint8_t event) { TITLE(STR_MENUSTAT); + switch(event) { case EVT_KEY_FIRST(KEY_UP): @@ -84,9 +85,11 @@ void menuStatisticsView(uint8_t event) #else #define MENU_DEBUG_COL_OFS (14*FW) #endif + void menuStatisticsDebug(uint8_t event) { TITLE(STR_MENUDEBUG); + switch(event) { #if defined(PCBSKY9X) diff --git a/src/translations.cpp b/src/translations.cpp index 5514e9bfb..dd4222ee5 100644 --- a/src/translations.cpp +++ b/src/translations.cpp @@ -375,6 +375,7 @@ const pm_char STR_GLOBAL_VARS[] PROGMEM = TR_GLOBAL_VARS; const pm_char STR_OWN[] PROGMEM = TR_OWN; const pm_char STR_ROTARY_ENCODER[] PROGMEM = TR_ROTARY_ENCODER; const pm_char STR_DATE[] PROGMEM = TR_DATE; +const pm_char STR_CHANNELS_MONITOR[] PROGMEM = TR_CHANNELS_MONITOR; const pm_uchar font_5x7[] PROGMEM = { #include "font.lbm" @@ -409,6 +410,10 @@ const pm_uchar font_10x14[] PROGMEM = { }; #if defined(PCBX9D) +const pm_uchar font_3x5[] PROGMEM = { +#include "font_tiny.lbm" +}; + const pm_uchar font_4x6[] PROGMEM = { #include "font_small.lbm" }; diff --git a/src/translations.h b/src/translations.h index c26d1b479..c6aad0f45 100644 --- a/src/translations.h +++ b/src/translations.h @@ -423,6 +423,7 @@ extern const pm_uchar font_5x7[]; extern const pm_uchar font_10x14[]; #if defined(PCBX9D) +extern const pm_uchar font_3x5[]; extern const pm_uchar font_4x6[]; extern const pm_uchar font_8x10[]; extern const pm_uchar font_5x7_extra[]; @@ -478,6 +479,7 @@ extern const pm_char STR_GLOBAL_VARS[]; extern const pm_char STR_OWN[]; extern const pm_char STR_ROTARY_ENCODER[]; extern const pm_char STR_DATE[]; +extern const pm_char STR_CHANNELS_MONITOR[]; #if defined(VOICE) PLAY_FUNCTION(playNumber, int16_t number, uint8_t unit, uint8_t att); diff --git a/src/translations/cz.h b/src/translations/cz.h index ee2e2a93d..0e783b103 100644 --- a/src/translations/cz.h +++ b/src/translations/cz.h @@ -458,3 +458,4 @@ #define TR_OWN "Sv\200" #define TR_DATE "Date" #define TR_ROTARY_ENCODER "R.Encs" +#define TR_CHANNELS_MONITOR "CHANNELS MONITOR" diff --git a/src/translations/de.h b/src/translations/de.h index a13c7a7ed..ec08682ff 100644 --- a/src/translations/de.h +++ b/src/translations/de.h @@ -464,3 +464,4 @@ #define TR_OWN "Eigen" #define TR_DATE "Datum" #define TR_ROTARY_ENCODER "Drehgeber" +#define TR_CHANNELS_MONITOR "CHANNELS MONITOR" diff --git a/src/translations/en.h b/src/translations/en.h index cdcf1f759..7dfe5985f 100644 --- a/src/translations/en.h +++ b/src/translations/en.h @@ -475,3 +475,4 @@ #define TR_OWN "Own" #define TR_DATE "Date" #define TR_ROTARY_ENCODER "R.Encs" +#define TR_CHANNELS_MONITOR "CHANNELS MONITOR" diff --git a/src/translations/es.h b/src/translations/es.h index f27eb335e..6584fb1d1 100644 --- a/src/translations/es.h +++ b/src/translations/es.h @@ -458,3 +458,4 @@ #define TR_OWN "Own" #define TR_DATE "Date" #define TR_ROTARY_ENCODER "R.Encs" +#define TR_CHANNELS_MONITOR "CHANNELS MONITOR" diff --git a/src/translations/fr.h b/src/translations/fr.h index dceb0844e..70e696c02 100644 --- a/src/translations/fr.h +++ b/src/translations/fr.h @@ -464,3 +464,4 @@ #define TR_OWN "Pers" #define TR_DATE "Date" #define TR_ROTARY_ENCODER "Enc.Rot." +#define TR_CHANNELS_MONITOR "CHANNELS MONITOR" diff --git a/src/translations/it.h b/src/translations/it.h index 30d55851c..6eec80296 100644 --- a/src/translations/it.h +++ b/src/translations/it.h @@ -462,3 +462,4 @@ #define TR_OWN "Own" #define TR_DATE "Date" #define TR_ROTARY_ENCODER "R.Encs" +#define TR_CHANNELS_MONITOR "CHANNELS MONITOR" diff --git a/src/translations/pt.h b/src/translations/pt.h index 29f311025..3195fa3f2 100644 --- a/src/translations/pt.h +++ b/src/translations/pt.h @@ -464,4 +464,4 @@ #define TR_OWN "Propr." #define TR_DATE "Data" #define TR_ROTARY_ENCODER "R.Encs" - +#define TR_CHANNELS_MONITOR "CHANNELS MONITOR" diff --git a/src/translations/se.h b/src/translations/se.h index 678db72d2..8d4d30add 100644 --- a/src/translations/se.h +++ b/src/translations/se.h @@ -467,3 +467,4 @@ #define TR_OWN "Egen" #define TR_DATE "Datum" #define TR_ROTARY_ENCODER "R.Enks" +#define TR_CHANNELS_MONITOR "CHANNELS MONITOR"