Use display to show serial message Only for test
Dependencies: EFM32_SegmentLCD IOFuncLib mbed
Revision 1:08217ba7f63c, committed 2015-07-19
- Comitter:
- MaxScorda
- Date:
- Sun Jul 19 00:26:13 2015 +0000
- Parent:
- 0:c0d5dcd1de43
- Commit message:
- Correct serial implementation; String=7 or "X"; Time
Changed in this revision
Functions.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r c0d5dcd1de43 -r 08217ba7f63c Functions.h --- a/Functions.h Thu Jul 16 21:06:45 2015 +0000 +++ b/Functions.h Sun Jul 19 00:26:13 2015 +0000 @@ -22,7 +22,7 @@ void serialCb(int events) { - /* Something triggered the callback, either buffer is full or 'S' is received */ + /* Something triggered the callback, either buffer is full or '\n' is received */ unsigned char i; string stringout; @@ -30,14 +30,8 @@ //Received 'S', check for buffer length for(i = 0; i < BUFF_LENGTH; i++) { //Found the length! - stringout=stringout+fnz.char2string(rx_buf[i]); - if ((rx_buf[i] == '\n')||(i==BUFF_LENGTH-1)) { - segmentDisplay.Write((char *)rx_buf); - //oppure - // segmentDisplay.Write((char *) stringout.c_str()); - break; - } + if ((rx_buf[i] == '\n') || (rx_buf[i] == 'X')) break; } // Toggle blinking @@ -59,12 +53,16 @@ i = 3; } + segmentDisplay.Write((char *)rx_buf); + //oppure + // segmentDisplay.Write((char *) stringout.c_str()); + // Echo string, no callback test_connection.write(rx_buf, i+1, 0, 0); // Reset serial reception - test_connection.read(rx_buf, BUFF_LENGTH, serialEventCb, SERIAL_EVENT_RX_ALL, 'S'); + test_connection.read(rx_buf, BUFF_LENGTH, serialEventCb, SERIAL_EVENT_RX_ALL, 'X'); } void tickerCallback(void); \ No newline at end of file
diff -r c0d5dcd1de43 -r 08217ba7f63c main.cpp --- a/main.cpp Thu Jul 16 21:06:45 2015 +0000 +++ b/main.cpp Sun Jul 19 00:26:13 2015 +0000 @@ -9,12 +9,12 @@ /*------------ Constant definitions --------------*/ #define TX_PIN USBTX #define RX_PIN USBRX -#define BRATE 115200 +#define BRATE 9600 #define LED_PIN LED1 -#define TOGGLE_RATE (0.5f) -#define BUFF_LENGTH 5 +#define TOGGLE_RATE (1.0f) +#define BUFF_LENGTH 7 -#define INIT_SECONDS 17600 +#define INIT_SECONDS 0 /*-------- Check if platform compatible ----------*/ #if DEVICE_SERIAL_ASYNCH @@ -53,8 +53,8 @@ /* Setup serial connection */ test_connection.baud(BRATE); - test_connection.printf("Low Power API test\n\nSend 'S' to toggle blinking\n"); - test_connection.read(rx_buf, BUFF_LENGTH, serialEventCb, SERIAL_EVENT_RX_ALL, 'S'); + test_connection.printf("Low Power API test\n\nSend 'X' to toggle blinking\n"); + test_connection.read(rx_buf, BUFF_LENGTH, serialEventCb, SERIAL_EVENT_RX_ALL, 'X'); /* Let the callbacks take care of everything */ refreshTicker.attach(&tickerCallback, 1.0f);