han back
/
CLEO_UART_TEXTLCD
SMART CLEO Uart Text Lcd
Revision 1:d05971975fdc, committed 2017-09-28
- Comitter:
- SMART_CLEO
- Date:
- Thu Sep 28 06:29:59 2017 +0000
- Parent:
- 0:21b4d8237564
- Commit message:
- SMART_CLEO
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 21b4d8237564 -r d05971975fdc main.cpp --- a/main.cpp Thu Sep 28 03:42:07 2017 +0000 +++ b/main.cpp Thu Sep 28 06:29:59 2017 +0000 @@ -16,19 +16,16 @@ Serial SerialUART(PA_2, PA_3); -UART_buf RX_BUF; +volatile UART_buf RX_BUF; void SerialUARTRX_ISR(void); -void LCD_printf(uint8_t *data, uint8_t len); int main() { - uint8_t ab[3] = {1, 2, 3}; SerialUART.baud(115200); SerialUART.attach(&SerialUARTRX_ISR); - - LCD_printf(ab, 3); + while(1) { } @@ -38,6 +35,7 @@ { static uint8_t RX_count = 0, RX_Len = 32, RX_Status = 0; uint8_t rx_da = SerialUART.getc(); + char buf[32]; switch(RX_Status) { case 0: @@ -82,25 +80,18 @@ case 0x01: if(RX_BUF.CMD == 0x18) { - LCD_printf(&RX_BUF.DATA[0], RX_BUF.LEN); + lcd.locate(0, 0); + for(int i=0; i<32; i++) + { + if(i<RX_BUF.LEN) + lcd.putc(RX_BUF.DATA[i]); + else + lcd.putc(0x20); + } } break; } } break; } -} - -void LCD_printf(uint8_t *data, uint8_t len) -{ - char buf[32]; - for(int i=0; i<32; i++) - { - if(i<len) - buf[i] = data[i]; - else - buf[i] = 0x20; - } - lcd.locate(0, 0); - lcd.printf(buf); } \ No newline at end of file