diff --git a/src/board_ersky9x.cpp b/src/board_ersky9x.cpp index 8d27c131c..486ac345c 100644 --- a/src/board_ersky9x.cpp +++ b/src/board_ersky9x.cpp @@ -951,6 +951,7 @@ extern uint32_t keyState(EnumKeys enuk) uint16_t Analog_values[NUMBER_ANALOG] ; uint16_t Temperature ; // Raw temp reading +uint16_t maxTemperature ; // Raw temp reading // Read 8 (9 for REVB) ADC channels // Documented bug, must do them 1 by 1 @@ -990,6 +991,9 @@ void read_9_adc() #endif Temperature = ( Temperature * 7 + ADC->ADC_CDR15 ) >> 3 ; // Filter it + if ( Temperature > maxTemperature ) { + maxTemperature = Temperature ; + } // Power save // PMC->PMC_PCER0 &= ~0x20000000L ; // Disable peripheral clock to ADC @@ -1157,3 +1161,22 @@ void usb_mode() disable_ssc() ; sam_boot() ; } + +#if defined(REVB) +uint16_t getCurrent() +{ + static uint16_t Current ; + static uint32_t Current_sum ; + static uint8_t Current_count ; + + Current_sum += anaIn(NUMBER_ANALOG-1); + if ( ++Current_count > 49 ) { + Current = Current_sum / 5 ; + Current_sum = 0 ; + Current_count = 0 ; + } + + uint32_t current_scale = 488 + g_eeGeneral.currentCalib ; + return (current_scale * Current) / 8192; +} +#endif diff --git a/src/board_ersky9x.h b/src/board_ersky9x.h index 9e3d36402..31b43b4bc 100644 --- a/src/board_ersky9x.h +++ b/src/board_ersky9x.h @@ -26,5 +26,7 @@ #define PIN_HIGH 0x100 void configure_pins( uint32_t pins, uint16_t config ); +uint16_t getCurrent(); extern uint16_t Temperature ; // Raw temp reading +extern uint16_t maxTemperature ; // Raw temp reading diff --git a/src/eeprom_arm.cpp b/src/eeprom_arm.cpp index b8affab6a..e526d3134 100644 --- a/src/eeprom_arm.cpp +++ b/src/eeprom_arm.cpp @@ -50,16 +50,6 @@ struct t_file_entry File_system[MAX_MODELS+1] ; char ModelNames[MAX_MODELS][sizeof(g_model.name)] ; // Allow for general - -//static uint32_t Eeprom_image_updated ; // Ram image changed -//static uint32_t Eeprom_sequence_no ; // Ram image changed -//static uint8_t Current_eeprom_block ; // 0 or 1 is active block -//static uint8_t Other_eeprom_block_blank ; -//static uint8_t Eeprom_process_state ; -//static uint8_t Eeprom_process_sub_no ; // Used to manage writes -//static uint8_t Eeprom_write_pending ; -//static uint8_t Eeprom_writing_block_no ; - // TODO check everything here uint8_t Eeprom32_process_state ; uint8_t Eeprom32_state_after_erase ; @@ -70,26 +60,10 @@ uint8_t *Eeprom32_source_address ; uint32_t Eeprom32_address ; uint32_t Eeprom32_data_size ; - -uint16_t General_timer ; -uint16_t Model_timer ; -uint32_t Update_timer ; - - -// States in Eeprom_process_state -#define E_IDLE 1 -//#define E_ERASESENDING 2 -//#define E_ERASEWAITING 3 -//#define E_WRITESENDING 4 -//#define E_WRITEWAITING 5 -//#define E_32ACTIVE 6 - // TODO use these constants everywhere #define EE_WAIT 0 #define EE_NO_WAIT 1 -//#define E32_READING 10 // Set elsewhere as a lock - void eeDirty(uint8_t msk) { s_eeDirtyMsk |= msk; diff --git a/src/frsky.cpp b/src/frsky.cpp index 7a8a4b253..170a465c6 100644 --- a/src/frsky.cpp +++ b/src/frsky.cpp @@ -853,7 +853,7 @@ void putsTelemetryValue(uint8_t x, uint8_t y, int16_t val, uint8_t unit, uint8_t { lcd_outdezAtt(x, (att & DBLSIZE ? y - FH : y), val, att & (~NO_UNIT)); // TODO we could add this test inside lcd_outdezAtt! if (~att & NO_UNIT && unit != UNIT_RAW) - lcd_putsiAtt(lcd_lastPos+1, y, STR_VTELEMUNIT, unit, 0); + lcd_putsiAtt(lcd_lastPos/*+1*/, y, STR_VTELEMUNIT, unit, 0); } static const pm_uint8_t bchunit_ar[] PROGMEM = { @@ -963,27 +963,33 @@ void displayGpsTime() void displayGpsCoord(uint8_t y, char direction, int16_t bp, int16_t ap) { - if (!direction) direction = '-'; + if (frskyHubData.gpsFix >= 0) { + if (!direction) direction = '-'; - lcd_outdezAtt(10*FW, y, bp / 100, LEFT); // ddd before '.' - lcd_putc(lcd_lastPos, y, '@'); - uint8_t mn = bp % 100; - if (g_eeGeneral.gpsFormat == 0) { - lcd_putc(lcd_lastPos+FWNUM, y, direction); - lcd_outdezNAtt(lcd_lastPos+FW+FW+1, y, mn, LEFT|LEADING0, 2); // mm before '.' - lcd_vline(lcd_lastPos, y, 2); - uint16_t ss = ap * 6; - lcd_outdezAtt(lcd_lastPos+3, y, ss / 1000, LEFT); // '' - lcd_plot(lcd_lastPos, y+FH-2, 0); // small decimal point - lcd_outdezAtt(lcd_lastPos+2, y, ss % 1000, LEFT); // '' - lcd_vline(lcd_lastPos, y, 2); - lcd_vline(lcd_lastPos+2, y, 2); + lcd_outdezAtt(10*FW, y, bp / 100, LEFT); // ddd before '.' + lcd_putc(lcd_lastPos, y, '@'); + uint8_t mn = bp % 100; + if (g_eeGeneral.gpsFormat == 0) { + lcd_putc(lcd_lastPos+FWNUM, y, direction); + lcd_outdezNAtt(lcd_lastPos+FW+FW+1, y, mn, LEFT|LEADING0, 2); // mm before '.' + lcd_vline(lcd_lastPos, y, 2); + uint16_t ss = ap * 6; + lcd_outdezAtt(lcd_lastPos+3, y, ss / 1000, LEFT); // '' + lcd_plot(lcd_lastPos, y+FH-2, 0); // small decimal point + lcd_outdezAtt(lcd_lastPos+2, y, ss % 1000, LEFT); // '' + lcd_vline(lcd_lastPos, y, 2); + lcd_vline(lcd_lastPos+2, y, 2); + } + else { + lcd_outdezNAtt(lcd_lastPos+FW, y, mn, LEFT|LEADING0, 2); // mm before '.' + lcd_plot(lcd_lastPos, y+FH-2, 0); // small decimal point + lcd_outdezNAtt(lcd_lastPos+2, y, ap, LEFT|UNSIGN|LEADING0, 4); // after '.' + lcd_putc(lcd_lastPos+1, y, direction); + } } else { - lcd_outdezNAtt(lcd_lastPos+FW, y, mn, LEFT|LEADING0, 2); // mm before '.' - lcd_plot(lcd_lastPos, y+FH-2, 0); // small decimal point - lcd_outdezNAtt(lcd_lastPos+2, y, ap, LEFT|UNSIGN|LEADING0, 4); // after '.' - lcd_putc(lcd_lastPos+1, y, direction); + // no fix + lcd_puts(10*FW, y, STR_VCSWFUNC+1/*----*/); } } #endif @@ -1030,6 +1036,7 @@ void menuProcFrsky(uint8_t event) if (frskyStreaming >= 0) { if (s_frsky_view == e_frsky_custom) { // The custom view + uint8_t fields_count = 0; for (uint8_t i=0; i<4; i++) { for (uint8_t j=0; j<2; j++) { uint8_t field = getTelemCustomField(i, j); @@ -1054,6 +1061,7 @@ void menuProcFrsky(uint8_t event) } } if (field) { + fields_count++; int16_t value = getValue(CSW_CHOUT_BASE+NUM_CHNOUT+field-1); uint8_t att = (i==3 ? NO_UNIT : DBLSIZE|NO_UNIT); if (field <= TELEM_TM2) { @@ -1067,6 +1075,10 @@ void menuProcFrsky(uint8_t event) } } } + if (fields_count == 0) { + // No bars at all! + putEvent(event == EVT_KEY_BREAK(KEY_UP) ? event : EVT_KEY_BREAK(KEY_DOWN)); + } lcd_status_line(); } else if (s_frsky_view == e_frsky_bars) { @@ -1112,7 +1124,7 @@ void menuProcFrsky(uint8_t event) } if (bars_height == 13) { // No bars at all! - s_frsky_view = ((event == EVT_KEY_BREAK(KEY_UP)) ? e_frsky_custom : e_frsky_a1a2); + putEvent(event == EVT_KEY_BREAK(KEY_UP) ? event : EVT_KEY_BREAK(KEY_DOWN)); } displayRssiLine(); } diff --git a/src/general_menus.cpp b/src/general_menus.cpp index 2032bacc7..c8ae1aa9c 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -635,23 +635,39 @@ void menuProcDiagKeys(uint8_t event) void menuProcDiagAna(uint8_t event) { - SIMPLE_MENU(STR_MENUANA, menuTabDiag, e_Ana, 2); +#if defined(PCBARM) && defined(REVB) +#define ANAS_ITEMS_COUNT 3 +#else +#define ANAS_ITEMS_COUNT 2 +#endif - for (uint8_t i=0; i<8; i++) { - uint8_t y=i*FH; - putsStrIdx(4*FW, y, PSTR("A"), i+1); - lcd_outhex4( 8*FW, y, anaIn(i)); - if (i<7) - lcd_outdez8(17*FW, y, (int32_t)calibratedStick[i]*100/1024); - else - putsVolts(17*FW, y, g_vbat100mV, (m_posVert==1 ? INVERS : 0)); + SIMPLE_MENU(STR_MENUANA, menuTabDiag, e_Ana, ANAS_ITEMS_COUNT); + + for (uint8_t i=0; i<7; i++) { + uint8_t y = 1+FH+(i/2)*FH; + uint8_t x = i&1 ? 64+5 : 0; + putsStrIdx(x, y, PSTR("A"), i+1, TWO_DOTS); + lcd_outhex4(x+3*FW-1, y, anaIn(i)); + lcd_outdez8(x+10*FW-1, y, (int16_t)calibratedStick[i]*25/256); } - // Display raw BandGap result (debug) - lcd_puts( 19*FW, 5*FH, STR_BG) ; - lcd_outdezAtt(21*FW, 6*FH, BandGap, 0); - lcd_outdezAtt(21*FW, 7*FH, anaIn(7)*35/512, PREC1); +#if !defined(PCBARM) + // Display raw BandGap result (debug) + lcd_puts(64+5, 1+4*FH, STR_BG); + lcd_outdezAtt(64+5+6*FW-3, 1+4*FH, BandGap, 0); +#endif + + // Voltage calibration + lcd_putsLeft(6*FH-2, STR_BATT_CALIB); + putsVolts(17*FW, 6*FH-2, g_vbat100mV, (m_posVert==1 ? INVERS : 0)); if (m_posVert==1) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatCalib, -127, 127); + +#if defined(PCBARM) && defined(REVB) + lcd_putsLeft(7*FH-2, STR_CURRENT_CALIB); + putsTelemetryValue(17*FW, 7*FH-2, getCurrent(), UNIT_MILLIAMPS, (m_posVert==2 ? INVERS : 0)) ; + if (m_posVert==2) CHECK_INCDEC_GENVAR(event, g_eeGeneral.currentCalib, -49, 49); +#endif + } void menuProcDiagCalib(uint8_t event) diff --git a/src/lcd.cpp b/src/lcd.cpp index ed689ef10..a2da09f1f 100644 --- a/src/lcd.cpp +++ b/src/lcd.cpp @@ -443,7 +443,7 @@ void putsTime(uint8_t x,uint8_t y,int16_t tme,uint8_t att,uint8_t att2) void putsVolts(uint8_t x, uint8_t y, uint16_t volts, uint8_t att) { lcd_outdezAtt(x, y, (int16_t)volts, (~NO_UNIT) & (att | ((att&PREC2)==PREC2 ? 0 : PREC1))); - if (~att & NO_UNIT) lcd_putcAtt(lcd_lastPos, y, 'v', att); + if (~att & NO_UNIT) lcd_putcAtt(lcd_lastPos, y, 'v', att&(~INVERS)); } void putsVBat(uint8_t x, uint8_t y, uint8_t att) diff --git a/src/menus.cpp b/src/menus.cpp index db5fa1fda..6c3458357 100644 --- a/src/menus.cpp +++ b/src/menus.cpp @@ -110,10 +110,10 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui killEvents(event); AUDIO_WARNING2(); } - if(newval != val){ - if(newval==0) { + if (newval != val) { + if ((~i_flags & NO_INCDEC_MARKS) && (newval==0 || newval==-100 || newval==+100)) { pauseEvents(event); // delay before auto-repeat continues - if (newval>val) // TODO check if without AUDIO it's optimized! + if (newval>val) // without AUDIO it's optimized, because the 2 sounds are the same AUDIO_KEYPAD_UP(); else AUDIO_KEYPAD_DOWN(); diff --git a/src/menus.h b/src/menus.h index 81fcd9cb8..0b7c6c47a 100644 --- a/src/menus.h +++ b/src/menus.h @@ -97,6 +97,10 @@ extern int16_t p1valdiff; extern int8_t checkIncDec_Ret; // global helper vars extern int8_t s_editMode; // global editmode +// checkIncDec flags +#define EE_GENERAL 0x01 +#define EE_MODEL 0x02 +#define NO_INCDEC_MARKS 0x04 int16_t checkIncDec(uint8_t event, int16_t i_pval, int16_t i_min, int16_t i_max, uint8_t i_flags); int8_t checkIncDecModel(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max); int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max); diff --git a/src/model_menus.cpp b/src/model_menus.cpp index 338843ee8..84da621dc 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -172,7 +172,7 @@ void menuProcModelSelect(uint8_t event) // no break case EVT_KEY_BREAK(KEY_EXIT): if (s_copyMode) { - sub = m_posVert = (s_copyMode == MOVE_MODE || s_copySrcRow<0) ? (16+sub+s_copyTgtOfs) % 16 : s_copySrcRow; // TODO reset s_copySrcRow? + sub = m_posVert = (s_copyMode == MOVE_MODE || s_copySrcRow<0) ? (MAX_MODELS+sub+s_copyTgtOfs) % MAX_MODELS : s_copySrcRow; // TODO reset s_copySrcRow? s_copyMode = 0; // TODO only this one? s_copySrcRow = -1; s_copyTgtOfs = 0; @@ -191,7 +191,7 @@ void menuProcModelSelect(uint8_t event) displayPopup(s_copyMode==COPY_MODE ? STR_COPYINGMODEL : STR_MOVINGMODEL); eeCheck(true); // force writing of current model data before this is changed - uint8_t cur = (16 + sub + s_copyTgtOfs) % 16; + uint8_t cur = (MAX_MODELS + sub + s_copyTgtOfs) % MAX_MODELS; if (s_copyMode == COPY_MODE) { if (!eeCopyModel(cur, s_copySrcRow)) @@ -201,7 +201,7 @@ void menuProcModelSelect(uint8_t event) s_copySrcRow = g_eeGeneral.currModel; // to update the currModel value while (sub != cur) { uint8_t src = cur; - cur = (s_copyTgtOfs > 0 ? cur+15 : cur+1) % 16; + cur = (s_copyTgtOfs > 0 ? cur+15 : cur+1) % MAX_MODELS; eeSwapModels(src, cur); if (src == s_copySrcRow) s_copySrcRow = cur; @@ -250,7 +250,7 @@ void menuProcModelSelect(uint8_t event) case EVT_KEY_FIRST(KEY_DOWN): if (s_copyMode) { int8_t next_ofs = (_event == EVT_KEY_FIRST(KEY_UP) ? s_copyTgtOfs+1 : s_copyTgtOfs-1); - if (next_ofs == 16 || next_ofs == -16) + if (next_ofs == MAX_MODELS || next_ofs == -MAX_MODELS) next_ofs = 0; if (s_copySrcRow < 0 && s_copyMode==COPY_MODE) { @@ -298,13 +298,13 @@ void menuProcModelSelect(uint8_t event) k = sub + s_copyTgtOfs; } } - else if (s_copyTgtOfs < 0 && ((k < sub && k >= sub+s_copyTgtOfs) || (k-16 < sub && k-16 >= sub+s_copyTgtOfs))) + else if (s_copyTgtOfs < 0 && ((k < sub && k >= sub+s_copyTgtOfs) || (k-MAX_MODELS < sub && k-MAX_MODELS >= sub+s_copyTgtOfs))) k += 1; - else if (s_copyTgtOfs > 0 && ((k > sub && k <= sub+s_copyTgtOfs) || (k+16 > sub && k+16 <= sub+s_copyTgtOfs))) + else if (s_copyTgtOfs > 0 && ((k > sub && k <= sub+s_copyTgtOfs) || (k+MAX_MODELS > sub && k+MAX_MODELS <= sub+s_copyTgtOfs))) k += 15; } - k %= 16; + k %= MAX_MODELS; if (eeModelExists(k)) { #if defined(PCBARM) @@ -1851,6 +1851,7 @@ void menuProcTelemetry(uint8_t event) case EVT_KEY_BREAK(KEY_RIGHT): if (s_editMode>0 && sub<=13) FRSKY_setModelAlarms(); // update Fr-Sky module when edit mode exited + break; } blink = (s_editMode>0) ? BLINK|INVERS : INVERS ; @@ -1860,7 +1861,7 @@ void menuProcTelemetry(uint8_t event) for (int i=0; i<2; i++) { if(s_pgOfs0 || p1valdiff)) { if (m_posHorz == 0) { uint16_t ratio = checkIncDec(event, g_model.frsky.channels[i].ratio, 0, 256, EE_MODEL); @@ -1939,7 +1940,7 @@ void menuProcTelemetry(uint8_t event) for (int j=0; j<2; j++) { if(s_pgOfs on) swTog = !swOn[i]; if (s_perout_mode == e_perout_mode_normal) { @@ -1561,7 +1567,7 @@ void perOut(uint8_t phase) if (!has_delay) { if (md->speedDown) { if (md->mltpx==MLTPX_REP) continue; - if (md->swtch) v = 0; + if (md->swtch) { v = 0; apply_offset = false; } } else if (md->swtch) { continue; @@ -1570,7 +1576,7 @@ void perOut(uint8_t phase) } //========== OFFSET =============== - if(md->sOffset) v += calc100toRESX(md->sOffset); + if (apply_offset && md->sOffset) v += calc100toRESX(md->sOffset); //========== SPEED =============== if (s_perout_mode==e_perout_mode_normal && (md->speedUp || md->speedDown)) // there are delay values diff --git a/src/open9x.h b/src/open9x.h index e0ee50a20..f1c38602b 100644 --- a/src/open9x.h +++ b/src/open9x.h @@ -570,10 +570,6 @@ void getADC_single(); void getADC_osmp(); void getADC_filt(); -// checkIncDec flags -#define EE_GENERAL 0x01 -#define EE_MODEL 0x02 - extern uint8_t s_eeDirtyMsk; #define STORE_MODELVARS eeDirty(EE_MODEL) @@ -660,6 +656,22 @@ void generalDefault(); void modelDefault(uint8_t id); void resetProto(); +#if defined(PCBARM) +inline int32_t calc100toRESX(register int8_t x) +{ + return ((uint32_t)x*655)>>6 ; +} + +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; +} +#else extern inline int16_t calc100toRESX(int8_t x) { // return (int16_t)x*10 + x/4 - x/64; @@ -675,6 +687,7 @@ extern inline int16_t calc1000toRESX(int16_t x) x-=y; return x+(y>>2); } +#endif extern volatile uint16_t g_tmr10ms; diff --git a/src/open9x.hex.zip b/src/open9x.hex.zip new file mode 100644 index 000000000..a3cce4131 Binary files /dev/null and b/src/open9x.hex.zip differ diff --git a/src/simpgmspace.cpp b/src/simpgmspace.cpp index 9b88b80e0..92391b9e7 100644 --- a/src/simpgmspace.cpp +++ b/src/simpgmspace.cpp @@ -213,6 +213,11 @@ void eeprom_read_block (void *pointer_ram, } } +uint16_t stack_free() +{ + return 500; +} + #if 0 static void EeFsDump(){ for(int i=0; i> 1) +#define ERSKY9X_RIGHT_MASK (0x20 >> 1) +#define ERSKY9X_DOWN_MASK (0x40 >> 1) +#define ERSKY9X_LEFT_MASK (0x10 >> 1) +#else +#define ERSKY9X_MENU_MASK (0x40) +#define ERSKY9X_EXIT_MASK (0x80000000) +#define ERSKY9X_EXIT_PIO PIOA +#define ERSKY9X_UP_MASK (0x08 >> 1) +#define ERSKY9X_RIGHT_MASK (0x20 >> 1) +#define ERSKY9X_DOWN_MASK (0x10 >> 1) +#define ERSKY9X_LEFT_MASK (0x40 >> 1) +#endif static uint64_t keys1[]={ - KEY_Return, INP_B_KEY_MEN, INP_P_KEY_MEN, (uint64_t)PIOB, 0x40, - KEY_Page_Up, INP_B_KEY_MEN, INP_P_KEY_MEN, (uint64_t)PIOB, 0x40, - KEY_KP_1, INP_B_KEY_MEN, INP_P_KEY_MEN, (uint64_t)PIOB, 0x40, - KEY_Page_Down, INP_B_KEY_EXT, INP_P_KEY_EXT, (uint64_t)PIOA, 0x80000000, - KEY_BackSpace, INP_B_KEY_EXT, INP_P_KEY_EXT, (uint64_t)PIOA, 0x80000000, - KEY_KP_0, INP_B_KEY_EXT, INP_P_KEY_EXT, (uint64_t)PIOA, 0x80000000, - KEY_Down, INP_B_KEY_DWN, INP_P_KEY_DWN, (uint64_t)PIOC, 0x10 >> 1, - KEY_Up, INP_B_KEY_UP, INP_P_KEY_UP, (uint64_t)PIOC, 0x08 >> 1, - KEY_Right, INP_B_KEY_RGT, INP_P_KEY_RGT, (uint64_t)PIOC, 0x20 >> 1, - KEY_Left, INP_B_KEY_LFT, INP_P_KEY_LFT, (uint64_t)PIOC, 0x40 >> 1, + KEY_Return, INP_B_KEY_MEN, INP_P_KEY_MEN, (uint64_t)PIOB, ERSKY9X_MENU_MASK, + KEY_Page_Up, INP_B_KEY_MEN, INP_P_KEY_MEN, (uint64_t)PIOB, ERSKY9X_MENU_MASK, + KEY_KP_1, INP_B_KEY_MEN, INP_P_KEY_MEN, (uint64_t)PIOB, ERSKY9X_MENU_MASK, + KEY_Page_Down, INP_B_KEY_EXT, INP_P_KEY_EXT, (uint64_t)ERSKY9X_EXIT_PIO, ERSKY9X_EXIT_MASK, + KEY_BackSpace, INP_B_KEY_EXT, INP_P_KEY_EXT, (uint64_t)ERSKY9X_EXIT_PIO, ERSKY9X_EXIT_MASK, + KEY_KP_0, INP_B_KEY_EXT, INP_P_KEY_EXT, (uint64_t)ERSKY9X_EXIT_PIO, ERSKY9X_EXIT_MASK, + KEY_Down, INP_B_KEY_DWN, INP_P_KEY_DWN, (uint64_t)PIOC, ERSKY9X_DOWN_MASK, + KEY_Up, INP_B_KEY_UP, INP_P_KEY_UP, (uint64_t)PIOC, ERSKY9X_UP_MASK, + KEY_Right, INP_B_KEY_RGT, INP_P_KEY_RGT, (uint64_t)PIOC, ERSKY9X_RIGHT_MASK, + KEY_Left, INP_B_KEY_LFT, INP_P_KEY_LFT, (uint64_t)PIOC, ERSKY9X_LEFT_MASK, }; pinb &= ~ 0x7e; @@ -291,6 +308,8 @@ void Open9xSim::refreshDiplay() PIOC->PIO_PDSR = 0xFDFFFFFF; PIOB->PIO_PDSR = 0xFFFFFFFF; PIOA->PIO_PDSR = 0xFFFFFFFF; + Temperature = 1000; + maxTemperature = 1500; #endif for(unsigned i=0; igetKeyState(keys1[i])) { diff --git a/src/statistics_views.cpp b/src/statistics_views.cpp index eec53d91c..b82e044ac 100644 --- a/src/statistics_views.cpp +++ b/src/statistics_views.cpp @@ -77,12 +77,7 @@ void menuProcStatistic(uint8_t event) } } -#if defined(PCBARM) && defined(REVB) -uint16_t Current ; -uint32_t Current_sum ; -uint8_t Current_count ; -#endif - +#define MENU_DEBUG_COL_OFS (14*FW) void menuProcDebug(uint8_t event) { TITLE(STR_MENUDEBUG); @@ -107,43 +102,42 @@ void menuProcDebug(uint8_t event) #if !defined(PCBARM) lcd_putsLeft(1*FH, STR_TMR1LATMAXUS); - lcd_outdez8(15*FW , 1*FH, g_tmr1Latency_max/2 ); + lcd_outdez8(MENU_DEBUG_COL_OFS , 1*FH, g_tmr1Latency_max/2 ); lcd_putsLeft(2*FH, STR_TMR1LATMINUS); - lcd_outdez8(15*FW , 2*FH, g_tmr1Latency_min/2 ); + lcd_outdez8(MENU_DEBUG_COL_OFS , 2*FH, g_tmr1Latency_min/2 ); lcd_putsLeft(3*FH, STR_TMR1JITTERUS); - lcd_outdez8(15*FW , 3*FH, (g_tmr1Latency_max - g_tmr1Latency_min) /2 ); + lcd_outdez8(MENU_DEBUG_COL_OFS , 3*FH, (g_tmr1Latency_max - g_tmr1Latency_min) /2 ); #endif lcd_putsLeft(4*FH, STR_TMAINMAXMS); #if defined(PCBARM) - lcd_outdezAtt(15*FW, 4*FH, (g_timeMain)/20, PREC2); + lcd_outdezAtt(MENU_DEBUG_COL_OFS, 4*FH, (g_timeMain)/20, PREC2); #else - lcd_outdezAtt(15*FW, 4*FH, (g_timeMain*100)/16, PREC2); + lcd_outdezAtt(MENU_DEBUG_COL_OFS, 4*FH, (g_timeMain*100)/16, PREC2); #endif -#if defined(PCBARM) && defined(REVB) - // TODO then there are 2 means, is it needed? - Current_sum += anaIn(NUMBER_ANALOG-1) ; - if ( ++Current_count > 49 ) - { - Current = Current_sum / 5 ; - Current_sum = 0 ; - Current_count = 0 ; - } - lcd_putsLeft(6*FH, STR_CURRENT); - lcd_outhex4(10*FW+3, 6*FH, Current ) ; - lcd_outdezAtt(18*FW, 6*FH, Current/22, 0 ) ; +#if defined(PCBARM) +#if defined(REVB) + lcd_putsLeft(2*FH, STR_CURRENT); + putsTelemetryValue(MENU_DEBUG_COL_OFS, 2*FH, getCurrent(), UNIT_MILLIAMPS, 0) ; +#endif + + lcd_putsLeft(3*FH, PSTR("CPU temp.\010>")); + putsTelemetryValue(MENU_DEBUG_COL_OFS, 3*FH, (((((int32_t)Temperature - 838 ) * 621 ) >> 11 ) - 20), UNIT_DEGREES, 0 ) ; + putsTelemetryValue(20*FW+2, 3*FH, (((((int32_t)maxTemperature - 838 ) * 621 ) >> 11 ) - 20), UNIT_DEGREES, 0 ) ; // TODO mAh, Battery from ersky9x? #endif +#if !defined(PCBARM) + lcd_puts( 0*FW, 5*FH, STR_FREESTACKMINB); + lcd_outdezAtt(14*FW, 5*FH, stack_free(), UNSIGN) ; +#endif #ifdef DEBUG - lcd_puts( 0*FW, 5*FH, STR_T10MSUS); - lcd_outdez8(15*FW , 5*FH, g_time_per10/2 ); -#endif -#if !defined(SIMU) && !defined(PCBARM) - lcd_puts( 0*FW, 6*FH, STR_FREESTACKMINB); - lcd_outdezAtt(18*FW-1, 6*FH, stack_free(), UNSIGN) ; + lcd_puts( 0*FW, 6*FH, STR_T10MSUS); + lcd_outdez8(MENU_DEBUG_COL_OFS, 6*FH, g_time_per10/2 ); #endif + + lcd_puts( 3*FW, 7*FH, STR_MENUTORESET); } diff --git a/src/translations/en.h b/src/translations/en.h index cd3a99d72..b930b55eb 100644 --- a/src/translations/en.h +++ b/src/translations/en.h @@ -104,7 +104,7 @@ #define TR_VTELEMCHNS "---\0""Tmr1""Tmr2""A1\0 ""A2\0 ""Tx\0 ""Rx\0 ""Alt\0""Rpm\0""Fuel""T1\0 ""T2\0 ""Spd\0""Dist""Cell""AccX""AccY""AccZ""Hdg\0""VSpd""A1-\0""A2-\0""Alt-""Alt+""Rpm+""T1+\0""T2+\0""Spd+""Dst+""Acc\0""Time" #define LEN_VTELEMUNIT "\003" -#define TR_VTELEMUNIT "v\0 ""A\0 ""-\0 ""kts""kmh""M/h""m\0 ""@\0 ""%\0" +#define TR_VTELEMUNIT "v\0 ""A\0 ""-\0 ""kts""kmh""M/h""m\0 ""@\0 ""%\0 ""mA\0" #define STR_V (STR_VTELEMUNIT+1) #define STR_A (STR_VTELEMUNIT+4) @@ -254,7 +254,7 @@ #define TR_CAL "Cal" #define TR_EEPROMV "EEPROM v" #define TR_VTRIM "Trim- +" -#define TR_BG "BG" +#define TR_BG "BG:" #define TR_MENUTOSTART "[MENU] TO START" #define TR_SETMIDPOINT "SET MIDPOINT" #define TR_MOVESTICKSPOTS "MOVE STICKS/POTS" @@ -266,12 +266,12 @@ #define TR_TM1TM2 "TM1\015TM2" #define TR_THRTHP "THR\015TH%" #define TR_TOT "TOT" -#define TR_TMR1LATMAXUS "tmr1Lat max\004us" -#define TR_TMR1LATMINUS "tmr1Lat min\004us" -#define TR_TMR1JITTERUS "tmr1 Jitter\004us" -#define TR_TMAINMAXMS "tmain max\006ms" -#define TR_T10MSUS "t10ms\010us" -#define TR_FREESTACKMINB "Free Stack min\004b" +#define TR_TMR1LATMAXUS "Tmr1Lat max\003us" +#define TR_TMR1LATMINUS "Tmr1Lat min\003us" +#define TR_TMR1JITTERUS "Tmr1 Jitter\003us" +#define TR_TMAINMAXMS "Tmain max\005ms" +#define TR_T10MSUS "T10ms\007us" +#define TR_FREESTACKMINB "Free Stack\004b" #define TR_MENUTORESET "[MENU] to reset" #define TR_PPM "PPM" #define TR_CH "CH" @@ -295,7 +295,7 @@ #define TR_MENUTRAINER "TRAINER" #define TR_MENUVERSION "VERSION" #define TR_MENUDIAG "DIAG" -#define TR_MENUANA "ANA" +#define TR_MENUANA "ANAS" #define TR_MENUCALIBRATION "CALIBRATION" #define TR_MENUSERROR "MENUS OVERFLOW" #define TR_TRIMS2OFFSETS "Trims => Offsets" @@ -324,4 +324,6 @@ #define TR_LONGITUDE "Longitude" #define TR_GPSCOORD "Gps Coords" #define TR_SHUTDOWN "SHUTTING DOWN" +#define TR_BATT_CALIB "Battery Calib" +#define TR_CURRENT_CALIB "Current Calib" #define TR_CURRENT "Current" diff --git a/src/translations/fr.h b/src/translations/fr.h index 26f469901..95404ed8e 100644 --- a/src/translations/fr.h +++ b/src/translations/fr.h @@ -104,7 +104,7 @@ #define TR_VTELEMCHNS "---\0""Tmr1""Tmr2""A1\0 ""A2\0 ""Tx\0 ""Rx\0 ""Alt\0""Rpm\0""Fuel""T1\0 ""T2\0 ""Spd\0""Dist""Cell""AccX""AccY""AccZ""Hdg\0""VSpd""A1-\0""A2-\0""Alt-""Alt+""Rpm+""T1+\0""T2+\0""Spd+""Dst+""Acc\0""Time" #define LEN_VTELEMUNIT "\003" -#define TR_VTELEMUNIT "v\0 ""A\0 ""-\0 ""kts""kmh""M/h""m\0 ""@\0 ""%\0" +#define TR_VTELEMUNIT "v\0 ""A\0 ""-\0 ""kts""kmh""M/h""m\0 ""@\0 ""%\0 ""mA\0" #define STR_V (STR_VTELEMUNIT+1) #define STR_A (STR_VTELEMUNIT+4) @@ -255,7 +255,7 @@ #define TR_CAL "Cal" #define TR_EEPROMV "EEPROM v" #define TR_VTRIM "Trim- +" -#define TR_BG "BG" +#define TR_BG "BG:" #define TR_MENUTOSTART "[MENU]POUR DEBUT" #define TR_SETMIDPOINT "SET NEUTRE" #define TR_MOVESTICKSPOTS "BOUGER MANCHES/POTS " @@ -267,12 +267,12 @@ #define TR_TM1TM2 "TM1\015TM2" #define TR_THRTHP "THR\015TH%" #define TR_TOT "TOT" -#define TR_TMR1LATMAXUS "tmr1Lat max\004us" -#define TR_TMR1LATMINUS "tmr1Lat min\004us" -#define TR_TMR1JITTERUS "tmr1 Jitter\004us" -#define TR_TMAINMAXMS "tmain max\006ms" -#define TR_T10MSUS "t10ms\010us" -#define TR_FREESTACKMINB "Free Stack min\004b" +#define TR_TMR1LATMAXUS "Tmr1Lat max\003us" +#define TR_TMR1LATMINUS "Tmr1Lat min\003us" +#define TR_TMR1JITTERUS "Tmr1 Jitter\003us" +#define TR_TMAINMAXMS "Tmain max\005ms" +#define TR_T10MSUS "T10ms\007us" +#define TR_FREESTACKMINB "Free Stack\004b" #define TR_MENUTORESET "[MENU]pour reset" #define TR_PPM "PPM" #define TR_CH "CH" @@ -296,7 +296,7 @@ #define TR_MENUTRAINER "ECOLAGE" #define TR_MENUVERSION "VERSION" #define TR_MENUDIAG "DIAG" -#define TR_MENUANA "ANA" +#define TR_MENUANA "ANAS" #define TR_MENUCALIBRATION "CALIBRATION" #define TR_MENUSERROR "MENUS OVERFLOW" #define TR_TRIMS2OFFSETS "Trims => Offsets" @@ -325,4 +325,6 @@ #define TR_LONGITUDE "Longitude" #define TR_GPSCOORD "Gps Coords" #define TR_SHUTDOWN "ARRET EN COURS" +#define TR_BATT_CALIB "Battery Calib" +#define TR_CURRENT_CALIB "Current Calib" #define TR_CURRENT "Courant" diff --git a/src/translations/se.h b/src/translations/se.h index 96eaec7eb..d8eec0da9 100644 --- a/src/translations/se.h +++ b/src/translations/se.h @@ -101,10 +101,10 @@ #define TR_FUNCSOUNDS "Varn1 ""Varn2 ""F\200r ""Ring ""SciFi ""Robot ""Pip ""Tada ""Syrsa ""Siren ""Alarm ""Ratata""Tick ""Vibr1 ""Vibr2 ""Vibr3 " #define LEN_VTELEMCHNS "\004" -#define TR_VTELEMCHNS "---\0""Tmr1""Tmr2""A1\0 ""A2\0 ""Tx\0 ""Rx\0 ""H\202jd""Varv""Tank""T1\0 ""T2\0 ""Hast""Avst""Batt""AccX""AccY""AccZ""Hdg\0""VHst""A1-\0""A2-\0""Hjd-""Hjd+""Vrv+""T1+\0""T2+\0""Hst+""Avs+""Acc\0""Tid\0" +#define TR_VTELEMCHNS "---\0""Tmr1""Tmr2""A1\0 ""A2\0 ""Tx\0 ""Rx\0 ""Alt\0""Rpm\0""Tank""T1\0 ""T2\0 ""Spd\0""Dist""Cell""AccX""AccY""AccZ""Hdg\0""VSpd""A1-\0""A2-\0""Alt-""Alt+""Rpm+""T1+\0""T2+\0""Spd+""Dst+""Acc\0""Tid\0" #define LEN_VTELEMUNIT "\003" -#define TR_VTELEMUNIT "v\0 ""A\0 ""-\0 ""kts""kmh""M/h""m\0 ""@\0 ""%\0" +#define TR_VTELEMUNIT "v\0 ""A\0 ""-\0 ""kts""kmh""M/h""m\0 ""@\0 ""%\0 ""mA\0" #define STR_V (STR_VTELEMUNIT+1) #define STR_A (STR_VTELEMUNIT+4) @@ -254,7 +254,7 @@ #define TR_CAL "Cal" #define TR_EEPROMV "EEPROM v" #define TR_VTRIM "Trim- +" -#define TR_BG "BG" +#define TR_BG "BG:" #define TR_MENUTOSTART "[MENU] STARTAR" #define TR_SETMIDPOINT " CENTRERA " #define TR_MOVESTICKSPOTS "R\205R SPAKAR/RATTAR" @@ -266,12 +266,12 @@ #define TR_TM1TM2 "TM1\015TM2" #define TR_THRTHP "THR\015TH%" #define TR_TOT "TOT" -#define TR_TMR1LATMAXUS "tmr1Lat max\004us" -#define TR_TMR1LATMINUS "tmr1Lat min\004us" -#define TR_TMR1JITTERUS "tmr1 Jitter\004us" -#define TR_TMAINMAXMS "tmain max\006ms" -#define TR_T10MSUS "t10ms\010us" -#define TR_FREESTACKMINB "Free Stack min\004b" +#define TR_TMR1LATMAXUS "Tmr1Lat max\003us" +#define TR_TMR1LATMINUS "Tmr1Lat min\003us" +#define TR_TMR1JITTERUS "Tmr1 Jitter\003us" +#define TR_TMAINMAXMS "Tmain max\005ms" +#define TR_T10MSUS "T10ms\007us" +#define TR_FREESTACKMINB "Free Stack\004b" #define TR_MENUTORESET "[MENU] NOLLAR " #define TR_PPM "PPM" #define TR_CH "KN" @@ -295,7 +295,7 @@ #define TR_MENUTRAINER "TRAINER (PPM IN)" #define TR_MENUVERSION "VERSION" #define TR_MENUDIAG "DIAGNOS" -#define TR_MENUANA "ANA" +#define TR_MENUANA "ANAS" #define TR_MENUCALIBRATION "KALIBRERING" #define TR_MENUSERROR "FEL I MENU" #define TR_TRIMS2OFFSETS "Trims => Offsets" @@ -324,4 +324,6 @@ #define TR_LONGITUDE "L\201ngdgrad" #define TR_GPSCOORD "GPS-Koord." #define TR_SHUTDOWN "ST\204NGER AV" +#define TR_BATT_CALIB "Battery Calib" +#define TR_CURRENT_CALIB "Current Calib" #define TR_CURRENT "Sp\201nning"