From 1c7e7226de55d44e2cf9eed5c6045188bb107369 Mon Sep 17 00:00:00 2001 From: "bsongis@gmail.com" Date: Tue, 6 Aug 2013 16:50:23 +0000 Subject: [PATCH] [Taranis] GVARS can now refer to the GVAR of another phase [Taranis] Issue 90 fixed (french translation) [9XR] TELEMETRY_MOD=STD|14051 added (thanks Gerard for the patch) --- src/Makefile | 101 ++++------------------------ src/gui/menu_model.cpp | 21 ++++-- src/gui/menus.cpp | 4 +- src/opentx.cpp | 106 +++++++++++++++++++++++------- src/opentx.h | 4 +- src/targets/stock/board_stock.cpp | 31 ++++----- src/translations.cpp | 2 +- src/translations/cz.h | 1 + src/translations/cz.h.txt | 1 + src/translations/de.h | 1 + src/translations/de.h.txt | 1 + src/translations/en.h | 1 + src/translations/es.h | 1 + src/translations/es.h.txt | 1 + src/translations/fr.h | 1 + src/translations/fr.h.txt | 1 + src/translations/it.h | 1 + src/translations/it.h.txt | 1 + src/translations/pt.h | 1 + src/translations/pt.h.txt | 1 + src/translations/se.h | 1 + src/translations/se.h.txt | 1 + util/img2lbm.py | 24 ++++--- 23 files changed, 162 insertions(+), 146 deletions(-) diff --git a/src/Makefile b/src/Makefile index b4e2e8b50..2febb3b84 100644 --- a/src/Makefile +++ b/src/Makefile @@ -289,7 +289,11 @@ ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR)) else CPPDEFS += -DPCB9X endif - + + ifeq ($(TELEMETRY_MOD), 14051) + CPPDEFS += -DTELEMETRY_MOD_14051 + endif + ifeq ($(AUDIO), YES) CPPDEFS += -DAUDIO CPPSRC += audio_avr.cpp @@ -344,6 +348,10 @@ ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128)) else CPPDEFS += -DPCB9X128 endif + + ifeq ($(TELEMETRY_MOD), 14051) + CPPDEFS += -DTELEMETRY_MOD_14051 + endif ifeq ($(AUDIO), YES) CPPDEFS += -DAUDIO @@ -1044,7 +1052,7 @@ else endif tra: translations/se.h -lbm: fonts/std/font_05x07.lbm fonts/sqt5/font_05x07.lbm bitmaps/sticks.lbm +lbm: fonts bitmaps/sticks.lbm elf: $(TARGET).elf bin: $(TARGET).bin @@ -1116,93 +1124,12 @@ translations/se.h: translations/cz.h.txt translations/de.h.txt translations/es.h $(TRANSLATE) translations/pt.h.txt translations/pt.h pt @echo "Swedish" $(TRANSLATE) translations/se.h.txt translations/se.h se - -ifeq ($(FONT), SQT5) -fonts/sqt5/font_05x07.lbm: fonts/std/font_03x05.png fonts/sqt5/font_04x06.png fonts/sqt5/font_05x07.png fonts/sqt5/font_08x10.png fonts/sqt5/font_10x14.png fonts/sqt5/font_10x14_compressed.png fonts/std/font_04x06_extra.png fonts/std/font_05x07_extra.png fonts/std/font_10x14_extra.png fonts/sqt5/font_cz_04x06.png fonts/sqt5/font_cz_05x07.png fonts/sqt5/font_cz_08x10.png fonts/sqt5/font_cz_10x14.png fonts/std/font_de_04x06.png fonts/std/font_de_05x07.png fonts/std/font_de_08x10.png fonts/std/font_de_10x14.png fonts/std/font_es_04x06.png fonts/std/font_es_05x07.png fonts/std/font_es_08x10.png fonts/std/font_es_10x14.png fonts/std/font_fr_04x06.png fonts/std/font_fr_05x07.png fonts/std/font_fr_08x10.png fonts/std/font_fr_10x14.png fonts/std/font_it_04x06.png fonts/std/font_it_05x07.png fonts/std/font_it_08x10.png fonts/std/font_it_10x14.png fonts/std/font_se_04x06.png fonts/std/font_se_05x07.png fonts/std/font_se_08x10.png fonts/std/font_se_10x14.png - @echo - @echo "Convert SQT5 fonts from png to lbm:" - $(IMG2LBM) fonts/std/font_03x05.png fonts/std/font_03x05.lbm 3x5 - $(IMG2LBM) fonts/sqt5/font_04x06.png fonts/sqt5/font_04x06.lbm 4x6 - $(IMG2LBM) fonts/sqt5/font_05x07.png fonts/sqt5/font_05x07.lbm 5x7 - $(IMG2LBM) fonts/sqt5/font_08x10.png fonts/sqt5/font_08x10.lbm 8x10 - $(IMG2LBM) fonts/sqt5/font_10x14.png fonts/sqt5/font_10x14.lbm 10x14 - $(IMG2LBM) fonts/sqt5/font_10x14_compressed.png fonts/sqt5/font_10x14_compressed.lbm 10x14 - $(IMG2LBM) fonts/std/font_04x06_extra.png fonts/std/font_04x06_extra.lbm 4x6 - $(IMG2LBM) fonts/std/font_05x07_extra.png fonts/std/font_05x07_extra.lbm 5x7 - $(IMG2LBM) fonts/std/font_10x14_extra.png fonts/std/font_10x14_extra.lbm 10x14 - $(IMG2LBM) fonts/sqt5/font_cz_04x06.png fonts/sqt5/font_cz_04x06.lbm 4x6 - $(IMG2LBM) fonts/sqt5/font_cz_05x07.png fonts/sqt5/font_cz_05x07.lbm 5x7 - $(IMG2LBM) fonts/sqt5/font_cz_08x10.png fonts/sqt5/font_cz_08x10.lbm 8x10 - $(IMG2LBM) fonts/sqt5/font_cz_10x14.png fonts/sqt5/font_cz_10x14.lbm 10x14 - $(IMG2LBM) fonts/std/font_de_04x06.png fonts/std/font_de_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_de_05x07.png fonts/std/font_de_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_de_08x10.png fonts/std/font_de_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_de_10x14.png fonts/std/font_de_10x14.lbm 10x14 - $(IMG2LBM) fonts/std/font_es_04x06.png fonts/std/font_es_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_es_05x07.png fonts/std/font_es_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_es_08x10.png fonts/std/font_es_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_es_10x14.png fonts/std/font_es_10x14.lbm 10x14 - $(IMG2LBM) fonts/std/font_fr_04x06.png fonts/std/font_fr_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_fr_05x07.png fonts/std/font_fr_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_fr_08x10.png fonts/std/font_fr_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_fr_10x14.png fonts/std/font_fr_10x14.lbm 10x14 - $(IMG2LBM) fonts/std/font_it_04x06.png fonts/std/font_it_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_it_05x07.png fonts/std/font_it_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_it_08x10.png fonts/std/font_it_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_it_10x14.png fonts/std/font_it_10x14.lbm 10x14 - $(IMG2LBM) fonts/std/font_pt_04x06.png fonts/std/font_pt_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_pt_05x07.png fonts/std/font_pt_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_pt_08x10.png fonts/std/font_pt_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_pt_10x14.png fonts/std/font_pt_10x14.lbm 10x14 - $(IMG2LBM) fonts/std/font_se_04x06.png fonts/std/font_se_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_se_05x07.png fonts/std/font_se_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_se_08x10.png fonts/std/font_se_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_se_10x14.png fonts/std/font_se_10x14.lbm 10x14 -else +.PHONY: fonts +fonts: $(patsubst %.png,%.lbm,$(wildcard fonts/*/*.png)) -fonts/std/font_05x07.lbm: fonts/std/font_03x05.png fonts/std/font_04x06.png fonts/std/font_05x07.png fonts/std/font_08x10.png fonts/std/font_10x14.png fonts/std/font_10x14_compressed.png fonts/std/font_04x06_extra.png fonts/std/font_05x07_extra.png fonts/std/font_10x14_extra.png fonts/std/font_cz_04x06.png fonts/std/font_cz_05x07.png fonts/std/font_cz_08x10.png fonts/std/font_cz_10x14.png fonts/std/font_de_04x06.png fonts/std/font_de_05x07.png fonts/std/font_de_08x10.png fonts/std/font_de_10x14.png fonts/std/font_es_04x06.png fonts/std/font_es_05x07.png fonts/std/font_es_08x10.png fonts/std/font_es_10x14.png fonts/std/font_fr_04x06.png fonts/std/font_fr_05x07.png fonts/std/font_fr_08x10.png fonts/std/font_fr_10x14.png fonts/std/font_it_04x06.png fonts/std/font_it_05x07.png fonts/std/font_it_08x10.png fonts/std/font_it_10x14.png fonts/std/font_se_04x06.png fonts/std/font_se_05x07.png fonts/std/font_se_08x10.png fonts/std/font_se_10x14.png - - @echo - @echo "Convert fonts from png to lbm:" - $(IMG2LBM) fonts/std/font_03x05.png fonts/std/font_03x05.lbm 3x5 - $(IMG2LBM) fonts/std/font_04x06.png fonts/std/font_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_05x07.png fonts/std/font_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_08x10.png fonts/std/font_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_10x14.png fonts/std/font_10x14.lbm 10x14 - $(IMG2LBM) fonts/std/font_10x14_compressed.png fonts/std/font_10x14_compressed.lbm 10x14 - $(IMG2LBM) fonts/std/font_04x06_extra.png fonts/std/font_04x06_extra.lbm 4x6 - $(IMG2LBM) fonts/std/font_05x07_extra.png fonts/std/font_05x07_extra.lbm 5x7 - $(IMG2LBM) fonts/std/font_10x14_extra.png fonts/std/font_10x14_extra.lbm 10x14 - $(IMG2LBM) fonts/std/font_cz_04x06.png fonts/std/font_cz_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_cz_05x07.png fonts/std/font_cz_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_cz_08x10.png fonts/std/font_cz_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_cz_10x14.png fonts/std/font_cz_10x14.lbm 10x14 - $(IMG2LBM) fonts/std/font_de_04x06.png fonts/std/font_de_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_de_05x07.png fonts/std/font_de_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_de_08x10.png fonts/std/font_de_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_de_10x14.png fonts/std/font_de_10x14.lbm 10x14 - $(IMG2LBM) fonts/std/font_es_04x06.png fonts/std/font_es_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_es_05x07.png fonts/std/font_es_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_es_08x10.png fonts/std/font_es_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_es_10x14.png fonts/std/font_es_10x14.lbm 10x14 - $(IMG2LBM) fonts/std/font_fr_04x06.png fonts/std/font_fr_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_fr_05x07.png fonts/std/font_fr_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_fr_08x10.png fonts/std/font_fr_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_fr_10x14.png fonts/std/font_fr_10x14.lbm 10x14 - $(IMG2LBM) fonts/std/font_it_04x06.png fonts/std/font_it_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_it_05x07.png fonts/std/font_it_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_it_08x10.png fonts/std/font_it_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_it_10x14.png fonts/std/font_it_10x14.lbm 10x14 - $(IMG2LBM) fonts/std/font_pt_04x06.png fonts/std/font_pt_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_pt_05x07.png fonts/std/font_pt_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_pt_08x10.png fonts/std/font_pt_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_pt_10x14.png fonts/std/font_pt_10x14.lbm 10x14 - $(IMG2LBM) fonts/std/font_se_04x06.png fonts/std/font_se_04x06.lbm 4x6 - $(IMG2LBM) fonts/std/font_se_05x07.png fonts/std/font_se_05x07.lbm 5x7 - $(IMG2LBM) fonts/std/font_se_08x10.png fonts/std/font_se_08x10.lbm 8x10 - $(IMG2LBM) fonts/std/font_se_10x14.png fonts/std/font_se_10x14.lbm 10x14 -endif +fonts/%.lbm: fonts/%.png + $(IMG2LBM) $^ $@ bitmaps/sticks.lbm: bitmaps/sticks_4x1.xbm bitmaps/splash_9x.xbm bitmaps/splash_taranis.png bitmaps/logo_taranis.bmp bitmaps/icons.png bitmaps/asterisk.xbm bitmaps/about_9x.png bitmaps/about_taranis.png bitmaps/asterisk_4bits.png @echo diff --git a/src/gui/menu_model.cpp b/src/gui/menu_model.cpp index fb97a7e88..9b5554ba5 100644 --- a/src/gui/menu_model.cpp +++ b/src/gui/menu_model.cpp @@ -3711,7 +3711,7 @@ void menuModelGVars(uint8_t event) putsStrIdx(0, y, STR_GV, i+1, (sub==i && m_posHorz<0) ? INVERS : 0); for (uint8_t j=0; j<1+MAX_PHASES; j++) { - uint8_t attr = ((sub==i && m_posHorz==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); + LcdFlags attr = ((sub==i && m_posHorz==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); xcoord_t x = 12*FW + FWNUM + (j-1)*(2+3*FWNUM) - 1; #if MAX_GVARS == 6 @@ -3729,13 +3729,13 @@ void menuModelGVars(uint8_t event) default: { PhaseData *phase = &g_model.phaseData[j-1]; - int16_t v = phase->gvars[i]; + int16_t & v = phase->gvars[i]; int16_t vmin, vmax; if (v > GVAR_MAX) { uint8_t p = v - GVAR_MAX - 1; - if (p >= s_currIdx) p++; - putsFlightPhase(x, y, p+1, attr); - vmin = GVAR_MAX+1; vmax = GVAR_MAX+MAX_PHASES; + if (p >= j-1) p++; + putsFlightPhase(x-15, y, p+1, attr|SMLSIZE); + vmin = GVAR_MAX+1; vmax = GVAR_MAX+MAX_PHASES-1; } else { if (abs(v) >= 100) @@ -3744,8 +3744,15 @@ void menuModelGVars(uint8_t event) lcd_outdezAtt(x, y, v, attr); vmin = -GVAR_MAX; vmax = GVAR_MAX; } - if (attr && ((s_editMode>0) || p1valdiff)) { - phase->gvars[i] = checkIncDec(event, v, vmin, vmax, EE_MODEL); + if (attr) { + if (event == EVT_KEY_LONG(KEY_ENTER)) { + s_editMode = 2; // TODO constant for that ... + v = (v > GVAR_MAX ? 0 : GVAR_MAX+1); + eeDirty(EE_MODEL); + } + else if (s_editMode>0 || p1valdiff) { + v = checkIncDec(event, v, vmin, vmax, EE_MODEL); + } } break; } diff --git a/src/gui/menus.cpp b/src/gui/menus.cpp index 761ca78b0..5092aea89 100644 --- a/src/gui/menus.cpp +++ b/src/gui/menus.cpp @@ -932,12 +932,12 @@ int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t m } if (idx < 0) { - value = (int16_t) GV_CALC_VALUE_IDX_NEG(idx,delta); + value = (int16_t) GV_CALC_VALUE_IDX_NEG(idx, delta); idx = -idx; lcd_putcAtt(x-6, y, '-', attr); } else { - value = (int16_t) GV_CALC_VALUE_IDX_POS(idx,delta); + value = (int16_t) GV_CALC_VALUE_IDX_POS(idx, delta); idx++; } putsStrIdx(x, y, STR_GV, idx, attr); diff --git a/src/opentx.cpp b/src/opentx.cpp index adb0d77d8..e5bb44f04 100644 --- a/src/opentx.cpp +++ b/src/opentx.cpp @@ -1690,6 +1690,10 @@ void checkSwitches() while (1) { +#if defined(TELEMETRY_MOD_14051) + getADC(); +#endif + getMovedSwitch(); switches_states <<= 1; @@ -1988,31 +1992,89 @@ void getADC() } } #else -void getADC() + +/** + * Read ADC using 10 bits + */ +inline uint16_t read_adc10(uint8_t adc_input) { uint16_t temp_ana; - for (uint8_t adc_input=0; adc_input<8; adc_input++) { -/* - ADMUX = adc_input|ADC_VREF_TYPE; - // ADCSRA|=0x08; // enable ADC Interrupt Enable should not be necessary? or is it - MCUCR|=0x28; // enable Sleep (bit5) enable ADC Noise Reduction (bit3) - asm volatile(" sleep \n\t"); // if _SLEEP() is not defined use this - while (ADCSRA & 0x40); // Wait for the AD conversion to complete - temp_ana = ADC; - - asm volatile(" sleep \n\t"); // if _SLEEP() is not defined use this - while (ADCSRA & 0x40); // Wait for the AD conversion to complete - s_anaFilt[adc_input] = temp_ana + ADC; - MCUCR&=0x08; // disable sleep - */ + ADMUX = adc_input|ADC_VREF_TYPE; +#if defined(TELEMETRY_MOD_14051) + ADCSRA &= 0x87; +#endif + ADCSRA |= 1 << ADSC; // Start the AD conversion + while (ADCSRA & (1 << ADSC)); // Wait for the AD conversion to complete + temp_ana = ADC; + ADCSRA |= 1 << ADSC; // Start the second AD conversion + while (ADCSRA & (1 << ADSC)); // Wait for the AD conversion to complete + temp_ana += ADC; + return temp_ana; +} + +#if defined(TELEMETRY_MOD_14051) +enum MuxInput { + MUX_BATT, + MUX_THR, + MUX_AIL, + MUX_MAX = MUX_AIL +}; + +uint8_t pf7_digital[2]; +/** + * Update ADC PF7 using 14051 multiplexer + * X0 : Battery voltage + * X1 : THR SW + * X2 : AIL SW + */ +void readMultiplexAna() +{ + static uint8_t muxNum = MUX_BATT; + uint16_t temp_ana; + uint8_t nextMuxNum = muxNum-1; + + DDRC |= 0xC1; + temp_ana = read_adc10(7); + + switch (muxNum) { + case MUX_BATT: + s_anaFilt[TX_VOLTAGE] = temp_ana; + nextMuxNum = MUX_MAX; + break; + case MUX_THR: + case MUX_AIL: + // Digital switch depend from input voltage + // take half voltage to determine digital state + pf7_digital[muxNum-1] = (temp_ana >= (s_anaFilt[TX_VOLTAGE] / 2)) ? 1 : 0; + break; + } + + // set the mux number for the next ADC convert, + // stabilize voltage before ADC read. + muxNum = nextMuxNum; + PORTC &= ~((1 << PC7) | (1 << PC6) | (1 << PC0)); // Clear CTRL ABC + switch (muxNum) { + case 1: + PORTC |= (1 << PC6); // Mux CTRL A : SW_THR + break; + case 2: + PORTC |= (1 << PC7); // Mux CTRL B : SW_AIL + break; + } +} +#endif + +void getADC() +{ +#if defined(TELEMETRY_MOD_14051) + readMultiplexAna(); + #define ADC_READ_COUNT 7 +#else + #define ADC_READ_COUNT 8 +#endif - ADMUX = adc_input|ADC_VREF_TYPE; - ADCSRA|=0x40; // Start the AD conversion - while (ADCSRA & 0x40); // Wait for the AD conversion to complete - temp_ana = ADC; - ADCSRA|=0x40; // Start the second AD conversion - while (ADCSRA & 0x40); // Wait for the AD conversion to complete - s_anaFilt[adc_input] = temp_ana + ADC; + for (uint8_t adc_input=0; adc_input 3: + what = sys.argv[3] +else: + for s in ("03x05", "04x06", "05x07", "08x10", "10x14"): + if s in sys.argv[2]: + what = s + break + +if what == "largimg": rows = 1 if len(sys.argv) > 4: rows = int(sys.argv[4]) @@ -21,7 +29,7 @@ if sys.argv[3] == "largimg": value += 1 << z f.write("0x%02x," % value) f.write("\n") -elif sys.argv[3] == "img": +elif what == "img": rows = 1 if len(sys.argv) > 4: rows = int(sys.argv[4]) @@ -34,7 +42,7 @@ elif sys.argv[3] == "img": value += 1 << z f.write("0x%02x," % value) f.write("\n") -elif sys.argv[3] == "bmp": +elif what == "bmp": rows = 1 colors = [] if len(sys.argv) > 4: @@ -52,7 +60,7 @@ elif sys.argv[3] == "bmp": for value in values: f.write("0x%02x," % value) f.write("\n") -elif sys.argv[3] == "3x5": +elif what == "03x05": for y in range(0, height, 5): for x in range(width): value = 0 @@ -61,7 +69,7 @@ elif sys.argv[3] == "3x5": value += 1 << z f.write("0x%02x," % value) f.write("\n") -elif sys.argv[3] == "4x6": +elif what == "04x06": for y in range(0, height, 7): for x in range(width): value = 0 @@ -70,7 +78,7 @@ elif sys.argv[3] == "4x6": value += 1 << z f.write("0x%02x," % value) f.write("\n") -elif sys.argv[3] == "5x7": +elif what == "05x07": for y in range(0, height, 8): for x in range(width): value = 0 @@ -79,7 +87,7 @@ elif sys.argv[3] == "5x7": value += 1 << z f.write("0x%02x," % value) f.write("\n") -elif sys.argv[3] == "8x10": +elif what == "08x10": for y in range(0, height, 12): for x in range(width): for l in range(0, 12, 8): @@ -89,7 +97,7 @@ elif sys.argv[3] == "8x10": value += 1 << z f.write("0x%02x," % value) f.write("\n") -elif sys.argv[3] == "10x14": +elif what == "10x14": for y in range(0, height, 16): for x in range(width): for l in range(0, 16, 8):