|
Post by jasonharper on Jan 27, 2014 13:58:26 GMT -8
How, exactly, were the screenshots on the Gameduino website made? I had assumed that cmd_snapshot() was used - but a full-screen snapshot would take all but 1K of the available RAM, there's no way that would work with any of the demos that load assets into RAM. I see that there are some registers related to a line-by-line snapshot feature, but they refer to a 'RAM_Composite' that isn't defined anywhere.
|
|
|
Post by Javi on Jun 24, 2014 10:31:39 GMT -8
I am also interested in using this function. It was implemented for Gameduino1, so these seems a step backward 
|
|
|
Post by jamesbowman on Jun 25, 2014 5:59:34 GMT -8
OK! I had early access to the new FT800 programmer's guide, which covers the screenshot procedure. Here is a demo program "screenshot.ino" that opens the Arduino serial port and sends screenshots. These are in "ppm" format because it is so simple to implement - "ppm" is just a header followed by raw RGB pixels.  You can use anything to collect the screenshots from the serial port. Each "ppm" screenshot is 391695 bytes. As an example, the Python script "getppm.py" reads the serial port and writes each 391695 bytes into a new file, shot0000.ppm, shot0001.ppm etc. A screenshot takes about a minute to collect and transmit. During this time the GD2's display is corrupted. First the sketch "screenshot.ino": #include <EEPROM.h> #include <SPI.h> #include <GD2.h>
////////////////////////////////////////////////////////////////////////
#define REG_SCREENSHOT_EN 0x00102410UL // Set to enable screenshot mode #define REG_SCREENSHOT_Y 0x00102414UL // Y line register #define REG_SCREENSHOT_START 0x00102418UL // Screenshot start trigger #define REG_SCREENSHOT_BUSY 0x001024d8UL // Screenshot ready flags #define REG_SCREENSHOT_READ 0x00102554UL // Set to enable readout #define RAM_SCREENSHOT 0x001c2000UL // Screenshot readout buffer
void screenshot_480x272(void) { int x, y;
GD.wr(REG_SCREENSHOT_EN, 1); Serial.write("P6\n480\n272\n255\n"); // PPM header
for (y = 0; y < 272; y++) { GD.wr16(REG_SCREENSHOT_Y, y); GD.wr(REG_SCREENSHOT_START, 1); while (GD.rd32(REG_SCREENSHOT_BUSY) | GD.rd32(REG_SCREENSHOT_BUSY + 4)) ; GD.wr(REG_SCREENSHOT_READ, 1); for (x = 0; x < 480; x++) { char rgb[3]; unsigned char b = GD.rd(RAM_SCREENSHOT + (4 * x) + 0); unsigned char g = GD.rd(RAM_SCREENSHOT + (4 * x) + 1); unsigned char r = GD.rd(RAM_SCREENSHOT + (4 * x) + 2); unsigned char a = GD.rd(RAM_SCREENSHOT + (4 * x) + 3); Serial.write(r); Serial.write(g); Serial.write(b); } GD.wr(REG_SCREENSHOT_READ, 0); } GD.wr16(REG_SCREENSHOT_EN, 0); }
////////////////////////////////////////////////////////////////////////
void setup() { Serial.begin(115200); GD.begin(); }
void loop() { GD.cmd_gradient(0, 0, 0x000000, 480, 272, 0x303080); GD.Begin(POINTS); for (int i = 0; i < 100; i++) { GD.ColorRGB(GD.random(256), GD.random(256), GD.random(256)); GD.PointSize(GD.random(200)); GD.Vertex2ii(GD.random(480), GD.random(272)); } GD.ColorRGB(0xffffff); GD.cmd_text(240, 136, 31, OPT_CENTER, "This is a screenshot"); GD.swap();
delay(6000); // 6 second delay, time to start serial capture screenshot_480x272(); }
You can use anything to collect the image output from the serial port, but here is a Python program using PySerial: import sys import time
import serial
if __name__ == '__main__': import sys, getopt try: optlist, args = getopt.getopt(sys.argv[1:], "vh:s:")
except getopt.GetoptError, reason: print reason print print 'usage: getppm.py -h <usb port> -s <usb speed>' print print sys.exit(1) optdict = dict(optlist)
if '-s' in optdict: speed = int(optdict['-s']) else: speed = 1000000
port = optdict.get('-h', "/dev/ttyUSB0") print 'Opening %s at %d' % (port, speed) ser = serial.Serial(port, speed)
ser.setDTR(0) time.sleep(0.1) ser.setDTR(1)
# Expected size of the PPM. 15 bytes for the header, then 480x272 image expected_size = 15 + (3 * 480 * 272) for frame in xrange(9999): s = ser.read(expected_size) open("shot%04d.ppm" % frame, "w").write(s) print "frame %d written" % frame
|
|
|
Post by mflamer on Feb 17, 2023 15:41:06 GMT -8
James, is there any reason this code will not work with the GD3? I'm having some trouble with it. I see this post is really old and a search in the BT8xx datasheet is not returning anything for "screenshot". Thanks!
|
|
|
Post by mflamer on Feb 17, 2023 15:50:08 GMT -8
|
|