#include <readline/readline.h>
#include <readline/history.h>
+#include "png.h"
+
//This routine locates a scope by VID/PID and returns an opened handle to it.
usb_dev_handle *find_scope() {
void do_get_screen(struct usb_dev_handle *sc)
{
unsigned char screen[320*234];
- unsigned char screen_conv[320*234*3];
- unsigned char lut[256][3];
time_t lt;
char filename[256];
- int i;
+ unsigned char *png;
+ int imglen;
int l;
- FILE *fp;
+ int fd;
pid_t display;
/* Hide "RMT" from screen */
printf ("hmm. didnt' get %d bytes, but %d\n\n", sizeof(screen), l);
}
- for(i = 0; i < 256; i++) {
- lut[i][0] = ((i >> 6) * 0x55);
- lut[i][1] = ((((i >> 3) & 7) * 0x49) >> 1);
- lut[i][2] = (((i & 7) * 0x49) >> 1);
- }
-
- for(i = 0; i < sizeof(screen_conv); i += 3) {
- screen_conv[i] = lut[screen[i/3]][0];
- screen_conv[i+1] = lut[screen[i/3]][1];
- screen_conv[i+2] = lut[screen[i/3]][2];
- }
-
- lt = time(NULL);
- strftime(filename, sizeof(filename), "screen_%Y%m%d-%H%M%S.ppm", localtime(<));
-
- fp = fopen (filename, "w");
- fprintf(fp, "P6\n320 234\n255\n");
- fwrite(screen_conv, sizeof(screen_conv), 1, fp);
- fclose (fp);
+ strftime(filename, sizeof(filename), "screen_%Y%m%d-%H%M%S.png", localtime(<));
+ fd=open(filename, O_CREAT|O_WRONLY, 0644);
+ png = lcd2png(screen, &imglen);
+ write(fd, png, imglen);
+ close(fd);
printf("Waveform saved as %s\n", filename);