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: WS2812 PixelArray
Fork of LED_WS2812 by
LEDs_Car.cpp
00001 // ***************************************************************** 00002 // Handle all the LEDs with some general function wrappers functions 00003 // ***************************************************************** 00004 #include "LEDs_Car.h" 00005 00006 // Added a lookup function from a color number to a color, used by Creabot 00007 int LEDs_Car::ColNr2Color( char ColNr) 00008 { switch (ColNr) { 00009 case 0: return BLACK; 00010 case 1: return WHITE; 00011 case 2: return RED; 00012 case 3: return GREEN; 00013 case 4: return BLUE; 00014 case 5: return PURPLE; 00015 default: return BLACK; 00016 } 00017 } 00018 00019 void LEDs_Car::LEDsOff( void ) { 00020 StopRotation(); 00021 StopBlink() ; 00022 for (int lNr=0; lNr<NumLEDs; lNr++) 00023 { SetColor(BLACK,lNr); } 00024 } 00025 00026 void LEDs_Car::LEDsRainbow( void ) 00027 { for (int Nr=0; Nr<NumLEDs; Nr++) 00028 { SetColor(ColNr2Color(Nr + 1),Nr); } 00029 } 00030 00031 void LEDs_Car::LEDNrCol(LED_Nr aNr, int parameter) 00032 { 00033 SetColor( ColNr2Color( aNr ), aNr); 00034 } 00035 00036 void LEDs_Car::LEDsRainbowMove( double speed ) 00037 { LEDsRainbow( ); 00038 StartRotation(0.3); 00039 } 00040 00041 void LEDs_Car::LEDClignote(LED_Nr aNr, int OnOff) { 00042 if (OnOff == 1) { 00043 SetColor( ORANGE, aNr); 00044 StartBlink(0.5) ;} 00045 else { LEDsOff(); } 00046 } 00047 00048 // ***************************************************************** 00049 // Handle all the LEDs specifically with the LED Position definitions 00050 // ***************************************************************** 00051 00052 void LEDs_Car::LEDFront(int ColNr) 00053 { 00054 SetColor( ColNr2Color( ColNr ), ledAvD); 00055 SetColor( ColNr2Color( ColNr ), ledAvG); 00056 } 00057 00058 void LEDs_Car::LEDRear(int ColNr) 00059 { 00060 SetColor( ColNr2Color( ColNr ), ledArD); 00061 SetColor( ColNr2Color( ColNr ), ledArG); 00062 } 00063 00064 void LEDs_Car::LEDCligR(int speed) { 00065 if ( (speed>0) && (speed<4) ) { 00066 SetColor(ORANGE, ledAvD) ; 00067 SetColor(ORANGE, ledArD) ; 00068 StartBlink(float(speed)/4) ;} 00069 else { LEDsOff(); } 00070 } 00071 00072 void LEDs_Car::LEDCligL(int speed) { 00073 if ( (speed>0) && (speed<4) ) { 00074 SetColor(ORANGE, ledAvG) ; 00075 SetColor(ORANGE, ledArG) ; 00076 StartBlink(float(speed)/4) ;} 00077 else { LEDsOff(); } 00078 } 00079 00080 void LEDs_Car::LEDAnim(int speed) { 00081 if ( (speed>0) && (speed<4) ) 00082 { LEDsRainbowMove(float(speed)/4); } 00083 else { LEDsOff(); } 00084 } 00085
Generated on Fri Jul 15 2022 20:57:43 by
1.7.2
