Bienvenido a los foros de FT81x Manía. Te invitamos a regístrate totalmente gratis. Disfruta de tu experiencia con un grandes amigos y Staff.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Thread Contributor: raufjayProblem with calling another screen

#1
0
Hello,
I am trying to open another screen by clicking on a button at previous screen.

For Example I have a button on screen1. When I click on that button, I want Screen2 should be opened.

But what happens when I clicked the button, the Screen2 shows up for a glance and I am back on Screen1. The display does not stay on Screen2.

I tried several options, but it seems I am missing something here.

Please have a look at the code and advise. Thanks.

// // //  Screen1 // // //

void commands()
{
        GD.cmd_dlstart();
        GD.Clear(1,1,1);
       
        GD.ColorRGB(255,100,0);// Red color shadow 255,255);
        GD.cmd_text(10, 6, 31, 0, "Commands");




// Buttons      
        GD.cmd_fgcolor(0xc0c0c0);
        GD.ColorA(170);
 
         tagval = GD.rd( REG_TOUCH_TAG);        //Reading TAG Number from REG_TOUCH_TAG into 32bit tagval variable.
         tagoption = 0;                                    // tagoption will be used to show on the screen that the button is pressed or not
 
 if(tagval==30)                                 // TAG=30, Patient data requested by sending PID
 { tagoption = OPT_FLAT;//1 ;
  GD.cmd_fgcolor(0x000080);
  reqPID=1;
  //key_board();
  //GD.swap();
 // GD.finish();
  IsPenDown();
 }
        GD.Tag(30);
        GD.cmd_button(660,106,120,90,28,tagoption,"data by  PID");
        GD.cmd_fgcolor(0xc0c0c0);
        tagoption = 0;

///////////////////////////////////////////////////
 
if(tagval==31)                                 // TAG=31, Patient data requested by sending last name
 { tagoption = OPT_FLAT;//1 ;
  GD.cmd_fgcolor(0x000080);
  reqlname=1;
 // key_board();
  //GD.swap();
  //GD.finish();
  IsPenDown();
 }
        GD.Tag(31);
        GD.cmd_button(660,106+110,120,90,28,tagoption,"data by  lname");
        GD.cmd_fgcolor(0xc0c0c0);
        tagoption = 0;

///////////////////////////////////////////////////

//GD.swap();//end the display list
GD.finish();
GD.End();


if(reqPID)          // if button was pressed to request patient data by sending PID to the host.
{
  reqPID=0;
  key_board();
}

else if(reqlname)
{
  reqlname=0;
  key_board();
}

}


// ===Screen1 END ===========


// // //  Screen2 // // //
// -------------------------

void key_board()
{        int x = 0, w = 700, h = 65;
         uint16_t options = 0;
         uint8_t key = 0;      
         String kbstring ="";

         GD.cmd_dlstart();
 //        GD.SaveContext();
         GD.Clear(1,1,1);
         GD.ColorRGB(60,60,255);    // Top label strip

  // Show keys

  int y = 240;
  const char *rows[4] = { "0123456789", "QWERTYUIOP", "ASDFGHJKL", "@ZXCVBNM,."};

         tagval = GD.rd( REG_TOUCH_TAG);        //Reading TAG Number from REG_TOUCH_TAG into 32bit tagval variable.

         kbstring += tagval;
         sysser.println(kbstring);
         IsPenDown();
          
for (int i = 0; i < 4; i++)
  {
   //GD.cmd_keys(x, y, w, h, 24, options | OPT_CENTER | key, rows[i]);
    GD.cmd_keys(x, y, w, h, 24, 0, rows[i]);
    y += (h + 5);
  }

  
//GD.RestoreContext();

//GD.swap();
 GD.finish();
 GD.End();
 }

// ===Screen2 END ===========
Reply
#2
1
Try this way:


void setup()
{
  GD.begin();
  MP();
}
void loop(){}

void MP()
{
  while(1)
  {
   GD.ClearColorRGB(0x000055);
   GD.Clear();
   GD.get_inputs();

   GD.Tag(1); GD.cmd_fgcolor(0x005000);  
    GD.cmd_button(410-80, (GD.h/2)-20, 60, 40, 28, 0,"M1");  
   GD.Tag(255);

   if (GD.inputs.tag==1)
   {
     M1();
   }

   GD.Tag(2); GD.cmd_fgcolor(0x500000);  
    GD.cmd_button(410, (GD.h/2)-20, 60, 40, 28, 0,"M2");  
   GD.Tag(255);

   if (GD.inputs.tag==2)
   {
     M2();
   }   

   GD.swap();
  } 
}

void M1()
{
  while(1)
  {
   GD.ClearColorRGB(0x005000);
   GD.Clear();
   GD.get_inputs();

   GD.Tag(3); GD.cmd_fgcolor(0x500000);  
    GD.cmd_button(410-100, (GD.h/2)-80, 60, 40, 28, 0,"M2");  
   GD.Tag(255);

   if (GD.inputs.tag==3)
   {
     M2();
   }

   GD.Tag(4); GD.cmd_fgcolor(0x000050);  
    GD.cmd_button(410-100, (GD.h/2)+50, 60, 40, 28, 0,"MP");  
   GD.Tag(255);

   if (GD.inputs.tag==4)
   {
     MP();
   }

   GD.swap();
  } 
}

void M2()
{
  while(1)
  {
   GD.ClearColorRGB(0x500000);
   GD.Clear();
   GD.get_inputs();

   GD.Tag(5); GD.cmd_fgcolor(0x000050);  
    GD.cmd_button(410, (GD.h/2)-80, 60, 40, 28, 0,"M1");  
   GD.Tag(255);

   if (GD.inputs.tag==5)
   {
     M1();
   }

   GD.Tag(6); GD.cmd_fgcolor(0x000050);  
    GD.cmd_button(410, (GD.h/2)+50, 60, 40, 28, 0,"MP");  
   GD.Tag(255);

   if (GD.inputs.tag==6)
   {
     MP();
   }

   GD.swap();
  } 
}
You can forget the "void loop"
Reply
#3
0
Thank you for your support.
I wonder how this code is working without using GD.dlstart(); command. Is GD.dlstart() is not needed?
You also use just swap(); with no GD.finish(); or GD.End();.

I have read about all the above commands in manual but in practical use, I find them a bit confusing.

Thanks.

Rauf
Reply
#4
2
Better response on post RE: Problem with calling another screenThe gameduino 2/3 library it's more efficient that the FTDI original instructions set.

GD.swap is the main instruction to send the displaylist to the screen. The GD.finish y GD.end are used for control the communication with the SPI bus

I suggest to you read the gameduino 2 cookbook one more time  juguete
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)