LCD implementation of our project.
Dependencies: mbed mbed-rtos MLX90614
UserInterface.cpp@0:1e597b0f8b3b, 2015-03-20 (annotated)
- Committer:
- ovidiup13
- Date:
- Fri Mar 20 23:22:41 2015 +0000
- Revision:
- 0:1e597b0f8b3b
- Child:
- 2:fcde41900fa5
initial menu mock-up st7565
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:1e597b0f8b3b | 36 | st7565->clear(); |
ovidiup13 | 0:1e597b0f8b3b | 37 | } |
ovidiup13 | 0:1e597b0f8b3b | 38 | |
ovidiup13 | 0:1e597b0f8b3b | 39 | void UI::display(void){ |
ovidiup13 | 0:1e597b0f8b3b | 40 | st7565->clear(); |
ovidiup13 | 0:1e597b0f8b3b | 41 | header->display(); |
ovidiup13 | 0:1e597b0f8b3b | 42 | current->display(); |
ovidiup13 | 0:1e597b0f8b3b | 43 | } |
ovidiup13 | 0:1e597b0f8b3b | 44 | |
ovidiup13 | 0:1e597b0f8b3b | 45 | void UI::update(char c){ |
ovidiup13 | 0:1e597b0f8b3b | 46 | current->update(c); |
ovidiup13 | 0:1e597b0f8b3b | 47 | //display header after update |
ovidiup13 | 0:1e597b0f8b3b | 48 | header->display(); |
ovidiup13 | 0:1e597b0f8b3b | 49 | } |