|
Post by lightcalamar on Nov 14, 2016 0:21:56 GMT -8
How to make text that scrolls in GD2 library? For example like this video;
|
|
|
Post by tftlcdcyg on Nov 14, 2016 8:44:54 GMT -8
My friend, try this:
//#include <EEPROM.h> #include <SPI.h> #include <GD3.h>
float PX = -190; //límite izquierdo // PX = 990; //límite derecho
float VelX = 5;
void setup() { GD.begin(); GD.cmd_setrotate(0); }
void loop() { GD.ClearColorRGB(0x000030); GD.Clear();
// if (PX>=990){PX=-190;} //avance a la derecha if (PX>=990){VelX = (-1)*abs(VelX);} if (PX<=-190){VelX = abs(VelX);} //ambas direcciones Texto(); PX=PX+VelX;
GD.swap(); }
void Texto() { if (FT_810_ENABLE==1){GD.cmd_text(PX, GD.h / 2, 31, OPT_CENTER, "FT810 en linea");} if (FT_811_ENABLE==1){GD.cmd_text(PX, GD.h / 2, 31, OPT_CENTER, "FT811 en linea");} if (FT_812_ENABLE==1){GD.cmd_text(PX, GD.h / 2, 31, OPT_CENTER, "FT812 en linea");} if (FT_813_ENABLE==1){GD.cmd_text(PX, GD.h / 2, 31, OPT_CENTER, "FT813 en linea");} }
|
|
|
Post by tftlcdcyg on Nov 14, 2016 10:09:10 GMT -8
Or this:
//#include <EEPROM.h> #include <SPI.h> #include <GD3.h>
//PX = -190; //límite izquierdo //PX = 990; //límite derecho
float PX[10], VelX[10];
void setup() { Serial.begin(9600); GD.begin(); GD.cmd_setrotate(0); PX[1] = -190; VelX[1]=5; PX[2] = -190; VelX[2]=5; PX[3] = 990; VelX[3]=-5; }
void loop() { GD.ClearColorRGB(0x000030); GD.Clear();
if (PX[1]>=990){VelX[1] = (-1)*abs(VelX[1]);} if (PX[1]<=-190){VelX[1] = abs(VelX[1]);} //ambas direcciones Texto(1, GD.h / 2);
if (PX[2]>=990){PX[2]=-190;} //avance a la derecha Texto(2, 120);
if (PX[3]<=-190){PX[3]=990;} //avance a la izquierda Texto(3, 360);
PX[1]=PX[1]+VelX[1]; PX[2]=PX[2]+VelX[2]; PX[3]=PX[3]+VelX[3]; GD.swap(); }
void Texto(int IDTexto, int PY) { if (FT_810_ENABLE==1){GD.cmd_text(PX[IDTexto], PY, 31, OPT_CENTER, "FT810 en linea");} if (FT_811_ENABLE==1){GD.cmd_text(PX[IDTexto], PY, 31, OPT_CENTER, "FT811 en linea");} if (FT_812_ENABLE==1){GD.cmd_text(PX[IDTexto], PY, 31, OPT_CENTER, "FT812 en linea");} if (FT_813_ENABLE==1){GD.cmd_text(PX[IDTexto], PY, 31, OPT_CENTER, "FT813 en linea");} }
|
|
|
Post by jamesbowman on Nov 14, 2016 14:42:38 GMT -8
This scrolls "hello world" from right to left, moving 2 pixels per frame:
#include <EEPROM.h> #include <SPI.h> #include <GD2.h>
void setup() { GD.begin(); }
void loop() { for (int x = 480; x > 0; x -= 2) { GD.ClearColorRGB(0x103000); GD.Clear(); GD.cmd_text(x, 136, 31, OPT_CENTER, "Hello world"); GD.swap(); } } You can adjust the increment on the 'for' loop line to make it go slower or faster.
|
|
|
Post by lightcalamar on Nov 15, 2016 3:32:36 GMT -8
|
|