Skip to content

Commit a870a4b

Browse files
committed
Update to current state of development
1 parent 3823aea commit a870a4b

File tree

9 files changed

+110
-18
lines changed

9 files changed

+110
-18
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
*.bin
55
*.s#*
66
*.b#*
7+
*.l#*

board_ledmatrix/atmega644_ledmatrix.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ AVR_MCU(F_CPU, "atmega644");
1919

2020
#define SINGLE_LINE
2121

22-
char msg[] = " Hallo WeltäöüßÄÖÜ€! 1234567890";
22+
char msg[] = " Hallo Welt ! 1234567890";
2323
#ifdef SINGLE_LINE
2424
const uint16_t msg_length = 25;
2525
#else

main/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ CFLAGS=-mmcu=atmega644 -O2 -std=c99
1010
%.s: %.c
1111
avr-gcc $(CFLAGS) -S -o $@ $<
1212

13+
%.bin: %.o
14+
avr-objcopy -j .text -j .data -O binary $< $@
15+
1316
all: $(FILE)
1417
asm: $(FILE:.hex=.s)
1518

main/docs/data.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ different windows and their data:
1313
uint16 length of image
1414
uint8[] raw image shown
1515

16-
1: marquee2 (show text and if it is oversized, scroll it through)
16+
1: marquee2 (show text and if it is oversized, scroll it through) (2x uint8_t variables for scroll-position)
1717
uint8 options: 0: single line 1: dual line (+font)
1818
uint8 text length
1919
char[] ASCII Text
2020
optional, if options 1 bit is set:
2121
uint8 lower text length
2222
char[] lower ASCII Text
2323

24-
2: timedate
24+
2: timedate (0)
2525
uint8 options: 0: single line 1: dual line (+font)
2626
uint8 timedate options:
2727
bit 1: show time (0) or date (1)
@@ -38,14 +38,14 @@ uint8 timedate options:
3838
optional, if options bit 1 is set:
3939
uint8 lower timedate options (see above)
4040

41-
3: analogclock
41+
3: analogclock (0)
4242
uint8 options:
4343
bit 1: show seconds
4444

45-
4: tetrinet
45+
4: tetrinet (?)
4646
TODO
4747

48-
5: serial console
48+
5: serial console (character buffer = W*H/64 uint8_t variables)
4949
uint8 options: 0: single line 1: dual line (+font)
5050

5151
demo: (55 bytes)

main/main.c

+40-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#define F_CPU 8000000UL
66
#include <avr/io.h>
77
#include <util/delay.h>
8+
#include "font.h"
89

910
#define DATA_LOW PC4
1011
#define DATA_HIGH PC2
@@ -16,6 +17,9 @@
1617
#define PANELDATA_SIZE (40*PANELS)
1718

1819
// TODO: Following will go into EEPROM when it is finished... or... think about it! ;)
20+
// Maybe save it to eeprom per command and reload it only once into RAM every reboot
21+
// to save EEPROM cycles
22+
1923
uint8_t storeData[] = {
2024
0x05, 0x02, 0x20, 0x00, 0x01, 0x00, 0x04, 0x54,
2125
0x45, 0x53, 0x54, 0xA8, 0x00, 0x01, 0x01, 0x18,
@@ -26,6 +30,9 @@ uint8_t storeData[] = {
2630
0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39
2731
};
2832

33+
// Must be allocated in setup!
34+
uint8_t variables[4];
35+
2936
uint16_t panelData[PANELDATA_SIZE];
3037

3138
void clear() {
@@ -46,6 +53,16 @@ void setRow(uint8_t x, uint8_t y, uint8_t value) {
4653
panelData[2*x+y] = value;
4754
}
4855

56+
void setDouble(uint8_t x, uint8_t value) {
57+
uint16_t value_lowhigh = 0;
58+
for(int i = 0; i < 8; i++) {
59+
value_lowhigh |= ((value&1)*3)<<i*2;
60+
value = value >> 1;
61+
}
62+
setRow(x, 0, value_lowhigh>>8);
63+
setRow(x, 1, value_lowhigh);
64+
}
65+
4966
uint16_t getPixel(int x, int y) {
5067
return panelData[x] & (1 << y);
5168
}
@@ -79,13 +96,22 @@ void setup() {
7996
DDRC |= (1<<DATA_LOW)|(1<<DATA_HIGH)|(1<<OE)|(1<<SRCK)|(1<<RCK);
8097
screen_on();
8198

82-
// TODO Do basically the same as in loop, but just note down the actual window widths if not specified. or edit them in EEPROM (maybe this is preferred as EEPROM is read continuously in the loop function, but 00 00 widths can be edited easily, so it will save computing power)
99+
// Check connected displays? if backlink is active, don't think so because it wouldn't be necessary if stored in EEPROM as it won't be changed much
100+
// Load EEPROM Content into RAM
101+
// Edit 00 00 Widths to matching displays connected - calculate the width once.
102+
// Allocate variable memory. This will be: 2 for each marquee, W*H/64 for each console
103+
// - for each marquee: preset xpos for centered strings, so it must only be checked if the width is fitting into the window's width
104+
// Start Clock timer
83105
}
84106

107+
// Timer Interrupt for exactly 1s counts uptime higher and if overflows adds value to the time (each ~18hrs, so it is not as important by now)
108+
109+
uint16_t xOffset = 0, windowWidth;
110+
uint8_t *data, *variable, *tmp_pointer;
111+
uint8_t tmp[16];
85112
void loop() {
86113
// TODO code this
87114
/*
88-
- check connected displays? maybe, if it does not take too long and if backlink is active or just do this at setup
89115
- Go through storeData (start cnt...)
90116
- ignore 1st byte (PANELS)
91117
- read 2nd byte into WindowCount
@@ -107,15 +133,22 @@ void loop() {
107133
- next i
108134
- if PixelDataHasChanged: shiftPixelData
109135
*/
110-
uint8_t *data = &storeData[1];
111-
uint8_t windowCount = *data;
112-
data++;
113-
uint16_t xOffset = 0, windowWidth;
114-
for(uint8_t i = 0; i < windowCount; i++) {
136+
*data = &storeData[2];
137+
*variable = &variables[0];
138+
xOffset = 0;
139+
for(uint8_t i = 0; i < storeData[1]; i++) {
115140
windowWidth = *(uint16_t*)data;
116141
data += 2;
117142
switch(*data++) {
118143
case 1: // marquee2
144+
tmp[0] = *(data++); // Options bit
145+
tmp[1] = *(data++); // Length of 1st line
146+
for(uint8_t j = 0; j < tmp[1]; j++) {
147+
// TODO: getNextCharacter
148+
for(uint8_t k = 0; k < 8; k++) {
149+
setDouble(xOffset + *variables + j*8 + k, *(tmp_pointer++)); // TODO only if option is like this
150+
}
151+
}
119152
// TODO
120153
break;
121154
}

marquee2/Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ CFLAGS=-mmcu=atmega644 -O2 -std=c99
1010
%.s: %.c
1111
avr-gcc $(CFLAGS) -S -o $@ $<
1212

13+
%.bin: %.o
14+
avr-objcopy -j .text -j .data -O binary $< $@
15+
1316
all: $(FILE)
1417
asm: $(FILE:.hex=.s)
18+
bin: $(FILE:.hex=.bin)
1519

1620
clean:
1721
rm -f *.o *.s *.hex
1822

1923
flash: $(FILE)
2024
avrdude -C /etc/avrdude.conf -p m644 -P usb -c usbasp -U flash:w:$<:a
25+
26+
simulate:
27+
../simulate.sh $(FILE:.hex=.c)

marquee2/font.h

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
uint8_t font[] = {
1+
static uint8_t font[] = {
22
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SP
33
0x00, 0x00, 0x00, 0xf2, 0xf2, 0x00, 0x00, 0x00, // !
44
0x00, 0xe0, 0xe0, 0x00, 0x00, 0xe0, 0xe0, 0x00, // "
@@ -101,3 +101,16 @@ uint8_t font[] = {
101101
0x00, 0x20, 0x40, 0x40, 0x20, 0x20, 0x40, 0x00, // ~
102102
0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, // DEL
103103
};
104+
105+
#define UNICODE_CHARACTERS 9
106+
static uint8_t unicode[] = {
107+
0x00, 0xc4, 0x00, 0x9e, 0x3e, 0x68, 0x68, 0x3e, 0x9e, 0x00, // Ä
108+
0x00, 0xc9, 0x00, 0x3e, 0x3e, 0x6a, 0xea, 0xa2, 0x22, 0x00, // É
109+
0x00, 0xd6, 0x00, 0xbc, 0x7e, 0x42, 0x42, 0x7e, 0xbc, 0x00, // Ö
110+
0x00, 0xdc, 0x00, 0x3c, 0xbe, 0x02, 0x02, 0xbe, 0x3c, 0x00, // Ü
111+
0x00, 0xdf, 0x00, 0x7e, 0xfe, 0x80, 0x92, 0xfe, 0x6c, 0x00, // ß
112+
0x00, 0xe4, 0x00, 0x04, 0xae, 0x2a, 0x2a, 0xbe, 0x1e, 0x00, // ä
113+
0x00, 0xf6, 0x00, 0x1c, 0xbe, 0x22, 0x22, 0xbe, 0x1c, 0x00, // ö
114+
0x00, 0xfc, 0x00, 0x3c, 0xbe, 0x02, 0x02, 0xbe, 0x3e, 0x00, // ü
115+
0x20, 0xac, 0x00, 0x28, 0x7c, 0xfe, 0xaa, 0x82, 0xc6, 0x44, // €
116+
};

marquee2/marquee.c

+36-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,36 @@ char msg[] = "Hallo /dev/tal!!!ÄÖÜßäöü€";
2323
const uint16_t msg_length = 12;
2424
#endif
2525
uint8_t c = 0;
26+
uint8_t* pointer;
27+
28+
void getNextFontChar() {
29+
uint8_t chr = msg[c++];
30+
if(chr & 0x80) { // simple UTF-8
31+
pointer = &font[0x2f8]; // DEL if not found
32+
uint8_t uc_chr[] = {0, 0};
33+
if((chr & 0xf0) == 0xe0) { // or chr & 0x20
34+
// 3 byte sequence
35+
uc_chr[0] = chr << 4;
36+
chr = (msg[c++] & 0x3f);
37+
uc_chr[0] |= chr >> 2;
38+
uc_chr[1] = (chr << 6) | (msg[c++] & 0x3f);
39+
} else if((chr & 0xe0) == 0xc0) { // or else
40+
// 2 byte sequence
41+
chr &= 0x1f;
42+
uc_chr[0] = chr >> 2;
43+
uc_chr[1] = (chr << 6) | (msg[c++] & 0x3f);
44+
}
45+
// find character in map
46+
for(int i = 0; i < UNICODE_CHARACTERS * 10; i+= 10) {
47+
if(unicode[i] == uc_chr[0] && unicode[i+1] == uc_chr[1]) {
48+
pointer = &unicode[i+2];
49+
break;
50+
}
51+
}
52+
} else { // ASCII
53+
pointer = &font[(chr-32)*8];
54+
}
55+
}
2656

2757
void screen_off() {
2858
PORTC &= ~(1<<OE);
@@ -50,7 +80,7 @@ void shiftLine(uint8_t value_high, uint8_t value_low) {
5080
}
5181

5282
void shiftDouble(uint8_t value) {
53-
uint16_t value_lowhigh;
83+
uint16_t value_lowhigh = 0;
5484
for(int i = 0; i < 8; i++) {
5585
value_lowhigh |= ((value&1)*3)<<i*2;
5686
value = value >> 1;
@@ -61,6 +91,7 @@ void shiftDouble(uint8_t value) {
6191
void setup() {
6292
DDRC |= (1<<DATA_LOW)|(1<<DATA_HIGH)|(1<<OE)|(1<<SRCK)|(1<<RCK);
6393
screen_on();
94+
getNextFontChar();
6495
}
6596

6697
uint8_t i = 0;
@@ -70,12 +101,12 @@ void loop() {
70101
#ifndef SINGLE_LINE
71102
shiftLine(font[8*(msg[c]-32)+i], font[8*(msg[c+msg_length]-32)+i]);
72103
#else
73-
shiftDouble(font[8*(msg[c]-32)+i]);
104+
shiftDouble(*pointer++);
74105
#endif
75106
i++;
76107
if(i==8) {
108+
getNextFontChar();
77109
i = 0;
78-
c++;
79110
}
80111
} else if(cnt < 8*msg_length + 10) {
81112
PORTC ^= (1<<OE);
@@ -85,10 +116,11 @@ void loop() {
85116
} else {
86117
cnt = -1;
87118
c = 0;
119+
getNextFontChar();
88120
i = 0;
89121
}
90122
cnt++;
91-
//_delay_ms(100);
123+
//_delay_ms(200);
92124
}
93125

94126
int main() {

tetris-demo/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ clean:
1818

1919
flash: $(FILE)
2020
avrdude -C /etc/avrdude.conf -p m644 -P usb -c usbasp -U flash:w:$<:a
21+
22+
simulate:
23+
../simulate.sh $(FILE:.hex=.c)

0 commit comments

Comments
 (0)