LCD implementation of our project.

Dependencies:   mbed mbed-rtos MLX90614

Committer:
ovidiup13
Date:
Wed Jun 03 17:42:47 2015 +0000
Revision:
10:97389d774ae1
Parent:
8:81ed1135ba02
working version, comment out thermo in main;

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