external UI solar on foils
Dependencies: mbed
Fork of CAN_module_ext_UI by
ExtUI.cpp@0:877c5ece70ac, 2015-08-11 (annotated)
- Committer:
- Dannis_mbed
- Date:
- Tue Aug 11 08:46:16 2015 +0000
- Revision:
- 0:877c5ece70ac
presentation version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Dannis_mbed | 0:877c5ece70ac | 1 | ////////////////////////////////////////////////////////////////////////////////////// |
Dannis_mbed | 0:877c5ece70ac | 2 | // // |
Dannis_mbed | 0:877c5ece70ac | 3 | // File : ExtUI.cpp // |
Dannis_mbed | 0:877c5ece70ac | 4 | // Version : 0.1 // |
Dannis_mbed | 0:877c5ece70ac | 5 | // Initial : 19 June 2015 // |
Dannis_mbed | 0:877c5ece70ac | 6 | // Author : Dany Brugman // |
Dannis_mbed | 0:877c5ece70ac | 7 | // Comment : externe UI class // |
Dannis_mbed | 0:877c5ece70ac | 8 | // // |
Dannis_mbed | 0:877c5ece70ac | 9 | // // |
Dannis_mbed | 0:877c5ece70ac | 10 | // Changelog : // |
Dannis_mbed | 0:877c5ece70ac | 11 | // Date: Name: Comment: // |
Dannis_mbed | 0:877c5ece70ac | 12 | // 19/06/2015 DNB First version // |
Dannis_mbed | 0:877c5ece70ac | 13 | // // |
Dannis_mbed | 0:877c5ece70ac | 14 | ////////////////////////////////////////////////////////////////////////////////////// |
Dannis_mbed | 0:877c5ece70ac | 15 | |
Dannis_mbed | 0:877c5ece70ac | 16 | ////////////////////////////////////////////////////////////////////////////////////// |
Dannis_mbed | 0:877c5ece70ac | 17 | // includes // |
Dannis_mbed | 0:877c5ece70ac | 18 | ////////////////////////////////////////////////////////////////////////////////////// |
Dannis_mbed | 0:877c5ece70ac | 19 | #include "ExtUI.h" |
Dannis_mbed | 0:877c5ece70ac | 20 | |
Dannis_mbed | 0:877c5ece70ac | 21 | ////////////////////////////////////////////////////////////////////////////////////// |
Dannis_mbed | 0:877c5ece70ac | 22 | // defines // |
Dannis_mbed | 0:877c5ece70ac | 23 | ////////////////////////////////////////////////////////////////////////////////////// |
Dannis_mbed | 0:877c5ece70ac | 24 | #define NEW_HEIGHT 1020 |
Dannis_mbed | 0:877c5ece70ac | 25 | |
Dannis_mbed | 0:877c5ece70ac | 26 | ////////////////////////////////////////////////////////////////////////////////////// |
Dannis_mbed | 0:877c5ece70ac | 27 | // constructor // |
Dannis_mbed | 0:877c5ece70ac | 28 | ////////////////////////////////////////////////////////////////////////////////////// |
Dannis_mbed | 0:877c5ece70ac | 29 | ExtUI::ExtUI() : |
Dannis_mbed | 0:877c5ece70ac | 30 | heightLeds (p13, p14, p5, p6, p7), |
Dannis_mbed | 0:877c5ece70ac | 31 | Red(p21), |
Dannis_mbed | 0:877c5ece70ac | 32 | Green(p22), |
Dannis_mbed | 0:877c5ece70ac | 33 | Blue(p23), |
Dannis_mbed | 0:877c5ece70ac | 34 | iHeight(1) |
Dannis_mbed | 0:877c5ece70ac | 35 | { |
Dannis_mbed | 0:877c5ece70ac | 36 | init(); |
Dannis_mbed | 0:877c5ece70ac | 37 | }; |
Dannis_mbed | 0:877c5ece70ac | 38 | |
Dannis_mbed | 0:877c5ece70ac | 39 | ExtUI::~ExtUI() |
Dannis_mbed | 0:877c5ece70ac | 40 | { |
Dannis_mbed | 0:877c5ece70ac | 41 | }; |
Dannis_mbed | 0:877c5ece70ac | 42 | |
Dannis_mbed | 0:877c5ece70ac | 43 | extern CAN CANBus; |
Dannis_mbed | 0:877c5ece70ac | 44 | |
Dannis_mbed | 0:877c5ece70ac | 45 | |
Dannis_mbed | 0:877c5ece70ac | 46 | void ExtUI::init(void) |
Dannis_mbed | 0:877c5ece70ac | 47 | { |
Dannis_mbed | 0:877c5ece70ac | 48 | Red.period_ms(10); |
Dannis_mbed | 0:877c5ece70ac | 49 | Green.period_ms(10); |
Dannis_mbed | 0:877c5ece70ac | 50 | Blue.period_ms(10); |
Dannis_mbed | 0:877c5ece70ac | 51 | Red = 0.2f; wait(0.2); |
Dannis_mbed | 0:877c5ece70ac | 52 | Red = 0.0f; Green = 0.2f; wait(0.2); |
Dannis_mbed | 0:877c5ece70ac | 53 | Green = 0.0f; Blue = 0.2f; |
Dannis_mbed | 0:877c5ece70ac | 54 | } |
Dannis_mbed | 0:877c5ece70ac | 55 | |
Dannis_mbed | 0:877c5ece70ac | 56 | uint32_t ExtUI::getTargetHeight(void) |
Dannis_mbed | 0:877c5ece70ac | 57 | { |
Dannis_mbed | 0:877c5ece70ac | 58 | return uiTargetHeight; |
Dannis_mbed | 0:877c5ece70ac | 59 | } |
Dannis_mbed | 0:877c5ece70ac | 60 | |
Dannis_mbed | 0:877c5ece70ac | 61 | int ExtUI::setTargetHeight(uint32_t Value) |
Dannis_mbed | 0:877c5ece70ac | 62 | { |
Dannis_mbed | 0:877c5ece70ac | 63 | if ((Value % 5 == 0)&&(Value <= 30)) |
Dannis_mbed | 0:877c5ece70ac | 64 | { |
Dannis_mbed | 0:877c5ece70ac | 65 | uiTargetHeight = Value; |
Dannis_mbed | 0:877c5ece70ac | 66 | vUpdatextUI(); |
Dannis_mbed | 0:877c5ece70ac | 67 | return 1; |
Dannis_mbed | 0:877c5ece70ac | 68 | } |
Dannis_mbed | 0:877c5ece70ac | 69 | else return 0; //error out of range |
Dannis_mbed | 0:877c5ece70ac | 70 | } |
Dannis_mbed | 0:877c5ece70ac | 71 | |
Dannis_mbed | 0:877c5ece70ac | 72 | void ExtUI::heightIncrease(void) |
Dannis_mbed | 0:877c5ece70ac | 73 | { |
Dannis_mbed | 0:877c5ece70ac | 74 | if (iHeight !=0) iHeight = getTargetHeight()/5; |
Dannis_mbed | 0:877c5ece70ac | 75 | if (iHeight < 6) iHeight++; |
Dannis_mbed | 0:877c5ece70ac | 76 | cMessage = (char) (iHeight * 5); |
Dannis_mbed | 0:877c5ece70ac | 77 | CANBus.write(CANMessage(NEW_HEIGHT, &cMessage, 1)); |
Dannis_mbed | 0:877c5ece70ac | 78 | //setTargetHeight(iHeight * 5); |
Dannis_mbed | 0:877c5ece70ac | 79 | vUpdatextUI(); |
Dannis_mbed | 0:877c5ece70ac | 80 | //heightLeds.write(cuLut[iHeight-1]); |
Dannis_mbed | 0:877c5ece70ac | 81 | } |
Dannis_mbed | 0:877c5ece70ac | 82 | |
Dannis_mbed | 0:877c5ece70ac | 83 | void ExtUI::heightDecrease(void) |
Dannis_mbed | 0:877c5ece70ac | 84 | { |
Dannis_mbed | 0:877c5ece70ac | 85 | iHeight = getTargetHeight()/5; |
Dannis_mbed | 0:877c5ece70ac | 86 | if (iHeight > 1) iHeight--; |
Dannis_mbed | 0:877c5ece70ac | 87 | cMessage = (char) (iHeight * 5); |
Dannis_mbed | 0:877c5ece70ac | 88 | CANBus.write(CANMessage(NEW_HEIGHT, &cMessage, 1)); |
Dannis_mbed | 0:877c5ece70ac | 89 | //setTargetHeight(iHeight * 5); |
Dannis_mbed | 0:877c5ece70ac | 90 | vUpdatextUI(); |
Dannis_mbed | 0:877c5ece70ac | 91 | //heightLeds.write(cuLut[iHeight-1]); |
Dannis_mbed | 0:877c5ece70ac | 92 | //printf("iHeight: %i\r\n", iHeight); |
Dannis_mbed | 0:877c5ece70ac | 93 | } |
Dannis_mbed | 0:877c5ece70ac | 94 | |
Dannis_mbed | 0:877c5ece70ac | 95 | void ExtUI::vUpdatextUI(void) |
Dannis_mbed | 0:877c5ece70ac | 96 | { |
Dannis_mbed | 0:877c5ece70ac | 97 | iHeight = getTargetHeight()/5; |
Dannis_mbed | 0:877c5ece70ac | 98 | heightLeds.write(cuLut[iHeight-1]); |
Dannis_mbed | 0:877c5ece70ac | 99 | } |
Dannis_mbed | 0:877c5ece70ac | 100 | |
Dannis_mbed | 0:877c5ece70ac | 101 | |
Dannis_mbed | 0:877c5ece70ac | 102 | |
Dannis_mbed | 0:877c5ece70ac | 103 |