start sequence added

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

View File

@ -109,45 +109,49 @@ 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:
break; break;
case STATE_START: case STATE_START:
set(true); set(true);
m_startTime = getMillis(); m_startTime = getMillis();
m_state = STATE_ON; m_state = STATE_ON;
break; break;
case STATE_ON: case STATE_ON:
if (getMillis() > m_timeout + m_startTime) { if (getMillis() > m_timeout + m_startTime) {
m_state = STATE_OFF; m_state = STATE_OFF;
} }
m_timeout--; m_timeout--;
break; break;
case STATE_OFF: case STATE_OFF:
set(false); set(false);
m_state = STATE_IDLE; m_state = STATE_IDLE;
break; break;
default: default:
m_state = STATE_IDLE; m_state = STATE_IDLE;
break; break;
} }
} }
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()) {