Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed C12832 USBDevice
Dependents: mbed_alif4000_hotkeys_3chan_001
Revision 5:fc7f3f5f4c2d, committed 2020-10-15
- Comitter:
- jwingar
- Date:
- Thu Oct 15 13:55:37 2020 +0000
- Parent:
- 4:6bf4cdb7b834
- Commit message:
- updated to not have an idle state
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Jun 03 14:38:07 2019 +0000
+++ b/main.cpp Thu Oct 15 13:55:37 2020 +0000
@@ -6,12 +6,11 @@
****************************************************************************/
-
+//imports
#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);
@@ -24,28 +23,23 @@
// 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;
+const int hotkeys = KEY_CTRL | KEY_RALT;
+const int max_channel = 9;
-void lcd_print(int key, int count, float speed) {
+//print to lcd screen while channel switching
+void lcd_print_switching(int key, int total, float speed, int sets) {
lcd.cls();
lcd.locate(0,0);
- lcd.printf("Sending CTRL+SHIFT+%c \nCount: %d\nSpeed: %4.2f\n", key, count, speed);
+ lcd.printf("Sending CTRL+RALT+%c \nCount: %d, Sets: %d\nSpeed: %4.2f seconds\n", key, total, sets, 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
+// Start programme
int main(void) {
- int key_base;
- int count = 1; // Cumulative channel switching count
- char key_modifier;
+
+ int key_base; // channel number
+ int count = 0; // Cumulative channel switching count
+ int sets = 0; // Cumulative channel switching sets
+ char key_modifier;
//Disconnect any existing connections
lcd.cls();
@@ -53,37 +47,22 @@
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.
+ // Loop forever
while(1) {
- int chswTotal = 1;
+ key_base = 0;
- // (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++;
- }
+ while(key_base <= max_channel) {
+ lcd.cls();
+ leds = ~key_base;
+ myleds = key_base;
+ key_modifier = '0'+key_base; //turn to ascii value
+ keyboard.keyCode(key_modifier, hotkeys);
+ count++;
+ lcd_print_switching(key_modifier, count, speed, sets);
+ key_base++;
+ wait(speed);
}
-
- // (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++;
- }
+ sets++;
}
}