From 11c1dba91ebe7dcd1f5ef8cb8adaacf81d5f9669 Mon Sep 17 00:00:00 2001 From: "bsongis@gmail.com" Date: Thu, 18 Apr 2013 20:04:37 +0000 Subject: [PATCH] [Taranis] Curve names [Taranis] Menu system now allows hidden rows [Taranis] DEBUG menu removed [stock2561] First draft! --- src/Makefile | 70 +++++++++++- src/eeprom_rlc.cpp | 6 +- src/eeprom_rlc.h | 2 +- src/gruvin9x/board_gruvin9x.h | 2 - src/lcd.cpp | 143 +++++++++++++++++++++++ src/lcd.h | 206 +++++++++++++++++----------------- src/maths.cpp | 2 +- src/mega2560/board_mega2560.h | 2 - src/menu_model.cpp | 197 +++++++++++++++++++++++++------- src/menus.cpp | 41 ++++++- src/menus.h | 5 + src/myeeprom.h | 84 ++++++++------ src/opentx.cpp | 103 +++++++++++++++-- src/opentx.h | 15 ++- src/pulses_avr.cpp | 30 ++--- src/simu.cpp | 19 +++- src/sky9x/board_sky9x.cpp | 3 + src/sky9x/board_sky9x.h | 4 +- src/stock/board_stock.cpp | 8 ++ src/stock/board_stock.h | 32 +++--- src/taranis/board_taranis.h | 22 ++-- src/translations/cz.h | 2 +- src/translations/de.h | 2 +- src/translations/en.h | 2 +- src/translations/es.h | 2 +- src/translations/fr.h | 2 +- src/translations/it.h | 2 +- src/translations/pt.h | 2 +- src/translations/se.h | 2 +- src/view_statistics.cpp | 11 ++ src/view_telemetry.cpp | 190 ------------------------------- 31 files changed, 752 insertions(+), 461 deletions(-) diff --git a/src/Makefile b/src/Makefile index 67751ed38..338cbe1e6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -50,7 +50,7 @@ DELAY = 5 #----------- BUILD OPTIONS --------------------------- # PCB version -# Values: 9X, 9X128, 9XR, 9XR128, GRUVIN9X, MEGA2560, SKY9X, TARANIS +# Values: 9X, 9X128, 9X2561, 9XR, 9XR128, 9XR2561, GRUVIN9X, MEGA2560, SKY9X, TARANIS # Old values STD and STD128 are mapped to 9X and 9X128 for compatibility PCB = 9X @@ -232,7 +232,7 @@ SRC = CPPSRC = # MCU name -ifneq ($(PCB), $(filter $(PCB), STD 9X 9XR STD128 9X128 9XR128 GRUVIN9X MEGA2560 SKY9X TARANIS)) +ifneq ($(PCB), $(filter $(PCB), STD 9X 9XR STD128 9X128 9XR128 9X2561 9XR2561 GRUVIN9X MEGA2560 SKY9X TARANIS)) $(error Sorry, the PCB $(PCB) is not supported yet in openTx) endif @@ -240,6 +240,7 @@ GVARS_VARIANT = +1 FRSKY_VARIANT = +2 3POS_VARIANT = +4 M128_VARIANT = +32768 +M2561_VARIANT = +16384 EEPROM_VARIANT = 0 ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR)) @@ -298,7 +299,7 @@ ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR)) endif ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128)) - # 9x/9xr radio with Atmega 64 replaced by Atmega 128 + # 9X/9XR radio with ATmega64 replaced by ATmega128 ARCH = AVR TRGT = avr- MCU = atmega128 @@ -352,6 +353,61 @@ ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128)) endif endif +ifeq ($(PCB), $(filter $(PCB), 9X2561)) + # 9X/9XR radio with ATmega64 replaced by ATmega2561 + ARCH = AVR + TRGT = avr- + MCU = atmega2561 + OPT = 2 + SDCARD = NO + THR_TRACE = YES + EEPROM_VARIANT += ${M2561_VARIANT} + CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM2561 -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc) + EXTRAINCDIRS = stock + BOARDSRC = stock/board_stock.cpp + EXTRABOARDSRC = stock/lcd_driver.cpp + EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp + PULSESSRC = pulses_avr.cpp + + ifeq ($(PCB), 9XR2561) + CPPDEFS += -DPCB9XR2561 + else + CPPDEFS += -DPCB9X2561 + endif + + ifeq ($(AUDIO), YES) + CPPDEFS += -DAUDIO + CPPSRC += audio_avr.cpp + else + CPPDEFS += -DBUZZER + CPPSRC += buzzer.cpp + endif + + ifeq ($(VOICE), YES) + CPPDEFS += -DVOICE + CPPSRC += stock/voice.cpp + endif + + ifeq ($(PWM_BACKLIGHT), YES) + ifeq ($(VOICE), YES) + $(error Sorry, PWM_BACKLIGHT doesnt work on stock board with VOICE mod) + endif + ifeq ($(AUDIO), YES) + $(error Sorry, PWM_BACKLIGHT doesnt work on stock board with AUDIO mod) + endif + CPPDEFS += -DPWM_BACKLIGHT + endif + + ifeq ($(HAPTIC), YES) + CPPDEFS += -DHAPTIC + CPPSRC += haptic.cpp + endif + + ifeq ($(SP22), YES) + CPPDEFS += -DSP22 + endif +endif + ifeq ($(PCB), GRUVIN9X) # 9x radio with a gruvin9x replacement board ARCH = AVR @@ -636,7 +692,7 @@ ifeq ($(AUTOSOURCE), YES) endif ifeq ($(DBLKEYS), YES) - ifeq ($(PCB), $(filter $(PCB), 9XR 9XR128)) + ifeq ($(PCB), $(filter $(PCB), 9XR 9XR128 9XR2561)) $(warning Sorry, DBLKEYS doesnt work on 9XR) else CPPDEFS += -DDBLKEYS @@ -952,6 +1008,12 @@ stock128-stamp: @echo "#define SVN_VERS \"opentx-r$(SVNREV)\"" >> stamp-opentx-stock128.txt @cat stamp-opentx-stock128.txt +stock2561-stamp: + @echo "#define DATE_STR \"`date +%Y-%m-%d`\"" > stamp-opentx-stock2561.txt + @echo "#define TIME_STR \"`date +%H:%M:%S`\"" >> stamp-opentx-stock2561.txt + @echo "#define SVN_VERS \"opentx-r$(SVNREV)\"" >> stamp-opentx-stock2561.txt + @cat stamp-opentx-stock2561.txt + v4-stamp: @echo "#define DATE_STR \"`date +%Y-%m-%d`\"" > stamp-opentx-v4.txt @echo "#define TIME_STR \"`date +%H:%M:%S`\"" >> stamp-opentx-v4.txt diff --git a/src/eeprom_rlc.cpp b/src/eeprom_rlc.cpp index 4091b1959..bcc8a0744 100644 --- a/src/eeprom_rlc.cpp +++ b/src/eeprom_rlc.cpp @@ -56,7 +56,7 @@ inline void eeprom_write_byte() EEAR = eeprom_pointer; EEDR = *eeprom_buffer_data; // TODO add some define here -#if defined (PCBGRUVIN9X) +#if defined (PCBGRUVIN9X) || defined(CPUM2561) EECR |= 1<= UNIT_RAW) { + converted_value /= 10; + } + else { +#if !defined(PCBTARANIS) + if (abs(converted_value) < 1000) { + att |= PREC2; + } + else { + converted_value /= 10; + att |= PREC1; + } +#else + att |= PREC2; +#endif + } + putsTelemetryValue(x, y, converted_value, g_model.frsky.channels[channel].type, att); + break; + } + + case TELEM_CELL-1: + putsTelemetryValue(x, y, val, UNIT_VOLTS, att|PREC2); + break; + + case TELEM_TX_VOLTAGE-1: + case TELEM_VFAS-1: + case TELEM_CELLS_SUM-1: + putsTelemetryValue(x, y, val, UNIT_VOLTS, att|PREC1); + break; + + case TELEM_CURRENT-1: + case TELEM_MAX_CURRENT-1: + putsTelemetryValue(x, y, val, UNIT_AMPS, att|PREC1); + break; + + case TELEM_CONSUMPTION-1: + putsTelemetryValue(x, y, val, UNIT_MAH, att); + break; + + case TELEM_POWER-1: + putsTelemetryValue(x, y, val, UNIT_WATTS, att); + break; + + case TELEM_ACCx-1: + case TELEM_ACCy-1: + case TELEM_ACCz-1: + case TELEM_VSPD-1: + putsTelemetryValue(x, y, val, UNIT_RAW, att|PREC2); + break; + + case TELEM_RSSI_TX-1: + case TELEM_RSSI_RX-1: + putsTelemetryValue(x, y, val, UNIT_RAW, att); + break; + +#if defined(FRSKY_SPORT) + case TELEM_ALT-1: + putsTelemetryValue(x, y, val/10, UNIT_METERS, att|PREC1); + break; +#elif defined(WS_HOW_HIGH) + case TELEM_ALT-1: + case TELEM_MIN_ALT-1: + case TELEM_MAX_ALT-1: + if (IS_IMPERIAL_ENABLE() && IS_USR_PROTO_WS_HOW_HIGH()) { + putsTelemetryValue(x, y, val, UNIT_FEET, att); + break; + } + // no break +#endif + + default: + { + uint8_t unit = 1; + if (channel >= TELEM_MAX_T1-1 && channel <= TELEM_MAX_DIST-1) + channel -= TELEM_MAX_T1 - TELEM_T1; + if (channel <= TELEM_GPSALT-1) + unit = channel + 1 - TELEM_ALT; + if (channel >= TELEM_MIN_ALT-1 && channel <= TELEM_MAX_ALT-1) + unit = 0; + if (channel == TELEM_HDG-1) + unit = 3; + putsTelemetryValue(x, y, val, pgm_read_byte(bchunit_ar+unit), att); + break; + } + } +} +#else // defined(FRSKY) +void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val, uint8_t att) +{ + switch (channel) { + case TELEM_TM1-1: + case TELEM_TM2-1: + att &= ~NO_UNIT; + putsTime(x, y, val, att, att); + break; + + case TELEM_TX_VOLTAGE-1: + lcd_outdezAtt(x, y, val, (att|PREC1) & (~NO_UNIT)); + if (!(att & NO_UNIT)) + lcd_putc(lcdLastPos/*+1*/, y, 'v'); + break; + } +} +#endif + void lcdSetContrast() { lcdSetRefVolt(g_eeGeneral.contrast); diff --git a/src/lcd.h b/src/lcd.h index 9c80eb535..84884a8bb 100644 --- a/src/lcd.h +++ b/src/lcd.h @@ -37,109 +37,102 @@ #ifndef lcd_h #define lcd_h -#if defined(PCBACT) -#define LCD_W 260 -#define LCD_H 75 -#define xcoord_t uint16_t -#define CENTER "\015" -#define CENTER_OFS (7*FW-FW/2) -#elif defined(PCBTARANIS) -#define LCD_W 212 -#define LCD_H 64 -#define xcoord_t uint16_t -#define CENTER "\015" -#define CENTER_OFS (7*FW-FW/2) +#if defined(PCBTARANIS) + #define LCD_W 212 + #define LCD_H 64 + #define xcoord_t uint16_t + #define CENTER "\015" + #define CENTER_OFS (7*FW-FW/2) #else -#define LCD_W 128 -#define LCD_H 64 -#define xcoord_t uint8_t -#define CENTER -#define CENTER_OFS 0 + #define LCD_W 128 + #define LCD_H 64 + #define xcoord_t uint8_t + #define CENTER + #define CENTER_OFS 0 #endif #if defined(CPUARM) -#define lcdint_t int32_t + #define lcdint_t int32_t #else -#define lcdint_t int16_t + #define lcdint_t int16_t #endif #if LCD_H > 64 -#define LCD_LINES 9 + #define LCD_LINES 9 #else -#define LCD_LINES 8 + #define LCD_LINES 8 #endif - -#define FW 6 -#define FWNUM 5 -#define FH 8 +#define FW 6 +#define FWNUM 5 +#define FH 8 /* lcd common flags */ -#define BLINK 0x01 +#define BLINK 0x01 /* lcd text flags */ -#define INVERS 0x02 -#define DBLSIZE 0x04 +#define INVERS 0x02 +#define DBLSIZE 0x04 #ifdef BOLD_FONT -#define BOLD 0x40 +#define BOLD 0x40 #else -#define BOLD 0x00 +#define BOLD 0x00 #endif /* lcd putc flags */ -#define CONDENSED 0x08 +#define CONDENSED 0x08 /* lcd puts flags */ /* no 0x80 here because of "GV"1 which is aligned LEFT */ /* no 0x10 here because of "MODEL"01 which uses LEADING0 */ -#define BSS 0x20 -#define ZCHAR 0x80 +#define BSS 0x20 +#define ZCHAR 0x80 /* lcd outdez flags */ -#define UNSIGN 0x08 -#define LEADING0 0x10 -#define PREC1 0x20 -#define PREC2 0x30 -#define MODE(flags) ((((int8_t)(flags) & 0x30) - 0x10) >> 4) -#define LEFT 0x80 /* align left */ +#define UNSIGN 0x08 +#define LEADING0 0x10 +#define PREC1 0x20 +#define PREC2 0x30 +#define MODE(flags) ((((int8_t)(flags) & 0x30) - 0x10) >> 4) +#define LEFT 0x80 /* align left */ /* line, rect, square flags */ -#define FORCE 0x02 -#define ERASE 0x04 -#define ROUND 0x08 +#define FORCE 0x02 +#define ERASE 0x04 +#define ROUND 0x08 #if defined(PCBTARANIS) - #define FILL_WHITE 0x10 + #define FILL_WHITE 0x10 #endif /* switches flags */ -#define SWCONDENSED 0x20 /* means that THRm will be displayed as THR */ +#define SWCONDENSED 0x20 /* means that THRm will be displayed as THR */ /* telemetry flags */ -#define NO_UNIT 0x40 +#define NO_UNIT 0x40 #if defined(CPUARM) - #define MIDSIZE 0x0100 - #define SMLSIZE 0x0200 - #define TINSIZE 0x0400 + #define MIDSIZE 0x0100 + #define SMLSIZE 0x0200 + #define TINSIZE 0x0400 #else - #define MIDSIZE DBLSIZE - #define SMLSIZE 0x00 - #define TINSIZE 0x00 + #define MIDSIZE DBLSIZE + #define SMLSIZE 0x00 + #define TINSIZE 0x00 #endif #if defined(PCBTARANIS) -#define GREY(x) ((x) * 0x1000) -#define GREY_DEFAULT GREY(11) -#define GREY_MASK(x) ((x) & 0xF000) +#define GREY(x) ((x) * 0x1000) +#define GREY_DEFAULT GREY(11) +#define GREY_MASK(x) ((x) & 0xF000) #endif #if defined(CPUARM) -#define LcdFlags uint32_t + #define LcdFlags uint32_t #else -#define LcdFlags uint8_t + #define LcdFlags uint8_t #endif -#define DISPLAY_PLAN_SIZE (LCD_W*((LCD_H+7)/8)) +#define DISPLAY_PLAN_SIZE (LCD_W*((LCD_H+7)/8)) #if defined(PCBTARANIS) #define DISPLAY_BUF_SIZE (4*DISPLAY_PLAN_SIZE) @@ -151,71 +144,72 @@ extern uint8_t displayBuf[DISPLAY_BUF_SIZE]; extern uint8_t lcdLastPos; #if defined(PCBSTD) && defined(VOICE) -extern volatile uint8_t LcdLock ; + extern volatile uint8_t LcdLock ; #endif #if defined(PCBSKY9X) -extern volatile uint8_t lcdLock ; -extern volatile uint32_t lcdInputs ; + extern volatile uint8_t lcdLock ; + extern volatile uint32_t lcdInputs ; #endif -extern void lcd_putc(xcoord_t x, uint8_t y, const unsigned char c); -extern void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags mode); -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_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); +void lcd_putc(xcoord_t x, uint8_t y, const unsigned char c); +void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags mode); +void lcd_putsAtt(xcoord_t x, uint8_t y, const pm_char * s, LcdFlags mode); +void lcd_putsiAtt(xcoord_t x, uint8_t y, const pm_char * s,uint8_t idx, LcdFlags mode); +void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s,unsigned char len, LcdFlags mode); +void lcd_puts(xcoord_t x, uint8_t y, const pm_char * s); +void lcd_putsn(xcoord_t x, uint8_t y, const pm_char * s, unsigned char len); +void lcd_putsLeft(uint8_t y, const pm_char * s); #define lcd_putsCenter(y, s) lcd_puts((LCD_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, lcdint_t val, LcdFlags mode=0); -extern void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags mode=0, uint8_t len=0); -extern void lcd_outdez8(xcoord_t x, uint8_t y, int8_t val); +void lcd_outhex4(xcoord_t x, uint8_t y, uint16_t val); +void lcd_outdezAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags mode=0); +void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags mode=0, uint8_t len=0); +void lcd_outdez8(xcoord_t x, uint8_t y, int8_t val); -extern void putsStrIdx(xcoord_t x, uint8_t y, const pm_char *str, uint8_t idx, LcdFlags att=0); -extern void putsModelName(xcoord_t x, uint8_t y, char *name, uint8_t id, LcdFlags att); -extern void putsSwitches(xcoord_t x, uint8_t y, int8_t swtch, LcdFlags att=0); -extern void putsMixerSource(xcoord_t x, uint8_t y, uint8_t idx, LcdFlags att=0); -extern void putsFlightPhase(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0); -extern void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0); -extern void putsTmrMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att); -extern void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att); +void putsStrIdx(xcoord_t x, uint8_t y, const pm_char *str, uint8_t idx, LcdFlags att=0); +void putsModelName(xcoord_t x, uint8_t y, char *name, uint8_t id, LcdFlags att); +void putsSwitches(xcoord_t x, uint8_t y, int8_t swtch, LcdFlags att=0); +void putsMixerSource(xcoord_t x, uint8_t y, uint8_t idx, LcdFlags att=0); +void putsFlightPhase(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0); +void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0); +void putsTmrMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att); +void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att); #if defined(ROTARY_ENCODERS) -void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att); + void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att); #endif #define putsChn(x, y, idx, att) putsMixerSource(x, y, MIXSRC_CH1+idx-1, att) -extern void putsChnLetter(xcoord_t x, uint8_t y, uint8_t idx, LcdFlags attr); +void putsChnLetter(xcoord_t x, uint8_t y, uint8_t idx, LcdFlags attr); -extern void putsVolts(xcoord_t x, uint8_t y, uint16_t volts, LcdFlags att); -extern void putsVBat(xcoord_t x, uint8_t y, LcdFlags att); +void putsVolts(xcoord_t x, uint8_t y, uint16_t volts, LcdFlags att); +void putsVBat(xcoord_t x, uint8_t y, LcdFlags att); +void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val, uint8_t att); #if defined(CPUARM) -#define putstime_t int32_t + #define putstime_t int32_t #else -#define putstime_t int16_t + #define putstime_t int16_t #endif -extern void putsTime(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2); +void putsTime(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2); #define SOLID 0xff #define DOTTED 0x55 -extern void lcd_plot(xcoord_t x, uint8_t y, LcdFlags att=0); -extern void lcd_hline(xcoord_t x, uint8_t y, xcoord_t w, LcdFlags att=0); -extern void lcd_hlineStip(xcoord_t x, uint8_t y, xcoord_t w, uint8_t pat, LcdFlags att=0); -extern void lcd_vline(xcoord_t x, int8_t y, int8_t h); +void lcd_plot(xcoord_t x, uint8_t y, LcdFlags att=0); +void lcd_hline(xcoord_t x, uint8_t y, xcoord_t w, LcdFlags att=0); +void lcd_hlineStip(xcoord_t x, uint8_t y, xcoord_t w, uint8_t pat, LcdFlags att=0); +void lcd_vline(xcoord_t x, int8_t y, int8_t h); #if defined(CPUM64) -extern void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat); + void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat); #else -extern void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat, LcdFlags att=0); + void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat, LcdFlags att=0); #endif -extern void lcd_rect(xcoord_t x, uint8_t y, xcoord_t w, uint8_t h, uint8_t pat=SOLID, LcdFlags att=0); -extern void lcd_filled_rect(xcoord_t x, int8_t y, xcoord_t w, uint8_t h, uint8_t pat=SOLID, LcdFlags att=0); -extern void lcd_invert_line(int8_t y); +void lcd_rect(xcoord_t x, uint8_t y, xcoord_t w, uint8_t h, uint8_t pat=SOLID, LcdFlags att=0); +void lcd_filled_rect(xcoord_t x, int8_t y, xcoord_t w, uint8_t h, uint8_t pat=SOLID, LcdFlags att=0); +void lcd_invert_line(int8_t y); #define lcd_status_line() lcd_invert_line(LCD_LINES-1) inline void lcd_square(xcoord_t x, uint8_t y, xcoord_t w, LcdFlags att=0) { lcd_rect(x, y, w, w, SOLID, att); } @@ -237,25 +231,25 @@ void lcdDrawTelemetryTopBar(); lcd_vline(x+4, y+8, 2); \ lcd_vline(x+5, y+8, 2); -extern void lcd_img(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t idx, LcdFlags att=0); -extern void lcd_bmp(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t offset=0, uint8_t width=0); +void lcd_img(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t idx, LcdFlags att=0); +void lcd_bmp(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t offset=0, uint8_t width=0); #define LCD_ICON(x, y, icon) lcd_bmp(x, y, icons, icon) -extern void lcdSetRefVolt(unsigned char val); -extern void lcdInit(); -extern void lcd_clear(); -extern void lcdSetContrast(); +void lcdSetRefVolt(unsigned char val); +void lcdInit(); +void lcd_clear(); +void lcdSetContrast(); -extern void lcdRefresh(); +void lcdRefresh(); #if defined(PCBTARANIS) -const pm_char * bmpLoad(uint8_t *dest, const char *filename, const xcoord_t width, const uint8_t height); + const pm_char * bmpLoad(uint8_t *dest, const char *filename, const xcoord_t width, const uint8_t height); #endif #define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6)) #ifdef SIMU -extern bool lcd_refresh; -extern uint8_t lcd_buf[DISPLAY_BUF_SIZE]; + extern bool lcd_refresh; + extern uint8_t lcd_buf[DISPLAY_BUF_SIZE]; #endif #define LCD_BYTE_FILTER_PLAN(p, keep, add) *(p) = (*(p) & (keep)) | (add) diff --git a/src/maths.cpp b/src/maths.cpp index 871839d63..f4e5b67c1 100644 --- a/src/maths.cpp +++ b/src/maths.cpp @@ -36,7 +36,7 @@ #include "opentx.h" -#if defined(FRSKY) +#if defined(FRSKY) || defined(CPUARM) uint16_t getChannelRatio(uint8_t channel) { return (uint16_t)g_model.frsky.channels[channel].ratio << g_model.frsky.channels[channel].multiplier; diff --git a/src/mega2560/board_mega2560.h b/src/mega2560/board_mega2560.h index 05377aa48..645f9a477 100644 --- a/src/mega2560/board_mega2560.h +++ b/src/mega2560/board_mega2560.h @@ -9,8 +9,6 @@ #define TIMER_10MS_COMPVAL OCR2A #define PAUSE_10MS_INTERRUPT() TIMSK2 &= ~(1<= 0); - #define IF_PORT1_ON(x) (g_model.moduleData[0].rfProtocol == RF_PROTO_OFF ? (uint8_t)-1 : (uint8_t)(x)) - #define IF_PORT2_ON(x) (g_model.externalModule == MODULE_TYPE_NONE ? (uint8_t)-1 : (uint8_t)(x)) + #define IF_PORT1_ON(x) (g_model.moduleData[0].rfProtocol == RF_PROTO_OFF ? HIDDEN_ROW : (uint8_t)(x)) + #define IF_PORT2_ON(x) (g_model.externalModule == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x)) #define IF_PORT_ON(idx, x) (idx==0 ? IS_PORT1_ON(x) : IS_PORT2_ON(x)) - #define IF_PORT2_XJT(x) (IS_MODULE_XJT(1) ? (uint8_t)x : (uint8_t)-1) + #define IF_PORT2_XJT(x) (IS_MODULE_XJT(1) ? (uint8_t)x : HIDDEN_ROW) #define PORT1_CHANNELS_ROWS() IF_PORT1_ON(1) #define PORT2_CHANNELS_ROWS() IF_PORT2_ON(g_model.externalModule == MODULE_TYPE_DJT ? (uint8_t)0 : (g_model.externalModule == MODULE_TYPE_DSM2 ? (uint8_t)0 : ((uint8_t)1))) #define PORT_CHANNELS_ROWS(x) (x==0 ? PORT1_CHANNELS_ROWS() : PORT2_CHANNELS_ROWS()) - MENU(STR_MENUSETUP, menuTabModel, e_ModelSetup, 1+ITEM_MODEL_SETUP_MAX, { 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), LABEL(InternalModule), 0, IF_PORT1_ON(1), IF_PORT1_ON(2), IF_PORT1_ON(g_model.moduleData[0].failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0), LABEL(ExternalModule), g_model.externalModule==MODULE_TYPE_XJT ? (uint8_t)1 : (uint8_t)0, PORT2_CHANNELS_ROWS(), (IS_MODULE_PPM(1) || IS_MODULE_XJT(1) ? (uint8_t)2 : (uint8_t)-1), IF_PORT2_XJT(g_model.moduleData[1].failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0), 0}); + MENU(STR_MENUSETUP, menuTabModel, e_ModelSetup, 1+ITEM_MODEL_SETUP_MAX, { 0, 0, CASE_PCBTARANIS(0) 2, IF_PERSISTENT_TIMERS(0) 0, 0, 2, IF_PERSISTENT_TIMERS(0) 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), LABEL(InternalModule), 0, IF_PORT1_ON(1), IF_PORT1_ON(2), IF_PORT1_ON(g_model.moduleData[0].failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0), LABEL(ExternalModule), g_model.externalModule==MODULE_TYPE_XJT ? (uint8_t)1 : (uint8_t)0, PORT2_CHANNELS_ROWS(), (IS_MODULE_PPM(1) || IS_MODULE_XJT(1) ? (uint8_t)2 : HIDDEN_ROW), IF_PORT2_XJT(g_model.moduleData[1].failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0), 0}); #elif defined(CPUM64) #define CURSOR_ON_CELL (true) uint8_t protocol = g_model.protocol; @@ -913,7 +913,15 @@ void menuModelSetup(uint8_t event) for (uint8_t i=0; i0) ? BLINK|INVERS : INVERS); uint8_t attr = (sub == k ? blink : 0); @@ -1008,13 +1016,13 @@ void menuModelSetup(uint8_t event) g_model.extendedTrims = onoffMenuItem(g_model.extendedTrims, MODEL_SETUP_2ND_COLUMN, y, STR_ETRIMS, m_posHorz<=0 ? attr : 0, event==EVT_KEY_BREAK(KEY_ENTER) ? event : 0); lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_RESET, m_posHorz>0 ? attr : 0); if (attr && m_posHorz>0) { - s_editMode = 0; - if (event==EVT_KEY_LONG(KEY_ENTER)) { + s_editMode = 0; + if (event==EVT_KEY_LONG(KEY_ENTER)) { for (uint8_t i=0; i 0) { + coordsOfs = 0; + if (crv.custom) { + moveCurve(s_curveChan, -crv.points+2); + } + else if (crv.points > MIN_POINTS) { + moveCurve(s_curveChan, -1, (crv.points+1)/2); + } + else { + AUDIO_WARNING2(); + } + return; + } + break; + + case EVT_KEY_REPT(KEY_RIGHT): + case EVT_KEY_FIRST(KEY_RIGHT): + if (m_posVert == 0 && s_editMode > 0) { + coordsOfs = 0; + if (!crv.custom) { + moveCurve(s_curveChan, crv.points-2, crv.points); + } + else if (crv.points < MAX_POINTS) { + if (moveCurve(s_curveChan, 1)) { + for (int8_t i=crv.points+crv.points-2; i>=0; i--) { + if (i%2) + crv.crv[i] = (crv.crv[i/2] + crv.crv[1+i/2]) / 2; + else + crv.crv[i] = crv.crv[i/2]; + } + } + } + else { + AUDIO_WARNING2(); + } + } + break; + } + + lcd_putsLeft(FH+1, STR_CURVE_TYPE); + uint8_t attr = (m_posVert==0 ? (s_editMode <= 0 ? INVERS : INVERS|BLINK) : 0); + lcd_outdezAtt(5*FW, FH+1, crv.points, LEFT|attr); + lcd_putsAtt(lcdLastPos, FH+1, crv.custom ? PSTR("pt'") : PSTR("pt"), attr); + + lcd_putsLeft(2*FH+1, STR_NAME); + editName(5*FW, 2*FH+1, g_model.curveNames[s_curveChan], sizeof(g_model.curveNames[s_curveChan]), event, m_posVert==1 ? INVERS : 0); + + lcd_putsAtt(0*FW, 3*FH+3, PSTR("[Edit]"), m_posVert==2 ? INVERS : 0); + lcd_putsAtt(0*FW, 4*FH+3, PSTR("[Preset]"), m_posVert==3 ? INVERS : 0); + if (m_posVert==3 && event==EVT_KEY_BREAK(KEY_ENTER)) { + static int8_t presetIdx = 0; + if (++presetIdx > 4) + presetIdx = -4; + for (uint8_t i=0; i0 && i=coordsOfs && i<=coordsOfs+5) { + int8_t x = -100 + 200*i/(crv.points-1); + if (crv.custom && i>0 && i 0) { + if (event==EVT_KEY_BREAK(KEY_ENTER)) { + if (s_editMode == EDIT_MODIFY_FIELD) + s_editMode = (crv.custom && m_posHorz>0 && m_posHorz= coordsOfs+6) + coordsOfs = m_posHorz-5; + } + } +} +#else void menuModelCurveOne(uint8_t event) { TITLE(STR_MENUCURVE); @@ -2053,28 +2193,14 @@ void menuModelCurveOne(uint8_t event) switch(event) { case EVT_ENTRY: -#if defined(PCBTARANIS) - m_posHorz = 0; -#endif s_editMode = 1; break; CASE_EVT_ROTARY_BREAK case EVT_KEY_BREAK(KEY_ENTER): -#if defined(PCBTARANIS) - if (s_editMode <= 0) { - s_editMode = 1; - m_posHorz = 0; - } - else if (s_editMode == 1) - s_editMode = (crv.custom && m_posHorz>0 && m_posHorz 0) { -#if defined(PCBTARANIS) - if (s_editMode == 3 && !(crv.custom && m_posHorz>0 && m_posHorz0 && iPIO_PDSR #define GPIO_BUTTON_EXIT PIOA->PIO_PDSR @@ -235,7 +237,7 @@ uint32_t pwrCheck(); // EEPROM driver void eepromInit(); -#define EEPROM_MASSSTORAGE() (0) +#define EEPROM_MASSSTORAGE() (0) // Rotary Encoder driver void rotencInit(); diff --git a/src/stock/board_stock.cpp b/src/stock/board_stock.cpp index 5356a0734..bec14017d 100644 --- a/src/stock/board_stock.cpp +++ b/src/stock/board_stock.cpp @@ -108,11 +108,17 @@ inline void boardInit() ADMUX = ADC_VREF_TYPE; ADCSRA = 0x85; // ADC enabled, pre-scaler division=32 (no interrupt, no auto-triggering) +#if defined(CPUM2561) + TCCR2B = (0b111 << CS20); // Norm mode, clk/1024 (differs from ATmega64 chip) + OCR2A = 156; + TIMSK2 |= (1<func)==CS_VOFS) - val = convertTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2); - else - val = convertTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2) - convertTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128); - return val; -} - -const pm_uint8_t bchunit_ar[] PROGMEM = { - UNIT_METERS, // Alt - UNIT_RAW, // Rpm - UNIT_PERCENT, // Fuel - UNIT_DEGREES, // T1 - UNIT_DEGREES, // T2 - UNIT_KTS, // Speed - UNIT_METERS, // Dist - UNIT_METERS, // GPS Alt -}; - -void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val, uint8_t att) -{ - switch (channel) { - case TELEM_TM1-1: - case TELEM_TM2-1: - att &= ~NO_UNIT; - putsTime(x, y, val, att, att); - break; - case TELEM_MIN_A1-1: - case TELEM_MIN_A2-1: - channel -= TELEM_MIN_A1-TELEM_A1; - // no break - case TELEM_A1-1: - case TELEM_A2-1: - channel -= TELEM_A1-1; - // A1 and A2 - { - lcdint_t converted_value = applyChannelRatio(channel, val); - if (g_model.frsky.channels[channel].type >= UNIT_RAW) { - converted_value /= 10; - } - else { -#if !defined(PCBTARANIS) - if (abs(converted_value) < 1000) { - att |= PREC2; - } - else { - converted_value /= 10; - att |= PREC1; - } -#else - att |= PREC2; -#endif - } - putsTelemetryValue(x, y, converted_value, g_model.frsky.channels[channel].type, att); - break; - } - - case TELEM_CELL-1: - putsTelemetryValue(x, y, val, UNIT_VOLTS, att|PREC2); - break; - - case TELEM_TX_VOLTAGE-1: - case TELEM_VFAS-1: - case TELEM_CELLS_SUM-1: - putsTelemetryValue(x, y, val, UNIT_VOLTS, att|PREC1); - break; - - case TELEM_CURRENT-1: - case TELEM_MAX_CURRENT-1: - putsTelemetryValue(x, y, val, UNIT_AMPS, att|PREC1); - break; - - case TELEM_CONSUMPTION-1: - putsTelemetryValue(x, y, val, UNIT_MAH, att); - break; - - case TELEM_POWER-1: - putsTelemetryValue(x, y, val, UNIT_WATTS, att); - break; - - case TELEM_ACCx-1: - case TELEM_ACCy-1: - case TELEM_ACCz-1: - case TELEM_VSPD-1: - putsTelemetryValue(x, y, val, UNIT_RAW, att|PREC2); - break; - - case TELEM_RSSI_TX-1: - case TELEM_RSSI_RX-1: - putsTelemetryValue(x, y, val, UNIT_RAW, att); - break; - -#if defined(FRSKY_SPORT) - case TELEM_ALT-1: - putsTelemetryValue(x, y, val/10, UNIT_METERS, att|PREC1); - break; -#elif defined(WS_HOW_HIGH) - case TELEM_ALT-1: - case TELEM_MIN_ALT-1: - case TELEM_MAX_ALT-1: - if (IS_IMPERIAL_ENABLE() && IS_USR_PROTO_WS_HOW_HIGH()) { - putsTelemetryValue(x, y, val, UNIT_FEET, att); - break; - } - // no break -#endif - - default: - { - uint8_t unit = 1; - if (channel >= TELEM_MAX_T1-1 && channel <= TELEM_MAX_DIST-1) - channel -= TELEM_MAX_T1 - TELEM_T1; - if (channel <= TELEM_GPSALT-1) - unit = channel + 1 - TELEM_ALT; - if (channel >= TELEM_MIN_ALT-1 && channel <= TELEM_MAX_ALT-1) - unit = 0; - if (channel == TELEM_HDG-1) - unit = 3; - putsTelemetryValue(x, y, val, pgm_read_byte(bchunit_ar+unit), att); - break; - } - } -} - enum FrskyViews { e_frsky_custom_screen_1, e_frsky_custom_screen_2,