Skip to content

Commit

Permalink
LCD_keyboard sketch added
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Mazurov committed Oct 22, 2009
1 parent 2590066 commit 05beed8
Showing 1 changed file with 42 additions and 67 deletions.
109 changes: 42 additions & 67 deletions examples/LCDkbd.pde
Expand Up @@ -5,58 +5,58 @@
#include <Max_LCD.h>

/* keyboard data taken from configuration descriptor */
#define KBD_ADDR 1
#define KBD_EP 1
#define KBD_IF 0
#define EP_MAXPKTSIZE 8
#define EP_POLL 0x0a
#define KBD_ADDR 1
#define KBD_EP 1
#define KBD_IF 0
#define EP_MAXPKTSIZE 8
#define EP_POLL 0x0a
/**/
//******************************************************************************
// macros to identify special charaters(other than Digits and Alphabets)
//******************************************************************************
#define BANG (0x1E)
#define AT (0x1F)
#define POUND (0x20)
#define DOLLAR (0x21)
#define PERCENT (0x22)
#define CAP (0x23)
#define AND (0x24)
#define STAR (0x25)
#define OPENBKT (0x26)
#define CLOSEBKT (0x27)
#define BANG (0x1E)
#define AT (0x1F)
#define POUND (0x20)
#define DOLLAR (0x21)
#define PERCENT (0x22)
#define CAP (0x23)
#define AND (0x24)
#define STAR (0x25)
#define OPENBKT (0x26)
#define CLOSEBKT (0x27)

#define RETURN (0x28)
#define ESCAPE (0x29)
#define BACKSPACE (0x2A)
#define TAB (0x2B)
#define SPACE (0x2C)
#define HYPHEN (0x2D)
#define EQUAL (0x2E)
#define SQBKTOPEN (0x2F)
#define SQBKTCLOSE (0x30)
#define BACKSLASH (0x31)
#define SEMICOLON (0x33)
#define INVCOMMA (0x34)
#define TILDE (0x35)
#define COMMA (0x36)
#define PERIOD (0x37)
#define FRONTSLASH (0x38)
#define DELETE (0x4c)
#define RETURN (0x28)
#define ESCAPE (0x29)
#define BACKSPACE (0x2A)
#define TAB (0x2B)
#define SPACE (0x2C)
#define HYPHEN (0x2D)
#define EQUAL (0x2E)
#define SQBKTOPEN (0x2F)
#define SQBKTCLOSE (0x30)
#define BACKSLASH (0x31)
#define SEMICOLON (0x33)
#define INVCOMMA (0x34)
#define TILDE (0x35)
#define COMMA (0x36)
#define PERIOD (0x37)
#define FRONTSLASH (0x38)
#define DELETE (0x4c)
/**/
/* Modifier masks. One for both modifiers */
#define SHIFT 0x22
#define SHIFT 0x22
#define CTRL 0x11
#define ALT 0x44
#define GUI 0x88
#define ALT 0x44
#define GUI 0x88
/**/
/* "Sticky keys */
#define CAPSLOCK (0x39)
#define NUMLOCK (0x53)
#define CAPSLOCK (0x39)
#define NUMLOCK (0x53)
#define SCROLLLOCK (0x47)
/* Sticky keys output report bitmasks */
#define bmNUMLOCK 0x01
#define bmCAPSLOCK 0x02
#define bmSCROLLLOCK 0x04
#define bmNUMLOCK 0x01
#define bmCAPSLOCK 0x02
#define bmSCROLLLOCK 0x04
/**/
EP_RECORD ep_record[ 2 ]; //endpoint record structure for the keyboard

Expand All @@ -78,15 +78,7 @@ Max_LCD LCD;
void setup() {
// set up the LCD's number of rows and columns:
LCD.begin(16, 2);
//LCD.leftToRight();
//LCD.autoscroll();
// Print a message to the LCD.

LCD.home();
//LCD.setCursor( 0,0 );
//LCD.print("Start");
//LCD.setCursor(0, 1);
//LCD.print("Second");
Serial.begin( 9600 );
Serial.println("Start");
Max.powerOn();
Expand All @@ -103,16 +95,11 @@ void loop() {
if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) { //poll the keyboard
kbd_poll();
}
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):

// print the number of seconds since reset:
//LCD.print(millis()/1000);
}
/* Initialize keyboard */
void kbd_init( void )
{
byte rcode = 0; //return code
byte rcode = 0; //return code
/**/
/* Initialize data structures */
ep_record[ 0 ] = *( Usb.getDevTableEntry( 0,0 )); //copy endpoint 0 parameters
Expand Down Expand Up @@ -187,8 +174,6 @@ void kbd_poll( void )
Serial.print(HIDtoA( buf[ i ], buf[ 0 ] ));
break;
}//switch( buf[ i ...
Serial.print("LEDs: ");
Serial.println( leds, HEX );
rcode = Usb.setReport( KBD_ADDR, 0, 1, KBD_IF, 0x02, 0, &leds );
if( rcode ) {
Serial.print("Set report error: ");
Expand Down Expand Up @@ -343,17 +328,7 @@ byte HIDtoA( byte HIDbyte, byte mod )
}//switch( HIDbyte..
}//if( HIDbye >= 0x2d && HIDbyte <= 0x38..
return( 0 );
}

//#define RETURN (0x28)
//#define ESCAPE (0x29)
//#define BACKSPACE (0x2A)
//#define TAB (0x2B)
//#define SPACE (0x2C)

//#define BACKSLASH (0x31)


}



Expand Down

0 comments on commit 05beed8

Please sign in to comment.