Simple test program to get familiar with functionality of MBED RTOS on ST Nucleo-F411RE. Tasks for LED blinking, user button, temperature measurement with DS1620, temperature measurement with internal temperature sensor of ST32F411RE, ultrasonic distance measurement and displaying result on 16x2 TextLCD.
Dependencies: DS1620_improved TextLCD_improved mbed-rtos mbed
tsk_display.cpp@15:a627638edd9c, 2015-12-14 (annotated)
- Committer:
- dzoni
- Date:
- Mon Dec 14 21:46:45 2015 +0000
- Revision:
- 15:a627638edd9c
- Parent:
- 13:f62b10a6e1c5
- Child:
- 17:94c385ff2641
Hangs out in display ("Raw: 20" and that's all)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dzoni | 9:645f0e517017 | 1 | #include "mbed.h" |
dzoni | 9:645f0e517017 | 2 | #include "rtos.h" |
dzoni | 9:645f0e517017 | 3 | |
dzoni | 9:645f0e517017 | 4 | #include "TextLCD.h" |
dzoni | 9:645f0e517017 | 5 | |
dzoni | 9:645f0e517017 | 6 | #include "tsk_display.h" |
dzoni | 9:645f0e517017 | 7 | #include "tsk_temp.h" |
dzoni | 9:645f0e517017 | 8 | #include "tsk_dist.h" |
dzoni | 9:645f0e517017 | 9 | #include "tsk_main.h" |
dzoni | 9:645f0e517017 | 10 | |
dzoni | 15:a627638edd9c | 11 | static TextLCD *lcd; |
dzoni | 9:645f0e517017 | 12 | |
dzoni | 12:1de8b271e292 | 13 | uint32_t initDisplay(void const *args) { |
dzoni | 13:f62b10a6e1c5 | 14 | |
dzoni | 13:f62b10a6e1c5 | 15 | lcd = new TextLCD(PA_8, PA_7, PA_9, PA_1, PB_5, PA_10, TextLCD::LCD16x2); |
dzoni | 13:f62b10a6e1c5 | 16 | |
dzoni | 13:f62b10a6e1c5 | 17 | lcd->cls(); |
dzoni | 13:f62b10a6e1c5 | 18 | lcd->printf("Row 1"); |
dzoni | 13:f62b10a6e1c5 | 19 | lcd->locate(0, 1); |
dzoni | 13:f62b10a6e1c5 | 20 | lcd->printf("Row 2"); |
dzoni | 13:f62b10a6e1c5 | 21 | |
dzoni | 13:f62b10a6e1c5 | 22 | return 1; |
dzoni | 13:f62b10a6e1c5 | 23 | } |
dzoni | 13:f62b10a6e1c5 | 24 | |
dzoni | 13:f62b10a6e1c5 | 25 | uint32_t disposeDisplay(void const *args) { |
dzoni | 13:f62b10a6e1c5 | 26 | |
dzoni | 13:f62b10a6e1c5 | 27 | delete lcd; |
dzoni | 13:f62b10a6e1c5 | 28 | lcd = NULL; |
dzoni | 13:f62b10a6e1c5 | 29 | |
dzoni | 12:1de8b271e292 | 30 | return 1; |
dzoni | 12:1de8b271e292 | 31 | } |
dzoni | 12:1de8b271e292 | 32 | |
dzoni | 12:1de8b271e292 | 33 | |
dzoni | 9:645f0e517017 | 34 | void disp_thread(void const *args) { |
dzoni | 9:645f0e517017 | 35 | |
dzoni | 9:645f0e517017 | 36 | while (true) { |
dzoni | 13:f62b10a6e1c5 | 37 | lcd->cls(); |
dzoni | 13:f62b10a6e1c5 | 38 | lcd->printf("Raw:%3u % 5.0f mm", temp_data.temp_raw, dist_data.distance); |
dzoni | 15:a627638edd9c | 39 | // uiCnt += 2; |
dzoni | 13:f62b10a6e1c5 | 40 | lcd->locate(0, 1); |
dzoni | 13:f62b10a6e1c5 | 41 | lcd->printf("Float: %3.2f%cC", temp_data.temperature, 0xdf); |
dzoni | 12:1de8b271e292 | 42 | |
dzoni | 15:a627638edd9c | 43 | Thread::wait(1896); |
dzoni | 9:645f0e517017 | 44 | } |
dzoni | 13:f62b10a6e1c5 | 45 | } |