keyboard input, serial com test

Dependencies:   mbed DISCO_L475VG_IOT01A_wifi TextLCD USBHost

Committer:
duchonic
Date:
Sat Aug 10 08:34:41 2019 +0000
Revision:
5:0466445897b8
Child:
6:9d975a9d2728
first

Who changed what in which revision?

UserRevisionLine numberNew contents of line
duchonic 5:0466445897b8 1 #include "TextLCD.h"
duchonic 5:0466445897b8 2 #include "mbed_assert.h"
duchonic 5:0466445897b8 3 #include <string>
duchonic 5:0466445897b8 4
duchonic 5:0466445897b8 5 TextLCD lcd(D8, D9, D4, D5, D6, D7); // LCD (RS, E, D4, D5, D6, D7);
duchonic 5:0466445897b8 6 PwmOut backlight(D10); // Backlight LCD
duchonic 5:0466445897b8 7
duchonic 5:0466445897b8 8 /*
duchonic 5:0466445897b8 9 ------> x
duchonic 5:0466445897b8 10 | (0,0)
duchonic 5:0466445897b8 11 | (15,1)
duchonic 5:0466445897b8 12 v y
duchonic 5:0466445897b8 13 */
duchonic 5:0466445897b8 14
duchonic 5:0466445897b8 15 const uint8_t FIRST_LINE=0;
duchonic 5:0466445897b8 16 const uint8_t SECOND_LINE=1;
duchonic 5:0466445897b8 17
duchonic 5:0466445897b8 18
duchonic 5:0466445897b8 19 void setCursor(uint8_t x, uint8_t y){
duchonic 5:0466445897b8 20 MBED_ASSERT(x <= 15);
duchonic 5:0466445897b8 21 MBED_ASSERT(y <= 1);
duchonic 5:0466445897b8 22 }
duchonic 5:0466445897b8 23
duchonic 5:0466445897b8 24 void setLine(uint8_t y){
duchonic 5:0466445897b8 25 MBED_ASSERT( y <= 1 );
duchonic 5:0466445897b8 26 lcd.locate(0,y);
duchonic 5:0466445897b8 27 }
duchonic 5:0466445897b8 28
duchonic 5:0466445897b8 29 void printLine(std::string text){
duchonic 5:0466445897b8 30 MBED_ASSERT(text.size()<=16);
duchonic 5:0466445897b8 31 lcd.printf(text.c_str());
duchonic 5:0466445897b8 32 }
duchonic 5:0466445897b8 33
duchonic 5:0466445897b8 34 void printLine(std::string text, uint8_t line){
duchonic 5:0466445897b8 35 MBED_ASSERT(text.size()<=16);
duchonic 5:0466445897b8 36 MBED_ASSERT(line <= 1);
duchonic 5:0466445897b8 37 lcd.cls(); // Clear LCD
duchonic 5:0466445897b8 38 lcd.locate(0,line); /* x/y */
duchonic 5:0466445897b8 39 lcd.printf(text.c_str());
duchonic 5:0466445897b8 40 }
duchonic 5:0466445897b8 41
duchonic 5:0466445897b8 42 void displayInit(void){
duchonic 5:0466445897b8 43 // Set backlight period and duty cycle
duchonic 5:0466445897b8 44 backlight.period(0.002);
duchonic 5:0466445897b8 45 backlight = 1;
duchonic 5:0466445897b8 46 lcd.cls(); // Clear LCD
duchonic 5:0466445897b8 47 lcd.locate(0,FIRST_LINE); /* x/y */
duchonic 5:0466445897b8 48 lcd.printf("testBoard");
duchonic 5:0466445897b8 49 }
duchonic 5:0466445897b8 50
duchonic 5:0466445897b8 51 void displayKey(char key){
duchonic 5:0466445897b8 52 lcd.cls(); // Clear LCD
duchonic 5:0466445897b8 53 lcd.locate(0,FIRST_LINE); /* x/y */
duchonic 5:0466445897b8 54 lcd.printf("%c", key);
duchonic 5:0466445897b8 55 }
duchonic 5:0466445897b8 56
duchonic 5:0466445897b8 57 void displayScreen(uint8_t nr){
duchonic 5:0466445897b8 58 switch(nr){
duchonic 5:0466445897b8 59 case 0:
duchonic 5:0466445897b8 60 {
duchonic 5:0466445897b8 61 lcd.cls();
duchonic 5:0466445897b8 62 setLine(FIRST_LINE);
duchonic 5:0466445897b8 63 printLine("keyboard det.");
duchonic 5:0466445897b8 64 break;
duchonic 5:0466445897b8 65 }
duchonic 5:0466445897b8 66 case 1:
duchonic 5:0466445897b8 67 {
duchonic 5:0466445897b8 68 lcd.cls();
duchonic 5:0466445897b8 69 setLine(SECOND_LINE);
duchonic 5:0466445897b8 70 printLine("buttons detected");
duchonic 5:0466445897b8 71 break;
duchonic 5:0466445897b8 72 }
duchonic 5:0466445897b8 73 }
duchonic 5:0466445897b8 74 }