118
118
#define D5 7
119
119
#define D4 6
120
120
121
- /* LCD Constants to match your display */
121
+ /* LCD Constants to match your display 16 x 2 */
122
122
/* Columns in display */
123
123
#define MAX_COL 16
124
124
/* Rows in display */
125
125
#define MAX_ROW 2
126
126
127
- /* LCD Constants to match your display */
127
+ /* LCD Constants to match your display 20 x 4 */
128
128
/* Columns in display */
129
- #define MAX_COL 20
129
+ // #define MAX_COL 20
130
130
/* Rows in display */
131
- #define MAX_ROW 4
131
+ // #define MAX_ROW 4
132
132
133
133
/* current cursor position */
134
134
signed char cols = 0 ;
@@ -137,7 +137,7 @@ signed char rows = 0;
137
137
/* messages constants */
138
138
/* Key codes and strings for keys producing a string */
139
139
/* three arrays in same order ( keycode, string to display, length of string ) */
140
- #if defined(ARDUINO_ARCH_AVR )
140
+ #if defined(PS2_REQUIRES_PROGMEM )
141
141
const uint8_t codes[] PROGMEM = { PS2_KEY_SPACE, PS2_KEY_TAB, PS2_KEY_ESC, PS2_KEY_DELETE,
142
142
PS2_KEY_F1, PS2_KEY_F2, PS2_KEY_F3, PS2_KEY_F4,
143
143
PS2_KEY_F5, PS2_KEY_F6, PS2_KEY_F7, PS2_KEY_F8,
@@ -167,7 +167,7 @@ const char *const keys[] PROGMEM = {
167
167
const int8_t sizes[] PROGMEM = { 1 , 5 , 5 , 5 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 5 , 5 , 5 };
168
168
char buffer[ 8 ];
169
169
170
- #elif defined(ARDUINO_ARCH_SAM)
170
+ #else
171
171
const uint8_t codes[] = { PS2_KEY_SPACE, PS2_KEY_TAB, PS2_KEY_ESC,
172
172
PS2_KEY_DELETE, PS2_KEY_F1, PS2_KEY_F2, PS2_KEY_F3,
173
173
PS2_KEY_F4, PS2_KEY_F5, PS2_KEY_F6, PS2_KEY_F7,
@@ -177,12 +177,9 @@ const char *const keys[] = { " ", "[Tab]", "[ESC]", "[Del]", "[F1]", "[F2]", "
177
177
" [F4]" , " [F5]" , " [F6]" , " [F7]" , " [F8]" ,
178
178
" [F9]" , " [F10]" , " [F11]" , " [F12]" };
179
179
const int8_t sizes[] = { 1 , 5 , 5 , 5 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 5 , 5 , 5 };
180
-
181
- #else
182
- #error “This library only supports boards with an AVR or SAM processor.”
183
180
#endif
184
181
185
- // Class initialisation/instanciation
182
+ // Class initialisation/instantiation
186
183
// keyboard library
187
184
PS2KeyAdvanced keyboard;
188
185
// Initialise the keyboard remapping to UTF-8
@@ -200,15 +197,9 @@ lcd.begin( MAX_COL, MAX_ROW );
200
197
lcd.clear (); // clear the screen
201
198
lcd.cursor (); // Enable Cursor
202
199
lcd.blink (); // Blinking cursor
203
- #if defined(ARDUINO_ARCH_AVR)
204
- lcd.print ( F ( " PC Services" ) ); // Display signon text
205
- lcd.setCursor ( 0 ,1 );
206
- lcd.print ( F ( " Keyboard to LCD" ) );
207
- #elif defined(ARDUINO_ARCH_SAM)
208
200
lcd.print ( " PC Services" ); // Display signon text
209
201
lcd.setCursor ( 0 ,1 );
210
202
lcd.print ( " Keyboard to LCD" );
211
- #endif
212
203
keyboard.begin ( DATAPIN, IRQPIN );// Setup keyboard pins
213
204
keyboard.setNoBreak ( 1 ); // No break codes for keys (when key released)
214
205
keyboard.setNoRepeat ( 1 ); // Don't repeat shift ctrl etc
@@ -329,28 +320,28 @@ if( keyboard.available() )
329
320
if ( base != PS2_KEY_EUROPE2 && ( base < PS2_KEY_KP0 || base >= PS2_KEY_F1 ) )
330
321
{ // Non printable sort which ones we can print
331
322
for ( idx = 0 ; idx < sizeof ( codes ); idx++ )
332
- #if defined(ARDUINO_ARCH_AVR )
323
+ #if defined(PS2_REQUIRES_PROGMEM )
333
324
if ( base == pgm_read_byte ( codes + idx ) )
334
- #elif defined(ARDUINO_ARCH_SAM)
325
+ #else
335
326
if ( base == codes[ idx ] )
336
327
#endif
337
328
{
338
329
/* String outputs */
339
330
mode = 1 ;
340
- #if defined(ARDUINO_ARCH_AVR )
331
+ #if defined(PS2_REQUIRES_PROGMEM )
341
332
c = pgm_read_byte ( sizes + idx );
342
- #elif defined(ARDUINO_ARCH_SAM)
333
+ #else
343
334
c = sizes[ idx ];
344
335
#endif
345
336
cols += c - 1 ;
346
337
check_cursor ( );
347
338
/* when cursor reset keep track */
348
339
if ( cols == 0 )
349
340
cols = c;
350
- #if defined(ARDUINO_ARCH_AVR )
341
+ #if defined(PS2_REQUIRES_PROGMEM )
351
342
strcpy_P ( buffer, (char *)pgm_read_word ( &( keys[ idx ] ) ) );
352
343
lcd.print ( buffer );
353
- #elif defined(ARDUINO_ARCH_SAM)
344
+ #else
354
345
lcd.print ( keys[ idx ] );
355
346
#endif
356
347
cols++;
0 commit comments