works better now, not perfect
This commit is contained in:
13
.cproject
13
.cproject
@ -53,5 +53,16 @@
|
|||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||||
<storageModule moduleId="refreshScope"/>
|
<storageModule moduleId="refreshScope"/>
|
||||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
|
||||||
|
<buildTargets>
|
||||||
|
<target name="build" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
|
<buildCommand>${MSP430MAKE}</buildCommand>
|
||||||
|
<buildArguments/>
|
||||||
|
<buildTarget>build</buildTarget>
|
||||||
|
<stopOnError>true</stopOnError>
|
||||||
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
|
<runAllBuilders>true</runAllBuilders>
|
||||||
|
</target>
|
||||||
|
</buildTargets>
|
||||||
|
</storageModule>
|
||||||
</cproject>
|
</cproject>
|
||||||
|
32
src/hmi.cpp
32
src/hmi.cpp
@ -15,7 +15,7 @@ public:
|
|||||||
enum e_switchResult { SWITCH_IDLE, SWITCH_SHORT, SWITCH_LONG };
|
enum e_switchResult { SWITCH_IDLE, SWITCH_SHORT, SWITCH_LONG };
|
||||||
SwitchPort() : m_state(STATE_IDLE) {
|
SwitchPort() : m_state(STATE_IDLE) {
|
||||||
};
|
};
|
||||||
virtual bool getSwitchState() { return false; };
|
virtual bool getSwitchState() { debugWrite(0x009); return false; };
|
||||||
e_switchResult get() {
|
e_switchResult get() {
|
||||||
e_switchResult result = SWITCH_IDLE;
|
e_switchResult result = SWITCH_IDLE;
|
||||||
bool inValue = getSwitchState();
|
bool inValue = getSwitchState();
|
||||||
@ -23,22 +23,33 @@ public:
|
|||||||
switch (m_state) {
|
switch (m_state) {
|
||||||
case STATE_IDLE:
|
case STATE_IDLE:
|
||||||
if (inValue == false) {
|
if (inValue == false) {
|
||||||
|
// debugWrite(0x001);
|
||||||
m_state = STATE_BUTTON_PRESSED;
|
m_state = STATE_BUTTON_PRESSED;
|
||||||
m_timestamp = getMillis();
|
m_timestamp = getMillis();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STATE_BUTTON_PRESSED:
|
case STATE_BUTTON_PRESSED:
|
||||||
if (inValue == true) {
|
if (inValue == true) {
|
||||||
|
// debugWrite(0x002);
|
||||||
m_state = STATE_BUTTON_RELEASED;
|
m_state = STATE_BUTTON_RELEASED;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STATE_BUTTON_RELEASED:
|
case STATE_BUTTON_RELEASED:
|
||||||
duration = m_timestamp - getMillis();
|
duration = getMillis() - m_timestamp;
|
||||||
|
// {
|
||||||
|
// 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)) {
|
if ((duration >= LOWER_SHORT_TIME) && (duration <= UPPER_SHORT_TIME)) {
|
||||||
|
// debugWrite(0x003);
|
||||||
m_state = STATE_SHORT;
|
m_state = STATE_SHORT;
|
||||||
} else if (duration > UPPER_SHORT_TIME) {
|
} else if (duration > UPPER_SHORT_TIME) {
|
||||||
|
// debugWrite(0x004);
|
||||||
m_state = STATE_LONG;
|
m_state = STATE_LONG;
|
||||||
} else {
|
} else {
|
||||||
|
// debugWrite(0x005);
|
||||||
m_state = STATE_IDLE;
|
m_state = STATE_IDLE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -65,16 +76,22 @@ private:
|
|||||||
|
|
||||||
class SwitchPort2 : public SwitchPort {
|
class SwitchPort2 : public SwitchPort {
|
||||||
public:
|
public:
|
||||||
SwitchPort2(uint16_t bit) : SwitchPort(), m_bit(bit) {
|
SwitchPort2(uint16_t bit) : SwitchPort() {
|
||||||
|
m_bit = bit;
|
||||||
P2REN |= bit;
|
P2REN |= bit;
|
||||||
P2DIR &= ~bit;
|
P2DIR &= ~bit;
|
||||||
P2SEL &= ~bit;
|
P2SEL &= ~bit;
|
||||||
};
|
};
|
||||||
virtual bool getSwitchState() {
|
virtual bool getSwitchState() {
|
||||||
return P2IN & m_bit;
|
bool a = P2IN & m_bit;
|
||||||
|
// if (a)
|
||||||
|
// debugWrite(0x00A);
|
||||||
|
// else
|
||||||
|
// debugWrite(0x00B);
|
||||||
|
return a;
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
bool m_bit;
|
uint16_t m_bit;
|
||||||
};
|
};
|
||||||
class SwitchPort1 : public SwitchPort {
|
class SwitchPort1 : public SwitchPort {
|
||||||
public:
|
public:
|
||||||
@ -87,7 +104,7 @@ public:
|
|||||||
return P1IN & m_bit;
|
return P1IN & m_bit;
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
bool m_bit;
|
uint16_t m_bit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -129,7 +146,7 @@ void hmiExec() {
|
|||||||
engineSetPwmValue(intensity);
|
engineSetPwmValue(intensity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (onTimeSwitch.get() == SwitchPort::SWITCH_SHORT) {
|
if (onTimeSwitch.get() == SwitchPort::SWITCH_SHORT) {
|
||||||
engineIncOnTime();
|
engineIncOnTime();
|
||||||
} else if (onTimeSwitch.get() == SwitchPort::SWITCH_LONG) {
|
} else if (onTimeSwitch.get() == SwitchPort::SWITCH_LONG) {
|
||||||
@ -141,4 +158,5 @@ void hmiExec() {
|
|||||||
} else if (onTimeSwitch.get() == SwitchPort::SWITCH_LONG) {
|
} else if (onTimeSwitch.get() == SwitchPort::SWITCH_LONG) {
|
||||||
engineDecOffTime();
|
engineDecOffTime();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user