Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Menu by
Revision 3:3cdd377f5899, committed 2015-05-13
- Comitter:
- jjcimon
- Date:
- Wed May 13 11:40:22 2015 +0000
- Parent:
- 2:2654dc659298
- Commit message:
- Beta private,
Changed in this revision
--- a/Navigator.cpp Tue Mar 05 21:24:37 2013 +0000 +++ b/Navigator.cpp Wed May 13 11:40:22 2015 +0000 @@ -1,6 +1,10 @@ #include "Navigator.h" +#include "SMARTGPU.h" + // + #include <stdio.h> +#include <iostream> -Navigator::Navigator(Menu *root, RPG &rpg, TextLCD *lcd) : activeMenu(root), rpg(rpg), lcd(lcd) +Navigator::Navigator(Menu *root, RPG &rpg, SMARTGPU *lcd) : activeMenu(root), rpg(rpg), lcd(lcd) { bottom = root->selections.size(); cursorPos = 0; @@ -14,46 +18,78 @@ void Navigator::printMenu() { - lcd->cls(); + lcd->erase(); + if(bottom == 1){ // the current Menu only has one selection - lcd->printf("%s\n", activeMenu->selections[0].selText); + //lcd->printf("%s\n", activeMenu->selections[0].selText); + //activeMenu->selections[0].selText; + lcd->string(70,10,300,220,YELLOW,FONT4,TRANS,activeMenu->selections[0].selText); //write a string on the screen } else { - if(cursorLine == 2){ // if we're at the bottom - lcd->printf("%s\n", activeMenu->selections[cursorPos-1].selText); - lcd->printf("%s\n", activeMenu->selections[cursorPos].selText); - } else { - lcd->printf("%s\n", activeMenu->selections[cursorPos].selText); - lcd->printf("%s\n", activeMenu->selections[cursorPos+1].selText); - } + // if(cursorLine == 4){ // if we're at the bottom + // lcd->printf("%s\n", activeMenu->selections[cursorPos-1].selText); + lcd->string(5,5,300,220,WHITE,FONT6,TRANS,activeMenu->selections[4].selText); //write a string on the screen + lcd->string(30,40,300,220,WHITE,FONT6,TRANS,(activeMenu->selections[0].selText)); //write a string on the screen + lcd->string(30,80,300,220,WHITE,FONT6,TRANS,activeMenu->selections[1].selText); //write a string on the screen + lcd->string(30,120,300,220,WHITE,FONT6,TRANS,(activeMenu->selections[2].selText)); //write a string on the screen + lcd->string(30,160,300,220,WHITE,FONT6,TRANS,activeMenu->selections[3].selText); //write a string on the screen + + // } else { + + // lcd->string(30,30,300,220,WHITE,FONT6,TRANS,activeMenu->selections[0].selText); //write a string on the screen + // lcd->string(30,70,300,220,WHITE,FONT6,TRANS,activeMenu->selections[1].selText); //write a string on the screen + // lcd->string(30,110,300,220,WHITE,FONT6,TRANS,(activeMenu->selections[2].selText)); //write a string on the screen + // lcd->string(30,150,300,220,WHITE,FONT6,TRANS,activeMenu->selections[3].selText); //write a string on the screen + //} } } void Navigator::printCursor() { - if(activeMenu->selections[cursorPos].childMenu == NULL) printf("No child menu\n"); - else printf("child menu: %s\n", activeMenu->selections[cursorPos].childMenu->menuID); + + + if(activeMenu->selections[cursorPos].childMenu == NULL) + // printf("No child menu\n"); + lcd->string(10,200,300,220,WHITE,FONT2,TRANS,"_ "); //write a string on the screen + + else + lcd->string(10,200,300,220,WHITE,FONT2,TRANS, activeMenu->selections[cursorPos].childMenu->menuID); //write a string on the screen + + //printf("child menu: %s\n", activeMenu->selections[cursorPos].childMenu->menuID); - lcd->locate(0,0); - if(cursorLine == 1){ - lcd->putc('>'); - lcd->locate(0,1); - lcd->putc(' '); - } else if(cursorLine == 2){ - lcd->putc(' '); - lcd->locate(0,1); - lcd->putc('>'); + // lcd->locate(0,0); cursorPos cursorLine + if(cursorPos == 0){ + lcd->string(15,40,300,220,WHITE,FONT6,TRANS,">"); + lcd->string(15,80,300,220,WHITE,FONT6,TRANS," "); + lcd->string(15,120,300,220,WHITE,FONT6,TRANS," "); + lcd->string(15,160,300,220,WHITE,FONT6,TRANS," "); + } else if(cursorPos == 1){ + lcd->string(15,40,300,220,WHITE,FONT6,TRANS," "); + lcd->string(15,80,300,220,WHITE,FONT6,TRANS,">"); + lcd->string(15,120,300,220,WHITE,FONT6,TRANS," "); + lcd->string(15,160,300,220,WHITE,FONT6,TRANS," "); + } else if(cursorPos == 2){ + lcd->string(15,40,300,220,WHITE,FONT6,TRANS," "); + lcd->string(15,80,300,220,WHITE,FONT6,TRANS," "); + lcd->string(15,120,300,220,WHITE,FONT6,TRANS,">"); + lcd->string(15,160,300,220,WHITE,FONT6,TRANS," "); + } else if(cursorPos == 3){ + lcd->string(15,40,300,220,WHITE,FONT6,TRANS," "); + lcd->string(15,80,300,220,WHITE,FONT6,TRANS," "); + lcd->string(15,120,300,220,WHITE,FONT6,TRANS," "); + lcd->string(15,160,300,220,WHITE,FONT6,TRANS,">"); } } void Navigator::poll() { + if((direction = rpg.dir())!=0){ //Get Dir wait(0.2); if(direction == 1) moveDown(); else if(direction == -1) moveUp(); } - if ((button = rpg.pb()) && !lastButton){ //prevents multiple selections when button is held down + if ((button = rpg.pb()) && !lastButton){ //prevents multiple selections when button is held down wait(0.2); if(activeMenu->selections[cursorPos].fun != NULL){ (activeMenu->selections[cursorPos].fun)(); @@ -74,7 +110,7 @@ { if(cursorLine == 1){ printMenu(); - } else if(cursorLine == 2){ + } else if(cursorLine == 5){ cursorLine = 1; } @@ -88,8 +124,8 @@ void Navigator::moveDown() { if(cursorLine == 1){ - cursorLine = 2; - } else if(cursorLine == 2){ + cursorLine = 5; + } else if(cursorLine == 5){ printMenu(); }
--- a/Navigator.h Tue Mar 05 21:24:37 2013 +0000 +++ b/Navigator.h Wed May 13 11:40:22 2015 +0000 @@ -1,23 +1,26 @@ #ifndef NAVIGATOR_H #define NAVIGATOR_H - +#include "SMARTGPU.h" #include "mbed.h" #include "Menu.h" -#include "TextLCD.h" +// #include "TextLCD.h" #include "RPG.h" - +#include "SMARTGPU.h" class Navigator { private: public: - Navigator(Menu *, RPG &, TextLCD *); + Navigator(Menu *, RPG &, SMARTGPU *); Menu *activeMenu; // the current menu - can change when RPG is pushed on selection with child menu RPG rpg; - TextLCD *lcd; + SMARTGPU *lcd; + bool lastButton, button; int direction; // 1 = CW, -1 = CCW + int hor; + int courb; int bottom; // the index of the last item of current menu int cursorPos; // what selection the cursor points to int cursorLine; // what line of the lcd the cursor is on. 1 = first line, 2 = second line
--- a/Selection.cpp Tue Mar 05 21:24:37 2013 +0000 +++ b/Selection.cpp Wed May 13 11:40:22 2015 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #include "Selection.h" -#include "TextLCD.h" +//#include "TextLCD.h" +#include "SMARTGPU.h" Selection::Selection(void (*fun)(), int position, Menu *child, char* text) : fun(fun), selText(text), pos(position), childMenu(child) {}