]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/tests/mbed/freopen/main.cpp
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / tests / mbed / freopen / main.cpp
1 #include "mbed.h"
2 #include "TextLCD.h"
3
4 int main() {
5 printf("printf to stdout\n");
6
7 // printf to specific peripherals
8 Serial pc(USBTX, USBRX);
9 pc.printf("Serial(USBTX, USBRX).printf\n");
10
11 TextLCD lcd(p14, p15, p16, p17, p18, p19, p20, "lcd"); // rs, rw, e, d0-d3, name
12 lcd.printf("TextLCD.printf\n");
13
14 // change stdout to file
15 LocalFileSystem local("local");
16 freopen("/local/output.txt", "w", stdout);
17 printf("printf redirected to LocalFileSystem\n");
18 fclose(stdout);
19
20 // change stdout to LCD
21 freopen("/lcd", "w", stdout);
22 printf("printf redirected to TextLCD\n");
23 fclose(stdout);
24
25 DigitalOut led(LED1);
26 while (true) {
27 led = !led;
28 wait(1);
29 }
30 }
Imprint / Impressum