LCD implementation of our project.

Dependencies:   mbed mbed-rtos MLX90614

Committer:
ovidiup13
Date:
Sun Apr 26 16:29:53 2015 +0000
Revision:
3:688b62ff6474
Parent:
2:fcde41900fa5
Child:
7:11675c1dce4f
added screens for interacting with other components. i.e. distance, thermo, gyro, compass, etc. Need to complete settings screen and create threads for interacting with other code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ovidiup13 0:1e597b0f8b3b 1 #include "UserInterface.h"
ovidiup13 0:1e597b0f8b3b 2
ovidiup13 0:1e597b0f8b3b 3 //colors
ovidiup13 0:1e597b0f8b3b 4 PwmOut red(p21);
ovidiup13 0:1e597b0f8b3b 5 PwmOut green(p22);
ovidiup13 0:1e597b0f8b3b 6 PwmOut blue(p23);
ovidiup13 0:1e597b0f8b3b 7 PwmOut a(p24);
ovidiup13 0:1e597b0f8b3b 8
ovidiup13 0:1e597b0f8b3b 9 void UI::set_colors(float r, float g, float b, float aa){ //red, green, blue, a+
ovidiup13 0:1e597b0f8b3b 10 //check that colors are between 0.0 and 1.0
ovidiup13 0:1e597b0f8b3b 11 assert(r >=0 && r <= 1);
ovidiup13 0:1e597b0f8b3b 12 assert(g >=0 && g <= 1);
ovidiup13 0:1e597b0f8b3b 13 assert(b >=0 && b <= 1);
ovidiup13 0:1e597b0f8b3b 14 assert(aa >=0 && aa <= 1);
ovidiup13 0:1e597b0f8b3b 15
ovidiup13 0:1e597b0f8b3b 16 //define colors
ovidiup13 0:1e597b0f8b3b 17 red = r;
ovidiup13 0:1e597b0f8b3b 18 green = g;
ovidiup13 0:1e597b0f8b3b 19 blue = b;
ovidiup13 0:1e597b0f8b3b 20 a = aa;
ovidiup13 0:1e597b0f8b3b 21 }
ovidiup13 0:1e597b0f8b3b 22
ovidiup13 0:1e597b0f8b3b 23 void UI::init(void){
ovidiup13 0:1e597b0f8b3b 24 //initialize variables
ovidiup13 0:1e597b0f8b3b 25 int brightness = _DEFAULT_BRIGHTNESS;
ovidiup13 0:1e597b0f8b3b 26
ovidiup13 0:1e597b0f8b3b 27 //start LCD and display logo
ovidiup13 0:1e597b0f8b3b 28 st7565->begin(_DEFAULT_CONTRAST);
ovidiup13 0:1e597b0f8b3b 29 st7565->st7565_set_brightness(brightness);
ovidiup13 0:1e597b0f8b3b 30 //set colors
ovidiup13 0:1e597b0f8b3b 31 set_colors(0, 1, 1, 1);
ovidiup13 0:1e597b0f8b3b 32 //display logo
ovidiup13 0:1e597b0f8b3b 33 st7565->display();
ovidiup13 0:1e597b0f8b3b 34 wait(2.0);
ovidiup13 0:1e597b0f8b3b 35
ovidiup13 3:688b62ff6474 36 header->setTitle(current->getTitle());
ovidiup13 2:fcde41900fa5 37 display();
ovidiup13 0:1e597b0f8b3b 38 }
ovidiup13 0:1e597b0f8b3b 39
ovidiup13 0:1e597b0f8b3b 40 void UI::display(void){
ovidiup13 0:1e597b0f8b3b 41 st7565->clear();
ovidiup13 2:fcde41900fa5 42 current->display();
ovidiup13 0:1e597b0f8b3b 43 header->display();
ovidiup13 0:1e597b0f8b3b 44 }
ovidiup13 0:1e597b0f8b3b 45
ovidiup13 0:1e597b0f8b3b 46 void UI::update(char c){
ovidiup13 0:1e597b0f8b3b 47 current->update(c);
ovidiup13 3:688b62ff6474 48 //set header after update
ovidiup13 3:688b62ff6474 49 if(c == 'y'){
ovidiup13 3:688b62ff6474 50 current = current->getSelectedScreen();
ovidiup13 3:688b62ff6474 51 header->setTitle(current->getTitle());
ovidiup13 3:688b62ff6474 52 }
ovidiup13 3:688b62ff6474 53 this->display();
ovidiup13 0:1e597b0f8b3b 54 }