Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed TextLCD PinDetect
Diff: src/LEDS.cpp
- Revision:
- 5:177520d43c87
- Parent:
- 2:825f572902c6
- Child:
- 7:78cb2263290a
--- a/src/LEDS.cpp Mon Jun 25 21:59:31 2012 +0000
+++ b/src/LEDS.cpp Sun Oct 14 21:09:49 2012 +0000
@@ -14,30 +14,16 @@
//Calculate new PWM values
void LEDS::refresh(float rpm)
{
- int value;
- int remainder;
- int i;
- //Number of fully-lit LEDs
- value = rpm / RESOLUTION;
-
- for(i = 0; i < NUM_LEDS; i++)
- {
- if(i < value)
- {
- //First LEDs on
- pins[i] = 1.0;
- }
- else if(i == value)
- {
- //Last LED partially lit - calculate intensity and set.
- remainder = (int)rpm % RESOLUTION;
- pins[i] = (float)remainder / (float)RESOLUTION;
- }
- else
- {
- //All others off
- pins[i] = 0.0;
- }
- }
+ //Engine running
+ pins[0]=(rpm-1000)/4000;
+ //Change Down
+ pins[1]=(rpm-5000)/2000;
+ //Good gear
+ pins[2]=(rpm-7000)/2000;
+ pins[3]=(rpm-9000)/2000;
+ //Change up
+ pins[4]=(rpm-11000)/500;
+ //Change up urgently
+ pins[5]=(rpm-11500)/500;
}
\ No newline at end of file
