This commit is contained in:
hg 2016-02-16 20:16:03 +01:00
parent a90a122974
commit 7f7ce171a9

View File

@ -33,20 +33,20 @@ public:
break;
case STATE_BUTTON_RELEASED:
duration = getMillis() - m_timestamp;
// {
// uint16_t d1 = (uint16_t) (duration & 0x0000ffff);
// uint16_t d2 = (uint16_t) ((duration & 0xffff0000) >> 16);
// debugWrite(d1);
// debugWrite(d2);
// }
{
uint16_t d1 = (uint16_t) (duration & 0x0000ffff);
uint16_t d2 = (uint16_t) ((duration & 0xffff0000) >> 16);
debugWrite(d1);
debugWrite(d2);
}
if ((duration >= LOWER_SHORT_TIME) && (duration <= UPPER_SHORT_TIME)) {
// debugWrite(0x003);
debugWrite(0x003);
m_state = STATE_SHORT;
} else if (duration > UPPER_SHORT_TIME) {
// debugWrite(0x004);
debugWrite(0x004);
m_state = STATE_LONG;
} else {
// debugWrite(0x005);
debugWrite(0x005);
m_state = STATE_IDLE;
}
break;
@ -67,7 +67,7 @@ public:
};
private:
static const uint32_t LOWER_SHORT_TIME = 100;
static const uint32_t UPPER_SHORT_TIME = 300;
static const uint32_t UPPER_SHORT_TIME = 500;
enum e_state { STATE_IDLE, STATE_BUTTON_PRESSED, STATE_BUTTON_RELEASED, STATE_SHORT, STATE_LONG };
e_state m_state;
uint32_t m_timestamp;
@ -127,10 +127,11 @@ public:
break;
case STATE_START:
set(true);
m_startTime = getMillis();
m_state = STATE_ON;
break;
case STATE_ON:
if (m_timeout == 0) {
if (getMillis() > m_timeout + m_startTime) {
m_state = STATE_OFF;
}
m_timeout--;
@ -146,10 +147,11 @@ public:
}
private:
static const uint32_t LED_WAIT_TIME_SHORT = 500;
static const uint32_t LED_WAIT_TIME_LONG = 1000;
static const uint32_t LED_WAIT_TIME_LONG = 5000;
enum e_state { STATE_IDLE, STATE_START, STATE_ON, STATE_OFF };
e_state m_state;
uint32_t m_timeout;
uint32_t m_startTime;
};
class Led1 : public Led {
public:
@ -200,46 +202,48 @@ void hmiInit() {
}
void hmiExec() {
if (intensitySwitch.get() == SwitchPort::SWITCH_SHORT) {
SwitchPort::e_switchResult switchResult = intensitySwitch.get();
if (switchResult == SwitchPort::SWITCH_SHORT) {
if (engineIncPwmValue()) {
ledGreen.start(Led::FLASH_SHORT);
} else {
ledGreen.start(Led::FLASH_LONG);
} else {
ledGreen.start(Led::FLASH_SHORT);
}
} else if (intensitySwitch.get() == SwitchPort::SWITCH_LONG) {
} else if (switchResult == SwitchPort::SWITCH_LONG) {
if (engineDecPwmValue()) {
ledRed.start(Led::FLASH_SHORT);
} else {
ledRed.start(Led::FLASH_LONG);
} else {
ledRed.start(Led::FLASH_SHORT);
}
}
if (onTimeSwitch.get() == SwitchPort::SWITCH_SHORT) {
switchResult = onTimeSwitch.get();
if (switchResult == SwitchPort::SWITCH_SHORT) {
if (engineIncOnTime()) {
ledGreen.start(Led::FLASH_SHORT);
} else {
ledGreen.start(Led::FLASH_LONG);
}
} else if (onTimeSwitch.get() == SwitchPort::SWITCH_LONG) {
if (engineDecOnTime()) {
ledRed.start(Led::FLASH_SHORT);
} else {
ledGreen.start(Led::FLASH_SHORT);
}
} else if (switchResult == SwitchPort::SWITCH_LONG) {
if (engineDecOnTime()) {
ledRed.start(Led::FLASH_LONG);
} else {
ledRed.start(Led::FLASH_SHORT);
}
}
if (offTimeSwitch.get() == SwitchPort::SWITCH_SHORT) {
switchResult = offTimeSwitch.get();
if (switchResult == SwitchPort::SWITCH_SHORT) {
if (engineIncOffTime()) {
ledGreen.start(Led::FLASH_SHORT);
} else {
ledGreen.start(Led::FLASH_LONG);
}
} else if (onTimeSwitch.get() == SwitchPort::SWITCH_LONG) {
if (engineDecOffTime()) {
ledRed.start(Led::FLASH_SHORT);
} else {
ledGreen.start(Led::FLASH_SHORT);
}
} else if (switchResult == SwitchPort::SWITCH_LONG) {
if (engineDecOffTime()) {
ledRed.start(Led::FLASH_LONG);
} else {
ledRed.start(Led::FLASH_SHORT);
}
}