The preloaded firmware shipped on the USB Prank.

Dependencies:   USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
Experiment626
Date:
Sat Sep 13 03:28:16 2014 +0000
Child:
1:2449ac218b24
Commit message:
Official USB Prank Firmware 1.0

Changed in this revision

USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Sat Sep 13 03:28:16 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/USBDevice/#5bf05f9b3c7b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Sep 13 03:28:16 2014 +0000
@@ -0,0 +1,81 @@
+#include "mbed.h"
+#include "USBMouse.h"
+#include <stdlib.h>
+#include <math.h>
+
+#define DELAY_TO_NEXT_RADIUS    (rand() % 5 + 1)
+#define DELAY_TO_RESTART        (rand() % 30 + 1)
+
+USBMouse mouse;
+
+main()
+{
+    static const float DELAY_TO_START = 25.0;
+    float DELAY_TO_NEXT_POINT = 0.001;
+    static const int16_t RADIUS_INC = 2;
+    static const int16_t ANGLE_INC = 2;
+    static const int8_t NUM_CIRCLE_SIZES = 4;
+    
+    int16_t x = 0;
+    int16_t y = 0;  
+    int16_t angle = 0;
+    int16_t radius = 5; // if radius is too large, OS dependent, Windows 8 it isn't visible
+    int16_t recenter_radius_correction = 0;
+    
+
+    int8_t circle_count;
+    
+    int nextPointFrequency;
+    
+    // Start-up Code
+    for (circle_count = 1; circle_count <= 5; circle_count++)
+    {
+        while (angle <= 360)
+        {
+            x = cos((double)angle*3.14/180.0)*5;
+            y = sin((double)angle*3.14/180.0)*5;
+            mouse.move(x, y);
+            angle += ANGLE_INC;
+            wait(.001);
+        } // draw circle
+            
+        wait(.25);
+        x = y = angle = 0; 
+    } // end circle_count
+
+    wait(DELAY_TO_START);
+    
+    while (true)
+    {
+        for (circle_count = 1; circle_count <= NUM_CIRCLE_SIZES; circle_count++)
+        {
+            while (angle <= 360)
+            {
+                x = cos((double)angle*3.14/180.0)*radius;
+                y = sin((double)angle*3.14/180.0)*radius;
+                mouse.move(x, y);
+                recenter_radius_correction -= x;
+                angle += ANGLE_INC;
+                wait(DELAY_TO_NEXT_POINT);
+            } // draw circle
+            
+            nextPointFrequency = rand() % 1000 + 1;
+            
+            if(nextPointFrequency < 100)
+                nextPointFrequency = 100;
+                
+            DELAY_TO_NEXT_POINT = 1/(float)nextPointFrequency; 
+            
+            wait(DELAY_TO_NEXT_RADIUS);
+            x = y = angle = 0; 
+            radius += RADIUS_INC;
+            // FIX: Change ANGLE_INCREMENT and DELAY_TO_NEXT_POINT so circle drawn relative resolution and time
+            mouse.move(recenter_radius_correction,0);
+            recenter_radius_correction = 0;
+        } // end circle_count
+        
+        radius = 5;
+        
+        wait(DELAY_TO_RESTART);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Sep 13 03:28:16 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file