@@ -16,28 +16,29 @@ FASTEPD epaper;
16
16
uint8_t ucTemp[64 ];
17
17
uint8_t u8_last[16 * 48 ]; // to allow UNDO of a single change
18
18
// Starting gray matrix. Copy your current one here before compiling/running the program
19
+ // This should normally be "const" data so that it gets written to FLASH, but for this
20
+ // program to be able to edit the values, it needs to be declared so it loads in RAM
19
21
uint8_t u8_graytable[] = {
20
- /* 0 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 0 ,
21
- /* 1 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 2 , 1 , 1 , 1 , 0 , 0 , 0 , 0 ,
22
- /* 2 */ 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 2 , 1 , 1 , 1 , 2 , 1 , 0 , 0 , 0 , 0 ,
23
- /* 3 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 2 , 1 , 0 , 0 , 0 , 0 , 0 ,
24
- /* 4 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 2 , 1 , 0 , 0 , 0 , 0 , 0 , 0 ,
25
- /* 5 */ 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 1 , 2 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 ,
26
- /* 6 */ 0 , 0 , 0 , 0 , 0 , 1 , 2 , 0 , 1 , 2 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 ,
27
- /* 7 */ 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 2 , 0 , 0 , 0 ,
28
- /* 8 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 2 , 2 , 1 , 2 , 1 , 0 , 0 , 0 , 0 , 0 ,
29
- /* 9 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 2 , 0 ,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 1 , 2 , 0 , 1 , 2 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 ,
29
+ /* 7 */ 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 2 , 0 , 0 , 0 ,
30
+ /* 8 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 1 , 2 , 1 , 0 , 0 , 0 , 0 , 0 ,
31
+ /* 9 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 2 , 0 , 0 , 0 ,
32
+ /* 10 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 2 , 0 , 0 , 0 ,
33
+ /* 11 */ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 2 , 1 , 2 , 0 , 0 ,
34
+ /* 12 */ 0 , 0 , 0 , 0 , 0 , 1 , 1 , 2 , 1 , 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
35
+ /* 13 */ 0 , 0 , 0 , 0 , 1 , 1 , 2 , 2 , 2 , 2 , 1 , 2 , 0 , 0 , 0 , 0 , 0 ,
36
+ /* 14 */ 0 , 0 , 0 , 1 , 1 , 2 , 2 , 1 , 2 , 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
37
+ /* 15 */ 1 , 1 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2
36
38
};
37
-
38
39
static int passes; // Calculated at startup based on the matrix size
39
40
// List of supported commands
40
- const char *szCMDs[] = {" HELP" , " LIST" , " SHOW" , " COPY" , " SWAP" , " EDIT" , " UNDO" , 0 };
41
+ const char *szCMDs[] = {" HELP" , " LIST" , " SHOW" , " COPY" , " SWAP" , " EDIT" , " UNDO" , " CODE " , 0 };
41
42
enum {
42
43
CMD_HELP = 0 ,
43
44
CMD_LIST,
46
47
CMD_SWAP,
47
48
CMD_EDIT,
48
49
CMD_UNDO,
50
+ CMD_CODE,
49
51
CMD_COUNT
50
52
};
51
53
@@ -144,17 +146,18 @@ void showHelp()
144
146
Serial.println (" Interactive FastEPD gray matrix editor command list" );
145
147
Serial.println (" (case insensitive, decimal numbers assumed, space or comma delimited)" );
146
148
Serial.println (" HELP - This command list" );
147
- Serial.println (" LIST - show the current gray matrix values" );
149
+ Serial.println (" LIST n - show a row of gray matrix values to copy/edit " );
148
150
Serial.println (" SHOW - Display the gray matrix on the EPD panel" );
149
151
Serial.println (" COPY n m - copy row n to row m" );
150
152
Serial.println (" SWAP n m - swap the contents of row n with row m" );
151
153
Serial.println (" EDIT n 0 1 2 2 1 0 0... write new values for row n" );
152
154
Serial.println (" UNDO - undo the last change (only 1 step is reversible)" );
155
+ Serial.println (" CODE - generate the code for the current gray matrix" );
153
156
} /* showHelp() */
154
157
155
158
// List the current values of the gray matrix in a form that can be easily copied
156
159
// back into your code
157
- void ListMatrix (void )
160
+ void ListCode (void )
158
161
{
159
162
int i, j;
160
163
uint8_t *s;
@@ -174,7 +177,7 @@ void ListMatrix(void)
174
177
Serial.print (" \n " );
175
178
} // for i
176
179
Serial.print (" };\n " );
177
- } /* ListMatrix () */
180
+ } /* ListCode () */
178
181
179
182
// Display the grayscale test image on the panel to see how your current gray matrix performs
180
183
void ShowMatrix (void )
@@ -209,12 +212,24 @@ uint8_t *s, *d;
209
212
case CMD_HELP:
210
213
showHelp ();
211
214
break ;
212
- case CMD_LIST :
213
- ListMatrix ();
215
+ case CMD_CODE :
216
+ ListCode ();
214
217
break ;
215
218
case CMD_SHOW:
216
219
ShowMatrix ();
217
220
break ;
221
+ case CMD_LIST:
222
+ if (pData[1 ] < 0 || pData[1 ] > 15 ) {
223
+ Serial.println (" LIST: Row must be in the range 0 to 15" );
224
+ return ;
225
+ }
226
+ Serial.printf (" EDIT %d " , pData[1 ]);
227
+ s = &u8_graytable[passes * pData[1 ]];
228
+ for (i=0 ; i<passes; i++) {
229
+ Serial.printf (" %d " , s[i]);
230
+ }
231
+ Serial.print (" \n " );
232
+ break ;
218
233
case CMD_COPY:
219
234
if (pData[1 ] < 0 || pData[1 ] > 15 || pData[2 ] < 0 || pData[2 ] > 15 ) {
220
235
Serial.println (" COPY: Source/Dest rows must be in the range 0 to 15" );
0 commit comments