LCD implementation of our project.
Dependencies: mbed mbed-rtos MLX90614
Menu.h@3:688b62ff6474, 2015-04-26 (annotated)
- Committer:
- ovidiup13
- Date:
- Sun Apr 26 16:29:53 2015 +0000
- Revision:
- 3:688b62ff6474
- Parent:
- 2:fcde41900fa5
- Child:
- 6:49a007861c76
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?
User | Revision | Line number | New contents of line |
---|---|---|---|
ovidiup13 | 0:1e597b0f8b3b | 1 | #ifndef _MENU_H_ |
ovidiup13 | 0:1e597b0f8b3b | 2 | #define _MENU_H_ |
ovidiup13 | 0:1e597b0f8b3b | 3 | |
ovidiup13 | 0:1e597b0f8b3b | 4 | #include<stdio.h> |
ovidiup13 | 0:1e597b0f8b3b | 5 | #include <stdlib.h> |
ovidiup13 | 0:1e597b0f8b3b | 6 | #include "st7565LCD.h" |
ovidiup13 | 0:1e597b0f8b3b | 7 | #include "Item.h" |
ovidiup13 | 0:1e597b0f8b3b | 8 | |
ovidiup13 | 0:1e597b0f8b3b | 9 | //define control keys |
ovidiup13 | 0:1e597b0f8b3b | 10 | #define NL 121 //newline char |
ovidiup13 | 0:1e597b0f8b3b | 11 | #define BS 8 //backspace |
ovidiup13 | 0:1e597b0f8b3b | 12 | #define UP 119 |
ovidiup13 | 0:1e597b0f8b3b | 13 | #define DOWN 115 |
ovidiup13 | 0:1e597b0f8b3b | 14 | |
ovidiup13 | 0:1e597b0f8b3b | 15 | int const MAX_ITEMS = 16; |
ovidiup13 | 0:1e597b0f8b3b | 16 | int const TITLE_LINE = 1; |
ovidiup13 | 2:fcde41900fa5 | 17 | int const FIRST_ITEM_LINE = 1; |
ovidiup13 | 0:1e597b0f8b3b | 18 | int const LAST_ITEM_LINE = 7; |
ovidiup13 | 2:fcde41900fa5 | 19 | int const ITEMS_PER_SCREEN = 7; |
ovidiup13 | 0:1e597b0f8b3b | 20 | |
ovidiup13 | 0:1e597b0f8b3b | 21 | class Menu: public Item { |
ovidiup13 | 0:1e597b0f8b3b | 22 | public: |
ovidiup13 | 0:1e597b0f8b3b | 23 | Item ** items; |
ovidiup13 | 3:688b62ff6474 | 24 | int size, selected, current_line; |
ovidiup13 | 0:1e597b0f8b3b | 25 | bool isScreen; |
ovidiup13 | 0:1e597b0f8b3b | 26 | |
ovidiup13 | 0:1e597b0f8b3b | 27 | //menu constructor |
ovidiup13 | 3:688b62ff6474 | 28 | Menu(char * t, ST7565 *lcd){ |
ovidiup13 | 0:1e597b0f8b3b | 29 | title = t; |
ovidiup13 | 0:1e597b0f8b3b | 30 | st7565 = lcd; |
ovidiup13 | 0:1e597b0f8b3b | 31 | items = new Item*[MAX_ITEMS]; |
ovidiup13 | 3:688b62ff6474 | 32 | selected = size = 0; |
ovidiup13 | 0:1e597b0f8b3b | 33 | current_line = FIRST_ITEM_LINE; |
ovidiup13 | 0:1e597b0f8b3b | 34 | isScreen = false; |
ovidiup13 | 0:1e597b0f8b3b | 35 | isSelectable = false; |
ovidiup13 | 0:1e597b0f8b3b | 36 | } |
ovidiup13 | 0:1e597b0f8b3b | 37 | |
ovidiup13 | 0:1e597b0f8b3b | 38 | //menu item constructor - go to a screen |
ovidiup13 | 3:688b62ff6474 | 39 | Menu(char * t, Item *screen){ |
ovidiup13 | 0:1e597b0f8b3b | 40 | title = t; |
ovidiup13 | 0:1e597b0f8b3b | 41 | st7565 = NULL; |
ovidiup13 | 0:1e597b0f8b3b | 42 | items = new Item*[1]; |
ovidiup13 | 0:1e597b0f8b3b | 43 | items[0] = screen; |
ovidiup13 | 0:1e597b0f8b3b | 44 | selected = 0; |
ovidiup13 | 0:1e597b0f8b3b | 45 | size = 1; |
ovidiup13 | 0:1e597b0f8b3b | 46 | current_line = FIRST_ITEM_LINE; |
ovidiup13 | 0:1e597b0f8b3b | 47 | isScreen = true; |
ovidiup13 | 0:1e597b0f8b3b | 48 | isSelectable = true; |
ovidiup13 | 0:1e597b0f8b3b | 49 | } |
ovidiup13 | 0:1e597b0f8b3b | 50 | |
ovidiup13 | 0:1e597b0f8b3b | 51 | //display the menu |
ovidiup13 | 0:1e597b0f8b3b | 52 | virtual void display(void); |
ovidiup13 | 0:1e597b0f8b3b | 53 | |
ovidiup13 | 0:1e597b0f8b3b | 54 | //update current selection |
ovidiup13 | 0:1e597b0f8b3b | 55 | virtual void update(char c); |
ovidiup13 | 0:1e597b0f8b3b | 56 | |
ovidiup13 | 0:1e597b0f8b3b | 57 | //set the title |
ovidiup13 | 0:1e597b0f8b3b | 58 | void setTitle(char * t){ |
ovidiup13 | 0:1e597b0f8b3b | 59 | title = t; |
ovidiup13 | 0:1e597b0f8b3b | 60 | } |
ovidiup13 | 0:1e597b0f8b3b | 61 | |
ovidiup13 | 0:1e597b0f8b3b | 62 | //highlights the current selection |
ovidiup13 | 0:1e597b0f8b3b | 63 | void addItem(Item * i); |
ovidiup13 | 0:1e597b0f8b3b | 64 | |
ovidiup13 | 0:1e597b0f8b3b | 65 | private: |
ovidiup13 | 0:1e597b0f8b3b | 66 | //display items on a new screen starting with a specific index |
ovidiup13 | 0:1e597b0f8b3b | 67 | void display_items(int index); |
ovidiup13 | 0:1e597b0f8b3b | 68 | }; |
ovidiup13 | 0:1e597b0f8b3b | 69 | |
ovidiup13 | 0:1e597b0f8b3b | 70 | #endif |
ovidiup13 | 0:1e597b0f8b3b | 71 |