118118#define D5 7
119119#define D4 6
120120
121- /* LCD Constants to match your display */
121+ /* LCD Constants to match your display 16 x 2 */
122122/* Columns in display */
123123#define MAX_COL 16
124124/* Rows in display */
125125#define MAX_ROW 2
126126
127- /* LCD Constants to match your display */
127+ /* LCD Constants to match your display 20 x 4 */
128128/* Columns in display */
129- #define MAX_COL 20
129+ // #define MAX_COL 20
130130/* Rows in display */
131- #define MAX_ROW 4
131+ // #define MAX_ROW 4
132132
133133/* current cursor position */
134134signed char cols = 0 ;
@@ -137,7 +137,7 @@ signed char rows = 0;
137137/* messages constants */
138138/* Key codes and strings for keys producing a string */
139139/* three arrays in same order ( keycode, string to display, length of string ) */
140- #if defined(ARDUINO_ARCH_AVR )
140+ #if defined(PS2_REQUIRES_PROGMEM )
141141const uint8_t codes[] PROGMEM = { PS2_KEY_SPACE, PS2_KEY_TAB, PS2_KEY_ESC, PS2_KEY_DELETE,
142142 PS2_KEY_F1, PS2_KEY_F2, PS2_KEY_F3, PS2_KEY_F4,
143143 PS2_KEY_F5, PS2_KEY_F6, PS2_KEY_F7, PS2_KEY_F8,
@@ -167,7 +167,7 @@ const char *const keys[] PROGMEM = {
167167const int8_t sizes[] PROGMEM = { 1 , 5 , 5 , 5 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 5 , 5 , 5 };
168168char buffer[ 8 ];
169169
170- #elif defined(ARDUINO_ARCH_SAM)
170+ #else
171171const uint8_t codes[] = { PS2_KEY_SPACE, PS2_KEY_TAB, PS2_KEY_ESC,
172172 PS2_KEY_DELETE, PS2_KEY_F1, PS2_KEY_F2, PS2_KEY_F3,
173173 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]", "
177177 " [F4]" , " [F5]" , " [F6]" , " [F7]" , " [F8]" ,
178178 " [F9]" , " [F10]" , " [F11]" , " [F12]" };
179179const 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.”
183180#endif
184181
185- // Class initialisation/instanciation
182+ // Class initialisation/instantiation
186183// keyboard library
187184PS2KeyAdvanced keyboard;
188185// Initialise the keyboard remapping to UTF-8
@@ -200,15 +197,9 @@ lcd.begin( MAX_COL, MAX_ROW );
200197lcd.clear (); // clear the screen
201198lcd.cursor (); // Enable Cursor
202199lcd.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)
208200lcd.print ( " PC Services" ); // Display signon text
209201lcd.setCursor ( 0 ,1 );
210202lcd.print ( " Keyboard to LCD" );
211- #endif
212203keyboard.begin ( DATAPIN, IRQPIN );// Setup keyboard pins
213204keyboard.setNoBreak ( 1 ); // No break codes for keys (when key released)
214205keyboard.setNoRepeat ( 1 ); // Don't repeat shift ctrl etc
@@ -329,28 +320,28 @@ if( keyboard.available() )
329320 if ( base != PS2_KEY_EUROPE2 && ( base < PS2_KEY_KP0 || base >= PS2_KEY_F1 ) )
330321 { // Non printable sort which ones we can print
331322 for ( idx = 0 ; idx < sizeof ( codes ); idx++ )
332- #if defined(ARDUINO_ARCH_AVR )
323+ #if defined(PS2_REQUIRES_PROGMEM )
333324 if ( base == pgm_read_byte ( codes + idx ) )
334- #elif defined(ARDUINO_ARCH_SAM)
325+ #else
335326 if ( base == codes[ idx ] )
336327#endif
337328 {
338329 /* String outputs */
339330 mode = 1 ;
340- #if defined(ARDUINO_ARCH_AVR )
331+ #if defined(PS2_REQUIRES_PROGMEM )
341332 c = pgm_read_byte ( sizes + idx );
342- #elif defined(ARDUINO_ARCH_SAM)
333+ #else
343334 c = sizes[ idx ];
344335#endif
345336 cols += c - 1 ;
346337 check_cursor ( );
347338 /* when cursor reset keep track */
348339 if ( cols == 0 )
349340 cols = c;
350- #if defined(ARDUINO_ARCH_AVR )
341+ #if defined(PS2_REQUIRES_PROGMEM )
351342 strcpy_P ( buffer, (char *)pgm_read_word ( &( keys[ idx ] ) ) );
352343 lcd.print ( buffer );
353- #elif defined(ARDUINO_ARCH_SAM)
344+ #else
354345 lcd.print ( keys[ idx ] );
355346#endif
356347 cols++;
0 commit comments