Post by iinfinityy on Mar 10, 2021 0:48:01 GMT -8
hello,
i have made the example on page 168 in the gd2 cook book. The example works fine for me, but i have a problem. after the code is done i will load an image but the image is not printed on the screen. why is that so? And what can i do to change this? Thanks for the help.
i have made the example on page 168 in the gd2 cook book. The example works fine for me, but i have a problem. after the code is done i will load an image but the image is not printed on the screen. why is that so? And what can i do to change this? Thanks for the help.
#include <EEPROM.h>
#include <SPI.h>
#include <GD2.h>
#define PAINT_ALPHA() GD.BlendFunc(ONE, ONE_MINUS_SRC_ALPHA)
#define CLEAR_ALPHA() GD.BlendFunc(ZERO, ONE_MINUS_SRC_ALPHA)
static void button(int x, int y, byte label)
{
int sz = 18; // button size in pixels
GD.Tag(label);
PAINT_ALPHA();
GD.Begin(RECTS);
GD.LineWidth(16 * 20);
GD.Vertex2ii(x - sz, y - sz);
GD.Vertex2ii(x + sz, y + sz);
CLEAR_ALPHA();
GD.ColorA(200);
GD.ColorA(200);
GD.LineWidth(16 * 15);
GD.Vertex2ii(x - sz, y - sz);
GD.Vertex2ii(x + sz, y + sz);
GD.ColorA(0xff);
PAINT_ALPHA();
GD.cmd_number(x, y, 31, OPT_CENTER, label);
}
void setup()
{
Serial.begin(9600);
GD.begin();
GD.BitmapHandle(0);
GD.cmd_loadimage(0, 0);
GD.load("land.jpg");
GD.BitmapHandle(1);
GD.cmd_loadimage(-1, 0);
GD.load("akku10.png");
GD.wr16(REG_HCYCLE, 928);
GD.wr16(REG_HOFFSET, 88);
GD.wr16(REG_HSIZE, 800);
GD.wr16(REG_HSYNC0, 0);
GD.wr16(REG_HSYNC1, 48);
GD.wr16(REG_VCYCLE, 525);
GD.wr16(REG_VOFFSET, 32);
GD.wr16(REG_VSIZE, 480);
GD.wr16(REG_VSYNC0, 0);
GD.wr16(REG_VSYNC1, 3);
GD.wr(REG_CSPREAD, 0);
GD.wr(REG_DITHER, 1);
GD.wr(REG_PCLK_POL, 0);
GD.wr(REG_PCLK, 2);
GD.wr(REG_SWIZZLE, 0);
}
void loop()
{
GD.Clear();
GD.ColorMask(1, 1, 1, 0);
GD.Begin(BITMAPS);
GD.Vertex2ii(0, 0);
GD.ColorMask(0, 0, 0, 1);
int x0 = 160, x1 = 240, x2 = 320;
int y0 = 56, y1 = 136, y2 = 216;
button(x0, y0, 1); button(x1, y0, 2); button(x2, y0, 3);
button(x0, y1, 4); button(x1, y1, 5); button(x2, y1, 6);
button(x0, y2, 7); button(x1, y2, 8); button(x2, y2, 9);
GD.ColorMask(1, 1, 1, 1);
GD.ColorRGB(0xffffff);
GD.BlendFunc(DST_ALPHA, ONE_MINUS_DST_ALPHA);
GD.Begin(RECTS);
GD.Vertex2ii(0, 0); GD.Vertex2ii(480, 272);
GD.ColorMask(1, 1, 1, 0);
GD.Begin(BITMAPS);
GD.BitmapHandle(1); //this image is not loading on the screen
GD.Vertex2f(16* 700, 16 * 380);
GD.swap();
}