Mark Hellyer
/
HelloWorldTerminal
Formatted strings to serial port plus flashing led
main.cpp@0:dce6037f5901, 2018-07-09 (annotated)
- Committer:
- MarkAntony
- Date:
- Mon Jul 09 23:17:01 2018 +0000
- Revision:
- 0:dce6037f5901
testing mbed-cli import functions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MarkAntony | 0:dce6037f5901 | 1 | #include "mbed.h" |
MarkAntony | 0:dce6037f5901 | 2 | |
MarkAntony | 0:dce6037f5901 | 3 | Serial pc(USBTX, USBRX); // tx, rx |
MarkAntony | 0:dce6037f5901 | 4 | DigitalOut MyLed1(LED1); |
MarkAntony | 0:dce6037f5901 | 5 | |
MarkAntony | 0:dce6037f5901 | 6 | int main() |
MarkAntony | 0:dce6037f5901 | 7 | { |
MarkAntony | 0:dce6037f5901 | 8 | pc.baud(9600); |
MarkAntony | 0:dce6037f5901 | 9 | while(1) { |
MarkAntony | 0:dce6037f5901 | 10 | printf ("Characters: %c %c \n\r", 'a', 65); |
MarkAntony | 0:dce6037f5901 | 11 | printf ("Decimals: %d %ld\n\r", 1977, 650000L); |
MarkAntony | 0:dce6037f5901 | 12 | // Reverse video: |
MarkAntony | 0:dce6037f5901 | 13 | //printf ("\033[7m"); |
MarkAntony | 0:dce6037f5901 | 14 | printf ("Preceding with blanks: %10d \n\r", 1977); |
MarkAntony | 0:dce6037f5901 | 15 | printf ("Preceding with zeros: %010d \n\r", 1977); |
MarkAntony | 0:dce6037f5901 | 16 | printf ("Some different radixes: %d %x %o %#x %#o \n\r", 100, 100, 100, 100, 100); |
MarkAntony | 0:dce6037f5901 | 17 | printf ("floats: %4.2f %+.0e %E \n\r", 3.1416, 3.1416, 3.1416); |
MarkAntony | 0:dce6037f5901 | 18 | printf ("Width trick: %*d \n\r", 5, 10); |
MarkAntony | 0:dce6037f5901 | 19 | printf ("%s \n\r", "A string"); |
MarkAntony | 0:dce6037f5901 | 20 | //Clear screen upwards |
MarkAntony | 0:dce6037f5901 | 21 | //printf ("\033[1J"); |
MarkAntony | 0:dce6037f5901 | 22 | MyLed1 = !MyLed1; |
MarkAntony | 0:dce6037f5901 | 23 | wait(1.0); |
MarkAntony | 0:dce6037f5901 | 24 | } |
MarkAntony | 0:dce6037f5901 | 25 | } |