LCD implementation of our project.
Dependencies: mbed mbed-rtos MLX90614
Header.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 "Header.h" |
ovidiup13 | 0:1e597b0f8b3b | 2 | |
ovidiup13 | 0:1e597b0f8b3b | 3 | Header::Header(float lvl, float dg, char s, ST7565 * lcd){ |
ovidiup13 | 0:1e597b0f8b3b | 4 | battery_level = lvl; |
ovidiup13 | 0:1e597b0f8b3b | 5 | degrees = dg; |
ovidiup13 | 0:1e597b0f8b3b | 6 | scale = s; |
ovidiup13 | 0:1e597b0f8b3b | 7 | st7565 = lcd; |
ovidiup13 | 0:1e597b0f8b3b | 8 | } |
ovidiup13 | 0:1e597b0f8b3b | 9 | |
ovidiup13 | 0:1e597b0f8b3b | 10 | void Header::display(void){ |
ovidiup13 | 0:1e597b0f8b3b | 11 | //create strings |
ovidiup13 | 0:1e597b0f8b3b | 12 | char temp[7], level[5]; |
ovidiup13 | 0:1e597b0f8b3b | 13 | char sign = ' '; |
ovidiup13 | 0:1e597b0f8b3b | 14 | //set sign |
ovidiup13 | 0:1e597b0f8b3b | 15 | if(temp > 0) sign = 43; |
ovidiup13 | 0:1e597b0f8b3b | 16 | else if(temp < 0) sign = 45; |
ovidiup13 | 0:1e597b0f8b3b | 17 | |
ovidiup13 | 0:1e597b0f8b3b | 18 | //strcat(temp, sign); |
ovidiup13 | 0:1e597b0f8b3b | 19 | |
ovidiup13 | 0:1e597b0f8b3b | 20 | //convert to char array |
ovidiup13 | 0:1e597b0f8b3b | 21 | sprintf(temp, " %c%.1f%c", sign, degrees, scale); |
ovidiup13 | 0:1e597b0f8b3b | 22 | sprintf(level, "%d%%", battery_level); |
ovidiup13 | 0:1e597b0f8b3b | 23 | |
ovidiup13 | 0:1e597b0f8b3b | 24 | //add to header |
ovidiup13 | 0:1e597b0f8b3b | 25 | st7565->drawstring(LEFT_MARGIN, 0, temp); |
ovidiup13 | 0:1e597b0f8b3b | 26 | st7565->drawstring(LCDWIDTH - LEFT_MARGIN*4, 0, level); |
ovidiup13 | 0:1e597b0f8b3b | 27 | |
ovidiup13 | 0:1e597b0f8b3b | 28 | st7565->display(); |
ovidiup13 | 0:1e597b0f8b3b | 29 | } |