|
Post by twenty on Sept 10, 2016 3:11:13 GMT -8
Need advice on how to make the following sketch work properly. It draws a sinusoidal graph but when the text "Hello World" is displayed the graph is cleared. I want them both showed at the same time. I have a work around and that is to use an image and set the bitmapsize parameter to 1x1 and use that as the pixel but I don't think this is an efficient way. I would appreciate any comments or advice
#include <EEPROM.h>
#include <SPI.h>
#include <GD2.h>
static void setpal(byte i, uint32_t argb)
{
GD.wr32(RAM_PAL + 4 * i, argb);
}
static void plot(uint16_t x, uint16_t y, uint32_t i)
{
if ((x < 480) && (y < 272))
GD.wr(x + (480UL * y), i);
}
void setup()
{
GD.begin(0);
GD.cmd_memset(0, 0, 480UL * 272UL);
GD.Clear();
GD.BitmapLayout(PALETTED, 480, 272);
GD.BitmapSize(NEAREST, BORDER, BORDER, 480, 272);
GD.BitmapSource(0);
GD.Begin(BITMAPS);
GD.Vertex2ii(0, 0);
GD.swap();
setpal(0, 0x00000000UL);
for (int i = 1; i < 256; i++) {
setpal(i, 0xff000000UL | random(0x1000000));}
}
void loop()
{
for (int i = 0; i < 479; i ++)
{
plot(i,136 + GD.rsin(100, i<<8),random(65500));
}
GD.Clear();
GD.cmd_text(10, 10, 28, 0, "Hello world");
GD.swap();
}
|
|