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: TextLCD mbed MMA8451Q
Revision 10:31d4d8104813, committed 2014-06-24
- Comitter:
- Berrng
- Date:
- Tue Jun 24 09:48:22 2014 +0000
- Parent:
- 9:9ff473e9dfea
- Child:
- 11:f3de201aace6
- Commit message:
- Versuch 24.06.
Changed in this revision
| Blinker.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Blinker.cpp Mon Jun 23 11:17:06 2014 +0000
+++ b/Blinker.cpp Tue Jun 24 09:48:22 2014 +0000
@@ -2,23 +2,161 @@
//Hardware: Freescale FRDM KL25Z & SaintSmart LCD Keypad Shield
//Copyright: Andre Ehwein, Marcel Berrang, Daniel Knopp
-#include "mbed.h" //common library für mbed
-#include "TextLCD.h" //library für den LCD Shield
-#include "TSISensor.h" //library für den TSi Sensor Idee: Helligkeit der Blinker LEDs einstellen
-//#include "MMA8451Q.h" //library für den Beschleunigungssensor
+#include "mbed.h" //common library für mbed
+#include "TextLCD.h" //library für den LCD Shield
+#include "TSISensor.h" //library für den TSi Sensor Idee: Helligkeit der Blinker LEDs einstellen
+
+DigitalOut myLED_G(PTB19); // grüne LED auf dem Board
+DigitalOut myLED_R(PTB18); // rote LED auf dem Board
+//DigitalOut BlinkerL(PTE0); // Digitaler Ausgang für die Blinker links
+//DigitalOut BlinkerR(PTE1); // Digitaler Ausgang für die Blinker rechts
+//AnalogIn TasterS(PTB3); // Taster zum Rückstelen der Blinker
+//AnalogIn TasterL(PTB2); // Taster für Blinker links
+//AnalogIn TasterR(PTB1); // Taster für Blinker rechts
AnalogIn KEYS(PTB0); //Analog In um die Spannung an PTB0 zu bestimmen und die Buttons zu erkennen
-DigitalOut myLED_G(PTB19); //grüne LED Idee: stellt die grünen blinkenden Pfeile im Auto da
-DigitalOut BlinkerL(PTE0); // Digitaler Ausgang für die Blinker links
-DigitalOut BlinkerR(PTE1); // Digitaler Ausgang für die Blinker rechts
-AnalogIn TasterS(PTB3); // Taster zum Rückstelen der Blinker
-AnalogIn TasterL(PTB2); // Taster für Blinker links
-AnalogIn TasterR(PTB1); // Taster für Blinker rechts
-TextLCD lcd(PTA13, PTD5, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD16x2);
+TextLCD lcd(PTA13, PTD5, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD16x2); //Konfiguration des LCD-Keypad-Schields mit Pins: rs, e, d4, d5, d6, d7
+
+#define NO_KEY 0 //definiert die Keys des LCD Shields
+#define UP_KEY 1
+#define DOWN_KEY 2
+#define LEFT_KEY 3
+#define RIGHT_KEY 4
+#define SELECT_KEY 5
+//Funktions Prototypen
+void Programmwahl();
+int read_KEY();
+float z = 0.4; //Rythmus der Blinker
+int buttenState = 0;
+
+void BlinkerL();
+//void BlinkerR();
+//void BlinkerW();
int main()
{
+ myLED_G= 1;
+ myLED_R= 1;
+ lcd.cls();
+ lcd.locate(4,1);
+ lcd.printf("smartBIG");
+
+ Programmwahl();
+}
+
+
+
+void Programmwahl()
+{
+ lcd.cls();
+ lcd.locate(4,1);
+ lcd.printf("smartBIG");
+ while(1)
+ {
+ buttenState = read_KEY();
+ if (buttenState == LEFT_KEY)
+ {
+ BlinkerL();
+ }
+ }
+}
+
+
+
+void BlinkerL()
+{
+ buttenState = 0;
+ lcd.cls();
+ wait(z);
+ lcd.locate(1,0);
+ lcd.printf("<--");
+ lcd.locate(0,1);
+ lcd.printf("Blinker Links");
+ wait(z);
+ buttenState = read_KEY();
+
+ if (buttenState == LEFT_KEY)
+ {
+ SchleifeR:
+ lcd.cls();
+ wait(z);
+ lcd.locate(1,0);
+ lcd.printf("<--");
+ lcd.locate(0,1);
+ lcd.printf("Blinker Links");
+
+ if (buttenState == DOWN_KEY) //Abschaltbedingung
+ {Programmwahl();}
+ else {goto SchleifeR;}
+ }
+ else //Kompfortblinker
+ {
+ char x = 5;
+ for (x=5; x>=1; x--)
+ {
+ lcd.cls();
+ wait(z);
+ lcd.locate(15,0);
+ lcd.printf("%d%",x);
+ lcd.locate(1,0);
+ lcd.printf("<--");
+ lcd.locate(1,1);
+ lcd.printf("Komfortblinker");
+ wait(z);
+ }
+ Programmwahl();
+ }
+ }
+
+
+
+
+
+
+ /*
+
+ char x = 5;
+ for (x=5; x>=1; x--)
+ {
+ lcd.cls();
+ wait(z);
+ lcd.locate(15,0);
+ lcd.printf("%d%",x);
+ lcd.locate(1,0);
+ lcd.printf("<--");
+ lcd.locate(1,1);
+ lcd.printf("Komfortblinker");
+ wait(z);
+ }
+ Programmwahl();
+}
+
+*/
+
+
+int read_KEY() //Bestimmt, welche Taste gerade gedrückt wird
+{
+ int adc_key_in = 0;
+ adc_key_in = KEYS.read_u16 (); // read the value from the sensor //Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF].
+ // watch approching values for pushbutton and set table below
+ // add approx 500 for safety
+ if (adc_key_in > 65000) {return NO_KEY;}
+ if (adc_key_in < 50) {return RIGHT_KEY;}
+ //if (adc_key_in < 790) {return SELECT_KEY;}
+ if (adc_key_in < 15500) {return UP_KEY;}
+ if (adc_key_in < 34600) {return DOWN_KEY;}
+ if (adc_key_in < 54000) {return LEFT_KEY;}
+
+ return NO_KEY; //when no value readable, also return NO_KEY...
+}
+
+
+
+/*
+
+int main()
+{
char x = 5;
while(1)
{
@@ -82,17 +220,7 @@
}
-
-#define NO_KEY 0 //definiert die Keys des LCD Shields
-#define UP_KEY 1
-#define DOWN_KEY 2
-#define LEFT_KEY 3
-#define RIGHT_KEY 4
-#define SELECT_KEY 5
-
-//TextLCD lcd(PTA13, PTD5, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD16x2); //Konfiguration für das LCD Shield
int read_LCD_KEYS() //Bestimmt, welche Taste gerade gedrückt wird
-// lcd.cls();
{
int adc_key_in = 0;
adc_key_in = KEYS.read_u16 (); // read the value from the sensor //Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF].
@@ -107,4 +235,5 @@
return NO_KEY; //when no value readable, also return NO_KEY...
}
+*/
//Ende
\ No newline at end of file