LCD implementation of our project.
Dependencies: mbed mbed-rtos MLX90614
Thermometer.cpp@8:81ed1135ba02, 2015-06-03 (annotated)
- Committer:
- ovidiup13
- Date:
- Wed Jun 03 16:37:21 2015 +0000
- Revision:
- 8:81ed1135ba02
done something, idk what
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ovidiup13 | 8:81ed1135ba02 | 1 | #include "Thermometer.h" |
ovidiup13 | 8:81ed1135ba02 | 2 | |
ovidiup13 | 8:81ed1135ba02 | 3 | Thermometer::Thermometer(ST7565 *lcd, Item *back, DigitalOut *gyro, DigitalOut *thermo){ |
ovidiup13 | 8:81ed1135ba02 | 4 | this->title = " Thermometer"; |
ovidiup13 | 8:81ed1135ba02 | 5 | this->st7565 = lcd; |
ovidiup13 | 8:81ed1135ba02 | 6 | this->back = back; |
ovidiup13 | 8:81ed1135ba02 | 7 | this->gyro = gyro; |
ovidiup13 | 8:81ed1135ba02 | 8 | this->thermo = thermo; |
ovidiup13 | 8:81ed1135ba02 | 9 | tt = NULL; |
ovidiup13 | 8:81ed1135ba02 | 10 | } |
ovidiup13 | 8:81ed1135ba02 | 11 | |
ovidiup13 | 8:81ed1135ba02 | 12 | void Thermometer::display(void){ |
ovidiup13 | 8:81ed1135ba02 | 13 | if(tt != NULL) return; |
ovidiup13 | 8:81ed1135ba02 | 14 | gyro->write(0); thermo->write(1); |
ovidiup13 | 8:81ed1135ba02 | 15 | tt = new Thread(&Thermometer::tt_start, this); |
ovidiup13 | 8:81ed1135ba02 | 16 | tt->signal_set(START_THREAD); |
ovidiup13 | 8:81ed1135ba02 | 17 | } |
ovidiup13 | 8:81ed1135ba02 | 18 | |
ovidiup13 | 8:81ed1135ba02 | 19 | void Thermometer::tt_start(const void * args){ |
ovidiup13 | 8:81ed1135ba02 | 20 | Thermometer *t = (Thermometer*)args; |
ovidiup13 | 8:81ed1135ba02 | 21 | t->display_temperature(); |
ovidiup13 | 8:81ed1135ba02 | 22 | } |
ovidiup13 | 8:81ed1135ba02 | 23 | |
ovidiup13 | 8:81ed1135ba02 | 24 | void Thermometer::display_temperature(){ |
ovidiup13 | 8:81ed1135ba02 | 25 | tt->signal_wait(START_THREAD); |
ovidiup13 | 8:81ed1135ba02 | 26 | |
ovidiup13 | 8:81ed1135ba02 | 27 | float temp; |
ovidiup13 | 8:81ed1135ba02 | 28 | char temp_char[50]; |
ovidiup13 | 8:81ed1135ba02 | 29 | while(1){ |
ovidiup13 | 8:81ed1135ba02 | 30 | temp = get_temperature(); |
ovidiup13 | 8:81ed1135ba02 | 31 | //get temperature and display it |
ovidiup13 | 8:81ed1135ba02 | 32 | sprintf(temp_char, "Temperature is: %0.2f", temp); |
ovidiup13 | 8:81ed1135ba02 | 33 | st7565->drawstring(5, 3, temp_char); |
ovidiup13 | 8:81ed1135ba02 | 34 | st7565->display(); |
ovidiup13 | 8:81ed1135ba02 | 35 | Thread::wait(15); |
ovidiup13 | 8:81ed1135ba02 | 36 | st7565->clear(); |
ovidiup13 | 8:81ed1135ba02 | 37 | } |
ovidiup13 | 8:81ed1135ba02 | 38 | } |
ovidiup13 | 8:81ed1135ba02 | 39 | |
ovidiup13 | 8:81ed1135ba02 | 40 | void Thermometer::update(char c){ |
ovidiup13 | 8:81ed1135ba02 | 41 | if(c == 'y'){ |
ovidiup13 | 8:81ed1135ba02 | 42 | tt->terminate(); |
ovidiup13 | 8:81ed1135ba02 | 43 | free(tt); tt = NULL; |
ovidiup13 | 8:81ed1135ba02 | 44 | thermo->write(0); |
ovidiup13 | 8:81ed1135ba02 | 45 | st7565->clear(); |
ovidiup13 | 8:81ed1135ba02 | 46 | this->setSelectedScreen(back); |
ovidiup13 | 8:81ed1135ba02 | 47 | } |
ovidiup13 | 8:81ed1135ba02 | 48 | } |
ovidiup13 | 8:81ed1135ba02 | 49 | |
ovidiup13 | 8:81ed1135ba02 | 50 | |
ovidiup13 | 8:81ed1135ba02 | 51 |