![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Differential pressure meter
Dependencies: TFT_Touch_WaveShare
main.cpp@1:c311d5f59c8b, 2018-04-03 (annotated)
- Committer:
- igbt6
- Date:
- Tue Apr 03 20:13:35 2018 +0000
- Revision:
- 1:c311d5f59c8b
- Parent:
- 0:619824763516
Differential pressure meter
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igbt6 | 0:619824763516 | 1 | #include "mbed.h" |
igbt6 | 0:619824763516 | 2 | #include "stdio.h" |
igbt6 | 0:619824763516 | 3 | #include "SPI_TFT.h" |
igbt6 | 0:619824763516 | 4 | #include "string" |
igbt6 | 0:619824763516 | 5 | #include "Arial12x12.h" |
igbt6 | 0:619824763516 | 6 | #include "Arial24x23.h" |
igbt6 | 0:619824763516 | 7 | |
igbt6 | 0:619824763516 | 8 | void print_char(char c = '*') |
igbt6 | 0:619824763516 | 9 | { |
igbt6 | 0:619824763516 | 10 | printf("%c", c); |
igbt6 | 0:619824763516 | 11 | fflush(stdout); |
igbt6 | 0:619824763516 | 12 | } |
igbt6 | 0:619824763516 | 13 | |
igbt6 | 0:619824763516 | 14 | Thread thread; |
igbt6 | 0:619824763516 | 15 | |
igbt6 | 0:619824763516 | 16 | DigitalOut led1(LED1); |
igbt6 | 0:619824763516 | 17 | |
igbt6 | 0:619824763516 | 18 | void print_thread() |
igbt6 | 0:619824763516 | 19 | { |
igbt6 | 0:619824763516 | 20 | while (true) { |
igbt6 | 0:619824763516 | 21 | wait(1); |
igbt6 | 0:619824763516 | 22 | print_char(); |
igbt6 | 0:619824763516 | 23 | } |
igbt6 | 0:619824763516 | 24 | } |
igbt6 | 0:619824763516 | 25 | |
igbt6 | 0:619824763516 | 26 | int main() |
igbt6 | 0:619824763516 | 27 | { |
igbt6 | 0:619824763516 | 28 | printf("\n\n*** RTOS basic example ***\n"); |
igbt6 | 0:619824763516 | 29 | |
igbt6 | 0:619824763516 | 30 | thread.start(print_thread); |
igbt6 | 0:619824763516 | 31 | |
igbt6 | 0:619824763516 | 32 | |
igbt6 | 0:619824763516 | 33 | |
igbt6 | 0:619824763516 | 34 | // the TFT is connected to SPI |
igbt6 | 0:619824763516 | 35 | // PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset |
igbt6 | 0:619824763516 | 36 | SPI_TFT TFT(PA_7, PA_6, PA_5, PB_6, PA_8,"TFT"); // mosi, miso, sclk, cs, reset |
igbt6 | 0:619824763516 | 37 | |
igbt6 | 0:619824763516 | 38 | TFT.claim(stdout); // send stdout to the TFT display |
igbt6 | 0:619824763516 | 39 | TFT.claim(stderr); // send stderr to the TFT display |
igbt6 | 0:619824763516 | 40 | |
igbt6 | 0:619824763516 | 41 | TFT.background(Black); // set background to black |
igbt6 | 0:619824763516 | 42 | TFT.foreground(White); // set chars to white |
igbt6 | 0:619824763516 | 43 | TFT.cls(); // clear the screen |
igbt6 | 0:619824763516 | 44 | TFT.set_font((unsigned char*) Arial12x12); // select the font |
igbt6 | 0:619824763516 | 45 | |
igbt6 | 0:619824763516 | 46 | TFT.set_orientation(0); |
igbt6 | 0:619824763516 | 47 | TFT.locate(0,0); |
igbt6 | 0:619824763516 | 48 | printf(" Hello Mbed 0"); |
igbt6 | 0:619824763516 | 49 | TFT.set_font((unsigned char*) Arial24x23); // select font 2 |
igbt6 | 0:619824763516 | 50 | TFT.locate(2,5); |
igbt6 | 0:619824763516 | 51 | TFT.printf("Bigger Font"); |
igbt6 | 0:619824763516 | 52 | |
igbt6 | 0:619824763516 | 53 | while (true) { |
igbt6 | 0:619824763516 | 54 | led1 = !led1; |
igbt6 | 0:619824763516 | 55 | wait(0.5); |
igbt6 | 0:619824763516 | 56 | } |
igbt6 | 0:619824763516 | 57 | } |