Stanley Cohen
/
Serial_IO_test_v1
KL46Z Serial I/O to and from PC/MAC for Ambient computing. Basic structure.
Revision 0:f940d73ac15c, committed 2015-03-05
- Comitter:
- scohennm
- Date:
- Thu Mar 05 00:28:46 2015 +0000
- Commit message:
- KL46Z Serial I/O to and from PC/MAC for Ambient computing. Basic structure.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SLCD.lib Thu Mar 05 00:28:46 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/SLCD/#ef2b3b7f1b01
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Mar 05 00:28:46 2015 +0000 @@ -0,0 +1,42 @@ +#include "mbed.h" +#include "SLCD.h" + +#define LCDLEN 10 +#define MAXCHAR 4 +#define LCD_UPDATE_TIME 100 // in ms +#define LEDBLINKTIME 0.2f +#define ALL8 "8888" + + +DigitalOut rLed(LED_RED); + + +Serial pc(USBTX, USBRX); // tx, rx +SLCD slcd; //define LCD display +char rxChar; +int charIndex = 0; +char rxString[LCDLEN]; + +void LCDMessNoDwell(char *lMess){ + slcd.Home(); + slcd.clear(); + slcd.printf(lMess); +} + + +int main() +{ + LCDMessNoDwell(ALL8); // just put something on the LCD to show it's working + + while (true) { + rLed = !rLed; // toggle led + if (pc.readable()) { // only read from the serial port if there is a character + rxChar= pc.getc(); // reading clears the buffer + pc.printf("%c\n\r", rxChar); // echo that character + rxString[charIndex] = rxChar; // construct a 4-digi string for the LCD + charIndex = (charIndex + 1 )% MAXCHAR; // Only allow 4 characters the roll over + LCDMessNoDwell(rxString); // display it + } + wait(LEDBLINKTIME); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Mar 05 00:28:46 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac \ No newline at end of file