Sunday, 08 December 2019
     
 
Main Menu
Home Home
Shop Shop
News News
BASCOM-AVR BASCOM-AVR
BASCOM-8051 BASCOM-8051
Products Products
Application Notes Application Notes
Publications Publications
Links Links
Support Center Support Center
Downloads Downloads
Forum Forum
Resellers Resellers
Contact Us Contact Us
Updates Updates
MCS Wiki MCS Wiki
Online Help
BASCOM-AVR Help BASCOM-AVR Help
BASCOM-8051 Help BASCOM-8051 Help
Contents in Cart
Show Cart
Your Cart is currently empty.
Search the Shop

Products Search

User Login
Username

Password

If you have problem after log in with disappeared login data, please press F5 in your browser

RSS News
 
     
 

 
   
     
 
AN #197 - Additional PC Multimedia USB-keyboard. Print
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.


by:
Vasily Rubashka, Ukraine , Sergey Shilov, Russia

 

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"):

 

Key

Main Layout (S1 is open)

Second Layout (S1 is shorted) for Microsoft Word

1

Browser

Insert © (Alt+Ctrl+C)

2

Mail

Insert ® (Alt+Ctrl+R)

3

Search

Insert ™ (Alt+Ctrl+T)

4

My PC

Insert ... (Alt+Ctrl+.)

5

Calculator

Insert a footnote (Alt+Ctrl+F)

6

FastForward

Insert an endnote (Alt+Ctrl+D)

7

Rewind

Insert a hyperlink (Ctrl+K)

8

Stop

Insert current date (Alt+Shift+D)

9

Play/Pause

Insert time (Alt+Shift+T)

10

Mute

Insert an empty {} field (Ctrl+F9)

11

Volume-

Apply/remove subscript (Ctrl+=)

12

Volume+

Apply/remove superscript (Ctrl+Shift+=)

13

Power

Apply/remove double-underline (Ctrl+Shift+D)

14

Wake Up

Apply/remove all capitals (Ctrl+Shift+A)

15

Standby

Apply/remove small capitals (Ctrl+Shift+K)

16

Close (Alt+F4)

All upper / first letter upper / all lower-case (Shift+F3)

17

Turn/Open (Win+D)

Display nonprinting characters (Ctrl+Shift+*)

18

Full Size (Alt+Enter)

Copy (Ctrl+C)

19

CTRL + ALT + DEL

Paste (Ctrl+V)

20

Explorer (Win+E)

Cut (Ctrl+X)

21

Copy (Ctrl+C)

Cut to the Spike (Ctrl+F3)

22

Insert (Ctrl+V)

Paste from the Spike (Ctrl+Shift+F3)

23

Cut (Ctrl+X)

Undo (Ctrl+Z)

24

Save (Ctrl+S)

Redo (Ctrl+Y)

25

Undo (Ctrl+Z)

Font dialog (Ctrl+D)

26

System (Win+Pause/Break)

Increase font size (Ctrl+])

27

System Menu (Alt+Space)

Decrease font size (Ctrl+[)

28

Create A New Folder (Ctrl+Shift+N)

Search menu (Ctrl+F)

29

High Contrast ON or OFF (Left Alt+Left Shift+PrtScn)

Find and replace dialog (Ctrl+H)

30

Shortcut menu (Shift+F10)

Repeat find (Shift+F4)

31

Task Manager (Ctrl+Shift+Esc)

Switch between documents (Ctrl+F6)

32

Ease of Access Center (Win+U)

Statistic (Ctrl+Shift+G)

33

Gadgets (Win+G)

Print (Ctrl+P)

34

Presentation mode (Win+P)

Save (Ctrl+S)


Ready device: