LCD implementation of our project.

Dependencies:   mbed mbed-rtos MLX90614

Menu.h

Committer:
ovidiup13
Date:
2015-04-04
Revision:
2:fcde41900fa5
Parent:
0:1e597b0f8b3b
Child:
3:688b62ff6474

File content as of revision 2:fcde41900fa5:


#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 = 1;
int const LAST_ITEM_LINE = 7;
int const ITEMS_PER_SCREEN = 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);
        
        //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);
};

#endif