1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-16 21:05:26 +03:00

No more voltage alarms on simu

This commit is contained in:
Bertrand Songis 2019-08-12 14:23:03 +02:00
parent bd6ba97707
commit 185532f05e
15 changed files with 147 additions and 128 deletions

View file

@ -198,7 +198,7 @@ void displayBattVoltage()
putsVBat(VBATT_X-8, VBATT_Y+1, RIGHT); putsVBat(VBATT_X-8, VBATT_Y+1, RIGHT);
lcdDrawSolidFilledRect(VBATT_X-25, VBATT_Y+9, 21, 5); lcdDrawSolidFilledRect(VBATT_X-25, VBATT_Y+9, 21, 5);
lcdDrawSolidVerticalLine(VBATT_X-4, VBATT_Y+10, 3); lcdDrawSolidVerticalLine(VBATT_X-4, VBATT_Y+10, 3);
uint8_t count = GET_TXBATT_BARS(); uint8_t count = GET_TXBATT_BARS(20);
for (uint8_t i=0; i<count; i+=2) for (uint8_t i=0; i<count; i+=2)
lcdDrawSolidVerticalLine(VBATT_X-24+i, VBATT_Y+10, 3); lcdDrawSolidVerticalLine(VBATT_X-24+i, VBATT_Y+10, 3);
if (!IS_TXBATT_WARNING() || BLINK_ON_PHASE) if (!IS_TXBATT_WARNING() || BLINK_ON_PHASE)

View file

