/*
	16X16.c

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

	Limits keypad return values to a 4x4 square of keys on the left side
	of the keypad. Also limits the display area on the lcd to two rows of
	sixteen characters.
*/

#use "kdm.lib"

#define KEYPAD_SIZE 16

#ifdef LK_COLS
#undef LK_COLS
#endif

#define LK_COLS     16

#ifdef LK_LINES
#undef LK_LINES
#endif
#define LK_LINES    2

main ()
{
   int k, l;

   for (k = 0; k < 10000; ++k) hitwd();
   lk_init_keypad (); 

   lk_setbeep (100);
   lk_printf ("   16 Keys\n");
   lk_printf ("2x16 LCD Display\n");
   lk_printf ("\x1b0");                   /* turn off cursor */

   l = 1;
   while (1)
   {
      while ((k = lk_kxget(0)) == -1) {
      	runwatch (); /* get a key */
      	hitwd();
      }
      lk_setbeep (200);                            /* beep */
      lk_led (l);                                  /* change LEDs */
      if (++l > 3) l = 0;                          /* setup next LED */
      printf ("%d\n", k);
      hitwd();
   }
}