Permalink
Browse files

all fixed tables to flash

  • Loading branch information...
1 parent c722636 commit d481d8606e3f678a61fca127027035cb76c5f07a tz committed Feb 26, 2010
Showing with 17 additions and 7 deletions.
  1. +1 −1 lcd.c
  2. +2 −2 qrencode.c
  3. +1 −0 qrencode.h
  4. +13 −4 qrframe.c
View
2 lcd.c
@@ -23,7 +23,7 @@ void LcdWrite(unsigned char dc, unsigned char data)
#include "qrencode.h"
#include <string.h>
-main()
+int main()
{
DDRB |= 0x20;
PORTB |= 0xf8;
View
4 qrencode.c
@@ -407,7 +407,7 @@ static int badcheck()
// final format bits with mask
// level << 3 | mask
-static const unsigned fmtword[] = {
+static const unsigned fmtword[] PROGMEM = {
0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976, //L
0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, //M
0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed, //Q
@@ -419,7 +419,7 @@ static void addfmt(unsigned char masknum)
unsigned fmtbits;
unsigned char i, lvl = ECCLEVEL - 1;
- fmtbits = fmtword[masknum + (lvl << 3)];
+ fmtbits = pgm_read_word(&fmtword[masknum + (lvl << 3)]);
// low byte
for (i = 0; i < 8; i++, fmtbits >>= 1)
if (fmtbits & 1) {
View
1 qrencode.h
@@ -2,6 +2,7 @@
#define PROGMEM
#define memcpy_P memcpy
#define __LPM(x) *x
+#define pgm_read_word(x) *x
#else
#include <avr/pgmspace.h>
#define USEPRECALC
View
17 qrframe.c
@@ -1,6 +1,15 @@
#include <string.h>
#include <stdlib.h>
+#ifndef __AVR__
+#define PROGMEM
+#define memcpy_P memcpy
+#define __LPM(x) *x
+#define pgm_read_word(x) *x
+#else
+#include <avr/pgmspace.h>
+#endif
+
unsigned char *framebase;
unsigned char *framask;
unsigned char *rlens;
@@ -78,7 +87,7 @@ static void putalign(int x, int y)
}
}
-static const unsigned char adelta[41] = {
+static const unsigned char adelta[41] PROGMEM = {
0, 11, 15, 19, 23, 27, 31, // force 1 pat
16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24,
26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28,
@@ -89,7 +98,7 @@ static void doaligns(void)
unsigned char delta, x, y;
if (VERSION < 2)
return;
- delta = adelta[VERSION];
+ delta = __LPM(&adelta[VERSION]);
y = WD - 7;
for (;;) {
x = WD - 7;
@@ -107,7 +116,7 @@ static void doaligns(void)
}
}
-static const unsigned vpat[] = {
+static const unsigned vpat[] PROGMEM = {
0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d,
0x928, 0xb78, 0x45d, 0xa17, 0x532, 0x9a6, 0x683, 0x8c9,
0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75,
@@ -122,7 +131,7 @@ static void putvpat(void)
unsigned verinfo;
if (vers < 7)
return;
- verinfo = vpat[vers - 7];
+ verinfo = pgm_read_word(&vpat[vers - 7]);
bc = 17;
for (x = 0; x < 6; x++)

0 comments on commit d481d86

Please sign in to comment.