CROSS_ROM_LDFLAGS = -Tlpc2220_rom.ld -nostartfiles -nostdlib
# build objects
-HOST_TARGET = lpcload fwdump
+HOST_TARGET = lpcload fwdump bmp2b
CROSS_TARGET = fwbc.hex fwflash.hex betty.hex
# betty deps
#BETTY_DEPS += pffs.o
# all projects
-all: $(HOST_TARGET) $(CROSS_TARGET)
+all: links $(HOST_TARGET) $(CROSS_TARGET)
+
+# bmp2b
+links:
+ ln -sfv ../../api/bmp/bmp.{c,h} .
+
+bmp.o: bmp.c
+ $(CC) -c $(CFLAGS) -o $@ $<
+
+bmp2b: bmp.o
# arm code
arm: arm_clean $(CROSS_TARGET)
--- /dev/null
+/*
+ * bmp2b.c - convert colored 24 bit bmp to the betty display ram format
+ *
+ * author: hackbard@hackdaworld.org
+ *
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "bmp.h"
+
+#define DX 128
+#define DY 160
+#define PM (DY/8)
+
+#define BINARY 1
+#define CHAR 2
+
+int main(int argc,char **argv) {
+
+ int i,fd;
+ t_bmp src;
+ char in[128];
+ char out[128];
+ unsigned char stat;
+ unsigned char buf[2];
+ int page,col;
+ int b,pix;
+
+ stat=0;
+ for(i=1;i<argc;i++) {
+ if(argv[i][0]!='-')
+ continue;
+ switch(argv[i][1]) {
+ case 'i':
+ strncpy(in,argv[++i],128);
+ break;
+ case 'o':
+ strncpy(out,argv[++i],128);
+ break;
+ case 'b':
+ stat=BINARY;
+ break;
+ case 'c':
+ stat=CHAR;
+ break;
+ default:
+ printf("usage:\n\n");
+ printf("%s -i <bitmap> -o <out file> [-b/c]\n",
+ argv[0]);
+ printf("\n");
+ printf(" -b: binary out\n");
+ printf(" -c: char array\n\n");
+ return -1;
+ }
+ }
+
+ /* the bitmap infile */
+ bmp_init(&src,1);
+ src.mode=READ;
+ strcpy(src.file,in);
+ bmp_read_file(&src);
+
+ if((src.width!=DX)|(src.height=!DY)) {
+ printf("wrong dimensions: %d %d (need: %d %d)\n",
+ src.width,src.height,DX,DY);
+ return -1;
+ }
+
+ /* out file */
+ fd=open(out,O_WRONLY|O_CREAT);
+ if(fd<0) {
+ perror("open outfile");
+ return fd;
+ }
+
+ if(stat==CHAR)
+ dprintf(fd,"unsigned char default_logo[%d]={\n",DX*PM*2);
+
+ for(page=0;page<PM;page++) {
+ for(col=0;col<DX;col++) {
+ buf[0]=0;
+ buf[1]=0;
+ for(i=0;i<8;i++) {
+ pix=((page*8+i)*DX)+col;
+ b=src.map[pix].r+src.map[pix].g+src.map[pix].b;
+ b/=3;
+ if(b<=(0.25*255)) {
+ buf[0]|=(1<<i);
+ buf[1]|=(1<<i); // 1 1
+ continue;
+ }
+ if(b<=(0.5*255)) {
+ buf[0]|=(1<<i); // 1 0
+ continue;
+ }
+ if(b<=(0.75*255)) {
+ buf[1]|=(1<<i); // 0 1
+ continue;
+ }
+ // 0 0 .. do nothing!
+ }
+ if(stat==BINARY) {
+ i=write(fd,buf,2);
+ if(i<0) {
+ perror("bin write");
+ return i;
+ }
+ if(i!=2) {
+ printf("write failure\n");
+ return -1;
+ }
+ }
+ else if(stat==CHAR) {
+ dprintf(fd,"\t%02x,%02x%c\n",buf[0],buf[1],
+ ((page+1==PM)&(col+1==DX))?' ':',');
+ }
+ }
+ }
+
+ if(stat==CHAR)
+ dprintf(fd,"};\n");
+
+ close(fd);
+ bmp_shutdown(&src);
+
+ return 0;
+}
+
* fwflash.c - firmware handling the flash access
* betty.c - replacement firmware for the betty tv remote
+ (follow the makefile + includes in betty.h to find more source!)
+
+* bmp2b.c - converts colored bmp images to a format according to the lcd ram
+ (you need my bmb api [my-projects/api])
to be continued ...