mirror of
https://github.com/opentx/opentx.git
synced 2025-07-16 04:45:17 +03:00
parent
5b139d7b35
commit
093025f444
19 changed files with 29 additions and 128 deletions
|
@ -130,8 +130,6 @@ class GeneralSettings {
|
||||||
unsigned int backlightBright;
|
unsigned int backlightBright;
|
||||||
unsigned int backlightOffBright;
|
unsigned int backlightOffBright;
|
||||||
int switchesDelay;
|
int switchesDelay;
|
||||||
int temperatureCalib;
|
|
||||||
int temperatureWarn;
|
|
||||||
unsigned int mAhWarn;
|
unsigned int mAhWarn;
|
||||||
unsigned int mAhUsed;
|
unsigned int mAhUsed;
|
||||||
unsigned int globalTimer;
|
unsigned int globalTimer;
|
||||||
|
|
|
@ -2354,11 +2354,11 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type
|
||||||
internalField.Append(new UnsignedField<8>(this, generalData.backlightBright));
|
internalField.Append(new UnsignedField<8>(this, generalData.backlightBright));
|
||||||
if (version < 218) internalField.Append(new SignedField<8>(this, generalData.txCurrentCalibration));
|
if (version < 218) internalField.Append(new SignedField<8>(this, generalData.txCurrentCalibration));
|
||||||
|
|
||||||
if (version < 218) internalField.Append(new SignedField<8>(this, generalData.temperatureWarn));
|
if (version < 218) internalField.Append(new SpareBitsField<8>(this));
|
||||||
if (version < 218) internalField.Append(new UnsignedField<8>(this, generalData.mAhWarn));
|
if (version < 218) internalField.Append(new UnsignedField<8>(this, generalData.mAhWarn));
|
||||||
if (version < 218) internalField.Append(new UnsignedField<16>(this, generalData.mAhUsed));
|
if (version < 218) internalField.Append(new UnsignedField<16>(this, generalData.mAhUsed));
|
||||||
internalField.Append(new UnsignedField<32>(this, generalData.globalTimer));
|
internalField.Append(new UnsignedField<32>(this, generalData.globalTimer));
|
||||||
if (version < 218) internalField.Append(new SignedField<8>(this, generalData.temperatureCalib));
|
if (version < 218) internalField.Append(new SpareBitsField<8>(this));
|
||||||
internalField.Append(new UnsignedField<4>(this, generalData.bluetoothBaudrate));
|
internalField.Append(new UnsignedField<4>(this, generalData.bluetoothBaudrate));
|
||||||
internalField.Append(new UnsignedField<4>(this, generalData.bluetoothMode));
|
internalField.Append(new UnsignedField<4>(this, generalData.bluetoothMode));
|
||||||
if (version < 218) internalField.Append(new BoolField<8>(this, generalData.optrexDisplay));
|
if (version < 218) internalField.Append(new BoolField<8>(this, generalData.optrexDisplay));
|
||||||
|
@ -2440,10 +2440,10 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type
|
||||||
}
|
}
|
||||||
else if (IS_SKY9X(board) && version >= 218) {
|
else if (IS_SKY9X(board) && version >= 218) {
|
||||||
internalField.Append(new SignedField<8>(this, generalData.txCurrentCalibration));
|
internalField.Append(new SignedField<8>(this, generalData.txCurrentCalibration));
|
||||||
internalField.Append(new SignedField<8>(this, generalData.temperatureWarn));
|
internalField.Append(new SpareBitsField<8>(this));
|
||||||
internalField.Append(new UnsignedField<8>(this, generalData.mAhWarn));
|
internalField.Append(new UnsignedField<8>(this, generalData.mAhWarn));
|
||||||
internalField.Append(new UnsignedField<16>(this, generalData.mAhUsed));
|
internalField.Append(new UnsignedField<16>(this, generalData.mAhUsed));
|
||||||
internalField.Append(new SignedField<8>(this, generalData.temperatureCalib));
|
internalField.Append(new SpareBitsField<8>(this));
|
||||||
internalField.Append(new BoolField<8>(this, generalData.optrexDisplay));
|
internalField.Append(new BoolField<8>(this, generalData.optrexDisplay));
|
||||||
internalField.Append(new UnsignedField<8>(this, generalData.sticksGain));
|
internalField.Append(new UnsignedField<8>(this, generalData.sticksGain));
|
||||||
internalField.Append(new UnsignedField<8>(this, generalData.rotarySteps));
|
internalField.Append(new UnsignedField<8>(this, generalData.rotarySteps));
|
||||||
|
|
|
@ -693,7 +693,7 @@ PACK(struct TrainerData {
|
||||||
#elif defined(PCBSKY9X)
|
#elif defined(PCBSKY9X)
|
||||||
#define EXTRA_GENERAL_FIELDS \
|
#define EXTRA_GENERAL_FIELDS \
|
||||||
int8_t txCurrentCalibration; \
|
int8_t txCurrentCalibration; \
|
||||||
int8_t temperatureWarn; \
|
int8_t spare; \
|
||||||
uint8_t mAhWarn; \
|
uint8_t mAhWarn; \
|
||||||
uint16_t mAhUsed; \
|
uint16_t mAhUsed; \
|
||||||
int8_t temperatureCalib; \
|
int8_t temperatureCalib; \
|
||||||
|
|
|
@ -118,9 +118,6 @@ enum {
|
||||||
#if defined(TX_CAPACITY_MEASUREMENT)
|
#if defined(TX_CAPACITY_MEASUREMENT)
|
||||||
ITEM_RADIO_HARDWARE_CAPACITY_CALIB,
|
ITEM_RADIO_HARDWARE_CAPACITY_CALIB,
|
||||||
#endif
|
#endif
|
||||||
#if defined(PCBSKY9X)
|
|
||||||
ITEM_RADIO_HARDWARE_TEMPERATURE_CALIB,
|
|
||||||
#endif
|
|
||||||
#if defined(CROSSFIRE) && SPORT_MAX_BAUDRATE < 400000
|
#if defined(CROSSFIRE) && SPORT_MAX_BAUDRATE < 400000
|
||||||
ITEM_RADIO_HARDWARE_SERIAL_BAUDRATE,
|
ITEM_RADIO_HARDWARE_SERIAL_BAUDRATE,
|
||||||
#endif
|
#endif
|
||||||
|
@ -183,12 +180,6 @@ enum {
|
||||||
#define TX_CAPACITY_MEASUREMENT_ROWS
|
#define TX_CAPACITY_MEASUREMENT_ROWS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBSKY9X)
|
|
||||||
#define TEMPERATURE_CALIB_ROWS 0,
|
|
||||||
#else
|
|
||||||
#define TEMPERATURE_CALIB_ROWS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CROSSFIRE) && SPORT_MAX_BAUDRATE < 400000
|
#if defined(CROSSFIRE) && SPORT_MAX_BAUDRATE < 400000
|
||||||
#define MAX_BAUD_ROWS 0,
|
#define MAX_BAUD_ROWS 0,
|
||||||
#else
|
#else
|
||||||
|
@ -215,8 +206,6 @@ void menuRadioHardware(event_t event)
|
||||||
|
|
||||||
TX_CAPACITY_MEASUREMENT_ROWS
|
TX_CAPACITY_MEASUREMENT_ROWS
|
||||||
|
|
||||||
TEMPERATURE_CALIB_ROWS
|
|
||||||
|
|
||||||
MAX_BAUD_ROWS
|
MAX_BAUD_ROWS
|
||||||
|
|
||||||
BLUETOOTH_ROWS
|
BLUETOOTH_ROWS
|
||||||
|
@ -348,16 +337,6 @@ void menuRadioHardware(event_t event)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBSKY9X)
|
|
||||||
case ITEM_RADIO_HARDWARE_TEMPERATURE_CALIB:
|
|
||||||
lcdDrawTextAlignedLeft(y, STR_TEMP_CALIB);
|
|
||||||
drawValueWithUnit(HW_SETTINGS_COLUMN2, y, getTemperature(), UNIT_TEMPERATURE, attr) ;
|
|
||||||
if (attr) {
|
|
||||||
CHECK_INCDEC_GENVAR(event, g_eeGeneral.temperatureCalib, -100, 100);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CROSSFIRE) && SPORT_MAX_BAUDRATE < 400000
|
#if defined(CROSSFIRE) && SPORT_MAX_BAUDRATE < 400000
|
||||||
case ITEM_RADIO_HARDWARE_SERIAL_BAUDRATE:
|
case ITEM_RADIO_HARDWARE_SERIAL_BAUDRATE:
|
||||||
lcdDrawTextAlignedLeft(y, STR_MAXBAUDRATE);
|
lcdDrawTextAlignedLeft(y, STR_MAXBAUDRATE);
|
||||||
|
|
|
@ -75,7 +75,6 @@ enum MenuRadioSetupItems {
|
||||||
ITEM_SETUP_ALARMS_LABEL,
|
ITEM_SETUP_ALARMS_LABEL,
|
||||||
ITEM_SETUP_BATTERY_WARNING,
|
ITEM_SETUP_BATTERY_WARNING,
|
||||||
CASE_CAPACITY(ITEM_SETUP_CAPACITY_WARNING)
|
CASE_CAPACITY(ITEM_SETUP_CAPACITY_WARNING)
|
||||||
CASE_PCBSKY9X(ITEM_SETUP_TEMPERATURE_WARNING)
|
|
||||||
ITEM_SETUP_INACTIVITY_ALARM,
|
ITEM_SETUP_INACTIVITY_ALARM,
|
||||||
ITEM_SETUP_MEMORY_WARNING,
|
ITEM_SETUP_MEMORY_WARNING,
|
||||||
ITEM_SETUP_ALARM_WARNING,
|
ITEM_SETUP_ALARM_WARNING,
|
||||||
|
@ -153,7 +152,6 @@ void menuRadioSetup(event_t event)
|
||||||
CASE_GYRO(0)
|
CASE_GYRO(0)
|
||||||
CASE_GYRO(0)
|
CASE_GYRO(0)
|
||||||
0, LABEL(ALARMS), 0, CASE_CAPACITY(0)
|
0, LABEL(ALARMS), 0, CASE_CAPACITY(0)
|
||||||
CASE_PCBSKY9X(0)
|
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
LABEL(BACKLIGHT), 0, 0, 0, CASE_PWM_BACKLIGHT(0)
|
LABEL(BACKLIGHT), 0, 0, 0, CASE_PWM_BACKLIGHT(0)
|
||||||
CASE_PWM_BACKLIGHT(0)
|
CASE_PWM_BACKLIGHT(0)
|
||||||
|
@ -444,14 +442,6 @@ void menuRadioSetup(event_t event)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBSKY9X)
|
|
||||||
case ITEM_SETUP_TEMPERATURE_WARNING:
|
|
||||||
lcdDrawTextAlignedLeft(y, STR_TEMPWARNING);
|
|
||||||
drawValueWithUnit(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.temperatureWarn, UNIT_TEMPERATURE, attr|LEFT) ;
|
|
||||||
if(attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.temperatureWarn, 0, 120); // 0 means no alarm
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case ITEM_SETUP_INACTIVITY_ALARM:
|
case ITEM_SETUP_INACTIVITY_ALARM:
|
||||||
lcdDrawTextAlignedLeft(y, STR_INACTIVITYALARM);
|
lcdDrawTextAlignedLeft(y, STR_INACTIVITYALARM);
|
||||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.inactivityTimer, attr|LEFT);
|
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.inactivityTimer, attr|LEFT);
|
||||||
|
|
|
@ -213,10 +213,7 @@ void displayBattVoltage()
|
||||||
#if defined(PCBSKY9X)
|
#if defined(PCBSKY9X)
|
||||||
void displayVoltageOrAlarm()
|
void displayVoltageOrAlarm()
|
||||||
{
|
{
|
||||||
if (g_eeGeneral.temperatureWarn && getTemperature() >= g_eeGeneral.temperatureWarn) {
|
if (g_eeGeneral.mAhWarn && (g_eeGeneral.mAhUsed + Current_used * (488 + g_eeGeneral.txCurrentCalibration)/8192/36) / 500 >= g_eeGeneral.mAhWarn) {
|
||||||
drawValueWithUnit(6*FW-1, 2*FH, getTemperature(), UNIT_TEMPERATURE, BLINK|INVERS|DBLSIZE|RIGHT);
|
|
||||||
}
|
|
||||||
else if (g_eeGeneral.mAhWarn && (g_eeGeneral.mAhUsed + Current_used * (488 + g_eeGeneral.txCurrentCalibration)/8192/36) / 500 >= g_eeGeneral.mAhWarn) {
|
|
||||||
drawValueWithUnit(7*FW-1, 2*FH, (g_eeGeneral.mAhUsed + Current_used*(488 + g_eeGeneral.txCurrentCalibration)/8192/36)/10, UNIT_MAH, BLINK|INVERS|DBLSIZE|RIGHT);
|
drawValueWithUnit(7*FW-1, 2*FH, (g_eeGeneral.mAhUsed + Current_used*(488 + g_eeGeneral.txCurrentCalibration)/8192/36)/10, UNIT_MAH, BLINK|INVERS|DBLSIZE|RIGHT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -256,16 +256,6 @@ void menuStatisticsDebug(event_t event)
|
||||||
y += FH;
|
y += FH;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBSKY9X)
|
|
||||||
lcdDrawTextAlignedLeft(y, STR_CPU_TEMP);
|
|
||||||
drawValueWithUnit(MENU_DEBUG_COL1_OFS, y, getTemperature(), UNIT_TEMPERATURE, LEFT);
|
|
||||||
lcdDrawChar(MENU_DEBUG_COL2_OFS, y, '>');
|
|
||||||
drawValueWithUnit(MENU_DEBUG_COL2_OFS+FW+1, y, maxTemperature+g_eeGeneral.temperatureCalib, UNIT_TEMPERATURE, LEFT);
|
|
||||||
#else
|
|
||||||
lcdDrawTextAlignedLeft(y, STR_CPU_TEMP);
|
|
||||||
drawValueWithUnit(MENU_DEBUG_COL1_OFS, y, getTemperature(), UNIT_TEMPERATURE, PREC1|LEFT);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
lcdDrawText(LCD_W/2, 7*FH+1, STR_MENUTORESET, CENTERED);
|
lcdDrawText(LCD_W/2, 7*FH+1, STR_MENUTORESET, CENTERED);
|
||||||
lcdInvertLastLine();
|
lcdInvertLastLine();
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,11 +226,6 @@ void menuStatisticsDebug(event_t event)
|
||||||
y += FH;
|
y += FH;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(STM32)
|
|
||||||
lcdDrawTextAlignedLeft(y, STR_CPU_TEMP);
|
|
||||||
drawValueWithUnit(MENU_DEBUG_COL1_OFS, y, getTemperature(), UNIT_TEMPERATURE, PREC1|LEFT);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
lcdDrawText(LCD_W/2, 7*FH+1, STR_MENUTORESET, CENTERED);
|
lcdDrawText(LCD_W/2, 7*FH+1, STR_MENUTORESET, CENTERED);
|
||||||
lcdInvertLastLine();
|
lcdInvertLastLine();
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,12 +160,6 @@ bool menuStatsDebug(event_t event)
|
||||||
y += FH;
|
y += FH;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#if defined(STM32)
|
|
||||||
// lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CPU_TEMP);
|
|
||||||
// drawValueWithUnit(MENU_STATS_COLUMN1, y, getTemperature(), UNIT_TEMPERATURE, PREC1|LEFT);
|
|
||||||
// y += FH;
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
#if defined(DISK_CACHE)
|
#if defined(DISK_CACHE)
|
||||||
lcdDrawText(MENUS_MARGIN_LEFT, y, "SD cache hits");
|
lcdDrawText(MENUS_MARGIN_LEFT, y, "SD cache hits");
|
||||||
lcdDrawNumber(MENU_STATS_COLUMN1, y, diskCache.getHitRate(), PREC1|LEFT, 0, NULL, "%");
|
lcdDrawNumber(MENU_STATS_COLUMN1, y, diskCache.getHitRate(), PREC1|LEFT, 0, NULL, "%");
|
||||||
|
|
|
@ -189,9 +189,6 @@ void checkBatteryAlarms()
|
||||||
// TRACE("checkBatteryAlarms(): battery low");
|
// TRACE("checkBatteryAlarms(): battery low");
|
||||||
}
|
}
|
||||||
#if defined(PCBSKY9X)
|
#if defined(PCBSKY9X)
|
||||||
else if (g_eeGeneral.temperatureWarn && getTemperature() >= g_eeGeneral.temperatureWarn) {
|
|
||||||
AUDIO_TX_TEMP_HIGH();
|
|
||||||
}
|
|
||||||
else if (g_eeGeneral.mAhWarn && (g_eeGeneral.mAhUsed + Current_used * (488 + g_eeGeneral.txCurrentCalibration)/8192/36) / 500 >= g_eeGeneral.mAhWarn) { // TODO move calculation into board file
|
else if (g_eeGeneral.mAhWarn && (g_eeGeneral.mAhUsed + Current_used * (488 + g_eeGeneral.txCurrentCalibration)/8192/36) / 500 >= g_eeGeneral.mAhWarn) { // TODO move calculation into board file
|
||||||
AUDIO_TX_MAH_HIGH();
|
AUDIO_TX_MAH_HIGH();
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,11 +364,6 @@ long OpenTxSim::onTimeout(FXObject*, FXSelector, void*)
|
||||||
Coproc_maxtemp = 28;
|
Coproc_maxtemp = 28;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBSKY9X)
|
|
||||||
temperature = 31;
|
|
||||||
maxTemperature = 42;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
updateKeysAndSwitches();
|
updateKeysAndSwitches();
|
||||||
|
|
||||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||||
|
@ -557,8 +552,6 @@ uint16_t anaIn(uint8_t chan)
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
else if (chan == TX_INTREF)
|
else if (chan == TX_INTREF)
|
||||||
return 826; // 3V VDD
|
return 826; // 3V VDD
|
||||||
else if (chan == TX_TEMPERATURE)
|
|
||||||
return 520;
|
|
||||||
else if (chan == TX_RTC_VOLTAGE)
|
else if (chan == TX_RTC_VOLTAGE)
|
||||||
return 800; // 2.34V
|
return 800; // 2.34V
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -776,7 +776,7 @@ PACK(typedef struct {
|
||||||
|
|
||||||
uint8_t backlightBright;
|
uint8_t backlightBright;
|
||||||
int8_t txCurrentCalibration;
|
int8_t txCurrentCalibration;
|
||||||
int8_t temperatureWarn;
|
int8_t spare;
|
||||||
uint8_t mAhWarn;
|
uint8_t mAhWarn;
|
||||||
uint16_t mAhUsed;
|
uint16_t mAhUsed;
|
||||||
uint32_t globalTimer;
|
uint32_t globalTimer;
|
||||||
|
@ -883,7 +883,6 @@ void convertRadioData_217_to_218(RadioData &settings)
|
||||||
|
|
||||||
#if defined(PCBSKY9X)
|
#if defined(PCBSKY9X)
|
||||||
settings.txCurrentCalibration = settings_v217.txCurrentCalibration;
|
settings.txCurrentCalibration = settings_v217.txCurrentCalibration;
|
||||||
settings.temperatureWarn = settings_v217.temperatureWarn;
|
|
||||||
settings.mAhWarn = settings_v217.mAhWarn;
|
settings.mAhWarn = settings_v217.mAhWarn;
|
||||||
settings.mAhUsed = settings_v217.mAhUsed;
|
settings.mAhUsed = settings_v217.mAhUsed;
|
||||||
settings.temperatureCalib = settings_v217.temperatureCalib;
|
settings.temperatureCalib = settings_v217.temperatureCalib;
|
||||||
|
|
|
@ -26,24 +26,24 @@
|
||||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, -1,1,-1, 1,-1, 1, 1,1};
|
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, -1,1,-1, 1,-1, 1, 1,1};
|
||||||
#elif defined(PCBX9E)
|
#elif defined(PCBX9E)
|
||||||
#if defined(HORUS_STICKS)
|
#if defined(HORUS_STICKS)
|
||||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, -1,-1,-1,1, -1,1,-1,-1, -1, -1,-1,-1};
|
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, -1,-1,-1,1, -1,1,-1,-1, -1,-1,-1};
|
||||||
#else
|
#else
|
||||||
const int8_t adcDirection[NUM_ANALOGS] = {1,1,-1,-1, -1,-1,-1,1, -1,1,-1,-1, -1, -1,-1,-1};
|
const int8_t adcDirection[NUM_ANALOGS] = {1,1,-1,-1, -1,-1,-1,1, -1,1,-1,-1, -1,-1,-1};
|
||||||
#endif
|
#endif
|
||||||
const uint8_t adcMapping[NUM_ANALOGS] = { 0 /*STICK1*/, 1 /*STICK2*/, 2 /*STICK3*/, 3 /*STICK4*/,
|
const uint8_t adcMapping[NUM_ANALOGS] = { 0 /*STICK1*/, 1 /*STICK2*/, 2 /*STICK3*/, 3 /*STICK4*/,
|
||||||
13 /*POT1*/, 4 /*POT2*/, 5 /*POT3*/, 6 /*POT4*/,
|
12 /*POT1*/, 4 /*POT2*/, 5 /*POT3*/, 6 /*POT4*/,
|
||||||
14 /*SLIDER1*/, 15 /*SLIDER2*/, 7 /*SLIDER3*/, 8 /*SLIDER4*/,
|
13 /*SLIDER1*/, 14 /*SLIDER2*/, 7 /*SLIDER3*/, 8 /*SLIDER4*/,
|
||||||
9 /*TX_VOLTAGE*/, 10 /*TX_TEMP*/, 11 /*ADC_INTREF*/, 12 /*TX_VBAT*/ };
|
9 /*TX_VOLTAGE*/, 10 /*ADC_INTREF*/, 11 /*TX_VBAT*/ };
|
||||||
#elif defined(PCBX9DP)
|
#elif defined(PCBX9DP)
|
||||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, 1,1,-1, 1,1, 1, 1,1,1};
|
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, 1,1,-1, 1,1, 1, 1,1};
|
||||||
#elif defined(PCBX7)
|
#elif defined(PCBX7)
|
||||||
const int8_t adcDirection[NUM_ANALOGS] = {-1,1,-1,1, 1,1, 1, 1,1,1};
|
const int8_t adcDirection[NUM_ANALOGS] = {-1,1,-1,1, 1,1, 1, 1,1};
|
||||||
#elif defined(PCBX9LITE)
|
#elif defined(PCBX9LITE)
|
||||||
const int8_t adcDirection[NUM_ANALOGS] = {-1,1,-1,1, 1,1, 1,1,1};
|
const int8_t adcDirection[NUM_ANALOGS] = {-1,1,-1,1, 1,1, 1,1};
|
||||||
#elif defined(PCBXLITE)
|
#elif defined(PCBXLITE)
|
||||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,-1,1, -1,1, 1, 1,1,1};
|
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,-1,1, -1,1, 1, 1,1};
|
||||||
#else
|
#else
|
||||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, 1,1,0, 1,1, 1, 1,1,1};
|
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, 1,1,0, 1,1, 1, 1,1};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if NUM_PWMSTICKS > 0
|
#if NUM_PWMSTICKS > 0
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
#define NUM_ANALOGS_ADC (STICKS_PWM_ENABLED() ? (NUM_ANALOGS - NUM_PWMSTICKS) : NUM_ANALOGS)
|
#define NUM_ANALOGS_ADC (STICKS_PWM_ENABLED() ? (NUM_ANALOGS - NUM_PWMSTICKS) : NUM_ANALOGS)
|
||||||
#elif defined(PCBX9E)
|
#elif defined(PCBX9E)
|
||||||
#define FIRST_ANALOG_ADC 0
|
#define FIRST_ANALOG_ADC 0
|
||||||
#define NUM_ANALOGS_ADC 13
|
#define NUM_ANALOGS_ADC 12
|
||||||
#define NUM_ANALOGS_ADC_EXT (NUM_ANALOGS - NUM_ANALOGS_ADC)
|
#define NUM_ANALOGS_ADC_EXT (NUM_ANALOGS - NUM_ANALOGS_ADC)
|
||||||
#else
|
#else
|
||||||
#define FIRST_ANALOG_ADC 0
|
#define FIRST_ANALOG_ADC 0
|
||||||
|
@ -106,27 +106,25 @@ void adcInit()
|
||||||
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_POT2 << 25);
|
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_POT2 << 25);
|
||||||
}
|
}
|
||||||
#elif defined(PCBX9E)
|
#elif defined(PCBX9E)
|
||||||
ADC_MAIN->SQR1 |= (ADC_Channel_Vbat << 0);
|
ADC_MAIN->SQR2 = (ADC_CHANNEL_POT4 << 0) + (ADC_CHANNEL_SLIDER3 << 5) + (ADC_CHANNEL_SLIDER4 << 10) + (ADC_CHANNEL_BATT << 15) + (ADC_Channel_Vrefint << 20) + (ADC_Channel_Vbat << 25);
|
||||||
ADC_MAIN->SQR2 = (ADC_CHANNEL_POT4 << 0) + (ADC_CHANNEL_SLIDER3 << 5) + (ADC_CHANNEL_SLIDER4 << 10) + (ADC_CHANNEL_BATT << 15) + (ADC_Channel_TempSensor << 20) + (ADC_Channel_Vrefint << 25);
|
|
||||||
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT2 << 20) + (ADC_CHANNEL_POT3 << 25);
|
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT2 << 20) + (ADC_CHANNEL_POT3 << 25);
|
||||||
#elif defined(PCBXLITE)
|
#elif defined(PCBXLITE)
|
||||||
if (STICKS_PWM_ENABLED()) {
|
if (STICKS_PWM_ENABLED()) {
|
||||||
ADC_MAIN->SQR2 = 0;
|
ADC_MAIN->SQR2 = 0;
|
||||||
ADC_MAIN->SQR3 = (ADC_CHANNEL_POT1 << 0) + (ADC_CHANNEL_POT2 << 5) + (ADC_CHANNEL_BATT << 10) + (ADC_Channel_TempSensor << 15) + (ADC_Channel_Vrefint << 20) + (ADC_Channel_Vbat << 25);
|
ADC_MAIN->SQR3 = (ADC_CHANNEL_POT1 << 0) + (ADC_CHANNEL_POT2 << 5) + (ADC_CHANNEL_BATT << 10) + (ADC_Channel_Vrefint << 15) + (ADC_Channel_Vbat << 20);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ADC_MAIN->SQR2 = (ADC_CHANNEL_BATT << 0) + (ADC_Channel_TempSensor << 5) + (ADC_Channel_Vrefint << 10) + (ADC_Channel_Vbat << 15);
|
ADC_MAIN->SQR2 = (ADC_CHANNEL_BATT << 0) + (ADC_Channel_Vrefint << 5) + (ADC_Channel_Vbat << 10);
|
||||||
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_POT2 << 25);
|
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_POT2 << 25);
|
||||||
}
|
}
|
||||||
#elif defined(PCBX7)
|
#elif defined(PCBX7)
|
||||||
ADC_MAIN->SQR2 = (ADC_CHANNEL_BATT << 0) + (ADC_Channel_TempSensor << 5) + (ADC_Channel_Vrefint << 10) + (ADC_Channel_Vbat << 15);
|
ADC_MAIN->SQR2 = (ADC_CHANNEL_BATT << 0) + (ADC_Channel_Vrefint << 5) + (ADC_Channel_Vbat << 10);
|
||||||
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_POT2 << 25);
|
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_POT2 << 25);
|
||||||
#elif defined(PCBX9LITE)
|
#elif defined(PCBX9LITE)
|
||||||
ADC_MAIN->SQR2 = (ADC_Channel_TempSensor << 0) + (ADC_Channel_Vrefint << 5) + (ADC_Channel_Vbat << 10);
|
ADC_MAIN->SQR2 = (ADC_Channel_Vrefint << 0) + (ADC_Channel_Vbat << 5);
|
||||||
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_BATT << 25);
|
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_BATT << 25);
|
||||||
#elif defined(PCBX9D) || defined(PCBX9DP)
|
#elif defined(PCBX9D) || defined(PCBX9DP)
|
||||||
ADC_MAIN->SQR1 |= (ADC_Channel_Vbat<<0);
|
ADC_MAIN->SQR2 = (ADC_CHANNEL_POT3 << 0) + (ADC_CHANNEL_SLIDER1 << 5) + (ADC_CHANNEL_SLIDER2 << 10) + (ADC_CHANNEL_BATT << 15) + (ADC_Channel_Vrefint << 20) + (ADC_Channel_Vbat << 25);
|
||||||
ADC_MAIN->SQR2 = (ADC_CHANNEL_POT3 << 0) + (ADC_CHANNEL_SLIDER1 << 5) + (ADC_CHANNEL_SLIDER2 << 10) + (ADC_CHANNEL_BATT << 15) + (ADC_Channel_TempSensor << 20) + (ADC_Channel_Vrefint << 25);
|
|
||||||
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_POT2 << 25);
|
ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_POT2 << 25);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -157,8 +155,8 @@ void adcInit()
|
||||||
ADC_EXT->SQR1 = (NUM_ANALOGS_ADC_EXT - 1) << 20;
|
ADC_EXT->SQR1 = (NUM_ANALOGS_ADC_EXT - 1) << 20;
|
||||||
ADC_EXT->SQR2 = 0;
|
ADC_EXT->SQR2 = 0;
|
||||||
ADC_EXT->SQR3 = (ADC_CHANNEL_POT1 << 0) + (ADC_CHANNEL_SLIDER1 << 5) + (ADC_CHANNEL_SLIDER2 << 10); // conversions 1 to 3
|
ADC_EXT->SQR3 = (ADC_CHANNEL_POT1 << 0) + (ADC_CHANNEL_SLIDER1 << 5) + (ADC_CHANNEL_SLIDER2 << 10); // conversions 1 to 3
|
||||||
ADC_EXT->SMPR1 = 0;
|
ADC_EXT->SMPR1 = (ADC_SAMPTIME << 0) + (ADC_SAMPTIME << 3) + (ADC_SAMPTIME << 6) + (ADC_SAMPTIME << 9) + (ADC_SAMPTIME << 12) + (ADC_SAMPTIME << 15) + (ADC_SAMPTIME << 18) + (ADC_SAMPTIME << 21) + (ADC_SAMPTIME << 24);
|
||||||
ADC_EXT->SMPR2 = (ADC_EXT_SAMPTIME << (3*ADC_CHANNEL_POT1)) + (ADC_EXT_SAMPTIME << (3*ADC_CHANNEL_SLIDER1)) + (ADC_EXT_SAMPTIME << (3*ADC_CHANNEL_SLIDER2));
|
ADC_EXT->SMPR2 = (ADC_SAMPTIME << 0) + (ADC_SAMPTIME << 3) + (ADC_SAMPTIME << 6) + (ADC_SAMPTIME << 9) + (ADC_SAMPTIME << 12) + (ADC_SAMPTIME << 15) + (ADC_SAMPTIME << 18) + (ADC_SAMPTIME << 21) + (ADC_SAMPTIME << 24) + (ADC_SAMPTIME << 27);
|
||||||
|
|
||||||
ADC_EXT_DMA_Stream->CR = DMA_SxCR_PL | DMA_SxCR_CHSEL_1 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC;
|
ADC_EXT_DMA_Stream->CR = DMA_SxCR_PL | DMA_SxCR_CHSEL_1 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC;
|
||||||
ADC_EXT_DMA_Stream->PAR = CONVERT_PTR_UINT(&ADC_EXT->DR);
|
ADC_EXT_DMA_Stream->PAR = CONVERT_PTR_UINT(&ADC_EXT->DR);
|
||||||
|
@ -189,7 +187,7 @@ void adcSingleRead()
|
||||||
|
|
||||||
#if defined(PCBX9E)
|
#if defined(PCBX9E)
|
||||||
ADC_EXT_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
ADC_EXT_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||||
ADC_EXT->SR &= ~(uint32_t) ( ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR );
|
ADC_EXT->SR &= ~(uint32_t)(ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR);
|
||||||
ADC_EXT_SET_DMA_FLAGS();
|
ADC_EXT_SET_DMA_FLAGS();
|
||||||
ADC_EXT_DMA_Stream->CR |= DMA_SxCR_EN; // Enable DMA
|
ADC_EXT_DMA_Stream->CR |= DMA_SxCR_EN; // Enable DMA
|
||||||
ADC_EXT->CR2 |= (uint32_t)ADC_CR2_SWSTART;
|
ADC_EXT->CR2 |= (uint32_t)ADC_CR2_SWSTART;
|
||||||
|
@ -253,18 +251,6 @@ uint16_t getRTCBatteryVoltage()
|
||||||
return rtcBatteryVoltage * 330 / 2048;
|
return rtcBatteryVoltage * 330 / 2048;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// Returns temperature in 10*C
|
|
||||||
uint16_t getTemperature()
|
|
||||||
{
|
|
||||||
// VDD IN 1/10 mV
|
|
||||||
int vdd = 2048 * 12100 / anaIn(TX_INTREF);
|
|
||||||
int vtemp = vdd * anaIn(TX_TEMPERATURE) / 2048;
|
|
||||||
|
|
||||||
// From Doc ID 15818 Rev 7 for STM32F2:
|
|
||||||
// 25 C = 0.76V, 2.5 mV/C
|
|
||||||
return (vtemp - 7600) * 10 / 25 + 250;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getRTCBatteryVoltage()
|
uint16_t getRTCBatteryVoltage()
|
||||||
{
|
{
|
||||||
return (uint16_t )(12100 * 2048 / anaIn(TX_INTREF) * anaIn(TX_RTC_VOLTAGE) / 204800 * 2);
|
return (uint16_t )(12100 * 2048 / anaIn(TX_INTREF) * anaIn(TX_RTC_VOLTAGE) / 204800 * 2);
|
||||||
|
|
|
@ -103,7 +103,6 @@ void adcInit();
|
||||||
void adcRead();
|
void adcRead();
|
||||||
uint16_t getAnalogValue(uint8_t index);
|
uint16_t getAnalogValue(uint8_t index);
|
||||||
uint16_t getBatteryVoltage(); // returns current battery voltage in 10mV steps
|
uint16_t getBatteryVoltage(); // returns current battery voltage in 10mV steps
|
||||||
uint16_t getTemperature();
|
|
||||||
uint16_t getRTCBatteryVoltage();
|
uint16_t getRTCBatteryVoltage();
|
||||||
|
|
||||||
// STM32 uses a 25K+25K voltage divider bridge to measure the battery voltage
|
// STM32 uses a 25K+25K voltage divider bridge to measure the battery voltage
|
||||||
|
|
|
@ -112,9 +112,8 @@ void OpenTxSimulator::init()
|
||||||
memset(g_anas, 0, sizeof(g_anas));
|
memset(g_anas, 0, sizeof(g_anas));
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
g_anas[TX_INTREF] = 826; // 3V VDD
|
g_anas[TX_INTREF] = 826; // 3V VDD
|
||||||
g_anas[TX_RTC_VOLTAGE] = 800; // 2,34V
|
g_anas[TX_RTC_VOLTAGE] = 800; // 2,34V
|
||||||
g_anas[TX_TEMPERATURE] = 520;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
simuInit();
|
simuInit();
|
||||||
|
|
|
@ -90,11 +90,6 @@ void adcSingleRead()
|
||||||
adcValues[7] = ADC->ADC_CDR14;
|
adcValues[7] = ADC->ADC_CDR14;
|
||||||
adcValues[8] = ADC->ADC_CDR8 ;
|
adcValues[8] = ADC->ADC_CDR8 ;
|
||||||
|
|
||||||
temperature = (((int32_t)temperature * 7) + ((((int32_t)ADC->ADC_CDR15 - 838) * 621) >> 11)) >> 3; // Filter it
|
|
||||||
if (get_tmr10ms() >= 100 && temperature > maxTemperature) {
|
|
||||||
maxTemperature = temperature;
|
|
||||||
}
|
|
||||||
|
|
||||||
// adc direction correct
|
// adc direction correct
|
||||||
#if defined(FRSKY_STICKS)
|
#if defined(FRSKY_STICKS)
|
||||||
uint32_t i ;
|
uint32_t i ;
|
||||||
|
|
|
@ -438,11 +438,6 @@ uint16_t getCurrent()
|
||||||
return (current_scale * Current) / 8192;
|
return (current_scale * Current) / 8192;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getTemperature()
|
|
||||||
{
|
|
||||||
return temperature + g_eeGeneral.temperatureCalib;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define STICK_LV_GAIN 0x01
|
#define STICK_LV_GAIN 0x01
|
||||||
#define STICK_LH_GAIN 0x02
|
#define STICK_LH_GAIN 0x02
|
||||||
#define STICK_RV_GAIN 0x04
|
#define STICK_RV_GAIN 0x04
|
||||||
|
|
|
@ -199,10 +199,6 @@ void usbMassStorage();
|
||||||
void configure_pins( uint32_t pins, uint16_t config );
|
void configure_pins( uint32_t pins, uint16_t config );
|
||||||
uint16_t getCurrent();
|
uint16_t getCurrent();
|
||||||
|
|
||||||
extern uint8_t temperature ; // Raw temp reading
|
|
||||||
extern uint8_t maxTemperature ; // Raw temp reading
|
|
||||||
uint8_t getTemperature();
|
|
||||||
|
|
||||||
extern uint16_t Current_analogue;
|
extern uint16_t Current_analogue;
|
||||||
extern uint16_t Current_max;
|
extern uint16_t Current_max;
|
||||||
extern uint32_t Current_accumulator;
|
extern uint32_t Current_accumulator;
|
||||||
|
|
|
@ -453,7 +453,6 @@ enum Analogs {
|
||||||
SLIDER2,
|
SLIDER2,
|
||||||
#endif
|
#endif
|
||||||
TX_VOLTAGE,
|
TX_VOLTAGE,
|
||||||
TX_TEMPERATURE,
|
|
||||||
TX_INTREF,
|
TX_INTREF,
|
||||||
TX_RTC_VOLTAGE,
|
TX_RTC_VOLTAGE,
|
||||||
NUM_ANALOGS
|
NUM_ANALOGS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue