/*
   20X24.C

	Example program for the small OP6100/KDM module with the 4x6 keypad and
	4x20 lcd.

	Uses all keys and the entire lcd. Displays the key number in the stdio
	window, counting from lower left to upper right.
*/

#use "default.h"

#use "kdm.lib"

#define KEYPAD_SIZE 24

#ifdef LK_COLS
#undef LK_COLS
#endif
#define LK_COLS 20

#ifdef LK_LINES
#undef LK_LINES
#endif
#define LK_LINES 4

main ()
{
   int k, l;

   outport(DCNTL, 0x30);           /* set I/O wait states to 4 */
   lk_init_keypad ();              /* initialize keypad and display */

   lk_setbeep (100);
   lk_printf ("      24 Keys\n");
   lk_printf (" 4 x 20 LCD Display\n");
   lk_printf ("Z-World Engineering\n");
   lk_printf (" Davis, California");
   lk_printf ("\x1b0");             /* turn off cursor */
   l = 1;

   while (1)
   {
      while ((k = lk_kxget(0)) == -1) {
      	runwatch ();
      	hitwd();
      }
      lk_setbeep (200);
      lk_led (l);                   /* make LED change */
      if (++l > 3) l = 0;
      printf ("%d\n", k);           /* display key number in STDIO */
      hitwd();
   }
}
