diff --git a/DONATIONS.txt b/DONATIONS.txt index 43ecab91d..16b2dbd39 100644 --- a/DONATIONS.txt +++ b/DONATIONS.txt @@ -508,3 +508,6 @@ Thos. O'Meara Photography Spis Ltd/TurboNote Patricia Cox Matthew Lukes +Sabine Witte +Phillip Perry +Beat Zurflueh diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp index d6a62b380..cc93774d6 100644 --- a/companion/src/modeledit/inputs.cpp +++ b/companion/src/modeledit/inputs.cpp @@ -457,22 +457,27 @@ int InputsPanel::gm_moveExpo(int idx, bool dir) //true=inc=down false=dec=up if (!dir && tdx<0 && src.chn>0) { src.chn--; return idx; - } else if (!dir && tdx<0) { + } + else if (!dir && tdx<0) { return idx; } - if(memcmp(&src,&temp,sizeof(ExpoData))==0) return idx; - bool tgtempty=(memcmp(&tgt,&temp,sizeof(ExpoData))==0 ? 1:0); - if(tgt.chn!=src.chn || tgtempty) { - if ((dir) && (src.chn<(inputsCount-1))) src.chn++; - if ((!dir) && (src.chn>0)) src.chn--; - return idx; + if (memcmp(&src, &temp, sizeof(ExpoData)) == 0) { + return idx; } - //flip between idx and tgt - memcpy(&temp,&src,sizeof(ExpoData)); - memcpy(&src,&tgt,sizeof(ExpoData)); - memcpy(&tgt,&temp,sizeof(ExpoData)); + bool tgtempty = (memcmp(&tgt, &temp, sizeof(ExpoData)) == 0); + + if (tgt.chn!=src.chn || tgtempty) { + if ((dir) && (src.chn0)) src.chn--; + return idx; + } + + // flip between idx and tgt + memcpy(&temp, &src, sizeof(ExpoData)); + memcpy(&src, &tgt, sizeof(ExpoData)); + memcpy(&tgt, &temp, sizeof(ExpoData)); return tdx; } diff --git a/radio/src/.gitignore b/radio/src/.gitignore index 129ed5ba2..0cc98b78d 100644 --- a/radio/src/.gitignore +++ b/radio/src/.gitignore @@ -10,6 +10,7 @@ /*.bin.* /*.hex /*.lst +/*.lss /SCRIPTS /TEMPLATES /SOUNDS diff --git a/radio/src/gui/view_telemetry.cpp b/radio/src/gui/view_telemetry.cpp index 983e3d76f..ae273dae8 100644 --- a/radio/src/gui/view_telemetry.cpp +++ b/radio/src/gui/view_telemetry.cpp @@ -47,22 +47,6 @@ bar_threshold_t barsThresholds[THLD_MAX]; #endif -enum FrskyViews { - CASE_LUA(TELEMETRY_LUA_SCREEN_1) - CASE_LUA(TELEMETRY_LUA_SCREEN_2) - CASE_LUA(TELEMETRY_LUA_SCREEN_3) - CASE_LUA(TELEMETRY_LUA_SCREEN_4) - CASE_LUA(TELEMETRY_LUA_SCREEN_5) - CASE_LUA(TELEMETRY_LUA_SCREEN_6) - CASE_LUA(TELEMETRY_LUA_SCREEN_7) - TELEMETRY_CUSTOM_SCREEN_1, - TELEMETRY_CUSTOM_SCREEN_2, - CASE_CPUARM(TELEMETRY_CUSTOM_SCREEN_3) - TELEMETRY_VOLTAGES_SCREEN, - TELEMETRY_AFTER_FLIGHT_SCREEN, - FRSKY_VIEW_MAX = TELEMETRY_AFTER_FLIGHT_SCREEN -}; - uint8_t s_frsky_view = 0; #if LCD_W >= 212 diff --git a/radio/src/lua.cpp b/radio/src/lua.cpp index e58ce95c0..ff6a297bc 100644 --- a/radio/src/lua.cpp +++ b/radio/src/lua.cpp @@ -1137,6 +1137,7 @@ void luaInit() // Push OpenTX constants lua_registerint(L, "FULLSCALE", RESX); + lua_registerint(L, "XXLSIZE", XXLSIZE); lua_registerint(L, "DBLSIZE", DBLSIZE); lua_registerint(L, "MIDSIZE", MIDSIZE); lua_registerint(L, "SMLSIZE", SMLSIZE); @@ -1293,8 +1294,16 @@ void getTelemetryScriptPath(char * path, uint8_t index) { strcpy(path, SCRIPTS_PATH "/"); char * curs = strcat_modelname(path+sizeof(SCRIPTS_PATH), g_eeGeneral.currModel); - strcpy(curs, "/telemX.lua"); - curs[6] = '0' + index; + if (index == TELEMETRY_VOLTAGES_SCREEN) { + strcpy(curs, "/telempw.lua"); + } + else if (index == TELEMETRY_AFTER_FLIGHT_SCREEN) { + strcpy(curs, "/telemaf.lua"); + } + else { + strcpy(curs, "/telemX.lua"); + curs[6] = '1' + index; + } } bool luaLoadTelemetryScript(uint8_t index) @@ -1319,7 +1328,7 @@ bool isTelemetryScriptAvailable(uint8_t index) { for (int i=0; ioutputsCount : 0, 0) == 0) { if (sio) { diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 2cd242cf6..588cf2773 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1640,7 +1640,7 @@ FORCEINLINE void evalTrims() if (i==THR_STICK && g_model.thrTrim) { if (g_model.throttleReversed) trim = -trim; - int16_t v = anas[i]; + int16_t v = getValue(MIXSRC_Thr); int32_t vv = ((int32_t)trim-TRIM_MIN)*(RESX-v)>>(RESX_SHIFT+1); trim = vv; } diff --git a/radio/src/opentx.h b/radio/src/opentx.h index bb017befa..3f34305be 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -1654,6 +1654,25 @@ extern const pm_uint8_t bchunit_ar[]; #endif #define IS_BARS_SCREEN(screenIndex) (g_model.frsky.screensType & (1<<(screenIndex))) + +enum FrskyViews { + CASE_LUA(TELEMETRY_LUA_SCREEN_1) + CASE_LUA(TELEMETRY_LUA_SCREEN_2) + CASE_LUA(TELEMETRY_LUA_SCREEN_3) + CASE_LUA(TELEMETRY_LUA_SCREEN_4) + CASE_LUA(TELEMETRY_LUA_SCREEN_5) + CASE_LUA(TELEMETRY_LUA_SCREEN_6) + CASE_LUA(TELEMETRY_LUA_SCREEN_7) + TELEMETRY_CUSTOM_SCREEN_1, + TELEMETRY_CUSTOM_SCREEN_2, + CASE_CPUARM(TELEMETRY_CUSTOM_SCREEN_3) + TELEMETRY_VOLTAGES_SCREEN, + TELEMETRY_AFTER_FLIGHT_SCREEN, + FRSKY_VIEW_MAX = TELEMETRY_AFTER_FLIGHT_SCREEN +}; + +extern uint8_t s_frsky_view; + #endif #define EARTH_RADIUSKM ((uint32_t)6371) diff --git a/radio/src/pulses/dsm2_arm.cpp b/radio/src/pulses/dsm2_arm.cpp index bcea759ef..a2b2c27b8 100644 --- a/radio/src/pulses/dsm2_arm.cpp +++ b/radio/src/pulses/dsm2_arm.cpp @@ -147,7 +147,7 @@ void setupPulsesDSM2(unsigned int port) *dsm2StreamPtr++ = dsm2Value; #endif - switch(s_current_protocol[port]) { + switch (s_current_protocol[port]) { case PROTO_DSM2_LP45: dsmDat[0] = 0x00; break; @@ -155,7 +155,7 @@ void setupPulsesDSM2(unsigned int port) dsmDat[0] = 0x10; break; default: // DSMX - dsmDat[0] = 0x18; + dsmDat[0] = 0x10 | DSMX_BIT; break; } diff --git a/radio/src/targets/taranis/lcd_driver.cpp b/radio/src/targets/taranis/lcd_driver.cpp index e132a4a1b..6465649da 100644 --- a/radio/src/targets/taranis/lcd_driver.cpp +++ b/radio/src/targets/taranis/lcd_driver.cpp @@ -15,49 +15,61 @@ #define WriteCommand(x) AspiCmd(x) #if defined(REVPLUS) - #define CONTRAST_OFS 120 + #define CONTRAST_OFS 160 #else #define CONTRAST_OFS 5 #endif +//275us +void Delay(volatile unsigned int ms) +{ + volatile u8 i; + while(ms != 0) { + for(i=0;i<250;i++) {} + for(i=0;i<75;i++) {} + ms--; + } +} + #if defined(REVPLUS) static void LCD_Init() { - AspiCmd(0x25); //(5) Temperature compensation curve definition: 0x25 = -0.05%/oC - AspiCmd(0x2b); //(6) Panel loading set ,Internal VLCD. - AspiCmd(0xEA); //(27) set bias=1/10 - AspiCmd(0x81); //(11) Set Vop + next byte + WriteCommand(0x2F); //Internal pump control + Delay(20); + WriteCommand(0x24); //Temperature compensation + WriteCommand(0xE9); //set bias=1/10 + WriteCommand(0x81); //Set Vop #if defined(BOOT) AspiCmd(CONTRAST_OFS+25); #else AspiCmd(CONTRAST_OFS+g_eeGeneral.contrast); #endif - AspiCmd(0xA6); //inverse display off - AspiCmd(0xA1); //line rates,24 Klps - AspiCmd(0x84); //Disable Partial Display - AspiCmd(0xC8); //SET N-LINE INVERSION - AspiCmd(0x00); //Disable NIV - AspiCmd(0xF1); //Set CEN - AspiCmd(0x3F); // 1/64DUTY - AspiCmd(0xC0); //(21) Set mapping - AspiCmd(0x05); // MY=1, MX=0, MSF=0 - AspiCmd(0x89); //(15) WA=1,column (CA) increment (+1) first until CA reaches CA boundary, then RA will increment by (+1). - AspiCmd(0xF8); //Set Window Program Enable ,inside modle - AspiCmd(0xD0); //(23) SET 4 bits/pixel, pattern 0 - AspiCmd(0xF4); //starting column address of RAM program window. - AspiCmd(0x00); - AspiCmd(0xF5); //starting row address of RAM program window. - AspiCmd(0x00); - AspiCmd(0xF6); //ending column address of RAM program window. - AspiCmd(0xD3); - AspiCmd(0xF7); //ending row address of RAM program window. - AspiCmd(0x3F); - AspiCmd(0xAF); // Active and 16-grey scale + WriteCommand(0xA2); //set line rate:28KLPS + WriteCommand(0x28); //set pannel loading + WriteCommand(0x40); //scroll line LSB + WriteCommand(0x50); //SCROLL LINE MSB + WriteCommand(0x89); //ram address control + WriteCommand(0xC0); //LCD mapping control + WriteCommand(0x04); //MX=0,MY=1 + WriteCommand(0xD0); //DISPLAY PATTERN = 16-SCALE GRAY + WriteCommand(0xF1); //SET COM end + WriteCommand(0x3F); //64 + + WriteCommand(0xF8); //Set Window Program Disable. + + WriteCommand(0xF5); //starting row address of RAM program window.PAGE1 + WriteCommand(0x00); + WriteCommand(0xF7); //end row address of RAM program window.PAGE32 + WriteCommand(0x1F); + WriteCommand(0xF4); //start column address of RAM program window. + WriteCommand(0x00); + WriteCommand(0xF6); //end column address of RAM program window.SEG212 + WriteCommand(0xD3); } #else static void LCD_Init() { - AspiCmd(0x2b); //Panel loading set ,Internal VLCD. + AspiCmd(0x2B); //Panel loading set ,Internal VLCD. AspiCmd(0x25); //Temperature compensation curve definition: 0x25 = -0.05%/oC AspiCmd(0xEA); //set bias=1/10 :Command table NO.27 AspiCmd(0x81); //Set Vop @@ -117,6 +129,7 @@ void lcdRefresh() for (uint32_t y=0; y>3)*LCD_W]; uint8_t mask = (1 << (y%8)); + uint8_t mask2 = (1 << (1+(y%8))); Set_Address(0, y/2); AspiCmd(0xAF); @@ -126,49 +139,18 @@ void lcdRefresh() LCD_NCS_LOW(); for (uint32_t x=0; x>1) & mask ) { - val |= 0x10 ; - } - - b = p[2*DISPLAY_PLAN_SIZE+x] ; - if ( b & mask ) { - val |= 2 ; - } - if ( (b>>1) & mask ) { - val |= 0x20 ; - } - - c = p[DISPLAY_PLAN_SIZE+x] ; - if ( c & mask ) { - val |= 4 ; - } - if ( (c>>1) & mask ) { - val |= 0x40 ; - } - - c = p[x] ; - if ( c & mask ) { - val |= 8 ; - } - if ( (c>>1) & mask ) { - val |= 0x80 ; - } - - LCD_WRITE_BIT(val & 1); - LCD_WRITE_BIT(val & 2); - LCD_WRITE_BIT(val & 4); - LCD_WRITE_BIT(val & 8); - LCD_WRITE_BIT(val & 0x10); - LCD_WRITE_BIT(val & 0x20); - LCD_WRITE_BIT(val & 0x40); - LCD_WRITE_BIT(val & 0x80); + uint8_t a = p[3*DISPLAY_PLAN_SIZE+x] ; + uint8_t b = p[2*DISPLAY_PLAN_SIZE+x] ; + uint8_t c = p[DISPLAY_PLAN_SIZE+x] ; + uint8_t d = p[x] ; + LCD_WRITE_BIT(a & mask2); + LCD_WRITE_BIT(b & mask2); + LCD_WRITE_BIT(c & mask2); + LCD_WRITE_BIT(d & mask2); + LCD_WRITE_BIT(a & mask); + LCD_WRITE_BIT(b & mask); + LCD_WRITE_BIT(c & mask); + LCD_WRITE_BIT(d & mask); } LCD_NCS_HIGH(); @@ -284,18 +266,6 @@ static void LCD_Hardware_Init() GPIO_Init(GPIO_LCD_RST, &GPIO_InitStructure); } -//275us -void Delay(volatile unsigned int ms) -{ - volatile u8 i; - while(ms != 0) - { - for(i=0;i<250;i++) {} - for(i=0;i<75;i++) {} - ms--; - } -} - void LCD_OFF() { AspiCmd(0xE2); diff --git a/radio/src/tests/gtests.cpp b/radio/src/tests/gtests.cpp index da6230ad8..02c800a9a 100644 --- a/radio/src/tests/gtests.cpp +++ b/radio/src/tests/gtests.cpp @@ -334,6 +334,36 @@ TEST(FrSkySPORT, checkCrc) } #endif + +#if defined(FRSKY) && defined(CPUARM) +TEST(FrSky, FrskyValueWithMinAveraging) +{ + /* + The following expected[] array is filled + with values that correspond to 4 elements + long averaging buffer. + If length of averaging buffer is changed, this + values must be adjusted + */ + uint8_t expected[] = { 10, 12, 17, 25, 35, 45, 55, 65, 75, 85, 92, 97, 100, 100, 100, 100, 100}; + int testPos = 0; + //test of averaging + FrskyValueWithMin testVal; + testVal.value = 0; + testVal.set(10); + EXPECT_EQ(testVal.value, expected[testPos++]); + for(int n=2; n<10; ++n) { + testVal.set(n*10); + EXPECT_EQ(testVal.value, expected[testPos++]); + } + for(int n=2; n<10; ++n) { + testVal.set(100); + EXPECT_EQ(testVal.value, expected[testPos++]); + } +} +#endif + + #if !defined(PCBTARANIS) TEST(getSwitch, undefCSW) { diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 3567292c1..6a25a8fc2 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -474,6 +474,7 @@ const pm_char STR_FLASH_BOOTLOADER[] PROGMEM = TR_FLASH_BOOTLOADER; const pm_char STR_WRITING[] PROGMEM = TR_WRITING; const pm_char STR_CONFIRM_FORMAT[] PROGMEM = TR_CONFIRM_FORMAT; const pm_char STR_EEBACKUP[] PROGMEM = TR_EEBACKUP; +const pm_char STR_TOO_MANY_LUA_SCRIPTS[] PROGMEM = TR_TO_MANY_LUA_SCRIPTS; const pm_char STR_BLCOLOR[] PROGMEM = TR_BLCOLOR; #if LCD_W >= 212 diff --git a/radio/src/translations.h b/radio/src/translations.h index e7aba07c4..ccf5dc138 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -626,6 +626,7 @@ extern const pm_char STR_FLASH_BOOTLOADER[]; extern const pm_char STR_WRITING[]; extern const pm_char STR_CONFIRM_FORMAT[]; extern const pm_char STR_EEBACKUP[]; +extern const pm_char STR_TOO_MANY_LUA_SCRIPTS[]; extern const pm_char STR_BLCOLOR[]; #if defined(VOICE) && defined(CPUARM) diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index 1f3bd4498..98070d55e 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -814,6 +814,7 @@ #define TR_INPUTS "Vstupy" #define TR_OUTPUTS "Výstupy" #define TR_EEBACKUP "\010[dlouze ENTER] zálohuje EEPROM" +#define TR_TO_MANY_LUA_SCRIPTS "Too many Lua scripts!" #if defined(MAVLINK) #define TR_MAVLINK_RC_RSSI_SCALE_LABEL "Max RSSI" diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index 0c7536e3c..96e5a1dcf 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -814,6 +814,7 @@ #define TR_INPUTS "Inputs" #define TR_OUTPUTS "Outputs" #define TR_EEBACKUP "\004[ENTER Long] to backup the EEPROM" +#define TR_TO_MANY_LUA_SCRIPTS "Too many Lua scripts!" #if defined(MAVLINK) #define TR_MAVLINK_RC_RSSI_SCALE_LABEL "Max RSSI" diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 0b440638e..addcf859a 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -814,6 +814,7 @@ #define TR_INPUTS "Inputs" #define TR_OUTPUTS "Outputs" #define TR_EEBACKUP "\004[ENTER Long] to backup the EEPROM" +#define TR_TO_MANY_LUA_SCRIPTS "Too many Lua scripts!" #if defined(MAVLINK) #define TR_MAVLINK_RC_RSSI_SCALE_LABEL "Max RSSI" diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index 950d02ad6..419657f4d 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -814,6 +814,7 @@ #define TR_INPUTS "Inputs" #define TR_OUTPUTS "Outputs" #define TR_EEBACKUP "\004[ENTER Long] to backup the EEPROM" +#define TR_TO_MANY_LUA_SCRIPTS "Too many Lua scripts!" #if defined(MAVLINK) #define TR_MAVLINK_RC_RSSI_SCALE_LABEL "Max RSSI" diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index a76285a7c..272a1f7c5 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -814,6 +814,7 @@ #define TR_INPUTS "Inputs" #define TR_OUTPUTS "Outputs" #define TR_EEBACKUP "\004[ENTER Long] to backup the EEPROM" +#define TR_TO_MANY_LUA_SCRIPTS "Too many Lua scripts!" #if defined(MAVLINK) #define TR_MAVLINK_RC_RSSI_SCALE_LABEL "Max RSSI" diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index 3f6553139..7f280f025 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -814,6 +814,7 @@ #define TR_INPUTS "Entrées" #define TR_OUTPUTS "Sorties" #define TR_EEBACKUP "\004[ENTER Long]: Sauvegarder l'EEPROM" +#define TR_TO_MANY_LUA_SCRIPTS "Too many Lua scripts!" #if defined(MAVLINK) #define TR_MAVLINK_RC_RSSI_SCALE_LABEL "RSSI Max" diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index eac7abfcd..1539e867b 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -814,6 +814,7 @@ #define TR_INPUTS "Ingresso" #define TR_OUTPUTS "Uscita" #define TR_EEBACKUP "\004[ENTER Lungo] per copiare la EEPROM" +#define TR_TO_MANY_LUA_SCRIPTS "Too many Lua scripts!" #if defined(MAVLINK) #define TR_MAVLINK_RC_RSSI_SCALE_LABEL "Max RSSI" diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index 26bb3b615..ba8a35b65 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -814,6 +814,7 @@ #define TR_INPUTS "Wejścia" #define TR_OUTPUTS "Wyjścia" #define TR_EEBACKUP "\004[ENTER Long] to backup the EEPROM" +#define TR_TO_MANY_LUA_SCRIPTS "Too many Lua scripts!" #if defined(MAVLINK) #define TR_MAVLINK_RC_RSSI_SCALE_LABEL "MaksRSSI" diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index 705cfe081..b96473313 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -814,6 +814,7 @@ #define TR_INPUTS "Inputs" #define TR_OUTPUTS "Outputs" #define TR_EEBACKUP "\004[ENTER Long] to backup the EEPROM" +#define TR_TO_MANY_LUA_SCRIPTS "Too many Lua scripts!" #if defined(MAVLINK) #define TR_MAVLINK_RC_RSSI_SCALE_LABEL "Max RSSI" diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index 76710b83b..7b66737f8 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -814,6 +814,7 @@ #define TR_INPUTS "Input" #define TR_OUTPUTS "Outputs" #define TR_EEBACKUP "\004[ENTER Lång] säkerhetskopiera EEPROM" +#define TR_TO_MANY_LUA_SCRIPTS "Too many Lua scripts!" #if defined(MAVLINK) #define TR_MAVLINK_RC_RSSI_SCALE_LABEL "Max RSSI"