1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-21 15:25:17 +03:00

Bug in Mixer when offset used with a switch + slow down

GPS displayed as ---- when there has no fixed received since beginning
No Custom telemetry screen displayed when nothing to display
Marks at -100 and +100 when editing a value
RSSI alarms 1 + 2 labels were wrong
ANAS menu redesigned
60 models on ersky9x board
Current calibration on ersky9x board
This commit is contained in:
bsongis 2012-04-10 18:20:51 +00:00
parent 41cafa4d98
commit 10a29a676e
21 changed files with 234 additions and 148 deletions

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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();
}

View file

@ -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)

View file

@ -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)

View file

@ -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();

View file

@ -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);

View file

@ -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_pgOfs<subN) {
y=(subN-s_pgOfs)*FH;
lcd_putsLeft( y, STR_ACHANNEL);
lcd_putsLeft(y, STR_ACHANNEL);
lcd_outdezAtt(2*FW, y, 1+i, 0);
}
subN++;
@ -1869,7 +1870,7 @@ void menuProcTelemetry(uint8_t event)
y=(subN-s_pgOfs)*FH;
lcd_puts(4, y, STR_RANGE);
putsTelemetryChannel(TELEM_COL2, y, i+MAX_TIMERS, 255-g_model.frsky.channels[i].offset, (sub==subN && m_posHorz==0 ? blink:0)|NO_UNIT|LEFT);
lcd_putsiAtt(lcd_lastPos+1, y, STR_VTELEMUNIT, g_model.frsky.channels[i].type, (sub==subN && m_posHorz==1 ? blink:0));
lcd_putsiAtt(lcd_lastPos, y, STR_VTELEMUNIT, g_model.frsky.channels[i].type, (sub==subN && m_posHorz==1 ? blink:0));
if (sub==subN && (s_editMode>0 || 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<subN) {
y = (subN-s_pgOfs)*FH;
lcd_putsn(4, y, STR_TX+j*OFS_RX, OFS_RX-2);
lcd_puts(4, y, STR_ALARM);
lcd_putsiAtt(TELEM_COL2, y, STR_VALARM, ((2+j+g_model.frsky.rssiAlarms[j].level)%4), (sub==subN && m_posHorz==0) ? blink : 0);
lcd_putc(TELEM_COL2+4*FW, y, '<');
lcd_outdezNAtt(TELEM_COL2+6*FW, y, 50+g_model.frsky.rssiAlarms[j].value, LEFT|((sub==subN && m_posHorz==1) ? blink : 0), 3);

View file

@ -133,6 +133,7 @@ PACK(typedef struct t_EEGeneral {
#if defined(PCBARM)
uint8_t speakerVolume;
uint8_t backlightBright; // backlight
int8_t currentCalib;
#endif
}) EEGeneral;
@ -270,6 +271,7 @@ enum TelemetryUnit {
UNIT_METERS,
UNIT_DEGREES,
UNIT_PERCENT,
UNIT_MILLIAMPS,
UNIT_MAX
};
@ -397,7 +399,12 @@ PACK(typedef struct t_PhaseData {
ROTARY_ENCODER_ARRAY
}) PhaseData;
#if defined(PCBARM)
#define MAX_MODELS 60
#else
#define MAX_MODELS 16
#endif
#define MAX_TIMERS 2
#define MAX_PHASES 5
#define MAX_MIXERS 32

View file

@ -293,6 +293,8 @@ const pm_char STR_SHUTDOWN[] PROGMEM = TR_SHUTDOWN;
#endif
#if defined(PCBARM)
const pm_char STR_BATT_CALIB[] PROGMEM = TR_BATT_CALIB;
const pm_char STR_CURRENT_CALIB[] PROGMEM = TR_CURRENT_CALIB;
const pm_char STR_CURRENT[] PROGMEM = TR_CURRENT;
#endif

View file

@ -354,6 +354,8 @@ extern const pm_char STR_SHUTDOWN[];
#endif
#if defined(PCBARM)
extern const pm_char STR_BATT_CALIB[];
extern const pm_char STR_CURRENT_CALIB[];
extern const pm_char STR_CURRENT[];
#endif

View file

@ -387,6 +387,11 @@ int16_t applyLimits(uint8_t channel, int32_t value)
if (safetyCh[channel] != -128) // if safety channel available for channel check
ofs = calc100toRESX(safetyCh[channel]);
#ifdef DSM2
if (g_model.protocol == PROTO_DSM2)
ofs = (ofs * 13) / 32;
#endif
return ofs;
}
@ -928,9 +933,9 @@ uint16_t BandGap = 225;
// G: Note that the above would have set the ADC prescaler to 128, equating to
// 125KHz sample rate. We now sample at 500KHz, with oversampling and other
// filtering options to produce 11-bit results.
#ifdef PCBV4
#if defined(PCBV4)
uint16_t BandGap = 2040 ;
#else
#elif defined(PCBSTD)
uint16_t BandGap ;
#endif
#if defined(PCBARM) and defined(REVB)
@ -1520,6 +1525,7 @@ void perOut(uint8_t phase)
//========== DELAYS ===============
uint8_t swTog;
bool apply_offset = true;
if (sw) { // switch on? (if no switch selected => 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

View file

@ -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;

BIN
src/open9x.hex.zip Normal file

Binary file not shown.

View file

@ -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<EESIZE; i++)

View file

@ -272,17 +272,34 @@ void Open9xSim::refreshDiplay()
}
if(hasFocus()) {
#ifdef REVB
#define ERSKY9X_MENU_MASK (0x20)
#define ERSKY9X_EXIT_MASK (0x01000000)
#define ERSKY9X_EXIT_PIO PIOC
#define ERSKY9X_UP_MASK (0x04 >> 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; i<DIM(keys1);i+=5) {
if (getApp()->getKeyState(keys1[i])) {

View file

@ -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);
}

View file

@ -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"

View file

@ -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"

View file

@ -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"