The final project of Embedde class.
Dependencies: C12832 LM75B ESP-call MMA7660
SWITCH/SWITCH_APPLICATION.cpp
- Committer:
- pkr7098
- Date:
- 2021-06-03
- Revision:
- 2:37756b51ccdb
- Parent:
- 1:ed1c6618f739
File content as of revision 2:37756b51ccdb:
#include "SWITCH_APPLICATION.h" Thread threadSwitches[2]; static void _threadSwitchLeft(void) { while(1) { if(switchValueWait(SWITCH_LEFT) == 1) { semaphoreModify.acquire(); if(MODE_MODIFY_TIME == ABLE_TO_MODIFY_TIME) { MODE_MODIFY_TIME = UNABLE_TO_MODIFY_TIME; semaphoreModify.release(); applicationChangeMode(); } else { MODE_MODIFY_TIME = ABLE_TO_MODIFY_TIME; semaphoreModify.release(); applicationChangeMode(); } while(switchValue(SWITCH_LEFT) == 1) { thread_sleep_for(SWITCH_DEBOUNCING_DELAY); } } } } static void _threadSwitchRight(void) { while(1) { if(switchValueWait(SWITCH_RIGHT) == 1) { semaphoreAlarmData.acquire(); if(alarmState == ALARM_ENABLED) { alarmState = ALARM_DISABLED; semaphoreAlarmData.release(); } else { alarmState = ALARM_ENABLED; semaphoreAlarmData.release(); } while(switchValue(SWITCH_RIGHT) == 1) { thread_sleep_for(SWITCH_DEBOUNCING_DELAY); } } } } void switchApplicationInit(void) { threadSwitches[SWITCH_LEFT].start(_threadSwitchLeft); threadSwitches[SWITCH_RIGHT].start(_threadSwitchRight); }