Simon Dziadon / Mbed 2 deprecated mbed_cz2_5_test

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers led.cpp Source File

led.cpp

00001 #include "led.h"
00002 
00003 Led::Led (void){
00004     ucServoPos = 0;
00005     unsigned char ucCurrentLed;
00006     lcd.SetFont(&Font24);
00007     lcd.Clear(LCD_COLOR_WHITE);
00008     
00009     lcd.SetTextColor(LCD_COLOR_BLACK);
00010     for( ucCurrentLed = 1; ucCurrentLed < 5; ucCurrentLed++ ){
00011         lcd.FillCircle((ucCurrentLed*50)-5,260,20);
00012     }
00013 }
00014 
00015 void Led::On(unsigned char ucLedIndeks){
00016     
00017     unsigned char ucCurrentLed;
00018     float posX, posY;
00019     lcd.SetTextColor(LCD_COLOR_BLACK);
00020     lcd.FillCircle(120,120,90);
00021     
00022     lcd.SetTextColor(LCD_COLOR_WHITE);
00023     lcd.FillCircle(120, 120, 10);
00024     
00025     for( ucCurrentLed = 1; ucCurrentLed < 5; ucCurrentLed++ )
00026     {
00027         lcd.FillCircle((ucCurrentLed*50)-5,260,16);
00028     }
00029     
00030     posX = 120 + (90 * sin((0.131 * ucServoPos)));
00031     posY = 120 + (90 * cos((0.131 * ucServoPos)));
00032     lcd.DrawLine(120, 120, posX, posY);
00033     
00034     lcd.SetTextColor(LCD_COLOR_BLUE);
00035     lcd.FillCircle(((ucLedIndeks+1)*50)-5,260,16);
00036     
00037 }
00038 
00039 void Led::Step (enum LedDirection Direction){
00040     
00041     static unsigned int uiLedCounter = 0;
00042     
00043     if(Direction == LEFT)
00044     {
00045         uiLedCounter++;
00046     }
00047     else
00048     {
00049         uiLedCounter--;
00050     }
00051     On(uiLedCounter%4);
00052 }
00053 
00054 void Led::StepLeft(void){
00055     if(ucServoPos < 47)
00056     {
00057         ucServoPos++;
00058     }
00059     else
00060     {
00061         ucServoPos = 0;
00062     }
00063     Step(LEFT);
00064 }
00065 
00066 void Led::StepRight(void){
00067     if(ucServoPos > 0)
00068     {
00069         ucServoPos--;
00070     }
00071     else
00072     {
00073         ucServoPos = 47;
00074     }
00075     Step(RIGHT);
00076 }