should work
This commit is contained in:
47
src/hmi.cpp
47
src/hmi.cpp
@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
|
|
||||||
const uint32_t LOWER_SHORT_TIME = 100;
|
const uint32_t LOWER_SHORT_TIME = 100;
|
||||||
const uint32_t UPPER_SHORT_TIME = 1000;
|
const uint32_t UPPER_SHORT_TIME = 300;
|
||||||
|
const uint32_t LED_WAIT_TIME = 500;
|
||||||
|
|
||||||
class SwitchPort {
|
class SwitchPort {
|
||||||
public:
|
public:
|
||||||
@ -115,11 +115,23 @@ SwitchPort2 onTimeSwitch = SwitchPort2(BIT2);
|
|||||||
SwitchPort2 offTimeSwitch = SwitchPort2(BIT3);
|
SwitchPort2 offTimeSwitch = SwitchPort2(BIT3);
|
||||||
//SwitchPort modeSwitch = SwitchPort2(BIT4);
|
//SwitchPort modeSwitch = SwitchPort2(BIT4);
|
||||||
|
|
||||||
int16_t intensity = 0;
|
uint16_t intensity = 0;
|
||||||
uint16_t maxIntensity = 0;
|
uint16_t maxIntensity = 0;
|
||||||
uint16_t intensityStep = 0;
|
uint16_t intensityStep = 0;
|
||||||
const uint16_t intensityStepCnt = 16;
|
const uint16_t intensityStepCnt = 16;
|
||||||
|
|
||||||
|
void hmiLedGreenOn() {
|
||||||
|
P1OUT |= BIT4;
|
||||||
|
}
|
||||||
|
void hmiLedRedOn() {
|
||||||
|
P1OUT |= BIT5;
|
||||||
|
}
|
||||||
|
void hmiLedGreenOff() {
|
||||||
|
P1OUT &= ~BIT4;
|
||||||
|
}
|
||||||
|
void hmiLedRedOff() {
|
||||||
|
P1OUT &= ~BIT5;
|
||||||
|
}
|
||||||
|
|
||||||
void hmiInit() {
|
void hmiInit() {
|
||||||
maxIntensity = engineMaxPwmValue();
|
maxIntensity = engineMaxPwmValue();
|
||||||
@ -130,33 +142,52 @@ void hmiInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void hmiExec() {
|
void hmiExec() {
|
||||||
|
static uint32_t ledWait = 0;
|
||||||
|
|
||||||
if (intensitySwitch.get() == SwitchPort::SWITCH_SHORT) {
|
if (intensitySwitch.get() == SwitchPort::SWITCH_SHORT) {
|
||||||
intensity += intensityStep;
|
intensity += intensityStep;
|
||||||
if (intensity > maxIntensity) {
|
if (intensity > maxIntensity) {
|
||||||
intensity = maxIntensity;
|
intensity = maxIntensity;
|
||||||
}
|
}
|
||||||
|
hmiLedGreenOn();
|
||||||
|
ledWait = LED_WAIT_TIME;
|
||||||
debugWrite(intensity);
|
debugWrite(intensity);
|
||||||
engineSetPwmValue(intensity);
|
engineSetPwmValue(intensity);
|
||||||
} else if (intensitySwitch.get() == SwitchPort::SWITCH_LONG) {
|
} else if (intensitySwitch.get() == SwitchPort::SWITCH_LONG) {
|
||||||
intensity -= intensityStep;
|
if (intensity != 0) {
|
||||||
if (intensity < 0) {
|
intensity -= intensityStep;
|
||||||
intensity = 0;
|
|
||||||
}
|
}
|
||||||
|
hmiLedRedOn();
|
||||||
|
ledWait = LED_WAIT_TIME;
|
||||||
debugWrite(intensity);
|
debugWrite(intensity);
|
||||||
engineSetPwmValue(intensity);
|
engineSetPwmValue(intensity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (onTimeSwitch.get() == SwitchPort::SWITCH_SHORT) {
|
if (onTimeSwitch.get() == SwitchPort::SWITCH_SHORT) {
|
||||||
engineIncOnTime();
|
engineIncOnTime();
|
||||||
|
hmiLedGreenOn();
|
||||||
|
ledWait = LED_WAIT_TIME;
|
||||||
} else if (onTimeSwitch.get() == SwitchPort::SWITCH_LONG) {
|
} else if (onTimeSwitch.get() == SwitchPort::SWITCH_LONG) {
|
||||||
engineDecOnTime();
|
engineDecOnTime();
|
||||||
|
hmiLedRedOn();
|
||||||
|
ledWait = LED_WAIT_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offTimeSwitch.get() == SwitchPort::SWITCH_SHORT) {
|
if (offTimeSwitch.get() == SwitchPort::SWITCH_SHORT) {
|
||||||
engineIncOffTime();
|
engineIncOffTime();
|
||||||
|
hmiLedGreenOn();
|
||||||
|
ledWait = LED_WAIT_TIME;
|
||||||
} else if (onTimeSwitch.get() == SwitchPort::SWITCH_LONG) {
|
} else if (onTimeSwitch.get() == SwitchPort::SWITCH_LONG) {
|
||||||
engineDecOffTime();
|
engineDecOffTime();
|
||||||
|
hmiLedRedOn();
|
||||||
|
ledWait = LED_WAIT_TIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ledWait != 0) {
|
||||||
|
ledWait--;
|
||||||
|
} else {
|
||||||
|
hmiLedGreenOff();
|
||||||
|
hmiLedRedOff();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user