diff --git a/tornado/fw/Makefile b/tornado/fw/Makefile index 2a02cdb..d370d1a 100644 --- a/tornado/fw/Makefile +++ b/tornado/fw/Makefile @@ -78,6 +78,11 @@ boot.elf: $(BOOT_OBJS) $(BUILD) $(OBJCOPY) -j .text -j .data -O ihex $< $@ $(SIZE) $@ +tornado.o: img.inc + +img.inc: txt/t + (cd txt; ./t) >$@ || { rm -f $@; exit 1; } + # ----- Cleanup --------------------------------------------------------------- clean: @@ -86,6 +91,7 @@ clean: rm -f boot.hex boot.elf rm -f $(BOOT_OBJS) $(BOOT_OBJS:.o=.d) rm -f version.c version.d version.o + rm -f img.inc # ----- Build version --------------------------------------------------------- diff --git a/tornado/fw/tornado.c b/tornado/fw/tornado.c index 6e8c421..2766bfe 100644 --- a/tornado/fw/tornado.c +++ b/tornado/fw/tornado.c @@ -2,6 +2,7 @@ #include #include +#include #define F_CPU 8000000UL #include @@ -100,6 +101,11 @@ static uint16_t adc(bool x) #define HYSTERESIS 14 +static const uint8_t img[] PROGMEM = { + #include "img.inc" +}; + + static void zxing(uint16_t x, uint16_t y) { static uint8_t one[LED_BYTES] = @@ -109,24 +115,30 @@ static void zxing(uint16_t x, uint16_t y) int16_t d; static bool up = 0; static bool on = 0; + static const prog_uint8_t *p; + static uint16_t cols = 0; e = y+(e-(e >> E_SHIFT)); m = y+(m-(m >> M_SHIFT)); d = (e >> E_SHIFT)-(m >> M_SHIFT); - if (on) { - on = 0; - led_off(); - } if (up) { if (d < -HYSTERESIS) up = 0; } else { if (d > HYSTERESIS) { up = 1; - led_show(one); + p = img; + cols = sizeof(img)/LED_BYTES; on = 1; } } + if (cols) { + led_show_pgm(p); + p += 8; + cols--; + } else { + led_off(); + } }