
Programm zur Darstellung der Lage eines Objektes im Raum mit Hilfe eines Beschleunigungssensores, 4 LED's und einem LCD-Display.
LCD.cpp@14:2543a798b4a1, 2016-06-30 (annotated)
- Committer:
- Schreeker
- Date:
- Thu Jun 30 18:56:35 2016 +0000
- Revision:
- 14:2543a798b4a1
- Parent:
- 11:5861bc23022a
- Child:
- 15:462c8c89fe35
initLCD hinzugef?gt (Introtext bei Programmstart auf Display). Kalibrierung ueberprueft. Alles ok. Simon Rutzen Ausstehend: Einstellen der LED's durch Auswertung der Winkel!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Schreeker | 0:2a6b63a19ae5 | 1 | /********************************************************************************** |
Schreeker | 0:2a6b63a19ae5 | 2 | * File name: LCD.cpp |
Schreeker | 0:2a6b63a19ae5 | 3 | * Zweck: Beinhaltet alle Funktionen zur Ausgabe von Informationen |
Schreeker | 0:2a6b63a19ae5 | 4 | auf dem LCD-Display, sowie Funktionen zum Debuggen des Projektes |
Schreeker | 0:2a6b63a19ae5 | 5 | * Author: Simon Rutzen, Nils Kemmer |
Schreeker | 0:2a6b63a19ae5 | 6 | * Changes: keine |
Schreeker | 0:2a6b63a19ae5 | 7 | ***********************************************************************************/ |
Schreeker | 0:2a6b63a19ae5 | 8 | |
Schreeker | 0:2a6b63a19ae5 | 9 | /* Includes */ |
Schreeker | 0:2a6b63a19ae5 | 10 | #include "LCD.h" |
Schreeker | 0:2a6b63a19ae5 | 11 | |
Schreeker | 0:2a6b63a19ae5 | 12 | /* Objekt zum Steuern des Bildschirmes */ |
Schreeker | 0:2a6b63a19ae5 | 13 | TextLCD olcd(PA_9, PC_7, PB_5, PB_4, PB_10, PA_8, TextLCD::LCD20x2); // rs, e, d4-d7 |
Schreeker | 0:2a6b63a19ae5 | 14 | |
Schreeker | 0:2a6b63a19ae5 | 15 | /************************************************************************************ |
Schreeker | 0:2a6b63a19ae5 | 16 | * void vLCDSet(word wWinkelX, word wWinkelY) |
Schreeker | 0:2a6b63a19ae5 | 17 | * Zweck: Funktion zur Darstellung der aktuellen X- und Y-Lage (in °) |
Schreeker | 0:2a6b63a19ae5 | 18 | des Beschleunigungssensores auf dem LCD-Display |
Schreeker | 0:2a6b63a19ae5 | 19 | * Parameter: |
Schreeker | 0:2a6b63a19ae5 | 20 | wWinkelX: aktueller Winkel bezogen auf die X-Achse des Beschleunigungssensores |
Schreeker | 0:2a6b63a19ae5 | 21 | wWinkelY: aktueller Winkel bezogen auf die Y-Achse des Beschleunigungssensores |
Schreeker | 0:2a6b63a19ae5 | 22 | * return Parameter: |
Schreeker | 0:2a6b63a19ae5 | 23 | keine |
Schreeker | 0:2a6b63a19ae5 | 24 | *************************************************************************************/ |
Schreeker | 9:38d287593320 | 25 | void vLCDSet(signed short int wWinkelX, signed short int wWinkelY){ |
Schreeker | 5:c0d6d490dd5b | 26 | /* Bildschirm bereinigen*/ |
Schreeker | 5:c0d6d490dd5b | 27 | olcd.cls(); |
Schreeker | 7:882edb5f9466 | 28 | |
Schreeker | 0:2a6b63a19ae5 | 29 | /* Überschrift in erster Zeile darstellen */ |
Schreeker | 0:2a6b63a19ae5 | 30 | olcd.locate(0,0); |
Schreeker | 0:2a6b63a19ae5 | 31 | olcd.printf("Lage:"); |
Schreeker | 0:2a6b63a19ae5 | 32 | |
Schreeker | 0:2a6b63a19ae5 | 33 | /* aktuelle Winkel darstellen in ° */ |
Schreeker | 0:2a6b63a19ae5 | 34 | olcd.locate(0,1); |
Schreeker | 7:882edb5f9466 | 35 | olcd.printf("X:%i\337 Y:%i\337",wWinkelX,wWinkelY); // \337 entspricht °-Zeichen |
Schreeker | 11:5861bc23022a | 36 | } |
Schreeker | 11:5861bc23022a | 37 | |
Schreeker | 11:5861bc23022a | 38 | /************************************************************************************ |
Schreeker | 11:5861bc23022a | 39 | * void vLCDDebug(signed short int wWinkelX, signed short int wWinkelY, signed short int wWinkelZ) |
Schreeker | 11:5861bc23022a | 40 | * Zweck: Debugfunktion zum Anzeigen der aktuellen Messwerte des Beschleunigungssensores |
Schreeker | 11:5861bc23022a | 41 | zwecks Kalibrierung der einzelnen Nullpunkte der Achsen |
Schreeker | 11:5861bc23022a | 42 | * Parameter: |
Schreeker | 11:5861bc23022a | 43 | wWinkelX: aktueller Winkel bezogen auf die X-Achse des Beschleunigungssensores |
Schreeker | 11:5861bc23022a | 44 | wWinkelY: aktueller Winkel bezogen auf die Y-Achse des Beschleunigungssensores |
Schreeker | 11:5861bc23022a | 45 | wWinkelZ: aktueller Winkel bezogen auf die Y-Achse des Beschleunigungssensores |
Schreeker | 11:5861bc23022a | 46 | Hinweis: Alle Winkelwerte sind Spannungswerte des Sensores mit Faktor 10000 multipliziert! |
Schreeker | 11:5861bc23022a | 47 | * return Parameter: |
Schreeker | 11:5861bc23022a | 48 | keine |
Schreeker | 11:5861bc23022a | 49 | *************************************************************************************/ |
Schreeker | 11:5861bc23022a | 50 | void vLCDDebug(signed short int wWinkelX, signed short int wWinkelY, signed short int wWinkelZ){ |
Schreeker | 11:5861bc23022a | 51 | /* Bildschirm bereinigen */ |
Schreeker | 11:5861bc23022a | 52 | olcd.cls(); |
Schreeker | 11:5861bc23022a | 53 | |
Schreeker | 11:5861bc23022a | 54 | /* Anzeigen der einzelnen Parameter, oben X und Y, unten Z */ |
Schreeker | 11:5861bc23022a | 55 | olcd.locate(0,0); |
Schreeker | 11:5861bc23022a | 56 | olcd.printf("X:%i Y:%i",wWinkelX,wWinkelY); |
Schreeker | 11:5861bc23022a | 57 | olcd.locate(0,1); |
Schreeker | 11:5861bc23022a | 58 | olcd.printf("Z:%i",wWinkelZ); |
Schreeker | 14:2543a798b4a1 | 59 | } |
Schreeker | 14:2543a798b4a1 | 60 | |
Schreeker | 14:2543a798b4a1 | 61 | /************************************************************************************ |
Schreeker | 14:2543a798b4a1 | 62 | * void initLCD() |
Schreeker | 14:2543a798b4a1 | 63 | * Zweck: Anzeigen des Initialtextes zum Programmstart. |
Schreeker | 14:2543a798b4a1 | 64 | * Parameter: |
Schreeker | 14:2543a798b4a1 | 65 | keine |
Schreeker | 14:2543a798b4a1 | 66 | * return Parameter: |
Schreeker | 14:2543a798b4a1 | 67 | keine |
Schreeker | 14:2543a798b4a1 | 68 | *************************************************************************************/ |
Schreeker | 14:2543a798b4a1 | 69 | void initLCD(){ |
Schreeker | 14:2543a798b4a1 | 70 | /* Löschen des Bildschirmes */ |
Schreeker | 14:2543a798b4a1 | 71 | olcd.cls(); |
Schreeker | 14:2543a798b4a1 | 72 | |
Schreeker | 14:2543a798b4a1 | 73 | /* Anzeigen des Initialtextes */ |
Schreeker | 14:2543a798b4a1 | 74 | olcd.locate(3,0); |
Schreeker | 14:2543a798b4a1 | 75 | olcd.printf("Lagesensor"); |
Schreeker | 14:2543a798b4a1 | 76 | |
Schreeker | 14:2543a798b4a1 | 77 | olcd.locate(1,1); |
Schreeker | 14:2543a798b4a1 | 78 | olcd.printf("Nils und Simon"); |
Schreeker | 11:5861bc23022a | 79 | } |