This keyboard helps to send specific keys
combination or whole words/phrases to PC - this can be Windows Shortcuts, ALT Keyboard Combinations (for example Alt+0169=©), your name or name of
company, useful phrases like "Dear user", "Best Regards". Also it can operate the multimedia functions, such as Volume, Play, Stop, Pause, Rewind and call Browser, Mail, Calculator, Search, Explorer, turn PC to Sleep-mode and Wake Up it. All this functions saved in EEPROM and can be easily changed
without reprogram chip flash memory. In AtMega8 can be stored up to 170 key
combinations in EEPROM. Program occupied less than 60% of flash and can store
additional 1000(!!!) combinations or letters for words/phrases.
Schematic diagram:
Program uses the software USB library, written
by Mr.Ollopa.
For contemporaneously working with keyboard and multimedia interfaces it use
two USB-endpoints, so it enumerates by system as a combined device. It required
some changes in HID descriptors and configuration. In program code this changes
marked for better understanding. New added strings and variables with ***,
changed from original - with !!!. Also (for better reading) descriptors, USB
configuration and key combination were written as separate *.inc files.
Keyboard matrix is 5x7, so it utilizes 35
keys (can be less or up to 49 using D5 & D6 port lines). In program keys
represented with numbers from 1 to 35, corresponding combination is 3 bytes and
has address in EEPROM as
First Byte =>N*3-2
Second Byte =>N*3-1
Third Byte =>N*3
In KeyCodes.inc
this looks as:
............................................................................
Data 8 , 0 , 7 '17 - Turn/Open (Win+D)
Data 4 , 0 , 40 '18 - Full
Size (Alt+Enter)
Data 5 , 0 , 76 '19 - CTRL +
ALT + DEL
Data 8 , 0 , 8 '20 - Explorer (Win+E)
Data 1 , 0 , 6 '21 - Copy (Ctrl+C)
Data 1 , 0 , 25 '22 - Insert
(Ctrl+V)
Data 1 , 0 , 27 '23 - Cut
(Ctrl+X)
Data 1 , 0 , 25 '24 - Save
(Ctrl+S)
Data 1 , 0 , 27 '25 - Undo
(Ctrl+S)
Data 8 , 0 , 72 '26 - System
(Win+Pause/Break)
.............................................................................
where :
1) For "keyboard" :
first byte is combination of Ctrl, Shift, Alt and Win (they can be pressed together):
bit0 LEFT
CTRL (1)
bit1 LEFT SHIFT (2)
bit2 LEFT ALT (4)
bit3 LEFT WIN (8)
bit4 RIGHT CTRL (16)
bit5 RIGHT SHIFT (32)
bit6 RIGHT ALT (64)
bit7 RIGHT WIN (128)
(For example LeftCtrl+LeftAlt=1+4=5)
second byte is always 0
(zero)
third byte is key number according to HID table (not compatible
with ASCII !!!):
2) For "multimedia":
first byte is 1 for Consumer Controls (Volume, Mute, Play, Rewind ...) and 2 for Generic Desktop Controls (Power, Sleep, Wake Up...).
second byte is LSB of command code
third byte is MSB of command code.
See more in http://www.usb.org/developers/devclass_docs/Hut1_11.pdf,
(Generic Desktop - page 27, Consumer Controls - page 75)
Program separates combinations on
"keyboard" or "multimedia" via second byte. In
"keyboard" this byte always 0,
so don't use multimedia codes $100(Fan Enable) and $200(Generic GUI Application
Controls).
For phrase/word sending program used flash ROM :
.............................................................................................................................
Restore Phrase_letters
For K = 1 To Phrase_length
Read Third_byte
If _usb_tx_status._usb_txc = 1 Then
_usb_tx_buffer2(2) =
2 ' "Shift" is pressed - all
letters are capital
_usb_tx_buffer2(3) = 0
_usb_tx_buffer2(4) = Third_byte
Call Usb_send(_usb_tx_status2 , 8) 'Sending one letter
End If
Next K 'Next letter
............................................................
Phrase_letters:
Data 5 , 4 , 22 , 6 , 18 , 45 , 4 , 25 , 21 'Phrase is
"BASCOM-AVR"
..........................................................................................................................
Constant Phrase_length determines the length of phrase/word.
Data consist its letters
in key numbers according to USB keyboard HID table
(see below).
_usb_tx_buffer2(2) = 2
for capital letters and = 0 for
lower.
For utilize 70 keys simply add layout switch S1 (LED
"L" will light then S1 is shorted):
In included BASCOM example keys stored in EEPROM for
this schematic are (key 35 is for sending frase "BASCOM-AVR"):