|
Post by valkir on Jun 25, 2014 12:41:07 GMT -8
Hi all
I'm currently trying to do the Transparent buttons using the code in the book. And it doesn't work.
Cans someone help!
I need to understand the device but I'm new to programming.
How does it work? Thanks
|
|
|
Post by jamesbowman on Jun 25, 2014 16:50:52 GMT -8
Hi, yes if you post your code I am sure someone can help fix it. The "widgets" example might be a good place to start: You can make something transparent in GD2 by setting the alpha value, for example: GD.ColorA(128); // 50% transparent Transparency is on p.18 of the book.
|
|
|
Post by marteke on Jul 12, 2014 11:15:12 GMT -8
hi, How can I print numbers? I try cmd_number is ok, but I can change the number! I do this: #include <EEPROM.h> #include <SPI.h> #include <GD2.h> int i=100; void setup() { GD.begin(); }
void loop() { GD.ClearColorRGB(0x103000); GD.Clear(); GD.cmd_text(240, 136, 31, OPT_CENTER, "Hello world"); //GD.cmd_spinner(100,100,0,0); GD.cmd_slider(200,100,120,8,0,10,100); GD.cmd_number(20,60,31,0,i); //GD.swap(); //for (int c=0; c<100; c++){ // GD.cmd_number(20,100,12,0,c); //} GD.swap(); } and I print the number 100 (i=100), now I wanna change and print variable value of (i), in the same place; how?? thanks Marcos
|
|
|
Post by jamesbowman on Jul 12, 2014 20:17:19 GMT -8
Well, each time through loop() is a redraw of the screen. So that code was drawing the same number 100 times. You can do something like this to update the number, or put all the drawing in a "redraw()" function that "loop()" calls:
#include <EEPROM.h> #include <SPI.h> #include <GD2.h> int i=100; void setup() { GD.begin(); }
void loop() { GD.ClearColorRGB(0x103000); GD.Clear(); GD.cmd_text(240, 136, 31, OPT_CENTER, "Hello world"); GD.cmd_slider(200,100,120,8,0,10,100);
GD.cmd_number(20,60,31,0,i++); GD.swap(); }
|
|
|
Post by marteke on Jul 13, 2014 13:56:16 GMT -8
thank you! it´s really nice!
|
|