![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Fork to see if I can get working
Dependencies: BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated
Fork of xDotBridge_update_test20180823 by
xDotBridge/src/UserInterface.cpp@64:46c8819c07cc, 2017-03-14 (annotated)
- Committer:
- Matt Briggs
- Date:
- Tue Mar 14 11:53:53 2017 -0600
- Revision:
- 64:46c8819c07cc
- Parent:
- 62:9751a8504c82
Continuted debug of pairing code. Qcuik hack to disable counters.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Matt Briggs | 62:9751a8504c82 | 1 | /* |
Matt Briggs | 62:9751a8504c82 | 2 | * UserInterface.cpp |
Matt Briggs | 62:9751a8504c82 | 3 | * |
Matt Briggs | 62:9751a8504c82 | 4 | */ |
Matt Briggs | 62:9751a8504c82 | 5 | |
Matt Briggs | 62:9751a8504c82 | 6 | #include "UserInterface.h" |
Matt Briggs | 62:9751a8504c82 | 7 | |
Matt Briggs | 62:9751a8504c82 | 8 | uint32_t HoldTimeSetting::rotVal2Msec(uint8_t in) { |
Matt Briggs | 62:9751a8504c82 | 9 | switch(in) { |
Matt Briggs | 62:9751a8504c82 | 10 | case 1: |
Matt Briggs | 62:9751a8504c82 | 11 | return 10e3; // 10 sec |
Matt Briggs | 62:9751a8504c82 | 12 | break; |
Matt Briggs | 62:9751a8504c82 | 13 | case 2: |
Matt Briggs | 62:9751a8504c82 | 14 | return 20e3; // 20 sec |
Matt Briggs | 62:9751a8504c82 | 15 | break; |
Matt Briggs | 62:9751a8504c82 | 16 | case 3: |
Matt Briggs | 62:9751a8504c82 | 17 | return 30e3; // 30 sec |
Matt Briggs | 62:9751a8504c82 | 18 | break; |
Matt Briggs | 62:9751a8504c82 | 19 | case 4: |
Matt Briggs | 62:9751a8504c82 | 20 | return 40e3; // 40 sec |
Matt Briggs | 62:9751a8504c82 | 21 | break; |
Matt Briggs | 62:9751a8504c82 | 22 | case 5: |
Matt Briggs | 62:9751a8504c82 | 23 | return 50e3; // 50 sec |
Matt Briggs | 62:9751a8504c82 | 24 | break; |
Matt Briggs | 62:9751a8504c82 | 25 | case 6: |
Matt Briggs | 62:9751a8504c82 | 26 | return 60e3; // 60 sec |
Matt Briggs | 62:9751a8504c82 | 27 | break; |
Matt Briggs | 62:9751a8504c82 | 28 | case 7: |
Matt Briggs | 62:9751a8504c82 | 29 | return 2*60e3; // 2 mins |
Matt Briggs | 62:9751a8504c82 | 30 | break; |
Matt Briggs | 62:9751a8504c82 | 31 | case 8: |
Matt Briggs | 62:9751a8504c82 | 32 | return 5*60e3; // 5 mins |
Matt Briggs | 62:9751a8504c82 | 33 | break; |
Matt Briggs | 62:9751a8504c82 | 34 | case 9: |
Matt Briggs | 62:9751a8504c82 | 35 | return 10*60e3; // 10 mins |
Matt Briggs | 62:9751a8504c82 | 36 | break; |
Matt Briggs | 62:9751a8504c82 | 37 | case 0: |
Matt Briggs | 62:9751a8504c82 | 38 | return 500; // 0.5 sec |
Matt Briggs | 62:9751a8504c82 | 39 | break; |
Matt Briggs | 62:9751a8504c82 | 40 | default: // Match case 0 |
Matt Briggs | 62:9751a8504c82 | 41 | return 500; // 0.5 sec |
Matt Briggs | 62:9751a8504c82 | 42 | } |
Matt Briggs | 62:9751a8504c82 | 43 | } |
Matt Briggs | 62:9751a8504c82 | 44 | |
Matt Briggs | 62:9751a8504c82 | 45 | PairBtnState PairBtnInterp::read(BaseboardIO *bbio) |
Matt Briggs | 62:9751a8504c82 | 46 | { |
Matt Briggs | 62:9751a8504c82 | 47 | const uint8_t holdCnt2ms = 100; // 100 ms per 0.1 sec count |
Matt Briggs | 62:9751a8504c82 | 48 | uint8_t holdCnt = 0; |
Matt Briggs | 62:9751a8504c82 | 49 | for (holdCnt=0; holdCnt < 90; holdCnt++) { |
Matt Briggs | 62:9751a8504c82 | 50 | if (bbio->isPairBtn() == false){ // Button released |
Matt Briggs | 62:9751a8504c82 | 51 | break; |
Matt Briggs | 62:9751a8504c82 | 52 | } |
Matt Briggs | 62:9751a8504c82 | 53 | // TODO Sleep here rather than just wait |
Matt Briggs | 62:9751a8504c82 | 54 | wait(0.1); |
Matt Briggs | 62:9751a8504c82 | 55 | } |
Matt Briggs | 62:9751a8504c82 | 56 | if (ShortPressStartTime <= holdCnt*holdCnt2ms |
Matt Briggs | 62:9751a8504c82 | 57 | && holdCnt*holdCnt2ms < ShortPressStopTime) { |
Matt Briggs | 62:9751a8504c82 | 58 | return pairBtnShortPress; |
Matt Briggs | 62:9751a8504c82 | 59 | } |
Matt Briggs | 62:9751a8504c82 | 60 | else if (MediumPressStartTime <= holdCnt*holdCnt2ms |
Matt Briggs | 62:9751a8504c82 | 61 | && holdCnt*holdCnt2ms < MediumPressStopTime) { |
Matt Briggs | 62:9751a8504c82 | 62 | return pairBtnMediumPress; |
Matt Briggs | 62:9751a8504c82 | 63 | } |
Matt Briggs | 62:9751a8504c82 | 64 | else { |
Matt Briggs | 62:9751a8504c82 | 65 | return pairBtnLongPress; |
Matt Briggs | 62:9751a8504c82 | 66 | } |
Matt Briggs | 62:9751a8504c82 | 67 | } |
Matt Briggs | 64:46c8819c07cc | 68 | |
Matt Briggs | 64:46c8819c07cc | 69 | LedPatterns::LedPatterns(BaseboardIO *bbio) |
Matt Briggs | 64:46c8819c07cc | 70 | { |
Matt Briggs | 64:46c8819c07cc | 71 | mBbio = bbio; |
Matt Briggs | 64:46c8819c07cc | 72 | } |
Matt Briggs | 64:46c8819c07cc | 73 | |
Matt Briggs | 64:46c8819c07cc | 74 | void LedPatterns::turnOn() |
Matt Briggs | 64:46c8819c07cc | 75 | { |
Matt Briggs | 64:46c8819c07cc | 76 | mBbio->ledOn(); |
Matt Briggs | 64:46c8819c07cc | 77 | } |
Matt Briggs | 64:46c8819c07cc | 78 | |
Matt Briggs | 64:46c8819c07cc | 79 | void LedPatterns::turnOff() |
Matt Briggs | 64:46c8819c07cc | 80 | { |
Matt Briggs | 64:46c8819c07cc | 81 | mBbio->ledOff(); |
Matt Briggs | 64:46c8819c07cc | 82 | } |
Matt Briggs | 64:46c8819c07cc | 83 | |
Matt Briggs | 64:46c8819c07cc | 84 | void LedPatterns::singleBlink() |
Matt Briggs | 64:46c8819c07cc | 85 | { |
Matt Briggs | 64:46c8819c07cc | 86 | mBbio->ledOn(); |
Matt Briggs | 64:46c8819c07cc | 87 | wait(0.5); |
Matt Briggs | 64:46c8819c07cc | 88 | mBbio->ledOff(); |
Matt Briggs | 64:46c8819c07cc | 89 | } |
Matt Briggs | 64:46c8819c07cc | 90 | |
Matt Briggs | 64:46c8819c07cc | 91 | void LedPatterns::tripleBlink() |
Matt Briggs | 64:46c8819c07cc | 92 | { |
Matt Briggs | 64:46c8819c07cc | 93 | singleBlink(); |
Matt Briggs | 64:46c8819c07cc | 94 | wait(0.5); |
Matt Briggs | 64:46c8819c07cc | 95 | singleBlink(); |
Matt Briggs | 64:46c8819c07cc | 96 | wait(0.5); |
Matt Briggs | 64:46c8819c07cc | 97 | singleBlink(); |
Matt Briggs | 64:46c8819c07cc | 98 | } |
Matt Briggs | 64:46c8819c07cc | 99 | |
Matt Briggs | 64:46c8819c07cc | 100 | void LedPatterns::tenBlinks() |
Matt Briggs | 64:46c8819c07cc | 101 | { |
Matt Briggs | 64:46c8819c07cc | 102 | for (uint8_t i=0; i<10; i++) { |
Matt Briggs | 64:46c8819c07cc | 103 | singleBlink(); |
Matt Briggs | 64:46c8819c07cc | 104 | wait(0.5); |
Matt Briggs | 64:46c8819c07cc | 105 | } |
Matt Briggs | 64:46c8819c07cc | 106 | } |