pp
Dependencies: mbed
Diff: DigitDisplay.cpp
- Revision:
- 2:6b4dda997dc0
- Parent:
- 1:ba7154d2d7ca
- Child:
- 4:a61cdd4e7afa
--- a/DigitDisplay.cpp Sat Dec 05 14:01:16 2015 +0000 +++ b/DigitDisplay.cpp Sat Dec 05 14:32:27 2015 +0000 @@ -36,7 +36,6 @@ #define DIGIT_UNKOWN 0x08 #define DIGIT_NULL 0x00 #define DIGIT_MINUS 0x40 -BusIn button(D9,D10,D11); const uint8_t DIGIT_TABLE[] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, @@ -76,9 +75,9 @@ buttonState1 = 0; buttonState2 = 0; buttonState3 = 0; - //prebuttonState1 = 0; - //prebuttonState2 = 0; - //prebuttonState3 = 0; + prebuttonState1 = 0; + prebuttonState2 = 0; + prebuttonState3 = 0; } void DigitDisplay::on() @@ -327,28 +326,33 @@ write(2, s3); write(3, s4); } -void DigitDisplay::getButtonState() +void DigitDisplay::getButtonState(int n) { - - if(button==0b011) buttonState1=1; - else buttonState1=0; - if(button==0b101) buttonState2=1; - else buttonState2=0; - if(button==0b110) buttonState3=1; - else buttonState3=0; + prebuttonState1 = buttonState1; + prebuttonState2 = buttonState2; + prebuttonState3 = buttonState3; + if(n==0) + { + buttonState1=0; + buttonState2=0; + buttonState3=0; + } + else if(n==1) buttonState1=1; + else if(n==2) buttonState2=1; + else if(n==3) buttonState3=1; } bool DigitDisplay::checkButton1() { - if(button==0b011) return 1; + if(prebuttonState1==0 && buttonState1==1) return 1; else return 0; } bool DigitDisplay::checkButton2() { - if(buttonState2==1) return 1; + if(prebuttonState2==0 && buttonState2==1) return 1; else return 0; } bool DigitDisplay::checkButton3() { - if(buttonState3==1) return 1; + if(prebuttonState3==0 && buttonState3==1) return 1; else return 0; } \ No newline at end of file