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.
Fork of randomSearch by
Diff: main.cpp
- Revision:
- 2:15eab46e805b
- Parent:
- 1:f2747e954f10
- Child:
- 3:7fe4dd911b58
--- a/main.cpp Thu Dec 17 21:21:06 2015 +0000
+++ b/main.cpp Thu Jan 14 17:00:53 2016 +0000
@@ -25,6 +25,8 @@
/// Run image searches at interval seconds for given number of repeats or -1 to run forever
void startSearches(float interval, int number);
+void runCommand(char *address);
+
// enter a keyboard string
void sendString(const char *str);
@@ -37,14 +39,24 @@
// Turn caps lock on n seconds after they turn it off.
void forceCaps(float delay, float checkPeriod=0.5);
+void maxVolume();
+void capsOn();
main()
{
LEDs = 0;
wait(10);
- forceCaps(5);
while (true) {
-
+ capsOn();
+ while ((keyboard.lockStatus() & 0x02) == 0x02) {
+ wait(1);
+ }
+ maxVolume();
+ runCommand("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
+ drawCircle(80,15);
+ drawCircle(100,15);
+ drawCircle(120,15);
+ wait(60*5);
}
}
@@ -77,6 +89,15 @@
searchTicker.attach(doNextSearch,interval);
}
+void runCommand(char *address)
+{
+ keyboard.keyCode('r',KEY_LOGO); // windows key an R
+ wait(0.1); // delay to give the run box a chance to come up.
+ sendString(address);
+ wait(0.05);
+ keyboard.putc(0x0a); // hit enter
+}
+
void sendString(const char *str)
{
while (*str != 0) {
@@ -85,6 +106,13 @@
}
}
+void maxVolume()
+{
+ for (int i = 0; i<50; i++) {
+ keyboard.mediaControl(KEY_VOLUME_UP);
+ }
+}
+
void drawCircle(float radius, float time, bool dir)
{
@@ -170,11 +198,12 @@
}
}
-void forceCaps(float delay, float checkPeriod) {
+void forceCaps(float delay, float checkPeriod)
+{
if (checkPeriod == 0)
- capLockTick.attach(NULL,0);
- else {
- capsWaitPeriod = delay;
- capLockTick.attach(checkCapsLock,checkPeriod);
- }
+ capLockTick.attach(NULL,0);
+ else {
+ capsWaitPeriod = delay;
+ capLockTick.attach(checkCapsLock,checkPeriod);
}
+}
