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:
- stevehousley
- Date:
- 2019-06-03
- Revision:
- 4:6bf4cdb7b834
- Parent:
- 3:e2f13978838c
- Child:
- 5:fc7f3f5f4c2d
File content as of revision 4:6bf4cdb7b834:
/**************************************************************************** - Following program is to emulate Infinity 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); // Switching period: 'every <speed> seconds' const float speed = 10.0; const int hotkeys = KEY_CTRL | KEY_SHIFT; const int maxChannels = 3; const int maxChSw = 60; const int remainMinutesMax = 50; 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); } void lcd_print2(int rMinutes, int rMinutesMax) { lcd.cls(); lcd.locate(0,0); lcd.printf("Idle time:\n>>> %d/%d minutes\n", rMinutes, rMinutesMax); } // Start programm int main(void) { int key_base; int count = 1; // Cumulative channel switching count 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); // Loop forever: // (1) Channel switch continuously for maxChSw in first part of hour. // (2) Idle (no channel switching for remainder of hour. while(1) { int chswTotal = 1; // (1) Channel switch continuously. while(chswTotal <= maxChSw) { key_base = 1; while(key_base <= maxChannels) { 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++; chswTotal++; } } // (2) Idle for remainder of hour, counting up // every 1 minute. int remainMin = 1; while(remainMin <= remainMinutesMax) { lcd_print2(remainMin, remainMinutesMax); wait(60.0); remainMin++; } } }