[X9D] Sticks and pots OK, calibration OK

This commit is contained in:
bernet.andre@gmail.com
2013-01-07 21:22:46 +00:00
parent 599bacd673
commit edd838d866
4 changed files with 28 additions and 7 deletions
+9 -2
View File
@@ -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));
+6
View File
@@ -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;
+12 -4
View File
@@ -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<NUM_STICKS+NUM_POTS+5;i++)
sum += g_eeGeneral.calibMid[i];
return sum;
}
@@ -1546,7 +1547,9 @@ int16_t thrAnaIn(uint8_t chan)
uint16_t anaIn(uint8_t chan)
{
#if defined(PCBX9D)
static const uint8_t crossAna[]={1,5,7,0,4,6,2,3};
// crossAna[]={LH,LV,RH,RV,S1,LS,S2,RS,BAT
// s_anaFilt[]={LH,LV,RH,RV,S1,S2,LS,RS,_BAT
static const uint8_t crossAna[]={0,1,2,3,4,6,5,7,8};
#elif defined(PCBSKY9X) && !defined(REVA)
static const uint8_t crossAna[]={1,5,7,0,4,6,2,3};
if (chan == TX_CURRENT) {
@@ -1767,6 +1770,11 @@ BeepANACenter evalSticks(uint8_t mode)
if(v < -RESX) v = -RESX;
if(v > 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;
+1 -1
View File
@@ -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