From: hackbard Date: Wed, 12 Sep 2007 08:42:26 +0000 (+0200) Subject: added a bitmap to betty lcd ram conversion tool X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69c590669acb39977d264c7c2103e0d2582b2e36;p=my-code%2Farm.git added a bitmap to betty lcd ram conversion tool --- diff --git a/betty/Makefile b/betty/Makefile index ad7c7d4..3807986 100644 --- a/betty/Makefile +++ b/betty/Makefile @@ -15,7 +15,7 @@ CROSS_RAM_LDFLAGS = -Tlpc2220_ram.ld -nostartfiles -nostdlib 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 @@ -23,7 +23,16 @@ BETTY_DEPS = system.o uart.o buttons.o spi.o display.o flash.o functions.o #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) diff --git a/betty/bmp2b.c b/betty/bmp2b.c new file mode 100644 index 0000000..9baf3b5 --- /dev/null +++ b/betty/bmp2b.c @@ -0,0 +1,135 @@ +/* + * bmp2b.c - convert colored 24 bit bmp to the betty display ram format + * + * author: hackbard@hackdaworld.org + * + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include + +#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 -o [-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