Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C12832_lcd mbed-rtos mbed
Fork of rtos_mail by
main.cpp
00001 #include "mbed.h" 00002 #include "rtos.h" 00003 #include "C12832_lcd.h" 00004 00005 C12832_LCD lcd; 00006 00007 /* Mail */ 00008 typedef struct { 00009 float temp; 00010 float humid; 00011 float illumi; 00012 // uint32_t count; 00013 } mail_t; 00014 00015 Mail<mail_t, 16> mail_box; 00016 00017 void send_thread (void const *args) { 00018 uint32_t count= 0; 00019 while (true) { 00020 count++; // fake data update 00021 mail_t *mail = mail_box.alloc(); 00022 mail->temp = ( count * 0.1) * 30; 00023 mail->humid = (count * 0.1) * 50; 00024 mail->illumi = (count * 0.1) * 50; 00025 // mail->count = count; 00026 mail_box.put(mail); 00027 Thread::wait(1000); 00028 } 00029 } 00030 00031 int main (void) { 00032 Thread thread(send_thread); 00033 00034 while (true) { 00035 osEvent evt = mail_box.get(); 00036 if (evt.status == osEventMail) { 00037 mail_t *mail = (mail_t*)evt.value.p; 00038 lcd.printf("temp: %.2f \n\r" , mail->temp); 00039 lcd.printf("humid: %.2f \n\r" , mail->humid); 00040 lcd.printf("illumination: %.2f \n\r" , mail->illumi); 00041 // lcd.printf("Number of cycles: %u\n\r", mail->counter); 00042 00043 mail_box.free(mail); 00044 } 00045 } 00046 }
Generated on Fri Jul 22 2022 03:31:33 by
1.7.2