@ -157,7 +157,7 @@ void menuStatisticsDebug(event_t event)
} }
#if defined(PCBSKY9X) #if defined(PCBSKY9X)
if ((ResetReason&RSTC_SR_RSTTYP) == (2<<8)) { if (IS_RESET_REASON_WATCHDOG()) {
lcdDrawText(LCD_W-8*FW, 0, "WATCHDOG"); lcdDrawText(LCD_W-8*FW, 0, "WATCHDOG");
} }
else if (unexpectedShutdown) { else if (unexpectedShutdown) {

View file

@ -294,7 +294,7 @@ void displayTopBar()
lcdDrawFilledRect(BAR_X, BAR_Y, BAR_W, BAR_H, SOLID, FILL_WHITE|GREY(12)|ROUND); lcdDrawFilledRect(BAR_X, BAR_Y, BAR_W, BAR_H, SOLID, FILL_WHITE|GREY(12)|ROUND);
/* The inside of the Batt gauge */ /* The inside of the Batt gauge */
displayTopBarGauge(batt_icon_x+FW, GET_TXBATT_BARS(), IS_TXBATT_WARNING()); displayTopBarGauge(batt_icon_x+FW, GET_TXBATT_BARS(10), IS_TXBATT_WARNING());
/* The inside of the RSSI gauge */ /* The inside of the RSSI gauge */
if (TELEMETRY_RSSI() > 0) { if (TELEMETRY_RSSI() > 0) {

View file

@ -82,7 +82,7 @@ void drawTopBar()
lcdDrawBitmapPattern(LCD_W-130, 4, LBM_TOPMENU_VOLUME_4, MENU_TITLE_COLOR); lcdDrawBitmapPattern(LCD_W-130, 4, LBM_TOPMENU_VOLUME_4, MENU_TITLE_COLOR);
/* Tx battery */ /* Tx battery */
uint8_t bars = limit<int8_t>(0, 6 * (g_vbat100mV - g_eeGeneral.vBatMin - 90) / (30 + g_eeGeneral.vBatMax - g_eeGeneral.vBatMin), 5); uint8_t bars = GET_TXBATT_BARS(5);
lcdDrawBitmapPattern(LCD_W-130, 24, LBM_TOPMENU_TXBATT, MENU_TITLE_COLOR); lcdDrawBitmapPattern(LCD_W-130, 24, LBM_TOPMENU_TXBATT, MENU_TITLE_COLOR);
for (unsigned int i = 0; i < 5; i++) { for (unsigned int i = 0; i < 5; i++) {
lcdDrawSolidFilledRect(LCD_W-122+4*i, 30, 2, 8, i >= bars ? MENU_TITLE_DISABLE_COLOR : MENU_TITLE_COLOR); lcdDrawSolidFilledRect(LCD_W-122+4*i, 30, 2, 8, i >= bars ? MENU_TITLE_DISABLE_COLOR : MENU_TITLE_COLOR);

View file

@ -541,7 +541,7 @@ void perMain()
setTopSecondTimer(g_eeGeneral.globalTimer + sessionTimer); setTopSecondTimer(g_eeGeneral.globalTimer + sessionTimer);
setTopRssi(TELEMETRY_RSSI()); setTopRssi(TELEMETRY_RSSI());
setTopBatteryValue(g_vbat100mV); setTopBatteryValue(g_vbat100mV);
setTopBatteryState(GET_TXBATT_BARS(), IS_TXBATT_WARNING()); setTopBatteryState(GET_TXBATT_BARS(10), IS_TXBATT_WARNING());
toplcdRefreshEnd(); toplcdRefreshEnd();
#endif #endif

View file

@ -723,15 +723,6 @@ extern const char vers_stamp[];
*/ */
const char * getOtherVersion(char * buffer); const char * getOtherVersion(char * buffer);
extern uint8_t g_vbat100mV;
#if LCD_W > 128
#define GET_TXBATT_BARS() (limit<int8_t>(0, div_and_round(10 * (g_vbat100mV - g_eeGeneral.vBatMin - 90), 30 + g_eeGeneral.vBatMax - g_eeGeneral.vBatMin), 10))
#else
#define GET_TXBATT_BARS() (limit<int8_t>(2, 20 * (g_vbat100mV - g_eeGeneral.vBatMin - 90) / (30 + g_eeGeneral.vBatMax - g_eeGeneral.vBatMin), 20))
#endif
#define IS_TXBATT_WARNING() (g_vbat100mV <= g_eeGeneral.vBatWarn)
#define g_blinkTmr10ms (*(uint8_t*)&g_tmr10ms) #define g_blinkTmr10ms (*(uint8_t*)&g_tmr10ms)
extern uint8_t g_beepCnt; extern uint8_t g_beepCnt;
@ -1260,6 +1251,18 @@ inline int div_and_round(int num, int den)
return num / den; return num / den;
} }
extern uint8_t g_vbat100mV;
inline uint8_t GET_TXBATT_BARS(uint8_t barsMax)
{
return limit<int8_t>(0, div_and_round(barsMax * (g_vbat100mV - g_eeGeneral.vBatMin - 90), 30 + g_eeGeneral.vBatMax - g_eeGeneral.vBatMin), barsMax);
}
inline bool IS_TXBATT_WARNING()
{
return g_vbat100mV <= g_eeGeneral.vBatWarn;
}
#if defined(TELEMETRY_FRSKY) #if defined(TELEMETRY_FRSKY)
enum TelemetryViews { enum TelemetryViews {
TELEMETRY_CUSTOM_SCREEN_1, TELEMETRY_CUSTOM_SCREEN_1,

View file

@ -528,27 +528,6 @@ uint16_t anaIn(uint8_t chan)
return opentxSim->sliders[chan]->getValue(); return opentxSim->sliders[chan]->getValue();
else if (chan<NUM_STICKS+NUM_POTS+NUM_SLIDERS) else if (chan<NUM_STICKS+NUM_POTS+NUM_SLIDERS)
return opentxSim->knobs[chan-NUM_STICKS]->getValue(); return opentxSim->knobs[chan-NUM_STICKS]->getValue();
#if defined(PCBHORUS)
else if (chan == TX_VOLTAGE)
return 1737; //~10.6V
#elif defined(PCBX9E)
else if (chan == TX_VOLTAGE)
return 1420; //~10.6V
#elif defined(PCBXLITE)
else if (chan == TX_VOLTAGE)
return 1100;
#elif defined(PCBTARANIS)
else if (chan == TX_VOLTAGE)
return 1000; //~7.4V
#elif defined(PCBSKY9X)
else if (chan == TX_VOLTAGE)
return 5.1*1500/11.3;
else if (chan == TX_CURRENT)
return 100;
#else
else if (chan == TX_VOLTAGE)
return 1500;
#endif
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
else if (chan == TX_RTC_VOLTAGE) else if (chan == TX_RTC_VOLTAGE)
return 800; // 2.34V return 800; // 2.34V

View file

@ -126,7 +126,6 @@ set(GVAR_SCREEN model_gvars.cpp)
set(TARGET_SRC set(TARGET_SRC
${TARGET_SRC} ${TARGET_SRC}
board.cpp
led_driver.cpp led_driver.cpp
extmodule_driver.cpp extmodule_driver.cpp
trainer_driver.cpp trainer_driver.cpp
@ -140,6 +139,7 @@ set(TARGET_SRC
set(FIRMWARE_TARGET_SRC set(FIRMWARE_TARGET_SRC
${FIRMWARE_TARGET_SRC} ${FIRMWARE_TARGET_SRC}
${LCD_DRIVER} ${LCD_DRIVER}
board.cpp
backlight_driver.cpp backlight_driver.cpp
pwr_driver.cpp pwr_driver.cpp
sdram_driver.c sdram_driver.c

View file

@ -20,12 +20,12 @@
#include "opentx.h" #include "opentx.h"
#if defined(__cplusplus) && !defined(SIMU) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
#include "usb_dcd_int.h" #include "usb_dcd_int.h"
#include "usb_bsp.h" #include "usb_bsp.h"
#if defined(__cplusplus) && !defined(SIMU) #if defined(__cplusplus)
} }
#endif #endif
@ -78,7 +78,6 @@ void boardInit()
initialise_monitor_handles(); initialise_monitor_handles();
#endif #endif
#if !defined(SIMU)
RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph |
PCBREV_RCC_AHB1Periph | PCBREV_RCC_AHB1Periph |
LED_RCC_AHB1Periph | LED_RCC_AHB1Periph |
@ -182,7 +181,6 @@ void boardInit()
#endif #endif
ledBlue(); ledBlue();
#endif
} }
void boardOff() void boardOff()

View file

@ -356,7 +356,7 @@ void * audioThread(void *)
*/ */
if ( SDL_OpenAudio(&wanted, &have) < 0 ) { if ( SDL_OpenAudio(&wanted, &have) < 0 ) {
fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
return 0; return nullptr;
} }
SDL_PauseAudio(0); SDL_PauseAudio(0);
@ -365,7 +365,7 @@ void * audioThread(void *)
sleep(1); sleep(1);
} }
SDL_CloseAudio(); SDL_CloseAudio();
return 0; return nullptr;
} }
void StartAudioThread(int volumeGain) void StartAudioThread(int volumeGain)
@ -428,6 +428,18 @@ void telemetryPortInit()
{ {
} }
void sportUpdatePowerOn()
{
}
void sportUpdatePowerOff()
{
}
void boardInit()
{
}
display_t simuLcdBackupBuf[DISPLAY_BUFFER_SIZE]; display_t simuLcdBackupBuf[DISPLAY_BUFFER_SIZE];
void lcdStoreBackupBuffer() void lcdStoreBackupBuffer()
{ {
@ -648,21 +660,62 @@ void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef * RTC_DateStruct)
RTC_DateStruct->RTC_Date = timeinfo->tm_mday; RTC_DateStruct->RTC_Date = timeinfo->tm_mday;
} }
void unlockFlash()
{
}
void unlockFlash() { } void lockFlash()
void lockFlash() { } {
void flashWrite(uint32_t *address, uint32_t *buffer) { simuSleep(100); } }
uint32_t isBootloaderStart(const uint8_t * block) { return 1; }
void flashWrite(uint32_t *address, uint32_t *buffer)
{
simuSleep(100);
}
uint32_t isBootloaderStart(const uint8_t * block)
{
return 1;
}
#endif // defined(STM32) #endif // defined(STM32)
#if defined(PCBHORUS)
void LCD_ControlLight(uint16_t dutyCycle) { }
#endif
#if defined(PCBXLITES) #if defined(PCBXLITES)
bool isJackPlugged() { return false; } bool isJackPlugged()
{
return false;
}
#endif #endif
void serialPrintf(const char * format, ...) { } void serialPrintf(const char * format, ...) { }
void serialCrlf() { } void serialCrlf() { }
void serialPutc(char c) { } void serialPutc(char c) { }
uint16_t getBatteryVoltage()
{
return (BATTERY_MAX + BATTERY_WARN) * 5;
}
void boardOff()
{
}
#if defined(PCBHORUS) || defined(PCBTARANIS)
HardwareOptions hardwareOptions;
#endif
uint32_t Master_frequency = 0;
uint32_t Current_used = 0;
uint16_t Current_max = 0;
void setSticksGain(uint8_t)
{
}
uint16_t getCurrent()
{
return 10;
}
void calcConsumption()
{
}

View file

@ -82,6 +82,7 @@ endif()
set(FIRMWARE_TARGET_SRC set(FIRMWARE_TARGET_SRC
${FIRMWARE_TARGET_SRC} ${FIRMWARE_TARGET_SRC}
../common/arm/loadboot.cpp ../common/arm/loadboot.cpp
board.cpp
core_cm3.c core_cm3.c
board_lowlevel.c board_lowlevel.c
crt.c crt.c
@ -111,7 +112,6 @@ set(FIRMWARE_TARGET_SRC
set(TARGET_SRC set(TARGET_SRC
${TARGET_SRC} ${TARGET_SRC}
board.cpp
telemetry_driver.cpp telemetry_driver.cpp
adc_driver.cpp adc_driver.cpp
pulses_driver.cpp pulses_driver.cpp

View file

@ -26,7 +26,6 @@
uint16_t ResetReason; uint16_t ResetReason;
uint32_t Master_frequency ; uint32_t Master_frequency ;
volatile uint32_t Tenms ;
volatile uint8_t lcdLock; volatile uint8_t lcdLock;
volatile uint32_t lcdInputs; volatile uint32_t lcdInputs;
@ -58,7 +57,6 @@ inline void setup_switches()
configure_pins( 0x91114900, PIN_ENABLE | PIN_INPUT | PIN_PORTC | PIN_PULLUP ) ; configure_pins( 0x91114900, PIN_ENABLE | PIN_INPUT | PIN_PORTC | PIN_PULLUP ) ;
} }
#if !defined(SIMU)
inline void UART3_Configure(uint32_t baudrate, uint32_t masterClock) inline void UART3_Configure(uint32_t baudrate, uint32_t masterClock)
{ {
Uart *pUart = BT_USART; Uart *pUart = BT_USART;
@ -250,67 +248,54 @@ void configure_pins( uint32_t pins, uint16_t config )
Pio * pioptr; Pio * pioptr;
pioptr = PIOA + ((config & PIN_PORT_MASK) >> 6); pioptr = PIOA + ((config & PIN_PORT_MASK) >> 6);
if ( config & PIN_PULLUP ) if (config & PIN_PULLUP) {
{
pioptr->PIO_PPDDR = pins; pioptr->PIO_PPDDR = pins;
pioptr->PIO_PUER = pins; pioptr->PIO_PUER = pins;
} }
else else {
{
pioptr->PIO_PUDR = pins; pioptr->PIO_PUDR = pins;
} }
if ( config & PIN_PULLDOWN ) if (config & PIN_PULLDOWN) {
{
pioptr->PIO_PUDR = pins; pioptr->PIO_PUDR = pins;
pioptr->PIO_PPDER = pins; pioptr->PIO_PPDER = pins;
} }
else else {
{
pioptr->PIO_PPDDR = pins; pioptr->PIO_PPDDR = pins;
} }
if ( config & PIN_HIGH ) if (config & PIN_HIGH) {
{
pioptr->PIO_SODR = pins; pioptr->PIO_SODR = pins;
} }
else else {
{
pioptr->PIO_CODR = pins; pioptr->PIO_CODR = pins;
} }
if ( config & PIN_INPUT ) if (config & PIN_INPUT) {
{
pioptr->PIO_ODR = pins; pioptr->PIO_ODR = pins;
} }
else else {
{
pioptr->PIO_OER = pins; pioptr->PIO_OER = pins;
} }
if ( config & PIN_PERI_MASK_L ) if (config & PIN_PERI_MASK_L) {
{
pioptr->PIO_ABCDSR[0] |= pins; pioptr->PIO_ABCDSR[0] |= pins;
} }
else else {
{
pioptr->PIO_ABCDSR[0] &= ~pins; pioptr->PIO_ABCDSR[0] &= ~pins;
} }
if ( config & PIN_PERI_MASK_H )
{ if (config & PIN_PERI_MASK_H) {
pioptr->PIO_ABCDSR[1] |= pins; pioptr->PIO_ABCDSR[1] |= pins;
} }
else else {
{
pioptr->PIO_ABCDSR[1] &= ~pins; pioptr->PIO_ABCDSR[1] &= ~pins;
} }
if ( config & PIN_ENABLE ) if (config & PIN_ENABLE) {
{
pioptr->PIO_PER = pins; pioptr->PIO_PER = pins;
} }
else else {
{
pioptr->PIO_PDR = pins; pioptr->PIO_PDR = pins;
} }
} }
@ -345,7 +330,6 @@ void i2cInit()
TWI0->TWI_MMR = 0x002F0000 ; // Device 5E (>>1) and master is writing TWI0->TWI_MMR = 0x002F0000 ; // Device 5E (>>1) and master is writing
NVIC_EnableIRQ(TWI0_IRQn) ; NVIC_EnableIRQ(TWI0_IRQn) ;
} }
#endif
void boardInit() void boardInit()
{ {
@ -502,3 +486,8 @@ uint16_t getBatteryVoltage()
instant_vbat /= 5530; instant_vbat /= 5530;
return (uint16_t)instant_vbat; return (uint16_t)instant_vbat;
} }
void boardOff()
{
pwrOff();
}

View file

@ -35,8 +35,8 @@ extern uint16_t ResetReason;
#define FIRMWARE_ADDRESS 0x00400000 #define FIRMWARE_ADDRESS 0x00400000
// Board driver // Board driver
void boardInit(void); void boardInit();
#define boardOff() pwrOff() void boardOff();
// Rotary Encoder driver // Rotary Encoder driver
void rotaryEncoderInit(); void rotaryEncoderInit();
@ -252,9 +252,11 @@ extern "C" {
#if defined(WATCHDOG_DISABLED) || defined(SIMU) #if defined(WATCHDOG_DISABLED) || defined(SIMU)
#define wdt_enable(x) #define wdt_enable(x)
#define wdt_reset() #define wdt_reset()
#define IS_RESET_REASON_WATCHDOG() false
#else #else
#define wdt_enable(x) WDT->WDT_MR = 0x3FFF207F #define wdt_enable(x) WDT->WDT_MR = 0x3FFF207F
#define wdt_reset() WDT->WDT_CR = 0xA5000001 #define wdt_reset() WDT->WDT_CR = 0xA5000001
#define IS_RESET_REASON_WATCHDOG() ((ResetReason & RSTC_SR_RSTTYP) == (2 << 8))
#endif #endif
// Backlight driver // Backlight driver

View file

@ -271,7 +271,6 @@ set(SRC
set(TARGET_SRC set(TARGET_SRC
${TARGET_SRC} ${TARGET_SRC}
board.cpp
${LED_DRIVER} ${LED_DRIVER}
backlight_driver.cpp backlight_driver.cpp
extmodule_driver.cpp extmodule_driver.cpp
@ -292,6 +291,7 @@ endif()
set(FIRMWARE_TARGET_SRC set(FIRMWARE_TARGET_SRC
${FIRMWARE_TARGET_SRC} ${FIRMWARE_TARGET_SRC}
${LCD_DRIVER} ${LCD_DRIVER}
board.cpp
i2c_driver.cpp i2c_driver.cpp
pwr_driver.cpp pwr_driver.cpp
../common/arm/loadboot.cpp ../common/arm/loadboot.cpp

View file

@ -20,12 +20,12 @@
#include "opentx.h" #include "opentx.h"
#if defined(__cplusplus) && !defined(SIMU) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
#include "usb_dcd_int.h" #include "usb_dcd_int.h"
#include "usb_bsp.h" #include "usb_bsp.h"
#if defined(__cplusplus) && !defined(SIMU) #if defined(__cplusplus)
} }
#endif #endif
@ -81,7 +81,6 @@ void sportUpdatePowerOff()
void boardInit() void boardInit()
{ {
#if !defined(SIMU)
RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph |
PCBREV_RCC_AHB1Periph | PCBREV_RCC_AHB1Periph |
KEYS_RCC_AHB1Periph | KEYS_RCC_AHB1Periph |
@ -267,8 +266,6 @@ void boardInit()
#if defined(GYRO) #if defined(GYRO)
gyroInit(); gyroInit();
#endif #endif
#endif // !defined(SIMU)
} }
void boardOff() void boardOff()
@ -298,9 +295,7 @@ void boardOff()
while (1) { while (1) {
wdt_reset(); wdt_reset();
#if defined(SIMU) #if defined(PWR_BUTTON_PRESS)
return;
#elif defined(PWR_BUTTON_PRESS)
// X9E/X7 needs watchdog reset because CPU is still running while // X9E/X7 needs watchdog reset because CPU is still running while
// the power key is held pressed by the user. // the power key is held pressed by the user.
// The power key should be released by now, but we must make sure // The power key should be released by now, but we must make sure