UT CS Bootcamp code for creating a secret knock
Dependencies: MMA8451Q mbed tsi_sensor
Fork of UTCSBootcamp by
Revision 10:351ba1920e42, committed 2014-08-21
- Comitter:
- parnell
- Date:
- Thu Aug 21 19:48:43 2014 +0000
- Parent:
- 9:0ba1973c3bd3
- Child:
- 11:0ac08d8a296f
- Commit message:
- Updated;
Changed in this revision
--- a/Includes/KnockBaseAPI.h Tue Aug 19 08:21:12 2014 +0000 +++ b/Includes/KnockBaseAPI.h Thu Aug 21 19:48:43 2014 +0000 @@ -2,7 +2,7 @@ #define KNOCK_BASE_API_046o73i4277823 #include <stdarg.h> -#include <MMA8451Q.h> +#include <MMA8451Q.h> // accelerometer Serial port(USBTX,USBRX); @@ -33,9 +33,9 @@ void _initialize(){ if(debug) utrace("initialize()\r\n"); /// set leds - rl = 1; - gl = 1; - bl = 1; + rl.write(1); + gl.write(1); + bl.write(1); // Initialize Baud Rate for PC Console // pc.baud(38400); }
--- a/KnockAPI.cpp Tue Aug 19 08:21:12 2014 +0000 +++ b/KnockAPI.cpp Thu Aug 21 19:48:43 2014 +0000 @@ -37,17 +37,41 @@ /******************************** INPUTS AND OUTPUTS ********************************/ void redLED(bool on){ - rl = !on; - if(debug) print("redLED(%d) \r\n", on); + redLED(on, true); } void greenLED(bool on){ - gl = !on; - if(debug) print("greenLED(%d) \r\n", on); + greenLED(on, true); } void blueLED(bool on){ - bl = !on; + blueLED(on, true); +} + +void redLED(bool on, bool turnOffOtherColors){ + if (turnOffOtherColors){ + gl.write(1); + bl.write(1); + } + rl.write(!on); + if(debug) print("redLED(%d) \r\n", on); +} + +void greenLED(bool on, bool turnOffOtherColors){ + if (turnOffOtherColors){ + rl.write(1); + bl.write(1); + } + gl.write(!on); + if(debug) print("greenLED(%d)\r\n", on); +} + +void blueLED(bool on, bool turnOffOtherColors){ + if (turnOffOtherColors){ + rl.write(1); + gl.write(1); + } + bl.write(!on); if(debug) print("blueLED(%d) \r\n", on); }
--- a/KnockAPI.h Tue Aug 19 08:21:12 2014 +0000 +++ b/KnockAPI.h Thu Aug 21 19:48:43 2014 +0000 @@ -49,6 +49,30 @@ */ void blueLED(bool on); +/** turn on/off red led + * @param on: true to turn on, false to turn off + * @param turnOffOtherColors: + true to only turn on/off this color, + false to allow color mixing with other colors + */ +void redLED(bool on, bool turnOffOtherColors); + +/** turn on/off green led + * @param on: true to turn on, false to turn off + * @param turnOffOtherColors: + true to only turn on/off this color, + false to allow color mixing with other colors + */ +void greenLED(bool on, bool turnOffOtherColors); + +/** turn on/off blue led + * @param on: true to turn on, false to turn off + * @param turnOffOtherColors: + true to only turn on/off this color, + false to allow color mixing with other colors + */ +void blueLED(bool on, bool turnOffOtherColors); + /** Turn on debugging. Prints each method call to the serial port. * @param _debug True to turn on debugging, false to turn it off. */
--- a/main.cpp Tue Aug 19 08:21:12 2014 +0000 +++ b/main.cpp Thu Aug 21 19:48:43 2014 +0000 @@ -6,8 +6,9 @@ int main() { init(); /// call the base inits - -// setDebug(true); // uncomment to see print traces from all API functions + /* uncomment to see print traces from all API functions + (you will need to use your serial port for this) */ +// setDebug(true); /** Code for the accelerometer can be found in MMA8451Q.h @@ -17,8 +18,8 @@ accelerometer.getAccZ(); */ Accelerometer accelerometer = getAccelerometer(); - /// Code Setup - while(true) { + /// Your code begins here + while(true) { /* <-- you can change this loop as well */ /* your code here */ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsi_sensor.lib Thu Aug 21 19:48:43 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Kojto/code/tsi_sensor/#20ffa9b18488