![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
can't push chnages :(
Fork of FBRDash by
src/LEDS.cpp@1:b3907b8d9f65, 2012-06-25 (annotated)
- Committer:
- intrinseca
- Date:
- Mon Jun 25 21:01:02 2012 +0000
- Revision:
- 1:b3907b8d9f65
- Child:
- 2:825f572902c6
Prototype before adding full CAN comms
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
intrinseca | 1:b3907b8d9f65 | 1 | #include "mbed.h" |
intrinseca | 1:b3907b8d9f65 | 2 | #include "LEDS.h" |
intrinseca | 1:b3907b8d9f65 | 3 | |
intrinseca | 1:b3907b8d9f65 | 4 | LEDS::LEDS(PwmOut _pins[]) |
intrinseca | 1:b3907b8d9f65 | 5 | { |
intrinseca | 1:b3907b8d9f65 | 6 | pins = _pins; |
intrinseca | 1:b3907b8d9f65 | 7 | |
intrinseca | 1:b3907b8d9f65 | 8 | pins[0].period_us(100); |
intrinseca | 1:b3907b8d9f65 | 9 | } |
intrinseca | 1:b3907b8d9f65 | 10 | |
intrinseca | 1:b3907b8d9f65 | 11 | void LEDS::refresh(float rpm) |
intrinseca | 1:b3907b8d9f65 | 12 | { |
intrinseca | 1:b3907b8d9f65 | 13 | int value; |
intrinseca | 1:b3907b8d9f65 | 14 | int remainder; |
intrinseca | 1:b3907b8d9f65 | 15 | int i; |
intrinseca | 1:b3907b8d9f65 | 16 | |
intrinseca | 1:b3907b8d9f65 | 17 | value = rpm / RESOLUTION; |
intrinseca | 1:b3907b8d9f65 | 18 | |
intrinseca | 1:b3907b8d9f65 | 19 | for(i = 0; i < NUM_LEDS; i++) |
intrinseca | 1:b3907b8d9f65 | 20 | { |
intrinseca | 1:b3907b8d9f65 | 21 | if(i < value) |
intrinseca | 1:b3907b8d9f65 | 22 | { |
intrinseca | 1:b3907b8d9f65 | 23 | pins[i] = 1.0; |
intrinseca | 1:b3907b8d9f65 | 24 | } |
intrinseca | 1:b3907b8d9f65 | 25 | else if(i == value) |
intrinseca | 1:b3907b8d9f65 | 26 | { |
intrinseca | 1:b3907b8d9f65 | 27 | remainder = (int)rpm % RESOLUTION; |
intrinseca | 1:b3907b8d9f65 | 28 | pins[i] = (float)remainder / (float)RESOLUTION; |
intrinseca | 1:b3907b8d9f65 | 29 | } |
intrinseca | 1:b3907b8d9f65 | 30 | else |
intrinseca | 1:b3907b8d9f65 | 31 | { |
intrinseca | 1:b3907b8d9f65 | 32 | pins[i] = 0.0; |
intrinseca | 1:b3907b8d9f65 | 33 | } |
intrinseca | 1:b3907b8d9f65 | 34 | } |
intrinseca | 1:b3907b8d9f65 | 35 | } |