Sends infinity hotkey combinations (Current: LCTRL + RALT + NUM) Cycles numbers 0 to 9 with gaps of 10 seconds.

Dependencies:   mbed C12832 USBDevice

Dependents:   mbed_alif4000_hotkeys_3chan_001

main.cpp

Committer:
shivikas
Date:
2018-02-23
Revision:
1:0e50909db8ee
Parent:
0:f4e0c6f139ea
Child:
2:9bf087cff7f4

File content as of revision 1:0e50909db8ee:

/****************************************************************************
- Following program is to emulate Inifinity channel switching.
- embeds are used to send hotkey combination to switch channel. 
- CTRL+SHIFT+[1-4] is used to switch among four channels.
- LCD screen on mbed application board is used to show switch status and count.

****************************************************************************/


#include "mbed.h"
#include "C12832.h"
#include "USBKeyboard.h"


// To change LED colour at channel switching
BusOut leds(p23, p24, p25);
BusOut myleds(LED1, LED2, LED3, LED4);

// keyboard interface to emulate keyboard and send keys with modifiers
USBKeyboard keyboard;

// LCD interface on appication board
C12832 lcd(p5, p7, p6, p8, p11);

const float speed = 5;
const int hotkeys = KEY_CTRL | KEY_SHIFT;

void lcd_print(int key, int count, float speed) {
    lcd.cls();
    lcd.locate(0,0);
    lcd.printf("Sending CTRL+SHIFT+%c \nCount: %d\nSpeed: %4.2f\n", key, count, speed);
}

// Start programm
int main(void) {
    int key_base;
    int count = 1;
    char key_modifier;
    
    //Disconnect any existing connections
    lcd.cls();
    lcd.locate(0,0);
    lcd.printf("Starting Up..\nAllowing USB to settle\n>>Please Wait<< ");
    wait(10);
    
    while(1) {
        key_base = 1;
        while(key_base <= 6) {
            lcd.cls();
            leds = ~key_base;
            myleds = key_base;
            key_modifier = '0'+key_base;
            keyboard.keyCode(key_modifier, hotkeys);
            lcd_print(key_modifier, count, speed);
            wait(speed);
            key_base++;
            count++;          
        }
    }
}