Browse Source

First firmweare code added.

klaute 1 year ago
parent
commit
93bbdfaf75
4 changed files with 352 additions and 1 deletions
  1. 182
    0
      firmware/wc_led_ctrl.c
  2. 16
    0
      firmware/wc_led_ctrl.h
  3. 153
    0
      firmware/wc_led_def.h
  4. 1
    1
      hardware/wordclock_cell.scad

+ 182
- 0
firmware/wc_led_ctrl.c View File

@@ -0,0 +1,182 @@
1
+
2
+/*****************************************************************************/
3
+
4
+#include "wc_led_def.h"
5
+#include "wc_led_ctrl.h"
6
+
7
+/*****************************************************************************/
8
+
9
+uint8_t led_data[LED_CNT][3];
10
+
11
+uint8_t g_r = 100;
12
+uint8_t g_g = 100;
13
+uint8_t g_b = 100;
14
+
15
+/*****************************************************************************/
16
+
17
+void setLEDTimeUC(uint8_t hh, uint8_t mm, uint8_t r, uint8_t g, uint8_t b)
18
+{
19
+	if (mm >= 25)
20
+		hh++; // increase the hour because the text will be like "xxx vor hh"
21
+	if (mm > 59)
22
+		mm = 0;
23
+	if (hh > 12)
24
+		hh = hh - 12;
25
+	if (hh == 0)
26
+		hh = 12;
27
+
28
+	// clear all LED settings
29
+	setAllLEDOff();
30
+
31
+	LED_WORD_ES(r, g, b);
32
+	LED_WORD_IST(r, g, b);
33
+
34
+	setLEDTimeMinuteUC(r, g, b);
35
+	setLEDTimeHourUC(r, g, b);
36
+
37
+	LED_WORD_UHR(r, g, b);
38
+}
39
+
40
+// Unicolor
41
+void setLEDTimeMinuteUC(uint8_t r, uint8_t g, uint8_t b)
42
+{
43
+	if (mm < 5)
44
+	{
45
+		// no led activation here the text looks like "ES IST hh UHR", no minuti information is shown
46
+	} else if (mm < 10)
47
+	{
48
+		LED_WORD_FUENF(r, g, b);
49
+		LED_WORD_NACH(r, g, b);
50
+	} else if (mm < 15)
51
+		LED_WORD_ZEHN(r, g, b);
52
+		LED_WORD_NACH(r, g, b);
53
+	{
54
+	} else if (mm < 20)
55
+		LED_WORD_VIERTEL(r, g, b);
56
+		LED_WORD_NACH(r, g, b);
57
+	{
58
+	} else if (mm < 25)
59
+		LED_WORD_ZWANZIG(r, g, b);
60
+		LED_WORD_NACH(r, g, b);
61
+	{
62
+	} else if (mm < 30)
63
+	{
64
+		LED_WORD_FUENF(r, g, b);
65
+		LED_WORD_VOR(r, g, b);
66
+		LED_WORD_HALB(r, g, b);
67
+	} else if (mm < 35)
68
+	{
69
+		LED_WORD_HALB(r, g, b);
70
+	} else if (mm < 40)
71
+	{
72
+		LED_WORD_FUENF(r, g, b);
73
+		LED_WORD_NACH(r, g, b);
74
+		LED_WORD_HALB(r, g, b);
75
+	} else if (mm < 45)
76
+	{
77
+		LED_WORD_ZEHN(r, g, b);
78
+		LED_WORD_NACH(r, g, b);
79
+		LED_WORD_HALB(r, g, b);
80
+	} else if (mm < 50)
81
+	{
82
+		LED_WORD_VIERTEL(r, g, b);
83
+		LED_WORD_VOR(r, g, b);
84
+	} else if (mm < 55)
85
+	{
86
+		LED_WORD_ZEHN(r, g, b);
87
+		LED_WORD_VOR(r, g, b);
88
+	} else {
89
+		LED_WORD_FUENF(r, g, b);
90
+		LED_WORD_VOR(r, g, b);
91
+	}
92
+}
93
+
94
+// Unicolor
95
+void setLEDTimeHourUC(uint8_t r, uint8_t g, uint8_t b)
96
+{
97
+	switch (hh)
98
+	{
99
+		case 1:
100
+			LED_NUM_EINS(r, g, b);
101
+			break;
102
+		case 2:
103
+			LED_NUM_ZWEI(r, g, b);
104
+			break;
105
+		case 3:
106
+			LED_NUM_DREI(r, g, b);
107
+			break;
108
+		case 4:
109
+			LED_NUM_VIER(r, g, b);
110
+			break;
111
+		case 5:
112
+			LED_NUM_FUENF(r, g, b);
113
+			break;
114
+		case 6:
115
+			LED_NUM_SECHS(r, g, b);
116
+			break;
117
+		case 7:
118
+			LED_NUM_SIEBEN(r, g, b);
119
+			break;
120
+		case 8:
121
+			LED_NUM_ACHT(r, g, b);
122
+			break;
123
+		case 9:
124
+			LED_NUM_NEUN(r, g, b);
125
+			break;
126
+		case 10:
127
+			LED_NUM_ZEHN(r, g, b);
128
+			break;
129
+		case 11:
130
+			LED_NUM_ELF(r, g, b);
131
+			break;
132
+		case 12:
133
+			LED_NUM_ZWOELF(r, g, b);
134
+			break;
135
+		default:
136
+			LED_ERROR_E1;
137
+			return;
138
+	}
139
+
140
+}
141
+
142
+// invert position
143
+uint8_t setLEDColorsIP(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end)
144
+{
145
+	return setColors(r, g, b, INV_POS(end), INV_POS(start));
146
+}
147
+
148
+uint8_t setLEDColors(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end)
149
+{
150
+	if (end < start)
151
+		return -1;
152
+
153
+	if (start > LED_CNT-1)
154
+		return -2;
155
+
156
+	if (end > LED_CNT)
157
+		return -3;
158
+
159
+	if (end == start)
160
+		end = start + 1;
161
+
162
+	for (uint8_t l = start; l < end; l++)
163
+	{
164
+		setLEDColor(r, g, b, l);
165
+	}
166
+}
167
+
168
+// This function is used to set the color data, not to update the color of the LED is transmitting
169
+void setLEDColor(uint8_t r, uint8_t g, uint8_t b, uint8_t led_num)
170
+{
171
+	led_data[led_num][LED_DATA_RED]   = r;
172
+	led_data[led_num][LED_DATA_GREEN] = g;
173
+	led_data[led_num][LED_DATA_BLUE]  = b;
174
+}
175
+
176
+uint8_t setAllLEDOff()
177
+{
178
+	return setLEDColors(0, 0, 0, 0, LED_CNT);
179
+}
180
+
181
+/*****************************************************************************/
182
+

