keyboard input, serial com test

Dependencies:   mbed DISCO_L475VG_IOT01A_wifi TextLCD USBHost

Committer:
duchonic
Date:
Thu Aug 15 19:33:04 2019 +0000
Revision:
6:9d975a9d2728
Parent:
5:0466445897b8
first

Who changed what in which revision?

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