LCD implementation of our project.

Dependencies:   mbed mbed-rtos MLX90614

Committer:
ovidiup13
Date:
Sat Apr 04 18:24:21 2015 +0000
Revision:
2:fcde41900fa5
Parent:
0:1e597b0f8b3b
Child:
3:688b62ff6474
Cleaned up interface, added buttons.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ovidiup13 0:1e597b0f8b3b 1
ovidiup13 0:1e597b0f8b3b 2 #ifndef _MENU_H_
ovidiup13 0:1e597b0f8b3b 3 #define _MENU_H_
ovidiup13 0:1e597b0f8b3b 4
ovidiup13 0:1e597b0f8b3b 5 #include<stdio.h>
ovidiup13 0:1e597b0f8b3b 6 #include <stdlib.h>
ovidiup13 0:1e597b0f8b3b 7 #include "st7565LCD.h"
ovidiup13 0:1e597b0f8b3b 8 #include "Item.h"
ovidiup13 0:1e597b0f8b3b 9
ovidiup13 0:1e597b0f8b3b 10 //define control keys
ovidiup13 0:1e597b0f8b3b 11 #define NL 121 //newline char
ovidiup13 0:1e597b0f8b3b 12 #define BS 8 //backspace
ovidiup13 0:1e597b0f8b3b 13 #define UP 119
ovidiup13 0:1e597b0f8b3b 14 #define DOWN 115
ovidiup13 0:1e597b0f8b3b 15
ovidiup13 0:1e597b0f8b3b 16 int const MAX_ITEMS = 16;
ovidiup13 0:1e597b0f8b3b 17 int const TITLE_LINE = 1;
ovidiup13 2:fcde41900fa5 18 int const FIRST_ITEM_LINE = 1;
ovidiup13 0:1e597b0f8b3b 19 int const LAST_ITEM_LINE = 7;
ovidiup13 2:fcde41900fa5 20 int const ITEMS_PER_SCREEN = 7;
ovidiup13 0:1e597b0f8b3b 21
ovidiup13 0:1e597b0f8b3b 22 class Menu: public Item {
ovidiup13 0:1e597b0f8b3b 23 public:
ovidiup13 0:1e597b0f8b3b 24 //Menu will have a limited number of items
ovidiup13 0:1e597b0f8b3b 25 Item ** items;
ovidiup13 0:1e597b0f8b3b 26 int size;
ovidiup13 0:1e597b0f8b3b 27 bool isScreen;
ovidiup13 0:1e597b0f8b3b 28 //selected items variables
ovidiup13 0:1e597b0f8b3b 29 int selected, current_line;
ovidiup13 0:1e597b0f8b3b 30
ovidiup13 0:1e597b0f8b3b 31 //menu constructor
ovidiup13 0:1e597b0f8b3b 32 Menu(char * t, ST7565 *lcd, UI * ui){
ovidiup13 0:1e597b0f8b3b 33 title = t;
ovidiup13 0:1e597b0f8b3b 34 st7565 = lcd;
ovidiup13 0:1e597b0f8b3b 35 items = new Item*[MAX_ITEMS];
ovidiup13 0:1e597b0f8b3b 36 selected = 0;
ovidiup13 0:1e597b0f8b3b 37 size = 0;
ovidiup13 0:1e597b0f8b3b 38 current_line = FIRST_ITEM_LINE;
ovidiup13 0:1e597b0f8b3b 39 isScreen = false;
ovidiup13 0:1e597b0f8b3b 40 isSelectable = false;
ovidiup13 0:1e597b0f8b3b 41 this->ui = ui;
ovidiup13 0:1e597b0f8b3b 42 }
ovidiup13 0:1e597b0f8b3b 43
ovidiup13 0:1e597b0f8b3b 44 //menu item constructor - go to a screen
ovidiup13 0:1e597b0f8b3b 45 Menu(char * t, Item *screen, UI *ui){
ovidiup13 0:1e597b0f8b3b 46 title = t;
ovidiup13 0:1e597b0f8b3b 47 st7565 = NULL;
ovidiup13 0:1e597b0f8b3b 48 items = new Item*[1];
ovidiup13 0:1e597b0f8b3b 49 items[0] = screen;
ovidiup13 0:1e597b0f8b3b 50 selected = 0;
ovidiup13 0:1e597b0f8b3b 51 size = 1;
ovidiup13 0:1e597b0f8b3b 52 current_line = FIRST_ITEM_LINE;
ovidiup13 0:1e597b0f8b3b 53 isScreen = true;
ovidiup13 0:1e597b0f8b3b 54 isSelectable = true;
ovidiup13 0:1e597b0f8b3b 55 this->ui = ui;
ovidiup13 0:1e597b0f8b3b 56 }
ovidiup13 0:1e597b0f8b3b 57
ovidiup13 0:1e597b0f8b3b 58 //display the menu
ovidiup13 0:1e597b0f8b3b 59 virtual void display(void);
ovidiup13 0:1e597b0f8b3b 60
ovidiup13 0:1e597b0f8b3b 61 //update current selection
ovidiup13 0:1e597b0f8b3b 62 virtual void update(char c);
ovidiup13 0:1e597b0f8b3b 63
ovidiup13 0:1e597b0f8b3b 64 //set the title
ovidiup13 0:1e597b0f8b3b 65 void setTitle(char * t){
ovidiup13 0:1e597b0f8b3b 66 title = t;
ovidiup13 0:1e597b0f8b3b 67 }
ovidiup13 0:1e597b0f8b3b 68
ovidiup13 0:1e597b0f8b3b 69 //highlights the current selection
ovidiup13 0:1e597b0f8b3b 70 void addItem(Item * i);
ovidiup13 0:1e597b0f8b3b 71
ovidiup13 0:1e597b0f8b3b 72 private:
ovidiup13 0:1e597b0f8b3b 73 //display items on a new screen starting with a specific index
ovidiup13 0:1e597b0f8b3b 74 void display_items(int index);
ovidiup13 0:1e597b0f8b3b 75 };
ovidiup13 0:1e597b0f8b3b 76
ovidiup13 0:1e597b0f8b3b 77 #endif
ovidiup13 0:1e597b0f8b3b 78