From 9e66404e8e704037aff06713ed0cdfa43fc1b220 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 15 Jan 2016 16:26:32 +0100 Subject: move sources to src and build files to build --- .gitignore | 8 +- Makefile | 33 ++++---- font.h | 264 ----------------------------------------------------------- font2.h | 266 ------------------------------------------------------------ main.cc | 217 ------------------------------------------------- modem.c | 95 ---------------------- modem.h | 24 ------ src/font.h | 264 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/font2.h | 266 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.cc | 217 +++++++++++++++++++++++++++++++++++++++++++++++++ src/modem.c | 95 ++++++++++++++++++++++ src/modem.h | 24 ++++++ 12 files changed, 885 insertions(+), 888 deletions(-) delete mode 100644 font.h delete mode 100644 font2.h delete mode 100644 main.cc delete mode 100644 modem.c delete mode 100644 modem.h create mode 100644 src/font.h create mode 100644 src/font2.h create mode 100644 src/main.cc create mode 100644 src/modem.c create mode 100644 src/modem.h diff --git a/.gitignore b/.gitignore index 975c237..84c048a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1 @@ -*.o -*.eep -*.elf -*.hex -*.lss -*.map -*.sym +/build/ diff --git a/Makefile b/Makefile index 4c0bbd1..2aea16c 100644 --- a/Makefile +++ b/Makefile @@ -21,42 +21,45 @@ ASFLAGS += ${MCU_FLAGS} -wA,--warn LDFLAGS += -Wl,--gc-sections AVRFLAGS += -U lfuse:w:0xee:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -AVRFLAGS += -U flash:w:main.hex +AVRFLAGS += -U flash:w:build/main.hex #AVRFLAGS += -U eeprom:w:main.eep -HEADERS = $(wildcard *.h) -ASFILES = $(wildcard *.S) -CFILES = $(wildcard *.c) -CXXFILES = $(wildcard *.cc) -OBJECTS = ${CFILES:.c=.o} ${CXXFILES:.cc=.o} ${ASFILES:.S=.o} +HEADERS = $(wildcard src/*.h) +ASFILES = $(wildcard src/*.S) +CFILES = $(wildcard src/*.c) +CXXFILES = $(wildcard src/*.cc) +OBJECTS = ${CFILES:src/%.c=build/%.o} ${CXXFILES:src/%.cc=build/%.o} ${ASFILES:src/%.S=build/%.o} -all: main.elf +all: build build/main.elf -%.hex: %.elf +build: + mkdir -p build + +build/%.hex: build/%.elf ${AVROBJCOPY} -O ihex -R .eeprom $< $@ -%.eep: %.elf +build/%.eep: build/%.elf ${AVROBJCOPY} -j .eeprom --set-section-flags=.eeprom="alloc,load" \ --change-section-lma .eeprom=0 -O ihex $< $@ -%.o: %.cc ${HEADERS} +build/%.o: src/%.cc ${HEADERS} ${AVRCXX} ${CXXFLAGS} -o $@ $< -c -Wl,-Map=main.map,--cref -%.o: %.c ${HEADERS} +build/%.o: src/%.c ${HEADERS} ${AVRCC} ${CFLAGS} -o $@ $< -c -Wl,-Map=main.map,--cref -main.elf: ${OBJECTS} +build/main.elf: ${OBJECTS} ${AVRCXX} ${CXXFLAGS} -o $@ $^ ${LDFLAGS} @echo @avr-size --format=avr --mcu=${MCU} $@ -program: main.hex #main.eep +program: build/main.hex #main.eep ${AVRFLASH} -p ${MCU} -c ${AVRDUDE_PROGRAMMER} ${AVRFLAGS} -secsize: main.elf +secsize: build/main.elf ${AVROBJDUMP} -hw -j.text -j.bss -j.data main.elf -funsize: main.elf +funsize: build/main.elf ${AVRNM} --print-size --size-sort main.elf .PHONY: all program secsize funsize diff --git a/font.h b/font.h deleted file mode 100644 index 839277b..0000000 --- a/font.h +++ /dev/null @@ -1,264 +0,0 @@ -#ifndef FONT_H_ -#define FONT_H_ - -#include - -typedef const unsigned char* glyph_t; - -const unsigned char PROGMEM chr_001[] = {0x08, 0x00, 0x20, 0x44, 0x40, 0x44, 0x20, 0x00, 0x00}; // happy smiley -const unsigned char PROGMEM chr_002[] = {0x08, 0x00, 0x40, 0x24, 0x20, 0x24, 0x40, 0x00, 0x00}; // sad smiley -const unsigned char PROGMEM chr_003[] = {0x05, 0x18, 0xEC, 0x5C, 0xEC, 0x18}; // skull -const unsigned char PROGMEM chr_004[] = {0x05, 0x18, 0x24, 0x48, 0x24, 0x18}; // heart -const unsigned char PROGMEM chr_005[] = {0x05, 0xD8, 0x34, 0xDE, 0x34, 0xD8}; // invader1 -const unsigned char PROGMEM chr_006[] = {0x05, 0xFA, 0xB4, 0x3C, 0xB4, 0xFA}; // invader2 -const unsigned char PROGMEM chr_007[] = {0x05, 0x9C, 0xF6, 0x1E, 0xF6, 0x9C}; // invader3 -const unsigned char PROGMEM chr_008[] = {0x05, 0xF8, 0x74, 0xFC, 0x74, 0xF8}; // ghost -const unsigned char PROGMEM chr_009[] = {0x05, 0x3C, 0x68, 0xF8, 0x68, 0x3C}; // fox -const unsigned char PROGMEM chr_010[] = {0x07, 0x7C, 0x40, 0x40, 0x00, 0x7C, 0x14, 0x04}; // -const unsigned char PROGMEM chr_011[] = {0x05, 0x60, 0x60, 0x3E, 0xCA, 0xFC}; // 2 musical notes -const unsigned char PROGMEM chr_012[] = {0x04, 0xC0, 0xFE, 0x04, 0x18}; // musical note -const unsigned char PROGMEM chr_013[] = {0x07, 0x38, 0x44, 0x44, 0x00, 0x7C, 0x14, 0x68}; // -const unsigned char PROGMEM chr_014[] = {0x05, 0x06, 0x8A, 0xF2, 0x8A, 0x06}; // glass -const unsigned char PROGMEM chr_015[] = {0x04, 0xFC, 0xF4, 0xF4, 0xFE}; // mobile -const unsigned char PROGMEM chr_016[] = {0x04, 0xE0, 0xCC, 0xAA, 0x19}; // flash -const unsigned char PROGMEM chr_017[] = {0x05, 0x0E, 0x71, 0xF9, 0x71, 0x0E}; // lightbulb -const unsigned char PROGMEM chr_018[] = {0x05, 0x10, 0x38, 0x54, 0x10, 0x10}; // <- -const unsigned char PROGMEM chr_019[] = {0x05, 0x10, 0x10, 0x54, 0x38, 0x10}; // -> -const unsigned char PROGMEM chr_020[] = {0x05, 0x60, 0x90, 0x9A, 0x66, 0x0E}; // male -const unsigned char PROGMEM chr_021[] = {0x05, 0x0C, 0x52, 0xF2, 0x52, 0x0C}; // female -const unsigned char PROGMEM chr_022[] = {0x07, 0x0C, 0xEE, 0xB2, 0x9A, 0xB2, 0xEE, 0x0C}; // telephone -const unsigned char PROGMEM chr_023[] = {0x05, 0x88, 0x48, 0x3A, 0x48, 0x88}; // stick figure -const unsigned char PROGMEM chr_024[] = {0x07, 0x10, 0x28, 0x54, 0xAA, 0x54, 0x28, 0x10}; // diamond -const unsigned char PROGMEM chr_025[] = {0x05, 0x38, 0x44, 0x5C, 0x54, 0x38}; // clock -const unsigned char PROGMEM chr_026[] = {0x05, 0x20, 0x3C, 0x7E, 0x3C, 0x20}; // bell -const unsigned char PROGMEM chr_027[] = {0x05, 0xC6, 0xAA, 0x92, 0x82, 0x82}; // sigma -const unsigned char PROGMEM chr_028[] = {0x05, 0xB8, 0xC4, 0x04, 0xC4, 0xB8}; // omega -const unsigned char PROGMEM chr_029[] = {0x06, 0x10, 0x38, 0x7C, 0xFE, 0xC6, 0x82}; // left -const unsigned char PROGMEM chr_030[] = {0x06, 0x82, 0xC6, 0xFE, 0x7C, 0x38, 0x10}; // right -const unsigned char PROGMEM chr_031[] = {0x07, 0x70, 0x88, 0x70, 0x00, 0xFE, 0x10, 0xEC}; // ok -const unsigned char PROGMEM chr_032[] = {0x03, 0x00, 0x00, 0x00}; // -const unsigned char PROGMEM chr_033[] = {0x01, 0xBE}; // ! -const unsigned char PROGMEM chr_034[] = {0x03, 0x06, 0x00, 0x06}; // " -const unsigned char PROGMEM chr_035[] = {0x05, 0x28, 0xFE, 0x28, 0xFE, 0x28}; // # -const unsigned char PROGMEM chr_036[] = {0x05, 0x48, 0x54, 0xFE, 0x54, 0x24}; // $ -const unsigned char PROGMEM chr_037[] = {0x05, 0x46, 0x26, 0x10, 0xC8, 0xC4}; // % -const unsigned char PROGMEM chr_038[] = {0x05, 0x6C, 0x92, 0xAC, 0x40, 0xA0}; // & -const unsigned char PROGMEM chr_039[] = {0x02, 0x0A, 0x06}; // ' -const unsigned char PROGMEM chr_040[] = {0x03, 0x38, 0x44, 0x82}; // ( -const unsigned char PROGMEM chr_041[] = {0x03, 0x82, 0x44, 0x38}; // ) -const unsigned char PROGMEM chr_042[] = {0x05, 0x44, 0x28, 0xD6, 0x28, 0x44}; // * -const unsigned char PROGMEM chr_043[] = {0x05, 0x10, 0x10, 0x7C, 0x10, 0x10}; // + -const unsigned char PROGMEM chr_044[] = {0x02, 0x80, 0x40}; // , -const unsigned char PROGMEM chr_045[] = {0x04, 0x10, 0x10, 0x10, 0x10}; // - -const unsigned char PROGMEM chr_046[] = {0x01, 0x80}; // . -const unsigned char PROGMEM chr_047[] = {0x05, 0xC0, 0x20, 0x10, 0x08, 0x06}; // / -const unsigned char PROGMEM chr_048[] = {0x04, 0x7C, 0x82, 0x82, 0x7C}; // 0 -const unsigned char PROGMEM chr_049[] = {0x03, 0x84, 0xFE, 0x80}; // 1 -const unsigned char PROGMEM chr_050[] = {0x04, 0xC4, 0xA2, 0x92, 0x8C}; // 2 -const unsigned char PROGMEM chr_051[] = {0x04, 0x44, 0x82, 0x92, 0x6C}; // 3 -const unsigned char PROGMEM chr_052[] = {0x04, 0x30, 0x28, 0x24, 0xFE}; // 4 -const unsigned char PROGMEM chr_053[] = {0x04, 0x4E, 0x8A, 0x8A, 0x72}; // 5 -const unsigned char PROGMEM chr_054[] = {0x04, 0x78, 0x94, 0x92, 0x62}; // 6 -const unsigned char PROGMEM chr_055[] = {0x04, 0x02, 0xE2, 0x1A, 0x06}; // 7 -const unsigned char PROGMEM chr_056[] = {0x04, 0x6C, 0x92, 0x92, 0x6C}; // 8 -const unsigned char PROGMEM chr_057[] = {0x04, 0x0C, 0x92, 0x52, 0x3C}; // 9 -const unsigned char PROGMEM chr_058[] = {0x01, 0x50}; // : -const unsigned char PROGMEM chr_059[] = {0x02, 0x80, 0x50}; // ; -const unsigned char PROGMEM chr_060[] = {0x04, 0x10, 0x28, 0x44, 0x82}; // < -const unsigned char PROGMEM chr_061[] = {0x04, 0x28, 0x28, 0x28, 0x28}; // = -const unsigned char PROGMEM chr_062[] = {0x04, 0x82, 0x44, 0x28, 0x10}; // > -const unsigned char PROGMEM chr_063[] = {0x04, 0x04, 0xA2, 0x12, 0x0C}; // ? -const unsigned char PROGMEM chr_064[] = {0x05, 0x64, 0x92, 0xF2, 0x82, 0x7C}; // @ -const unsigned char PROGMEM chr_065[] = {0x04, 0xFC, 0x12, 0x12, 0xFC}; // A -const unsigned char PROGMEM chr_066[] = {0x04, 0xFE, 0x92, 0x92, 0x6C}; // B -const unsigned char PROGMEM chr_067[] = {0x04, 0x7C, 0x82, 0x82, 0x44}; // C -const unsigned char PROGMEM chr_068[] = {0x04, 0xFE, 0x82, 0x82, 0x7C}; // D -const unsigned char PROGMEM chr_069[] = {0x04, 0xFE, 0x92, 0x92, 0x82}; // E -const unsigned char PROGMEM chr_070[] = {0x04, 0xFE, 0x12, 0x12, 0x02}; // F -const unsigned char PROGMEM chr_071[] = {0x04, 0x7C, 0x82, 0x92, 0x74}; // G -const unsigned char PROGMEM chr_072[] = {0x04, 0xFE, 0x10, 0x10, 0xFE}; // H -const unsigned char PROGMEM chr_073[] = {0x03, 0x82, 0xFE, 0x82}; // I -const unsigned char PROGMEM chr_074[] = {0x04, 0x40, 0x80, 0x80, 0x7E}; // J -const unsigned char PROGMEM chr_075[] = {0x04, 0xFE, 0x10, 0x28, 0xC6}; // K -const unsigned char PROGMEM chr_076[] = {0x04, 0xFE, 0x80, 0x80, 0x80}; // L -const unsigned char PROGMEM chr_077[] = {0x05, 0xFE, 0x04, 0x18, 0x04, 0xFE}; // M -const unsigned char PROGMEM chr_078[] = {0x04, 0xFE, 0x0C, 0x30, 0xFE}; // N -const unsigned char PROGMEM chr_079[] = {0x04, 0x7C, 0x82, 0x82, 0x7C}; // O -const unsigned char PROGMEM chr_080[] = {0x04, 0xFE, 0x12, 0x12, 0x0C}; // P -const unsigned char PROGMEM chr_081[] = {0x04, 0x7C, 0x82, 0x42, 0xBC}; // Q -const unsigned char PROGMEM chr_082[] = {0x04, 0xFE, 0x12, 0x32, 0xCC}; // R -const unsigned char PROGMEM chr_083[] = {0x04, 0x4C, 0x92, 0x92, 0x64}; // S -const unsigned char PROGMEM chr_084[] = {0x05, 0x02, 0x02, 0xFE, 0x02, 0x02}; // T -const unsigned char PROGMEM chr_085[] = {0x04, 0x7E, 0x80, 0x80, 0x7E}; // U -const unsigned char PROGMEM chr_086[] = {0x05, 0x0E, 0x30, 0xC0, 0x30, 0x0E}; // V -const unsigned char PROGMEM chr_087[] = {0x05, 0x7E, 0x80, 0x70, 0x80, 0x7E}; // W -const unsigned char PROGMEM chr_088[] = {0x05, 0xC6, 0x28, 0x10, 0x28, 0xC6}; // X -const unsigned char PROGMEM chr_089[] = {0x05, 0x06, 0x08, 0xF0, 0x08, 0x06}; // Y -const unsigned char PROGMEM chr_090[] = {0x04, 0xC2, 0xB2, 0x8A, 0x86}; // Z -const unsigned char PROGMEM chr_091[] = {0x03, 0xFE, 0x82, 0x82}; // [ -const unsigned char PROGMEM chr_092[] = {0x05, 0x06, 0x08, 0x10, 0x20, 0xC0}; // backslash -const unsigned char PROGMEM chr_093[] = {0x03, 0x82, 0x82, 0xFE}; // ] -const unsigned char PROGMEM chr_094[] = {0x03, 0x04, 0x02, 0x04}; // ^ -const unsigned char PROGMEM chr_095[] = {0x04, 0x80, 0x80, 0x80, 0x80}; // _ -const unsigned char PROGMEM chr_096[] = {0x02, 0x06, 0x08}; // ` -const unsigned char PROGMEM chr_097[] = {0x04, 0x40, 0xA8, 0xA8, 0xF0}; // a -const unsigned char PROGMEM chr_098[] = {0x04, 0xFE, 0x88, 0x88, 0x70}; // b -const unsigned char PROGMEM chr_099[] = {0x04, 0x70, 0x88, 0x88, 0x40}; // c -const unsigned char PROGMEM chr_100[] = {0x04, 0x70, 0x88, 0x88, 0xFE}; // d -const unsigned char PROGMEM chr_101[] = {0x04, 0x70, 0xA8, 0xA8, 0x90}; // e -const unsigned char PROGMEM chr_102[] = {0x04, 0x08, 0xFC, 0x0A, 0x02}; // f -const unsigned char PROGMEM chr_103[] = {0x04, 0x10, 0xA8, 0xA8, 0x78}; // g -const unsigned char PROGMEM chr_104[] = {0x04, 0xFE, 0x10, 0x10, 0xE0}; // h -const unsigned char PROGMEM chr_105[] = {0x01, 0xFA}; // i -const unsigned char PROGMEM chr_106[] = {0x03, 0x40, 0x80, 0x7A}; // j -const unsigned char PROGMEM chr_107[] = {0x04, 0xFE, 0x10, 0x28, 0xC4}; // k -const unsigned char PROGMEM chr_108[] = {0x03, 0x82, 0xFE, 0x80}; // l -const unsigned char PROGMEM chr_109[] = {0x05, 0xF8, 0x08, 0xF0, 0x08, 0xF0}; // m -const unsigned char PROGMEM chr_110[] = {0x04, 0xF8, 0x08, 0x08, 0xF0}; // n -const unsigned char PROGMEM chr_111[] = {0x04, 0x70, 0x88, 0x88, 0x70}; // o -const unsigned char PROGMEM chr_112[] = {0x04, 0xF8, 0x48, 0x48, 0x30}; // p -const unsigned char PROGMEM chr_113[] = {0x04, 0x30, 0x48, 0x48, 0xF8}; // q -const unsigned char PROGMEM chr_114[] = {0x03, 0xF0, 0x08, 0x08}; // r -const unsigned char PROGMEM chr_115[] = {0x04, 0x90, 0xA8, 0xA8, 0x48}; // s -const unsigned char PROGMEM chr_116[] = {0x04, 0x08, 0x7E, 0x88, 0x88}; // t -const unsigned char PROGMEM chr_117[] = {0x04, 0x78, 0x80, 0x80, 0xF8}; // u -const unsigned char PROGMEM chr_118[] = {0x05, 0x18, 0x60, 0x80, 0x60, 0x18}; // v -const unsigned char PROGMEM chr_119[] = {0x05, 0x78, 0x80, 0x60, 0x80, 0x78}; // w -const unsigned char PROGMEM chr_120[] = {0x05, 0x88, 0x50, 0x20, 0x50, 0x88}; // x -const unsigned char PROGMEM chr_121[] = {0x04, 0x18, 0xA0, 0xA0, 0x78}; // y -const unsigned char PROGMEM chr_122[] = {0x04, 0xC8, 0xA8, 0x98, 0x88}; // z -const unsigned char PROGMEM chr_123[] = {0x03, 0x10, 0x6C, 0x82}; // { -const unsigned char PROGMEM chr_124[] = {0x01, 0xFF}; // | -const unsigned char PROGMEM chr_125[] = {0x03, 0x82, 0x6C, 0x10}; // } -const unsigned char PROGMEM chr_126[] = {0x05, 0x10, 0x08, 0x10, 0x20, 0x10}; // ~ - -const glyph_t font[] PROGMEM = { - chr_001, - chr_002, - chr_003, - chr_004, - chr_005, - chr_006, - chr_007, - chr_008, - chr_009, - chr_010, - chr_011, - chr_012, - chr_013, - chr_014, - chr_015, - chr_016, - chr_017, - chr_018, - chr_019, - chr_020, - chr_021, - chr_022, - chr_023, - chr_024, - chr_025, - chr_026, - chr_027, - chr_028, - chr_029, - chr_030, - chr_031, - chr_032, - chr_033, - chr_034, - chr_035, - chr_036, - chr_037, - chr_038, - chr_039, - chr_040, - chr_041, - chr_042, - chr_043, - chr_044, - chr_045, - chr_046, - chr_047, - chr_048, - chr_049, - chr_050, - chr_051, - chr_052, - chr_053, - chr_054, - chr_055, - chr_056, - chr_057, - chr_058, - chr_059, - chr_060, - chr_061, - chr_062, - chr_063, - chr_064, - chr_065, - chr_066, - chr_067, - chr_068, - chr_069, - chr_070, - chr_071, - chr_072, - chr_073, - chr_074, - chr_075, - chr_076, - chr_077, - chr_078, - chr_079, - chr_080, - chr_081, - chr_082, - chr_083, - chr_084, - chr_085, - chr_086, - chr_087, - chr_088, - chr_089, - chr_090, - chr_091, - chr_092, - chr_093, - chr_094, - chr_095, - chr_096, - chr_097, - chr_098, - chr_099, - chr_100, - chr_101, - chr_102, - chr_103, - chr_104, - chr_105, - chr_106, - chr_107, - chr_108, - chr_109, - chr_110, - chr_111, - chr_112, - chr_113, - chr_114, - chr_115, - chr_116, - chr_117, - chr_118, - chr_119, - chr_120, - chr_121, - chr_122, - chr_123, - chr_124, - chr_125, - chr_126 -}; - -#endif /* FONT_H_ */ diff --git a/font2.h b/font2.h deleted file mode 100644 index aea6b8a..0000000 --- a/font2.h +++ /dev/null @@ -1,266 +0,0 @@ -#ifndef FONT_H_ -#define FONT_H_ - -#include - -typedef const unsigned char* glyph_t; - -const unsigned char PROGMEM chr_001[] = {0x08,0x00,0x04,0x22,0x02,0x22,0x04,0x00,0x00}; // happy smiley -const unsigned char PROGMEM chr_002[] = {0x08,0x00,0x02,0x24,0x04,0x24,0x02,0x00,0x00}; // sad smiley -const unsigned char PROGMEM chr_003[] = {0x05,0x18,0x37,0x3a,0x37,0x18}; // skull -const unsigned char PROGMEM chr_004[] = {0x05,0x18,0x24,0x12,0x24,0x18}; // heart -const unsigned char PROGMEM chr_005[] = {0x05,0x1b,0x2c,0x7b,0x2c,0x1b}; // invader1 -const unsigned char PROGMEM chr_006[] = {0x05,0x5f,0x2d,0x3c,0x2d,0x5f}; // invader2 -const unsigned char PROGMEM chr_007[] = {0x05,0x39,0x6f,0x78,0x6f,0x39}; // invader3 -const unsigned char PROGMEM chr_008[] = {0x05,0x1f,0x2e,0x3f,0x2e,0x1f}; // ghost -const unsigned char PROGMEM chr_009[] = {0x05,0x3c,0x16,0x1f,0x16,0x3c}; // fox -const unsigned char PROGMEM chr_010[] = {0x07,0x3e,0x02,0x02,0x00,0x3e,0x28,0x20}; // -const unsigned char PROGMEM chr_011[] = {0x05,0x06,0x06,0x7c,0x53,0x3f}; // 2 musical notes -const unsigned char PROGMEM chr_012[] = {0x04,0x03,0x7f,0x20,0x18}; // musical note -const unsigned char PROGMEM chr_013[] = {0x07,0x1c,0x22,0x22,0x00,0x3e,0x28,0x16}; // -const unsigned char PROGMEM chr_014[] = {0x05,0x60,0x51,0x4f,0x51,0x60}; // glass -const unsigned char PROGMEM chr_015[] = {0x04,0x3f,0x2f,0x2f,0x7f}; // mobile -const unsigned char PROGMEM chr_016[] = {0x04,0x07,0x33,0x55,0x98}; // flash -const unsigned char PROGMEM chr_017[] = {0x05,0x70,0x8e,0x9f,0x8e,0x70}; // lightbulb -const unsigned char PROGMEM chr_018[] = {0x05,0x08,0x1c,0x2a,0x08,0x08}; // <- -const unsigned char PROGMEM chr_019[] = {0x05,0x08,0x08,0x2a,0x1c,0x08}; // -> -const unsigned char PROGMEM chr_020[] = {0x05,0x06,0x09,0x59,0x66,0x70}; // male -const unsigned char PROGMEM chr_021[] = {0x05,0x30,0x4a,0x4f,0x4a,0x30}; // female -const unsigned char PROGMEM chr_022[] = {0x07,0x30,0x77,0x4d,0x59,0x4d,0x77,0x30}; // telephone -const unsigned char PROGMEM chr_023[] = {0x05,0x11,0x12,0x5c,0x12,0x11}; // stick figure -const unsigned char PROGMEM chr_024[] = {0x07,0x08,0x14,0x2a,0x55,0x2a,0x14,0x08}; // diamond -const unsigned char PROGMEM chr_025[] = {0x05,0x1c,0x22,0x3a,0x2a,0x1c}; // clock -const unsigned char PROGMEM chr_026[] = {0x05,0x04,0x3c,0x7e,0x3c,0x04}; // bell -const unsigned char PROGMEM chr_027[] = {0x05,0x63,0x55,0x49,0x41,0x41}; // sigma -const unsigned char PROGMEM chr_028[] = {0x05,0x1d,0x23,0x20,0x23,0x1d}; // omega -const unsigned char PROGMEM chr_029[] = {0x06,0x08,0x1c,0x3e,0x7f,0x63,0x41}; // left -const unsigned char PROGMEM chr_030[] = {0x06,0x41,0x63,0x7f,0x3e,0x1c,0x08}; // right -const unsigned char PROGMEM chr_031[] = {0x07,0x0e,0x11,0x0e,0x00,0x7f,0x08,0x37}; // ok -const unsigned char PROGMEM chr_032[] = {0x03,0x00,0x00,0x00}; // -const unsigned char PROGMEM chr_033[] = {0x01,0x7d}; // ! -const unsigned char PROGMEM chr_034[] = {0x03,0x60,0x00,0x60}; // " -const unsigned char PROGMEM chr_035[] = {0x05,0x14,0x7f,0x14,0x7f,0x14}; // # -const unsigned char PROGMEM chr_036[] = {0x05,0x12,0x2a,0x7f,0x2a,0x24}; // $ -const unsigned char PROGMEM chr_037[] = {0x05,0x62,0x64,0x08,0x13,0x23}; // % -const unsigned char PROGMEM chr_038[] = {0x05,0x36,0x49,0x35,0x02,0x05}; // & -const unsigned char PROGMEM chr_039[] = {0x02,0x50,0x60}; // ' -const unsigned char PROGMEM chr_040[] = {0x03,0x1c,0x22,0x41}; // ( -const unsigned char PROGMEM chr_041[] = {0x03,0x41,0x22,0x1c}; // ) -const unsigned char PROGMEM chr_042[] = {0x05,0x22,0x14,0x6b,0x14,0x22}; // * -const unsigned char PROGMEM chr_043[] = {0x05,0x08,0x08,0x3e,0x08,0x08}; // + -const unsigned char PROGMEM chr_044[] = {0x02,0x01,0x02}; // , -const unsigned char PROGMEM chr_045[] = {0x04,0x08,0x08,0x08,0x08}; // - -const unsigned char PROGMEM chr_046[] = {0x01,0x01}; // . -const unsigned char PROGMEM chr_047[] = {0x05,0x03,0x04,0x08,0x10,0x60}; // / -const unsigned char PROGMEM chr_048[] = {0x04,0x3e,0x41,0x41,0x3e}; // 0 -const unsigned char PROGMEM chr_049[] = {0x03,0x21,0x7f,0x01}; // 1 -const unsigned char PROGMEM chr_050[] = {0x04,0x23,0x45,0x49,0x31}; // 2 -const unsigned char PROGMEM chr_051[] = {0x04,0x22,0x41,0x49,0x36}; // 3 -const unsigned char PROGMEM chr_052[] = {0x04,0x0c,0x14,0x24,0x7f}; // 4 -const unsigned char PROGMEM chr_053[] = {0x04,0x72,0x51,0x51,0x4e}; // 5 -const unsigned char PROGMEM chr_054[] = {0x04,0x1e,0x29,0x49,0x46}; // 6 -const unsigned char PROGMEM chr_055[] = {0x04,0x40,0x47,0x58,0x60}; // 7 -const unsigned char PROGMEM chr_056[] = {0x04,0x36,0x49,0x49,0x36}; // 8 -const unsigned char PROGMEM chr_057[] = {0x04,0x30,0x49,0x4a,0x3c}; // 9 -const unsigned char PROGMEM chr_058[] = {0x01,0x0a}; // : -const unsigned char PROGMEM chr_059[] = {0x02,0x01,0x0a}; // ; -const unsigned char PROGMEM chr_060[] = {0x04,0x08,0x14,0x22,0x41}; // < -const unsigned char PROGMEM chr_061[] = {0x04,0x14,0x14,0x14,0x14}; // = -const unsigned char PROGMEM chr_062[] = {0x04,0x41,0x22,0x14,0x08}; // > -const unsigned char PROGMEM chr_063[] = {0x04,0x20,0x45,0x48,0x30}; // ? -const unsigned char PROGMEM chr_064[] = {0x05,0x26,0x49,0x4f,0x41,0x3e}; // @ -const unsigned char PROGMEM chr_065[] = {0x04,0x3f,0x48,0x48,0x3f}; // A -const unsigned char PROGMEM chr_066[] = {0x04,0x7f,0x49,0x49,0x36}; // B -const unsigned char PROGMEM chr_067[] = {0x04,0x3e,0x41,0x41,0x22}; // C -const unsigned char PROGMEM chr_068[] = {0x04,0x7f,0x41,0x41,0x3e}; // D -const unsigned char PROGMEM chr_069[] = {0x04,0x7f,0x49,0x49,0x41}; // E -const unsigned char PROGMEM chr_070[] = {0x04,0x7f,0x48,0x48,0x40}; // F -const unsigned char PROGMEM chr_071[] = {0x04,0x3e,0x41,0x49,0x2e}; // G -const unsigned char PROGMEM chr_072[] = {0x04,0x7f,0x08,0x08,0x7f}; // H -const unsigned char PROGMEM chr_073[] = {0x03,0x41,0x7f,0x41}; // I -const unsigned char PROGMEM chr_074[] = {0x04,0x02,0x01,0x01,0x7e}; // J -const unsigned char PROGMEM chr_075[] = {0x04,0x7f,0x08,0x14,0x63}; // K -const unsigned char PROGMEM chr_076[] = {0x04,0x7f,0x01,0x01,0x01}; // L -const unsigned char PROGMEM chr_077[] = {0x05,0x7f,0x20,0x18,0x20,0x7f}; // M -const unsigned char PROGMEM chr_078[] = {0x04,0x7f,0x30,0x0c,0x7f}; // N -const unsigned char PROGMEM chr_079[] = {0x04,0x3e,0x41,0x41,0x3e}; // O -const unsigned char PROGMEM chr_080[] = {0x04,0x7f,0x48,0x48,0x30}; // P -const unsigned char PROGMEM chr_081[] = {0x04,0x3e,0x41,0x42,0x3d}; // Q -const unsigned char PROGMEM chr_082[] = {0x04,0x7f,0x48,0x4c,0x33}; // R -const unsigned char PROGMEM chr_083[] = {0x04,0x32,0x49,0x49,0x26}; // S -const unsigned char PROGMEM chr_084[] = {0x05,0x40,0x40,0x7f,0x40,0x40}; // T -const unsigned char PROGMEM chr_085[] = {0x04,0x7e,0x01,0x01,0x7e}; // U -const unsigned char PROGMEM chr_086[] = {0x05,0x70,0x0c,0x03,0x0c,0x70}; // V -const unsigned char PROGMEM chr_087[] = {0x05,0x7e,0x01,0x0e,0x01,0x7e}; // W -const unsigned char PROGMEM chr_088[] = {0x05,0x63,0x14,0x08,0x14,0x63}; // X -const unsigned char PROGMEM chr_089[] = {0x05,0x60,0x10,0x0f,0x10,0x60}; // Y -const unsigned char PROGMEM chr_090[] = {0x04,0x43,0x4d,0x51,0x61}; // Z -const unsigned char PROGMEM chr_091[] = {0x03,0x7f,0x41,0x41}; // [ -const unsigned char PROGMEM chr_092[] = {0x05,0x60,0x10,0x08,0x04,0x03}; // backslash -const unsigned char PROGMEM chr_093[] = {0x03,0x41,0x41,0x7f}; // ] -const unsigned char PROGMEM chr_094[] = {0x03,0x20,0x40,0x20}; // ^ -const unsigned char PROGMEM chr_095[] = {0x04,0x01,0x01,0x01,0x01}; // _ -const unsigned char PROGMEM chr_096[] = {0x02,0x60,0x10}; // ` -const unsigned char PROGMEM chr_097[] = {0x04,0x02,0x15,0x15,0x0f}; // a -const unsigned char PROGMEM chr_098[] = {0x04,0x7f,0x11,0x11,0x0e}; // b -const unsigned char PROGMEM chr_099[] = {0x04,0x0e,0x11,0x11,0x02}; // c -const unsigned char PROGMEM chr_100[] = {0x04,0x0e,0x11,0x11,0x7f}; // d -const unsigned char PROGMEM chr_101[] = {0x04,0x0e,0x15,0x15,0x09}; // e -const unsigned char PROGMEM chr_102[] = {0x04,0x10,0x3f,0x50,0x40}; // f -const unsigned char PROGMEM chr_103[] = {0x04,0x08,0x15,0x15,0x1e}; // g -const unsigned char PROGMEM chr_104[] = {0x04,0x7f,0x08,0x08,0x07}; // h -const unsigned char PROGMEM chr_105[] = {0x01,0x5f}; // i -const unsigned char PROGMEM chr_106[] = {0x03,0x02,0x01,0x5e}; // j -const unsigned char PROGMEM chr_107[] = {0x04,0x7f,0x08,0x14,0x23}; // k -const unsigned char PROGMEM chr_108[] = {0x03,0x41,0x7f,0x01}; // l -const unsigned char PROGMEM chr_109[] = {0x05,0x1f,0x10,0x0f,0x10,0x0f}; // m -const unsigned char PROGMEM chr_110[] = {0x04,0x1f,0x10,0x10,0x0f}; // n -const unsigned char PROGMEM chr_111[] = {0x04,0x0e,0x11,0x11,0x0e}; // o -const unsigned char PROGMEM chr_112[] = {0x04,0x1f,0x12,0x12,0x0c}; // p -const unsigned char PROGMEM chr_113[] = {0x04,0x0c,0x12,0x12,0x1f}; // q -const unsigned char PROGMEM chr_114[] = {0x03,0x0f,0x10,0x10}; // r -const unsigned char PROGMEM chr_115[] = {0x04,0x09,0x15,0x15,0x12}; // s -const unsigned char PROGMEM chr_116[] = {0x04,0x10,0x7e,0x11,0x11}; // t -const unsigned char PROGMEM chr_117[] = {0x04,0x1e,0x01,0x01,0x1f}; // u -const unsigned char PROGMEM chr_118[] = {0x05,0x18,0x06,0x01,0x06,0x18}; // v -const unsigned char PROGMEM chr_119[] = {0x05,0x1e,0x01,0x06,0x01,0x1e}; // w -const unsigned char PROGMEM chr_120[] = {0x05,0x11,0x0a,0x04,0x0a,0x11}; // x -const unsigned char PROGMEM chr_121[] = {0x04,0x18,0x05,0x05,0x1e}; // y -const unsigned char PROGMEM chr_122[] = {0x04,0x13,0x15,0x19,0x11}; // z -const unsigned char PROGMEM chr_123[] = {0x03,0x08,0x36,0x41}; // { -const unsigned char PROGMEM chr_124[] = {0x01,0xff}; // | -const unsigned char PROGMEM chr_125[] = {0x03,0x41,0x36,0x08}; // } -const unsigned char PROGMEM chr_126[] = {0x05,0x08,0x10,0x08,0x04,0x08}; // ~ - -const glyph_t font[] PROGMEM = { - chr_001, - chr_002, - chr_003, - chr_004, - chr_005, - chr_006, - chr_007, - chr_008, - chr_009, - chr_010, - chr_011, - chr_012, - chr_013, - chr_014, - chr_015, - chr_016, - chr_017, - chr_018, - chr_019, - chr_020, - chr_021, - chr_022, - chr_023, - chr_024, - chr_025, - chr_026, - chr_027, - chr_028, - chr_029, - chr_030, - chr_031, - chr_032, - chr_033, - chr_034, - chr_035, - chr_036, - chr_037, - chr_038, - chr_039, - chr_040, - chr_041, - chr_042, - chr_043, - chr_044, - chr_045, - chr_046, - chr_047, - chr_048, - chr_049, - chr_050, - chr_051, - chr_052, - chr_053, - chr_054, - chr_055, - chr_056, - chr_057, - chr_058, - chr_059, - chr_060, - chr_061, - chr_062, - chr_063, - chr_064, - chr_065, - chr_066, - chr_067, - chr_068, - chr_069, - chr_070, - chr_071, - chr_072, - chr_073, - chr_074, - chr_075, - chr_076, - chr_077, - chr_078, - chr_079, - chr_080, - chr_081, - chr_082, - chr_083, - chr_084, - chr_085, - chr_086, - chr_087, - chr_088, - chr_089, - chr_090, - chr_091, - chr_092, - chr_093, - chr_094, - chr_095, - chr_096, - chr_097, - chr_098, - chr_099, - chr_100, - chr_101, - chr_102, - chr_103, - chr_104, - chr_105, - chr_106, - chr_107, - chr_108, - chr_109, - chr_110, - chr_111, - chr_112, - chr_113, - chr_114, - chr_115, - chr_116, - chr_117, - chr_118, - chr_119, - chr_120, - chr_121, - chr_122, - chr_123, - chr_124, - chr_125, - chr_126 -}; - - - -#endif /* FONT_H_ */ diff --git a/main.cc b/main.cc deleted file mode 100644 index c51483d..0000000 --- a/main.cc +++ /dev/null @@ -1,217 +0,0 @@ -#include -#include -#include -#include -#include - -#include "font2.h" - -#define SHUTDOWN_THRESHOLD 2048 - -volatile uint8_t disp[8]; - -class System { - private: - uint16_t want_shutdown; - public: - System() { want_shutdown = 0; }; - void loop(void); - void shutdown(void); -}; - -class Display { - public: - Display() {}; - void turn_on(void); - void turn_off(void); -}; - -System rocket; -Display display; - -void Display::turn_off() -{ - TIMSK0 &= ~_BV(TOIE0); - PORTB = 0; - PORTD = 0; -} - -void Display::turn_on() -{ - TIMSK0 |= _BV(TOIE0); -} - -void System::loop() -{ - // both buttons are pressed - if ((PINC & (_BV(PC3) | _BV(PC7))) == 0) { - // naptime! - // But not before both buttons have been pressed for - // SHUTDOWN_THRESHOLD * 0.256 ms. And then, not before both have - // been released, because otherwise we'd go te sleep when - // they're pressed and wake up when they're released, which - // isn't really the point here. - - if (want_shutdown < SHUTDOWN_THRESHOLD) { - want_shutdown++; - } - else { - - // turn off display to indicate we're about to shut down - display.turn_off(); - - // wait until both buttons are released - while (!((PINC & _BV(PC3)) && (PINC & _BV(PC7)))) ; - - // and some more to debounce the buttons - _delay_ms(10); - - // actual naptime - - // enable PCINT on PC3 (PCINT11) and PC7 (PCINT15) for wakeup - PCMSK1 |= _BV(PCINT15) | _BV(PCINT11); - PCICR |= _BV(PCIE1); - - // go to power-down mode - SMCR = _BV(SM1) | _BV(SE); - asm("sleep"); - - // execution will resume here - disable PCINT again. - // Don't disable PCICR, something else might need it. - PCMSK1 &= ~(_BV(PCINT15) | _BV(PCINT11)); - - // turn on display - display.turn_on(); - - want_shutdown = 0; - } - } - else { - want_shutdown = 0; - } -} - -int main (void) -{ - // disable ADC to save power - PRR |= _BV(PRADC); - - // dito - wdt_disable(); - - // Ports B and D drive the dot matrix display -> set all as output - DDRB = 0xff; - DDRD = 0xff; - PORTB = 0; - PORTD = 0; - - // Enable pull-ups on PC3 and PC7 (button pins) - PORTC |= _BV(PC3) | _BV(PC7); - - // Enable 8bit counter with prescaler=8 (-> timer frequency = 1MHz) - TCCR0A = _BV(CS01); - // raise timer interrupt on counter overflow (-> interrupt frequency = ~4kHz) - TIMSK0 = _BV(TOIE0); - - disp[0] = font[8][1]; - disp[1] = font[8][2]; - disp[2] = font[8][3]; - disp[3] = font[8][4]; - disp[4] = font[8][5]; - disp[5] = font[8][6]; - disp[6] = font[8][7]; - disp[7] = font[8][8]; - -#if 0 - // smile! - disp[0] = 0x08; - disp[1] = 0x04; - disp[2] = 0x62; - disp[3] = 0x02; - disp[4] = 0x02; - disp[5] = 0x62; - disp[6] = 0x04; - disp[7] = 0x08; - disp[8] = 0x00; - disp[9] = 0x00; - disp[10] = 0x00; - disp[11] = 0x00; - disp[12] = 0x00; - disp[13] = 0x00; - disp[14] = 0x00; - disp[15] = 0x00; - disp[16] = 0x28; - disp[17] = 0x44; - disp[18] = 0x22; - disp[19] = 0x02; - disp[20] = 0x02; - disp[21] = 0x22; - disp[22] = 0x44; - disp[23] = 0x28; - disp[24] = 0x00; - disp[25] = 0x00; - disp[26] = 0x00; - disp[27] = 0x00; - disp[28] = 0x00; - disp[29] = 0x00; - disp[30] = 0x00; - disp[31] = 0x00; -#endif - - sei(); - - while (1) { - // nothing to do here, go to idle to save power - SMCR = _BV(SE); - asm("sleep"); - rocket.loop(); - } - - return 0; -} - -/* - * Draws a single display column. This function should be called at least once - * per millisecond. - * - * Current configuration: - * Called every 256 microseconds. The whole display is refreshed every 2048us, - * giving a refresh rate of ~500Hz - */ -ISR(TIMER0_OVF_vect) -{ - static uint8_t active_col = 0; - static uint16_t scroll = 0; - static uint8_t disp_offset = 0; - - static uint8_t disp_buf[8]; - - uint8_t i; - - if (++scroll == 512) { - scroll = 0; - if (++disp_offset == sizeof(disp)) { - disp_offset = 0; - } - - for (i = 0; i < 8; i++) { - disp_buf[i] = ~disp[(disp_offset + i) % sizeof(disp)]; - } - } - - /* - * To avoid flickering, do not put any code (or expensive index - * calculations) between the following three lines. - */ - PORTB = 0; - PORTD = disp_buf[active_col]; - PORTB = _BV(active_col); - - if (++active_col == 8) - active_col = 0; -} - -ISR(PCINT1_vect) -{ - // we use PCINT1 for wakeup, so we should catch it here (and do nothing) -} diff --git a/modem.c b/modem.c deleted file mode 100644 index dbe9d35..0000000 --- a/modem.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Name: modem.c - * - * Audio modem for Attiny85 & other AVR chips with modifications - * - * Author: Jari Tulilahti - * Copyright: 2014 Rakettitiede Oy - * License: LGPLv3, see COPYING, and COPYING.LESSER -files for more info - */ - -#include "modem.h" - -/* Ring buffer global variables */ -static volatile uint8_t modem_buffer_head = 0, modem_buffer_tail = 0; -static volatile uint8_t modem_buffer[MODEM_BUFFER_SIZE]; - -/* - * Returns number of available bytes in ringbuffer or 0 if empty - */ -uint8_t modem_buffer_available() { - return modem_buffer_head - modem_buffer_tail; -} - -/* - * Store 1 byte in ringbuffer - */ -static inline void modem_buffer_put(const uint8_t c) { - if (modem_buffer_available() != MODEM_BUFFER_SIZE) { - modem_buffer[modem_buffer_head++ % MODEM_BUFFER_SIZE] = c; - } -} - -/* - * Fetch 1 byte from ringbuffer - */ -uint8_t modem_buffer_get() { - uint8_t b = 0; - if (modem_buffer_available() != 0) { - b = modem_buffer[modem_buffer_tail++ % MODEM_BUFFER_SIZE]; - } - return b; -} - -/* - * Pin Change Interrupt Vector. This is The Modem. - */ -ISR(PCINT3_vect) { - /* Static variables instead of globals to keep scope inside ISR */ - static uint8_t modem_bit = 0; - static uint8_t modem_bitlen = 0; - static uint8_t modem_byte = 0; - - /* Read & Zero Timer/Counter 1 value */ - uint8_t modem_pulselen = MODEM_TIMER; - MODEM_TIMER = 0; - - /* - * Check if we received Start/Sync -pulse. - * Calculate bit signal length middle point from pulse. - * Return from ISR immediately. - */ - if (modem_pulselen > MODEM_SYNC_LEN) { - modem_bitlen = (modem_pulselen >> 2); - modem_bit = 0; - return; - } - - /* - * Shift byte and set high bit according to the pulse length. - * Long pulse = 1, Short pulse = 0 - */ - modem_byte = (modem_byte >> 1) | (modem_pulselen < modem_bitlen ? 0x00 : 0x80); - - /* Check if we received complete byte and store it in ring buffer */ - if (!(++modem_bit % 0x08)) { - modem_buffer_put(modem_byte); - } -} - -/* - * Start the modem by enabling Pin Change Interrupts & Timer - */ -void modem_init() { - /* Modem pin as input */ - MODEM_DDR &= ~(1 << MODEM_PIN); - - /* Enable Pin Change Interrupts and PCINT for MODEM_PIN */ - PCMSK1 |= _BV(MODEM_PIN); - PCICR |= _BV(PCIE3); - - /* Timer: TCCR1: CS10 and CS11 bits: 8MHz clock with Prescaler 64 = 125kHz timer clock */ - TCCR1B = _BV(CS11) | _BV(CS10); - - /* Enable interrupts */ - sei(); -} diff --git a/modem.h b/modem.h deleted file mode 100644 index d538c22..0000000 --- a/modem.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Name: modem.h - * Author: Jari Tulilahti - * Copyright: 2014 Rakettitiede Oy - * License: LGPLv3, see COPYING, and COPYING.LESSER -files for more info - */ - -#pragma once - -#include -#include - -/* Modem ring buffer size must be power of 2 */ -#define MODEM_BUFFER_SIZE 4 - -/* Modem defines */ -#define MODEM_SYNC_LEN 42 -#define MODEM_TIMER TCNT1L -#define MODEM_PIN PCINT24 -#define MODEM_DDR DDRA - -/* Public funtions */ -uint8_t modem_buffer_available(); -uint8_t modem_buffer_get(); -void modem_init(); diff --git a/src/font.h b/src/font.h new file mode 100644 index 0000000..839277b --- /dev/null +++ b/src/font.h @@ -0,0 +1,264 @@ +#ifndef FONT_H_ +#define FONT_H_ + +#include + +typedef const unsigned char* glyph_t; + +const unsigned char PROGMEM chr_001[] = {0x08, 0x00, 0x20, 0x44, 0x40, 0x44, 0x20, 0x00, 0x00}; // happy smiley +const unsigned char PROGMEM chr_002[] = {0x08, 0x00, 0x40, 0x24, 0x20, 0x24, 0x40, 0x00, 0x00}; // sad smiley +const unsigned char PROGMEM chr_003[] = {0x05, 0x18, 0xEC, 0x5C, 0xEC, 0x18}; // skull +const unsigned char PROGMEM chr_004[] = {0x05, 0x18, 0x24, 0x48, 0x24, 0x18}; // heart +const unsigned char PROGMEM chr_005[] = {0x05, 0xD8, 0x34, 0xDE, 0x34, 0xD8}; // invader1 +const unsigned char PROGMEM chr_006[] = {0x05, 0xFA, 0xB4, 0x3C, 0xB4, 0xFA}; // invader2 +const unsigned char PROGMEM chr_007[] = {0x05, 0x9C, 0xF6, 0x1E, 0xF6, 0x9C}; // invader3 +const unsigned char PROGMEM chr_008[] = {0x05, 0xF8, 0x74, 0xFC, 0x74, 0xF8}; // ghost +const unsigned char PROGMEM chr_009[] = {0x05, 0x3C, 0x68, 0xF8, 0x68, 0x3C}; // fox +const unsigned char PROGMEM chr_010[] = {0x07, 0x7C, 0x40, 0x40, 0x00, 0x7C, 0x14, 0x04}; // +const unsigned char PROGMEM chr_011[] = {0x05, 0x60, 0x60, 0x3E, 0xCA, 0xFC}; // 2 musical notes +const unsigned char PROGMEM chr_012[] = {0x04, 0xC0, 0xFE, 0x04, 0x18}; // musical note +const unsigned char PROGMEM chr_013[] = {0x07, 0x38, 0x44, 0x44, 0x00, 0x7C, 0x14, 0x68}; // +const unsigned char PROGMEM chr_014[] = {0x05, 0x06, 0x8A, 0xF2, 0x8A, 0x06}; // glass +const unsigned char PROGMEM chr_015[] = {0x04, 0xFC, 0xF4, 0xF4, 0xFE}; // mobile +const unsigned char PROGMEM chr_016[] = {0x04, 0xE0, 0xCC, 0xAA, 0x19}; // flash +const unsigned char PROGMEM chr_017[] = {0x05, 0x0E, 0x71, 0xF9, 0x71, 0x0E}; // lightbulb +const unsigned char PROGMEM chr_018[] = {0x05, 0x10, 0x38, 0x54, 0x10, 0x10}; // <- +const unsigned char PROGMEM chr_019[] = {0x05, 0x10, 0x10, 0x54, 0x38, 0x10}; // -> +const unsigned char PROGMEM chr_020[] = {0x05, 0x60, 0x90, 0x9A, 0x66, 0x0E}; // male +const unsigned char PROGMEM chr_021[] = {0x05, 0x0C, 0x52, 0xF2, 0x52, 0x0C}; // female +const unsigned char PROGMEM chr_022[] = {0x07, 0x0C, 0xEE, 0xB2, 0x9A, 0xB2, 0xEE, 0x0C}; // telephone +const unsigned char PROGMEM chr_023[] = {0x05, 0x88, 0x48, 0x3A, 0x48, 0x88}; // stick figure +const unsigned char PROGMEM chr_024[] = {0x07, 0x10, 0x28, 0x54, 0xAA, 0x54, 0x28, 0x10}; // diamond +const unsigned char PROGMEM chr_025[] = {0x05, 0x38, 0x44, 0x5C, 0x54, 0x38}; // clock +const unsigned char PROGMEM chr_026[] = {0x05, 0x20, 0x3C, 0x7E, 0x3C, 0x20}; // bell +const unsigned char PROGMEM chr_027[] = {0x05, 0xC6, 0xAA, 0x92, 0x82, 0x82}; // sigma +const unsigned char PROGMEM chr_028[] = {0x05, 0xB8, 0xC4, 0x04, 0xC4, 0xB8}; // omega +const unsigned char PROGMEM chr_029[] = {0x06, 0x10, 0x38, 0x7C, 0xFE, 0xC6, 0x82}; // left +const unsigned char PROGMEM chr_030[] = {0x06, 0x82, 0xC6, 0xFE, 0x7C, 0x38, 0x10}; // right +const unsigned char PROGMEM chr_031[] = {0x07, 0x70, 0x88, 0x70, 0x00, 0xFE, 0x10, 0xEC}; // ok +const unsigned char PROGMEM chr_032[] = {0x03, 0x00, 0x00, 0x00}; // +const unsigned char PROGMEM chr_033[] = {0x01, 0xBE}; // ! +const unsigned char PROGMEM chr_034[] = {0x03, 0x06, 0x00, 0x06}; // " +const unsigned char PROGMEM chr_035[] = {0x05, 0x28, 0xFE, 0x28, 0xFE, 0x28}; // # +const unsigned char PROGMEM chr_036[] = {0x05, 0x48, 0x54, 0xFE, 0x54, 0x24}; // $ +const unsigned char PROGMEM chr_037[] = {0x05, 0x46, 0x26, 0x10, 0xC8, 0xC4}; // % +const unsigned char PROGMEM chr_038[] = {0x05, 0x6C, 0x92, 0xAC, 0x40, 0xA0}; // & +const unsigned char PROGMEM chr_039[] = {0x02, 0x0A, 0x06}; // ' +const unsigned char PROGMEM chr_040[] = {0x03, 0x38, 0x44, 0x82}; // ( +const unsigned char PROGMEM chr_041[] = {0x03, 0x82, 0x44, 0x38}; // ) +const unsigned char PROGMEM chr_042[] = {0x05, 0x44, 0x28, 0xD6, 0x28, 0x44}; // * +const unsigned char PROGMEM chr_043[] = {0x05, 0x10, 0x10, 0x7C, 0x10, 0x10}; // + +const unsigned char PROGMEM chr_044[] = {0x02, 0x80, 0x40}; // , +const unsigned char PROGMEM chr_045[] = {0x04, 0x10, 0x10, 0x10, 0x10}; // - +const unsigned char PROGMEM chr_046[] = {0x01, 0x80}; // . +const unsigned char PROGMEM chr_047[] = {0x05, 0xC0, 0x20, 0x10, 0x08, 0x06}; // / +const unsigned char PROGMEM chr_048[] = {0x04, 0x7C, 0x82, 0x82, 0x7C}; // 0 +const unsigned char PROGMEM chr_049[] = {0x03, 0x84, 0xFE, 0x80}; // 1 +const unsigned char PROGMEM chr_050[] = {0x04, 0xC4, 0xA2, 0x92, 0x8C}; // 2 +const unsigned char PROGMEM chr_051[] = {0x04, 0x44, 0x82, 0x92, 0x6C}; // 3 +const unsigned char PROGMEM chr_052[] = {0x04, 0x30, 0x28, 0x24, 0xFE}; // 4 +const unsigned char PROGMEM chr_053[] = {0x04, 0x4E, 0x8A, 0x8A, 0x72}; // 5 +const unsigned char PROGMEM chr_054[] = {0x04, 0x78, 0x94, 0x92, 0x62}; // 6 +const unsigned char PROGMEM chr_055[] = {0x04, 0x02, 0xE2, 0x1A, 0x06}; // 7 +const unsigned char PROGMEM chr_056[] = {0x04, 0x6C, 0x92, 0x92, 0x6C}; // 8 +const unsigned char PROGMEM chr_057[] = {0x04, 0x0C, 0x92, 0x52, 0x3C}; // 9 +const unsigned char PROGMEM chr_058[] = {0x01, 0x50}; // : +const unsigned char PROGMEM chr_059[] = {0x02, 0x80, 0x50}; // ; +const unsigned char PROGMEM chr_060[] = {0x04, 0x10, 0x28, 0x44, 0x82}; // < +const unsigned char PROGMEM chr_061[] = {0x04, 0x28, 0x28, 0x28, 0x28}; // = +const unsigned char PROGMEM chr_062[] = {0x04, 0x82, 0x44, 0x28, 0x10}; // > +const unsigned char PROGMEM chr_063[] = {0x04, 0x04, 0xA2, 0x12, 0x0C}; // ? +const unsigned char PROGMEM chr_064[] = {0x05, 0x64, 0x92, 0xF2, 0x82, 0x7C}; // @ +const unsigned char PROGMEM chr_065[] = {0x04, 0xFC, 0x12, 0x12, 0xFC}; // A +const unsigned char PROGMEM chr_066[] = {0x04, 0xFE, 0x92, 0x92, 0x6C}; // B +const unsigned char PROGMEM chr_067[] = {0x04, 0x7C, 0x82, 0x82, 0x44}; // C +const unsigned char PROGMEM chr_068[] = {0x04, 0xFE, 0x82, 0x82, 0x7C}; // D +const unsigned char PROGMEM chr_069[] = {0x04, 0xFE, 0x92, 0x92, 0x82}; // E +const unsigned char PROGMEM chr_070[] = {0x04, 0xFE, 0x12, 0x12, 0x02}; // F +const unsigned char PROGMEM chr_071[] = {0x04, 0x7C, 0x82, 0x92, 0x74}; // G +const unsigned char PROGMEM chr_072[] = {0x04, 0xFE, 0x10, 0x10, 0xFE}; // H +const unsigned char PROGMEM chr_073[] = {0x03, 0x82, 0xFE, 0x82}; // I +const unsigned char PROGMEM chr_074[] = {0x04, 0x40, 0x80, 0x80, 0x7E}; // J +const unsigned char PROGMEM chr_075[] = {0x04, 0xFE, 0x10, 0x28, 0xC6}; // K +const unsigned char PROGMEM chr_076[] = {0x04, 0xFE, 0x80, 0x80, 0x80}; // L +const unsigned char PROGMEM chr_077[] = {0x05, 0xFE, 0x04, 0x18, 0x04, 0xFE}; // M +const unsigned char PROGMEM chr_078[] = {0x04, 0xFE, 0x0C, 0x30, 0xFE}; // N +const unsigned char PROGMEM chr_079[] = {0x04, 0x7C, 0x82, 0x82, 0x7C}; // O +const unsigned char PROGMEM chr_080[] = {0x04, 0xFE, 0x12, 0x12, 0x0C}; // P +const unsigned char PROGMEM chr_081[] = {0x04, 0x7C, 0x82, 0x42, 0xBC}; // Q +const unsigned char PROGMEM chr_082[] = {0x04, 0xFE, 0x12, 0x32, 0xCC}; // R +const unsigned char PROGMEM chr_083[] = {0x04, 0x4C, 0x92, 0x92, 0x64}; // S +const unsigned char PROGMEM chr_084[] = {0x05, 0x02, 0x02, 0xFE, 0x02, 0x02}; // T +const unsigned char PROGMEM chr_085[] = {0x04, 0x7E, 0x80, 0x80, 0x7E}; // U +const unsigned char PROGMEM chr_086[] = {0x05, 0x0E, 0x30, 0xC0, 0x30, 0x0E}; // V +const unsigned char PROGMEM chr_087[] = {0x05, 0x7E, 0x80, 0x70, 0x80, 0x7E}; // W +const unsigned char PROGMEM chr_088[] = {0x05, 0xC6, 0x28, 0x10, 0x28, 0xC6}; // X +const unsigned char PROGMEM chr_089[] = {0x05, 0x06, 0x08, 0xF0, 0x08, 0x06}; // Y +const unsigned char PROGMEM chr_090[] = {0x04, 0xC2, 0xB2, 0x8A, 0x86}; // Z +const unsigned char PROGMEM chr_091[] = {0x03, 0xFE, 0x82, 0x82}; // [ +const unsigned char PROGMEM chr_092[] = {0x05, 0x06, 0x08, 0x10, 0x20, 0xC0}; // backslash +const unsigned char PROGMEM chr_093[] = {0x03, 0x82, 0x82, 0xFE}; // ] +const unsigned char PROGMEM chr_094[] = {0x03, 0x04, 0x02, 0x04}; // ^ +const unsigned char PROGMEM chr_095[] = {0x04, 0x80, 0x80, 0x80, 0x80}; // _ +const unsigned char PROGMEM chr_096[] = {0x02, 0x06, 0x08}; // ` +const unsigned char PROGMEM chr_097[] = {0x04, 0x40, 0xA8, 0xA8, 0xF0}; // a +const unsigned char PROGMEM chr_098[] = {0x04, 0xFE, 0x88, 0x88, 0x70}; // b +const unsigned char PROGMEM chr_099[] = {0x04, 0x70, 0x88, 0x88, 0x40}; // c +const unsigned char PROGMEM chr_100[] = {0x04, 0x70, 0x88, 0x88, 0xFE}; // d +const unsigned char PROGMEM chr_101[] = {0x04, 0x70, 0xA8, 0xA8, 0x90}; // e +const unsigned char PROGMEM chr_102[] = {0x04, 0x08, 0xFC, 0x0A, 0x02}; // f +const unsigned char PROGMEM chr_103[] = {0x04, 0x10, 0xA8, 0xA8, 0x78}; // g +const unsigned char PROGMEM chr_104[] = {0x04, 0xFE, 0x10, 0x10, 0xE0}; // h +const unsigned char PROGMEM chr_105[] = {0x01, 0xFA}; // i +const unsigned char PROGMEM chr_106[] = {0x03, 0x40, 0x80, 0x7A}; // j +const unsigned char PROGMEM chr_107[] = {0x04, 0xFE, 0x10, 0x28, 0xC4}; // k +const unsigned char PROGMEM chr_108[] = {0x03, 0x82, 0xFE, 0x80}; // l +const unsigned char PROGMEM chr_109[] = {0x05, 0xF8, 0x08, 0xF0, 0x08, 0xF0}; // m +const unsigned char PROGMEM chr_110[] = {0x04, 0xF8, 0x08, 0x08, 0xF0}; // n +const unsigned char PROGMEM chr_111[] = {0x04, 0x70, 0x88, 0x88, 0x70}; // o +const unsigned char PROGMEM chr_112[] = {0x04, 0xF8, 0x48, 0x48, 0x30}; // p +const unsigned char PROGMEM chr_113[] = {0x04, 0x30, 0x48, 0x48, 0xF8}; // q +const unsigned char PROGMEM chr_114[] = {0x03, 0xF0, 0x08, 0x08}; // r +const unsigned char PROGMEM chr_115[] = {0x04, 0x90, 0xA8, 0xA8, 0x48}; // s +const unsigned char PROGMEM chr_116[] = {0x04, 0x08, 0x7E, 0x88, 0x88}; // t +const unsigned char PROGMEM chr_117[] = {0x04, 0x78, 0x80, 0x80, 0xF8}; // u +const unsigned char PROGMEM chr_118[] = {0x05, 0x18, 0x60, 0x80, 0x60, 0x18}; // v +const unsigned char PROGMEM chr_119[] = {0x05, 0x78, 0x80, 0x60, 0x80, 0x78}; // w +const unsigned char PROGMEM chr_120[] = {0x05, 0x88, 0x50, 0x20, 0x50, 0x88}; // x +const unsigned char PROGMEM chr_121[] = {0x04, 0x18, 0xA0, 0xA0, 0x78}; // y +const unsigned char PROGMEM chr_122[] = {0x04, 0xC8, 0xA8, 0x98, 0x88}; // z +const unsigned char PROGMEM chr_123[] = {0x03, 0x10, 0x6C, 0x82}; // { +const unsigned char PROGMEM chr_124[] = {0x01, 0xFF}; // | +const unsigned char PROGMEM chr_125[] = {0x03, 0x82, 0x6C, 0x10}; // } +const unsigned char PROGMEM chr_126[] = {0x05, 0x10, 0x08, 0x10, 0x20, 0x10}; // ~ + +const glyph_t font[] PROGMEM = { + chr_001, + chr_002, + chr_003, + chr_004, + chr_005, + chr_006, + chr_007, + chr_008, + chr_009, + chr_010, + chr_011, + chr_012, + chr_013, + chr_014, + chr_015, + chr_016, + chr_017, + chr_018, + chr_019, + chr_020, + chr_021, + chr_022, + chr_023, + chr_024, + chr_025, + chr_026, + chr_027, + chr_028, + chr_029, + chr_030, + chr_031, + chr_032, + chr_033, + chr_034, + chr_035, + chr_036, + chr_037, + chr_038, + chr_039, + chr_040, + chr_041, + chr_042, + chr_043, + chr_044, + chr_045, + chr_046, + chr_047, + chr_048, + chr_049, + chr_050, + chr_051, + chr_052, + chr_053, + chr_054, + chr_055, + chr_056, + chr_057, + chr_058, + chr_059, + chr_060, + chr_061, + chr_062, + chr_063, + chr_064, + chr_065, + chr_066, + chr_067, + chr_068, + chr_069, + chr_070, + chr_071, + chr_072, + chr_073, + chr_074, + chr_075, + chr_076, + chr_077, + chr_078, + chr_079, + chr_080, + chr_081, + chr_082, + chr_083, + chr_084, + chr_085, + chr_086, + chr_087, + chr_088, + chr_089, + chr_090, + chr_091, + chr_092, + chr_093, + chr_094, + chr_095, + chr_096, + chr_097, + chr_098, + chr_099, + chr_100, + chr_101, + chr_102, + chr_103, + chr_104, + chr_105, + chr_106, + chr_107, + chr_108, + chr_109, + chr_110, + chr_111, + chr_112, + chr_113, + chr_114, + chr_115, + chr_116, + chr_117, + chr_118, + chr_119, + chr_120, + chr_121, + chr_122, + chr_123, + chr_124, + chr_125, + chr_126 +}; + +#endif /* FONT_H_ */ diff --git a/src/font2.h b/src/font2.h new file mode 100644 index 0000000..aea6b8a --- /dev/null +++ b/src/font2.h @@ -0,0 +1,266 @@ +#ifndef FONT_H_ +#define FONT_H_ + +#include + +typedef const unsigned char* glyph_t; + +const unsigned char PROGMEM chr_001[] = {0x08,0x00,0x04,0x22,0x02,0x22,0x04,0x00,0x00}; // happy smiley +const unsigned char PROGMEM chr_002[] = {0x08,0x00,0x02,0x24,0x04,0x24,0x02,0x00,0x00}; // sad smiley +const unsigned char PROGMEM chr_003[] = {0x05,0x18,0x37,0x3a,0x37,0x18}; // skull +const unsigned char PROGMEM chr_004[] = {0x05,0x18,0x24,0x12,0x24,0x18}; // heart +const unsigned char PROGMEM chr_005[] = {0x05,0x1b,0x2c,0x7b,0x2c,0x1b}; // invader1 +const unsigned char PROGMEM chr_006[] = {0x05,0x5f,0x2d,0x3c,0x2d,0x5f}; // invader2 +const unsigned char PROGMEM chr_007[] = {0x05,0x39,0x6f,0x78,0x6f,0x39}; // invader3 +const unsigned char PROGMEM chr_008[] = {0x05,0x1f,0x2e,0x3f,0x2e,0x1f}; // ghost +const unsigned char PROGMEM chr_009[] = {0x05,0x3c,0x16,0x1f,0x16,0x3c}; // fox +const unsigned char PROGMEM chr_010[] = {0x07,0x3e,0x02,0x02,0x00,0x3e,0x28,0x20}; // +const unsigned char PROGMEM chr_011[] = {0x05,0x06,0x06,0x7c,0x53,0x3f}; // 2 musical notes +const unsigned char PROGMEM chr_012[] = {0x04,0x03,0x7f,0x20,0x18}; // musical note +const unsigned char PROGMEM chr_013[] = {0x07,0x1c,0x22,0x22,0x00,0x3e,0x28,0x16}; // +const unsigned char PROGMEM chr_014[] = {0x05,0x60,0x51,0x4f,0x51,0x60}; // glass +const unsigned char PROGMEM chr_015[] = {0x04,0x3f,0x2f,0x2f,0x7f}; // mobile +const unsigned char PROGMEM chr_016[] = {0x04,0x07,0x33,0x55,0x98}; // flash +const unsigned char PROGMEM chr_017[] = {0x05,0x70,0x8e,0x9f,0x8e,0x70}; // lightbulb +const unsigned char PROGMEM chr_018[] = {0x05,0x08,0x1c,0x2a,0x08,0x08}; // <- +const unsigned char PROGMEM chr_019[] = {0x05,0x08,0x08,0x2a,0x1c,0x08}; // -> +const unsigned char PROGMEM chr_020[] = {0x05,0x06,0x09,0x59,0x66,0x70}; // male +const unsigned char PROGMEM chr_021[] = {0x05,0x30,0x4a,0x4f,0x4a,0x30}; // female +const unsigned char PROGMEM chr_022[] = {0x07,0x30,0x77,0x4d,0x59,0x4d,0x77,0x30}; // telephone +const unsigned char PROGMEM chr_023[] = {0x05,0x11,0x12,0x5c,0x12,0x11}; // stick figure +const unsigned char PROGMEM chr_024[] = {0x07,0x08,0x14,0x2a,0x55,0x2a,0x14,0x08}; // diamond +const unsigned char PROGMEM chr_025[] = {0x05,0x1c,0x22,0x3a,0x2a,0x1c}; // clock +const unsigned char PROGMEM chr_026[] = {0x05,0x04,0x3c,0x7e,0x3c,0x04}; // bell +const unsigned char PROGMEM chr_027[] = {0x05,0x63,0x55,0x49,0x41,0x41}; // sigma +const unsigned char PROGMEM chr_028[] = {0x05,0x1d,0x23,0x20,0x23,0x1d}; // omega +const unsigned char PROGMEM chr_029[] = {0x06,0x08,0x1c,0x3e,0x7f,0x63,0x41}; // left +const unsigned char PROGMEM chr_030[] = {0x06,0x41,0x63,0x7f,0x3e,0x1c,0x08}; // right +const unsigned char PROGMEM chr_031[] = {0x07,0x0e,0x11,0x0e,0x00,0x7f,0x08,0x37}; // ok +const unsigned char PROGMEM chr_032[] = {0x03,0x00,0x00,0x00}; // +const unsigned char PROGMEM chr_033[] = {0x01,0x7d}; // ! +const unsigned char PROGMEM chr_034[] = {0x03,0x60,0x00,0x60}; // " +const unsigned char PROGMEM chr_035[] = {0x05,0x14,0x7f,0x14,0x7f,0x14}; // # +const unsigned char PROGMEM chr_036[] = {0x05,0x12,0x2a,0x7f,0x2a,0x24}; // $ +const unsigned char PROGMEM chr_037[] = {0x05,0x62,0x64,0x08,0x13,0x23}; // % +const unsigned char PROGMEM chr_038[] = {0x05,0x36,0x49,0x35,0x02,0x05}; // & +const unsigned char PROGMEM chr_039[] = {0x02,0x50,0x60}; // ' +const unsigned char PROGMEM chr_040[] = {0x03,0x1c,0x22,0x41}; // ( +const unsigned char PROGMEM chr_041[] = {0x03,0x41,0x22,0x1c}; // ) +const unsigned char PROGMEM chr_042[] = {0x05,0x22,0x14,0x6b,0x14,0x22}; // * +const unsigned char PROGMEM chr_043[] = {0x05,0x08,0x08,0x3e,0x08,0x08}; // + +const unsigned char PROGMEM chr_044[] = {0x02,0x01,0x02}; // , +const unsigned char PROGMEM chr_045[] = {0x04,0x08,0x08,0x08,0x08}; // - +const unsigned char PROGMEM chr_046[] = {0x01,0x01}; // . +const unsigned char PROGMEM chr_047[] = {0x05,0x03,0x04,0x08,0x10,0x60}; // / +const unsigned char PROGMEM chr_048[] = {0x04,0x3e,0x41,0x41,0x3e}; // 0 +const unsigned char PROGMEM chr_049[] = {0x03,0x21,0x7f,0x01}; // 1 +const unsigned char PROGMEM chr_050[] = {0x04,0x23,0x45,0x49,0x31}; // 2 +const unsigned char PROGMEM chr_051[] = {0x04,0x22,0x41,0x49,0x36}; // 3 +const unsigned char PROGMEM chr_052[] = {0x04,0x0c,0x14,0x24,0x7f}; // 4 +const unsigned char PROGMEM chr_053[] = {0x04,0x72,0x51,0x51,0x4e}; // 5 +const unsigned char PROGMEM chr_054[] = {0x04,0x1e,0x29,0x49,0x46}; // 6 +const unsigned char PROGMEM chr_055[] = {0x04,0x40,0x47,0x58,0x60}; // 7 +const unsigned char PROGMEM chr_056[] = {0x04,0x36,0x49,0x49,0x36}; // 8 +const unsigned char PROGMEM chr_057[] = {0x04,0x30,0x49,0x4a,0x3c}; // 9 +const unsigned char PROGMEM chr_058[] = {0x01,0x0a}; // : +const unsigned char PROGMEM chr_059[] = {0x02,0x01,0x0a}; // ; +const unsigned char PROGMEM chr_060[] = {0x04,0x08,0x14,0x22,0x41}; // < +const unsigned char PROGMEM chr_061[] = {0x04,0x14,0x14,0x14,0x14}; // = +const unsigned char PROGMEM chr_062[] = {0x04,0x41,0x22,0x14,0x08}; // > +const unsigned char PROGMEM chr_063[] = {0x04,0x20,0x45,0x48,0x30}; // ? +const unsigned char PROGMEM chr_064[] = {0x05,0x26,0x49,0x4f,0x41,0x3e}; // @ +const unsigned char PROGMEM chr_065[] = {0x04,0x3f,0x48,0x48,0x3f}; // A +const unsigned char PROGMEM chr_066[] = {0x04,0x7f,0x49,0x49,0x36}; // B +const unsigned char PROGMEM chr_067[] = {0x04,0x3e,0x41,0x41,0x22}; // C +const unsigned char PROGMEM chr_068[] = {0x04,0x7f,0x41,0x41,0x3e}; // D +const unsigned char PROGMEM chr_069[] = {0x04,0x7f,0x49,0x49,0x41}; // E +const unsigned char PROGMEM chr_070[] = {0x04,0x7f,0x48,0x48,0x40}; // F +const unsigned char PROGMEM chr_071[] = {0x04,0x3e,0x41,0x49,0x2e}; // G +const unsigned char PROGMEM chr_072[] = {0x04,0x7f,0x08,0x08,0x7f}; // H +const unsigned char PROGMEM chr_073[] = {0x03,0x41,0x7f,0x41}; // I +const unsigned char PROGMEM chr_074[] = {0x04,0x02,0x01,0x01,0x7e}; // J +const unsigned char PROGMEM chr_075[] = {0x04,0x7f,0x08,0x14,0x63}; // K +const unsigned char PROGMEM chr_076[] = {0x04,0x7f,0x01,0x01,0x01}; // L +const unsigned char PROGMEM chr_077[] = {0x05,0x7f,0x20,0x18,0x20,0x7f}; // M +const unsigned char PROGMEM chr_078[] = {0x04,0x7f,0x30,0x0c,0x7f}; // N +const unsigned char PROGMEM chr_079[] = {0x04,0x3e,0x41,0x41,0x3e}; // O +const unsigned char PROGMEM chr_080[] = {0x04,0x7f,0x48,0x48,0x30}; // P +const unsigned char PROGMEM chr_081[] = {0x04,0x3e,0x41,0x42,0x3d}; // Q +const unsigned char PROGMEM chr_082[] = {0x04,0x7f,0x48,0x4c,0x33}; // R +const unsigned char PROGMEM chr_083[] = {0x04,0x32,0x49,0x49,0x26}; // S +const unsigned char PROGMEM chr_084[] = {0x05,0x40,0x40,0x7f,0x40,0x40}; // T +const unsigned char PROGMEM chr_085[] = {0x04,0x7e,0x01,0x01,0x7e}; // U +const unsigned char PROGMEM chr_086[] = {0x05,0x70,0x0c,0x03,0x0c,0x70}; // V +const unsigned char PROGMEM chr_087[] = {0x05,0x7e,0x01,0x0e,0x01,0x7e}; // W +const unsigned char PROGMEM chr_088[] = {0x05,0x63,0x14,0x08,0x14,0x63}; // X +const unsigned char PROGMEM chr_089[] = {0x05,0x60,0x10,0x0f,0x10,0x60}; // Y +const unsigned char PROGMEM chr_090[] = {0x04,0x43,0x4d,0x51,0x61}; // Z +const unsigned char PROGMEM chr_091[] = {0x03,0x7f,0x41,0x41}; // [ +const unsigned char PROGMEM chr_092[] = {0x05,0x60,0x10,0x08,0x04,0x03}; // backslash +const unsigned char PROGMEM chr_093[] = {0x03,0x41,0x41,0x7f}; // ] +const unsigned char PROGMEM chr_094[] = {0x03,0x20,0x40,0x20}; // ^ +const unsigned char PROGMEM chr_095[] = {0x04,0x01,0x01,0x01,0x01}; // _ +const unsigned char PROGMEM chr_096[] = {0x02,0x60,0x10}; // ` +const unsigned char PROGMEM chr_097[] = {0x04,0x02,0x15,0x15,0x0f}; // a +const unsigned char PROGMEM chr_098[] = {0x04,0x7f,0x11,0x11,0x0e}; // b +const unsigned char PROGMEM chr_099[] = {0x04,0x0e,0x11,0x11,0x02}; // c +const unsigned char PROGMEM chr_100[] = {0x04,0x0e,0x11,0x11,0x7f}; // d +const unsigned char PROGMEM chr_101[] = {0x04,0x0e,0x15,0x15,0x09}; // e +const unsigned char PROGMEM chr_102[] = {0x04,0x10,0x3f,0x50,0x40}; // f +const unsigned char PROGMEM chr_103[] = {0x04,0x08,0x15,0x15,0x1e}; // g +const unsigned char PROGMEM chr_104[] = {0x04,0x7f,0x08,0x08,0x07}; // h +const unsigned char PROGMEM chr_105[] = {0x01,0x5f}; // i +const unsigned char PROGMEM chr_106[] = {0x03,0x02,0x01,0x5e}; // j +const unsigned char PROGMEM chr_107[] = {0x04,0x7f,0x08,0x14,0x23}; // k +const unsigned char PROGMEM chr_108[] = {0x03,0x41,0x7f,0x01}; // l +const unsigned char PROGMEM chr_109[] = {0x05,0x1f,0x10,0x0f,0x10,0x0f}; // m +const unsigned char PROGMEM chr_110[] = {0x04,0x1f,0x10,0x10,0x0f}; // n +const unsigned char PROGMEM chr_111[] = {0x04,0x0e,0x11,0x11,0x0e}; // o +const unsigned char PROGMEM chr_112[] = {0x04,0x1f,0x12,0x12,0x0c}; // p +const unsigned char PROGMEM chr_113[] = {0x04,0x0c,0x12,0x12,0x1f}; // q +const unsigned char PROGMEM chr_114[] = {0x03,0x0f,0x10,0x10}; // r +const unsigned char PROGMEM chr_115[] = {0x04,0x09,0x15,0x15,0x12}; // s +const unsigned char PROGMEM chr_116[] = {0x04,0x10,0x7e,0x11,0x11}; // t +const unsigned char PROGMEM chr_117[] = {0x04,0x1e,0x01,0x01,0x1f}; // u +const unsigned char PROGMEM chr_118[] = {0x05,0x18,0x06,0x01,0x06,0x18}; // v +const unsigned char PROGMEM chr_119[] = {0x05,0x1e,0x01,0x06,0x01,0x1e}; // w +const unsigned char PROGMEM chr_120[] = {0x05,0x11,0x0a,0x04,0x0a,0x11}; // x +const unsigned char PROGMEM chr_121[] = {0x04,0x18,0x05,0x05,0x1e}; // y +const unsigned char PROGMEM chr_122[] = {0x04,0x13,0x15,0x19,0x11}; // z +const unsigned char PROGMEM chr_123[] = {0x03,0x08,0x36,0x41}; // { +const unsigned char PROGMEM chr_124[] = {0x01,0xff}; // | +const unsigned char PROGMEM chr_125[] = {0x03,0x41,0x36,0x08}; // } +const unsigned char PROGMEM chr_126[] = {0x05,0x08,0x10,0x08,0x04,0x08}; // ~ + +const glyph_t font[] PROGMEM = { + chr_001, + chr_002, + chr_003, + chr_004, + chr_005, + chr_006, + chr_007, + chr_008, + chr_009, + chr_010, + chr_011, + chr_012, + chr_013, + chr_014, + chr_015, + chr_016, + chr_017, + chr_018, + chr_019, + chr_020, + chr_021, + chr_022, + chr_023, + chr_024, + chr_025, + chr_026, + chr_027, + chr_028, + chr_029, + chr_030, + chr_031, + chr_032, + chr_033, + chr_034, + chr_035, + chr_036, + chr_037, + chr_038, + chr_039, + chr_040, + chr_041, + chr_042, + chr_043, + chr_044, + chr_045, + chr_046, + chr_047, + chr_048, + chr_049, + chr_050, + chr_051, + chr_052, + chr_053, + chr_054, + chr_055, + chr_056, + chr_057, + chr_058, + chr_059, + chr_060, + chr_061, + chr_062, + chr_063, + chr_064, + chr_065, + chr_066, + chr_067, + chr_068, + chr_069, + chr_070, + chr_071, + chr_072, + chr_073, + chr_074, + chr_075, + chr_076, + chr_077, + chr_078, + chr_079, + chr_080, + chr_081, + chr_082, + chr_083, + chr_084, + chr_085, + chr_086, + chr_087, + chr_088, + chr_089, + chr_090, + chr_091, + chr_092, + chr_093, + chr_094, + chr_095, + chr_096, + chr_097, + chr_098, + chr_099, + chr_100, + chr_101, + chr_102, + chr_103, + chr_104, + chr_105, + chr_106, + chr_107, + chr_108, + chr_109, + chr_110, + chr_111, + chr_112, + chr_113, + chr_114, + chr_115, + chr_116, + chr_117, + chr_118, + chr_119, + chr_120, + chr_121, + chr_122, + chr_123, + chr_124, + chr_125, + chr_126 +}; + + + +#endif /* FONT_H_ */ diff --git a/src/main.cc b/src/main.cc new file mode 100644 index 0000000..c51483d --- /dev/null +++ b/src/main.cc @@ -0,0 +1,217 @@ +#include +#include +#include +#include +#include + +#include "font2.h" + +#define SHUTDOWN_THRESHOLD 2048 + +volatile uint8_t disp[8]; + +class System { + private: + uint16_t want_shutdown; + public: + System() { want_shutdown = 0; }; + void loop(void); + void shutdown(void); +}; + +class Display { + public: + Display() {}; + void turn_on(void); + void turn_off(void); +}; + +System rocket; +Display display; + +void Display::turn_off() +{ + TIMSK0 &= ~_BV(TOIE0); + PORTB = 0; + PORTD = 0; +} + +void Display::turn_on() +{ + TIMSK0 |= _BV(TOIE0); +} + +void System::loop() +{ + // both buttons are pressed + if ((PINC & (_BV(PC3) | _BV(PC7))) == 0) { + // naptime! + // But not before both buttons have been pressed for + // SHUTDOWN_THRESHOLD * 0.256 ms. And then, not before both have + // been released, because otherwise we'd go te sleep when + // they're pressed and wake up when they're released, which + // isn't really the point here. + + if (want_shutdown < SHUTDOWN_THRESHOLD) { + want_shutdown++; + } + else { + + // turn off display to indicate we're about to shut down + display.turn_off(); + + // wait until both buttons are released + while (!((PINC & _BV(PC3)) && (PINC & _BV(PC7)))) ; + + // and some more to debounce the buttons + _delay_ms(10); + + // actual naptime + + // enable PCINT on PC3 (PCINT11) and PC7 (PCINT15) for wakeup + PCMSK1 |= _BV(PCINT15) | _BV(PCINT11); + PCICR |= _BV(PCIE1); + + // go to power-down mode + SMCR = _BV(SM1) | _BV(SE); + asm("sleep"); + + // execution will resume here - disable PCINT again. + // Don't disable PCICR, something else might need it. + PCMSK1 &= ~(_BV(PCINT15) | _BV(PCINT11)); + + // turn on display + display.turn_on(); + + want_shutdown = 0; + } + } + else { + want_shutdown = 0; + } +} + +int main (void) +{ + // disable ADC to save power + PRR |= _BV(PRADC); + + // dito + wdt_disable(); + + // Ports B and D drive the dot matrix display -> set all as output + DDRB = 0xff; + DDRD = 0xff; + PORTB = 0; + PORTD = 0; + + // Enable pull-ups on PC3 and PC7 (button pins) + PORTC |= _BV(PC3) | _BV(PC7); + + // Enable 8bit counter with prescaler=8 (-> timer frequency = 1MHz) + TCCR0A = _BV(CS01); + // raise timer interrupt on counter overflow (-> interrupt frequency = ~4kHz) + TIMSK0 = _BV(TOIE0); + + disp[0] = font[8][1]; + disp[1] = font[8][2]; + disp[2] = font[8][3]; + disp[3] = font[8][4]; + disp[4] = font[8][5]; + disp[5] = font[8][6]; + disp[6] = font[8][7]; + disp[7] = font[8][8]; + +#if 0 + // smile! + disp[0] = 0x08; + disp[1] = 0x04; + disp[2] = 0x62; + disp[3] = 0x02; + disp[4] = 0x02; + disp[5] = 0x62; + disp[6] = 0x04; + disp[7] = 0x08; + disp[8] = 0x00; + disp[9] = 0x00; + disp[10] = 0x00; + disp[11] = 0x00; + disp[12] = 0x00; + disp[13] = 0x00; + disp[14] = 0x00; + disp[15] = 0x00; + disp[16] = 0x28; + disp[17] = 0x44; + disp[18] = 0x22; + disp[19] = 0x02; + disp[20] = 0x02; + disp[21] = 0x22; + disp[22] = 0x44; + disp[23] = 0x28; + disp[24] = 0x00; + disp[25] = 0x00; + disp[26] = 0x00; + disp[27] = 0x00; + disp[28] = 0x00; + disp[29] = 0x00; + disp[30] = 0x00; + disp[31] = 0x00; +#endif + + sei(); + + while (1) { + // nothing to do here, go to idle to save power + SMCR = _BV(SE); + asm("sleep"); + rocket.loop(); + } + + return 0; +} + +/* + * Draws a single display column. This function should be called at least once + * per millisecond. + * + * Current configuration: + * Called every 256 microseconds. The whole display is refreshed every 2048us, + * giving a refresh rate of ~500Hz + */ +ISR(TIMER0_OVF_vect) +{ + static uint8_t active_col = 0; + static uint16_t scroll = 0; + static uint8_t disp_offset = 0; + + static uint8_t disp_buf[8]; + + uint8_t i; + + if (++scroll == 512) { + scroll = 0; + if (++disp_offset == sizeof(disp)) { + disp_offset = 0; + } + + for (i = 0; i < 8; i++) { + disp_buf[i] = ~disp[(disp_offset + i) % sizeof(disp)]; + } + } + + /* + * To avoid flickering, do not put any code (or expensive index + * calculations) between the following three lines. + */ + PORTB = 0; + PORTD = disp_buf[active_col]; + PORTB = _BV(active_col); + + if (++active_col == 8) + active_col = 0; +} + +ISR(PCINT1_vect) +{ + // we use PCINT1 for wakeup, so we should catch it here (and do nothing) +} diff --git a/src/modem.c b/src/modem.c new file mode 100644 index 0000000..dbe9d35 --- /dev/null +++ b/src/modem.c @@ -0,0 +1,95 @@ +/* Name: modem.c + * + * Audio modem for Attiny85 & other AVR chips with modifications + * + * Author: Jari Tulilahti + * Copyright: 2014 Rakettitiede Oy + * License: LGPLv3, see COPYING, and COPYING.LESSER -files for more info + */ + +#include "modem.h" + +/* Ring buffer global variables */ +static volatile uint8_t modem_buffer_head = 0, modem_buffer_tail = 0; +static volatile uint8_t modem_buffer[MODEM_BUFFER_SIZE]; + +/* + * Returns number of available bytes in ringbuffer or 0 if empty + */ +uint8_t modem_buffer_available() { + return modem_buffer_head - modem_buffer_tail; +} + +/* + * Store 1 byte in ringbuffer + */ +static inline void modem_buffer_put(const uint8_t c) { + if (modem_buffer_available() != MODEM_BUFFER_SIZE) { + modem_buffer[modem_buffer_head++ % MODEM_BUFFER_SIZE] = c; + } +} + +/* + * Fetch 1 byte from ringbuffer + */ +uint8_t modem_buffer_get() { + uint8_t b = 0; + if (modem_buffer_available() != 0) { + b = modem_buffer[modem_buffer_tail++ % MODEM_BUFFER_SIZE]; + } + return b; +} + +/* + * Pin Change Interrupt Vector. This is The Modem. + */ +ISR(PCINT3_vect) { + /* Static variables instead of globals to keep scope inside ISR */ + static uint8_t modem_bit = 0; + static uint8_t modem_bitlen = 0; + static uint8_t modem_byte = 0; + + /* Read & Zero Timer/Counter 1 value */ + uint8_t modem_pulselen = MODEM_TIMER; + MODEM_TIMER = 0; + + /* + * Check if we received Start/Sync -pulse. + * Calculate bit signal length middle point from pulse. + * Return from ISR immediately. + */ + if (modem_pulselen > MODEM_SYNC_LEN) { + modem_bitlen = (modem_pulselen >> 2); + modem_bit = 0; + return; + } + + /* + * Shift byte and set high bit according to the pulse length. + * Long pulse = 1, Short pulse = 0 + */ + modem_byte = (modem_byte >> 1) | (modem_pulselen < modem_bitlen ? 0x00 : 0x80); + + /* Check if we received complete byte and store it in ring buffer */ + if (!(++modem_bit % 0x08)) { + modem_buffer_put(modem_byte); + } +} + +/* + * Start the modem by enabling Pin Change Interrupts & Timer + */ +void modem_init() { + /* Modem pin as input */ + MODEM_DDR &= ~(1 << MODEM_PIN); + + /* Enable Pin Change Interrupts and PCINT for MODEM_PIN */ + PCMSK1 |= _BV(MODEM_PIN); + PCICR |= _BV(PCIE3); + + /* Timer: TCCR1: CS10 and CS11 bits: 8MHz clock with Prescaler 64 = 125kHz timer clock */ + TCCR1B = _BV(CS11) | _BV(CS10); + + /* Enable interrupts */ + sei(); +} diff --git a/src/modem.h b/src/modem.h new file mode 100644 index 0000000..d538c22 --- /dev/null +++ b/src/modem.h @@ -0,0 +1,24 @@ +/* Name: modem.h + * Author: Jari Tulilahti + * Copyright: 2014 Rakettitiede Oy + * License: LGPLv3, see COPYING, and COPYING.LESSER -files for more info + */ + +#pragma once + +#include +#include + +/* Modem ring buffer size must be power of 2 */ +#define MODEM_BUFFER_SIZE 4 + +/* Modem defines */ +#define MODEM_SYNC_LEN 42 +#define MODEM_TIMER TCNT1L +#define MODEM_PIN PCINT24 +#define MODEM_DDR DDRA + +/* Public funtions */ +uint8_t modem_buffer_available(); +uint8_t modem_buffer_get(); +void modem_init(); -- cgit v1.2.3