Change Details
tornado/fw/Makefile |
78 | 78 | $(BUILD) $(OBJCOPY) -j .text -j .data -O ihex $< $@ |
79 | 79 | $(SIZE) $@ |
80 | 80 | |
| 81 | tornado.o: img.inc |
| 82 | |
| 83 | img.inc: txt/t |
| 84 | (cd txt; ./t) >$@ || { rm -f $@; exit 1; } |
| 85 | |
81 | 86 | # ----- Cleanup --------------------------------------------------------------- |
82 | 87 | |
83 | 88 | clean: |
... | ... | |
86 | 91 | rm -f boot.hex boot.elf |
87 | 92 | rm -f $(BOOT_OBJS) $(BOOT_OBJS:.o=.d) |
88 | 93 | rm -f version.c version.d version.o |
| 94 | rm -f img.inc |
89 | 95 | |
90 | 96 | # ----- Build version --------------------------------------------------------- |
91 | 97 | |
tornado/fw/tornado.c |
2 | 2 | #include <stdint.h> |
3 | 3 | |
4 | 4 | #include <avr/interrupt.h> |
| 5 | #include <avr/pgmspace.h> |
5 | 6 | #define F_CPU 8000000UL |
6 | 7 | #include <util/delay.h> |
7 | 8 | |
... | ... | |
100 | 101 | #define HYSTERESIS 14 |
101 | 102 | |
102 | 103 | |
| 104 | static const uint8_t img[] PROGMEM = { |
| 105 | #include "img.inc" |
| 106 | }; |
| 107 | |
| 108 | |
103 | 109 | static void zxing(uint16_t x, uint16_t y) |
104 | 110 | { |
105 | 111 | static uint8_t one[LED_BYTES] = |
... | ... | |
109 | 115 | int16_t d; |
110 | 116 | static bool up = 0; |
111 | 117 | static bool on = 0; |
| 118 | static const prog_uint8_t *p; |
| 119 | static uint16_t cols = 0; |
112 | 120 | |
113 | 121 | e = y+(e-(e >> E_SHIFT)); |
114 | 122 | m = y+(m-(m >> M_SHIFT)); |
115 | 123 | d = (e >> E_SHIFT)-(m >> M_SHIFT); |
116 | | if (on) { |
117 | | on = 0; |
118 | | led_off(); |
119 | | } |
120 | 124 | if (up) { |
121 | 125 | if (d < -HYSTERESIS) |
122 | 126 | up = 0; |
123 | 127 | } else { |
124 | 128 | if (d > HYSTERESIS) { |
125 | 129 | up = 1; |
126 | | led_show(one); |
| 130 | p = img; |
| 131 | cols = sizeof(img)/LED_BYTES; |
127 | 132 | on = 1; |
128 | 133 | } |
129 | 134 | } |
| 135 | if (cols) { |
| 136 | led_show_pgm(p); |
| 137 | p += 8; |
| 138 | cols--; |
| 139 | } else { |
| 140 | led_off(); |
| 141 | } |
130 | 142 | } |
131 | 143 | |
132 | 144 | |
Download the corresponding diff file