File tree Expand file tree Collapse file tree 3 files changed +58
-11
lines changed Expand file tree Collapse file tree 3 files changed +58
-11
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ byte secs = 0;
7070byte ampm = 0 ;
7171byte update = 1 ;
7272byte rotation = 0 ;
73+ byte invert = 0 ;
7374
7475byte xo = 15 ;
7576byte yo = 55 ;
@@ -149,6 +150,24 @@ void advancetime()
149150 }
150151}
151152
153+ void clearScreen ()
154+ {
155+ uint16_t color = 0 ;
156+
157+ clearPrevQR ();
158+
159+ if (invert)
160+ {
161+ color = WHITE;
162+ }
163+ else
164+ {
165+ color = BLACK;
166+ }
167+
168+ Tft.fillScreen (color);
169+ }
170+
152171void clearPrevQR ()
153172{
154173 for (byte i = 0 ; i < 21 ; i++)
@@ -161,15 +180,15 @@ void setup() {
161180 Serial.begin (9600 );
162181 Tft.TFTinit ();
163182
164- Serial.println (F (" valid init string is: r1; h15;m22;s25;u10 ;d;x;" ));
183+ Serial.println (F (" valid init string is: i0;r2; h15;m22;s25;u1 ;d;x;" ));
165184
166185 ul_UpdateMillis = update * (unsigned long )1000 ;
167186
168187 buildtimestring ();
169188 generate ();
170189 ul_LastGenerated = millis ();
171190
172- clearPrevQR ();
191+ clearScreen ();
173192 printcode (&outputmatrix[0 ]);
174193
175194 advancetime ();
Original file line number Diff line number Diff line change @@ -77,6 +77,16 @@ void SerialFSM()
7777 break ;
7878 }
7979
80+ // invert colors
81+ case ' I' :
82+ case ' i' :
83+ {
84+ collectednumber = 0 ;
85+ numberstocollect = 1 ;
86+ storenumbersin = 7 ;
87+ break ;
88+ }
89+
8090 // draw the time
8191 case ' D' :
8292 case ' d' :
@@ -171,8 +181,6 @@ void SerialFSM()
171181 {
172182 if (collectednumber < 4 )
173183 {
174- clearPrevQR ();
175-
176184 rotation = collectednumber;
177185
178186 if ((rotation == 0 ) || (rotation == 2 ))
@@ -187,19 +195,25 @@ void SerialFSM()
187195 }
188196
189197 Tft.setRotation (rotation);
190- Tft.fillScreen (BLACK);
198+ clearScreen ();
199+ printcode (&outputmatrix[0 ]);
200+ }
201+ break ;
202+ }
203+ case 7 :
204+ {
205+ if ((collectednumber == 0 ) || (collectednumber == 1 ))
206+ {
207+ invert = collectednumber;
208+ clearScreen ();
191209 printcode (&outputmatrix[0 ]);
192210 }
193211 break ;
194212 }
195213 }
196-
197214 }
198-
199215 break ;
200216 }
201217 }
202-
203-
204218 }
205219}
Original file line number Diff line number Diff line change @@ -46,8 +46,22 @@ void printcode(unsigned char * array)
4646 int i = 0 ;
4747 int j = 0 ;
4848 uint16_t color = 0 ;
49+ uint16_t colorbg = 0 ;
50+ uint16_t colorfg = 0 ;
51+
4952 byte c = 0 ;
5053 unsigned long mbit = 1 ;
54+
55+ if (invert)
56+ {
57+ colorbg = WHITE;
58+ colorfg = BLACK;
59+ }
60+ else
61+ {
62+ colorbg = BLACK;
63+ colorfg = WHITE;
64+ }
5165
5266 for (i = 0 ; i < 21 ; i++)
5367 {
@@ -57,12 +71,12 @@ void printcode(unsigned char * array)
5771 {
5872 if (getbit (&array[0 ], (21 * i) + j))
5973 {
60- color = BLACK ;
74+ color = colorbg ;
6175 c = 0 ;
6276 }
6377 else
6478 {
65- color = WHITE ;
79+ color = colorfg ;
6680 c = 1 ;
6781 }
6882
You can’t perform that action at this time.
0 commit comments