samavr
Junior Member

Posts: 16
|
Post by samavr on Aug 18, 2021 12:56:20 GMT -8
Hi,
I have written a code successfully and the touch reacts to the button pres event and the correct tag number returns, but the button style does not change when I press the button. By default, it should show some kind of pressing effect, but nothing. I don't know why
GD.Tag(10); GD.cmd_button(328, 195, 120, 36, 27, 0, "Button"); GD.cmd_track(328, 195, 120, 36, 10);
|
|
|
Post by tftlcdcyg on Aug 18, 2021 16:28:56 GMT -8
Because you only show one event: 3D style
3D effect
GD.cmd_button(328, 195, 120, 36, 27, 0, "Button");
2D effect
GD.cmd_button(328, 195, 120, 36, 27, OPT_FLAT, "Button");
You must replace 0 or OPT_FLAT, by some variable like this:
static uint16_t options = 0; Then the instruction for draw the button must be:
GD.cmd_button(328, 195, 120, 36, 27, options, "Button");
In order to get "the touching effect", you need one variable that store each event, for example: 0 for 3D or 1 for 2D. Try this experiment:
#include <GDT4Xv134.h> //my version of GD23X libray for teensy 4.x and EVE3/EVE4 chips, with SdFat library/SDIO support
int Press = 0; static uint16_t options = 0;
void setup(){ GD.begin(); MP(); } void loop(){}
void MP() { while(1) { GD.ClearColorRGB(0x000055); GD.Clear(); GD.get_inputs();
GD.SaveContext(); if(Press==0){GD.Tag(1); options = 0; GD.cmd_fgcolor(0x005000); GD.cmd_button(328, 195, 120, 72, 27, options, "Button 3D");} if(Press==1){GD.Tag(1); options = OPT_FLAT; GD.cmd_fgcolor(0x005000); GD.cmd_button(328, 195, 120, 72, 27, options, "Button 2D");} GD.RestoreContext();
if (GD.inputs.tag==1) { Press=1; } else { Press=0; } GD.swap(); } }
|
|
samavr
Junior Member

Posts: 16
|
Post by samavr on Aug 19, 2021 4:40:42 GMT -8
Thank you. What is the easiest method to add a touch effect on images? Loading another image on the same coordinate?
|
|
|
Post by jamesbowman on Aug 21, 2021 6:15:23 GMT -8
samavr easiest is probably to draw the image darkened. When drawing images, they get drawn using the current RGB color. So to darken the image use a darker color: GD.Begin(BITMAPS); if (pressed) GD.ColorRGB(90, 90, 90); else GD.ColorRGB(255, 255, 255); GD.Vertex2f(100, 120);
|
|
|
Post by tftlcdcyg on Aug 22, 2021 8:33:51 GMT -8
By subscribing to the theme, you can use an assets file or an arrangement of cells, in which you have an example, the image of a switch in position 0 and another, in position 1. With a control variable you can decide what will be displayed on the screen when you type the image.
You can assign a tag to the image itself, and the image will become a button:
GD.Tag (1); GD.Vertex2ii (300, 110, 9); GD.Tag (255);
|
|