Post by aap98 on Jan 24, 2020 11:44:45 GMT -8
Hello folks, I am struggling to update this code that I have attached to show only the new 'pressed menu' once it has detected a touch on one of the corresponding tags in the main menu. Currently as you can see the screen detects a touch quickly flashes the new menu but goes back to the main menu, any suggestions??
Thanks in Advance
#include <EEPROM.h>
#include <SPI.h>
#include <GD2.h>
#define MAIN_TAG 0
#define FUZZ_TAG 1
#define DELAY_TAG 2
#define COMPRESSOR_TAG 3
#define OVERDRIVE_TAG 4
#define BOOST_TAG 5
#define MODULATION_TAG 6
#define ELOOP_TAG 7
#define BACK_TAG 8
void setup()
{
Serial.begin(1000000);
GD.begin(~GD_STORAGE);
}
//Main Menu of the GUI this is the menu I want to be available when nothing is pressed and when the system boots up.
void MainMenu() {
GD.Begin(RECTS); //create rectangle
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(1); //Assign Tag value of 1.
GD.Vertex2ii(5,10);
GD.Vertex2ii(151,100);
GD.ColorRGB(0,0,120);
GD.cmd_text(73,52,28,OPT_CENTER, "FUZZ");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(2);
GD.Vertex2ii(161,10);
GD.Vertex2ii(317,100);
GD.ColorRGB(0,0,120);
GD.cmd_text(239,52,28,OPT_CENTER, "DELAY");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(3);
GD.Vertex2ii(327,10);
GD.Vertex2ii(470,100);
GD.ColorRGB(0,0,120);
GD.cmd_text(399,52,28,OPT_CENTER, "COMPRESSOR");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(4);
GD.Vertex2ii(5,110);
GD.Vertex2ii(151,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(72,155,28,OPT_CENTER, "OVERDRIVE");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(5);
GD.Vertex2ii(161,110);
GD.Vertex2ii(317,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(233,155,28,OPT_CENTER, "BOOST");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(6);
GD.Vertex2ii(327,110);
GD.Vertex2ii(470,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(399,155,28,OPT_CENTER, "MODULATION");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(7);
GD.Vertex2ii(50,220);
GD.Vertex2ii(430,250);
GD.ColorRGB(0,0,120);
GD.cmd_text(237,237,28,OPT_CENTER, "EFFECTS LOOP");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
}
int backbutton() {
GD.TagMask(1); //start tagging
GD.Tag(8);
GD.cmd_button(320,150,100,100,18,0,"back"); //GO back button
GD.TagMask(0); //stop tagging
}
void wait_for_release()
{ /************************************/
/* Wait till the button is released */
/************************************/
GD.get_inputs();
while (GD.inputs.tag > 0 && GD.inputs.tag < 255)
{
GD.get_inputs();
delay(5);
}
}
//This will change once I can get this code working. It will change to amenu showing effect parameters but for now simple rectangles!
void pressedmenu(int pressed) {
if(pressed == 1) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, "You have pressed FUZZ");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
else if(pressed == 2) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, "You have pressed Delay");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
else if(pressed == 3) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, "You have pressed Compressor");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
else if(pressed == 4) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, " You have pressed Overdrive");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
else if(pressed == 5) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, "You have pressed Boost");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
else if(pressed == 6) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, "You have pressed Modulation");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
else if(pressed == 7) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, "You have pressed Effects Loop");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
}
void loop() {
GD.Clear();
GD.get_inputs();
switch(GD.inputs.tag) {
case MAIN_TAG:
MainMenu();
break;
case FUZZ_TAG:
wait_for_release();
pressedmenu(FUZZ_TAG);
//Code in here that keeps it on this new screen until the back button has pressed same for all cases below??
break;
case DELAY_TAG:
wait_for_release();
pressedmenu(DELAY_TAG);
break;
case COMPRESSOR_TAG:
wait_for_release();
pressedmenu(COMPRESSOR_TAG);
break;
case OVERDRIVE_TAG:
wait_for_release();
pressedmenu(OVERDRIVE_TAG);
break;
case BOOST_TAG:
wait_for_release();
pressedmenu(BOOST_TAG);
break;
case MODULATION_TAG:
wait_for_release();
pressedmenu(MODULATION_TAG);
break;
case ELOOP_TAG:
wait_for_release();
pressedmenu(ELOOP_TAG);
break;
}
GD.swap();
}
Thanks in Advance
#include <EEPROM.h>
#include <SPI.h>
#include <GD2.h>
#define MAIN_TAG 0
#define FUZZ_TAG 1
#define DELAY_TAG 2
#define COMPRESSOR_TAG 3
#define OVERDRIVE_TAG 4
#define BOOST_TAG 5
#define MODULATION_TAG 6
#define ELOOP_TAG 7
#define BACK_TAG 8
void setup()
{
Serial.begin(1000000);
GD.begin(~GD_STORAGE);
}
//Main Menu of the GUI this is the menu I want to be available when nothing is pressed and when the system boots up.
void MainMenu() {
GD.Begin(RECTS); //create rectangle
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(1); //Assign Tag value of 1.
GD.Vertex2ii(5,10);
GD.Vertex2ii(151,100);
GD.ColorRGB(0,0,120);
GD.cmd_text(73,52,28,OPT_CENTER, "FUZZ");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(2);
GD.Vertex2ii(161,10);
GD.Vertex2ii(317,100);
GD.ColorRGB(0,0,120);
GD.cmd_text(239,52,28,OPT_CENTER, "DELAY");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(3);
GD.Vertex2ii(327,10);
GD.Vertex2ii(470,100);
GD.ColorRGB(0,0,120);
GD.cmd_text(399,52,28,OPT_CENTER, "COMPRESSOR");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(4);
GD.Vertex2ii(5,110);
GD.Vertex2ii(151,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(72,155,28,OPT_CENTER, "OVERDRIVE");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(5);
GD.Vertex2ii(161,110);
GD.Vertex2ii(317,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(233,155,28,OPT_CENTER, "BOOST");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(6);
GD.Vertex2ii(327,110);
GD.Vertex2ii(470,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(399,155,28,OPT_CENTER, "MODULATION");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.TagMask(1);
GD.Tag(7);
GD.Vertex2ii(50,220);
GD.Vertex2ii(430,250);
GD.ColorRGB(0,0,120);
GD.cmd_text(237,237,28,OPT_CENTER, "EFFECTS LOOP");
GD.TagMask(0);
GD.ColorRGB(255,255,255);
}
int backbutton() {
GD.TagMask(1); //start tagging
GD.Tag(8);
GD.cmd_button(320,150,100,100,18,0,"back"); //GO back button
GD.TagMask(0); //stop tagging
}
void wait_for_release()
{ /************************************/
/* Wait till the button is released */
/************************************/
GD.get_inputs();
while (GD.inputs.tag > 0 && GD.inputs.tag < 255)
{
GD.get_inputs();
delay(5);
}
}
//This will change once I can get this code working. It will change to amenu showing effect parameters but for now simple rectangles!
void pressedmenu(int pressed) {
if(pressed == 1) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, "You have pressed FUZZ");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
else if(pressed == 2) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, "You have pressed Delay");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
else if(pressed == 3) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, "You have pressed Compressor");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
else if(pressed == 4) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, " You have pressed Overdrive");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
else if(pressed == 5) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, "You have pressed Boost");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
else if(pressed == 6) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, "You have pressed Modulation");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
else if(pressed == 7) {
GD.Begin(RECTS);
GD.LineWidth(3*16);
GD.Vertex2ii(10,10);
GD.Vertex2ii(300,200);
GD.ColorRGB(0,0,120);
GD.cmd_text(155,95,28,OPT_CENTER, "You have pressed Effects Loop");
GD.ColorRGB(255,255,255);
backbutton(); //Display a go back button to return to main menu.
}
}
void loop() {
GD.Clear();
GD.get_inputs();
switch(GD.inputs.tag) {
case MAIN_TAG:
MainMenu();
break;
case FUZZ_TAG:
wait_for_release();
pressedmenu(FUZZ_TAG);
//Code in here that keeps it on this new screen until the back button has pressed same for all cases below??
break;
case DELAY_TAG:
wait_for_release();
pressedmenu(DELAY_TAG);
break;
case COMPRESSOR_TAG:
wait_for_release();
pressedmenu(COMPRESSOR_TAG);
break;
case OVERDRIVE_TAG:
wait_for_release();
pressedmenu(OVERDRIVE_TAG);
break;
case BOOST_TAG:
wait_for_release();
pressedmenu(BOOST_TAG);
break;
case MODULATION_TAG:
wait_for_release();
pressedmenu(MODULATION_TAG);
break;
case ELOOP_TAG:
wait_for_release();
pressedmenu(ELOOP_TAG);
break;
}
GD.swap();
}