Hotkeys for RTL investigation

Dependencies:   C12832 USBDevice mbed

Dependents:   mbed_hotkeys_rtlx7 mbed_hotkeys_rtlX6

main.cpp

Committer:
rowlybot12000
Date:
2018-05-09
Revision:
1:e0fb48c0f15b
Parent:
0:fcb5eced08ed
Child:
2:f5bc849199f3

File content as of revision 1:e0fb48c0f15b:

/*==============================================================================
* Hotkey channel switcher                                                      *
* Sends hotkeys to switch channels on Infinity-like systems, then types        *
* 
==============================================================================*/
 
 
#include "mbed.h"
#include "C12832.h"
#include "USBKeyboard.h"
#include <string>
 
 
BusOut leds(p23, p24, p25);
C12832 lcd(p5, p7, p6, p8, p11);
USBKeyboard keyboard;
 
const float delay = 0.1;
int count = 1;

const int ccs_hotkeys = KEY_CTRL | KEY_ALT;
int ccs_base = 1;
const int ccs_end = 8;
char ccs_mod;

const int alif_hotkeys = KEY_CTRL | KEY_SHIFT;
int alif_base = 1;
const int alif_end = 4;
char alif_mod;

const float speed = 5;

string info;
 
static void sendKey(char c, int modifiers, float delay)
{
    keyboard.keyCode(c, modifiers);
    wait(delay);
}

//Display general status information
void printData(string info, int key2) {
    lcd.cls();
    lcd.locate(0,0);
    lcd.printf("Sending %s+%c \n", info.c_str(), key2);
}
 
int main(void)
{
    
    lcd.cls();
    lcd.locate(0,0);
    lcd.printf("Starting Up,\nAllowing USB to settle\n>>Please Wait<< ");
    wait(10);    
    
    while (1) {
        
        ccs_base = 1;
                
        while (ccs_base<=ccs_end) {
            
            //setup and open next connection
            ccs_mod = '0'+ccs_base;
            leds = ~ccs_base;
            sendKey(ccs_mod, ccs_hotkeys, delay);
            printData("Ctrl+Alt", ccs_mod);
            wait(speed);
            alif_base = 1;
            while (alif_base<=alif_end) {
                alif_mod = '0'+alif_base;
                sendKey(alif_mod, alif_hotkeys, delay);
                printData("Ctrl+Shift", alif_mod);
                wait(speed);
                sendKey('x', alif_hotkeys, delay);
                alif_base++;
            }
            //prep for next loop
            wait(speed);
            ccs_base++;

        }
    }
}