LCD implementation of our project.
Dependencies: mbed mbed-rtos MLX90614
Diff: Menu.h
- Revision:
- 0:1e597b0f8b3b
- Child:
- 2:fcde41900fa5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Menu.h Fri Mar 20 23:22:41 2015 +0000 @@ -0,0 +1,86 @@ + +#ifndef _MENU_H_ +#define _MENU_H_ + +#include<stdio.h> +#include <stdlib.h> +#include "st7565LCD.h" +#include "Item.h" + +//define control keys +#define NL 121 //newline char +#define BS 8 //backspace +#define UP 119 +#define DOWN 115 + +int const MAX_ITEMS = 16; +int const TITLE_LINE = 1; +int const FIRST_ITEM_LINE = 2; +int const LAST_ITEM_LINE = 7; + +class Menu: public Item { + public: + //Menu will have a limited number of items + Item ** items; + int size; + bool isScreen; + //selected items variables + int selected, current_line; + + //menu constructor + Menu(char * t, ST7565 *lcd, UI * ui){ + title = t; + st7565 = lcd; + items = new Item*[MAX_ITEMS]; + selected = 0; + size = 0; + current_line = FIRST_ITEM_LINE; + isScreen = false; + isSelectable = false; + this->ui = ui; + } + + //menu item constructor - go to a screen + Menu(char * t, Item *screen, UI *ui){ + title = t; + st7565 = NULL; + items = new Item*[1]; + items[0] = screen; + selected = 0; + size = 1; + current_line = FIRST_ITEM_LINE; + isScreen = true; + isSelectable = true; + this->ui = ui; + } + + //display the menu + virtual void display(void); + + //update current selection + virtual void update(char c); + + //get the title of the menu + virtual char * getTitle(void){ + return title; + } + + //set the title + void setTitle(char * t){ + title = t; + } + + //highlights the current selection + void addItem(Item * i); + + private: + //display items on a new screen starting with a specific index + void display_items(int index); + //draw arrows on right side to indicate there are more items up or down + void draw_arrows(int line, char c); + //draw the circle indicating which item is selected + void draw_selected(void); +}; + +#endif +