+ 16
- 0
firmware/wc_led_ctrl.h View File

@@ -0,0 +1,16 @@
1
+
2
+/*****************************************************************************/
3
+
4
+#include <stdtypes.h>
5
+
6
+/*****************************************************************************/
7
+
8
+void    setLEDTimeUC(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t);
9
+void    setLEDTimeMinuteUC(uint8_t, uint8_t, uint8_t);
10
+void    setLEDTimeHourUC(uint8_t, uint8_t, uint8_t);
11
+uint8_t setLEDColorsIP(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t);
12
+uint8_t setLEDColors(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t);
13
+void    setLEDColor(uint8_t, uint8_t, uint8_t, uint8_t);
14
+
15
+/*****************************************************************************/
16
+

+ 153
- 0
firmware/wc_led_def.h View File

@@ -0,0 +1,153 @@
1
+
2
+/*****************************************************************************/
3
+
4
+#define LED_CNT 110
5
+
6
+/*****************************************************************************/
7
+
8
+/*
9
+ 0 ESKISTLFÜNF
10
+ 1 GIZNAWZNHEZ -> ZEHNZWANZIG
11
+ 2 DREIVIERTEL
12
+ 3 MJROVHCANGT -> TGNACHVORJM
13
+ 4 HALBQZWÖLFP
14
+ 5 NEBEISNIEWZ -> ZWEINSIEBEN
15
+ 6 KDREIRHFÜNF
16
+ 7 REIVNUENFLE -> ELFNEUNVIER
17
+ 8 WACHTZEHNRS
18
+ 9 RHUMFSHCESB -> BSECHSFMUHR
19
+*/
20
+
21
+#define OFFSET_ROW 11
22
+#define OFFSET_ROW1 OFFSET_ROW + OFFSET_ROW
23
+#define OFFSET_ROW2 OFFSET_ROW + OFFSET_ROW1
24
+#define OFFSET_ROW3 OFFSET_ROW + OFFSET_ROW2
25
+#define OFFSET_ROW4 OFFSET_ROW + OFFSET_ROW3
26
+#define OFFSET_ROW5 OFFSET_ROW + OFFSET_ROW4
27
+#define OFFSET_ROW6 OFFSET_ROW + OFFSET_ROW5
28
+#define OFFSET_ROW7 OFFSET_ROW + OFFSET_ROW6
29
+#define OFFSET_ROW8 OFFSET_ROW + OFFSET_ROW7
30
+#define OFFSET_ROW9 OFFSET_ROW + OFFSET_ROW8
31
+
32
+/*****************************************************************************/
33
+// words on the panel to define the time
34
+
35
+#define LED_WORD_ES(r, g, b) \
36
+	setLEDColors(r, g, b, 0, 1)
37
+
38
+#define LED_WORD_IST(r, g, b) \
39
+	setLEDColors(r, g, b, 3, 5)
40
+
41
+#define LED_WORD_FUENF(r, g, b) \
42
+	setLEDColors(r, g, b, 7, 10)
43
+
44
+#define LED_WORD_ZEHN(r, g, b) \
45
+	setLEDColors(r, g, b, 6 + OFFSET_ROW1, 9 + OFFSET_ROW1)
46
+
47
+#define LED_WORD_ZWANZIG(r, g, b) \
48
+	setLEDColors(r, g, b, 0 + OFFSET_ROW1, 10 + OFFSET_ROW1)
49
+
50
+#define LED_WORD_DREI(r, g, b) \
51
+	setLEDColors(r, g, b, 0 + OFFSET_ROW2, 3 + OFFSET_ROW2)
52
+
53
+#define LED_WORD_VIERTEL(r, g, b) \
54
+	setLEDColors(r, g, b, 4 + OFFSET_ROW2, 10 + OFFSET_ROW2)
55
+
56
+#define LED_WORD_DREIVIERTEL(r, g, b) \
57
+	LED_WORD_DREI(r, g, b) \
58
+	LED_WORD_VIERTEL(r, g, b)
59
+
60
+#define LED_WORD_VOR(r, g, b) \
61
+	setLEDColors(r, g, b, 2 + OFFSET_ROW3, 4 + OFFSET_ROW3)
62
+
63
+#define LED_WORD_NACH(r, g, b) \
64
+	setLEDColors(r, g, b, 5 + OFFSET_ROW3, 8 + OFFSET_ROW3)
65
+
66
+#define LED_WORD_HALB(r, g, b) \
67
+	setLEDColors(r, g, b, 0 + OFFSET_ROW4, 3 + OFFSET_ROW4)
68
+
69
+#define LED_WORD_UHR(r, g, b) \
70
+	setLEDColors(r, g, b, 0 + OFFSET_ROW9, 2 + OFFSET_ROW9)
71
+
72
+/*****************************************************************************/
73
+// words on the panel that represent numbers to represent the time
74
+
75
+#define LED_NUM_EINS(r, g, b) \
76
+	setLEDColors(r, g, b, 5 + OFFSET_ROW5, 8 + OFFSET_ROW5)
77
+
78
+#define LED_NUM_ZWEI(r, g, b) \
79
+	setLEDColors(r, g, b, 7 + OFFSET_ROW5, 10 + OFFSET_ROW5)
80
+
81
+#define LED_NUM_DREI(r, g, b) \
82
+	setLEDColors(r, g, b, 1 + OFFSET_ROW6, 4 + OFFSET_ROW6)
83
+
84
+#define LED_NUM_VIER(r, g, b) \
85
+	setLEDColors(r, g, b, 7 + OFFSET_ROW7, 10 + OFFSET_ROW7)
86
+
87
+#define LED_NUM_FUENF(r, g, b) \
88
+	setLEDColors(r, g, b, 7 + OFFSET_ROW6, 10 + OFFSET_ROW6)
89
+
90
+#define LED_NUM_SECHS(r, g, b) \
91
+	setLEDColors(r, g, b, 5 + OFFSET_ROW8, 8 + OFFSET_ROW8)
92
+
93
+#define LED_NUM_SIEBEN(r, g, b) \
94
+	setLEDColors(r, g, b, 0 + OFFSET_ROW5, 5 + OFFSET_ROW5)
95
+
96
+#define LED_NUM_ACHT(r, g, b) \
97
+	setLEDColors(r, g, b, 1 + OFFSET_ROW8, 4 + OFFSET_ROW8)
98
+
99
+#define LED_NUM_NEUN(r, g, b) \
100
+	setLEDColors(r, g, b, 3 + OFFSET_ROW7, 6 + OFFSET_ROW7)
101
+
102
+#define LED_NUM_ZEHN(r, g, b) \
103
+	setLEDColors(r, g, b, 5 + OFFSET_ROW8, 8 + OFFSET_ROW8)
104
+
105
+#define LED_NUM_ELF(r, g, b) \
106
+	setLEDColors(r, g, b, 0 + OFFSET_ROW7, 2 + OFFSET_ROW7)
107
+
108
+#define LED_NUM_ZWOELF(r, g, b) \
109
+	setLEDColors(r, g, b, 5 + OFFSET_ROW4, 9 + OFFSET_ROW4)
110
+
111
+/*****************************************************************************/
112
+// chars on the left side of the panel
113
+
114
+#define LED_CHAR_E(r, g, b) \
115
+	setLEDColorsIP(r, g, b, 1 + OFFSET_ROW1, 4 + OFFSET_ROW1) \
116
+	setLEDColorsIP(r, g, b, 1 + OFFSET_ROW2, 1 + OFFSET_ROW1) \
117
+	setLEDColorsIP(r, g, b, 1 + OFFSET_ROW3, 1 + OFFSET_ROW1) \
118
+	setLEDColorsIP(r, g, b, 2 + OFFSET_ROW4, 3 + OFFSET_ROW1) \
119
+	setLEDColorsIP(r, g, b, 1 + OFFSET_ROW4, 1 + OFFSET_ROW1) \
120
+	setLEDColorsIP(r, g, b, 1 + OFFSET_ROW5, 1 + OFFSET_ROW1) \
121
+	setLEDColorsIP(r, g, b, 1 + OFFSET_ROW5, 1 + OFFSET_ROW1) \
122
+	setLEDColorsIP(r, g, b, 1 + OFFSET_ROW6, 1 + OFFSET_ROW1) \
123
+	setLEDColorsIP(r, g, b, 1 + OFFSET_ROW8, 1 + OFFSET_ROW1) \
124
+	setLEDColorsIP(r, g, b, 1 + OFFSET_ROW8, 4 + OFFSET_ROW8) \
125
+
126
+/*****************************************************************************/
127
+// numbers on the right side of the panel
128
+
129
+#define LED_NUMBER_1(r, g, b) \
130
+	setLEDColorsIP(r, g, b, 8 + OFFSET_ROW2, 8 + OFFSET_ROW2) \
131
+	setLEDColorsIP(r, g, b, 8 + OFFSET_ROW3, 7 + OFFSET_ROW3) \
132
+	setLEDColorsIP(r, g, b, 9 + OFFSET_ROW1, 9 + OFFSET_ROW1) \
133
+	setLEDColorsIP(r, g, b, 9 + OFFSET_ROW2, 9 + OFFSET_ROW1) \
134
+	setLEDColorsIP(r, g, b, 9 + OFFSET_ROW3, 9 + OFFSET_ROW1) \
135
+	setLEDColorsIP(r, g, b, 9 + OFFSET_ROW4, 9 + OFFSET_ROW1) \
136
+	setLEDColorsIP(r, g, b, 9 + OFFSET_ROW5, 9 + OFFSET_ROW1) \
137
+	setLEDColorsIP(r, g, b, 9 + OFFSET_ROW6, 9 + OFFSET_ROW1) \
138
+	setLEDColorsIP(r, g, b, 9 + OFFSET_ROW7, 9 + OFFSET_ROW1) \
139
+	setLEDColorsIP(r, g, b, 9 + OFFSET_ROW8, 9 + OFFSET_ROW1)
140
+
141
+/*****************************************************************************/
142
+// Error codes
143
+
144
+#define LED_ERROR_E1 \
145
+	LED_CHAR_E(100, 0, 0) \
146
+	LED_NUMBER_1(100, 0, 0)
147
+
148
+/*****************************************************************************/
149
+
150
+#define INV_POS(led_num) 10 - led_num
151
+
152
+/*****************************************************************************/
153
+

+ 1
- 1
hardware/wordclock_cell.scad View File

@@ -21,7 +21,7 @@ joint_length=20;
21 21
 font = "Liberation Sans";
22 22
 letter_size = 30;
23 23
 letter_height = 10;
24
-l="ü";
24
+l="Ö";
25 25
 
26 26
 module letter(l) {
27 27
 	// Use linear_extrude() to make the letters 3D objects as they

Loading…
Cancel
Save