can't push chnages :(

Fork of FBRDash by Michael Allan

main.cpp

Committer:
intrinseca
Date:
2011-11-03
Revision:
0:1f422ed56e0f
Child:
1:b3907b8d9f65

File content as of revision 0:1f422ed56e0f:

#include "mbed.h"
#include "TextLCD.h"

#define NUM_LEDS 6
PwmOut leds[] = { (p26), (p25), (p24), (p23), (p22), (p21) };

TextLCD lcd(p10, p11, p12, p17, p18, p19, p20);

InterruptIn shiftDown(p5);
InterruptIn shiftUp(p6);
InterruptIn shiftNeutral(p7);

volatile float increment = 0;

void up()
{
    increment += 0.01;
}

void down()
{
    increment -= 0.01;
}

void neutral()
{
    increment = 0;
}

int main() {
    float i;

    shiftUp.rise(&up);
    shiftDown.rise(&down);
    shiftNeutral.rise(&neutral);

    leds[0].period(0.0001);
    
    lcd.locate(0, 1);
    lcd.printf("Neutral");
    
    while(1) {
        if(increment >= 0)
            i = 0;
        else
            i = 6.0;
    
        for(; i <= 6 && i >= 0; i += increment)
        {
            for(int j = 0; j < NUM_LEDS; j++)
            {          
                if(j < (int)i)
                {
                    leds[j] = 1.0;
                }
                else if(j >= (int)i + 1)
                {
                    leds[j] = 0;
                }
                else
                {
                    leds[j] = i - ((int)i);
                }
            }
      
            lcd.locate(0, 0);
            lcd.printf("%4.2f %4.2f", i, increment);
            
            lcd.locate(0, 1);
            if(increment < 0)
                lcd.printf("Down   ");
            else if(increment > 0)
                lcd.printf("Up     ");
            else
                lcd.printf("Neutral");
            
            wait_ms(10);
        }
    }
}