Minor changes to avoid infinite loops inside companion9x
This commit is contained in:
+15
-2
@@ -480,7 +480,11 @@ inline uint8_t keyDown()
|
||||
|
||||
void clearKeyEvents()
|
||||
{
|
||||
while(keyDown()); // loop until all keys are up
|
||||
#ifdef SIMU
|
||||
while (keyDown() && main_thread_running);
|
||||
#else
|
||||
while (keyDown()); // loop until all keys are up
|
||||
#endif
|
||||
putEvent(0);
|
||||
}
|
||||
|
||||
@@ -512,7 +516,9 @@ void doSplash()
|
||||
uint16_t tgtime = get_tmr10ms() + SPLASH_TIMEOUT; //2sec splash screen
|
||||
while(tgtime != get_tmr10ms())
|
||||
{
|
||||
#ifndef SIMU
|
||||
#ifdef SIMU
|
||||
if (!main_thread_running) return;
|
||||
#else
|
||||
getADC_filt();
|
||||
#endif
|
||||
uint16_t tsum = 0;
|
||||
@@ -606,6 +612,10 @@ void checkSwitches()
|
||||
//loop until all switches are reset
|
||||
while (1)
|
||||
{
|
||||
#ifdef SIMU
|
||||
if (!main_thread_running) return;
|
||||
#endif
|
||||
|
||||
uint8_t i;
|
||||
for(i=SW_BASE; i<SW_Trainer; i++)
|
||||
{
|
||||
@@ -645,6 +655,9 @@ void alert(const prog_char * s, bool defaults)
|
||||
clearKeyEvents();
|
||||
while(1)
|
||||
{
|
||||
#ifdef SIMU
|
||||
if (!main_thread_running) return;
|
||||
#endif
|
||||
if(keyDown()) return; //wait for key release
|
||||
|
||||
if(getSwitch(g_eeGeneral.lightSw,0) || g_eeGeneral.lightAutoOff || defaults)
|
||||
|
||||
+12
-9
@@ -75,18 +75,21 @@ void *eeprom_write_function(void *)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool main_thread_running = true;
|
||||
uint8_t main_thread_running = 0;
|
||||
void *main_thread(void *)
|
||||
{
|
||||
g_menuStack[0] = menuMainView;
|
||||
g_menuStack[1] = menuProcModelSelect;
|
||||
|
||||
eeReadAll(); //load general setup and selected model
|
||||
doSplash();
|
||||
checkLowEEPROM();
|
||||
checkTHR();
|
||||
checkSwitches();
|
||||
checkAlarm();
|
||||
|
||||
if (main_thread_running == 1) {
|
||||
doSplash();
|
||||
checkLowEEPROM();
|
||||
checkTHR();
|
||||
checkSwitches();
|
||||
checkAlarm();
|
||||
}
|
||||
|
||||
while (main_thread_running) {
|
||||
perMain();
|
||||
@@ -96,15 +99,15 @@ void *main_thread(void *)
|
||||
}
|
||||
|
||||
pthread_t main_thread_pid;
|
||||
void StartMainThread()
|
||||
void StartMainThread(bool tests)
|
||||
{
|
||||
main_thread_running = true;
|
||||
main_thread_running = (tests ? 1 : 2);
|
||||
pthread_create(&main_thread_pid, NULL, &main_thread, NULL);
|
||||
}
|
||||
|
||||
void StopMainThread()
|
||||
{
|
||||
main_thread_running = false;
|
||||
main_thread_running = 0;
|
||||
pthread_join(main_thread_pid, NULL);
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -89,6 +89,10 @@ extern sem_t eeprom_write_sem;
|
||||
#define RXCIE0 dummyport
|
||||
#define OCR0A dummyport
|
||||
|
||||
#define OCR1B dummyport
|
||||
#define TCCR1A dummyport
|
||||
#define COM1B0 dummyport
|
||||
|
||||
#define SPDR dummyport
|
||||
#define SPSR dummyport
|
||||
#define SPIF dummyport
|
||||
@@ -126,8 +130,9 @@ extern sem_t eeprom_write_sem;
|
||||
|
||||
extern volatile unsigned char pinb,pinc,pind,pine,ping,pinj,pinl;
|
||||
extern unsigned char portb,dummyport;
|
||||
extern uint8_t main_thread_running;
|
||||
|
||||
void StartMainThread();
|
||||
void StartMainThread(bool tests=true);
|
||||
void StartEepromThread(const char *filename="eeprom.bin");
|
||||
|
||||
extern const char *eepromFile;
|
||||
|
||||
Reference in New Issue
Block a user