diff --git a/src/Makefile b/src/Makefile index 52d4f42c6..1cf7fe058 100644 --- a/src/Makefile +++ b/src/Makefile @@ -752,9 +752,9 @@ FOXLIB=-L/usr/local/lib \ -Wl,-rpath,$(FOXPATH)/src/.libs LBITS := $(shell getconf LONG_BIT) -OS := @$(shell dpkg-architecture -qDEB_BUILD_ARCH_OS) +OS := $(shell uname -o) ifeq ($(LBITS),64) - ifneq ($(OS),linux) + ifneq ($(OS),GNU/Linux) ARCH=-arch x86_64 endif else diff --git a/src/audio.h b/src/audio.h index 8797ea9e6..82f3bcf9a 100644 --- a/src/audio.h +++ b/src/audio.h @@ -72,7 +72,8 @@ enum AUDIO_SOUNDS { AU_FRSKY_TICK, AU_FRSKY_HAPTIC1, AU_FRSKY_HAPTIC2, - AU_FRSKY_HAPTIC3 + AU_FRSKY_HAPTIC3, + AU_FRSKY_LAST, }; class audioQueue diff --git a/src/frsky.cpp b/src/frsky.cpp index 6f92138b2..1a80110c1 100644 --- a/src/frsky.cpp +++ b/src/frsky.cpp @@ -94,8 +94,12 @@ uint8_t frskyGetUserData(char *buffer, uint8_t bufSize) #ifdef FRSKY_HUB int8_t parseTelemHubIndex(uint8_t index) { - if (index > 0x26) + if (index > 0x3b) index = 0; // invalid index + if (index > 0x39) + index -= 17; + if (index > 0x27) + index -= 1; if (index > 0x21) index -= 5; if (index > 0x0f) diff --git a/src/frsky.h b/src/frsky.h index a199dcec7..632081e67 100644 --- a/src/frsky.h +++ b/src/frsky.h @@ -48,13 +48,16 @@ struct FrskyData { #if defined(FRSKY_HUB) struct FrskyHubData { + // 1 spare int16_t gpsAltitude_bp; // before punct int16_t temperature1; // -20 .. 250 deg. celcius uint16_t rpm; // 0..60,000 revs. per minute uint16_t fuelLevel; // 0, 25, 50, 75, 100 percent int16_t temperature2; // -20 .. 250 deg. celcius uint16_t volts; // 1/500V increments (0..4.2V) + // 2 spares int16_t gpsAltitude_ap; // after punct + // 6 spares uint16_t baroAltitude; // 0..9,999 meters uint16_t gpsSpeed_bp; // before punct uint16_t gpsLongitude_bp; // before punct @@ -70,11 +73,17 @@ struct FrskyHubData { uint16_t gpsLongitude_ap; uint16_t gpsLatitude_ap; uint16_t gpsCourse_ap; + // 5 spares uint16_t gpsLongitudeEW; // East/West uint16_t gpsLatitudeNS; // North/South int16_t accelX; // 1/256th gram (-8g ~ +8g) int16_t accelY; // 1/256th gram (-8g ~ +8g) int16_t accelZ; // 1/256th gram (-8g ~ +8g) + // 1 spare + uint16_t current; + // 17 spares + uint16_t volts_bp; + uint16_t volts_ap; }; #elif defined(WS_HOW_HIGH) diff --git a/src/lcd.cpp b/src/lcd.cpp index b215fc039..76a90ce45 100644 --- a/src/lcd.cpp +++ b/src/lcd.cpp @@ -142,13 +142,16 @@ void lcd_putsnAtt(uint8_t x,uint8_t y,const pm_char * s,uint8_t len,uint8_t mode c = pgm_read_byte(s); break; } + if (!c) break; lcd_putcAtt(x,y,c,mode); x+=FW; if (mode&DBLSIZE) x+=FW-1; s++; len--; } + lcd_lastPos = x; } + void lcd_putsn_P(uint8_t x,uint8_t y,const pm_char * s,uint8_t len) { lcd_putsnAtt(x, y, s, len, 0); @@ -156,14 +159,7 @@ void lcd_putsn_P(uint8_t x,uint8_t y,const pm_char * s,uint8_t len) void lcd_putsAtt(uint8_t x,uint8_t y,const pm_char * s,uint8_t mode) { - while(1) { - char c = (mode & BSS) ? *s++ : pgm_read_byte(s++); - if(!c) break; - lcd_putcAtt(x,y,c,mode); - x+=FW; - if(mode&DBLSIZE) x+=FW; - } - lcd_lastPos = x; + lcd_putsnAtt(x, y, s, 255, mode); } void lcd_puts_P(uint8_t x,uint8_t y,const pm_char * s) diff --git a/src/model_menus.cpp b/src/model_menus.cpp index 1713c5524..0a35db672 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -39,7 +39,6 @@ enum EnumTabModel { e_CurvesAll, e_CustomSwitches, e_FunctionSwitches, - e_SafetySwitches, #ifdef FRSKY e_Telemetry, #endif @@ -60,7 +59,6 @@ void menuProcLimits(uint8_t event); void menuProcCurvesAll(uint8_t event); void menuProcCustomSwitches(uint8_t event); void menuProcFunctionSwitches(uint8_t event); -void menuProcSafetySwitches(uint8_t event); #ifdef FRSKY void menuProcTelemetry(uint8_t event); #endif @@ -82,7 +80,6 @@ const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = { menuProcCurvesAll, menuProcCustomSwitches, menuProcFunctionSwitches, - menuProcSafetySwitches, #ifdef FRSKY menuProcTelemetry, #endif @@ -1743,7 +1740,19 @@ void menuProcFunctionSwitches(uint8_t event) break; case 1: if (sd->swtch) { - lcd_putsnAtt(5*FW, y, STR_VFSWFUNC+LEN_VFSWFUNC*sd->func, LEN_VFSWFUNC, attr); + uint8_t func_displayed; + if (sd->func < NUM_CHNOUT) { + func_displayed = 0; + putsChnRaw(14*FW-2, y, NUM_STICKS+NUM_POTS+2+3+NUM_PPM+sd->func+1, attr); + } + else if (sd->func < NUM_CHNOUT + NUM_STICKS + 1) { + func_displayed = 1; + if (sd->func != FUNC_TRAINER) + putsChnRaw(13*FW-2, y, sd->func-FUNC_TRAINER, attr); + } + else + func_displayed = 2 + sd->func - NUM_CHNOUT - NUM_STICKS - 1; + lcd_putsnAtt(5*FW-2, y, STR_VFSWFUNC+LEN_VFSWFUNC*func_displayed, LEN_VFSWFUNC, attr); if (active) { CHECK_INCDEC_MODELVAR( event, sd->func, 0, FUNC_MAX-1); } @@ -1753,10 +1762,31 @@ void menuProcFunctionSwitches(uint8_t event) } break; case 2: - if (sd->swtch && sd->func == FUNC_PLAY_SOUND) { - lcd_outdezAtt(19*FW, y, sd->param, attr); + if (sd->swtch) { + int16_t val_displayed; + int8_t val_min; + int8_t val_max; + if (sd->func == FUNC_PLAY_SOUND) { + val_displayed = sd->param; + +#ifdef AUDIO + val_min = 0; + val_max = AU_FRSKY_LAST-AU_FRSKY_FIRST-1; +#else + break; +#endif + } + else if (sd->func <= FUNC_SAFETY_CH16) { + val_displayed = (int8_t)sd->param; + val_min = -125; + val_max = 125; + } + else { + break; + } + lcd_outdezAtt(21*FW, y, val_displayed, attr); if (active) { - CHECK_INCDEC_MODELVAR( event, sd->param, 0, 15); + CHECK_INCDEC_MODELVAR(event, sd->param, val_min, val_max); } } else if (attr) { @@ -1768,6 +1798,7 @@ void menuProcFunctionSwitches(uint8_t event) } } +#if 0 void menuProcSafetySwitches(uint8_t event) { MENU(STR_MENUSAFETYSWITCHES, menuTabModel, e_SafetySwitches, NUM_CHNOUT+1, {0, 1/*repeated*/}); @@ -1802,6 +1833,7 @@ void menuProcSafetySwitches(uint8_t event) } } } +#endif #ifdef FRSKY void menuProcTelemetry(uint8_t event) diff --git a/src/myeeprom.h b/src/myeeprom.h index 0659777e3..16299c1fc 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -154,13 +154,9 @@ PACK(typedef struct t_CustomSwData { // Custom Switches data uint8_t func; }) CustomSwData; -PACK(typedef struct t_SafetySwData { // Safety Switches data - int8_t swtch; - int8_t val; -}) SafetySwData; - enum Functions { - FUNC_NONE, + FUNC_SAFETY_CH1, + FUNC_SAFETY_CH16=FUNC_SAFETY_CH1+15, FUNC_TRAINER, FUNC_TRAINER_RUD, FUNC_TRAINER_ELE, @@ -177,8 +173,8 @@ enum Functions { PACK(typedef struct t_FuncSwData { // Function Switches data int8_t swtch; //input - uint8_t func:4; - uint8_t param:4; + uint8_t func; + uint8_t param; }) FuncSwData; PACK(typedef struct t_FrSkyChannelData { @@ -239,7 +235,7 @@ PACK(typedef struct t_PhaseData { #define NUM_CHNOUT 16 // number of real output channels CH1-CH16 #define NUM_CSW 12 // number of custom switches -#define NUM_FSW 12 // number of functions assigned to switches +#define NUM_FSW 16 // number of functions assigned to switches #define TMRMODE_NONE 0 #define TMRMODE_ABS 1 @@ -277,9 +273,8 @@ PACK(typedef struct t_ModelData { ExpoData expoData[MAX_EXPOS]; int8_t curves5[MAX_CURVE5][5]; int8_t curves9[MAX_CURVE9][9]; - CustomSwData customSw[NUM_CSW]; - SafetySwData safetySw[NUM_CHNOUT]; - FuncSwData funcSw[NUM_FSW]; + CustomSwData customSw[NUM_CSW]; + FuncSwData funcSw[NUM_FSW]; SwashRingData swashR; PhaseData phaseData[MAX_PHASES]; FrSkyData frsky; diff --git a/src/open9x.cpp b/src/open9x.cpp index 1f53b70d5..d14ffcdf6 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -52,6 +52,8 @@ audioQueue audio; uint8_t heartbeat; +int8_t safetyCh[NUM_CHNOUT]; + const pm_char s_charTab[] PROGMEM = "_-.,"; //R=1 @@ -1045,19 +1047,25 @@ uint16_t active_functions = 0; // current max = 16 functions void evalFunctions() { - assert(sizeof(active_functions)*8 > FUNC_MAX); + assert(sizeof(active_functions)*8 > FUNC_MAX-NUM_CHNOUT); + + for (uint8_t i=0; iswtch && sd->func) { - uint16_t mask = (1 << (sd->func-1)); + if (sd->swtch) { + uint16_t mask = (sd->func >= FUNC_TRAINER ? (1 << (sd->func-FUNC_TRAINER)) : 0); if (getSwitch(sd->swtch, 0)) { - if (sd->func == FUNC_PLAY_SOUND && (~active_functions & mask)) { + if (sd->func < FUNC_TRAINER) { + safetyCh[sd->func] = (int8_t)sd->param; + } + if (sd->func == FUNC_PLAY_SOUND/* && (~active_functions & mask)*/) { #if defined(AUDIO) - audioDefevent(sd->param); + audioDefevent(AU_FRSKY_FIRST+sd->param); #else if (g_eeGeneral.beeperVal>0) { - _beep(min(1, sd->param*10)); + _beep(10); } #endif } @@ -1336,8 +1344,8 @@ void perOut(int16_t *chanOut, uint8_t phase) if(q