From 340276a9f7bcc40b354e2470a72fee6304149fb0 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 4 Aug 2011 10:53:52 +0200 Subject: [PATCH 1/5] Be more clear on charging status --- firmware/l0dable/debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/l0dable/debug.c b/firmware/l0dable/debug.c index a4c329b..25b2b9c 100644 --- a/firmware/l0dable/debug.c +++ b/firmware/l0dable/debug.c @@ -65,9 +65,9 @@ void ChkBattery(void) { lcdNl(); lcdPrintln("Chrg_stat:"); if(gpioGetValue(RB_PWR_CHRG)){ - lcdPrintln("1"); + lcdPrintln("not charging"); }else{ - lcdPrintln("0"); + lcdPrintln(" CHARGING"); }; lcdRefresh(); delayms_queue(100); From ef0d134a340ff9bb25c227db63df7e6bd47bac03 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 4 Aug 2011 10:54:09 +0200 Subject: [PATCH 2/5] table.c/table.h are generated and need not be commited --- firmware/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/firmware/.gitignore b/firmware/.gitignore index ca10624..5323c83 100644 --- a/firmware/.gitignore +++ b/firmware/.gitignore @@ -4,3 +4,5 @@ lpc1xxx/memory.ld applications/wrapper.c lcd/allfonts.h Makefile.dep +table.c +table.h From 3b7f41bb581d0aa64585e6be67fb23e8842b66c1 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 4 Aug 2011 10:55:41 +0200 Subject: [PATCH 3/5] Revert "Revert "save 4 bytes by making internal function static"" This reverts commit 8875fc8d8b7c92254aa1182ce21fbfa7d6179225. --- firmware/lcd/render.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/lcd/render.c b/firmware/lcd/render.c index 69c6d6e..e2ae3f5 100644 --- a/firmware/lcd/render.c +++ b/firmware/lcd/render.c @@ -14,7 +14,7 @@ const struct FONT_DEF * font = NULL; struct EXTFONT efont; -FIL file; /* current font file */ +static FIL file; /* current font file */ /* Exported Functions */ @@ -138,7 +138,7 @@ int _getFontData(int type, int offset){ return 0; }; -int _getIndex(int c){ +static int _getIndex(int c){ #define ERRCHR (font->u8FirstChar+1) /* Does this font provide this character? */ if(cu8FirstChar) From d8371af9abf7fce739552a9927a1e4eedaf00aa5 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 4 Aug 2011 10:56:02 +0200 Subject: [PATCH 4/5] Revert "Revert "lcd/render.c: save 56 bytes"" This reverts commit a5f8a9b04faa6df17d4fe235b6010be283b305be. --- firmware/lcd/render.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/firmware/lcd/render.c b/firmware/lcd/render.c index e2ae3f5..c98b147 100644 --- a/firmware/lcd/render.c +++ b/firmware/lcd/render.c @@ -8,6 +8,7 @@ #include "fonts/smallfonts.h" #include "filesystem/ff.h" +#include "render.h" /* Global Variables */ const struct FONT_DEF * font = NULL; @@ -36,10 +37,17 @@ void setExtFont(const char *fname){ int getFontHeight(void){ if(font) - return font->u8Height; + return font->u8Height; return 8; // XXX: Should be done right. }; +static uint8_t read_byte (void) +{ + UINT readbytes; + uint8_t byte; + f_read(&file, &byte, sizeof(uint8_t), &readbytes); + return byte; +} int _getFontData(int type, int offset){ UINT readbytes; @@ -51,10 +59,10 @@ int _getFontData(int type, int offset){ if(efont.type == FONT_EXTERNAL){ if (type == START_FONT){ - res = f_read(&file, &efont.def.u8Width, sizeof(uint8_t), &readbytes); - res = f_read(&file, &efont.def.u8Height, sizeof(uint8_t), &readbytes); - res = f_read(&file, &efont.def.u8FirstChar, sizeof(uint8_t), &readbytes); - res = f_read(&file, &efont.def.u8LastChar, sizeof(uint8_t), &readbytes); + efont.def.u8Width = read_byte (); + efont.def.u8Height = read_byte (); + efont.def.u8FirstChar = read_byte (); + efont.def.u8LastChar = read_byte (); res = f_read(&file, &extras, sizeof(uint16_t), &readbytes); return 0; }; @@ -72,9 +80,7 @@ int _getFontData(int type, int offset){ return 0; }; if(type == GET_WIDTH || type == GET_DATA){ - uint8_t width; - res = f_read(&file, &width, sizeof(uint8_t), &readbytes); - return width; + return read_byte (); }; if(type == SEEK_DATA){ character=offset; @@ -87,7 +93,7 @@ int _getFontData(int type, int offset){ }; if(type == PEEK_DATA){ uint8_t width; - res = f_read(&file, &width, sizeof(uint8_t), &readbytes); + width = read_byte (); f_lseek(&file,6+ (extras*sizeof(uint16_t))+ ((extras+font->u8LastChar-font->u8FirstChar)*sizeof(uint8_t))+ @@ -240,10 +246,10 @@ int DoChar(int sx, int sy, int c){ UINT res; UINT readbytes; uint8_t testbyte; - res = f_read(&file, &testbyte, sizeof(uint8_t), &readbytes); + testbyte = read_byte (); if(testbyte>>4 ==15){ - res = f_read(&file, &preblank, sizeof(uint8_t), &readbytes); - res = f_read(&file, &postblank, sizeof(uint8_t), &readbytes); + preblank = read_byte (); + postblank = read_byte (); width-=3; width/=height; res = f_read(&file, charBuf, width*height, &readbytes); From 55d15269c55d71caba59356814473f3414443a86 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 4 Aug 2011 11:07:32 +0200 Subject: [PATCH 5/5] fix make clean, and run mktable if usetable.h is missing --- firmware/l0dable/.gitignore | 2 +- firmware/l0dable/Makefile | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/firmware/l0dable/.gitignore b/firmware/l0dable/.gitignore index 7652361..ca79c34 100644 --- a/firmware/l0dable/.gitignore +++ b/firmware/l0dable/.gitignore @@ -1,4 +1,4 @@ *.elf *.bin -*.h +usetable.h loadable.ld diff --git a/firmware/l0dable/Makefile b/firmware/l0dable/Makefile index f4f6714..8da03dc 100644 --- a/firmware/l0dable/Makefile +++ b/firmware/l0dable/Makefile @@ -42,7 +42,7 @@ $(LDFILE): $(OBJCOPY) $(OCFLAGS) -O binary $< $@ clean: - rm -f *.o *.elf *.bin + rm -f *.o *.elf *.bin usetable.h IDIR=/cygdrive/f install: @@ -50,6 +50,9 @@ install: $(OBJS): usetable.h +usetable.h: + ./mktable.pl + .SUFFIXES: .PHONY: $(LDFILE)