seems to work now
This commit is contained in:
parent
279e3fa1a8
commit
1a850d01b5
55
src/hmi.cpp
55
src/hmi.cpp
@ -17,15 +17,24 @@
|
||||
|
||||
|
||||
|
||||
class SwitchPort2 {
|
||||
class SwitchPort {
|
||||
public:
|
||||
SwitchPort2(uint16_t bit) : m_bit(bit), m_state(0), m_cnt(0) {
|
||||
P2REN |= m_bit;
|
||||
SwitchPort(uint16_t bit, uint16_t inRegister) : m_bit(bit), m_state(0), m_cnt(0), m_inRegister(inRegister) {
|
||||
};
|
||||
bool get() {
|
||||
bool result = false;
|
||||
bool inValue = false;
|
||||
switch (m_inRegister) {
|
||||
case 1:
|
||||
inValue = P1IN & m_bit;
|
||||
break;
|
||||
case 2:
|
||||
inValue = P2IN & m_bit;
|
||||
break;
|
||||
}
|
||||
switch (m_state) {
|
||||
case 0:
|
||||
|
||||
if (P2IN & m_bit) {
|
||||
m_cnt = 0;
|
||||
} else {
|
||||
@ -61,14 +70,30 @@ private:
|
||||
uint16_t m_bit;
|
||||
uint8_t m_state;
|
||||
uint16_t m_cnt;
|
||||
uint8_t m_inRegister;
|
||||
};
|
||||
|
||||
class SwitchPort2 : public SwitchPort {
|
||||
public:
|
||||
SwitchPort2(uint16_t bit) : SwitchPort(bit, 2) {
|
||||
P2REN |= bit;
|
||||
P2DIR &= ~bit;
|
||||
P2SEL &= ~bit;
|
||||
};
|
||||
};
|
||||
class SwitchPort1 : public SwitchPort {
|
||||
public:
|
||||
SwitchPort1(uint16_t bit) : SwitchPort(bit, 1) {
|
||||
P1REN |= bit;
|
||||
P1DIR &= ~bit;
|
||||
P1SEL &= ~bit;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
SwitchPort2 switch1 = SwitchPort2(BIT0);
|
||||
SwitchPort2 switch2 = SwitchPort2(BIT1);
|
||||
SwitchPort2 switch3 = SwitchPort2(BIT2);
|
||||
SwitchPort2 switch4 = SwitchPort2(BIT3);
|
||||
SwitchPort switch1 = SwitchPort2(BIT0);
|
||||
SwitchPort switch2 = SwitchPort2(BIT1);
|
||||
SwitchPort switch3 = SwitchPort2(BIT2);
|
||||
SwitchPort switch4 = SwitchPort2(BIT3);
|
||||
|
||||
|
||||
const uint8_t LED_RED_PIN = BIT5;
|
||||
@ -130,16 +155,16 @@ void hmiExec() {
|
||||
setUDes(savedVoltage);
|
||||
}
|
||||
}
|
||||
// if (switch4.get()) {
|
||||
// dispState++;
|
||||
// if (dispState > MAX_DISP_STATE) {
|
||||
// dispState = 0;
|
||||
// }
|
||||
// }
|
||||
if (switch4.get()) {
|
||||
dispState++;
|
||||
if (dispState > MAX_DISP_STATE) {
|
||||
dispState = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t cnt = 0;
|
||||
cnt++;
|
||||
if (cnt >= 10000) {
|
||||
if (cnt >= 5000) {
|
||||
dispSetFloat(0, getUCur());
|
||||
float dispValue;
|
||||
switch (dispState) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user