LCD implementation of our project.

Dependencies:   mbed mbed-rtos MLX90614

Committer:
ovidiup13
Date:
Wed Jun 03 12:22:46 2015 +0000
Revision:
7:11675c1dce4f
Parent:
3:688b62ff6474
Child:
8:81ed1135ba02
updated header, cleaned up menu, fixed controls for device

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ovidiup13 3:688b62ff6474 1 #include "Measure.h"
ovidiup13 3:688b62ff6474 2
ovidiup13 3:688b62ff6474 3 void Measure::display(void){
ovidiup13 3:688b62ff6474 4 this->display_items();
ovidiup13 3:688b62ff6474 5 }
ovidiup13 3:688b62ff6474 6
ovidiup13 3:688b62ff6474 7 void Measure::update(char c){
ovidiup13 3:688b62ff6474 8 //select down
ovidiup13 3:688b62ff6474 9 if(c == 's'){
ovidiup13 3:688b62ff6474 10 if(selected == 2) return; //do nothing
ovidiup13 3:688b62ff6474 11 selected = 2;
ovidiup13 3:688b62ff6474 12 current_line = 7;
ovidiup13 3:688b62ff6474 13 }
ovidiup13 3:688b62ff6474 14 //select up
ovidiup13 3:688b62ff6474 15 else if(c == 'w'){
ovidiup13 3:688b62ff6474 16 if(selected == 1) return; //do nothing
ovidiup13 3:688b62ff6474 17 selected = 1;
ovidiup13 3:688b62ff6474 18 current_line = 6;
ovidiup13 3:688b62ff6474 19 }
ovidiup13 3:688b62ff6474 20 //go to next screen
ovidiup13 3:688b62ff6474 21 else if(c == 'y'){
ovidiup13 3:688b62ff6474 22 if(selected == 1)
ovidiup13 3:688b62ff6474 23 this->setSelectedScreen(next);
ovidiup13 3:688b62ff6474 24 else if(selected == 2)
ovidiup13 3:688b62ff6474 25 this->setSelectedScreen(back);
ovidiup13 3:688b62ff6474 26 else
ovidiup13 3:688b62ff6474 27 return;
ovidiup13 3:688b62ff6474 28 }
ovidiup13 3:688b62ff6474 29 //display items
ovidiup13 3:688b62ff6474 30 display_items();
ovidiup13 3:688b62ff6474 31 }
ovidiup13 3:688b62ff6474 32
ovidiup13 3:688b62ff6474 33 void Measure::display_description(char * r){
ovidiup13 3:688b62ff6474 34 st7565->drawstring(0, 2, description); //description
ovidiup13 3:688b62ff6474 35 //result
ovidiup13 3:688b62ff6474 36 if(hasResult)
ovidiup13 3:688b62ff6474 37 st7565->drawstring(30, 5, r);
ovidiup13 3:688b62ff6474 38 }
ovidiup13 3:688b62ff6474 39
ovidiup13 3:688b62ff6474 40 void Measure::display_items(void){
ovidiup13 3:688b62ff6474 41 //clear screen
ovidiup13 3:688b62ff6474 42 st7565->clear();
ovidiup13 3:688b62ff6474 43
ovidiup13 3:688b62ff6474 44 //display result if it is a result screen
ovidiup13 3:688b62ff6474 45 float r = 5;
ovidiup13 3:688b62ff6474 46 char result[15];
ovidiup13 3:688b62ff6474 47 if(hasResult){
ovidiup13 3:688b62ff6474 48 //calculate result
ovidiup13 3:688b62ff6474 49 sprintf(result, "%.2f Meters", r);
ovidiup13 3:688b62ff6474 50 }
ovidiup13 3:688b62ff6474 51
ovidiup13 3:688b62ff6474 52 //display description
ovidiup13 3:688b62ff6474 53 display_description(result);
ovidiup13 3:688b62ff6474 54
ovidiup13 3:688b62ff6474 55 //draw items
ovidiup13 3:688b62ff6474 56 st7565->drawstring(LEFT_MARGIN * 2, SELECTION_LINE, nextName);
ovidiup13 3:688b62ff6474 57 st7565->drawstring(LEFT_MARGIN * 2, SELECTION_LINE + 1, backName);
ovidiup13 3:688b62ff6474 58
ovidiup13 3:688b62ff6474 59 //set first as selected
ovidiup13 3:688b62ff6474 60 st7565->drawcircle(2, (current_line * 8) + 3, 2, 20);
ovidiup13 3:688b62ff6474 61 st7565->display();
ovidiup13 3:688b62ff6474 62 }