mbed-os

Fork of mbed-os by erkin yucel

Committer:
xuaner
Date:
Thu Jul 20 14:26:57 2017 +0000
Revision:
1:3deb71413561
Parent:
0:f269e3021894
mbed_os

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elessair 0:f269e3021894 1 #include "mbed.h"
elessair 0:f269e3021894 2
elessair 0:f269e3021894 3 #if !DEVICE_LOCALFILESYSTEM
elessair 0:f269e3021894 4 #error [NOT_SUPPORTED] LocalFileSystem not supported
elessair 0:f269e3021894 5 #endif
elessair 0:f269e3021894 6
elessair 0:f269e3021894 7 #include "TextLCD.h"
elessair 0:f269e3021894 8
elessair 0:f269e3021894 9 int main() {
elessair 0:f269e3021894 10 printf("printf to stdout\n");
elessair 0:f269e3021894 11
elessair 0:f269e3021894 12 // printf to specific peripherals
elessair 0:f269e3021894 13 Serial pc(USBTX, USBRX);
elessair 0:f269e3021894 14 pc.printf("Serial(USBTX, USBRX).printf\n");
elessair 0:f269e3021894 15
elessair 0:f269e3021894 16 TextLCD lcd(p14, p15, p16, p17, p18, p19, p20, "lcd"); // rs, rw, e, d0-d3, name
elessair 0:f269e3021894 17 lcd.printf("TextLCD.printf\n");
elessair 0:f269e3021894 18
elessair 0:f269e3021894 19 // change stdout to file
elessair 0:f269e3021894 20 LocalFileSystem local("local");
elessair 0:f269e3021894 21 freopen("/local/output.txt", "w", stdout);
elessair 0:f269e3021894 22 printf("printf redirected to LocalFileSystem\n");
elessair 0:f269e3021894 23 fclose(stdout);
elessair 0:f269e3021894 24
elessair 0:f269e3021894 25 // change stdout to LCD
elessair 0:f269e3021894 26 freopen("/lcd", "w", stdout);
elessair 0:f269e3021894 27 printf("printf redirected to TextLCD\n");
elessair 0:f269e3021894 28 fclose(stdout);
elessair 0:f269e3021894 29
elessair 0:f269e3021894 30 DigitalOut led(LED1);
elessair 0:f269e3021894 31 while (true) {
elessair 0:f269e3021894 32 led = !led;
elessair 0:f269e3021894 33 wait(1);
elessair 0:f269e3021894 34 }
elessair 0:f269e3021894 35 }