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