start sequence added

This commit is contained in:
hg
2016-02-16 21:19:45 +01:00
parent bad81e35c7
commit 0e062197c7

View File

@ -109,18 +109,21 @@ private:
class Led { class Led {
public: public:
enum e_flashType { FLASH_SHORT, FLASH_LONG }; enum e_flashType { FLASH_SHORT, FLASH_LONG, FLASH_EXTRA_LONG };
Led() : m_state(STATE_IDLE), m_timeout(0) { Led() : m_state(STATE_IDLE), m_timeout(0) {
} }
void start(e_flashType ft) { void start(e_flashType ft) {
m_state = STATE_START; m_state = STATE_START;
if (FLASH_LONG == ft) { if (FLASH_EXTRA_LONG == ft) {
m_timeout = LED_WAIT_TIME_EXTRA_LONG;
} else if (FLASH_LONG == ft) {
m_timeout = LED_WAIT_TIME_LONG; m_timeout = LED_WAIT_TIME_LONG;
} else { } else {
m_timeout = LED_WAIT_TIME_SHORT; m_timeout = LED_WAIT_TIME_SHORT;
} }
} }
virtual void set(bool v) {}; virtual void set(bool v) {};
bool isIdle() { return m_state == STATE_IDLE; };
void exec() { void exec() {
switch (m_state) { switch (m_state) {
case STATE_IDLE: case STATE_IDLE:
@ -148,6 +151,7 @@ public:
private: private:
static const uint32_t LED_WAIT_TIME_SHORT = 500; static const uint32_t LED_WAIT_TIME_SHORT = 500;
static const uint32_t LED_WAIT_TIME_LONG = 5000; static const uint32_t LED_WAIT_TIME_LONG = 5000;
static const uint32_t LED_WAIT_TIME_EXTRA_LONG = 50000;
enum e_state { STATE_IDLE, STATE_START, STATE_ON, STATE_OFF }; enum e_state { STATE_IDLE, STATE_START, STATE_ON, STATE_OFF };
e_state m_state; e_state m_state;
uint32_t m_timeout; uint32_t m_timeout;
@ -202,6 +206,27 @@ void hmiInit() {
} }
void hmiExec() { void hmiExec() {
static bool starting = true;
if (starting) {
ledGreen.start(Led::FLASH_EXTRA_LONG);
while (! ledGreen.isIdle()) {
ledGreen.exec();
}
ledRed.start(Led::FLASH_EXTRA_LONG);
while (! ledRed.isIdle()) {
ledRed.exec();
}
ledGreen.start(Led::FLASH_EXTRA_LONG);
while (! ledGreen.isIdle()) {
ledGreen.exec();
}
ledRed.start(Led::FLASH_EXTRA_LONG);
while (! ledRed.isIdle()) {
ledRed.exec();
}
starting = false;
}
SwitchPort::e_switchResult switchResult = intensitySwitch.get(); SwitchPort::e_switchResult switchResult = intensitySwitch.get();
if (switchResult == SwitchPort::SWITCH_SHORT) { if (switchResult == SwitchPort::SWITCH_SHORT) {
if (engineIncPwmValue()) { if (engineIncPwmValue()) {