![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A mbed RTOS based multimeter application that sends results to a phone over the Bluetooth module.
Dependencies: LCD_DISCO_F429ZI mbed mbed-rtos BSP_DISCO_F429ZI
main.cpp
- Committer:
- hunter64288
- Date:
- 2021-01-17
- Revision:
- 12:441ee5b1cf71
- Parent:
- 11:0309bef74ba8
- Child:
- 13:d21f6477ba19
File content as of revision 12:441ee5b1cf71:
#include "mbed.h" #include "rtos.h" #include "LCD_DISCO_F429ZI.h" //#include <AnalogIn.h> //float message_t //MemoryPool<message_t, 10> mpool; //Queue<message_t, > queue; Serial bluetooth(PA_9, PA_10);//Tx, Rx AnalogIn ain(PA_0); //potentiometer DigitalOut led1(LED1); DigitalOut led2(LED2); //DigitalIn btn1(PA_0); //Button on your Nucleo Board LCD_DISCO_F429ZI lcd; Thread thread1; //thread(osPriority osPriorityNormal) Thread thread2; void thread1_function() { lcd.Clear(LCD_COLOR_WHITE); lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"TASK1 RUNNING", CENTER_MODE); printf("Task1 Running\n\r"); //DigitalOut led1(LED1); //led1 = !led1; float samples[10]; float volt_value[10]; while(1) { for(int i=0; i<10; i++) { //ain.set_reference_voltage(3.0); samples[i] = ain.read()*3; //volt_value[i] = (((float)samples[i])/255.0)*3.0; wait(0.001f); } bluetooth.printf("Results:\n"); for(int i=0; i<10; i++) { bluetooth.printf("%d = , %f\n", i, samples[i]); } Thread::wait(1000); } } void thread2_function() { lcd.DisplayStringAt(0, LINE(2), (uint8_t *)"TASK2 RUNNING", CENTER_MODE); printf("Task2 Running\n\r"); while(true) { //float i=0; //led2 = !led2; bluetooth.printf("Hello World !\r\n"); Thread::wait(1000); //bluetooth.printf("This program runs since %f seconds.\r\n", i++); } } int main() { printf("We are in main.\n\r"); thread1.set_priority(osPriorityHigh); thread2.set_priority(osPriorityNormal); thread1.start(thread1_function); // Starting the processes thread2.start(thread2_function); thread1.join(); thread2.join(); //wait for threads to complete printf("The end of main.\n\r"); }