diff --git a/src/general_menus.cpp b/src/general_menus.cpp index 87a892c5f..11fd67cf0 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -859,7 +859,7 @@ void menuGeneralDiagAna(uint8_t event) SIMPLE_MENU(STR_MENUANA, menuTabDiag, e_Ana, ANAS_ITEMS_COUNT); - for (uint8_t i=0; i<7; i++) { + for (uint8_t i=0; i<8; i++) { uint8_t y = 1+FH+(i/2)*FH; uint8_t x = i&1 ? 64+5 : 0; putsStrIdx(x, y, PSTR("A"), i+1); @@ -874,7 +874,7 @@ void menuGeneralDiagAna(uint8_t event) lcd_outdezAtt(64+5+6*FW-3, 1+4*FH, BandGap, 0); #endif -#if defined(CPUARM) +#if defined(PCBSKY9X) lcd_putsLeft(5*FH, STR_BATT_CALIB); static uint32_t adcBatt; adcBatt = ((adcBatt * 7) + anaIn(7)) / 8; // running average, sourced directly (to avoid unending debate :P) @@ -888,6 +888,13 @@ void menuGeneralDiagAna(uint8_t event) adcBatt = ((adcBatt * 7) + anaIn(7)) / 8; // running average, sourced directly (to avoid unending debate :P) uint32_t batCalV = ((uint32_t)adcBatt*1390 + (10*(int32_t)adcBatt*g_eeGeneral.vBatCalib)/8) / BandGap; lcd_outdezNAtt(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, batCalV, PREC2|(m_posVert==1 ? INVERS : 0)); +#elif defined(PCBX9D) + lcd_putsLeft(5*FH, STR_BATT_CALIB); + static uint32_t adcBatt; + adcBatt = ((adcBatt * 7) + anaIn(8)) / 8; // running average, sourced directly (to avoid unending debate :P) + uint32_t batCalV = ( adcBatt + adcBatt*(g_eeGeneral.vBatCalib)/128 ) * 4191 ; + batCalV /= 55296 ; + putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 5*FH, batCalV, (m_posVert==1 ? INVERS : 0)); #else lcd_putsLeft(6*FH-2, STR_BATT_CALIB); putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH-2, g_vbat100mV, (m_posVert==1 ? INVERS : 0)); diff --git a/src/myeeprom.h b/src/myeeprom.h index b0624d29e..2675c92be 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -146,9 +146,15 @@ uint8_t spare4:2 PACK(typedef struct t_EEGeneral { uint8_t version; uint16_t variant; +#if defined(PCBX9D) + int16_t calibMid[8]; + int16_t calibSpanNeg[8]; + int16_t calibSpanPos[8]; +#else int16_t calibMid[7]; int16_t calibSpanNeg[7]; int16_t calibSpanPos[7]; +#endif uint16_t chkSum; int8_t currModel; uint8_t contrast; diff --git a/src/open9x.cpp b/src/open9x.cpp index d1b234fc5..c86b583ad 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -352,18 +352,19 @@ void generalDefault() g_eeGeneral.variant = EEPROM_VARIANT; g_eeGeneral.contrast = 25; g_eeGeneral.vBatWarn = 90; - for (int i = 0; i < 7; ++i) { + + for (int i = 0; i < NUM_STICKS+NUM_POTS; ++i) { g_eeGeneral.calibMid[i] = 0x200; g_eeGeneral.calibSpanNeg[i] = 0x180; g_eeGeneral.calibSpanPos[i] = 0x180; } - g_eeGeneral.chkSum = (0x200 * 7) + (0x180 * 5); + g_eeGeneral.chkSum = (0x200 * NUM_STICKS+NUM_POTS) + (0x180 * 5); } uint16_t evalChkSum() { uint16_t sum=0; - for (int i=0; i<12;i++) + for (int i=0; i RESX) v = RESX; + + #if defined(PCBX9D) + if(i == 2 || i == 3 || i == 6 || i == 7) + v = -v; + #endif if (g_eeGeneral.throttleReversed && ch==THR_STICK) v = -v; diff --git a/src/x9d/i2c_ee.c b/src/x9d/i2c_ee.c index 339959821..6ff1981f9 100644 --- a/src/x9d/i2c_ee.c +++ b/src/x9d/i2c_ee.c @@ -12,7 +12,7 @@ #include "../open9x.h" -#define I2C_delay() delay_01us(30); +#define I2C_delay() delay_01us(15); /** * @brief Configure the used I/O ports pin