mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-19 10:02:48 +02:00
8643e457fa
- ubb-vga2.c (session, grab): made the frame buffer "void *" and pass frame buffer resolution - ubb-vga.h: color encoding and items shared between compilation units - ubb-vga2.c (thres, pattern, grab), grabfb.c: move to grabfb.c - ubb-vga2.c (map): make global, for use by grabfb.c - ubb-vga2.c (pick, pattern, tricolor, grid): removed obsolete test image generators - Makefile (OBJS, ubb-vga2): added grabfb.o - Makefile (clean): remove only .o files - Makefile (spotless): remove only executables
52 lines
1010 B
C
52 lines
1010 B
C
/*
|
|
* grabfb.c - Grab the Ben's main frame buffer
|
|
*
|
|
* Written 2011 by Werner Almesberger
|
|
* Copyright 2011 Werner Almesberger
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*/
|
|
|
|
|
|
#include <stdint.h>
|
|
#include <assert.h>
|
|
|
|
#include "ubb-vga.h"
|
|
|
|
|
|
uint8_t thres = 63;
|
|
|
|
|
|
static uint8_t pattern(int r, int g, int b)
|
|
{
|
|
return ((r ? R_VAL : 0) | (g ? G_VAL : 0) | (b ? B_VAL : 0))*0x11;
|
|
}
|
|
|
|
|
|
void grabfb(void *f, int xres, int yres)
|
|
{
|
|
uint32_t *fb = map(0x01d00000, 4*320*240);
|
|
uint8_t *p = f;
|
|
int x, y;
|
|
uint32_t pix;
|
|
uint8_t r, g, b;
|
|
|
|
assert(xres == 640);
|
|
assert(yres == 480);
|
|
for (y = 0; y != 240; y++) {
|
|
for (x = 0; x != 320; x++) {
|
|
pix = *fb++;
|
|
r = pix >> 16;
|
|
g = pix >> 8;
|
|
b = pix;
|
|
p[0] = p[320] =
|
|
pattern(r >= thres, g >= thres, b >= thres);
|
|
p++;
|
|
}
|
|
p += 320;
|
|
}
|
|
}
|