|
Post by ishotjr on Oct 3, 2015 19:38:45 GMT -8
Hello! First of all, let me start by saying thank you for creating this wonderful product - the Gameduino2 is just a delight to use - it's easy to get started, and then as you start to attempt more advanced things, it feels like everything you need has already been anticipated - I love it! I am working on a project where I hope to grab a bitmap from another device's frame buffer, transmit it to the Gameduino2, and re-assemble and reproduce it there - an external display of sorts... I started out w/ a quick PoC based on a static image that I ran through gd2asset (after converting that to use Pillow, since the code as downloaded wouldn't work on my system), but what I'd like to do now is basically have a similar 1d array (the frame buffer data is also a 1d array of uint8_t!), but that I can populate myself from the transferred data; I believe that the asset file data is gzipped - I'm hoping I can use something like LOAD_ASSETS() / GD.copy to recreate my source bitmap - am I on the right track, or should I be pursuing a completely different approach? Thanks in advance for any and all help!! PS, I did find this: gameduino2.proboards.com/thread/23/screenshotswhich seems almost exactly what I want to do, but in reverse (I want to transmit another device's frame buffer via serial for display on the Gameduino2) - and it actually made me a little wary, since it said it takes about a minute to transmit a full screen at 115K; I w/b sending a much smaller screen to the Gameduino2, but...I'm guessing I should start getting used to the idea that it won't be anything like real-time replication of the device's display, huh...?
|
|
|
Post by jamesbowman on Oct 4, 2015 8:33:44 GMT -8
This project does something similar, loading an image from an IR sensor into a bitmap: www.theresistornetwork.com/2014/11/flir-lepton-thermal-imaging-sensor.htmlHere is a short program that shows how to set up a bitmap image and set its pixel data. It is using GD.random() to set the pixel data, instead of a real source: #include <EEPROM.h> #include <SPI.h> #include <GD2.h>
void setup() { GD.begin();
// Set up a 320x240 L8 bitmap starting at 0 GD.BitmapSource(0); GD.BitmapLayout(L8, 320, 240); GD.BitmapSize(NEAREST, BORDER, BORDER, 320, 240);
GD.Clear(); GD.Begin(BITMAPS); GD.Vertex2ii((480 - 320) / 2, (272 - 240) / 2); GD.swap(); }
void loop() { for (long i = 0; i < 76800L; i++) GD.wr(i, GD.random()); }
This works fine but GD.wr() for each byte is quite inefficient. This version of loop() uses GD.cmd_memwrite() to do a block write void loop() { union { uint8_t b[4]; // as four bytes uint16_t s[2]; // as two shorts uint32_t l; // as a single long } u;
GD.cmd_memwrite(0, 76800L); for (int i = 0; i < 19200; i++) { u.s[0] = GD.random(); u.s[1] = GD.random(); GD.cmd32(u.l); } }
|
|
|
Post by Renaud on Nov 20, 2015 0:59:59 GMT -8
Hello,
Do you have a sample code for a color bitmap?
Thx,
|
|
|
Post by jamesbowman on Nov 22, 2015 2:20:31 GMT -8
Sure... if the input data is already RGB565 format (many camera emit RGB565) you can do:
#include <EEPROM.h> #include <SPI.h> #include <GD2.h>
void setup() { GD.begin();
// Set up a 320x240 L8 bitmap starting at 0 GD.BitmapSource(0); GD.BitmapLayout(RGB565, 320, 240); GD.BitmapSize(NEAREST, BORDER, BORDER, 320, 240);
GD.Clear(); GD.Begin(BITMAPS); GD.Vertex2ii((480 - 320) / 2, (272 - 240) / 2); GD.swap(); }
void loop() { union { uint8_t b[4]; // as four bytes uint16_t s[2]; // as two shorts uint32_t l; // as a single long } u;
GD.cmd_memwrite(0, 320L * 240 * 2); for (int i = 0; i < 240; i++) { for (int j = 0; j < 320; j += 2) { u.s[0] = GD.random(); u.s[1] = GD.random(); GD.cmd32(u.l); } } }
If your source data is 8-bit RGB then it needs to be converted to RGB565. This is one way:
unsigned char r, g, b; uint16_t rgb565 = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
|
|