wiring-sucks

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 3677a2498f11e23b7edc3359b2aa7f546d29c04a
parent d86d9c75d4b48838ad33e7f25255e2cfdb2823e2
Author: Elecon-rou <elecon@xecut.net>
Date:   Thu,  2 Jul 2020 10:18:46 +0000

remove unneeded docs

Diffstat:
Ddoc/Bridge/README.adoc | 24------------------------
Ddoc/Bridge/examples/Bridge/Bridge.ino | 183-------------------------------------------------------------------------------
Ddoc/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino | 95-------------------------------------------------------------------------------
Ddoc/Bridge/examples/ConsolePixel/ConsolePixel.ino | 63---------------------------------------------------------------
Ddoc/Bridge/examples/ConsoleRead/ConsoleRead.ino | 58----------------------------------------------------------
Ddoc/Bridge/examples/Datalogger/Datalogger.ino | 102-------------------------------------------------------------------------------
Ddoc/Bridge/examples/FileWriteScript/FileWriteScript.ino | 83-------------------------------------------------------------------------------
Ddoc/Bridge/examples/HttpClient/HttpClient.ino | 51---------------------------------------------------
Ddoc/Bridge/examples/HttpClientConsole/HttpClientConsole.ino | 53-----------------------------------------------------
Ddoc/Bridge/examples/MailboxReadMessage/MailboxReadMessage.ino | 58----------------------------------------------------------
Ddoc/Bridge/examples/Process/Process.ino | 71-----------------------------------------------------------------------
Ddoc/Bridge/examples/RemoteDueBlink/RemoteDueBlink.ino | 33---------------------------------
Ddoc/Bridge/examples/ShellCommands/ShellCommands.ino | 52----------------------------------------------------
Ddoc/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino | 122-------------------------------------------------------------------------------
Ddoc/Bridge/examples/TemperatureWebPanel/www/index.html | 16----------------
Ddoc/Bridge/examples/TemperatureWebPanel/www/zepto.min.js | 2--
Ddoc/Bridge/examples/TimeCheck/TimeCheck.ino | 88-------------------------------------------------------------------------------
Ddoc/Bridge/examples/WiFiStatus/WiFiStatus.ino | 51---------------------------------------------------
Ddoc/Bridge/examples/YunFirstConfig/YunFirstConfig.ino | 328-------------------------------------------------------------------------------
Ddoc/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino | 82-------------------------------------------------------------------------------
Ddoc/Esplora/README.adoc | 24------------------------
Ddoc/Esplora/examples/Beginners/EsploraAccelerometer/EsploraAccelerometer.ino | 38--------------------------------------
Ddoc/Esplora/examples/Beginners/EsploraBlink/EsploraBlink.ino | 42------------------------------------------
Ddoc/Esplora/examples/Beginners/EsploraJoystickMouse/EsploraJoystickMouse.ino | 60------------------------------------------------------------
Ddoc/Esplora/examples/Beginners/EsploraLedShow/EsploraLedShow.ino | 42------------------------------------------
Ddoc/Esplora/examples/Beginners/EsploraLedShow2/EsploraLedShow2.ino | 55-------------------------------------------------------
Ddoc/Esplora/examples/Beginners/EsploraLightCalibrator/EsploraLightCalibrator.ino | 91-------------------------------------------------------------------------------
Ddoc/Esplora/examples/Beginners/EsploraMusic/EsploraMusic.ino | 53-----------------------------------------------------
Ddoc/Esplora/examples/Beginners/EsploraSoundSensor/EsploraSoundSensor.ino | 41-----------------------------------------
Ddoc/Esplora/examples/Beginners/EsploraTemperatureSensor/EsploraTemperatureSensor.ino | 37-------------------------------------
Ddoc/Esplora/examples/Experts/EsploraKart/EsploraKart.ino | 125-------------------------------------------------------------------------------
Ddoc/Esplora/examples/Experts/EsploraPong/EsploraPong.ino | 44--------------------------------------------
Ddoc/Esplora/examples/Experts/EsploraRemote/EsploraRemote.ino | 116-------------------------------------------------------------------------------
Ddoc/Esplora/examples/Experts/EsploraTable/EsploraTable.ino | 213-------------------------------------------------------------------------------
Ddoc/Keyboard/README.adoc | 25-------------------------
Ddoc/Mouse/README.adoc | 25-------------------------
Ddoc/RobotIRremote/LICENSE.txt | 458-------------------------------------------------------------------------------
Ddoc/RobotIRremote/README.adoc | 31-------------------------------
Ddoc/Robot_Control/README.adoc | 27---------------------------
Ddoc/Robot_Control/examples/explore/R01_Logo/R01_Logo.ino | 136-------------------------------------------------------------------------------
Ddoc/Robot_Control/examples/explore/R02_Line_Follow/R02_Line_Follow.ino | 76----------------------------------------------------------------------------
Ddoc/Robot_Control/examples/explore/R03_Disco_Bot/R03_Disco_Bot.ino | 181-------------------------------------------------------------------------------
Ddoc/Robot_Control/examples/explore/R04_Compass/R04_Compass.ino | 72------------------------------------------------------------------------
Ddoc/Robot_Control/examples/explore/R05_Inputs/R05_Inputs.ino | 167-------------------------------------------------------------------------------
Ddoc/Robot_Control/examples/explore/R06_Wheel_Calibration/R06_Wheel_Calibration.ino | 40----------------------------------------
Ddoc/Robot_Control/examples/explore/R06_Wheel_Calibration/scripts_library.h | 43-------------------------------------------
Ddoc/Robot_Control/examples/explore/R07_Runaway_Robot/R07_Runaway_Robot.ino | 80-------------------------------------------------------------------------------
Ddoc/Robot_Control/examples/explore/R08_Remote_Control/R08_Remote_Control.ino | 93-------------------------------------------------------------------------------
Ddoc/Robot_Control/examples/explore/R09_Picture_Browser/R09_Picture_Browser.ino | 161-------------------------------------------------------------------------------
Ddoc/Robot_Control/examples/explore/R10_Rescue/R10_Rescue.ino | 121-------------------------------------------------------------------------------
Ddoc/Robot_Control/examples/explore/R11_Hello_User/R11_Hello_User.ino | 180-------------------------------------------------------------------------------
Ddoc/Robot_Control/examples/learn/AllIOPorts/AllIOPorts.ino | 151------------------------------------------------------------------------------
Ddoc/Robot_Control/examples/learn/Beep/Beep.ino | 41-----------------------------------------
Ddoc/Robot_Control/examples/learn/CleanEEPROM/CleanEEPROM.ino | 43-------------------------------------------
Ddoc/Robot_Control/examples/learn/Compass/Compass.ino | 43-------------------------------------------
Ddoc/Robot_Control/examples/learn/IRArray/IRArray.ino | 46----------------------------------------------
Ddoc/Robot_Control/examples/learn/LCDDebugPrint/LCDDebugPrint.ino | 39---------------------------------------
Ddoc/Robot_Control/examples/learn/LCDPrint/LCDPrint.ino | 46----------------------------------------------
Ddoc/Robot_Control/examples/learn/LCDWriteText/LCDWriteText.ino | 43-------------------------------------------
Ddoc/Robot_Control/examples/learn/LineFollowWithPause/LineFollowWithPause.ino | 51---------------------------------------------------
Ddoc/Robot_Control/examples/learn/Melody/Melody.ino | 64----------------------------------------------------------------
Ddoc/Robot_Control/examples/learn/MotorTest/MotorTest.ino | 43-------------------------------------------
Ddoc/Robot_Control/examples/learn/SpeedByPotentiometer/SpeedByPotentiometer.ino | 41-----------------------------------------
Ddoc/Robot_Control/examples/learn/TurnTest/TurnTest.ino | 34----------------------------------
Ddoc/Robot_Control/examples/learn/keyboardTest/keyboardTest.ino | 40----------------------------------------
Ddoc/Robot_Motor/README.adoc | 24------------------------
Ddoc/Robot_Motor/examples/Robot_IR_Array_Test/Robot_IR_Array_Test.ino | 26--------------------------
Ddoc/Robot_Motor/examples/Robot_Motor_Core/Robot_Motor_Core.ino | 18------------------
Ddoc/SpacebrewYun/README.adoc | 21---------------------
Ddoc/SpacebrewYun/examples/inputOutput/inputOutput.ino | 134-------------------------------------------------------------------------------
Ddoc/SpacebrewYun/examples/spacebrewBoolean/spacebrewBoolean.ino | 94-------------------------------------------------------------------------------
Ddoc/SpacebrewYun/examples/spacebrewRange/spacebrewRange.ino | 88-------------------------------------------------------------------------------
Ddoc/SpacebrewYun/examples/spacebrewString/spacebrewString.ino | 86-------------------------------------------------------------------------------
Ddoc/TFT/README.adoc | 26--------------------------
Ddoc/TFT/examples/Arduino/TFTBitmapLogo/TFTBitmapLogo.ino | 108-------------------------------------------------------------------------------
Ddoc/TFT/examples/Arduino/TFTBitmapLogo/arduino.bmp | 0
Ddoc/TFT/examples/Arduino/TFTColorPicker/TFTColorPicker.ino | 67-------------------------------------------------------------------
Ddoc/TFT/examples/Arduino/TFTDisplayText/TFTDisplayText.ino | 74--------------------------------------------------------------------------
Ddoc/TFT/examples/Arduino/TFTEtchASketch/TFTEtchASketch.ino | 83-------------------------------------------------------------------------------
Ddoc/TFT/examples/Arduino/TFTGraph/TFTGraph.ino | 70----------------------------------------------------------------------
Ddoc/TFT/examples/Arduino/TFTPong/TFTPong.ino | 135-------------------------------------------------------------------------------
Ddoc/TFT/examples/Esplora/EsploraTFTBitmapLogo/EsploraTFTBitmapLogo.ino | 101-------------------------------------------------------------------------------
Ddoc/TFT/examples/Esplora/EsploraTFTBitmapLogo/arduino.bmp | 0
Ddoc/TFT/examples/Esplora/EsploraTFTColorPicker/EsploraTFTColorPicker.ino | 54------------------------------------------------------
Ddoc/TFT/examples/Esplora/EsploraTFTEtchASketch/EsploraTFTEtchASketch.ino | 80-------------------------------------------------------------------------------
Ddoc/TFT/examples/Esplora/EsploraTFTGraph/EsploraTFTGraph.ino | 55-------------------------------------------------------
Ddoc/TFT/examples/Esplora/EsploraTFTHorizon/EsploraTFTHorizon.ino | 62--------------------------------------------------------------
Ddoc/TFT/examples/Esplora/EsploraTFTPong/EsploraTFTPong.ino | 126-------------------------------------------------------------------------------
Ddoc/TFT/examples/Esplora/EsploraTFTTemp/EsploraTFTTemp.ino | 64----------------------------------------------------------------
Ddoc/Temboo/README.adoc | 32--------------------------------
Ddoc/Temboo/examples/ArduinoYun/CloudControlsConfig/CloudControlsConfig.ino | 97-------------------------------------------------------------------------------
Ddoc/Temboo/examples/ArduinoYun/GetYahooWeatherReport/GetYahooWeatherReport.ino | 115-------------------------------------------------------------------------------
Ddoc/Temboo/examples/ArduinoYun/GetYahooWeatherReport/TembooAccount.h | 4----
Ddoc/Temboo/examples/ArduinoYun/ReadATweet/ReadATweet.ino | 173-------------------------------------------------------------------------------
Ddoc/Temboo/examples/ArduinoYun/ReadATweet/TembooAccount.h | 4----
Ddoc/Temboo/examples/ArduinoYun/SendATweet/SendATweet.ino | 138-------------------------------------------------------------------------------
Ddoc/Temboo/examples/ArduinoYun/SendATweet/TembooAccount.h | 4----
Ddoc/Temboo/examples/ArduinoYun/SendAnEmail/SendAnEmail.ino | 166-------------------------------------------------------------------------------
Ddoc/Temboo/examples/ArduinoYun/SendAnEmail/TembooAccount.h | 4----
Ddoc/Temboo/examples/ArduinoYun/SendAnSMS/SendAnSMS.ino | 154-------------------------------------------------------------------------------
Ddoc/Temboo/examples/ArduinoYun/SendAnSMS/TembooAccount.h | 5-----
Ddoc/Temboo/examples/ArduinoYun/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino | 200-------------------------------------------------------------------------------
Ddoc/Temboo/examples/ArduinoYun/SendDataToGoogleSpreadsheet/TembooAccount.h | 5-----
Ddoc/Temboo/examples/ArduinoYun/ToxicFacilitiesSearch/TembooAccount.h | 5-----
Ddoc/Temboo/examples/ArduinoYun/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino | 171-------------------------------------------------------------------------------
Ddoc/Temboo/examples/ArduinoYun/UpdateFacebookStatus/TembooAccount.h | 5-----
Ddoc/Temboo/examples/ArduinoYun/UpdateFacebookStatus/UpdateFacebookStatus.ino | 132-------------------------------------------------------------------------------
Ddoc/Temboo/examples/ArduinoYun/UploadToDropbox/TembooAccount.h | 5-----
Ddoc/Temboo/examples/ArduinoYun/UploadToDropbox/UploadToDropbox.ino | 208-------------------------------------------------------------------------------
109 files changed, 0 insertions(+), 8460 deletions(-)

diff --git a/doc/Bridge/README.adoc b/doc/Bridge/README.adoc @@ -1,24 +0,0 @@ -= Bridge Library for Arduino = - -The Bridge library simplifies communication between the ATmega32U4 and the AR9331. - -For more information about this library please visit us at -http://www.arduino.cc/en/Reference/YunBridgeLibrary - -== License == - -Copyright (c) 2014 Arduino LLC. All right reserved. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/doc/Bridge/examples/Bridge/Bridge.ino b/doc/Bridge/examples/Bridge/Bridge.ino @@ -1,183 +0,0 @@ -/* - Arduino Yún Bridge example - - This example for the YunShield/Yún shows how - to use the Bridge library to access the digital and - analog pins on the board through REST calls. - It demonstrates how you can create your own API when - using REST style calls through the browser. - - Possible commands created in this shetch: - - "/arduino/digital/13" -> digitalRead(13) - "/arduino/digital/13/1" -> digitalWrite(13, HIGH) - "/arduino/analog/2/123" -> analogWrite(2, 123) - "/arduino/analog/2" -> analogRead(2) - "/arduino/mode/13/input" -> pinMode(13, INPUT) - "/arduino/mode/13/output" -> pinMode(13, OUTPUT) - - This example code is part of the public domain - - http://www.arduino.cc/en/Tutorial/Bridge - -*/ - -#include <Bridge.h> -#include <BridgeServer.h> -#include <BridgeClient.h> - -// Listen to the default port 5555, the Yún webserver -// will forward there all the HTTP requests you send -BridgeServer server; - -void setup() { - // Bridge startup - pinMode(13, OUTPUT); - digitalWrite(13, LOW); - Bridge.begin(); - digitalWrite(13, HIGH); - - // Listen for incoming connection only from localhost - // (no one from the external network could connect) - server.listenOnLocalhost(); - server.begin(); -} - -void loop() { - // Get clients coming from server - BridgeClient client = server.accept(); - - // There is a new client? - if (client) { - // Process request - process(client); - - // Close connection and free resources. - client.stop(); - } - - delay(50); // Poll every 50ms -} - -void process(BridgeClient client) { - // read the command - String command = client.readStringUntil('/'); - - // is "digital" command? - if (command == "digital") { - digitalCommand(client); - } - - // is "analog" command? - if (command == "analog") { - analogCommand(client); - } - - // is "mode" command? - if (command == "mode") { - modeCommand(client); - } -} - -void digitalCommand(BridgeClient client) { - int pin, value; - - // Read pin number - pin = client.parseInt(); - - // If the next character is a '/' it means we have an URL - // with a value like: "/digital/13/1" - if (client.read() == '/') { - value = client.parseInt(); - digitalWrite(pin, value); - } else { - value = digitalRead(pin); - } - - // Send feedback to client - client.print(F("Pin D")); - client.print(pin); - client.print(F(" set to ")); - client.println(value); - - // Update datastore key with the current pin value - String key = "D"; - key += pin; - Bridge.put(key, String(value)); -} - -void analogCommand(BridgeClient client) { - int pin, value; - - // Read pin number - pin = client.parseInt(); - - // If the next character is a '/' it means we have an URL - // with a value like: "/analog/5/120" - if (client.read() == '/') { - // Read value and execute command - value = client.parseInt(); - analogWrite(pin, value); - - // Send feedback to client - client.print(F("Pin D")); - client.print(pin); - client.print(F(" set to analog ")); - client.println(value); - - // Update datastore key with the current pin value - String key = "D"; - key += pin; - Bridge.put(key, String(value)); - } else { - // Read analog pin - value = analogRead(pin); - - // Send feedback to client - client.print(F("Pin A")); - client.print(pin); - client.print(F(" reads analog ")); - client.println(value); - - // Update datastore key with the current pin value - String key = "A"; - key += pin; - Bridge.put(key, String(value)); - } -} - -void modeCommand(BridgeClient client) { - int pin; - - // Read pin number - pin = client.parseInt(); - - // If the next character is not a '/' we have a malformed URL - if (client.read() != '/') { - client.println(F("error")); - return; - } - - String mode = client.readStringUntil('\r'); - - if (mode == "input") { - pinMode(pin, INPUT); - // Send feedback to client - client.print(F("Pin D")); - client.print(pin); - client.print(F(" configured as INPUT!")); - return; - } - - if (mode == "output") { - pinMode(pin, OUTPUT); - // Send feedback to client - client.print(F("Pin D")); - client.print(pin); - client.print(F(" configured as OUTPUT!")); - return; - } - - client.print(F("error: invalid mode ")); - client.print(mode); -} diff --git a/doc/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino b/doc/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino @@ -1,95 +0,0 @@ -/* - Console ASCII table for YunShield/Yún - Prints out byte values in all possible formats: - * as raw binary values - * as ASCII-encoded decimal, hex, octal, and binary values - - For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII - - The circuit: - - YunShield/Yún - - created 2006 - by Nicholas Zambetti - http://www.zambetti.com - modified 9 Apr 2012 - by Tom Igoe - modified 22 May 2013 - by Cristian Maglie - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/ConsoleAsciiTable - - */ - -#include <Console.h> - -void setup() { - //Initialize Console and wait for port to open: - Bridge.begin(); - Console.begin(); - - // Uncomment the following line to enable buffering: - // - better transmission speed and efficiency - // - needs to call Console.flush() to ensure that all - // transmitted data is sent - - //Console.buffer(64); - - while (!Console) { - ; // wait for Console port to connect. - } - - // prints title with ending line break - Console.println("ASCII Table ~ Character Map"); -} - -// first visible ASCIIcharacter '!' is number 33: -int thisByte = 33; -// you can also write ASCII characters in single quotes. -// for example. '!' is the same as 33, so you could also use this: -//int thisByte = '!'; - -void loop() { - // prints value unaltered, i.e. the raw binary version of the - // byte. The Console monitor interprets all bytes as - // ASCII, so 33, the first number, will show up as '!' - Console.write(thisByte); - - Console.print(", dec: "); - // prints value as string as an ASCII-encoded decimal (base 10). - // Decimal is the default format for Console.print() and Console.println(), - // so no modifier is needed: - Console.print(thisByte); - // But you can declare the modifier for decimal if you want to. - //this also works if you uncomment it: - - // Console.print(thisByte, DEC); - - Console.print(", hex: "); - // prints value as string in hexadecimal (base 16): - Console.print(thisByte, HEX); - - Console.print(", oct: "); - // prints value as string in octal (base 8); - Console.print(thisByte, OCT); - - Console.print(", bin: "); - // prints value as string in binary (base 2) - // also prints ending line break: - Console.println(thisByte, BIN); - - // if printed last visible character '~' or 126, stop: - if (thisByte == 126) { // you could also use if (thisByte == '~') { - // ensure the latest bit of data is sent - Console.flush(); - - // This loop loops forever and does nothing - while (true) { - continue; - } - } - // go on to the next character - thisByte++; -} diff --git a/doc/Bridge/examples/ConsolePixel/ConsolePixel.ino b/doc/Bridge/examples/ConsolePixel/ConsolePixel.ino @@ -1,63 +0,0 @@ -/* - Console Pixel - - An example of using YunShield/Yún board to receive data from the - Console on the Yún. In this case, the board turns on an LED when - it receives the character 'H', and turns off the LED when it - receives the character 'L'. - - To see the Console, pick your Yún's name and IP address in the Port menu - then open the Port Monitor. You can also see it by opening a terminal window - and typing - ssh root@ yourYunsName.local 'telnet localhost 6571' - then pressing enter. When prompted for the password, enter it. - - - The circuit: - * LED connected from digital pin 13 to ground - - created 2006 - by David A. Mellis - modified 25 Jun 2013 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/ConsolePixel - - */ - -#include <Console.h> - -const int ledPin = 13; // the pin that the LED is attached to -char incomingByte; // a variable to read incoming Console data into - -void setup() { - Bridge.begin(); // Initialize Bridge - Console.begin(); // Initialize Console - - // Wait for the Console port to connect - while (!Console); - - Console.println("type H or L to turn pin 13 on or off"); - - // initialize the LED pin as an output: - pinMode(ledPin, OUTPUT); -} - -void loop() { - // see if there's incoming Console data: - if (Console.available() > 0) { - // read the oldest byte in the Console buffer: - incomingByte = Console.read(); - Console.println(incomingByte); - // if it's a capital H (ASCII 72), turn on the LED: - if (incomingByte == 'H') { - digitalWrite(ledPin, HIGH); - } - // if it's an L (ASCII 76) turn off the LED: - if (incomingByte == 'L') { - digitalWrite(ledPin, LOW); - } - } -} diff --git a/doc/Bridge/examples/ConsoleRead/ConsoleRead.ino b/doc/Bridge/examples/ConsoleRead/ConsoleRead.ino @@ -1,58 +0,0 @@ -/* -Console Read example for YunShield/Yún - - Read data coming from bridge using the Console.read() function - and store it in a string. - - To see the Console, pick your Yún's name and IP address in the Port menu - then open the Port Monitor. You can also see it by opening a terminal window - and typing: - ssh root@ yourYunsName.local 'telnet localhost 6571' - then pressing enter. When prompted for the password, enter it. - - created 13 Jun 2013 - by Angelo Scialabba - modified 16 June 2013 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/ConsoleRead - - */ - -#include <Console.h> - -String name; - -void setup() { - // Initialize Console and wait for port to open: - Bridge.begin(); - Console.begin(); - - // Wait for Console port to connect - while (!Console); - - Console.println("Hi, what's your name?"); -} - -void loop() { - if (Console.available() > 0) { - char c = Console.read(); // read the next char received - // look for the newline character, this is the last character in the string - if (c == '\n') { - //print text with the name received - Console.print("Hi "); - Console.print(name); - Console.println("! Nice to meet you!"); - Console.println(); - // Ask again for name and clear the old name - Console.println("Hi, what's your name?"); - name = ""; // clear the name string - } else { // if the buffer is empty Cosole.read() returns -1 - name += c; // append the read char from Console to the name string - } - } else { - delay(100); - } -} diff --git a/doc/Bridge/examples/Datalogger/Datalogger.ino b/doc/Bridge/examples/Datalogger/Datalogger.ino @@ -1,102 +0,0 @@ -/* - SD card datalogger - - This example shows how to log data from three analog sensors - to an SD card mounted on the YunShield/Yún using the Bridge library. - - The circuit: - * analog sensors on analog pins 0, 1 and 2 - * SD card attached to SD card slot of the YunShield/Yún - - Prepare your SD card creating an empty folder in the SD root - named "arduino". This will ensure that the Yún will create a link - to the SD to the "/mnt/sd" path. - - You can remove the SD card while the Linux and the - sketch are running but be careful not to remove it while - the system is writing to it. - - created 24 Nov 2010 - modified 9 Apr 2012 - by Tom Igoe - adapted to the Yún Bridge library 20 Jun 2013 - by Federico Vanzati - modified 21 Jun 2013 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/YunDatalogger - - */ - -#include <FileIO.h> - -void setup() { - // Initialize the Bridge and the Serial - Bridge.begin(); - Serial.begin(9600); - FileSystem.begin(); - - while (!SerialUSB); // wait for Serial port to connect. - SerialUSB.println("Filesystem datalogger\n"); -} - - -void loop() { - // make a string that start with a timestamp for assembling the data to log: - String dataString; - dataString += getTimeStamp(); - dataString += " = "; - - // read three sensors and append to the string: - for (int analogPin = 0; analogPin < 3; analogPin++) { - int sensor = analogRead(analogPin); - dataString += String(sensor); - if (analogPin < 2) { - dataString += ","; // separate the values with a comma - } - } - - // open the file. note that only one file can be open at a time, - // so you have to close this one before opening another. - // The FileSystem card is mounted at the following "/mnt/FileSystema1" - File dataFile = FileSystem.open("/mnt/sd/datalog.txt", FILE_APPEND); - - // if the file is available, write to it: - if (dataFile) { - dataFile.println(dataString); - dataFile.close(); - // print to the serial port too: - SerialUSB.println(dataString); - } - // if the file isn't open, pop up an error: - else { - SerialUSB.println("error opening datalog.txt"); - } - - delay(15000); - -} - -// This function return a string with the time stamp -String getTimeStamp() { - String result; - Process time; - // date is a command line utility to get the date and the time - // in different formats depending on the additional parameter - time.begin("date"); - time.addParameter("+%D-%T"); // parameters: D for the complete date mm/dd/yy - // T for the time hh:mm:ss - time.run(); // run the command - - // read the output of the command - while (time.available() > 0) { - char c = time.read(); - if (c != '\n') { - result += c; - } - } - - return result; -} diff --git a/doc/Bridge/examples/FileWriteScript/FileWriteScript.ino b/doc/Bridge/examples/FileWriteScript/FileWriteScript.ino @@ -1,83 +0,0 @@ -/* - Write to file using FileIO classes. - - This sketch demonstrate how to write file into the YunShield/Yún filesystem. - A shell script file is created in /tmp, and it is executed afterwards. - - created 7 June 2010 - by Cristian Maglie - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/FileWriteScript - - */ - -#include <FileIO.h> - -void setup() { - // Setup Bridge (needed every time we communicate with the Arduino Yún) - Bridge.begin(); - // Initialize the Serial - SerialUSB.begin(9600); - - while (!SerialUSB); // wait for Serial port to connect. - SerialUSB.println("File Write Script example\n\n"); - - // Setup File IO - FileSystem.begin(); - - // Upload script used to gain network statistics - uploadScript(); -} - -void loop() { - // Run stats script every 5 secs. - runScript(); - delay(5000); -} - -// this function creates a file into the linux processor that contains a shell script -// to check the network traffic of the WiFi interface -void uploadScript() { - // Write our shell script in /tmp - // Using /tmp stores the script in RAM this way we can preserve - // the limited amount of FLASH erase/write cycles - File script = FileSystem.open("/tmp/wlan-stats.sh", FILE_WRITE); - // Shell script header - script.print("#!/bin/sh\n"); - // shell commands: - // ifconfig: is a command line utility for controlling the network interfaces. - // wlan0 is the interface we want to query - // grep: search inside the output of the ifconfig command the "RX bytes" keyword - // and extract the line that contains it - script.print("ifconfig wlan0 | grep 'RX bytes'\n"); - script.close(); // close the file - - // Make the script executable - Process chmod; - chmod.begin("chmod"); // chmod: change mode - chmod.addParameter("+x"); // x stays for executable - chmod.addParameter("/tmp/wlan-stats.sh"); // path to the file to make it executable - chmod.run(); -} - - -// this function run the script and read the output data -void runScript() { - // Run the script and show results on the Serial - Process myscript; - myscript.begin("/tmp/wlan-stats.sh"); - myscript.run(); - - String output = ""; - - // read the output of the script - while (myscript.available()) { - output += (char)myscript.read(); - } - // remove the blank spaces at the beginning and the ending of the string - output.trim(); - SerialUSB.println(output); - SerialUSB.flush(); -} diff --git a/doc/Bridge/examples/HttpClient/HttpClient.ino b/doc/Bridge/examples/HttpClient/HttpClient.ino @@ -1,51 +0,0 @@ -/* - Yún HTTP Client - - This example for the YunShield/Yún shows how create a basic - HTTP client that connects to the internet and downloads - content. In this case, you'll connect to the Arduino - website and download a version of the logo as ASCII text. - - created by Tom igoe - May 2013 - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/HttpClient - - */ - -#include <Bridge.h> -#include <HttpClient.h> - -void setup() { - // Bridge takes about two seconds to start up - // it can be helpful to use the on-board LED - // as an indicator for when it has initialized - pinMode(13, OUTPUT); - digitalWrite(13, LOW); - Bridge.begin(); - digitalWrite(13, HIGH); - - SerialUSB.begin(9600); - - while (!SerialUSB); // wait for a serial connection -} - -void loop() { - // Initialize the client library - HttpClient client; - - // Make a HTTP request: - client.get("http://www.arduino.cc/asciilogo.txt"); - - // if there are incoming bytes available - // from the server, read them and print them: - while (client.available()) { - char c = client.read(); - SerialUSB.print(c); - } - SerialUSB.flush(); - - delay(5000); -} diff --git a/doc/Bridge/examples/HttpClientConsole/HttpClientConsole.ino b/doc/Bridge/examples/HttpClientConsole/HttpClientConsole.ino @@ -1,53 +0,0 @@ -/* - Yún HTTP Client Console version for Arduino Uno and Mega using Yún Shield - - This example for the YunShield/Yún shows how create a basic - HTTP client that connects to the internet and downloads - content. In this case, you'll connect to the Arduino - website and download a version of the logo as ASCII text. - - created by Tom igoe - May 2013 - modified by Marco Brianza to use Console - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/HttpClient - - */ - -#include <Bridge.h> -#include <HttpClient.h> -#include <Console.h> - -void setup() { - // Bridge takes about two seconds to start up - // it can be helpful to use the on-board LED - // as an indicator for when it has initialized - pinMode(13, OUTPUT); - digitalWrite(13, LOW); - Bridge.begin(); - digitalWrite(13, HIGH); - - Console.begin(); - - while (!Console); // wait for a serial connection -} - -void loop() { - // Initialize the client library - HttpClient client; - - // Make a HTTP request: - client.get("http://www.arduino.cc/asciilogo.txt"); - - // if there are incoming bytes available - // from the server, read them and print them: - while (client.available()) { - char c = client.read(); - Console.print(c); - } - Console.flush(); - - delay(5000); -} diff --git a/doc/Bridge/examples/MailboxReadMessage/MailboxReadMessage.ino b/doc/Bridge/examples/MailboxReadMessage/MailboxReadMessage.ino @@ -1,58 +0,0 @@ -/* - Read Messages from the Mailbox - - This example for the YunShield/Yún shows how to - read the messages queue, called Mailbox, using the - Bridge library. - The messages can be sent to the queue through REST calls. - Appen the message in the URL after the keyword "/mailbox". - Example - - "/mailbox/hello" - - created 3 Feb 2014 - by Federico Vanzati & Federico Fissore - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/MailboxReadMessage - - */ - -#include <Mailbox.h> - -void setup() { - pinMode(13, OUTPUT); - digitalWrite(13, LOW); - // Initialize Bridge and Mailbox - Bridge.begin(); - Mailbox.begin(); - digitalWrite(13, HIGH); - - // Initialize Serial - SerialUSB.begin(9600); - - // Wait until a Serial Monitor is connected. - while (!SerialUSB); - - SerialUSB.println("Mailbox Read Message\n"); - SerialUSB.println("The Mailbox is checked every 10 seconds. The incoming messages will be shown below.\n"); -} - -void loop() { - String message; - - // if there is a message in the Mailbox - if (Mailbox.messageAvailable()) { - // read all the messages present in the queue - while (Mailbox.messageAvailable()) { - Mailbox.readMessage(message); - SerialUSB.println(message); - } - - SerialUSB.println("Waiting 10 seconds before checking the Mailbox again"); - } - - // wait 10 seconds - delay(10000); -} diff --git a/doc/Bridge/examples/Process/Process.ino b/doc/Bridge/examples/Process/Process.ino @@ -1,71 +0,0 @@ -/* - Running process using Process class. - - This sketch demonstrate how to run linux processes - using a YunShield/Yún - - created 5 Jun 2013 - by Cristian Maglie - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/Process - - */ - -#include <Process.h> - -void setup() { - // Initialize Bridge - Bridge.begin(); - - // Initialize Serial - SerialUSB.begin(9600); - - // Wait until a Serial Monitor is connected. - while (!SerialUSB); - - // run various example processes - runCurl(); - runCpuInfo(); -} - -void loop() { - // Do nothing here. -} - -void runCurl() { - // Launch "curl" command and get Arduino ascii art logo from the network - // curl is command line program for transferring data using different internet protocols - Process p; // Create a process and call it "p" - p.begin("curl"); // Process that launch the "curl" command - p.addParameter("http://www.arduino.cc/asciilogo.txt"); // Add the URL parameter to "curl" - p.run(); // Run the process and wait for its termination - - // Print arduino logo over the Serial - // A process output can be read with the stream methods - while (p.available() > 0) { - char c = p.read(); - SerialUSB.print(c); - } - // Ensure the last bit of data is sent. - SerialUSB.flush(); -} - -void runCpuInfo() { - // Launch "cat /proc/cpuinfo" command (shows info on Atheros CPU) - // cat is a command line utility that shows the content of a file - Process p; // Create a process and call it "p" - p.begin("cat"); // Process that launch the "cat" command - p.addParameter("/proc/cpuinfo"); // Add the cpuifo file path as parameter to cut - p.run(); // Run the process and wait for its termination - - // Print command output on the SerialUSB. - // A process output can be read with the stream methods - while (p.available() > 0) { - char c = p.read(); - SerialUSB.print(c); - } - // Ensure the last bit of data is sent. - SerialUSB.flush(); -} diff --git a/doc/Bridge/examples/RemoteDueBlink/RemoteDueBlink.ino b/doc/Bridge/examples/RemoteDueBlink/RemoteDueBlink.ino @@ -1,33 +0,0 @@ -/* - Blink - Turns on an LED on for one second, then off for one second, repeatedly. - - Most Arduinos have an on-board LED you can control. On the Uno and - Leonardo, it is attached to digital pin 13. If you're unsure what - pin the on-board LED is connected to on your Arduino model, check - the documentation at http://www.arduino.cc - - This example code is in the public domain. - - modified 8 May 2014 - by Scott Fitzgerald - - modified by Marco Brianza to show the remote sketch update feature on Arduino Due using Yún Shield - */ - -#include <Bridge.h> - -// the setup function runs once when you press reset or power the board -void setup() { - checkForRemoteSketchUpdate(); - // initialize digital pin 13 as an output. - pinMode(13, OUTPUT); -} - -// the loop function runs over and over again forever -void loop() { - digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) - delay(100); // wait for a second - digitalWrite(13, LOW); // turn the LED off by making the voltage LOW - delay(100); // wait for a second -} diff --git a/doc/Bridge/examples/ShellCommands/ShellCommands.ino b/doc/Bridge/examples/ShellCommands/ShellCommands.ino @@ -1,52 +0,0 @@ -/* - Running shell commands using Process class. - - This sketch demonstrate how to run linux shell commands - using a YunShield/Yún. It runs the wifiCheck script on the Linux side - of the Yún, then uses grep to get just the signal strength line. - Then it uses parseInt() to read the wifi signal strength as an integer, - and finally uses that number to fade an LED using analogWrite(). - - The circuit: - * YunShield/Yún with LED connected to pin 9 - - created 12 Jun 2013 - by Cristian Maglie - modified 25 June 2013 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/ShellCommands - - */ - -#include <Process.h> - -void setup() { - Bridge.begin(); // Initialize the Bridge - SerialUSB.begin(9600); // Initialize the Serial - - // Wait until a Serial Monitor is connected. - while (!SerialUSB); -} - -void loop() { - Process p; - // This command line runs the WifiStatus script, (/usr/bin/pretty-wifi-info.lua), then - // sends the result to the grep command to look for a line containing the word - // "Signal:" the result is passed to this sketch: - p.runShellCommand("/usr/bin/pretty-wifi-info.lua | grep Signal"); - - // do nothing until the process finishes, so you get the whole output: - while (p.running()); - - // Read command output. runShellCommand() should have passed "Signal: xx&": - while (p.available()) { - int result = p.parseInt(); // look for an integer - int signal = map(result, 0, 100, 0, 255); // map result from 0-100 range to 0-255 - analogWrite(9, signal); // set the brightness of LED on pin 9 - SerialUSB.println(result); // print the number as well - } - delay(5000); // wait 5 seconds before you do it again -} diff --git a/doc/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino b/doc/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino @@ -1,122 +0,0 @@ -/* - Temperature web interface - - This example shows how to serve data from an analog input - via the YunShield/Yún built-in webserver using the Bridge library. - - The circuit: - * TMP36 temperature sensor on analog pin A1 - * SD card attached to SD card slot of the YunShield/Yún - - This sketch must be uploaded via wifi. REST API must be set to "open". - - Prepare your SD card with an empty folder in the SD root - named "arduino" and a subfolder of that named "www". - This will ensure that the Yún will create a link - to the SD to the "/mnt/sd" path. - - In this sketch folder is a basic webpage and a copy of zepto.js, a - minimized version of jQuery. When you upload your sketch, these files - will be placed in the /arduino/www/TemperatureWebPanel folder on your SD card. - - You can then go to http://arduino.local/sd/TemperatureWebPanel - to see the output of this sketch. - - You can remove the SD card while the Linux and the - sketch are running but be careful not to remove it while - the system is writing to it. - - created 6 July 2013 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/TemperatureWebPanel - - */ - -#include <Bridge.h> -#include <BridgeServer.h> -#include <BridgeClient.h> - -// Listen on default port 5555, the webserver on the Yún -// will forward there all the HTTP requests for us. -BridgeServer server; -String startString; -long hits = 0; - -void setup() { - SerialUSB.begin(9600); - - // Bridge startup - pinMode(13, OUTPUT); - digitalWrite(13, LOW); - Bridge.begin(); - digitalWrite(13, HIGH); - - // using A0 and A2 as vcc and gnd for the TMP36 sensor: - pinMode(A0, OUTPUT); - pinMode(A2, OUTPUT); - digitalWrite(A0, HIGH); - digitalWrite(A2, LOW); - - // Listen for incoming connection only from localhost - // (no one from the external network could connect) - server.listenOnLocalhost(); - server.begin(); - - // get the time that this sketch started: - Process startTime; - startTime.runShellCommand("date"); - while (startTime.available()) { - char c = startTime.read(); - startString += c; - } -} - -void loop() { - // Get clients coming from server - BridgeClient client = server.accept(); - - // There is a new client? - if (client) { - // read the command - String command = client.readString(); - command.trim(); //kill whitespace - SerialUSB.println(command); - // is "temperature" command? - if (command == "temperature") { - - // get the time from the server: - Process time; - time.runShellCommand("date"); - String timeString = ""; - while (time.available()) { - char c = time.read(); - timeString += c; - } - SerialUSB.println(timeString); - int sensorValue = analogRead(A1); - // convert the reading to millivolts: - float voltage = sensorValue * (5000.0f / 1024.0f); - // convert the millivolts to temperature celsius: - float temperature = (voltage - 500.0f) / 10.0f; - // print the temperature: - client.print("Current time on the Y&uacute;n: "); - client.println(timeString); - client.print("<br>Current temperature: "); - client.print(temperature); - client.print(" &deg;C"); - client.print("<br>This sketch has been running since "); - client.print(startString); - client.print("<br>Hits so far: "); - client.print(hits); - } - - // Close connection and free resources. - client.stop(); - hits++; - } - - delay(50); // Poll every 50ms -} diff --git a/doc/Bridge/examples/TemperatureWebPanel/www/index.html b/doc/Bridge/examples/TemperatureWebPanel/www/index.html @@ -1,16 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <script type="text/javascript" src="zepto.min.js"></script> - <script type="text/javascript"> - function refresh() { - $('#content').load('/arduino/temperature'); - } -</script> - - </head> - <body onload="setInterval(refresh, 2000);"> - <span id="content">0</span> - </body> -</html> - diff --git a/doc/Bridge/examples/TemperatureWebPanel/www/zepto.min.js b/doc/Bridge/examples/TemperatureWebPanel/www/zepto.min.js @@ -1,2 +0,0 @@ -/* Zepto v1.0-1-ga3cab6c - polyfill zepto detect event ajax form fx - zeptojs.com/license */ -(function(a){String.prototype.trim===a&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),Array.prototype.reduce===a&&(Array.prototype.reduce=function(b){if(this===void 0||this===null)throw new TypeError;var c=Object(this),d=c.length>>>0,e=0,f;if(typeof b!="function")throw new TypeError;if(d==0&&arguments.length==1)throw new TypeError;if(arguments.length>=2)f=arguments[1];else do{if(e in c){f=c[e++];break}if(++e>=d)throw new TypeError}while(!0);while(e<d)e in c&&(f=b.call(a,f,c[e],e,c)),e++;return f})})();var Zepto=function(){function E(a){return a==null?String(a):y[z.call(a)]||"object"}function F(a){return E(a)=="function"}function G(a){return a!=null&&a==a.window}function H(a){return a!=null&&a.nodeType==a.DOCUMENT_NODE}function I(a){return E(a)=="object"}function J(a){return I(a)&&!G(a)&&a.__proto__==Object.prototype}function K(a){return a instanceof Array}function L(a){return typeof a.length=="number"}function M(a){return g.call(a,function(a){return a!=null})}function N(a){return a.length>0?c.fn.concat.apply([],a):a}function O(a){return a.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function P(a){return a in j?j[a]:j[a]=new RegExp("(^|\\s)"+a+"(\\s|$)")}function Q(a,b){return typeof b=="number"&&!l[O(a)]?b+"px":b}function R(a){var b,c;return i[a]||(b=h.createElement(a),h.body.appendChild(b),c=k(b,"").getPropertyValue("display"),b.parentNode.removeChild(b),c=="none"&&(c="block"),i[a]=c),i[a]}function S(a){return"children"in a?f.call(a.children):c.map(a.childNodes,function(a){if(a.nodeType==1)return a})}function T(c,d,e){for(b in d)e&&(J(d[b])||K(d[b]))?(J(d[b])&&!J(c[b])&&(c[b]={}),K(d[b])&&!K(c[b])&&(c[b]=[]),T(c[b],d[b],e)):d[b]!==a&&(c[b]=d[b])}function U(b,d){return d===a?c(b):c(b).filter(d)}function V(a,b,c,d){return F(b)?b.call(a,c,d):b}function W(a,b,c){c==null?a.removeAttribute(b):a.setAttribute(b,c)}function X(b,c){var d=b.className,e=d&&d.baseVal!==a;if(c===a)return e?d.baseVal:d;e?d.baseVal=c:b.className=c}function Y(a){var b;try{return a?a=="true"||(a=="false"?!1:a=="null"?null:isNaN(b=Number(a))?/^[\[\{]/.test(a)?c.parseJSON(a):a:b):a}catch(d){return a}}function Z(a,b){b(a);for(var c in a.childNodes)Z(a.childNodes[c],b)}var a,b,c,d,e=[],f=e.slice,g=e.filter,h=window.document,i={},j={},k=h.defaultView.getComputedStyle,l={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},m=/^\s*<(\w+|!)[^>]*>/,n=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,o=/^(?:body|html)$/i,p=["val","css","html","text","data","width","height","offset"],q=["after","prepend","before","append"],r=h.createElement("table"),s=h.createElement("tr"),t={tr:h.createElement("tbody"),tbody:r,thead:r,tfoot:r,td:s,th:s,"*":h.createElement("div")},u=/complete|loaded|interactive/,v=/^\.([\w-]+)$/,w=/^#([\w-]*)$/,x=/^[\w-]+$/,y={},z=y.toString,A={},B,C,D=h.createElement("div");return A.matches=function(a,b){if(!a||a.nodeType!==1)return!1;var c=a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.matchesSelector;if(c)return c.call(a,b);var d,e=a.parentNode,f=!e;return f&&(e=D).appendChild(a),d=~A.qsa(e,b).indexOf(a),f&&D.removeChild(a),d},B=function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})},C=function(a){return g.call(a,function(b,c){return a.indexOf(b)==c})},A.fragment=function(b,d,e){b.replace&&(b=b.replace(n,"<$1></$2>")),d===a&&(d=m.test(b)&&RegExp.$1),d in t||(d="*");var g,h,i=t[d];return i.innerHTML=""+b,h=c.each(f.call(i.childNodes),function(){i.removeChild(this)}),J(e)&&(g=c(h),c.each(e,function(a,b){p.indexOf(a)>-1?g[a](b):g.attr(a,b)})),h},A.Z=function(a,b){return a=a||[],a.__proto__=c.fn,a.selector=b||"",a},A.isZ=function(a){return a instanceof A.Z},A.init=function(b,d){if(!b)return A.Z();if(F(b))return c(h).ready(b);if(A.isZ(b))return b;var e;if(K(b))e=M(b);else if(I(b))e=[J(b)?c.extend({},b):b],b=null;else if(m.test(b))e=A.fragment(b.trim(),RegExp.$1,d),b=null;else{if(d!==a)return c(d).find(b);e=A.qsa(h,b)}return A.Z(e,b)},c=function(a,b){return A.init(a,b)},c.extend=function(a){var b,c=f.call(arguments,1);return typeof a=="boolean"&&(b=a,a=c.shift()),c.forEach(function(c){T(a,c,b)}),a},A.qsa=function(a,b){var c;return H(a)&&w.test(b)?(c=a.getElementById(RegExp.$1))?[c]:[]:a.nodeType!==1&&a.nodeType!==9?[]:f.call(v.test(b)?a.getElementsByClassName(RegExp.$1):x.test(b)?a.getElementsByTagName(b):a.querySelectorAll(b))},c.contains=function(a,b){return a!==b&&a.contains(b)},c.type=E,c.isFunction=F,c.isWindow=G,c.isArray=K,c.isPlainObject=J,c.isEmptyObject=function(a){var b;for(b in a)return!1;return!0},c.inArray=function(a,b,c){return e.indexOf.call(b,a,c)},c.camelCase=B,c.trim=function(a){return a.trim()},c.uuid=0,c.support={},c.expr={},c.map=function(a,b){var c,d=[],e,f;if(L(a))for(e=0;e<a.length;e++)c=b(a[e],e),c!=null&&d.push(c);else for(f in a)c=b(a[f],f),c!=null&&d.push(c);return N(d)},c.each=function(a,b){var c,d;if(L(a)){for(c=0;c<a.length;c++)if(b.call(a[c],c,a[c])===!1)return a}else for(d in a)if(b.call(a[d],d,a[d])===!1)return a;return a},c.grep=function(a,b){return g.call(a,b)},window.JSON&&(c.parseJSON=JSON.parse),c.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){y["[object "+b+"]"]=b.toLowerCase()}),c.fn={forEach:e.forEach,reduce:e.reduce,push:e.push,sort:e.sort,indexOf:e.indexOf,concat:e.concat,map:function(a){return c(c.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return c(f.apply(this,arguments))},ready:function(a){return u.test(h.readyState)?a(c):h.addEventListener("DOMContentLoaded",function(){a(c)},!1),this},get:function(b){return b===a?f.call(this):this[b>=0?b:b+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){this.parentNode!=null&&this.parentNode.removeChild(this)})},each:function(a){return e.every.call(this,function(b,c){return a.call(b,c,b)!==!1}),this},filter:function(a){return F(a)?this.not(this.not(a)):c(g.call(this,function(b){return A.matches(b,a)}))},add:function(a,b){return c(C(this.concat(c(a,b))))},is:function(a){return this.length>0&&A.matches(this[0],a)},not:function(b){var d=[];if(F(b)&&b.call!==a)this.each(function(a){b.call(this,a)||d.push(this)});else{var e=typeof b=="string"?this.filter(b):L(b)&&F(b.item)?f.call(b):c(b);this.forEach(function(a){e.indexOf(a)<0&&d.push(a)})}return c(d)},has:function(a){return this.filter(function(){return I(a)?c.contains(this,a):c(this).find(a).size()})},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){var a=this[0];return a&&!I(a)?a:c(a)},last:function(){var a=this[this.length-1];return a&&!I(a)?a:c(a)},find:function(a){var b,d=this;return typeof a=="object"?b=c(a).filter(function(){var a=this;return e.some.call(d,function(b){return c.contains(b,a)})}):this.length==1?b=c(A.qsa(this[0],a)):b=this.map(function(){return A.qsa(this,a)}),b},closest:function(a,b){var d=this[0],e=!1;typeof a=="object"&&(e=c(a));while(d&&!(e?e.indexOf(d)>=0:A.matches(d,a)))d=d!==b&&!H(d)&&d.parentNode;return c(d)},parents:function(a){var b=[],d=this;while(d.length>0)d=c.map(d,function(a){if((a=a.parentNode)&&!H(a)&&b.indexOf(a)<0)return b.push(a),a});return U(b,a)},parent:function(a){return U(C(this.pluck("parentNode")),a)},children:function(a){return U(this.map(function(){return S(this)}),a)},contents:function(){return this.map(function(){return f.call(this.childNodes)})},siblings:function(a){return U(this.map(function(a,b){return g.call(S(b.parentNode),function(a){return a!==b})}),a)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(a){return c.map(this,function(b){return b[a]})},show:function(){return this.each(function(){this.style.display=="none"&&(this.style.display=null),k(this,"").getPropertyValue("display")=="none"&&(this.style.display=R(this.nodeName))})},replaceWith:function(a){return this.before(a).remove()},wrap:function(a){var b=F(a);if(this[0]&&!b)var d=c(a).get(0),e=d.parentNode||this.length>1;return this.each(function(f){c(this).wrapAll(b?a.call(this,f):e?d.cloneNode(!0):d)})},wrapAll:function(a){if(this[0]){c(this[0]).before(a=c(a));var b;while((b=a.children()).length)a=b.first();c(a).append(this)}return this},wrapInner:function(a){var b=F(a);return this.each(function(d){var e=c(this),f=e.contents(),g=b?a.call(this,d):a;f.length?f.wrapAll(g):e.append(g)})},unwrap:function(){return this.parent().each(function(){c(this).replaceWith(c(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(b){return this.each(function(){var d=c(this);(b===a?d.css("display")=="none":b)?d.show():d.hide()})},prev:function(a){return c(this.pluck("previousElementSibling")).filter(a||"*")},next:function(a){return c(this.pluck("nextElementSibling")).filter(a||"*")},html:function(b){return b===a?this.length>0?this[0].innerHTML:null:this.each(function(a){var d=this.innerHTML;c(this).empty().append(V(this,b,a,d))})},text:function(b){return b===a?this.length>0?this[0].textContent:null:this.each(function(){this.textContent=b})},attr:function(c,d){var e;return typeof c=="string"&&d===a?this.length==0||this[0].nodeType!==1?a:c=="value"&&this[0].nodeName=="INPUT"?this.val():!(e=this[0].getAttribute(c))&&c in this[0]?this[0][c]:e:this.each(function(a){if(this.nodeType!==1)return;if(I(c))for(b in c)W(this,b,c[b]);else W(this,c,V(this,d,a,this.getAttribute(c)))})},removeAttr:function(a){return this.each(function(){this.nodeType===1&&W(this,a)})},prop:function(b,c){return c===a?this[0]&&this[0][b]:this.each(function(a){this[b]=V(this,c,a,this[b])})},data:function(b,c){var d=this.attr("data-"+O(b),c);return d!==null?Y(d):a},val:function(b){return b===a?this[0]&&(this[0].multiple?c(this[0]).find("option").filter(function(a){return this.selected}).pluck("value"):this[0].value):this.each(function(a){this.value=V(this,b,a,this.value)})},offset:function(a){if(a)return this.each(function(b){var d=c(this),e=V(this,a,b,d.offset()),f=d.offsetParent().offset(),g={top:e.top-f.top,left:e.left-f.left};d.css("position")=="static"&&(g.position="relative"),d.css(g)});if(this.length==0)return null;var b=this[0].getBoundingClientRect();return{left:b.left+window.pageXOffset,top:b.top+window.pageYOffset,width:Math.round(b.width),height:Math.round(b.height)}},css:function(a,c){if(arguments.length<2&&typeof a=="string")return this[0]&&(this[0].style[B(a)]||k(this[0],"").getPropertyValue(a));var d="";if(E(a)=="string")!c&&c!==0?this.each(function(){this.style.removeProperty(O(a))}):d=O(a)+":"+Q(a,c);else for(b in a)!a[b]&&a[b]!==0?this.each(function(){this.style.removeProperty(O(b))}):d+=O(b)+":"+Q(b,a[b])+";";return this.each(function(){this.style.cssText+=";"+d})},index:function(a){return a?this.indexOf(c(a)[0]):this.parent().children().indexOf(this[0])},hasClass:function(a){return e.some.call(this,function(a){return this.test(X(a))},P(a))},addClass:function(a){return this.each(function(b){d=[];var e=X(this),f=V(this,a,b,e);f.split(/\s+/g).forEach(function(a){c(this).hasClass(a)||d.push(a)},this),d.length&&X(this,e+(e?" ":"")+d.join(" "))})},removeClass:function(b){return this.each(function(c){if(b===a)return X(this,"");d=X(this),V(this,b,c,d).split(/\s+/g).forEach(function(a){d=d.replace(P(a)," ")}),X(this,d.trim())})},toggleClass:function(b,d){return this.each(function(e){var f=c(this),g=V(this,b,e,X(this));g.split(/\s+/g).forEach(function(b){(d===a?!f.hasClass(b):d)?f.addClass(b):f.removeClass(b)})})},scrollTop:function(){if(!this.length)return;return"scrollTop"in this[0]?this[0].scrollTop:this[0].scrollY},position:function(){if(!this.length)return;var a=this[0],b=this.offsetParent(),d=this.offset(),e=o.test(b[0].nodeName)?{top:0,left:0}:b.offset();return d.top-=parseFloat(c(a).css("margin-top"))||0,d.left-=parseFloat(c(a).css("margin-left"))||0,e.top+=parseFloat(c(b[0]).css("border-top-width"))||0,e.left+=parseFloat(c(b[0]).css("border-left-width"))||0,{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||h.body;while(a&&!o.test(a.nodeName)&&c(a).css("position")=="static")a=a.offsetParent;return a})}},c.fn.detach=c.fn.remove,["width","height"].forEach(function(b){c.fn[b]=function(d){var e,f=this[0],g=b.replace(/./,function(a){return a[0].toUpperCase()});return d===a?G(f)?f["inner"+g]:H(f)?f.documentElement["offset"+g]:(e=this.offset())&&e[b]:this.each(function(a){f=c(this),f.css(b,V(this,d,a,f[b]()))})}}),q.forEach(function(a,b){var d=b%2;c.fn[a]=function(){var a,e=c.map(arguments,function(b){return a=E(b),a=="object"||a=="array"||b==null?b:A.fragment(b)}),f,g=this.length>1;return e.length<1?this:this.each(function(a,h){f=d?h:h.parentNode,h=b==0?h.nextSibling:b==1?h.firstChild:b==2?h:null,e.forEach(function(a){if(g)a=a.cloneNode(!0);else if(!f)return c(a).remove();Z(f.insertBefore(a,h),function(a){a.nodeName!=null&&a.nodeName.toUpperCase()==="SCRIPT"&&(!a.type||a.type==="text/javascript")&&!a.src&&window.eval.call(window,a.innerHTML)})})})},c.fn[d?a+"To":"insert"+(b?"Before":"After")]=function(b){return c(b)[a](this),this}}),A.Z.prototype=c.fn,A.uniq=C,A.deserializeValue=Y,c.zepto=A,c}();window.Zepto=Zepto,"$"in window||(window.$=Zepto),function(a){function b(a){var b=this.os={},c=this.browser={},d=a.match(/WebKit\/([\d.]+)/),e=a.match(/(Android)\s+([\d.]+)/),f=a.match(/(iPad).*OS\s([\d_]+)/),g=!f&&a.match(/(iPhone\sOS)\s([\d_]+)/),h=a.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),i=h&&a.match(/TouchPad/),j=a.match(/Kindle\/([\d.]+)/),k=a.match(/Silk\/([\d._]+)/),l=a.match(/(BlackBerry).*Version\/([\d.]+)/),m=a.match(/(BB10).*Version\/([\d.]+)/),n=a.match(/(RIM\sTablet\sOS)\s([\d.]+)/),o=a.match(/PlayBook/),p=a.match(/Chrome\/([\d.]+)/)||a.match(/CriOS\/([\d.]+)/),q=a.match(/Firefox\/([\d.]+)/);if(c.webkit=!!d)c.version=d[1];e&&(b.android=!0,b.version=e[2]),g&&(b.ios=b.iphone=!0,b.version=g[2].replace(/_/g,".")),f&&(b.ios=b.ipad=!0,b.version=f[2].replace(/_/g,".")),h&&(b.webos=!0,b.version=h[2]),i&&(b.touchpad=!0),l&&(b.blackberry=!0,b.version=l[2]),m&&(b.bb10=!0,b.version=m[2]),n&&(b.rimtabletos=!0,b.version=n[2]),o&&(c.playbook=!0),j&&(b.kindle=!0,b.version=j[1]),k&&(c.silk=!0,c.version=k[1]),!k&&b.android&&a.match(/Kindle Fire/)&&(c.silk=!0),p&&(c.chrome=!0,c.version=p[1]),q&&(c.firefox=!0,c.version=q[1]),b.tablet=!!(f||o||e&&!a.match(/Mobile/)||q&&a.match(/Tablet/)),b.phone=!b.tablet&&!!(e||g||h||l||m||p&&a.match(/Android/)||p&&a.match(/CriOS\/([\d.]+)/)||q&&a.match(/Mobile/))}b.call(a,navigator.userAgent),a.__detect=b}(Zepto),function(a){function g(a){return a._zid||(a._zid=d++)}function h(a,b,d,e){b=i(b);if(b.ns)var f=j(b.ns);return(c[g(a)]||[]).filter(function(a){return a&&(!b.e||a.e==b.e)&&(!b.ns||f.test(a.ns))&&(!d||g(a.fn)===g(d))&&(!e||a.sel==e)})}function i(a){var b=(""+a).split(".");return{e:b[0],ns:b.slice(1).sort().join(" ")}}function j(a){return new RegExp("(?:^| )"+a.replace(" "," .* ?")+"(?: |$)")}function k(b,c,d){a.type(b)!="string"?a.each(b,d):b.split(/\s/).forEach(function(a){d(a,c)})}function l(a,b){return a.del&&(a.e=="focus"||a.e=="blur")||!!b}function m(a){return f[a]||a}function n(b,d,e,h,j,n){var o=g(b),p=c[o]||(c[o]=[]);k(d,e,function(c,d){var e=i(c);e.fn=d,e.sel=h,e.e in f&&(d=function(b){var c=b.relatedTarget;if(!c||c!==this&&!a.contains(this,c))return e.fn.apply(this,arguments)}),e.del=j&&j(d,c);var g=e.del||d;e.proxy=function(a){var c=g.apply(b,[a].concat(a.data));return c===!1&&(a.preventDefault(),a.stopPropagation()),c},e.i=p.length,p.push(e),b.addEventListener(m(e.e),e.proxy,l(e,n))})}function o(a,b,d,e,f){var i=g(a);k(b||"",d,function(b,d){h(a,b,d,e).forEach(function(b){delete c[i][b.i],a.removeEventListener(m(b.e),b.proxy,l(b,f))})})}function t(b){var c,d={originalEvent:b};for(c in b)!r.test(c)&&b[c]!==undefined&&(d[c]=b[c]);return a.each(s,function(a,c){d[a]=function(){return this[c]=p,b[a].apply(b,arguments)},d[c]=q}),d}function u(a){if(!("defaultPrevented"in a)){a.defaultPrevented=!1;var b=a.preventDefault;a.preventDefault=function(){this.defaultPrevented=!0,b.call(this)}}}var b=a.zepto.qsa,c={},d=1,e={},f={mouseenter:"mouseover",mouseleave:"mouseout"};e.click=e.mousedown=e.mouseup=e.mousemove="MouseEvents",a.event={add:n,remove:o},a.proxy=function(b,c){if(a.isFunction(b)){var d=function(){return b.apply(c,arguments)};return d._zid=g(b),d}if(typeof c=="string")return a.proxy(b[c],b);throw new TypeError("expected function")},a.fn.bind=function(a,b){return this.each(function(){n(this,a,b)})},a.fn.unbind=function(a,b){return this.each(function(){o(this,a,b)})},a.fn.one=function(a,b){return this.each(function(c,d){n(this,a,b,null,function(a,b){return function(){var c=a.apply(d,arguments);return o(d,b,a),c}})})};var p=function(){return!0},q=function(){return!1},r=/^([A-Z]|layer[XY]$)/,s={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};a.fn.delegate=function(b,c,d){return this.each(function(e,f){n(f,c,d,b,function(c){return function(d){var e,g=a(d.target).closest(b,f).get(0);if(g)return e=a.extend(t(d),{currentTarget:g,liveFired:f}),c.apply(g,[e].concat([].slice.call(arguments,1)))}})})},a.fn.undelegate=function(a,b,c){return this.each(function(){o(this,b,c,a)})},a.fn.live=function(b,c){return a(document.body).delegate(this.selector,b,c),this},a.fn.die=function(b,c){return a(document.body).undelegate(this.selector,b,c),this},a.fn.on=function(b,c,d){return!c||a.isFunction(c)?this.bind(b,c||d):this.delegate(c,b,d)},a.fn.off=function(b,c,d){return!c||a.isFunction(c)?this.unbind(b,c||d):this.undelegate(c,b,d)},a.fn.trigger=function(b,c){if(typeof b=="string"||a.isPlainObject(b))b=a.Event(b);return u(b),b.data=c,this.each(function(){"dispatchEvent"in this&&this.dispatchEvent(b)})},a.fn.triggerHandler=function(b,c){var d,e;return this.each(function(f,g){d=t(typeof b=="string"?a.Event(b):b),d.data=c,d.target=g,a.each(h(g,b.type||b),function(a,b){e=b.proxy(d);if(d.isImmediatePropagationStopped())return!1})}),e},"focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(b){a.fn[b]=function(a){return a?this.bind(b,a):this.trigger(b)}}),["focus","blur"].forEach(function(b){a.fn[b]=function(a){return a?this.bind(b,a):this.each(function(){try{this[b]()}catch(a){}}),this}}),a.Event=function(a,b){typeof a!="string"&&(b=a,a=b.type);var c=document.createEvent(e[a]||"Events"),d=!0;if(b)for(var f in b)f=="bubbles"?d=!!b[f]:c[f]=b[f];return c.initEvent(a,d,!0,null,null,null,null,null,null,null,null,null,null,null,null),c.isDefaultPrevented=function(){return this.defaultPrevented},c}}(Zepto),function($){function triggerAndReturn(a,b,c){var d=$.Event(b);return $(a).trigger(d,c),!d.defaultPrevented}function triggerGlobal(a,b,c,d){if(a.global)return triggerAndReturn(b||document,c,d)}function ajaxStart(a){a.global&&$.active++===0&&triggerGlobal(a,null,"ajaxStart")}function ajaxStop(a){a.global&&!--$.active&&triggerGlobal(a,null,"ajaxStop")}function ajaxBeforeSend(a,b){var c=b.context;if(b.beforeSend.call(c,a,b)===!1||triggerGlobal(b,c,"ajaxBeforeSend",[a,b])===!1)return!1;triggerGlobal(b,c,"ajaxSend",[a,b])}function ajaxSuccess(a,b,c){var d=c.context,e="success";c.success.call(d,a,e,b),triggerGlobal(c,d,"ajaxSuccess",[b,c,a]),ajaxComplete(e,b,c)}function ajaxError(a,b,c,d){var e=d.context;d.error.call(e,c,b,a),triggerGlobal(d,e,"ajaxError",[c,d,a]),ajaxComplete(b,c,d)}function ajaxComplete(a,b,c){var d=c.context;c.complete.call(d,b,a),triggerGlobal(c,d,"ajaxComplete",[b,c]),ajaxStop(c)}function empty(){}function mimeToDataType(a){return a&&(a=a.split(";",2)[0]),a&&(a==htmlType?"html":a==jsonType?"json":scriptTypeRE.test(a)?"script":xmlTypeRE.test(a)&&"xml")||"text"}function appendQuery(a,b){return(a+"&"+b).replace(/[&?]{1,2}/,"?")}function serializeData(a){a.processData&&a.data&&$.type(a.data)!="string"&&(a.data=$.param(a.data,a.traditional)),a.data&&(!a.type||a.type.toUpperCase()=="GET")&&(a.url=appendQuery(a.url,a.data))}function parseArguments(a,b,c,d){var e=!$.isFunction(b);return{url:a,data:e?b:undefined,success:e?$.isFunction(c)?c:undefined:b,dataType:e?d||c:c}}function serialize(a,b,c,d){var e,f=$.isArray(b);$.each(b,function(b,g){e=$.type(g),d&&(b=c?d:d+"["+(f?"":b)+"]"),!d&&f?a.add(g.name,g.value):e=="array"||!c&&e=="object"?serialize(a,g,c,b):a.add(b,g)})}var jsonpID=0,document=window.document,key,name,rscript=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,scriptTypeRE=/^(?:text|application)\/javascript/i,xmlTypeRE=/^(?:text|application)\/xml/i,jsonType="application/json",htmlType="text/html",blankRE=/^\s*$/;$.active=0,$.ajaxJSONP=function(a){if("type"in a){var b="jsonp"+ ++jsonpID,c=document.createElement("script"),d=function(){clearTimeout(g),$(c).remove(),delete window[b]},e=function(c){d();if(!c||c=="timeout")window[b]=empty;ajaxError(null,c||"abort",f,a)},f={abort:e},g;return ajaxBeforeSend(f,a)===!1?(e("abort"),!1):(window[b]=function(b){d(),ajaxSuccess(b,f,a)},c.onerror=function(){e("error")},c.src=a.url.replace(/=\?/,"="+b),$("head").append(c),a.timeout>0&&(g=setTimeout(function(){e("timeout")},a.timeout)),f)}return $.ajax(a)},$.ajaxSettings={type:"GET",beforeSend:empty,success:empty,error:empty,complete:empty,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript",json:jsonType,xml:"application/xml, text/xml",html:htmlType,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0},$.ajax=function(options){var settings=$.extend({},options||{});for(key in $.ajaxSettings)settings[key]===undefined&&(settings[key]=$.ajaxSettings[key]);ajaxStart(settings),settings.crossDomain||(settings.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(settings.url)&&RegExp.$2!=window.location.host),settings.url||(settings.url=window.location.toString()),serializeData(settings),settings.cache===!1&&(settings.url=appendQuery(settings.url,"_="+Date.now()));var dataType=settings.dataType,hasPlaceholder=/=\?/.test(settings.url);if(dataType=="jsonp"||hasPlaceholder)return hasPlaceholder||(settings.url=appendQuery(settings.url,"callback=?")),$.ajaxJSONP(settings);var mime=settings.accepts[dataType],baseHeaders={},protocol=/^([\w-]+:)\/\//.test(settings.url)?RegExp.$1:window.location.protocol,xhr=settings.xhr(),abortTimeout;settings.crossDomain||(baseHeaders["X-Requested-With"]="XMLHttpRequest"),mime&&(baseHeaders.Accept=mime,mime.indexOf(",")>-1&&(mime=mime.split(",",2)[0]),xhr.overrideMimeType&&xhr.overrideMimeType(mime));if(settings.contentType||settings.contentType!==!1&&settings.data&&settings.type.toUpperCase()!="GET")baseHeaders["Content-Type"]=settings.contentType||"application/x-www-form-urlencoded";settings.headers=$.extend(baseHeaders,settings.headers||{}),xhr.onreadystatechange=function(){if(xhr.readyState==4){xhr.onreadystatechange=empty,clearTimeout(abortTimeout);var result,error=!1;if(xhr.status>=200&&xhr.status<300||xhr.status==304||xhr.status==0&&protocol=="file:"){dataType=dataType||mimeToDataType(xhr.getResponseHeader("content-type")),result=xhr.responseText;try{dataType=="script"?(1,eval)(result):dataType=="xml"?result=xhr.responseXML:dataType=="json"&&(result=blankRE.test(result)?null:$.parseJSON(result))}catch(e){error=e}error?ajaxError(error,"parsererror",xhr,settings):ajaxSuccess(result,xhr,settings)}else ajaxError(null,xhr.status?"error":"abort",xhr,settings)}};var async="async"in settings?settings.async:!0;xhr.open(settings.type,settings.url,async);for(name in settings.headers)xhr.setRequestHeader(name,settings.headers[name]);return ajaxBeforeSend(xhr,settings)===!1?(xhr.abort(),!1):(settings.timeout>0&&(abortTimeout=setTimeout(function(){xhr.onreadystatechange=empty,xhr.abort(),ajaxError(null,"timeout",xhr,settings)},settings.timeout)),xhr.send(settings.data?settings.data:null),xhr)},$.get=function(a,b,c,d){return $.ajax(parseArguments.apply(null,arguments))},$.post=function(a,b,c,d){var e=parseArguments.apply(null,arguments);return e.type="POST",$.ajax(e)},$.getJSON=function(a,b,c){var d=parseArguments.apply(null,arguments);return d.dataType="json",$.ajax(d)},$.fn.load=function(a,b,c){if(!this.length)return this;var d=this,e=a.split(/\s/),f,g=parseArguments(a,b,c),h=g.success;return e.length>1&&(g.url=e[0],f=e[1]),g.success=function(a){d.html(f?$("<div>").html(a.replace(rscript,"")).find(f):a),h&&h.apply(d,arguments)},$.ajax(g),this};var escape=encodeURIComponent;$.param=function(a,b){var c=[];return c.add=function(a,b){this.push(escape(a)+"="+escape(b))},serialize(c,a,b),c.join("&").replace(/%20/g,"+")}}(Zepto),function(a){a.fn.serializeArray=function(){var b=[],c;return a(Array.prototype.slice.call(this.get(0).elements)).each(function(){c=a(this);var d=c.attr("type");this.nodeName.toLowerCase()!="fieldset"&&!this.disabled&&d!="submit"&&d!="reset"&&d!="button"&&(d!="radio"&&d!="checkbox"||this.checked)&&b.push({name:c.attr("name"),value:c.val()})}),b},a.fn.serialize=function(){var a=[];return this.serializeArray().forEach(function(b){a.push(encodeURIComponent(b.name)+"="+encodeURIComponent(b.value))}),a.join("&")},a.fn.submit=function(b){if(b)this.bind("submit",b);else if(this.length){var c=a.Event("submit");this.eq(0).trigger(c),c.defaultPrevented||this.get(0).submit()}return this}}(Zepto),function(a,b){function s(a){return t(a.replace(/([a-z])([A-Z])/,"$1-$2"))}function t(a){return a.toLowerCase()}function u(a){return d?d+a:t(a)}var c="",d,e,f,g={Webkit:"webkit",Moz:"",O:"o",ms:"MS"},h=window.document,i=h.createElement("div"),j=/^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,k,l,m,n,o,p,q,r={};a.each(g,function(a,e){if(i.style[a+"TransitionProperty"]!==b)return c="-"+t(a)+"-",d=e,!1}),k=c+"transform",r[l=c+"transition-property"]=r[m=c+"transition-duration"]=r[n=c+"transition-timing-function"]=r[o=c+"animation-name"]=r[p=c+"animation-duration"]=r[q=c+"animation-timing-function"]="",a.fx={off:d===b&&i.style.transitionProperty===b,speeds:{_default:400,fast:200,slow:600},cssPrefix:c,transitionEnd:u("TransitionEnd"),animationEnd:u("AnimationEnd")},a.fn.animate=function(b,c,d,e){return a.isPlainObject(c)&&(d=c.easing,e=c.complete,c=c.duration),c&&(c=(typeof c=="number"?c:a.fx.speeds[c]||a.fx.speeds._default)/1e3),this.anim(b,c,d,e)},a.fn.anim=function(c,d,e,f){var g,h={},i,t="",u=this,v,w=a.fx.transitionEnd;d===b&&(d=.4),a.fx.off&&(d=0);if(typeof c=="string")h[o]=c,h[p]=d+"s",h[q]=e||"linear",w=a.fx.animationEnd;else{i=[];for(g in c)j.test(g)?t+=g+"("+c[g]+") ":(h[g]=c[g],i.push(s(g)));t&&(h[k]=t,i.push(k)),d>0&&typeof c=="object"&&(h[l]=i.join(", "),h[m]=d+"s",h[n]=e||"linear")}return v=function(b){if(typeof b!="undefined"){if(b.target!==b.currentTarget)return;a(b.target).unbind(w,v)}a(this).css(r),f&&f.call(this)},d>0&&this.bind(w,v),this.size()&&this.get(0).clientLeft,this.css(h),d<=0&&setTimeout(function(){u.each(function(){v.call(this)})},0),this},i=null}(Zepto) diff --git a/doc/Bridge/examples/TimeCheck/TimeCheck.ino b/doc/Bridge/examples/TimeCheck/TimeCheck.ino @@ -1,88 +0,0 @@ -/* - Time Check - - Gets the time from Linux via Bridge then parses out hours, - minutes and seconds using a YunShield/Yún. - - created 27 May 2013 - modified 21 June 2013 - By Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/TimeCheck - - */ - - -#include <Process.h> - -Process date; // process used to get the date -int hours, minutes, seconds; // for the results -int lastSecond = -1; // need an impossible value for comparison - -void setup() { - Bridge.begin(); // initialize Bridge - SerialUSB.begin(9600); // initialize serial - - while (!Serial); // wait for Serial Monitor to open - SerialUSB.println("Time Check"); // Title of sketch - - // run an initial date process. Should return: - // hh:mm:ss : - if (!date.running()) { - date.begin("date"); - date.addParameter("+%T"); - date.run(); - } -} - -void loop() { - - if (lastSecond != seconds) { // if a second has passed - // print the time: - if (hours <= 9) { - SerialUSB.print("0"); // adjust for 0-9 - } - SerialUSB.print(hours); - SerialUSB.print(":"); - if (minutes <= 9) { - SerialUSB.print("0"); // adjust for 0-9 - } - SerialUSB.print(minutes); - SerialUSB.print(":"); - if (seconds <= 9) { - SerialUSB.print("0"); // adjust for 0-9 - } - SerialUSB.println(seconds); - - // restart the date process: - if (!date.running()) { - date.begin("date"); - date.addParameter("+%T"); - date.run(); - } - } - - //if there's a result from the date process, parse it: - while (date.available() > 0) { - // get the result of the date process (should be hh:mm:ss): - String timeString = date.readString(); - - // find the colons: - int firstColon = timeString.indexOf(":"); - int secondColon = timeString.lastIndexOf(":"); - - // get the substrings for hour, minute second: - String hourString = timeString.substring(0, firstColon); - String minString = timeString.substring(firstColon + 1, secondColon); - String secString = timeString.substring(secondColon + 1); - - // convert to ints,saving the previous second: - hours = hourString.toInt(); - minutes = minString.toInt(); - lastSecond = seconds; // save to do a time comparison - seconds = secString.toInt(); - } - -} diff --git a/doc/Bridge/examples/WiFiStatus/WiFiStatus.ino b/doc/Bridge/examples/WiFiStatus/WiFiStatus.ino @@ -1,51 +0,0 @@ -/* - WiFi Status - - This sketch runs a script called "pretty-wifi-info.lua" - installed on your Yún in folder /usr/bin. - It prints information about the status of your wifi connection. - - It uses Serial to print, so you need to connect your YunShield/Yún to your - computer using a USB cable and select the appropriate port from - the Port menu - - created 18 June 2013 - By Federico Fissore - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/YunWiFiStatus - - */ - -#include <Process.h> - -void setup() { - SerialUSB.begin(9600); // initialize serial communication - while (!SerialUSB); // do nothing until the serial monitor is opened - - SerialUSB.println("Starting bridge...\n"); - pinMode(13, OUTPUT); - digitalWrite(13, LOW); - Bridge.begin(); // make contact with the linux processor - digitalWrite(13, HIGH); // Led on pin 13 turns on when the bridge is ready - - delay(2000); // wait 2 seconds -} - -void loop() { - Process wifiCheck; // initialize a new process - - wifiCheck.runShellCommand("/usr/bin/pretty-wifi-info.lua"); // command you want to run - - // while there's any characters coming back from the - // process, print them to the serial monitor: - while (wifiCheck.available() > 0) { - char c = wifiCheck.read(); - SerialUSB.print(c); - } - - SerialUSB.println(); - - delay(5000); -} diff --git a/doc/Bridge/examples/YunFirstConfig/YunFirstConfig.ino b/doc/Bridge/examples/YunFirstConfig/YunFirstConfig.ino @@ -1,328 +0,0 @@ - -/* - Arduino Yún First configuration sketch - - Configures the YunShield/Yún WiFi and infos via the Bridge - Works correctly if Line Ending is set as "NewLine" - If your board has two USB ports, use the Native one - - The circuit: - Arduino YunShield - (or any Yun model with firmware > 1.6.1) - - created March 2016 - by Arduino LLC - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/YunFirstConfig -*/ - -#include <Process.h> - -#define MAX_WIFI_LIST 10 - -String networks[MAX_WIFI_LIST]; -String yunName; -String yunPassword; - -void setup() { - SERIAL_PORT_USBVIRTUAL.begin(9600); // initialize serial communication - while (!SERIAL_PORT_USBVIRTUAL); // do nothing until the serial monitor is opened - - SERIAL_PORT_USBVIRTUAL.println(F("Hi! Nice to see you!")); - SERIAL_PORT_USBVIRTUAL.println(F("I'm your YunShield assistant sketch")); - SERIAL_PORT_USBVIRTUAL.println(F("I'll help you configuring your Yun in a matter of minutes")); - - SERIAL_PORT_USBVIRTUAL.println(F("Let's start by communicating with the Linux processor")); - SERIAL_PORT_USBVIRTUAL.println(F("When LED (L13) will light up we'll be ready to go!")); - SERIAL_PORT_USBVIRTUAL.println(F("Waiting...")); - SERIAL_PORT_USBVIRTUAL.println(F("(in the meanwhile, if you are using the IDE's serial monitor, make sure that it's configured to send a \"Newline\")\n")); - pinMode(13, OUTPUT); - digitalWrite(13, LOW); - Bridge.begin(); // make contact with the linux processor - digitalWrite(13, HIGH); // Led on pin 13 turns on when the bridge is ready - - // Recover if the board is in AP mode - unused - Process wifiList; - bool master = false; - wifiList.runShellCommand(F("iwinfo | grep \"Mode: Master\"")); - while (wifiList.available() > 0) { - wifiList.read(); - master = true; - } - - // Get the list of reachable networks - wifiList.runShellCommand(F("iwinfo wlan0 scan | grep ESSID | cut -d\"\\\"\" -f2")); - - uint8_t num_networks = 0; - uint8_t i = 0; - char c; - bool dropNet = false; - - networks[0].reserve(32); - - while (wifiList.available() > 0) { - c = wifiList.read(); - if (c != '\n') { - networks[i] += c; - } else { - // check if we already found networks[i] and eventually drop it - for (uint8_t s = 0; s < i; s++) { - if (networks[i].equals(networks[s])) { - dropNet = true; - } - } - if (i <= MAX_WIFI_LIST && dropNet == false) { - networks[i++].reserve(32); - } else { - dropNet = false; - networks[i]=""; - } - } - } - - num_networks = i; - - String encryption; - String password; - int chose = 0; - - // If networks number is 0, start manual configuration - if (num_networks == 0) { - SERIAL_PORT_USBVIRTUAL.println(F("Oops, it seems that you have no WiFi network available")); - SERIAL_PORT_USBVIRTUAL.println(F("Let's configure it manually")); - SERIAL_PORT_USBVIRTUAL.println(F("SSID of the network you want to connect to: ")); - networks[0] = getUserInput(networks[0], false); - SERIAL_PORT_USBVIRTUAL.println(F("Password for the network you want to connect to: ")); - password = getUserInput(password, true); - SERIAL_PORT_USBVIRTUAL.print(F("Encryption (eg WPA, WPA2, WEP): ")); - encryption = getUserInput(encryption, false); - } else { - // else print them prepending a number - SERIAL_PORT_USBVIRTUAL.print(F("It looks like you have ")); - SERIAL_PORT_USBVIRTUAL.print(num_networks); - SERIAL_PORT_USBVIRTUAL.println(F(" networks around you ")); - SERIAL_PORT_USBVIRTUAL.println(F("Which one do you want to connect to?\n")); - for (i = 0; i < num_networks && i < MAX_WIFI_LIST; i++) { - SERIAL_PORT_USBVIRTUAL.print(i); - SERIAL_PORT_USBVIRTUAL.println(") " + networks[i]); - } - String selection; - selection = getUserInput(selection, false); - chose = atoi(selection.c_str()); - } - - // Extract the selected network security - bool openNet = false; - wifiList.runShellCommand("iwinfo wlan0 scan | grep \"" + networks[chose] + "\" -A5 | grep Encryption | cut -f2 -d\":\""); - while (wifiList.available() > 0) { - c = wifiList.read(); - encryption += c; - } - - if (encryption.indexOf("none") >= 0) { - openNet = true; - encryption = "none"; - } - if (encryption.indexOf("WPA2") >= 0) { - encryption = "psk2"; - } - if (encryption.indexOf("WPA") >= 0) { - encryption = "psk"; - } - if (encryption.indexOf("WEP") >= 0) { - encryption = "wep"; - } - - if (openNet == false && password.length() == 0) { - SERIAL_PORT_USBVIRTUAL.print(F("It looks like you need a password to connect to ")); - SERIAL_PORT_USBVIRTUAL.println(networks[chose]); - SERIAL_PORT_USBVIRTUAL.print(F("Write it here: ")); - password = getUserInput(password, true); - } - - // Change hostname/root password - SERIAL_PORT_USBVIRTUAL.println(F("We are almost done! Give a name and a password to your Yun")); - SERIAL_PORT_USBVIRTUAL.print(F("Name: ")); - yunName = getUserInput(yunName, false); - SERIAL_PORT_USBVIRTUAL.print(F("Password: ")); - yunPassword = getUserInput(yunPassword, true); - - // Select a country code - String countryCode; - SERIAL_PORT_USBVIRTUAL.println(F("One last question: where do you live?")); - SERIAL_PORT_USBVIRTUAL.print(F("Insert a two letters county code (eg IT, US, DE): ")); - countryCode = getUserInput(countryCode, false); - - yunName.trim(); - yunPassword.trim(); - networks[chose].trim(); - password.trim(); - countryCode.trim(); - - // Configure the Yun with user provided strings - wifiConfig(yunName, yunPassword, networks[chose], password, "YUN" + yunName + "AP", countryCode, encryption); - - SERIAL_PORT_USBVIRTUAL.print(F("Waiting for the Yun to connect to the network")); -} - -bool Connected = false; -bool serialTerminalMode = false; -int runs = 0; - -void loop() { - if (!serialTerminalMode) { - String resultStr = ""; - - if (!Connected) { - SERIAL_PORT_USBVIRTUAL.print("."); - runs++; - } - - // If it takes more than 20 seconds to connect, stop trying - if (runs > 20) { - SERIAL_PORT_USBVIRTUAL.println(""); - SERIAL_PORT_USBVIRTUAL.println(F("We couldn't connect to the network.")); - SERIAL_PORT_USBVIRTUAL.println(F("Restart the board if you want to execute the wizard again")); - resultStr = getUserInput(resultStr, false); - } - - // Check if we have an IP address - Process wifiCheck; - wifiCheck.runShellCommand(F("/usr/bin/pretty-wifi-info.lua | grep \"IP address\" | cut -f2 -d\":\" | cut -f1 -d\"/\"" )); // command you want to run - while (wifiCheck.available() > 0) { - char c = wifiCheck.read(); - resultStr += c; - } - - delay(1000); - - if (resultStr != "") { - // We got an IP, freeze the loop, display the value and "spawn" a serial terminal - Connected = true; - resultStr.trim(); - SERIAL_PORT_USBVIRTUAL.println(""); - SERIAL_PORT_USBVIRTUAL.print(F("\nGreat! You can now reach your Yun from a browser typing http://")); - SERIAL_PORT_USBVIRTUAL.println(resultStr); - SERIAL_PORT_USBVIRTUAL.print(F("Press 'Enter' key twice to start a serial terminal")); - resultStr = getUserInput(resultStr, false); - serialTerminalMode = true; - //startSerialTerminal(); - SERIAL_PORT_HARDWARE.write((uint8_t *)"\xff\0\0\x05XXXXX\x7f\xf9", 11); // send "bridge shutdown" command - delay(100); - SERIAL_PORT_HARDWARE.println("\nreset\n\n"); - SERIAL_PORT_HARDWARE.flush(); - SERIAL_PORT_HARDWARE.println("\nreset\n\n"); - SERIAL_PORT_HARDWARE.write((uint8_t *)"\n", 1); - } - - } else { - loopSerialTerminal(); - } -} - -String getUserInput(String out, bool obfuscated) { - /* - while (SerialUSB.available() <= 0) {} - while (SerialUSB.available() > 0) { - char c = SerialUSB.read(); - out += c; - } - return out; - */ - while (SERIAL_PORT_USBVIRTUAL.available() <= 0) {} - while (1) { - char c = SERIAL_PORT_USBVIRTUAL.read(); - if (c == '\n' || c == '\r') - break; - else { - if (c != -1) { - out += c; - if (obfuscated) - SERIAL_PORT_USBVIRTUAL.print("*"); - else - SERIAL_PORT_USBVIRTUAL.print(c); - } - } - } - SERIAL_PORT_USBVIRTUAL.println(""); - return out; -} - -void wifiConfig(String yunName, String yunPsw, String wifissid, String wifipsw, String wifiAPname, String countryCode, String encryption) { - Process p; - - p.runShellCommand("blink-start 100"); //start the blue blink - - p.runShellCommand("hostname " + yunName); //change the current hostname - p.runShellCommand("uci set system.@system[0].hostname='" + yunName + "'"); //change teh hostname in uci - - p.runShellCommand("uci set arduino.@arduino[0].access_point_wifi_name='" + wifiAPname + "'"); - - //this block resets the wifi psw - p.runShellCommand("uci set wireless.@wifi-iface[0].encryption='" + encryption + "'"); - p.runShellCommand("uci set wireless.@wifi-iface[0].mode='sta'\n"); - p.runShellCommand("uci set wireless.@wifi-iface[0].ssid='" + wifissid + "'"); - p.runShellCommand("uci set wireless.@wifi-iface[0].key='" + wifipsw + "'"); - p.runShellCommand("uci set wireless.radio0.channel='auto'"); - p.runShellCommand("uci set wireless.radio0.country='" + countryCode + "'"); - p.runShellCommand("uci delete network.lan.ipaddr"); - p.runShellCommand("uci delete network.lan.netmask"); - p.runShellCommand("uci set network.lan.proto='dhcp'"); - - p.runShellCommand("echo -e \"" + yunPsw + "\n" + yunPsw + "\" | passwd root"); //change the passwors - p.runShellCommand("uci commit"); //save the mods done via UCI - p.runShellCommand("blink-stop"); //start the blue blink - - p.runShellCommand("wifi "); -} - -long linuxBaud = 250000; - -void startSerialTerminal() { - SERIAL_PORT_USBVIRTUAL.begin(115200); // open serial connection via USB-Serial - SERIAL_PORT_HARDWARE.begin(linuxBaud); // open serial connection to Linux -} - -boolean commandMode = false; -void loopSerialTerminal() { - // copy from USB-CDC to UART - int c = SERIAL_PORT_USBVIRTUAL.read(); // read from USB-CDC - if (c != -1) { // got anything? - if (commandMode == false) { // if we aren't in command mode... - if (c == '~') { // Tilde '~' key pressed? - commandMode = true; // enter in command mode - } else { - SERIAL_PORT_HARDWARE.write(c); // otherwise write char to UART - } - } else { // if we are in command mode... - if (c == '0') { // '0' key pressed? - SERIAL_PORT_HARDWARE.begin(57600); // set speed to 57600 - SERIAL_PORT_USBVIRTUAL.println("Speed set to 57600"); - } else if (c == '1') { // '1' key pressed? - SERIAL_PORT_HARDWARE.begin(115200); // set speed to 115200 - SERIAL_PORT_USBVIRTUAL.println("Speed set to 115200"); - } else if (c == '2') { // '2' key pressed? - SERIAL_PORT_HARDWARE.begin(250000); // set speed to 250000 - SERIAL_PORT_USBVIRTUAL.println("Speed set to 250000"); - } else if (c == '3') { // '3' key pressed? - SERIAL_PORT_HARDWARE.begin(500000); // set speed to 500000 - SERIAL_PORT_USBVIRTUAL.println("Speed set to 500000"); - } else if (c == '~') { // '~` key pressed? - SERIAL_PORT_HARDWARE.write((uint8_t *)"\xff\0\0\x05XXXXX\x7f\xf9", 11); // send "bridge shutdown" command - SERIAL_PORT_USBVIRTUAL.println("Sending bridge's shutdown command"); - } else { // any other key pressed? - SERIAL_PORT_HARDWARE.write('~'); // write '~' to UART - SERIAL_PORT_HARDWARE.write(c); // write char to UART - } - commandMode = false; // in all cases exit from command mode - } - } - - // copy from UART to USB-CDC - c = SERIAL_PORT_HARDWARE.read(); // read from UART - if (c != -1) { // got anything? - SERIAL_PORT_USBVIRTUAL.write(c); // write to USB-CDC - } -} diff --git a/doc/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino b/doc/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino @@ -1,82 +0,0 @@ -/* - Arduino Yún USB-to-Serial - - Allows you to use the YunShield/Yún processor as a - serial terminal for the Linux side on the Yún. - - Upload this to a YunShield/Yún via serial (not WiFi) then open - the serial monitor at 115200 to see the boot process of Linux. - You can also use the serial monitor as a basic command line - interface for Linux using this sketch. - - From the serial monitor the following commands can be issued: - - '~' followed by '0' -> Set the UART speed to 57600 baud - '~' followed by '1' -> Set the UART speed to 115200 baud - '~' followed by '2' -> Set the UART speed to 250000 baud - '~' followed by '3' -> Set the UART speed to 500000 baud - '~' followed by '~' -> Sends the bridge's shutdown command to - obtain the console. - - The circuit: - YunShield/Yún - - created March 2013 - by Massimo Banzi - modified by Cristian Maglie - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/YunSerialTerminal - -*/ - -long linuxBaud = 250000; - -void setup() { - SERIAL_PORT_USBVIRTUAL.begin(115200); // open serial connection via USB-Serial - SERIAL_PORT_HARDWARE.begin(linuxBaud); // open serial connection to Linux -} - -boolean commandMode = false; - -void loop() { - // copy from USB-CDC to UART - int c = SERIAL_PORT_USBVIRTUAL.read(); // read from USB-CDC - if (c != -1) { // got anything? - if (commandMode == false) { // if we aren't in command mode... - if (c == '~') { // Tilde '~' key pressed? - commandMode = true; // enter in command mode - } else { - SERIAL_PORT_HARDWARE.write(c); // otherwise write char to UART - } - } else { // if we are in command mode... - if (c == '0') { // '0' key pressed? - SERIAL_PORT_HARDWARE.begin(57600); // set speed to 57600 - SERIAL_PORT_USBVIRTUAL.println("Speed set to 57600"); - } else if (c == '1') { // '1' key pressed? - SERIAL_PORT_HARDWARE.begin(115200); // set speed to 115200 - SERIAL_PORT_USBVIRTUAL.println("Speed set to 115200"); - } else if (c == '2') { // '2' key pressed? - SERIAL_PORT_HARDWARE.begin(250000); // set speed to 250000 - SERIAL_PORT_USBVIRTUAL.println("Speed set to 250000"); - } else if (c == '3') { // '3' key pressed? - SERIAL_PORT_HARDWARE.begin(500000); // set speed to 500000 - SERIAL_PORT_USBVIRTUAL.println("Speed set to 500000"); - } else if (c == '~') { // '~` key pressed? - SERIAL_PORT_HARDWARE.write((uint8_t *)"\xff\0\0\x05XXXXX\x7f\xf9", 11); // send "bridge shutdown" command - SERIAL_PORT_USBVIRTUAL.println("Sending bridge's shutdown command"); - } else { // any other key pressed? - SERIAL_PORT_HARDWARE.write('~'); // write '~' to UART - SERIAL_PORT_HARDWARE.write(c); // write char to UART - } - commandMode = false; // in all cases exit from command mode - } - } - - // copy from UART to USB-CDC - c = SERIAL_PORT_HARDWARE.read(); // read from UART - if (c != -1) { // got anything? - SERIAL_PORT_USBVIRTUAL.write(c); // write to USB-CDC - } -} diff --git a/doc/Esplora/README.adoc b/doc/Esplora/README.adoc @@ -1,24 +0,0 @@ -= Esplora Library for Arduino = - -The library offers easy access to the data from the onboard Esplora's sensors, and provides the ability to change the state of the outputs. - -For more information about this library please visit us at -http://www.arduino.cc/en/Reference/EsploraLibrary - -== License == - -Copyright (c) 2012 Arduino LLC. All right reserved. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/doc/Esplora/examples/Beginners/EsploraAccelerometer/EsploraAccelerometer.ino b/doc/Esplora/examples/Beginners/EsploraAccelerometer/EsploraAccelerometer.ino @@ -1,38 +0,0 @@ -/* - Esplora Accelerometer - - This sketch shows you how to read the values from the accelerometer. - To see it in action, open the serial monitor and tilt the board. You'll see - the accelerometer values for each axis change when you tilt the board - on that axis. - - Created on 22 Dec 2012 - by Tom Igoe - - This example is in the public domain. - */ - -#include <Esplora.h> - -void setup() -{ - Serial.begin(9600); // initialize serial communications with your computer -} - -void loop() -{ - int xAxis = Esplora.readAccelerometer(X_AXIS); // read the X axis - int yAxis = Esplora.readAccelerometer(Y_AXIS); // read the Y axis - int zAxis = Esplora.readAccelerometer(Z_AXIS); // read the Z axis - - Serial.print("x: "); // print the label for X - Serial.print(xAxis); // print the value for the X axis - Serial.print("\ty: "); // print a tab character, then the label for Y - Serial.print(yAxis); // print the value for the Y axis - Serial.print("\tz: "); // print a tab character, then the label for Z - Serial.println(zAxis); // print the value for the Z axis - - delay(500); // wait half a second (500 milliseconds) -} - - diff --git a/doc/Esplora/examples/Beginners/EsploraBlink/EsploraBlink.ino b/doc/Esplora/examples/Beginners/EsploraBlink/EsploraBlink.ino @@ -1,42 +0,0 @@ - -/* - Esplora Blink - - This sketch blinks the Esplora's RGB LED. It goes through - all three primary colors (red, green, blue), then it - combines them for secondary colors(yellow, cyan, magenta), then - it turns on all the colors for white. - For best results cover the LED with a piece of white paper to see the colors. - - Created on 22 Dec 2012 - by Tom Igoe - - This example is in the public domain. - */ - -#include <Esplora.h> - - -void setup() { - // There's nothing to set up for this sketch -} - -void loop() { - Esplora.writeRGB(255, 0, 0); // make the LED red - delay(1000); // wait 1 second - Esplora.writeRGB(0, 255, 0); // make the LED green - delay(1000); // wait 1 second - Esplora.writeRGB(0, 0, 255); // make the LED blue - delay(1000); // wait 1 second - Esplora.writeRGB(255, 255, 0); // make the LED yellow - delay(1000); // wait 1 second - Esplora.writeRGB(0, 255, 255); // make the LED cyan - delay(1000); // wait 1 second - Esplora.writeRGB(255, 0, 255); // make the LED magenta - delay(1000); // wait 1 second - Esplora.writeRGB(255, 255, 255); // make the LED white - delay(1000); // wait 1 second - -} - - diff --git a/doc/Esplora/examples/Beginners/EsploraJoystickMouse/EsploraJoystickMouse.ino b/doc/Esplora/examples/Beginners/EsploraJoystickMouse/EsploraJoystickMouse.ino @@ -1,60 +0,0 @@ -/* - Esplora Joystick Mouse - - This sketch shows you how to read the joystick and use it to control the movement - of the cursor on your computer. You're making your Esplora into a mouse! - - WARNING: this sketch will take over your mouse movement. If you lose control - of your mouse do the following: - 1) unplug the Esplora. - 2) open the EsploraBlink sketch - 3) hold the reset button down while plugging your Esplora back in - 4) while holding reset, click "Upload" - 5) when you see the message "Done compiling", release the reset button. - - This will stop your Esplora from controlling your mouse while you upload a sketch - that doesn't take control of the mouse. - - Created on 22 Dec 2012 - by Tom Igoe - Updated 8 March 2014 - by Scott Fitzgerald - - http://www.arduino.cc/en/Reference/EsploraReadJoystickSwitch - - This example is in the public domain. - */ - -#include <Esplora.h> - -void setup() -{ - Serial.begin(9600); // initialize serial communication with your computer - Mouse.begin(); // take control of the mouse -} - -void loop() -{ - int xValue = Esplora.readJoystickX(); // read the joystick's X position - int yValue = Esplora.readJoystickY(); // read the joystick's Y position - int button = Esplora.readJoystickSwitch(); // read the joystick pushbutton - Serial.print("Joystick X: "); // print a label for the X value - Serial.print(xValue); // print the X value - Serial.print("\tY: "); // print a tab character and a label for the Y value - Serial.print(yValue); // print the Y value - Serial.print("\tButton: "); // print a tab character and a label for the button - Serial.print(button); // print the button value - - int mouseX = map(xValue, -512, 512, 10, -10); // map the X value to a range of movement for the mouse X - int mouseY = map(yValue, -512, 512, -10, 10); // map the Y value to a range of movement for the mouse Y - Mouse.move(mouseX, mouseY, 0); // move the mouse - - if (button == 0) { // if the joystick button is pressed - Mouse.press(); // send a mouse click - } else { - Mouse.release(); // if it's not pressed, release the mouse button - } - - delay(10); // a short delay before moving again -} - diff --git a/doc/Esplora/examples/Beginners/EsploraLedShow/EsploraLedShow.ino b/doc/Esplora/examples/Beginners/EsploraLedShow/EsploraLedShow.ino @@ -1,42 +0,0 @@ -/* - Esplora LED Show - - Makes the RGB LED bright and glow as the joystick or the - slider are moved. - - Created on 22 november 2012 - By Enrico Gueli <enrico.gueli@gmail.com> - Modified 22 Dec 2012 - by Tom Igoe -*/ -#include <Esplora.h> - -void setup() { - // initialize the serial communication: - Serial.begin(9600); -} - -void loop() { - // read the sensors into variables: - int xAxis = Esplora.readJoystickX(); - int yAxis = Esplora.readJoystickY(); - int slider = Esplora.readSlider(); - - // convert the sensor readings to light levels: - byte red = map(xAxis, -512, 512, 0, 255); - byte green = map(yAxis, -512, 512, 0, 255); - byte blue = slider / 4; - - // print the light levels: - Serial.print(red); - Serial.print(' '); - Serial.print(green); - Serial.print(' '); - Serial.println(blue); - - // write the light levels to the LED. - Esplora.writeRGB(red, green, blue); - - // add a delay to keep the LED from flickering: - delay(10); -} diff --git a/doc/Esplora/examples/Beginners/EsploraLedShow2/EsploraLedShow2.ino b/doc/Esplora/examples/Beginners/EsploraLedShow2/EsploraLedShow2.ino @@ -1,55 +0,0 @@ -/* - Esplora Led/Microphone - - This simple sketch reads the microphone, light sensor, and slider. - Then it uses those readings to set the brightness of red, green and blue - channels of the RGB LED. The red channel will change with the loudness - "heared" by the microphone, the green channel changes as the - amount of light in the room and the blue channel will change - with the position of the slider. - - Created on 22 november 2012 - By Enrico Gueli <enrico.gueli@gmail.com> - Modified 24 Nov 2012 - by Tom Igoe -*/ - -#include <Esplora.h> - -void setup() { - // initialize the serial communication: - Serial.begin(9600); -} - -int lowLight = 400; // the light sensor reading when it's covered -int highLight = 1023; // the maximum light sensor reading -int minGreen = 0; // minimum brightness of the green LED -int maxGreen = 100; // maximum brightness of the green LED - -void loop() { - // read the sensors into variables: - int mic = Esplora.readMicrophone(); - int light = Esplora.readLightSensor(); - int slider = Esplora.readSlider(); - - // convert the sensor readings to light levels: - byte red = constrain(mic, 0, 255); - byte green = constrain( - map(light, lowLight, highLight, minGreen, maxGreen), - 0, 255); - byte blue = slider / 4; - - // print the light levels (to see what's going on): - Serial.print(red); - Serial.print(' '); - Serial.print(green); - Serial.print(' '); - Serial.println(blue); - - // write the light levels to the LED. - // note that the green value is always 0: - Esplora.writeRGB(red, green, blue); - - // add a delay to keep the LED from flickering: - delay(10); -} diff --git a/doc/Esplora/examples/Beginners/EsploraLightCalibrator/EsploraLightCalibrator.ino b/doc/Esplora/examples/Beginners/EsploraLightCalibrator/EsploraLightCalibrator.ino @@ -1,91 +0,0 @@ -/* - Esplora Led calibration - - This sketch shows you how to read and calibrate the light sensor. - Because light levels vary from one location to another, you need to calibrate the - sensor for each location. To do this, you read the sensor for a few seconds, - and save the highest and lowest readings as maximum and minimum. - Then, when you're using the sensor's reading (for example, to set the brightness - of the LED), you map the sensor's reading to a range between the minimum - and the maximum. - - Created on 22 Dec 2012 - by Tom Igoe - - This example is in the public domain. - */ - -#include <Esplora.h> - -// variables: -int lightMin = 1023; // minimum sensor value -int lightMax = 0; // maximum sensor value -boolean calibrated = false; // whether the sensor's been calibrated yet - -void setup() { - // initialize the serial communication: - Serial.begin(9600); - - // print an intial message - Serial.println("To calibrate the light sensor, press and hold Switch 1"); -} - -void loop() { - // if switch 1 is pressed, go to the calibration function again: - if (Esplora.readButton(1) == LOW) { - calibrate(); - } - // read the sensor into a variable: - int light = Esplora.readLightSensor(); - - // map the light level to a brightness level for the LED - // using the calibration min and max: - int brightness = map(light, lightMin, lightMax, 0, 255); - // limit the brightness to a range from 0 to 255: - brightness = constrain(brightness, 0, 255); - // write the brightness to the blue LED. - Esplora.writeBlue(brightness); - - // if the calibration's been done, show the sensor and brightness - // levels in the serial monitor: - if (calibrated == true) { - // print the light sensor levels and the LED levels (to see what's going on): - Serial.print("light sensor level: "); - Serial.print(light); - Serial.print(" blue brightness: "); - Serial.println(brightness); - } - // add a delay to keep the LED from flickering: - delay(10); -} - -void calibrate() { - // tell the user what do to using the serial monitor: - Serial.println("While holding switch 1, shine a light on the light sensor, then cover it."); - - // calibrate while switch 1 is pressed: - while (Esplora.readButton(1) == LOW) { - // read the sensor value: - int light = Esplora.readLightSensor(); - - // record the maximum sensor value: - if (light > lightMax) { - lightMax = light; - } - - // record the minimum sensor value: - if (light < lightMin) { - lightMin = light; - } - // note that you're calibrated, for future reference: - calibrated = true; - } -} - - - - - - - - diff --git a/doc/Esplora/examples/Beginners/EsploraMusic/EsploraMusic.ino b/doc/Esplora/examples/Beginners/EsploraMusic/EsploraMusic.ino @@ -1,53 +0,0 @@ -/* - Esplora Music - - This sketch turns the Esplora in a simple musical instrument. - Press the Switch 1 and move the slider to see how it works. - - Created on 22 november 2012 - By Enrico Gueli <enrico.gueli@gmail.com> - modified 22 Dec 2012 - by Tom Igoe -*/ - - -#include <Esplora.h> - -// these are the frequencies for the notes from middle C -// to one octave above middle C: -const int note[] = { - 262, // C - 277, // C# - 294, // D - 311, // D# - 330, // E - 349, // F - 370, // F# - 392, // G - 415, // G# - 440, // A - 466, // A# - 494, // B - 523 // C next octave -}; - -void setup() { -} - -void loop() { - // read the button labeled SWITCH_DOWN. If it's low, - // then play a note: - if (Esplora.readButton(SWITCH_DOWN) == LOW) { - int slider = Esplora.readSlider(); - - // use map() to map the slider's range to the - // range of notes you have: - byte thisNote = map(slider, 0, 1023, 0, 13); - // play the note corresponding to the slider's position: - Esplora.tone(note[thisNote]); - } - else { - // if the button isn't pressed, turn the note off: - Esplora.noTone(); - } -} diff --git a/doc/Esplora/examples/Beginners/EsploraSoundSensor/EsploraSoundSensor.ino b/doc/Esplora/examples/Beginners/EsploraSoundSensor/EsploraSoundSensor.ino @@ -1,41 +0,0 @@ -/* - Esplora Sound Sensor - - This sketch shows you how to read the microphone sensor. The microphone -will range from 0 (total silence) to 1023 (really loud). - When you're using the sensor's reading (for example, to set the brightness - of the LED), you map the sensor's reading to a range between the minimum - and the maximum. - - Created on 22 Dec 2012 - by Tom Igoe - - This example is in the public domain. - */ - -#include <Esplora.h> - -void setup() { - // initialize the serial communication: - Serial.begin(9600); -} - -void loop() { - // read the sensor into a variable: - int loudness = Esplora.readMicrophone(); - - // map the sound level to a brightness level for the LED: - int brightness = map(loudness, 0, 1023, 0, 255); - // write the brightness to the green LED: - Esplora.writeGreen(brightness); - - - // print the microphone levels and the LED levels (to see what's going on): - Serial.print("sound level: "); - Serial.print(loudness); - Serial.print(" Green brightness: "); - Serial.println(brightness); - // add a delay to keep the LED from flickering: - delay(10); -} - diff --git a/doc/Esplora/examples/Beginners/EsploraTemperatureSensor/EsploraTemperatureSensor.ino b/doc/Esplora/examples/Beginners/EsploraTemperatureSensor/EsploraTemperatureSensor.ino @@ -1,37 +0,0 @@ -/* - Esplora Temperature Sensor - - This sketch shows you how to read the Esplora's temperature sensor - You can read the temperature sensor in Farhenheit or Celsius. - - Created on 22 Dec 2012 - by Tom Igoe - - This example is in the public domain. - */ -#include <Esplora.h> - -void setup() -{ - Serial.begin(9600); // initialize serial communications with your computer -} - -void loop() -{ - // read the temperature sensor in Celsius, then Fahrenheit: - int celsius = Esplora.readTemperature(DEGREES_C); - int fahrenheit = Esplora.readTemperature(DEGREES_F); - - // print the results: - Serial.print("Temperature is: "); - Serial.print(celsius); - Serial.print(" degrees Celsius, or "); - Serial.print(fahrenheit); - Serial.println(" degrees Fahrenheit."); - Serial.println(" Fahrenheit = (9/5 * Celsius) + 32"); - - // wait a second before reading again: - delay(1000); -} - - diff --git a/doc/Esplora/examples/Experts/EsploraKart/EsploraKart.ino b/doc/Esplora/examples/Experts/EsploraKart/EsploraKart.ino @@ -1,125 +0,0 @@ -/* - Esplora Kart - - This sketch turns the Esplora into a PC game pad. - - It uses the both the analog joystick and the four switches. - By moving the joystick in a direction or by pressing a switch, - the PC will "see" that a key is pressed. If the PC is running - a game that has keyboard input, the Esplora can control it. - - The default configuration is suitable for SuperTuxKart, an - open-source racing game. It can be downloaded from - http://supertuxkart.sourceforge.net/ . - - Created on 22 november 2012 - By Enrico Gueli <enrico.gueli@gmail.com> -*/ - - -#include <Esplora.h> - -/* - You're going to handle eight different buttons. You'll use arrays, - which are ordered lists of variables with a fixed size. Each array - has an index (counting from 0) to keep track of the position - you're reading in the array, and each position can contain a number. - - This code uses three different arrays: one for the buttons you'll read; - a second to hold the current states of those buttons; and a third to hold - the keystrokes associated with each button. - */ - -/* - This array holds the last sensed state of each of the buttons - you're reading. - Later in the code, you'll read the button states, and compare them - to the previous states that are stored in this array. If the two - states are different, it means that the button was either - pressed or released. - */ -boolean buttonStates[8]; - -/* - This array holds the names of the buttons being read. - Later in the sketch, you'll use these names with - the method Esplora.readButton(x), where x - is one of these buttons. - */ -const byte buttons[] = { - JOYSTICK_DOWN, - JOYSTICK_LEFT, - JOYSTICK_UP, - JOYSTICK_RIGHT, - SWITCH_RIGHT, // fire - SWITCH_LEFT, // bend - SWITCH_UP, // nitro - SWITCH_DOWN, // look back -}; - -/* - This array tells what keystroke to send to the PC when a - button is pressed. - If you look at this array and the above one, you can see that - the "cursor down" keystroke is sent when the joystick is moved - down, the "cursor up" keystroke when the joystick is moved up - and so on. -*/ -const char keystrokes[] = { - KEY_DOWN_ARROW, - KEY_LEFT_ARROW, - KEY_UP_ARROW, - KEY_RIGHT_ARROW, - ' ', - 'V', - 'N', - 'B' -}; - -/* - This is code is run only at startup, to initialize the - virtual USB keyboard. -*/ -void setup() { - Keyboard.begin(); -} - -/* - After setup() is finished, this code is run continuously. - Here we continuously check if something happened with the - buttons. -*/ -void loop() { - - // Iterate through all the buttons: - for (byte thisButton = 0; thisButton < 8; thisButton++) { - boolean lastState = buttonStates[thisButton]; - boolean newState = Esplora.readButton(buttons[thisButton]); - if (lastState != newState) { // Something changed! - /* - The Keyboard library allows you to "press" and "release" the - keys as two distinct actions. These actions can be - linked to the buttons we're handling. - */ - if (newState == PRESSED) { - Keyboard.press(keystrokes[thisButton]); - } - else if (newState == RELEASED) { - Keyboard.release(keystrokes[thisButton]); - } - } - - // Store the new button state, so you can sense a difference later: - buttonStates[thisButton] = newState; - } - - /* - Wait a little bit (50ms) between a check and another. - When a mechanical switch is pressed or released, the - contacts may bounce very rapidly. If the check is done too - fast, these bounces may be confused as multiple presses and - may lead to unexpected behaviour. - */ - delay(50); -} - diff --git a/doc/Esplora/examples/Experts/EsploraPong/EsploraPong.ino b/doc/Esplora/examples/Experts/EsploraPong/EsploraPong.ino @@ -1,44 +0,0 @@ -/* - Esplora Pong - - This sketch connects serially to a Processing sketch to control a Pong game. - It sends the position of the slider and the states of three pushbuttons to the - Processing sketch serially, separated by commas. The Processing sketch uses that - data to control the graphics in the sketch. - - The slider sets a paddle's height - Switch 1 is resets the game - Switch 2 resets the ball to the center - Switch 3 reverses the players - - You can play this game with one or two Esploras. - - Created on 22 Dec 2012 - by Tom Igoe - - This example is in the public domain. - */ - -#include <Esplora.h> - -void setup() { - Serial.begin(9600); // initialize serial communication -} - -void loop() { - // read the slider and three of the buttons - int slider = Esplora.readSlider(); - int resetButton = Esplora.readButton(SWITCH_1); - int serveButton = Esplora.readButton(SWITCH_3); - int switchPlayerButton = Esplora.readButton(SWITCH_4); - - Serial.print(slider); // print the slider value - Serial.print(","); // add a comma - Serial.print(resetButton); // print the reset button value - Serial.print(","); // add another comma - Serial.print(serveButton); // print the serve button value - Serial.print(","); // add another comma - Serial.println(switchPlayerButton); // print the last button with a newline - delay(10); // delay before sending the next set -} - diff --git a/doc/Esplora/examples/Experts/EsploraRemote/EsploraRemote.ino b/doc/Esplora/examples/Experts/EsploraRemote/EsploraRemote.ino @@ -1,116 +0,0 @@ -/* - Esplora Remote - - This sketch allows to test all the Esplora's peripherals. - It is also used with the ProcessingStart sketch (for Processing). - - When uploaded, you can open the Serial monitor and write one of - the following commands (without quotes) to get an answer: - - "D": prints the current value of all sensors, separated by a comma. - See the dumpInputs() function below to get the meaning of - each value. - - "Rxxx" - "Gxxx" - "Bxxx": set the color of the RGB led. For example, write "R255" - to turn on the red to full brightness, "G128" to turn - the green to half brightness, or "G0" to turn off - the green channel. - - "Txxxx": play a tone with the buzzer. The number is the - frequency, e.g. "T440" plays the central A note. - Write "T0" to turn off the buzzer. - - - Created on 22 november 2012 - By Enrico Gueli <enrico.gueli@gmail.com> - Modified 23 Dec 2012 - by Tom Igoe - */ - -#include <Esplora.h> - -void setup() { - while (!Serial); // needed for Leonardo-based board like Esplora - Serial.begin(9600); -} - -void loop() { - if (Serial.available()) - parseCommand(); -} - -/* - * This function reads a character from the serial line and - * decide what to do next. The "what to do" part is given by - * function it calls (e.g. dumpInputs(), setRed() and so on). - */ -void parseCommand() { - char cmd = Serial.read(); - switch (cmd) { - case 'D': - dumpInputs(); - break; - case 'R': - setRed(); - break; - case 'G': - setGreen(); - break; - case 'B': - setBlue(); - break; - case 'T': - setTone(); - break; - } -} - -void dumpInputs() { - Serial.print(Esplora.readButton(SWITCH_1)); - Serial.print(','); - Serial.print(Esplora.readButton(SWITCH_2)); - Serial.print(','); - Serial.print(Esplora.readButton(SWITCH_3)); - Serial.print(','); - Serial.print(Esplora.readButton(SWITCH_4)); - Serial.print(','); - Serial.print(Esplora.readSlider()); - Serial.print(','); - Serial.print(Esplora.readLightSensor()); - Serial.print(','); - Serial.print(Esplora.readTemperature(DEGREES_C)); - Serial.print(','); - Serial.print(Esplora.readMicrophone()); - Serial.print(','); - Serial.print(Esplora.readJoystickSwitch()); - Serial.print(','); - Serial.print(Esplora.readJoystickX()); - Serial.print(','); - Serial.print(Esplora.readJoystickY()); - Serial.print(','); - Serial.print(Esplora.readAccelerometer(X_AXIS)); - Serial.print(','); - Serial.print(Esplora.readAccelerometer(Y_AXIS)); - Serial.print(','); - Serial.print(Esplora.readAccelerometer(Z_AXIS)); - Serial.println(); -} - -void setRed() { - Esplora.writeRed(Serial.parseInt()); -} - -void setGreen() { - Esplora.writeGreen(Serial.parseInt()); -} - -void setBlue() { - Esplora.writeBlue(Serial.parseInt()); -} - -void setTone() { - Esplora.tone(Serial.parseInt()); -} - diff --git a/doc/Esplora/examples/Experts/EsploraTable/EsploraTable.ino b/doc/Esplora/examples/Experts/EsploraTable/EsploraTable.ino @@ -1,213 +0,0 @@ -/* - Esplora Table - - Acts like a keyboard that prints sensor - data in a table-like text, row by row. - - At startup, it does nothing. It waits for you to open a - spreadsheet (e.g. Google Drive spreadsheet) so it can write - data. By pressing Switch 1, it starts printing the table - headers and the first row of data. It waits a bit, then it - will print another row, and so on. - - The amount of time between each row is determined by the slider. - If put to full left, the sketch will wait 10 seconds; at - full right position, it will wait 5 minutes. An intermediate - position will make the sketch wait for some time in-between. - - Clicking the Switch 1 at any time will stop the logging. - - The color LED shows what the sketch is doing: - blue = idle, waiting for you to press Switch 1 to start logging - green = active; will print soon - red = printing data to the PC - - Created on 22 november 2012 - By Enrico Gueli <enrico.gueli@gmail.com> - modified 24 Nov 2012 - by Tom Igoe -*/ - -#include <Esplora.h> - -/* - * this variable tells if the data-logging is currently active. - */ -boolean active = false; - -/* - * this variable holds the time in the future when the sketch - * will "sample" the data (sampling is the act of reading some - * input at a known time). This variable is checked continuously - * against millis() to know when it's time to sample. - */ -unsigned long nextSampleAt = 0; - -/* - * This variable just holds the millis() value at the time the - * logging was activated. This is needed to enter the correct - * value in the "Time" column in the printed table. - */ -unsigned long startedAt = 0; - - -/* - * when the "active" variable is set to true, the same is done - * with this variable. This is needed because the code that does - * the "just-after-activation" stuff is run some time later than - * the code that says "be active now". - */ -boolean justActivated = false; - - -/* - * this variable holds the last sensed status of the switch press - * button. If the code sees a difference between the value of - * this variable and the current status of the switch, it means - * that the button was either pressed or released. - */ -boolean lastStartBtn = HIGH; - -/* - * Initialization code. The virtual USB keyboard must be - * initialized; the Serial class is needed just for debugging. - */ -void setup() { - Keyboard.begin(); - Serial.begin(9600); -} - -/* - * This code is run continuously. - */ -void loop() { - /* - * note: we don't use Arduino's delay() here, because we can't - * normally do anything while delaying. Our own version lets us - * check for button presses often enough to not miss any event. - */ - activeDelay(50); - - /* - * the justActivated variable may be set to true in the - * checkSwitchPress() function. Here we check its status to - * print the table headers and configure what's needed to. - */ - if (justActivated == true) { - justActivated = false; // do this just once - printHeaders(); - // do next sampling ASAP - nextSampleAt = startedAt = millis(); - } - - if (active == true) { - if (nextSampleAt < millis()) { - // it's time to sample! - int slider = Esplora.readSlider(); - // the row below maps the slider position to a range between - // 10 and 290 seconds. - int sampleInterval = map(slider, 0, 1023, 10, 290); - nextSampleAt = millis() + sampleInterval * 1000; - - logAndPrint(); - } - - // let the RGB led blink green once per second, for 200ms. - unsigned int ms = millis() % 1000; - if (ms < 200) - Esplora.writeGreen(50); - else - Esplora.writeGreen(0); - - Esplora.writeBlue(0); - } - else - // while not active, keep a reassuring blue color coming - // from the Esplora... - Esplora.writeBlue(20); - -} - -/* - * Print the table headers. - */ -void printHeaders() { - Keyboard.print("Time"); - Keyboard.write(KEY_TAB); - activeDelay(300); // Some spreadsheets are slow, e.g. Google - // Drive that wants to save every edit. - Keyboard.print("Accel X"); - Keyboard.write(KEY_TAB); - activeDelay(300); - Keyboard.print("Accel Y"); - Keyboard.write(KEY_TAB); - activeDelay(300); - Keyboard.print("Accel Z"); - Keyboard.println(); - activeDelay(300); -} - -void logAndPrint() { - // do all the samplings at once, because keystrokes have delays - unsigned long timeSecs = (millis() - startedAt) / 1000; - int xAxis = Esplora.readAccelerometer(X_AXIS); - int yAxis = Esplora.readAccelerometer(Y_AXIS); - int zAxis = Esplora.readAccelerometer(Z_AXIS); - - Esplora.writeRed(100); - - Keyboard.print(timeSecs); - Keyboard.write(KEY_TAB); - activeDelay(300); - Keyboard.print(xAxis); - Keyboard.write(KEY_TAB); - activeDelay(300); - Keyboard.print(yAxis); - Keyboard.write(KEY_TAB); - activeDelay(300); - Keyboard.print(zAxis); - Keyboard.println(); - activeDelay(300); - Keyboard.write(KEY_HOME); - - Esplora.writeRed(0); -} - -/** - * Similar to delay(), but allows the program to do something else - * in the meanwhile. In particular, it calls checkSwitchPress(). - * Note 1: it may wait longer than the specified amount, not less; - * Note 2: beware of data synchronization issues, e.g. if the - * activeDelay() function alters some variables used by the - * caller of this function. - */ -void activeDelay(unsigned long amount) { - unsigned long at = millis() + amount; - while (millis() < at) { - checkSwitchPress(); - } -} - -/* - * This function reads the status of the switch; if it sees that - * it was pressed, toggles the status of the "active" variable. - * If it's set to true, also the justActivated variable is set to - * true, so the loop() function above can do the right things. - * This function should be called as often as possible and do as - * little as possible, because it can be called while another - * function is running. - */ -void checkSwitchPress() { - boolean startBtn = Esplora.readButton(SWITCH_DOWN); - - if (startBtn != lastStartBtn) { - if (startBtn == HIGH) { // button released - active = !active; - if (active) - justActivated = true; - } - - lastStartBtn = startBtn; - } -} - diff --git a/doc/Keyboard/README.adoc b/doc/Keyboard/README.adoc @@ -1,25 +0,0 @@ -= Keyboard Library for Arduino = - -This library allows an Arduino board with USB capabilites to act as a Keyboard. -Being based on HID library you need to include "HID.h" in your sketch. - -For more information about this library please visit us at -http://www.arduino.cc/en/Reference/Keyboard - -== License == - -Copyright (c) Arduino LLC. All right reserved. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/doc/Mouse/README.adoc b/doc/Mouse/README.adoc @@ -1,25 +0,0 @@ -= Mouse Library for Arduino = - -This library allows an Arduino board with USB capabilites to act as a Mouse. -Being based on HID library you need to include "HID.h" in your sketch - -For more information about this library please visit us at -http://www.arduino.cc/en/Reference/Mouse - -== License == - -Copyright (c) Arduino LLC. All right reserved. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/doc/RobotIRremote/LICENSE.txt b/doc/RobotIRremote/LICENSE.txt @@ -1,458 +0,0 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - diff --git a/doc/RobotIRremote/README.adoc b/doc/RobotIRremote/README.adoc @@ -1,31 +0,0 @@ -= Robot IR Remote Library for Arduino = - -The Robot has a number of built in sensors and actuators. The library is designed to easily access the robot's functionality. - -For more information about this library please visit us at -http://www.arduino.cc/en/Reference/RobotLibrary - -== License == - -Copyright (c) Arduino LLC. All right reserved. -Copyright (c) Paul Stoffregen. All right reserved. -Copyright (c) Mitra Ardron. All right reserved. -Copyright (c) Joe Knapp. All right reserved. -Copyright (c) Mark Ivey. All right reserved. -Copyright (c) Kristian Lauszus. All right reserved. - -Copyright (c) 2009 Ken Shirriff. All right reserved. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/doc/Robot_Control/README.adoc b/doc/Robot_Control/README.adoc @@ -1,27 +0,0 @@ -= Robot Control Library for Arduino = - -The Robot has a number of built in sensors and actuators. The library is designed to easily access the robot's functionality. - -For more information about this library please visit us at -http://www.arduino.cc/en/Reference/RobotLibrary - -== License == - -Copyright (c) Arduino LLC. All right reserved. -Copyright (c) Bill Porter. All right reserved. -Copyright (C) 2008 by William Greiman. All right reserved. -Copyright (c) 2013 Adafruit Industries. All rights reserved. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/doc/Robot_Control/examples/explore/R01_Logo/R01_Logo.ino b/doc/Robot_Control/examples/explore/R01_Logo/R01_Logo.ino @@ -1,136 +0,0 @@ -/* Robot Logo - - This sketch demonstrates basic movement of the Robot. - When the sketch starts, press the on-board buttons to tell - the robot how to move. Pressing the middle button will - save the pattern, and the robot will follow accordingly. - You can record up to 20 commands. The robot will move for - one second per command. - - This example uses images on an SD card. It looks for - files named "lg0.bmp" and "lg1.bmp" and draws them on the - screen. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> // include the robot library -#include <Wire.h> -#include <SPI.h> - -int commands[20]; // array for storing commands - -void setup() { - // initialize the Robot, SD card, and display - Robot.begin(); - Robot.beginTFT(); - Robot.beginSD(); - - // draw "lg0.bmp" and "lg1.bmp" on the screen - Robot.displayLogos(); -} - -void loop() { - - Robot.drawBMP("intro.bmp", 0, 0); //display background image - - iniCommands(); // remove commands from the array - addCommands(); // add commands to the array - - delay(1000); // wait for a second - - executeCommands(); // follow orders - - Robot.stroke(0, 0, 0); - Robot.text("Done!", 5, 103); // write some text to the display - delay(1500); // wait for a moment -} - -// empty the commands array -void iniCommands() { - for (int i = 0; i < 20; i++) - commands[i] = -1; -} - -// add commands to the array -void addCommands() { - Robot.stroke(0, 0, 0); - // display text on the screen - Robot.text("1. Press buttons to\n add commands.\n\n 2. Middle to finish.", 5, 5); - - // read the buttons' state - for (int i = 0; i < 20;) { //max 20 commands - int key = Robot.keyboardRead(); - if (key == BUTTON_MIDDLE) { //finish input - break; - } else if (key == BUTTON_NONE) { //if no button is pressed - continue; - } - commands[i] = key; // save the button to the array - PrintCommandI(i, 46); // print the command on the screen - delay(100); - i++; - } -} - -// run through the array and move the robot -void executeCommands() { - // print status to the screen - Robot.text("Excuting...", 5, 70); - - // read through the array and move accordingly - for (int i = 0; i < 20; i++) { - switch (commands[i]) { - case BUTTON_LEFT: - Robot.turn(-90); - break; - case BUTTON_RIGHT: - Robot.turn(90); - break; - case BUTTON_UP: - Robot.motorsWrite(255, 255); - break; - case BUTTON_DOWN: - Robot.motorsWrite(-255, -255); - break; - case BUTTON_NONE: - return; - } - // print the current command to the screen - Robot.stroke(255, 0, 0); - PrintCommandI(i, 86); - delay(1000); - - // stop moving for a second - Robot.motorsStop(); - delay(1000); - } -} - -// convert the button press to a single character -char keyToChar(int key) { - switch (key) { - case BUTTON_LEFT: - return '<'; - case BUTTON_RIGHT: - return '>'; - case BUTTON_UP: - return '^'; - case BUTTON_DOWN: - return 'v'; - } -} - -// display a command -void PrintCommandI(int i, int originY) { - Robot.text(keyToChar(commands[i]), i % 14 * 8 + 5, i / 14 * 10 + originY); -} - diff --git a/doc/Robot_Control/examples/explore/R02_Line_Follow/R02_Line_Follow.ino b/doc/Robot_Control/examples/explore/R02_Line_Follow/R02_Line_Follow.ino @@ -1,76 +0,0 @@ -/* Robot Line Follow - - This sketch demonstrates the line following capabilities - of the Arduino Robot. On the floor, place some black - electrical tape along the path you wish the robot to follow. - To indicate a stopping point, place another piece of tape - perpendicular to the path. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> // include the robot library -#include <Wire.h> -#include <SPI.h> - -long timerOrigin; // used for counting elapsed time - -void setup() { - // initialize the Robot, SD card, display, and speaker - Robot.begin(); - Robot.beginTFT(); - Robot.beginSD(); - Robot.beginSpeaker(); - - // show the logots on the TFT screen - Robot.displayLogos(); - - Robot.drawBMP("lf.bmp", 0, 0); // display background image - - Robot.playFile("chase.sqm"); // play a song from the SD card - - // add the instructions - Robot.text("Line Following\n\n place the robot on\n the track and \n see it run", 5, 5); - Robot.text("Press the middle\n button to start...", 5, 61); - Robot.waitContinue(); - - // These are some general values that work for line following - // uncomment one or the other to see the different behaviors of the robot - //Robot.lineFollowConfig(14, 9, 50, 10); - Robot.lineFollowConfig(11, 7, 60, 5); - - - //set the motor board into line-follow mode - Robot.setMode(MODE_LINE_FOLLOW); - - // start - Robot.fill(255, 255, 255); - Robot.stroke(255, 255, 255); - Robot.rect(0, 0, 128, 80); // erase the previous text - Robot.stroke(0, 0, 0); - Robot.text("Start", 5, 5); - - Robot.stroke(0, 0, 0); // choose color for the text - Robot.text("Time passed:", 5, 21); // write some text to the screen - - timerOrigin = millis(); // keep track of the elapsed time - - while (!Robot.isActionDone()) { //wait for the finish signal - Robot.debugPrint(millis() - timerOrigin, 5, 29); // show how much time has passed - } - - Robot.stroke(0, 0, 0); - Robot.text("Done!", 5, 45); -} -void loop() { - //nothing here, the program only runs once. Reset the robot - //to do it again! -} diff --git a/doc/Robot_Control/examples/explore/R03_Disco_Bot/R03_Disco_Bot.ino b/doc/Robot_Control/examples/explore/R03_Disco_Bot/R03_Disco_Bot.ino @@ -1,181 +0,0 @@ -/* Disco Bot - - This sketch shows you how to use the melody playing - feature of the robot, with some really cool 8-bit music. - Music will play when the robot is turned on, and it - will show you some dance moves. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> // include the robot library -#include <Wire.h> -#include <SPI.h> - -/* Dancing steps: - S: stop - L: turn left - R: turn right - F: go forward - B: go backwards - - The number after each command determines how long - each step lasts. Each number is 1/2 second long. - - The "\0" indicates end of string -*/ -char danceScript[] = "S4L1R1S2F1B1S1\0"; - -int currentScript = 0; // what step are we at - -int currentSong = 0; // keep track of the current song -static const int SONGS_COUNT = 3; // number of songs - -// an array to hold the songs -char musics[][11] = { - "melody.sqm", - "menu.sqm", - "chase.sqm", -}; - -// variables for non-blocking delay -long waitFrom; -long waitTime = 0; - -void setup() { - // initialize the Robot, SD card, display, and speaker - Robot.begin(); - Robot.beginSpeaker(); - Robot.beginSD(); - Robot.beginTFT(); - - // draw "lg0.bmp" and "lg1.bmp" on the screen - Robot.displayLogos(); - - // Print instructions to the screen - Robot.text("1. Use left and\n right key to switch\n song", 5, 5); - Robot.text("2. Put robot on the\n ground to dance", 5, 33); - - // wait for a few soconds - delay(3000); - - setInterface(); // display the current song - play(0); //play the first song in the array - - resetWait(); //Initialize non-blocking delay -} - -void loop() { - // read the butttons on the robot - int key = Robot.keyboardRead(); - - // Right/left buttons play next/previous song - switch (key) { - case BUTTON_UP: - case BUTTON_LEFT: - play(-1); //play previous song - break; - case BUTTON_DOWN: - case BUTTON_RIGHT: - play(1); //play next song - break; - } - - // dance! - runScript(); -} - -// Dancing function -void runScript() { - if (!waiting()) { // if the previous instructions have finished - // get the next 2 commands (direction and duration) - parseCommand(danceScript[currentScript], danceScript[currentScript + 1]); - currentScript += 2; - if (danceScript[currentScript] == '\0') // at the end of the array - currentScript = 0; // start again at the beginning - } -} - -// instead of delay, use this timer -boolean waiting() { - if (millis() - waitFrom >= waitTime) - return false; - else - return true; -} - -// how long to wait -void wait(long t) { - resetWait(); - waitTime = t; -} - -// reset the timer -void resetWait() { - waitFrom = millis(); -} - -// read the direction and dirstion of the steps -void parseCommand(char dir, char duration) { - //convert the scripts to action - switch (dir) { - case 'L': - Robot.motorsWrite(-255, 255); - break; - case 'R': - Robot.motorsWrite(255, -255); - break; - case 'F': - Robot.motorsWrite(255, 255); - break; - case 'B': - Robot.motorsWrite(-255, -255); - break; - case 'S': - Robot.motorsStop(); - break; - } - //You can change "500" to change the pace of dancing - wait(500 * (duration - '0')); -} - -// display the song -void setInterface() { - Robot.clearScreen(); - Robot.stroke(0, 0, 0); - Robot.text(musics[0], 0, 0); -} - -// display the next song -void select(int seq, boolean onOff) { - if (onOff) { //select - Robot.stroke(0, 0, 0); - Robot.text(musics[seq], 0, 0); - } else { //deselect - Robot.stroke(255, 255, 255); - Robot.text(musics[seq], 0, 0); - } -} - -// play the slected song -void play(int seq) { - select(currentSong, false); - if (currentSong <= 0 && seq == -1) { //previous of 1st song? - currentSong = SONGS_COUNT - 1; //go to last song - } else if (currentSong >= SONGS_COUNT - 1 && seq == 1) { //next of last? - currentSong = 0; //go to 1st song - } else { - currentSong += seq; //next song - } - Robot.stopPlayFile(); - Robot.playFile(musics[currentSong]); - select(currentSong, true); //display the current song -} diff --git a/doc/Robot_Control/examples/explore/R04_Compass/R04_Compass.ino b/doc/Robot_Control/examples/explore/R04_Compass/R04_Compass.ino @@ -1,72 +0,0 @@ -/* Robot Compass - - The robot has an on-board compass module, with - which it can tell the direction the robot is - facing. This sketch will make sure the robot - goes towards a certain direction. - - Beware, magnets will interfere with the compass - readings. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -// include the robot library -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -int speedLeft; -int speedRight; -int compassValue; -int direc = 180; //Direction the robot is heading - -void setup() { - // initialize the modules - Robot.begin(); - Robot.beginTFT(); - Robot.beginSD(); - Robot.displayLogos(); -} - -void loop() { - // read the compass orientation - compassValue = Robot.compassRead(); - - // how many degrees are we off - int diff = compassValue - direc; - - // modify degress - if (diff > 180) - diff = -360 + diff; - else if (diff < -180) - diff = 360 + diff; - - // Make the robot turn to its proper orientation - diff = map(diff, -180, 180, -255, 255); - - if (diff > 0) { - // keep the right wheel spinning, - // change the speed of the left wheel - speedLeft = 255 - diff; - speedRight = 255; - } else { - // keep the right left spinning, - // change the speed of the left wheel - speedLeft = 255; - speedRight = 255 + diff; - } - // write out to the motors - Robot.motorsWrite(speedLeft, speedRight); - - // draw the orientation on the screen - Robot.drawCompass(compassValue); -} diff --git a/doc/Robot_Control/examples/explore/R05_Inputs/R05_Inputs.ino b/doc/Robot_Control/examples/explore/R05_Inputs/R05_Inputs.ino @@ -1,167 +0,0 @@ -/* Robot Inputs - - This sketch shows you how to use the on-board - potentiometer and buttons as inputs. - - Turning the potentiometer draws a clock-shaped - circle. The up and down buttons change the pitch, - while the left and right buttons change the tempo. - The middle button resets tempo and pitch. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -// default tempo and pitch of the music -int tempo = 60; -int pitch = 1000; - -void setup() { - // initialize the Robot, SD card, speaker, and display - Robot.begin(); - Robot.beginTFT(); - Robot.beginSpeaker(); - Robot.beginSD(); - - // draw "lg0.bmp" and "lg1.bmp" on the screen - Robot.displayLogos(); - - // play a sound file - Robot.playFile("Melody.sqm"); -} - -void loop() { - // check the value of the buttons - keyDown(Robot.keyboardRead()); - - // check the value of the pot - drawKnob(Robot.knobRead()); -} - -// Draw the basic interface -void renderUI() { - //fill the buttons blank - Robot.fill(255, 255, 255); - Robot.rect(53, 58, 13, 13); // left - Robot.rect(93, 58, 13, 13); // right - Robot.rect(73, 38, 13, 13); // up - Robot.circle(79, 64, 6); // middle - Robot.rect(73, 78, 13, 13); // down - - //draw the knob - Robot.noFill(); - Robot.circle(26, 116, 17); // knob - - //draw the vertical bargraph - int fullPart = map(pitch, 200, 2000, 0, 58); //length of filled bargraph - Robot.fill(255, 255, 255); - Robot.rect(21, 30, 13, 58 - fullPart); - Robot.fill(0, 0, 255); - Robot.rect(21, 88 - fullPart, 13, fullPart); //58-fullPart+30 - - //draw the horizontal bargraph - fullPart = map(tempo, 20, 100, 0, 58); // length of filled bargraph - Robot.fill(255, 190, 0); - Robot.rect(53, 110, fullPart, 13); - Robot.fill(255, 255, 255); - Robot.rect(53 + fullPart, 110, 58 - fullPart, 13); -} - -void keyDown(int keyCode) { - // use a static int so it is persistent over time - static int oldKey; - switch (keyCode) { - case BUTTON_LEFT: - //left button pressed, reduces tempo - tempo -= 5; - if (tempo < 20) tempo = 20; //lowest tempo 20 - Robot.fill(255, 190, 0); - - Robot.rect(53, 58, 13, 13); - break; - case BUTTON_RIGHT: - //right button pressed, increases tempo - tempo += 5; - if (tempo > 100) tempo = 100; //highest tempo 100 - Robot.fill(255, 190, 0); - Robot.rect(93, 58, 13, 13); - break; - case BUTTON_UP: - //up button pressed, increases pitch - pitch += 120; - if (pitch > 2000) pitch = 2000; - Robot.fill(0, 0, 255); - - Robot.rect(73, 38, 13, 13); - break; - case BUTTON_DOWN: - //down button pressed, reduces pitch - pitch -= 120; - if (pitch < 200) { - pitch = 200; - } - Robot.fill(0, 0, 255); - - Robot.rect(73, 78, 13, 13); - break; - case BUTTON_MIDDLE: - //middle button pressed, resets tempo and pitch - tempo = 60; - pitch = 1000; - Robot.fill(160, 160, 160); - - Robot.circle(79, 64, 6); - break; - case BUTTON_NONE: - //Only when the keys are released(thus BUTTON_NONE is - //encountered the first time), the interface will be - //re-drawn. - if (oldKey != BUTTON_NONE) { - renderUI(); - } - break; - } - if (oldKey != keyCode) { - // change the song's tempo - Robot.tempoWrite(tempo); - // change the song's pitch - Robot.tuneWrite(float(pitch / 1000.0)); - } - oldKey = keyCode; -} - -//Draw a circle according to value -//of the knob. -void drawKnob(int val) { - static int val_old; - int r = map(val, 0, 1023, 1, 15); - - //Only updates when the - //value changes. - if (val_old != r) { - Robot.noFill(); - - //erase the old circle - Robot.stroke(255, 255, 255); - Robot.circle(26, 116, r + 1); - - //draw the new circle - Robot.stroke(255, 0, 255); - Robot.circle(26, 116, r); - - Robot.stroke(0, 0, 0); - - val_old = r; - } -} diff --git a/doc/Robot_Control/examples/explore/R06_Wheel_Calibration/R06_Wheel_Calibration.ino b/doc/Robot_Control/examples/explore/R06_Wheel_Calibration/R06_Wheel_Calibration.ino @@ -1,40 +0,0 @@ -/* 6 Wheel Calibration -* -* Use this sketch to calibrate the wheels in your robot. -* Your robot should drive as straight as possible when -* putting both motors at the same speed. -* -* Run the software and follow the on-screen instructions. -* Use the trimmer on the bottom board to make sure the -* robot is working at its best! -* -* (c) 2013 X. Yang -*/ -#include "scripts_library.h" - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -void setup() { - Serial.begin(9600); - Robot.begin(); - Robot.beginTFT(); - Robot.beginSD(); - - Robot.setTextWrap(false); - Robot.displayLogos(); - - writeAllScripts(); - -} -void loop() { - int val = map(Robot.knobRead(), 0, 1023, -255, 255); - Serial.println(val); - Robot.motorsWrite(val, val); - - int WC = map(Robot.trimRead(), 0, 1023, -20, 20); - Robot.debugPrint(WC, 108, 149); - delay(40); - -} diff --git a/doc/Robot_Control/examples/explore/R06_Wheel_Calibration/scripts_library.h b/doc/Robot_Control/examples/explore/R06_Wheel_Calibration/scripts_library.h @@ -1,43 +0,0 @@ -#include <avr/pgmspace.h> -#include <ArduinoRobot.h> - -const char script1[] PROGMEM="Wheel Calibration\n"; -const char script2[] PROGMEM="1. Put Robot on a flat surface\n"; -const char script3[] PROGMEM="2. Adjust speed with the knob on top\n"; -const char script4[] PROGMEM="3. If robot goes straight, it's done\n"; -const char script5[] PROGMEM="4. Use screwdriver on the trim on bottom\n"; -const char script6[] PROGMEM="Robot turns left, screw it clockwise;\n"; -const char script7[] PROGMEM="Turns right, screw it ct-colockwise;\n"; -const char script8[] PROGMEM="5. Repeat 4 until going straight\n"; - -char buffer[42];//must be longer than text - -const char * const scripts[] PROGMEM = { - script1, - script2, - script3, - script4, - script5, - script6, - script7, - script8, -}; - -void getPGMtext(int seq){ - strcpy_P(buffer,(char*)pgm_read_word(&(scripts[seq]))); -} - -void writePGMtext(int seq){ - getPGMtext(seq); - Robot.print(buffer); -} - -void writeScript(int seq){ - writePGMtext(seq); -} - -void writeAllScripts(){ - for(int i=0;i<8;i++){ - writeScript(i); - } -} diff --git a/doc/Robot_Control/examples/explore/R07_Runaway_Robot/R07_Runaway_Robot.ino b/doc/Robot_Control/examples/explore/R07_Runaway_Robot/R07_Runaway_Robot.ino @@ -1,80 +0,0 @@ -/* Runaway Robot - - Play tag with your robot! With an ultrasonic - distance sensor, it's capable of detecting and avoiding - obstacles, never bumping into walls again! - - You'll need to attach an untrasonic range finder to M1. - - Circuit: - * Arduino Robot - * US range finder like Maxbotix EZ10, with analog output - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -// include the robot library -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -int sensorPin = M1; // pin is used by the sensor - -void setup() { - // initialize the Robot, SD card, and display - Serial.begin(9600); - Robot.begin(); - Robot.beginTFT(); - Robot.beginSD(); - Robot.displayLogos(); - - // draw a face on the LCD screen - setFace(true); -} - -void loop() { - // If the robot is blocked, turn until free - while (getDistance() < 40) { // If an obstacle is less than 20cm away - setFace(false); //shows an unhappy face - Robot.motorsStop(); // stop the motors - delay(1000); // wait for a moment - Robot.turn(90); // turn to the right and try again - setFace(true); // happy face - } - // if there are no objects in the way, keep moving - Robot.motorsWrite(255, 255); - delay(100); -} - -// return the distance in cm -float getDistance() { - // read the value from the sensor - int sensorValue = Robot.analogRead(sensorPin); - //Convert the sensor input to cm. - float distance_cm = sensorValue * 1.27; - return distance_cm; -} - -// make a happy or sad face -void setFace(boolean onOff) { - if (onOff) { - // if true show a happy face - Robot.background(0, 0, 255); - Robot.setCursor(44, 60); - Robot.stroke(0, 255, 0); - Robot.setTextSize(4); - Robot.print(":)"); - } else { - // if false show an upset face - Robot.background(255, 0, 0); - Robot.setCursor(44, 60); - Robot.stroke(0, 255, 0); - Robot.setTextSize(4); - Robot.print("X("); - } -} diff --git a/doc/Robot_Control/examples/explore/R08_Remote_Control/R08_Remote_Control.ino b/doc/Robot_Control/examples/explore/R08_Remote_Control/R08_Remote_Control.ino @@ -1,93 +0,0 @@ -/* 08 Remote Control - - If you connect a IR receiver to the robot, - you can control it like a RC car. - Using the remote control comes with sensor - pack, You can make the robot move around - without even touching it! - - Circuit: - * Arduino Robot - * Connect the IRreceiver to D2 - * Remote control from Robot sensor pack - - based on the IRremote library - by Ken Shirriff - http://arcfn.com - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -// include the necessary libraries -#include <IRremote.h> -#include <IRremoteTools.h> -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -// Define a few commands from your remote control -#define IR_CODE_FORWARD 284154405 -#define IR_CODE_BACKWARDS 284113605 -#define IR_CODE_TURN_LEFT 284129925 -#define IR_CODE_TURN_RIGHT 284127885 -#define IR_CODE_CONTINUE -1 - -boolean isActing = false; //If the robot is executing command from remote -long timer; -const long TIME_OUT = 150; - -void setup() { - // initialize the Robot, SD card, display, and speaker - Serial.begin(9600); - Robot.begin(); - Robot.beginTFT(); - Robot.beginSD(); - - // print some text to the screen - beginIRremote(); // Start the receiver -} - -void loop() { - // if there is an IR command, process it - if (IRrecived()) { - processResult(); - resumeIRremote(); // resume receiver - } - - //If the robot does not receive any command, stop it - if (isActing && (millis() - timer >= TIME_OUT)) { - Robot.motorsStop(); - isActing = false; - } -} -void processResult() { - unsigned long res = getIRresult(); - switch (res) { - case IR_CODE_FORWARD: - changeAction(1, 1); //Move the robot forward - break; - case IR_CODE_BACKWARDS: - changeAction(-1, -1); //Move the robot backwards - break; - case IR_CODE_TURN_LEFT: - changeAction(-0.5, 0.5); //Turn the robot left - break; - case IR_CODE_TURN_RIGHT: - changeAction(0.5, -0.5); //Turn the robot Right - break; - case IR_CODE_CONTINUE: - timer = millis(); //Continue the last action, reset timer - break; - } -} -void changeAction(float directionLeft, float directionRight) { - Robot.motorsWrite(255 * directionLeft, 255 * directionRight); - timer = millis(); - isActing = true; -} - diff --git a/doc/Robot_Control/examples/explore/R09_Picture_Browser/R09_Picture_Browser.ino b/doc/Robot_Control/examples/explore/R09_Picture_Browser/R09_Picture_Browser.ino @@ -1,161 +0,0 @@ -/* Picture Browser - - You can make your own gallery/picture show with the - Robot. Put some pictures on the SD card, start the - sketch, they will diplay on the screen. - - Use the left/right buttons to navigate through the - previous and next images. - - Press up or down to enter a mode where you change - the pictures by rotating the robot. - - You can add your own pictures onto the SD card, and - view them in the Robot's gallery! - - Pictures must be uncompressed BMP, 24-bit color depth, - 160 pixels wide, and 128 pixels tall. - - They should be named as "picN.bmp". Replace 'N' with a - number between 0 and 9. - - The current code only supports 10 pictures. How would you - improve it to handle more? - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> // include the robot library -#include <Wire.h> -#include <SPI.h> - -const int NUM_PICS = 4; //Total number of pictures in Gallery - -// name the modes -const int CONTROL_MODE_KEY = 0; -const int CONTROL_MODE_COMPASS = 1; - -char buffer[] = "pic1.bmp"; // current file name -int i = 1; // Current gallery sequence counter -int mode = 0; // Current mode - -// text to display on screen -char modeNames[][9] = { "keyboard", "tilt " }; - -void setup() { - // initialize the Robot, SD card, display, and speaker - Robot.beginSD(); - Robot.beginTFT(); - Robot.begin(); - - // draw "lg0.bmp" and "lg1.bmp" on the screen - Robot.displayLogos(); - - // draw init3.bmp from the SD card on the screen - Robot.drawBMP("init3.bmp", 0, 0); - - // display instructions - Robot.stroke(0, 0, 0); - Robot.text("The gallery\n\n has 2 modes, in\n keyboard mode, L/R\n key for switching\n pictures, U/D key\n for changing modes", 5, 5); - delay(6000); - Robot.clearScreen(); - Robot.drawBMP("pb.bmp", 0, 0); - Robot.text("In tilt mode,\n quickly tilt the\n robot to switch\n pictures", 5, 5); - delay(4000); -} - -void loop() { - buffer[3] = '0' + i; // change filename of the img to be displayed - Robot.drawBMP(buffer, 0, 0); // draw the file on the screen - // change control modes - switch (mode) { - case CONTROL_MODE_COMPASS: - compassControl(3); - break; - case CONTROL_MODE_KEY: - keyboardControl(); - break; - } - delay(200); -} - -void keyboardControl() { - //Use buttons to control the gallery - while (true) { - int keyPressed = Robot.keyboardRead(); // read the button values - switch (keyPressed) { - case BUTTON_LEFT: // display previous picture - if (--i < 1) i = NUM_PICS; - return; - case BUTTON_MIDDLE: // do nothing - case BUTTON_RIGHT: // display next picture - if (++i > NUM_PICS) i = 1; - return; - case BUTTON_UP: // change mode - changeMode(-1); - return; - case BUTTON_DOWN: // change mode - changeMode(1); - return; - } - } -} - -// if controlling by the compass -void compassControl(int change) { - // Rotate the robot to change the pictures - while (true) { - // read the value of the compass - int oldV = Robot.compassRead(); - - //get the change of angle - int diff = Robot.compassRead() - oldV; - if (diff > 180) diff -= 360; - else if (diff < -180) diff += 360; - - if (abs(diff) > change) { - if (++i > NUM_PICS) i = 1; - return; - } - - // chage modes, if buttons are pressed - int keyPressed = Robot.keyboardRead(); - switch (keyPressed) { - case BUTTON_UP: - changeMode(-1); - return; - case BUTTON_DOWN: - changeMode(1); - return; - } - delay(10); - } -} - -// Change the control mode and display it on the LCD -void changeMode(int changeDir) { - // alternate modes - mode += changeDir; - if (mode < 0) { - mode = 1; - } else if (mode > 1) - mode = 0; - - // display the mode on screen - Robot.fill(255, 255, 255); - Robot.stroke(255, 255, 255); - Robot.rect(0, 0, 128, 12); - Robot.stroke(0, 0, 0); - Robot.text("Control:", 2, 2); - Robot.text(modeNames[mode], 52, 2); - delay(1000); -} - diff --git a/doc/Robot_Control/examples/explore/R10_Rescue/R10_Rescue.ino b/doc/Robot_Control/examples/explore/R10_Rescue/R10_Rescue.ino @@ -1,121 +0,0 @@ -/* Robot Rescue - - In this example, the robot enters the line following mode and - plays some music until it reaches its target. Once it finds the - target, it pushes it out of the track. It then returns to the - track and looks for a second target. - - You can make the robot push as many objects as you want to, just - add more to calls to the rescue function or even move that code - into the loop. - - Circuit: - * Arduino Robot - * some objects for the robot to push - * a line-following circuit - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> // include the robot library -#include <Wire.h> -#include <SPI.h> - -void setup() { - // initialize the Robot, SD card, display, and speaker - Robot.begin(); - Robot.beginTFT(); - Robot.beginSD(); - Robot.beginSpeaker(); - - // draw "lg0.bmp" and "lg1.bmp" on the screen - Robot.displayLogos(); - - // display the line following instructional image from the SD card - Robot.drawBMP("lf.bmp", 0, 0); - - // play the chase music file - Robot.playFile("chase.sqm"); - - // add the instructions - Robot.text("Rescue\n\n place the robot on\n the rescue track\n pushing the\n obstacles away", 5, 5); - Robot.text("Press the middle\n button to start...", 5, 61); - Robot.waitContinue(); - - // start - Robot.fill(255, 255, 255); - Robot.stroke(255, 255, 255); - Robot.rect(0, 0, 128, 80); // erase the previous text - Robot.stroke(0, 0, 0); - Robot.text("Start", 5, 5); - - // use this to calibrate the line following algorithm - // uncomment one or the other to see the different behaviors of the robot - // Robot.lineFollowConfig(14, 9, 50, 10); - Robot.lineFollowConfig(11, 7, 60, 5); - - // run the rescue sequence - rescueSequence(); - // find the track again - goToNext(); - // run the rescue sequence a second time - rescueSequence(); - - // here you could go on ... - - -} - -void loop() { - //nothing here, the program only runs once. -} - -// run the sequence -void rescueSequence() { - //set the motor board into line-follow mode - Robot.setMode(MODE_LINE_FOLLOW); - - while (!Robot.isActionDone()) { // wait until it is no longer following the line - } - delay(1000); - - // do the rescue operation - doRescue(); - delay(1000); -} - -void doRescue() { - // Reached the endline, engage the target - Robot.motorsWrite(200, 200); - delay(250); - Robot.motorsStop(); - delay(1000); - - // Turn the robot - Robot.turn(90); - Robot.motorsStop(); - delay(1000); - - // Move forward - Robot.motorsWrite(200, 200); - delay(500); - Robot.motorsStop(); - delay(1000); - - // move backwards, leave the target - Robot.motorsWrite(-200, -200); - delay(500); - Robot.motorsStop(); -} - -void goToNext() { - // Turn the robot - Robot.turn(-90); - Robot.motorsStop(); - delay(1000); -} diff --git a/doc/Robot_Control/examples/explore/R11_Hello_User/R11_Hello_User.ino b/doc/Robot_Control/examples/explore/R11_Hello_User/R11_Hello_User.ino @@ -1,180 +0,0 @@ -/* Hello User - - Hello User! This sketch is the first thing you see - when starting this robot. It gives you a warm welcome, - showing you some of the really amazing abilities of - the robot, and make itself really personal to you. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> // include the robot library -#include <Wire.h> -#include <SPI.h> - -// include the utility function for ths sketch -// see the details below -#include <utility/RobotTextManager.h> - -char buffer[20];//for storing user name - -void setup() { - //necessary initialization sequence - Robot.begin(); - Robot.beginTFT(); - Robot.beginSD(); - - // show the logos from the SD card - Robot.displayLogos(); - - // clear the screen - Robot.clearScreen(); - - // From now on, display different slides of - // text/pictures in sequence. The so-called - // scripts are strings of text stored in the - // robot's memory - - // these functions are explained below - - //Script 6 - textManager.writeScript(5, 4, 0); - textManager.writeScript(9, 10, 0); - Robot.waitContinue(); - delay(500); - Robot.clearScreen(); - - //Script 7 - textManager.writeScript(6, 4, 0); - textManager.writeScript(9, 10, 0); - Robot.waitContinue(); - delay(500); - Robot.clearScreen(); - - //Script 8 - // this function enables sound and images at once - textManager.showPicture("init2.bmp", 0, 0); - - textManager.writeScript(7, 2, 0); - textManager.writeScript(9, 7, 0); - Robot.waitContinue(); - delay(500); - Robot.clearScreen(); - - //Script 9 - textManager.showPicture("init3.bmp", 0, 0); - textManager.writeScript(8, 2, 0); - textManager.writeScript(9, 7, 0); - Robot.waitContinue(); - delay(500); - Robot.clearScreen(); - - //Script 11 - textManager.writeScript(10, 4, 0); - textManager.writeScript(9, 10, 0); - Robot.waitContinue(); - delay(500); - Robot.clearScreen(); - - //Input screen - textManager.writeScript(0, 1, 1); - textManager.input(3, 1, USERNAME); - - textManager.writeScript(1, 5, 1); - textManager.input(7, 1, ROBOTNAME); - - delay(1000); - Robot.clearScreen(); - - //last screen - textManager.showPicture("init4.bmp", 0, 0); - textManager.writeText(1, 2, "Hello"); - Robot.userNameRead(buffer); - textManager.writeText(3, 2, buffer); - - textManager.writeScript(4, 10, 0); - - Robot.waitContinue(BUTTON_LEFT); - Robot.waitContinue(BUTTON_RIGHT); - textManager.showPicture("kt1.bmp", 0, 0); -} - -void loop() { - // do nothing here -} - - -/** -textManager mostly contains helper functions for -R06_Wheel_Calibration and R01_Hello_User. - -The ones used in this example: - textManager.setMargin(margin_left, margin_top): - Configure the left and top margin for text - display. The margins will be used for - textManager.writeText(). - Parameters: - margin_left, margin_top: the margin values - from the top and left side of the screen. - Returns: - none - - textManager.writeScript(script_number,line,column): - Display a script of Hello User example. - Parameters: - script_number: an int value representing the - script to be displayed. - line, column: in which line,column is the script - displayed. Same as writeText(). - Returns: - none - - textManager.input(line,column,codename): - Print an input indicator(">") in the line and column, - dispaly and receive input from a virtual keyboard, - and save the value into EEPROM represented by codename - Parameters: - line,column: int values represents where the input - starts. Same as wirteText(). - codename: either USERNAME,ROBOTNAME,CITYNAME or - COUNTRYNAME. You can call Robot.userNameRead(), - robotNameRead(),cityNameRead() or countryNameRead() - to access the values later. - Returns: - none; - - textManager.writeText(line,column,text): - Display text on the specific line and column. - It's different from Robot.text() as the later - uses pixels for positioning the text. - Parameters: - line:in which line is the text displayed. Each line - is 10px high. - column:in which column is the text displayed. Each - column is 8px wide. - text:a char array(string) of the text to be displayed. - Returns: - none - - textManager.showPicture(filename, x, y): - It has the same functionality as Robot.drawPicture(), - while fixing the conflict between drawPicture() and - sound playing. Using Robot.drawPicture(), it'll have - glitches when playing sound at the same time. Using - showPicture(), it'll stop sound when displaying - picture, so preventing the problem. - Parameters: - filename:string, name of the bmp file in sd - x,y: int values, position of the picture - Returns: - none - -*/ diff --git a/doc/Robot_Control/examples/learn/AllIOPorts/AllIOPorts.ino b/doc/Robot_Control/examples/learn/AllIOPorts/AllIOPorts.ino @@ -1,151 +0,0 @@ -/* - All IO Ports - - This example goes through all the IO ports on your robot and - reads/writes from/to them. Uncomment the different lines inside - the loop to test the different possibilities. - - The M inputs on the Control Board are multiplexed and therefore - it is not recommended to use them as outputs. The D pins on the - Control Board as well as the D pins on the Motor Board go directly - to the microcontroller and therefore can be used both as inputs - and outputs. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -// use arrays to store the names of the pins to be read -uint8_t arr[] = { M0, M1, M2, M3, M4, M5, M6, M7 }; -uint8_t arr2[] = { D0, D1, D2, D3, D4, D5 }; -uint8_t arr3[] = { D7, D8, D9, D10 }; - -void setup() { - // initialize the robot - Robot.begin(); - - // open the serial port to send the information of what you are reading - Serial.begin(9600); -} - -void loop() { - // read all the D inputs at the Motor Board as analog - //analogReadB_Ds(); - - // read all the D inputs at the Motor Board as digital - //digitalReadB_Ds(); - - // read all the M inputs at the Control Board as analog - //analogReadMs(); - - // read all the M inputs at the Control Board as digital - //digitalReadMs(); - - // read all the D inputs at the Control Board as analog - analogReadT_Ds(); - - // read all the D inputs at the Control Board as digital - //digitalReadT_Ds(); - - // write all the D outputs at the Motor Board as digital - //digitalWriteB_Ds(); - - // write all the D outputs at the Control Board as digital - //digitalWriteT_Ds(); - delay(40); -} - -// read all M inputs on the Control Board as analog inputs -void analogReadMs() { - for (int i = 0; i < 8; i++) { - Serial.print(Robot.analogRead(arr[i])); - Serial.print(","); - } - Serial.println(""); -} - -// read all M inputs on the Control Board as digital inputs -void digitalReadMs() { - for (int i = 0; i < 8; i++) { - Serial.print(Robot.digitalRead(arr[i])); - Serial.print(","); - } - Serial.println(""); -} - -// read all D inputs on the Control Board as analog inputs -void analogReadT_Ds() { - for (int i = 0; i < 6; i++) { - Serial.print(Robot.analogRead(arr2[i])); - Serial.print(","); - } - Serial.println(""); -} - -// read all D inputs on the Control Board as digital inputs -void digitalReadT_Ds() { - for (int i = 0; i < 6; i++) { - Serial.print(Robot.digitalRead(arr2[i])); - Serial.print(","); - } - Serial.println(""); -} - -// write all D outputs on the Control Board as digital outputs -void digitalWriteT_Ds() { - // turn all the pins on - for (int i = 0; i < 6; i++) { - Robot.digitalWrite(arr2[i], HIGH); - } - delay(500); - - // turn all the pins off - for (int i = 0; i < 6; i++) { - Robot.digitalWrite(arr2[i], LOW); - } - delay(500); -} - -// write all D outputs on the Motor Board as digital outputs -void digitalWriteB_Ds() { - // turn all the pins on - for (int i = 0; i < 4; i++) { - Robot.digitalWrite(arr3[i], HIGH); - } - delay(500); - - // turn all the pins off - for (int i = 0; i < 4; i++) { - Robot.digitalWrite(arr3[i], LOW); - } - delay(500); -} - -// read all D inputs on the Motor Board as analog inputs -void analogReadB_Ds() { - for (int i = 0; i < 4; i++) { - Serial.print(Robot.analogRead(arr3[i])); - Serial.print(","); - } - Serial.println(""); -} - -// read all D inputs on the Motor Board as digital inputs -void digitalReadB_Ds() { - for (int i = 0; i < 4; i++) { - Serial.print(Robot.digitalRead(arr3[i])); - Serial.print(","); - } - Serial.println(""); -} diff --git a/doc/Robot_Control/examples/learn/Beep/Beep.ino b/doc/Robot_Control/examples/learn/Beep/Beep.ino @@ -1,41 +0,0 @@ -/* - Beep - - Test different pre-configured beeps on - the robot's speaker. - - Possible beeps are: - - BEEP_SIMPLE - - BEEP_DOUBLE - - BEEP_LONG - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -void setup() { - // initialize the robot - Robot.begin(); - - // initialize the sound speaker - Robot.beginSpeaker(); -} -void loop() { - Robot.beep(BEEP_SIMPLE); - delay(1000); - Robot.beep(BEEP_DOUBLE); - delay(1000); - Robot.beep(BEEP_LONG); - delay(1000); -} diff --git a/doc/Robot_Control/examples/learn/CleanEEPROM/CleanEEPROM.ino b/doc/Robot_Control/examples/learn/CleanEEPROM/CleanEEPROM.ino @@ -1,43 +0,0 @@ -/* - Clean EEPROM - - This example erases the user information stored on the - external EEPROM memory chip on your robot. - - BEWARE, this will erase the following information: - - your name - - your robots name given by you - - your city and country if you configured them via software - - EEPROMs shouldn't be rewritten too often, therefore the - code runs only during setup and not inside loop. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -void setup() { - // initialize the robot - Robot.begin(); - - // write empty strings for the different fields - Robot.userNameWrite(""); - Robot.robotNameWrite(""); - Robot.cityNameWrite(""); - Robot.countryNameWrite(""); -} - -void loop() { - // do nothing -} diff --git a/doc/Robot_Control/examples/learn/Compass/Compass.ino b/doc/Robot_Control/examples/learn/Compass/Compass.ino @@ -1,43 +0,0 @@ -/* - Compass - - Try the compass both on the robot's TFT - and through the serial port. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -void setup() { - // initialize the robot - Robot.begin(); - - // initialize the robot's screen - Robot.beginTFT(); - - // initialize the serial port - Serial.begin(9600); -} - -void loop() { - // read the compass - int compass = Robot.compassRead(); - - // print out the sensor's value - Serial.println(compass); - - // show the value on the robot's screen - Robot.drawCompass(compass); -} - diff --git a/doc/Robot_Control/examples/learn/IRArray/IRArray.ino b/doc/Robot_Control/examples/learn/IRArray/IRArray.ino @@ -1,46 +0,0 @@ -/* - IR array - - Read the analog value of the IR sensors at the - bottom of the robot. The also-called line following - sensors are a series of pairs of IR sender/receiver - used to detect how dark it is underneath the robot. - - The information coming from the sensor array is stored - into the Robot.IRarray[] and updated using the Robot.updateIR() - method. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -void setup() { - // initialize the robot - Robot.begin(); - - // initialize the serial port - Serial.begin(9600); -} - -void loop() { - // store the sensor information into the array - Robot.updateIR(); - - // iterate the array and print the data to the Serial port - for (int i = 0; i < 5; i++) { - Serial.print(Robot.IRarray[i]); - Serial.print(" "); - } - Serial.println(""); -} diff --git a/doc/Robot_Control/examples/learn/LCDDebugPrint/LCDDebugPrint.ino b/doc/Robot_Control/examples/learn/LCDDebugPrint/LCDDebugPrint.ino @@ -1,39 +0,0 @@ -/* - LCD Debug Print - - Use the Robot's library function debugPrint() to - quickly send a sensor reading to the robot's creen. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -int value; - -void setup() { - // initialize the robot - Robot.begin(); - - // initialize the screen - Robot.beginTFT(); -} -void loop() { - // read a value - value = analogRead(A4); - - // send the value to the screen - Robot.debugPrint(value); - - delay(40); -} diff --git a/doc/Robot_Control/examples/learn/LCDPrint/LCDPrint.ino b/doc/Robot_Control/examples/learn/LCDPrint/LCDPrint.ino @@ -1,46 +0,0 @@ -/* - LCD Print - - Print the reading from a sensor to the screen. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -int value; - -void setup() { - // initialize the robot - Robot.begin(); - - // initialize the robot's screen - Robot.beginTFT(); -} - -void loop() { - // read a analog port - value = Robot.analogRead(TK4); - - // write the sensor value on the screen - Robot.stroke(0, 255, 0); - Robot.textSize(1); - Robot.text(value, 0, 0); - - delay(500); - - // erase the previous text on the screen - Robot.stroke(255, 255, 255); - Robot.textSize(1); - Robot.text(value, 0, 0); -} diff --git a/doc/Robot_Control/examples/learn/LCDWriteText/LCDWriteText.ino b/doc/Robot_Control/examples/learn/LCDWriteText/LCDWriteText.ino @@ -1,43 +0,0 @@ -/* - LCD Write Text - - Use the Robot's library function text() to - print out text to the robot's screen. Take - into account that you need to erase the - information before continuing writing. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -void setup() { - // initialize the robot - Robot.begin(); - - // initialize the screen - Robot.beginTFT(); -} -void loop() { - Robot.stroke(0, 0, 0); // choose the color black - Robot.text("Hello World", 0, 0); // print the text - delay(2000); - Robot.stroke(255, 255, 255); // choose the color white - Robot.text("Hello World", 0, 0); // writing text in the same color as the BG erases the text! - - Robot.stroke(0, 0, 0); // choose the color black - Robot.text("I am a robot", 0, 0); // print the text - delay(3000); - Robot.stroke(255, 255, 255); // choose the color black - Robot.text("I am a robot", 0, 0); // print the text -} diff --git a/doc/Robot_Control/examples/learn/LineFollowWithPause/LineFollowWithPause.ino b/doc/Robot_Control/examples/learn/LineFollowWithPause/LineFollowWithPause.ino @@ -1,51 +0,0 @@ -/* - Line Following with Pause - - As the robot has two processors, one to command the motors and one to - take care of the screen and user input, it is possible to write - programs that put one part of the robot to do something and get the - other half to control it. - - This example shows how the Control Board assigns the Motor one to - follow a line, but asks it to stop every 3 seconds. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -void setup() { - // initialize the robot - Robot.begin(); - - // initialize the screen - Robot.beginTFT(); - - // get some time to place the robot on the ground - delay(3000); - - // set the robot in line following mode - Robot.setMode(MODE_LINE_FOLLOW); -} - -void loop() { - // tell the robot to take a break and stop - Robot.pauseMode(true); - Robot.debugPrint('p'); - delay(3000); - - // tell the robot to move on - Robot.pauseMode(false); - Robot.debugPrint('>'); - delay(3000); -} diff --git a/doc/Robot_Control/examples/learn/Melody/Melody.ino b/doc/Robot_Control/examples/learn/Melody/Melody.ino @@ -1,64 +0,0 @@ -/* - Melody - - Plays a melody stored in a string. - - The notes and durations are encoded as follows: - - NOTES: - c play "C" - C play "#C" - d play "D" - D play "#D" - e play "E" - f play "F" - F play "#F" - g play "G" - G play "#G" - a play "A" - A play "#A" - b play "B" - - silence - - DURATIONS: - 1 Set as full note - 2 Set as half note - 4 Set as quarter note - 8 Set as eigth note - - SPECIAL NOTATION: - . Make the previous note 3/4 the length - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - - This code uses the Squawk sound library designed by STG. For - more information about it check: http://github.com/stg/squawk - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -void setup() { - // initialize the robot - Robot.begin(); - - // initialize the sound library - Robot.beginSpeaker(); -} - -void loop() { - // array containing the melody - char aTinyMelody[] = "8eF-FFga4b.a.g.F.8beee-d2e.1-"; - - // play the melody - Robot.playMelody(aTinyMelody); -} diff --git a/doc/Robot_Control/examples/learn/MotorTest/MotorTest.ino b/doc/Robot_Control/examples/learn/MotorTest/MotorTest.ino @@ -1,43 +0,0 @@ -/* - Motor Test - - Just see if the robot can move and turn. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -void setup() { - // initialize the robot - Robot.begin(); -} - -void loop() { - Robot.motorsWrite(255, 255); // move forward - delay(2000); - Robot.motorsStop(); // fast stop - delay(1000); - Robot.motorsWrite(-255, -255); // backward - delay(1000); - Robot.motorsWrite(0, 0); // slow stop - delay(1000); - Robot.motorsWrite(-255, 255); // turn left - delay(2000); - Robot.motorsStop(); // fast stop - delay(1000); - Robot.motorsWrite(255, -255); // turn right - delay(2000); - Robot.motorsStop(); // fast stop - delay(1000); -} diff --git a/doc/Robot_Control/examples/learn/SpeedByPotentiometer/SpeedByPotentiometer.ino b/doc/Robot_Control/examples/learn/SpeedByPotentiometer/SpeedByPotentiometer.ino @@ -1,41 +0,0 @@ -/* - Speed by Potentiometer - - Control the robot's speed using the on-board - potentiometer. The speed will be printed on - the TFT screen. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -void setup() { - // initialize the robot - Robot.begin(); - - // initialize the screen - Robot.beginTFT(); -} - -void loop() { - // read the value of the potentiometer - int val = map(Robot.knobRead(), 0, 1023, -255, 255); - - // print the value to the TFT screen - Robot.debugPrint(val); - - // set the same speed on both of the robot's wheels - Robot.motorsWrite(val, val); - delay(10); -} diff --git a/doc/Robot_Control/examples/learn/TurnTest/TurnTest.ino b/doc/Robot_Control/examples/learn/TurnTest/TurnTest.ino @@ -1,34 +0,0 @@ -/* - Turn Test - - Check if the robot turns a certain amount of degrees. - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -void setup() { - // initialize the robot - Robot.begin(); -} - -void loop() { - Robot.turn(50); //turn 50 degrees to the right - Robot.motorsStop(); - delay(1000); - - Robot.turn(-100); //turn 100 degrees to the left - Robot.motorsStop(); - delay(1000); -} diff --git a/doc/Robot_Control/examples/learn/keyboardTest/keyboardTest.ino b/doc/Robot_Control/examples/learn/keyboardTest/keyboardTest.ino @@ -1,40 +0,0 @@ -/* - Keyboard Test - - Check how the robot's keyboard works. This example - sends the data about the key pressed through the - serial port. - - All the buttons on the Control Board are tied up to a - single analog input pin, in this way it is possible to multiplex a - whole series of buttons on one single pin. - - It is possible to recalibrate the thresholds of the buttons using - the Robot.keyboardCalibrate() function, that takes a 5 ints long - array as parameter - - Circuit: - * Arduino Robot - - created 1 May 2013 - by X. Yang - modified 12 May 2013 - by D. Cuartielles - - This example is in the public domain - */ - -#include <ArduinoRobot.h> -#include <Wire.h> -#include <SPI.h> - -void setup() { - // initialize the serial port - Serial.begin(9600); -} - -void loop() { - // print out the keyboard readings - Serial.println(Robot.keyboardRead()); - delay(100); -} diff --git a/doc/Robot_Motor/README.adoc b/doc/Robot_Motor/README.adoc @@ -1,24 +0,0 @@ -= Robot Motor Library for Arduino = - -The Robot has a number of built in sensors and actuators. The library is designed to easily access the robot's functionality. - -For more information about this library please visit us at -http://www.arduino.cc/en/Reference/RobotLibrary - -== License == - -Copyright (c) Arduino LLC. All right reserved. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/doc/Robot_Motor/examples/Robot_IR_Array_Test/Robot_IR_Array_Test.ino b/doc/Robot_Motor/examples/Robot_IR_Array_Test/Robot_IR_Array_Test.ino @@ -1,26 +0,0 @@ -/* Motor Board IR Array Test - - This example of the Arduno robot's motor board returns the - values read fron the 5 infrared sendors on the bottom of - the robot. - -*/ -// include the motor board header -#include <ArduinoRobotMotorBoard.h> - -String bar; // string for storing the informaton - -void setup() { - // start serial communication - Serial.begin(9600); - // initialize the library - RobotMotor.begin(); -} -void loop() { - bar = String(""); // empty the string - // read the sensors and add them to the string - bar = bar + RobotMotor.IRread(1) + ' ' + RobotMotor.IRread(2) + ' ' + RobotMotor.IRread(3) + ' ' + RobotMotor.IRread(4) + ' ' + RobotMotor.IRread(5); - // print out the values - Serial.println(bar); - delay(100); -} diff --git a/doc/Robot_Motor/examples/Robot_Motor_Core/Robot_Motor_Core.ino b/doc/Robot_Motor/examples/Robot_Motor_Core/Robot_Motor_Core.ino @@ -1,18 +0,0 @@ -/* Motor Core - - This code for the Arduino Robot's motor board - is the stock firmware. program the motor board with - this sketch whenever you want to return the motor - board to its default state. - -*/ - -#include <ArduinoRobotMotorBoard.h> - -void setup() { - RobotMotor.begin(); -} -void loop() { - RobotMotor.parseCommand(); - RobotMotor.process(); -} diff --git a/doc/SpacebrewYun/README.adoc b/doc/SpacebrewYun/README.adoc @@ -1,21 +0,0 @@ -= Spacebrew Library for Arduino = - -This library allows an Arduino Yun to connect to the Spacebrew service. - -== License == - -Copyright (c) Arduino LLC. All right reserved. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/doc/SpacebrewYun/examples/inputOutput/inputOutput.ino b/doc/SpacebrewYun/examples/inputOutput/inputOutput.ino @@ -1,134 +0,0 @@ -/* - Input Output - - Demonstrates how to create a sketch that sends and receives all standard - spacebrew data types, and a custom data type. Every time data is - received it is output to the Serial monitor. - - Make sure that your Yún is connected to the internet for this example - to function properly. - - The circuit: - - No circuit required - - created 2013 - by Julio Terra - - This example code is in the public domain. - - More information about Spacebrew is available at: - http://spacebrew.cc/ - - */ - -#include <Bridge.h> -#include <SpacebrewYun.h> - -// create a variable of type SpacebrewYun and initialize it with the constructor -SpacebrewYun sb = SpacebrewYun("aYun", "Arduino Yun spacebrew test"); - -// create variables to manage interval between each time we send a string -long last = 0; -int interval = 2000; - -int counter = 0; - -void setup() { - - // start the serial port - SerialUSB.begin(57600); - - // for debugging, wait until a serial console is connected - delay(4000); - while (!SerialUSB) { - ; - } - - // start-up the bridge - Bridge.begin(); - - // configure the spacebrew object to print status messages to serial - sb.verbose(true); - - // configure the spacebrew publisher and subscriber - sb.addPublish("string test", "string"); - sb.addPublish("range test", "range"); - sb.addPublish("boolean test", "boolean"); - sb.addPublish("custom test", "crazy"); - sb.addSubscribe("string test", "string"); - sb.addSubscribe("range test", "range"); - sb.addSubscribe("boolean test", "boolean"); - sb.addSubscribe("custom test", "crazy"); - - // register the string message handler method - sb.onRangeMessage(handleRange); - sb.onStringMessage(handleString); - sb.onBooleanMessage(handleBoolean); - sb.onCustomMessage(handleCustom); - - // connect to cloud spacebrew server at "sandbox.spacebrew.cc" - sb.connect("sandbox.spacebrew.cc"); - // we give some time to arduino to connect to sandbox, otherwise the first sb.monitor(); call will give an error - delay(1000); -} - - -void loop() { - // monitor spacebrew connection for new data - sb.monitor(); - - // connected to spacebrew then send a string every 2 seconds - if (sb.connected()) { - - // check if it is time to send a new message - if ((millis() - last) > interval) { - String test_str_msg = "testing, testing, "; - test_str_msg += counter; - counter ++; - - sb.send("string test", test_str_msg); - sb.send("range test", 500); - sb.send("boolean test", true); - sb.send("custom test", "youre loco"); - - last = millis(); - - } - } - delay(1000); -} - -// define handler methods, all standard data type handlers take two appropriate arguments - -void handleRange(String route, int value) { - SerialUSB.print("Range msg "); - SerialUSB.print(route); - SerialUSB.print(", value "); - SerialUSB.println(value); -} - -void handleString(String route, String value) { - SerialUSB.print("String msg "); - SerialUSB.print(route); - SerialUSB.print(", value "); - SerialUSB.println(value); -} - -void handleBoolean(String route, boolean value) { - SerialUSB.print("Boolen msg "); - SerialUSB.print(route); - SerialUSB.print(", value "); - SerialUSB.println(value ? "true" : "false"); -} - -// custom data type handlers takes three String arguments - -void handleCustom(String route, String value, String type) { - SerialUSB.print("Custom msg "); - SerialUSB.print(route); - SerialUSB.print(" of type "); - SerialUSB.print(type); - SerialUSB.print(", value "); - SerialUSB.println(value); -} - diff --git a/doc/SpacebrewYun/examples/spacebrewBoolean/spacebrewBoolean.ino b/doc/SpacebrewYun/examples/spacebrewBoolean/spacebrewBoolean.ino @@ -1,94 +0,0 @@ -/* - Spacebrew Boolean - - Demonstrates how to create a sketch that sends and receives a - boolean value to and from Spacebrew. Every time the buttton is - pressed (or other digital input component) a spacebrew message - is sent. The sketch also accepts analog range messages from - other Spacebrew apps. - - Make sure that your Yún is connected to the internet for this example - to function properly. - - The circuit: - - Button connected to Yún, using the Arduino's internal pullup resistor. - - created 2013 - by Julio Terra - - This example code is in the public domain. - - More information about Spacebrew is available at: - http://spacebrew.cc/ - - */ - -#include <Bridge.h> -#include <SpacebrewYun.h> - -// create a variable of type SpacebrewYun and initialize it with the constructor -SpacebrewYun sb = SpacebrewYun("spacebrewYun Boolean", "Boolean sender and receiver"); - -// variable that holds the last potentiometer value -int last_value = 0; - -// create variables to manage interval between each time we send a string -void setup() { - - // start the serial port - SerialUSB.begin(57600); - - // for debugging, wait until a serial console is connected - delay(4000); - while (!SerialUSB) { - ; - } - - // start-up the bridge - Bridge.begin(); - - // configure the spacebrew object to print status messages to serial - sb.verbose(true); - - // configure the spacebrew publisher and subscriber - sb.addPublish("physical button", "boolean"); - sb.addSubscribe("virtual button", "boolean"); - - // register the string message handler method - sb.onBooleanMessage(handleBoolean); - - // connect to cloud spacebrew server at "sandbox.spacebrew.cc" - sb.connect("sandbox.spacebrew.cc"); - - pinMode(3, INPUT); - digitalWrite(3, HIGH); -} - - -void loop() { - // monitor spacebrew connection for new data - sb.monitor(); - - // connected to spacebrew then send a new value whenever the pot value changes - if (sb.connected()) { - int cur_value = digitalRead(3); - if (last_value != cur_value) { - if (cur_value == HIGH) { - sb.send("physical button", false); - } else { - sb.send("physical button", true); - } - last_value = cur_value; - } - } -} - -// handler method that is called whenever a new string message is received -void handleBoolean(String route, boolean value) { - // print the message that was received - SerialUSB.print("From "); - SerialUSB.print(route); - SerialUSB.print(", received msg: "); - SerialUSB.println(value ? "true" : "false"); -} - diff --git a/doc/SpacebrewYun/examples/spacebrewRange/spacebrewRange.ino b/doc/SpacebrewYun/examples/spacebrewRange/spacebrewRange.ino @@ -1,88 +0,0 @@ -/* - Spacebrew Range - - Demonstrates how to create a sketch that sends and receives analog - range value to and from Spacebrew. Every time the state of the - potentiometer (or other analog input component) change a spacebrew - message is sent. The sketch also accepts analog range messages from - other Spacebrew apps. - - Make sure that your Yún is connected to the internet for this example - to function properly. - - The circuit: - - Potentiometer connected to Yún. Middle pin connected to analog pin A0, - other pins connected to 5v and GND pins. - - created 2013 - by Julio Terra - - This example code is in the public domain. - - More information about Spacebrew is available at: - http://spacebrew.cc/ - - */ - -#include <Bridge.h> -#include <SpacebrewYun.h> - -// create a variable of type SpacebrewYun and initialize it with the constructor -SpacebrewYun sb = SpacebrewYun("spacebrewYun Range", "Range sender and receiver"); - -// variable that holds the last potentiometer value -int last_value = 0; - -// create variables to manage interval between each time we send a string -void setup() { - - // start the serial port - SerialUSB.begin(57600); - - // for debugging, wait until a serial console is connected - delay(4000); - while (!SerialUSB) { - ; - } - - // start-up the bridge - Bridge.begin(); - - // configure the spacebrew object to print status messages to serial - sb.verbose(true); - - // configure the spacebrew publisher and subscriber - sb.addPublish("physical pot", "range"); - sb.addSubscribe("virtual pot", "range"); - - // register the string message handler method - sb.onRangeMessage(handleRange); - - // connect to cloud spacebrew server at "sandbox.spacebrew.cc" - sb.connect("sandbox.spacebrew.cc"); -} - - -void loop() { - // monitor spacebrew connection for new data - sb.monitor(); - - // connected to spacebrew then send a new value whenever the pot value changes - if (sb.connected()) { - int cur_value = analogRead(A0); - if (last_value != cur_value) { - sb.send("physical pot", cur_value); - last_value = cur_value; - } - } -} - -// handler method that is called whenever a new string message is received -void handleRange(String route, int value) { - // print the message that was received - SerialUSB.print("From "); - SerialUSB.print(route); - SerialUSB.print(", received msg: "); - SerialUSB.println(value); -} - diff --git a/doc/SpacebrewYun/examples/spacebrewString/spacebrewString.ino b/doc/SpacebrewYun/examples/spacebrewString/spacebrewString.ino @@ -1,86 +0,0 @@ -/* - Spacebrew String - - Demonstrates how to create a sketch that sends and receives strings - to and from Spacebrew. Every time string data is received it - is output to the Serial monitor. - - Make sure that your Yún is connected to the internet for this example - to function properly. - - The circuit: - - No circuit required - - created 2013 - by Julio Terra - - This example code is in the public domain. - - More information about Spacebrew is available at: - http://spacebrew.cc/ - - */ - -#include <Bridge.h> -#include <SpacebrewYun.h> - -// create a variable of type SpacebrewYun and initialize it with the constructor -SpacebrewYun sb = SpacebrewYun("spacebrewYun Strings", "String sender and receiver"); - -// create variables to manage interval between each time we send a string -long last_time = 0; -int interval = 2000; - -void setup() { - - // start the serial port - SerialUSB.begin(57600); - - // for debugging, wait until a serial console is connected - delay(4000); - while (!SerialUSB) { - ; - } - - // start-up the bridge - Bridge.begin(); - - // configure the spacebrew object to print status messages to serial - sb.verbose(true); - - // configure the spacebrew publisher and subscriber - sb.addPublish("speak", "string"); - sb.addSubscribe("listen", "string"); - - // register the string message handler method - sb.onStringMessage(handleString); - - // connect to cloud spacebrew server at "sandbox.spacebrew.cc" - sb.connect("sandbox.spacebrew.cc"); -} - - -void loop() { - // monitor spacebrew connection for new data - sb.monitor(); - - // connected to spacebrew then send a string every 2 seconds - if (sb.connected()) { - - // check if it is time to send a new message - if ((millis() - last_time) > interval) { - sb.send("speak", "is anybody out there?"); - last_time = millis(); - } - } -} - -// handler method that is called whenever a new string message is received -void handleString(String route, String value) { - // print the message that was received - SerialUSB.print("From "); - SerialUSB.print(route); - SerialUSB.print(", received msg: "); - SerialUSB.println(value); -} - diff --git a/doc/TFT/README.adoc b/doc/TFT/README.adoc @@ -1,26 +0,0 @@ -= TFT Library for Arduino = - -This library enables an Arduino board to communicate with the Arduino TFT LCD screen. It simplifies the process for drawing shapes, lines, images, and text to the screen. - -For more information about this library please visit us at -http://www.arduino.cc/en/Reference/TFTLibrary - -== License == - -Copyright (c) Arduino LLC. All right reserved. -Copyright (c) Enrico Gueli. All right reserved. -Copyright (c) 2012, Adafruit Industries. All rights reserved. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/doc/TFT/examples/Arduino/TFTBitmapLogo/TFTBitmapLogo.ino b/doc/TFT/examples/Arduino/TFTBitmapLogo/TFTBitmapLogo.ino @@ -1,108 +0,0 @@ -/* - - Arduino TFT Bitmap Logo example - - This example reads an image file from a micro-SD card - and draws it on the screen, at random locations. - - In this sketch, the Arduino logo is read from a micro-SD card. - There is a .bmp file included with this sketch. - - open the sketch folder (Ctrl-K or Cmd-K) - - copy the "arduino.bmp" file to a micro-SD - - put the SD into the SD slot of the Arduino TFT module. - - This example code is in the public domain. - - Created 19 April 2013 by Enrico Gueli - - http://www.arduino.cc/en/Tutorial/TFTBitmapLogo - - */ - -// include the necessary libraries -#include <SPI.h> -#include <SD.h> -#include <TFT.h> // Arduino LCD library - -// pin definition for the Uno -#define sd_cs 4 -#define lcd_cs 10 -#define dc 9 -#define rst 8 - -// pin definition for the Leonardo -//#define sd_cs 8 -//#define lcd_cs 7 -//#define dc 0 -//#define rst 1 - -TFT TFTscreen = TFT(lcd_cs, dc, rst); - -// this variable represents the image to be drawn on screen -PImage logo; - - -void setup() { - // initialize the GLCD and show a message - // asking the user to open the serial line - TFTscreen.begin(); - TFTscreen.background(255, 255, 255); - - TFTscreen.stroke(0, 0, 255); - TFTscreen.println(); - TFTscreen.println(F("Arduino TFT Bitmap Example")); - TFTscreen.stroke(0, 0, 0); - TFTscreen.println(F("Open serial monitor")); - TFTscreen.println(F("to run the sketch")); - - // initialize the serial port: it will be used to - // print some diagnostic info - Serial.begin(9600); - while (!Serial) { - // wait for serial port to connect. Needed for native USB port only - } - - // clear the GLCD screen before starting - TFTscreen.background(255, 255, 255); - - // try to access the SD card. If that fails (e.g. - // no card present), the setup process will stop. - Serial.print(F("Initializing SD card...")); - if (!SD.begin(sd_cs)) { - Serial.println(F("failed!")); - return; - } - Serial.println(F("OK!")); - - // initialize and clear the GLCD screen - TFTscreen.begin(); - TFTscreen.background(255, 255, 255); - - // now that the SD card can be access, try to load the - // image file. - logo = TFTscreen.loadImage("arduino.bmp"); - if (!logo.isValid()) { - Serial.println(F("error while loading arduino.bmp")); - } -} - -void loop() { - // don't do anything if the image wasn't loaded correctly. - if (logo.isValid() == false) { - return; - } - - Serial.println(F("drawing image")); - - // get a random location where to draw the image. - // To avoid the image to be draw outside the screen, - // take into account the image size. - int x = random(TFTscreen.width() - logo.width()); - int y = random(TFTscreen.height() - logo.height()); - - // draw the image to the screen - TFTscreen.image(logo, x, y); - - // wait a little bit before drawing again - delay(1500); -} diff --git a/doc/TFT/examples/Arduino/TFTBitmapLogo/arduino.bmp b/doc/TFT/examples/Arduino/TFTBitmapLogo/arduino.bmp Binary files differ. diff --git a/doc/TFT/examples/Arduino/TFTColorPicker/TFTColorPicker.ino b/doc/TFT/examples/Arduino/TFTColorPicker/TFTColorPicker.ino @@ -1,67 +0,0 @@ -/* - - TFT Color Picker - - This example for the Arduino screen reads the input of - potentiometers or analog sensors attached to A0, A1, - and A2 and uses the values to change the screen's color. - - This example code is in the public domain. - - Created 15 April 2013 by Scott Fitzgerald - - http://www.arduino.cc/en/Tutorial/TFTColorPicker - - */ - -// pin definition for the Uno -#define cs 10 -#define dc 9 -#define rst 8 - -// pin definition for the Leonardo -// #define cs 7 -// #define dc 0 -// #define rst 1 - -#include <TFT.h> // Arduino LCD library -#include <SPI.h> - -TFT TFTscreen = TFT(cs, dc, rst); - -void setup() { - // begin serial communication - Serial.begin(9600); - - // initialize the display - TFTscreen.begin(); - - // set the background to white - TFTscreen.background(255, 255, 255); - -} - -void loop() { - - // read the values from your sensors and scale them to 0-255 - int redVal = map(analogRead(A0), 0, 1023, 0, 255); - int greenVal = map(analogRead(A1), 0, 1023, 0, 255); - int blueVal = map(analogRead(A2), 0, 1023, 0, 255); - - // draw the background based on the mapped values - TFTscreen.background(redVal, greenVal, blueVal); - - // send the values to the serial monitor - Serial.print("background("); - Serial.print(redVal); - Serial.print(" , "); - Serial.print(greenVal); - Serial.print(" , "); - Serial.print(blueVal); - Serial.println(")"); - - // wait for a moment - delay(33); - -} - diff --git a/doc/TFT/examples/Arduino/TFTDisplayText/TFTDisplayText.ino b/doc/TFT/examples/Arduino/TFTDisplayText/TFTDisplayText.ino @@ -1,74 +0,0 @@ -/* - Arduino TFT text example - - This example demonstrates how to draw text on the - TFT with an Arduino. The Arduino reads the value - of an analog sensor attached to pin A0, and writes - the value to the LCD screen, updating every - quarter second. - - This example code is in the public domain - - Created 15 April 2013 by Scott Fitzgerald - - http://www.arduino.cc/en/Tutorial/TFTDisplayText - - */ - -#include <TFT.h> // Arduino LCD library -#include <SPI.h> - -// pin definition for the Uno -#define cs 10 -#define dc 9 -#define rst 8 - -// pin definition for the Leonardo -// #define cs 7 -// #define dc 0 -// #define rst 1 - -// create an instance of the library -TFT TFTscreen = TFT(cs, dc, rst); - -// char array to print to the screen -char sensorPrintout[4]; - -void setup() { - - // Put this line at the beginning of every sketch that uses the GLCD: - TFTscreen.begin(); - - // clear the screen with a black background - TFTscreen.background(0, 0, 0); - - // write the static text to the screen - // set the font color to white - TFTscreen.stroke(255, 255, 255); - // set the font size - TFTscreen.setTextSize(2); - // write the text to the top left corner of the screen - TFTscreen.text("Sensor Value :\n ", 0, 0); - // ste the font size very large for the loop - TFTscreen.setTextSize(5); -} - -void loop() { - - // Read the value of the sensor on A0 - String sensorVal = String(analogRead(A0)); - - // convert the reading to a char array - sensorVal.toCharArray(sensorPrintout, 4); - - // set the font color - TFTscreen.stroke(255, 255, 255); - // print the sensor value - TFTscreen.text(sensorPrintout, 0, 20); - // wait for a moment - delay(250); - // erase the text you just wrote - TFTscreen.stroke(0, 0, 0); - TFTscreen.text(sensorPrintout, 0, 20); -} - diff --git a/doc/TFT/examples/Arduino/TFTEtchASketch/TFTEtchASketch.ino b/doc/TFT/examples/Arduino/TFTEtchASketch/TFTEtchASketch.ino @@ -1,83 +0,0 @@ -/* - - TFT EtchASketch - - This example for the Arduino screen draws a white point - on the GLCD based on the values of 2 potentiometers. - To clear the screen, press a button attached to pin 2. - - This example code is in the public domain. - - Created 15 April 2013 by Scott Fitzgerald - - http://www.arduino.cc/en/Tutorial/TFTEtchASketch - - */ - -#include <TFT.h> // Arduino LCD library -#include <SPI.h> - -// pin definition for the Uno -#define cs 10 -#define dc 9 -#define rst 8 - -// pin definition for the Leonardo -// #define cs 7 -// #define dc 0 -// #define rst 1 - -TFT TFTscreen = TFT(cs, dc, rst); - -// initial position of the cursor -int xPos = TFTscreen.width() / 2; -int yPos = TFTscreen.height() / 2; - -// pin the erase switch is connected to -int erasePin = 2; - -void setup() { - // declare inputs - pinMode(erasePin, INPUT); - // initialize the screen - TFTscreen.begin(); - // make the background black - TFTscreen.background(0, 0, 0); -} - -void loop() { - // read the potentiometers on A0 and A1 - int xValue = analogRead(A0); - int yValue = analogRead(A1); - - // map the values and update the position - xPos = xPos + (map(xValue, 0, 1023, 2, -2)); - yPos = yPos + (map(yValue, 0, 1023, -2, 2)); - - // don't let the point go past the screen edges - if (xPos > 159) { - (xPos = 159); - } - - if (xPos < 0) { - (xPos = 0); - } - if (yPos > 127) { - (yPos = 127); - } - - if (yPos < 0) { - (yPos = 0); - } - - // draw the point - TFTscreen.stroke(255, 255, 255); - TFTscreen.point(xPos, yPos); - - // read the value of the pin, and erase the screen if pressed - if (digitalRead(erasePin) == HIGH) { - TFTscreen.background(0, 0, 0); - } - - delay(33); -} diff --git a/doc/TFT/examples/Arduino/TFTGraph/TFTGraph.ino b/doc/TFT/examples/Arduino/TFTGraph/TFTGraph.ino @@ -1,70 +0,0 @@ -/* - - TFT Graph - - This example for an Arduino screen reads - the value of an analog sensor on A0, and - graphs the values on the screen. - - This example code is in the public domain. - - Created 15 April 2013 by Scott Fitzgerald - - http://www.arduino.cc/en/Tutorial/TFTGraph - - */ - -#include <TFT.h> // Arduino LCD library -#include <SPI.h> - -// pin definition for the Uno -#define cs 10 -#define dc 9 -#define rst 8 - -// pin definition for the Leonardo -// #define cs 7 -// #define dc 0 -// #define rst 1 - -TFT TFTscreen = TFT(cs, dc, rst); - -// position of the line on screen -int xPos = 0; - -void setup() { - // initialize the serial port - Serial.begin(9600); - - // initialize the display - TFTscreen.begin(); - - // clear the screen with a pretty color - TFTscreen.background(250, 16, 200); -} - -void loop() { - // read the sensor and map it to the screen height - int sensor = analogRead(A0); - int drawHeight = map(sensor, 0, 1023, 0, TFTscreen.height()); - - // print out the height to the serial monitor - Serial.println(drawHeight); - - // draw a line in a nice color - TFTscreen.stroke(250, 180, 10); - TFTscreen.line(xPos, TFTscreen.height() - drawHeight, xPos, TFTscreen.height()); - - // if the graph has reached the screen edge - // erase the screen and start again - if (xPos >= 160) { - xPos = 0; - TFTscreen.background(250, 16, 200); - } else { - // increment the horizontal position: - xPos++; - } - - delay(16); -} - diff --git a/doc/TFT/examples/Arduino/TFTPong/TFTPong.ino b/doc/TFT/examples/Arduino/TFTPong/TFTPong.ino @@ -1,135 +0,0 @@ -/* - - TFT Pong - - This example for the Arduino screen reads the values - of 2 potentiometers to move a rectangular platform - on the x and y axes. The platform can intersect - with a ball causing it to bounce. - - This example code is in the public domain. - - Created by Tom Igoe December 2012 - Modified 15 April 2013 by Scott Fitzgerald - - http://www.arduino.cc/en/Tutorial/TFTPong - - */ - -#include <TFT.h> // Arduino LCD library -#include <SPI.h> - -// pin definition for the Uno -#define cs 10 -#define dc 9 -#define rst 8 - -// pin definition for the Leonardo -// #define cs 7 -// #define dc 0 -// #define rst 1 - -TFT TFTscreen = TFT(cs, dc, rst); - -// variables for the position of the ball and paddle -int paddleX = 0; -int paddleY = 0; -int oldPaddleX, oldPaddleY; -int ballDirectionX = 1; -int ballDirectionY = 1; - -int ballSpeed = 10; // lower numbers are faster - -int ballX, ballY, oldBallX, oldBallY; - -void setup() { - // initialize the display - TFTscreen.begin(); - // black background - TFTscreen.background(0, 0, 0); -} - -void loop() { - - // save the width and height of the screen - int myWidth = TFTscreen.width(); - int myHeight = TFTscreen.height(); - - // map the paddle's location to the position of the potentiometers - paddleX = map(analogRead(A0), 512, -512, 0, myWidth) - 20 / 2; - paddleY = map(analogRead(A1), 512, -512, 0, myHeight) - 5 / 2; - - // set the fill color to black and erase the previous - // position of the paddle if different from present - TFTscreen.fill(0, 0, 0); - - if (oldPaddleX != paddleX || oldPaddleY != paddleY) { - TFTscreen.rect(oldPaddleX, oldPaddleY, 20, 5); - } - - // draw the paddle on screen, save the current position - // as the previous. - TFTscreen.fill(255, 255, 255); - - TFTscreen.rect(paddleX, paddleY, 20, 5); - oldPaddleX = paddleX; - oldPaddleY = paddleY; - - // update the ball's position and draw it on screen - if (millis() % ballSpeed < 2) { - moveBall(); - } -} - -// this function determines the ball's position on screen -void moveBall() { - // if the ball goes offscreen, reverse the direction: - if (ballX > TFTscreen.width() || ballX < 0) { - ballDirectionX = -ballDirectionX; - } - - if (ballY > TFTscreen.height() || ballY < 0) { - ballDirectionY = -ballDirectionY; - } - - // check if the ball and the paddle occupy the same space on screen - if (inPaddle(ballX, ballY, paddleX, paddleY, 20, 5)) { - ballDirectionX = -ballDirectionX; - ballDirectionY = -ballDirectionY; - } - - // update the ball's position - ballX += ballDirectionX; - ballY += ballDirectionY; - - // erase the ball's previous position - TFTscreen.fill(0, 0, 0); - - if (oldBallX != ballX || oldBallY != ballY) { - TFTscreen.rect(oldBallX, oldBallY, 5, 5); - } - - - // draw the ball's current position - TFTscreen.fill(255, 255, 255); - TFTscreen.rect(ballX, ballY, 5, 5); - - oldBallX = ballX; - oldBallY = ballY; - -} - -// this function checks the position of the ball -// to see if it intersects with the paddle -boolean inPaddle(int x, int y, int rectX, int rectY, int rectWidth, int rectHeight) { - boolean result = false; - - if ((x >= rectX && x <= (rectX + rectWidth)) && - (y >= rectY && y <= (rectY + rectHeight))) { - result = true; - } - - return result; -} - - diff --git a/doc/TFT/examples/Esplora/EsploraTFTBitmapLogo/EsploraTFTBitmapLogo.ino b/doc/TFT/examples/Esplora/EsploraTFTBitmapLogo/EsploraTFTBitmapLogo.ino @@ -1,101 +0,0 @@ -/* - - Esplora TFT Bitmap Logos - - This example for the Arduino TFT screen is for use - with an Arduino Esplora. - - This example reads an image file from a micro-SD card - and draws it on the screen, at random locations. - - There is a .bmp file included with this sketch. - - open the sketch folder (Ctrl-K or Cmd-K) - - copy the "arduino.bmp" file to a micro-SD - - put the SD into the SD slot of the Arduino LCD module. - - This example code is in the public domain. - - Created 19 April 2013 by Enrico Gueli - - http://www.arduino.cc/en/Tutorial/EsploraTFTBitmapLogo - - */ - -// include the necessary libraries -#include <Esplora.h> -#include <SPI.h> -#include <SD.h> -#include <TFT.h> // Arduino LCD library - -// the Esplora pin connected to the chip select line for SD card -#define SD_CS 8 - -// this variable represents the image to be drawn on screen -PImage logo; - -void setup() { - // initialize the GLCD and show a message - // asking the user to open the serial line - EsploraTFT.begin(); - EsploraTFT.background(255, 255, 255); - - EsploraTFT.stroke(0, 0, 255); - EsploraTFT.println(); - EsploraTFT.println(F("Arduino LCD Bitmap Example")); - EsploraTFT.stroke(0, 0, 0); - EsploraTFT.println(F("Open serial monitor")); - EsploraTFT.println(F("to run the sketch")); - - // initialize the serial port: it will be used to - // print some diagnostic info - Serial.begin(9600); - while (!Serial) { - // wait for serial port to connect. Needed for native USB port only - } - - // try to access the SD card. If that fails (e.g. - // no card present), the Esplora's LED will turn red. - Serial.print(F("Initializing SD card...")); - if (!SD.begin(SD_CS)) { - Serial.println(F("failed!")); - Esplora.writeRed(255); - return; - } - Serial.println("OK!"); - - // clear the GLCD screen before starting - EsploraTFT.background(255, 255, 255); - - // now that the SD card can be access, try to load the - // image file. The Esplora LED will turn green or red if - // the loading went OK or not. - Esplora.writeRGB(0, 0, 0); - logo = EsploraTFT.loadImage("arduino.bmp"); - if (logo.isValid()) { - Esplora.writeGreen(255); - } else { - Esplora.writeRed(255); - } - -} - -void loop() { - // don't do anything if the image wasn't loaded correctly. - if (logo.isValid() == false) { - return; - } - - Serial.println(F("drawing image")); - - // get a random location where to draw the image. - // To avoid the image to be draw outside the screen, - // take into account the image size. - int x = random(EsploraTFT.width() - logo.width()); - int y = random(EsploraTFT.height() - logo.height()); - - // draw the image to the screen - EsploraTFT.image(logo, x, y); - - // wait a little bit before drawing again - delay(1500); -} diff --git a/doc/TFT/examples/Esplora/EsploraTFTBitmapLogo/arduino.bmp b/doc/TFT/examples/Esplora/EsploraTFTBitmapLogo/arduino.bmp Binary files differ. diff --git a/doc/TFT/examples/Esplora/EsploraTFTColorPicker/EsploraTFTColorPicker.ino b/doc/TFT/examples/Esplora/EsploraTFTColorPicker/EsploraTFTColorPicker.ino @@ -1,54 +0,0 @@ -/* - - Esplora TFT Color Picker - - This example for the Esplora with an Arduino TFT reads - the input of the joystick and slider, using the values - to change the screen's color. - - This example code is in the public domain. - - Created 15 April 2013 by Scott Fitzgerald - - http://www.arduino.cc/en/Tutorial/TFTColorPicker - - */ - -#include <Esplora.h> -#include <TFT.h> // Arduino LCD library -#include <SPI.h> - -void setup() { - Serial.begin(9600); - - // initialize the LCD - EsploraTFT.begin(); - - // start out with a white screen - EsploraTFT.background(255, 255, 255); - -} - -void loop() { - - // map the values from sensors - int xValue = map(Esplora.readJoystickX(), -512, 512, 0, 255); // read the joystick's X position - int yValue = map(Esplora.readJoystickY(), -512, 512, 0, 255); // read the joystick's Y position - int slider = map(Esplora.readSlider(), 0, 1023, 0, 255); // read the slider's position - - // change the background color based on the mapped values - EsploraTFT.background(xValue, yValue, slider); - - // print the mapped values to the Serial monitor - Serial.print("background("); - Serial.print(xValue); - Serial.print(" , "); - Serial.print(yValue); - Serial.print(" , "); - Serial.print(slider); - Serial.println(")"); - - delay(33); - -} - diff --git a/doc/TFT/examples/Esplora/EsploraTFTEtchASketch/EsploraTFTEtchASketch.ino b/doc/TFT/examples/Esplora/EsploraTFTEtchASketch/EsploraTFTEtchASketch.ino @@ -1,80 +0,0 @@ -/* - - Esplora TFT EtchASketch - - This example for the Arduino TFT and Esplora draws - a white line on the screen, based on the position - of the joystick. To clear the screen, shake the - Esplora, using the values from the accelerometer. - - This example code is in the public domain. - - Created 15 April 2013 by Scott Fitzgerald - - http://www.arduino.cc/en/Tutorial/EsploraTFTEtchASketch - - */ - -#include <Esplora.h> -#include <TFT.h> // Arduino LCD library -#include <SPI.h> - -// initial position of the cursor -int xPos = EsploraTFT.width() / 2; -int yPos = EsploraTFT.height() / 2; - -void setup() { - // initialize the display - EsploraTFT.begin(); - - // clear the background - EsploraTFT.background(0, 0, 0); -} - -void loop() { - - int xAxis = Esplora.readJoystickX(); // read the X axis - int yAxis = Esplora.readJoystickY(); // read the Y axis - - // update the position of the line - // depending on the position of the joystick - if (xAxis < 10 && xAxis > -10) { - xPos = xPos; - } else { - xPos = xPos + (map(xAxis, -512, 512, 2, -2)); - } - if (yAxis < 10 && yAxis > -10) { - yAxis = yAxis; - } else { - yPos = yPos + (map(yAxis, -512, 512, -2, 2)); - } - - // don't let the point go past the screen edges - if (xPos > 159) { - (xPos = 159); - } - - if (xPos < 0) { - (xPos = 0); - } - if (yPos > 127) { - (yPos = 127); - } - - if (yPos < 0) { - (yPos = 0); - } - - // draw the point - EsploraTFT.stroke(255, 255, 255); - EsploraTFT.point(xPos, yPos); - - // check the accelerometer values and clear - // the screen if it is being shaken - if (abs(Esplora.readAccelerometer(X_AXIS)) > 200 || abs(Esplora.readAccelerometer(Y_AXIS)) > 200) { - EsploraTFT.background(0, 0, 0); - } - - delay(33); -} - diff --git a/doc/TFT/examples/Esplora/EsploraTFTGraph/EsploraTFTGraph.ino b/doc/TFT/examples/Esplora/EsploraTFTGraph/EsploraTFTGraph.ino @@ -1,55 +0,0 @@ -/* - - Esplora TFT Graph - - This example for the Esplora with an Arduino TFT reads - the value of the light sensor, and graphs the values on - the screen. - - This example code is in the public domain. - - Created 15 April 2013 by Scott Fitzgerald - - http://www.arduino.cc/en/Tutorial/EsploraTFTGraph - - */ - -#include <Esplora.h> -#include <TFT.h> // Arduino LCD library -#include <SPI.h> - -// position of the line on screen -int xPos = 0; - -void setup() { - - // initialize the screen - EsploraTFT.begin(); - - // clear the screen with a nice color - EsploraTFT.background(250, 16, 200); -} - -void loop() { - - // read the sensor value - int sensor = Esplora.readLightSensor(); - // map the sensor value to the height of the screen - int graphHeight = map(sensor, 0, 1023, 0, EsploraTFT.height()); - - // draw the line in a pretty color - EsploraTFT.stroke(250, 180, 10); - EsploraTFT.line(xPos, EsploraTFT.height() - graphHeight, xPos, EsploraTFT.height()); - - // if the graph reaches the edge of the screen - // erase it and start over from the other side - if (xPos >= 160) { - xPos = 0; - EsploraTFT.background(250, 16, 200); - } else { - // increment the horizontal position: - xPos++; - } - - delay(16); -} diff --git a/doc/TFT/examples/Esplora/EsploraTFTHorizon/EsploraTFTHorizon.ino b/doc/TFT/examples/Esplora/EsploraTFTHorizon/EsploraTFTHorizon.ino @@ -1,62 +0,0 @@ -/* - - Esplora TFT Horizon - - This example for the Arduino TFT and Esplora draws - a line on the screen that stays level with the ground - as you tile the Esplora side to side - - This example code is in the public domain. - - Created 15 April 2013 by Scott Fitzgerald - - http://www.arduino.cc/en/Tutorial/EsploraTFTHorizon - - */ - -#include <Esplora.h> -#include <TFT.h> // Arduino LCD library -#include <SPI.h> - -// horizontal start and end positions -int yStart = EsploraTFT.height() / 2; -int yEnd = EsploraTFT.height() / 2; - -// previous start and end positions -int oldEndY; -int oldStartY; - -void setup() { - // initialize the display - EsploraTFT.begin(); - // make the background black - EsploraTFT.background(0, 0, 0); -} - -void loop() { - // read the x-axis of te accelerometer - int tilt = Esplora.readAccelerometer(X_AXIS); - - // the values are 100 when tilted to the left - // and -100 when tilted to the right - // map these values to the start and end points - yStart = map(tilt, -100, 100, EsploraTFT.height(), 0); - yEnd = map(tilt, -100, 100, 0, EsploraTFT.height()); - - // if the previous values are different than the current values - // erase the previous line - if (oldStartY != yStart || oldEndY != yEnd) { - EsploraTFT.stroke(0, 0, 0); - EsploraTFT.line(0, oldStartY, EsploraTFT.width(), oldEndY); - } - - // draw the line in magenta - EsploraTFT.stroke(255, 0, 255); - EsploraTFT.line(0, yStart, EsploraTFT.width(), yEnd); - - // save the current start and end points - // to compare int he next loop - oldStartY = yStart; - oldEndY = yEnd; - delay(10); -} diff --git a/doc/TFT/examples/Esplora/EsploraTFTPong/EsploraTFTPong.ino b/doc/TFT/examples/Esplora/EsploraTFTPong/EsploraTFTPong.ino @@ -1,126 +0,0 @@ -/* - - Esplora TFT Pong - - This example for the Esplora with an Arduino TFT screen reads - the value of the joystick to move a rectangular platform - on the x and y axes. The platform can intersect with a ball - causing it to bounce. The Esplora's slider adjusts the speed - of the ball. - - This example code is in the public domain. - - Created by Tom Igoe December 2012 - Modified 15 April 2013 by Scott Fitzgerald - - http://www.arduino.cc/en/Tutorial/EsploraTFTPong - - */ - -#include <Esplora.h> -#include <TFT.h> // Arduino LCD library -#include <SPI.h> - -// variables for the position of the ball and paddle -int paddleX = 0; -int paddleY = 0; -int oldPaddleX, oldPaddleY; -int ballDirectionX = 1; -int ballDirectionY = 1; - -int ballX, ballY, oldBallX, oldBallY; - -void setup() { - - Serial.begin(9600); - - // initialize the display - EsploraTFT.begin(); - // set the background the black - EsploraTFT.background(0, 0, 0); -} - -void loop() { - // save the width and height of the screen - int myWidth = EsploraTFT.width(); - int myHeight = EsploraTFT.height(); - - // map the paddle's location to the joystick's position - paddleX = map(Esplora.readJoystickX(), 512, -512, 0, myWidth) - 20 / 2; - paddleY = map(Esplora.readJoystickY(), -512, 512, 0, myHeight) - 5 / 2; - Serial.print(paddleX); - Serial.print(" "); - Serial.println(paddleY); - - // set the fill color to black and erase the previous - // position of the paddle if different from present - EsploraTFT.fill(0, 0, 0); - - if (oldPaddleX != paddleX || oldPaddleY != paddleY) { - EsploraTFT.rect(oldPaddleX, oldPaddleY, 20, 5); - } - - // draw the paddle on screen, save the current position - // as the previous. - EsploraTFT.fill(255, 255, 255); - EsploraTFT.rect(paddleX, paddleY, 20, 5); - oldPaddleX = paddleX; - oldPaddleY = paddleY; - - // read the slider to determinde the speed of the ball - int ballSpeed = map(Esplora.readSlider(), 0, 1023, 0, 80) + 1; - if (millis() % ballSpeed < 2) { - moveBall(); - } -} - - -// this function determines the ball's position on screen -void moveBall() { - // if the ball goes offscreen, reverse the direction: - if (ballX > EsploraTFT.width() || ballX < 0) { - ballDirectionX = -ballDirectionX; - } - - if (ballY > EsploraTFT.height() || ballY < 0) { - ballDirectionY = -ballDirectionY; - } - - // check if the ball and the paddle occupy the same space on screen - if (inPaddle(ballX, ballY, paddleX, paddleY, 20, 5)) { - ballDirectionY = -ballDirectionY; - } - - // update the ball's position - ballX += ballDirectionX; - ballY += ballDirectionY; - - // erase the ball's previous position - EsploraTFT.fill(0, 0, 0); - - if (oldBallX != ballX || oldBallY != ballY) { - EsploraTFT.rect(oldBallX, oldBallY, 5, 5); - } - - // draw the ball's current position - EsploraTFT.fill(255, 255, 255); - - EsploraTFT.rect(ballX, ballY, 5, 5); - - oldBallX = ballX; - oldBallY = ballY; - -} - -// this function checks the position of the ball -// to see if it intersects with the paddle -boolean inPaddle(int x, int y, int rectX, int rectY, int rectWidth, int rectHeight) { - boolean result = false; - - if ((x >= rectX && x <= (rectX + rectWidth)) && - (y >= rectY && y <= (rectY + rectHeight))) { - result = true; - } - - return result; -} diff --git a/doc/TFT/examples/Esplora/EsploraTFTTemp/EsploraTFTTemp.ino b/doc/TFT/examples/Esplora/EsploraTFTTemp/EsploraTFTTemp.ino @@ -1,64 +0,0 @@ -/* - - Esplora TFT Temperature Display - - This example for the Arduino TFT screen is for use - with an Arduino Esplora. - - This example reads the temperature of the Esplora's - on board thermisistor and displays it on an attached - LCD screen, updating every second. - - This example code is in the public domain. - - Created 15 April 2013 by Scott Fitzgerald - - http://www.arduino.cc/en/Tutorial/EsploraTFTTemp - - */ - -// include the necessary libraries -#include <Esplora.h> -#include <TFT.h> // Arduino LCD library -#include <SPI.h> - -char tempPrintout[3]; // array to hold the temperature data - -void setup() { - - // Put this line at the beginning of every sketch that uses the GLCD - EsploraTFT.begin(); - - // clear the screen with a black background - EsploraTFT.background(0, 0, 0); - - // set the text color to magenta - EsploraTFT.stroke(200, 20, 180); - // set the text to size 2 - EsploraTFT.setTextSize(2); - // start the text at the top left of the screen - // this text is going to remain static - EsploraTFT.text("Degrees in C :\n ", 0, 0); - - // set the text in the loop to size 5 - EsploraTFT.setTextSize(5); -} - -void loop() { - - // read the temperature in Celcius and store it in a String - String temperature = String(Esplora.readTemperature(DEGREES_C)); - - // convert the string to a char array - temperature.toCharArray(tempPrintout, 3); - - // set the text color to white - EsploraTFT.stroke(255, 255, 255); - // print the temperature one line below the static text - EsploraTFT.text(tempPrintout, 0, 30); - - delay(1000); - // erase the text for the next loop - EsploraTFT.stroke(0, 0, 0); - EsploraTFT.text(tempPrintout, 0, 30); -} diff --git a/doc/Temboo/README.adoc b/doc/Temboo/README.adoc @@ -1,32 +0,0 @@ -= Temboo Library for Arduino = - -This library allows an Arduino to connect to the Temboo service. - -== License == - -Copyright 2015, Temboo Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -either express or implied. See the License for the specific -language governing permissions and limitations under the License. - -This library includes elements of the Paho MQTT client, used -with permission under the Eclipse Public License - v1.0: - -http://www.eclipse.org/legal/epl-v10.html - -and the Eclipse Distribution License v1.0: - -http://www.eclipse.org/org/documents/edl-v10.php - -The Eclipse MQTT Paho client source is available here: - -http://www.eclipse.org/paho/ diff --git a/doc/Temboo/examples/ArduinoYun/CloudControlsConfig/CloudControlsConfig.ino b/doc/Temboo/examples/ArduinoYun/CloudControlsConfig/CloudControlsConfig.ino @@ -1,97 +0,0 @@ -// Copyright 2016, Temboo Inc. - -#include <Process.h> - -void setup() { - // initialize the Bridge - Bridge.begin(); - Serial.begin(9600); - Process p; - - //intro message - Serial.println("**** Temboo Cloud Controls ****\n"); - - // update the package list - Serial.print("Updating package listings..."); - p.runShellCommand("opkg update"); - int returnCode = p.exitValue(); - if (returnCode == 0) { - Serial.println("Success!"); - } else { - Serial.println("Failed. Make sure your device is connected to the internet properly."); - while(p.available()) { - char c = p.read(); - Serial.print(c); - } - return; - } - Serial.println(); - // upgrade the Temboo package - Serial.print("Updating Temboo..."); - p.runShellCommand("opkg install http://downloads.arduino.cc/openwrtyun/1/packages/temboo_1.3.1-1_ar71xx.ipk"); - returnCode = p.exitValue(); - if (returnCode == 0) { - Serial.println("Success!"); - } else { - Serial.println("Failed."); - while(p.available()) { - char c = p.read(); - Serial.print(c); - } - return; - } - Serial.println(); - - // install python openssl to allow for for ssl connections - Serial.print("Installing python-openssl..."); - p.runShellCommand("opkg install python-openssl"); - returnCode = p.exitValue(); - if (returnCode == 0) { - Serial.println("Success!"); - } else { - Serial.println("Failed."); - while(p.available()) { - char c = p.read(); - Serial.print(c); - } - return; - } - Serial.println(); - - // Installing twisted web to work with CoAP gateway - Serial.print("Installing twisted-web..."); - p.runShellCommand("opkg install twisted-web"); - returnCode = p.exitValue(); - if (returnCode == 0) { - Serial.println("Success!"); - } else { - Serial.println("Failed."); - while(p.available()) { - char c = p.read(); - Serial.print(c); - } - return; - } - Serial.println(); - - // Configuring zope - Serial.print("Configuring zope..."); - p.runShellCommand("touch /usr/lib/python2.7/site-packages/zope/__init__.py"); - returnCode = p.exitValue(); - if (returnCode == 0) { - Serial.println("Success!"); - } else { - Serial.println("Failed."); - while(p.available()) { - char c = p.read(); - Serial.print(c); - } - return; - } - - Serial.println("Update Complete - your Yun is ready for Cloud Controls!"); -} - -void loop() { - // do nothing -} diff --git a/doc/Temboo/examples/ArduinoYun/GetYahooWeatherReport/GetYahooWeatherReport.ino b/doc/Temboo/examples/ArduinoYun/GetYahooWeatherReport/GetYahooWeatherReport.ino @@ -1,115 +0,0 @@ -/* - GetYahooWeatherReport - - Demonstrates making a request to the Yahoo! Weather API using Temboo from an Arduino Yún. - - Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino - - A Temboo account and application key are necessary to run all Temboo examples. - If you don't already have one, you can register for a free Temboo account at - http://www.temboo.com - - This example assumes basic familiarity with Arduino sketches, and that your Yún is connected - to the Internet. - - Looking for another API to use with your Arduino Yún? We've got over 100 in our Library! - - This example code is in the public domain. -*/ - -#include <Bridge.h> -#include <Temboo.h> -#include "TembooAccount.h" // contains Temboo account information - // as described in the footer comment below - - -// the address for which a weather forecast will be retrieved -String ADDRESS_FOR_FORECAST = "104 Franklin St., New York NY 10013"; - -int numRuns = 1; // execution count, so that this doesn't run forever -int maxRuns = 10; // max number of times the Yahoo WeatherByAddress Choreo should be run - - -void setup() { - Serial.begin(9600); - - // for debugging, wait until a serial console is connected - delay(4000); - while(!Serial); - Bridge.begin(); - -} - -void loop() -{ - // while we haven't reached the max number of runs... - if (numRuns <= maxRuns) { - - // print status - Serial.println("Running GetWeatherByAddress - Run #" + String(numRuns++) + "..."); - - // create a TembooChoreo object to send a Choreo request to Temboo - TembooChoreo GetWeatherByAddressChoreo; - - // invoke the Temboo client - GetWeatherByAddressChoreo.begin(); - - // add your temboo account info - GetWeatherByAddressChoreo.setAccountName(TEMBOO_ACCOUNT); - GetWeatherByAddressChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); - GetWeatherByAddressChoreo.setAppKey(TEMBOO_APP_KEY); - - // set the name of the choreo we want to run - GetWeatherByAddressChoreo.setChoreo("/Library/Yahoo/Weather/GetWeatherByAddress"); - - // set choreo inputs; in this case, the address for which to retrieve weather data - // the Temboo client provides standardized calls to 100+ cloud APIs - GetWeatherByAddressChoreo.addInput("Address", ADDRESS_FOR_FORECAST); - - // add an output filter to extract the name of the city. - GetWeatherByAddressChoreo.addOutputFilter("city", "/rss/channel/yweather:location/@city", "Response"); - - // add an output filter to extract the current temperature - GetWeatherByAddressChoreo.addOutputFilter("temperature", "/rss/channel/item/yweather:condition/@temp", "Response"); - - // add an output filter to extract the date and time of the last report. - GetWeatherByAddressChoreo.addOutputFilter("date", "/rss/channel/item/yweather:condition/@date", "Response"); - - // run the choreo - GetWeatherByAddressChoreo.run(); - - // when the choreo results are available, print them to the serial monitor - while(GetWeatherByAddressChoreo.available()) { - - char c = GetWeatherByAddressChoreo.read(); - Serial.print(c); - } - GetWeatherByAddressChoreo.close(); - - } - - Serial.println("Waiting..."); - Serial.println(""); - delay(30000); // wait 30 seconds between GetWeatherByAddress calls -} - -/* - IMPORTANT NOTE: TembooAccount.h: - - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, - by inserting your own Temboo account name and app key information. The contents of the file should - look like: - - #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name - #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name - #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - You can find your Temboo App Key information on the Temboo website, - under My Account > Application Keys - - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - - Keeping your account information in a separate file means you can share the main .ino file without worrying - that you forgot to delete your credentials. -*/ diff --git a/doc/Temboo/examples/ArduinoYun/GetYahooWeatherReport/TembooAccount.h b/doc/Temboo/examples/ArduinoYun/GetYahooWeatherReport/TembooAccount.h @@ -1,4 +0,0 @@ -#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name -#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name -#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - diff --git a/doc/Temboo/examples/ArduinoYun/ReadATweet/ReadATweet.ino b/doc/Temboo/examples/ArduinoYun/ReadATweet/ReadATweet.ino @@ -1,173 +0,0 @@ -/* - ReadATweet - - Demonstrates retrieving the most recent Tweet from a user's home timeline - using Temboo from an Arduino Yún. - - Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino - - A Temboo account and application key are necessary to run all Temboo examples. - If you don't already have one, you can register for a free Temboo account at - http://www.temboo.com - - In order to run this sketch, you'll need to register an application using - the Twitter dev console at https://dev.twitter.com. After creating the - app, you'll find OAuth credentials for that application under the "OAuth Tool" tab. - Substitute these values for the placeholders below. - - This example assumes basic familiarity with Arduino sketches, and that your Yún - is connected to the Internet. - - Want to use another social API with your Arduino Yún? We've got Facebook, - Google+, Instagram, Tumblr and more in our Library! - - This example code is in the public domain. -*/ - -#include <Bridge.h> -#include <Temboo.h> -#include "TembooAccount.h" // contains Temboo account information - // as described in the footer comment below - -/*** SUBSTITUTE YOUR VALUES BELOW: ***/ - -// Note that for additional security and reusability, you could -// use #define statements to specify these values in a .h file. -const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token"; -const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret"; -const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key"; -const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret"; - -int numRuns = 1; // execution count, so this doesn't run forever -int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo should run - -void setup() { - Serial.begin(9600); - - // For debugging, wait until a serial console is connected. - delay(4000); - while(!Serial); - Bridge.begin(); -} -void loop() -{ - // while we haven't reached the max number of runs... - if (numRuns <= maxRuns) { - Serial.println("Running ReadATweet - Run #" + String(numRuns++)); - - TembooChoreo HomeTimelineChoreo; - - // invoke the Temboo client. - // NOTE that the client must be reinvoked, and repopulated with - // appropriate arguments, each time its run() method is called. - HomeTimelineChoreo.begin(); - - // set Temboo account credentials - HomeTimelineChoreo.setAccountName(TEMBOO_ACCOUNT); - HomeTimelineChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); - HomeTimelineChoreo.setAppKey(TEMBOO_APP_KEY); - - // tell the Temboo client which Choreo to run (Twitter > Timelines > HomeTimeline) - HomeTimelineChoreo.setChoreo("/Library/Twitter/Timelines/HomeTimeline"); - - - // set the required choreo inputs - // see https://www.temboo.com/library/Library/Twitter/Timelines/HomeTimeline/ - // for complete details about the inputs for this Choreo - - HomeTimelineChoreo.addInput("Count", "1"); // the max number of Tweets to return from each request - HomeTimelineChoreo.addInput("AccessToken", TWITTER_ACCESS_TOKEN); - HomeTimelineChoreo.addInput("AccessTokenSecret", TWITTER_ACCESS_TOKEN_SECRET); - HomeTimelineChoreo.addInput("ConsumerKey", TWITTER_CONSUMER_KEY); - HomeTimelineChoreo.addInput("ConsumerSecret", TWITTER_CONSUMER_SECRET); - - // next, we'll define two output filters that let us specify the - // elements of the response from Twitter that we want to receive. - // see the examples at http://www.temboo.com/arduino - // for more on using output filters - - // we want the text of the tweet - HomeTimelineChoreo.addOutputFilter("tweet", "/[1]/text", "Response"); - - // and the name of the author - HomeTimelineChoreo.addOutputFilter("author", "/[1]/user/screen_name", "Response"); - - - // tell the Process to run and wait for the results. The - // return code will tell us whether the Temboo client - // was able to send our request to the Temboo servers - unsigned int returnCode = HomeTimelineChoreo.run(); - - // a response code of 0 means success; print the API response - if(returnCode == 0) { - - String author; // a String to hold the tweet author's name - String tweet; // a String to hold the text of the tweet - - - // choreo outputs are returned as key/value pairs, delimited with - // newlines and record/field terminator characters, for example: - // Name1\n\x1F - // Value1\n\x1E - // Name2\n\x1F - // Value2\n\x1E - - // see the examples at http://www.temboo.com/arduino for more details - // we can read this format into separate variables, as follows: - - while(HomeTimelineChoreo.available()) { - // read the name of the output item - String name = HomeTimelineChoreo.readStringUntil('\x1F'); - name.trim(); - - // read the value of the output item - String data = HomeTimelineChoreo.readStringUntil('\x1E'); - data.trim(); - - // assign the value to the appropriate String - if (name == "tweet") { - tweet = data; - } else if (name == "author") { - author = data; - } - } - - Serial.println("@" + author + " - " + tweet); - - } else { - // there was an error - // print the raw output from the choreo - while(HomeTimelineChoreo.available()) { - char c = HomeTimelineChoreo.read(); - Serial.print(c); - } - } - - HomeTimelineChoreo.close(); - - } - - Serial.println("Waiting..."); - delay(90000); // wait 90 seconds between HomeTimeline calls -} - -/* - IMPORTANT NOTE: TembooAccount.h: - - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, - by inserting your own Temboo account name and app key information. The contents of the file should - look like: - - #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name - #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name - #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - You can find your Temboo App Key information on the Temboo website, - under My Account > Application Keys - - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - - Keeping your account information in a separate file means you can share the main .ino file without worrying - that you forgot to delete your credentials. -*/ diff --git a/doc/Temboo/examples/ArduinoYun/ReadATweet/TembooAccount.h b/doc/Temboo/examples/ArduinoYun/ReadATweet/TembooAccount.h @@ -1,4 +0,0 @@ -#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name -#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name -#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - diff --git a/doc/Temboo/examples/ArduinoYun/SendATweet/SendATweet.ino b/doc/Temboo/examples/ArduinoYun/SendATweet/SendATweet.ino @@ -1,138 +0,0 @@ -/* - SendATweet - - Demonstrates sending a tweet via a Twitter account using Temboo from an Arduino Yún. - - Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino - - A Temboo account and application key are necessary to run all Temboo examples. - If you don't already have one, you can register for a free Temboo account at - http://www.temboo.com - - In order to run this sketch, you'll need to register an application using - the Twitter dev console at https://dev.twitter.com. Note that since this - sketch creates a new tweet, your application will need to be configured with - read+write permissions. After creating the app, you'll find OAuth credentials - for that application under the "OAuth Tool" tab. Substitute these values for - the placeholders below. - - This example assumes basic familiarity with Arduino sketches, and that your Yún is connected - to the Internet. - - Want to use another social API with your Arduino Yún? We've got Facebook, - Google+, Instagram, Tumblr and more in our Library! - - This example code is in the public domain. -*/ - -#include <Bridge.h> -#include <Temboo.h> -#include "TembooAccount.h" // contains Temboo account information - // as described in the footer comment below - - -/*** SUBSTITUTE YOUR VALUES BELOW: ***/ - -// Note that for additional security and reusability, you could -// use #define statements to specify these values in a .h file. -const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token"; -const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret"; -const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key"; -const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret"; - -int numRuns = 1; // execution count, so this sketch doesn't run forever -int maxRuns = 3; // the max number of times the Twitter Update Choreo should run - -void setup() { - Serial.begin(9600); - - // for debugging, wait until a serial console is connected - delay(4000); - while(!Serial); - - Bridge.begin(); -} - -void loop() -{ - // only try to send the tweet if we haven't already sent it successfully - if (numRuns <= maxRuns) { - - Serial.println("Running SendATweet - Run #" + String(numRuns++) + "..."); - - // define the text of the tweet we want to send - String tweetText("My Arduino Yun has been running for " + String(millis()) + " milliseconds."); - - - TembooChoreo StatusesUpdateChoreo; - - // invoke the Temboo client - // NOTE that the client must be reinvoked, and repopulated with - // appropriate arguments, each time its run() method is called. - StatusesUpdateChoreo.begin(); - - // set Temboo account credentials - StatusesUpdateChoreo.setAccountName(TEMBOO_ACCOUNT); - StatusesUpdateChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); - StatusesUpdateChoreo.setAppKey(TEMBOO_APP_KEY); - - // identify the Temboo Library choreo to run (Twitter > Tweets > StatusesUpdate) - StatusesUpdateChoreo.setChoreo("/Library/Twitter/Tweets/StatusesUpdate"); - - // set the required choreo inputs - // see https://www.temboo.com/library/Library/Twitter/Tweets/StatusesUpdate/ - // for complete details about the inputs for this Choreo - - // add the Twitter account information - StatusesUpdateChoreo.addInput("AccessToken", TWITTER_ACCESS_TOKEN); - StatusesUpdateChoreo.addInput("AccessTokenSecret", TWITTER_ACCESS_TOKEN_SECRET); - StatusesUpdateChoreo.addInput("ConsumerKey", TWITTER_CONSUMER_KEY); - StatusesUpdateChoreo.addInput("ConsumerSecret", TWITTER_CONSUMER_SECRET); - - // and the tweet we want to send - StatusesUpdateChoreo.addInput("StatusUpdate", tweetText); - - // tell the Process to run and wait for the results. The - // return code (returnCode) will tell us whether the Temboo client - // was able to send our request to the Temboo servers - unsigned int returnCode = StatusesUpdateChoreo.run(); - - // a return code of zero (0) means everything worked - if (returnCode == 0) { - Serial.println("Success! Tweet sent!"); - } else { - // a non-zero return code means there was an error - // read and print the error message - while (StatusesUpdateChoreo.available()) { - char c = StatusesUpdateChoreo.read(); - Serial.print(c); - } - } - StatusesUpdateChoreo.close(); - - // do nothing for the next 90 seconds - Serial.println("Waiting..."); - delay(90000); - } -} - -/* - IMPORTANT NOTE: TembooAccount.h: - - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, - by inserting your own Temboo account name and app key information. The contents of the file should - look like: - - #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name - #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name - #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - You can find your Temboo App Key information on the Temboo website, - under My Account > Application Keys - - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - - Keeping your account information in a separate file means you can share the main .ino file without worrying - that you forgot to delete your credentials. -*/ diff --git a/doc/Temboo/examples/ArduinoYun/SendATweet/TembooAccount.h b/doc/Temboo/examples/ArduinoYun/SendATweet/TembooAccount.h @@ -1,4 +0,0 @@ -#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name -#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name -#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - diff --git a/doc/Temboo/examples/ArduinoYun/SendAnEmail/SendAnEmail.ino b/doc/Temboo/examples/ArduinoYun/SendAnEmail/SendAnEmail.ino @@ -1,166 +0,0 @@ -/* - SendAnEmail - - Demonstrates sending an email via a Google Gmail account using Temboo from an Arduino Yún. - - Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino - - A Temboo account and application key are necessary to run all Temboo examples. - If you don't already have one, you can register for a free Temboo account at - http://www.temboo.com - - Instructions: - - 1. Create a Temboo account: http://www.temboo.com - - 2. Retrieve your Temboo application details: http://www.temboo.com/account/applications - - 3. Replace the values in the TembooAccount.h tab with your Temboo application details - - 4. You'll also need a Gmail account. Update the placeholder Gmail address in the code - below with your own details. - - https://www.gmail.com - - 5. Once you have a Gmail account, turn on 2-step authentication, and create an application-specific - password to allow Temboo to access your Google account: https://www.google.com/landing/2step/. - - 6. After you've enabled 2-Step authentication, you'll need to create an App Password: - https://security.google.com/settings/security/apppasswords - - 7. In the "Select app" dropdown menu, choose "Other", and give your app a name (e.g., TembooApp). - - 8. Click "Generate". You'll be given a 16-digit passcode that can be used to access your Google Account from Temboo. - - 9. Copy and paste this password into the code below, updating the GMAIL_APP_PASSWORD variable - - 10. Upload the sketch to your Arduino Yún and open Arduino's serial monitor - - NOTE: You can test this Choreo and find the latest instructions on our website: - https://temboo.com/library/Library/Google/Gmail/SendEmail - - You can also find an in-depth version of this example here: - https://temboo.com/hardware/ti/send-an-email - - This example assumes basic familiarity with Arduino sketches, and that your Yún is connected - to the Internet. - - Looking for another API to use with your Arduino Yún? We've got over 100 in our Library! - - This example code is in the public domain. -*/ - -#include <Bridge.h> -#include <Temboo.h> -#include "TembooAccount.h" // contains Temboo account information - // as described in the footer comment below - -/*** SUBSTITUTE YOUR VALUES BELOW: ***/ - -// Note that for additional security and reusability, you could -// use #define statements to specify these values in a .h file. - -// your Gmail username, formatted as a complete email address, eg "bob.smith@gmail.com" -const String GMAIL_USER_NAME = "xxxxxxxxxx"; - -// your application specific password (see instructions above) -const String GMAIL_APP_PASSWORD = "xxxxxxxxxx"; - -// the email address you want to send the email to, eg "jane.doe@temboo.com" -const String TO_EMAIL_ADDRESS = "xxxxxxxxxx"; - -// a flag to indicate whether we've tried to send the email yet or not -boolean attempted = false; - -void setup() { - Serial.begin(9600); - - // for debugging, wait until a serial console is connected - delay(4000); - while(!Serial); - - Bridge.begin(); -} - -void loop() -{ - // only try to send the email if we haven't already tried - if (!attempted) { - - Serial.println("Running SendAnEmail..."); - - TembooChoreo SendEmailChoreo; - - // invoke the Temboo client - // NOTE that the client must be reinvoked, and repopulated with - // appropriate arguments, each time its run() method is called. - SendEmailChoreo.begin(); - - // set Temboo account credentials - SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT); - SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); - SendEmailChoreo.setAppKey(TEMBOO_APP_KEY); - - // identify the Temboo Library choreo to run (Google > Gmail > SendEmail) - SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail"); - - - // set the required choreo inputs - // see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/ - // for complete details about the inputs for this Choreo - - // the first input is your Gmail email address. - SendEmailChoreo.addInput("Username", GMAIL_USER_NAME); - // next is your application specific password - SendEmailChoreo.addInput("Password", GMAIL_APP_PASSWORD); - // who to send the email to - SendEmailChoreo.addInput("ToAddress", TO_EMAIL_ADDRESS); - // then a subject line - SendEmailChoreo.addInput("Subject", "ALERT: Greenhouse Temperature"); - - // next comes the message body, the main content of the email - SendEmailChoreo.addInput("MessageBody", "Hey! The greenhouse is too cold!"); - - // tell the Choreo to run and wait for the results. The - // return code (returnCode) will tell us whether the Temboo client - // was able to send our request to the Temboo servers - unsigned int returnCode = SendEmailChoreo.run(); - - // a return code of zero (0) means everything worked - if (returnCode == 0) { - Serial.println("Success! Email sent!"); - } else { - // a non-zero return code means there was an error - // read and print the error message - while (SendEmailChoreo.available()) { - char c = SendEmailChoreo.read(); - Serial.print(c); - } - } - SendEmailChoreo.close(); - - // set the flag showing we've tried - attempted = true; - } -} - -/* - IMPORTANT NOTE: TembooAccount.h: - - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, - by inserting your own Temboo account name and app key information. The contents of the file should - look like: - - #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name - #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name - #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - You can find your Temboo App Key information on the Temboo website, - under My Account > Application Keys - - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - - Keeping your account information in a separate file means you can share the main .ino file without worrying - that you forgot to delete your credentials. -*/ diff --git a/doc/Temboo/examples/ArduinoYun/SendAnEmail/TembooAccount.h b/doc/Temboo/examples/ArduinoYun/SendAnEmail/TembooAccount.h @@ -1,4 +0,0 @@ -#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name -#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name -#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - diff --git a/doc/Temboo/examples/ArduinoYun/SendAnSMS/SendAnSMS.ino b/doc/Temboo/examples/ArduinoYun/SendAnSMS/SendAnSMS.ino @@ -1,154 +0,0 @@ -/* - SendAnSMS - - Demonstrates sending an SMS via Twilio using Temboo from an Arduino Yún. - - Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino - - A Temboo account and application key are necessary to run all Temboo examples. - If you don't already have one, you can register for a free Temboo account at - http://www.temboo.com - - Since this sketch uses Twilio to send the SMS, you'll also need a valid - Twilio account. You can create one for free at https://www.twilio.com. - - The sketch needs your Twilio phone number, along with - the Account SID and Auth Token you get when you register with Twilio. - Make sure to use the Account SID and Auth Token from your Twilio Dashboard - (not your test credentials from the Dev Tools panel). - - Also note that if you're using a free Twilio account, you'll need to verify - the phone number to which messages are being sent by going to twilio.com and following - the instructions under the "Numbers > Verified Caller IDs" tab (this restriction - doesn't apply if you have a paid Twilio account). - - This example assumes basic familiarity with Arduino sketches, and that your Yún is connected - to the Internet. - - Looking for another API to use with your Arduino Yún? We've got over 100 in our Library! - - This example code is in the public domain. -*/ - -#include <Bridge.h> -#include <Temboo.h> -#include "TembooAccount.h" // contains Temboo account information - // as described in the footer comment below - - - -/*** SUBSTITUTE YOUR VALUES BELOW: ***/ - -// Note that for additional security and reusability, you could -// use #define statements to specify these values in a .h file. - -// the Account SID from your Twilio account -const String TWILIO_ACCOUNT_SID = "xxxxxxxxxx"; - -// the Auth Token from your Twilio account -const String TWILIO_AUTH_TOKEN = "xxxxxxxxxx"; - -// your Twilio phone number, e.g., "+1 555-222-1212" -const String TWILIO_NUMBER = "xxxxxxxxxx"; - -// the number to which the SMS should be sent, e.g., "+1 555-222-1212" -const String RECIPIENT_NUMBER = "xxxxxxxxxx"; - -// a flag to indicate whether we've attempted to send the SMS yet or not -boolean attempted = false; - -void setup() { - Serial.begin(9600); - - // for debugging, wait until a serial console is connected - delay(4000); - while(!Serial); - - Bridge.begin(); -} - -void loop() -{ - // only try to send the SMS if we haven't already sent it successfully - if (!attempted) { - - Serial.println("Running SendAnSMS..."); - - // we need a Process object to send a Choreo request to Temboo - TembooChoreo SendSMSChoreo; - - // invoke the Temboo client - // NOTE that the client must be reinvoked and repopulated with - // appropriate arguments each time its run() method is called. - SendSMSChoreo.begin(); - - // set Temboo account credentials - SendSMSChoreo.setAccountName(TEMBOO_ACCOUNT); - SendSMSChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); - SendSMSChoreo.setAppKey(TEMBOO_APP_KEY); - - // identify the Temboo Library choreo to run (Twilio > SMSMessages > SendSMS) - SendSMSChoreo.setChoreo("/Library/Twilio/SMSMessages/SendSMS"); - - // set the required choreo inputs - // see https://www.temboo.com/library/Library/Twilio/SMSMessages/SendSMS/ - // for complete details about the inputs for this Choreo - - // the first input is a your AccountSID - SendSMSChoreo.addInput("AccountSID", TWILIO_ACCOUNT_SID); - - // next is your Auth Token - SendSMSChoreo.addInput("AuthToken", TWILIO_AUTH_TOKEN); - - // next is your Twilio phone number - SendSMSChoreo.addInput("From", TWILIO_NUMBER); - - // next, what number to send the SMS to - SendSMSChoreo.addInput("To", RECIPIENT_NUMBER); - - // finally, the text of the message to send - SendSMSChoreo.addInput("Body", "Hey, there! This is a message from your Arduino Yun!"); - - // tell the Process to run and wait for the results. The - // return code (returnCode) will tell us whether the Temboo client - // was able to send our request to the Temboo servers - unsigned int returnCode = SendSMSChoreo.run(); - - // a return code of zero (0) means everything worked - if (returnCode == 0) { - Serial.println("Success! SMS sent!"); - } else { - // a non-zero return code means there was an error - // read and print the error message - while (SendSMSChoreo.available()) { - char c = SendSMSChoreo.read(); - Serial.print(c); - } - } - SendSMSChoreo.close(); - - // set the flag indicatine we've tried once. - attempted=true; - } -} - -/* - IMPORTANT NOTE: TembooAccount.h: - - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, - by inserting your own Temboo account name and app key information. The contents of the file should - look like: - - #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name - #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name - #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - You can find your Temboo App Key information on the Temboo website, - under My Account > Application Keys - - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - - Keeping your account information in a separate file means you can share the main .ino file without worrying - that you forgot to delete your credentials. -*/ diff --git a/doc/Temboo/examples/ArduinoYun/SendAnSMS/TembooAccount.h b/doc/Temboo/examples/ArduinoYun/SendAnSMS/TembooAccount.h @@ -1,5 +0,0 @@ -#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name -#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name -#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - diff --git a/doc/Temboo/examples/ArduinoYun/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino b/doc/Temboo/examples/ArduinoYun/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino @@ -1,200 +0,0 @@ -/* - SendDataToGoogleSpreadsheet - - Demonstrates appending a row of data to a Google spreadsheet using Temboo from an Arduino Yún. - - Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino - - A Temboo account and application key are necessary to run all Temboo examples. - If you don't already have one, you can register for a free Temboo account at - http://www.temboo.com - - Instructions: - - 1. Create a Temboo account: http://www.temboo.com - 2. Retrieve your Temboo application details: http://www.temboo.com/account/applications - 3. Replace the values in the TembooAccount.h tab with your Temboo application details - 4. You'll also need a Google Spreadsheet that includes a title in the first row - of each column that data will be written to. This example assumes there are two columns. - The first column is the time (in milliseconds) that the row was appended, and the second - column is a sensor value. In other words, your spreadsheet should look like: - - Time | Sensor Value | - ------+----------------- - | | - - 5. Google Spreadsheets requires you to authenticate via OAuth. Follow the steps - in the link below to find your ClientID, ClientSecret, and RefreshToken, and then - use those values to overwrite the placeholders in the code below. - - https://temboo.com/library/Library/Google/OAuth/ - - For the scope field, you need to use: https://spreadsheets.google.com/feeds/ - - Here's a video outlines how Temboo helps with the OAuth process: - - https://www.temboo.com/videos#oauthchoreos - - And here's a more in-depth version of this example on our website: - - https://temboo.com/hardware/ti/update-google-spreadsheet - - 6. Next, upload the sketch to your Arduino Yún and open Arduino's serial monitor - - Note: you can test this Choreo and find the latest instructions on our website: - https://temboo.com/library/Library/Google/Spreadsheets/AppendRow/ - - Looking for another API to use with your Arduino Yún? We've got over 100 in our Library! - - This example code is in the public domain. - -*/ - -#include <Bridge.h> -#include <Temboo.h> -#include "TembooAccount.h" // contains Temboo account information, - // as described in the footer comment below - - -/*** SUBSTITUTE YOUR VALUES BELOW: ***/ - -// Note that for additional security and reusability, you could -// use #define statements to specify these values in a .h file. - -// the clientID found in Google's Developer Console under APIs & Auth > Credentials -const String CLIENT_ID = "your-client-id"; - -// the clientSecret found in Google's Developer Console under APIs & Auth > Credentials -const String CLIENT_SECRET = "your-client-secret"; - -// returned after running FinalizeOAuth -const String REFRESH_TOKEN = "your-oauth-refresh-token"; - -// the title of the spreadsheet you want to send data to -// (Note that this must actually be the title of a Google spreadsheet -// that exists in your Google Drive/Docs account, and is configured -// as described above.) -const String SPREADSHEET_TITLE = "your-spreadsheet-title"; - -const unsigned long RUN_INTERVAL_MILLIS = 60000; // how often to run the Choreo (in milliseconds) - -// the last time we ran the Choreo -// (initialized to 60 seconds ago so the -// Choreo is run immediately when we start up) -unsigned long lastRun = (unsigned long)-60000; - -void setup() { - - // for debugging, wait until a serial console is connected - Serial.begin(9600); - delay(4000); - while(!Serial); - - Serial.print("Initializing the bridge..."); - Bridge.begin(); - Serial.println("Done"); -} - -void loop() -{ - // get the number of milliseconds this sketch has been running - unsigned long now = millis(); - - // run again if it's been 60 seconds since we last ran - if (now - lastRun >= RUN_INTERVAL_MILLIS) { - - // remember 'now' as the last time we ran the choreo - lastRun = now; - - Serial.println("Getting sensor value..."); - - // get the value we want to append to our spreadsheet - unsigned long sensorValue = getSensorValue(); - - Serial.println("Appending value to spreadsheet..."); - - // we need a Process object to send a Choreo request to Temboo - TembooChoreo AppendRowChoreo; - - // invoke the Temboo client - // NOTE that the client must be reinvoked and repopulated with - // appropriate arguments each time its run() method is called. - AppendRowChoreo.begin(); - - // set Temboo account credentials - AppendRowChoreo.setAccountName(TEMBOO_ACCOUNT); - AppendRowChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); - AppendRowChoreo.setAppKey(TEMBOO_APP_KEY); - - // identify the Temboo Library choreo to run (Google > Spreadsheets > AppendRow) - AppendRowChoreo.setChoreo("/Library/Google/Spreadsheets/AppendRow"); - - // set the required Choreo inputs - // see https://www.temboo.com/library/Library/Google/Spreadsheets/AppendRow/ - // for complete details about the inputs for this Choreo - - // your Google application client ID - AppendRowChoreo.addInput("ClientID", CLIENT_ID); - // your Google application client secert - AppendRowChoreo.addInput("ClientSecret", CLIENT_SECRET); - // your Google OAuth refresh token - AppendRowChoreo.addInput("RefreshToken", REFRESH_TOKEN); - - // the title of the spreadsheet you want to append to - // NOTE: substitute your own value, retaining the "SpreadsheetTitle:" prefix. - AppendRowChoreo.addInput("SpreadsheetTitle", SPREADSHEET_TITLE); - - // convert the time and sensor values to a comma separated string - String rowData(now); - rowData += ","; - rowData += sensorValue; - - // add the RowData input item - AppendRowChoreo.addInput("RowData", rowData); - - // run the Choreo and wait for the results - // The return code (returnCode) will indicate success or failure - unsigned int returnCode = AppendRowChoreo.run(); - - // return code of zero (0) means success - if (returnCode == 0) { - Serial.println("Success! Appended " + rowData); - Serial.println(""); - } else { - // return code of anything other than zero means failure - // read and display any error messages - while (AppendRowChoreo.available()) { - char c = AppendRowChoreo.read(); - Serial.print(c); - } - } - - AppendRowChoreo.close(); - } -} - -// this function simulates reading the value of a sensor -unsigned long getSensorValue() { - return analogRead(A0); -} - -/* - IMPORTANT NOTE: TembooAccount.h: - - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, - by inserting your own Temboo account name and app key information. The contents of the file should - look like: - - #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name - #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name - #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - You can find your Temboo App Key information on the Temboo website, - under My Account > Application Keys - - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - - Keeping your account information in a separate file means you can share the main .ino file without worrying - that you forgot to delete your credentials. -*/ diff --git a/doc/Temboo/examples/ArduinoYun/SendDataToGoogleSpreadsheet/TembooAccount.h b/doc/Temboo/examples/ArduinoYun/SendDataToGoogleSpreadsheet/TembooAccount.h @@ -1,5 +0,0 @@ -#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name -#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name -#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - diff --git a/doc/Temboo/examples/ArduinoYun/ToxicFacilitiesSearch/TembooAccount.h b/doc/Temboo/examples/ArduinoYun/ToxicFacilitiesSearch/TembooAccount.h @@ -1,5 +0,0 @@ -#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name -#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name -#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - diff --git a/doc/Temboo/examples/ArduinoYun/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino b/doc/Temboo/examples/ArduinoYun/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino @@ -1,171 +0,0 @@ -/* - ToxicFacilitiesSearch - - Demonstrates making a request to the Envirofacts API using Temboo from an Arduino Yún. - This example retrieves the names and addresses of EPA-regulated facilities in the - Toxins Release Inventory (TRI) database within a given zip code. - - Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino - - A Temboo account and application key are necessary to run all Temboo examples. - If you don't already have one, you can register for a free Temboo account at - http://www.temboo.com - - This example assumes basic familiarity with Arduino sketches, and that your Yún is connected - to the Internet. - - Looking for another API to use with your Arduino Yún? We've got over 100 in our Library! - - This example code is in the public domain. -*/ - -#include <Bridge.h> -#include <Temboo.h> -#include "TembooAccount.h" // contains Temboo account information - // as described in the footer comment below - -// the zip code to search for toxin-emitting facilities -String US_ZIP_CODE = "11215"; - -int numRuns = 1; // execution count, so that this doesn't run forever -int maxRuns = 10; // max number of times the Envirofacts FacilitiesSearch Choreo should be run - -void setup() { - Serial.begin(9600); - - // for debugging, wait until a serial console is connected - delay(4000); - while(!Serial); - Bridge.begin(); -} - -void loop() -{ - // while we haven't reached the max number of runs... - if (numRuns <= maxRuns) { - - // print status - Serial.println("Running ToxicFacilitiesSearch - Run #" + String(numRuns++) + "..."); - - // we need a Process object to send a Choreo request to Temboo - TembooChoreo FacilitiesSearchByZipChoreo; - - // invoke the Temboo client - // NOTE that the client must be reinvoked and repopulated with - // appropriate arguments each time its run() method is called. - FacilitiesSearchByZipChoreo.begin(); - - // set Temboo account credentials - FacilitiesSearchByZipChoreo.setAccountName(TEMBOO_ACCOUNT); - FacilitiesSearchByZipChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); - FacilitiesSearchByZipChoreo.setAppKey(TEMBOO_APP_KEY); - - // identify the Temboo Library choreo to run (EnviroFacts > Toxins > FacilitiesSearchByZip) - FacilitiesSearchByZipChoreo.setChoreo("/Library/EnviroFacts/Toxins/FacilitiesSearchByZip"); - - // set choreo inputs; in this case, the US zip code for which to retrieve toxin release data - // the Temboo client provides standardized calls to 100+ cloud APIs - FacilitiesSearchByZipChoreo.addInput("Zip", US_ZIP_CODE); - - // specify two output filters, to help simplify the Envirofacts API results. - // see the tutorials on using Temboo SDK output filters at http://www.temboo.com/arduino - FacilitiesSearchByZipChoreo.addOutputFilter("fac", "FACILITY_NAME", "Response"); - - FacilitiesSearchByZipChoreo.addOutputFilter("addr", "STREET_ADDRESS", "Response"); - - // run the choreo - unsigned int returnCode = FacilitiesSearchByZipChoreo.run(); - if (returnCode == 0) { - String facilities; - String addresses; - - // when the choreo results are available, process them. - // the output filters we specified will return comma delimited - // lists containing the name and street address of the facilities - // located in the specified zip code. - while(FacilitiesSearchByZipChoreo.available()) { - String name = FacilitiesSearchByZipChoreo.readStringUntil('\x1F'); - name.trim(); - - String data = FacilitiesSearchByZipChoreo.readStringUntil('\x1E'); - data.trim(); - - if (name == "fac") { - facilities = data; - } else if (name == "addr") { - addresses = data; - } - } - FacilitiesSearchByZipChoreo.close(); - - // parse the comma delimited lists of facilities to join the - // name with the address and print it to the serial monitor - if (facilities.length() > 0) { - int i = -1; - int facilityStart = 0; - int addressStart = 0; - String facility; - String address; - do { - i = facilities.indexOf(',', facilityStart); - if (i >= 0) { - facility = facilities.substring(facilityStart, i); - facilityStart = i + 1; - } - - i = addresses.indexOf(',', addressStart); - if (i >= 0) { - address = addresses.substring(addressStart, i); - addressStart = i + 1; - } - - if (i >= 0) { - printResult(facility, address); - } - - }while (i >= 0); - facility = facilities.substring(facilityStart); - address = addresses.substring(addressStart); - printResult(facility, address); - } else { - Serial.println("No facilities found in zip code " + US_ZIP_CODE); - } - } else { - while(FacilitiesSearchByZipChoreo.available()) { - char c = FacilitiesSearchByZipChoreo.read(); - Serial.print(c); - } - } - } - Serial.println("Waiting..."); - Serial.println(""); - delay(30000); // wait 30 seconds between calls -} - -// a simple utility function, to output the facility name and address in the serial monitor. -void printResult(String facility, String address) { - Serial.print(facility); - Serial.print(" - "); - Serial.println(address); -} - -/* - IMPORTANT NOTE: TembooAccount.h: - - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, - by inserting your own Temboo account name and app key information. The contents of the file should - look like: - - #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name - #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name - #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - You can find your Temboo App Key information on the Temboo website, - under My Account > Application Keys - - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - - Keeping your account information in a separate file means you can share the main .ino file without worrying - that you forgot to delete your credentials. -*/ diff --git a/doc/Temboo/examples/ArduinoYun/UpdateFacebookStatus/TembooAccount.h b/doc/Temboo/examples/ArduinoYun/UpdateFacebookStatus/TembooAccount.h @@ -1,5 +0,0 @@ -#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name -#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name -#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - diff --git a/doc/Temboo/examples/ArduinoYun/UpdateFacebookStatus/UpdateFacebookStatus.ino b/doc/Temboo/examples/ArduinoYun/UpdateFacebookStatus/UpdateFacebookStatus.ino @@ -1,132 +0,0 @@ -/* - UpdateFacebookStatus - - Demonstrates sending a Facebook status update using Temboo from an Arduino Yún. - - Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino - - A Temboo account and application key are necessary to run all Temboo examples. - If you don't already have one, you can register for a free Temboo account at - http://www.temboo.com - - In order to run this sketch, you'll need to register an application using - the Facebook dev console at https://developers.facebook.com/apps -- after creating - the app, log in to Temboo and visit https://www.temboo.com/library/Library/Facebook/Publishing/SetStatus/ - to use our OAuth Wizard (or OAuth Choreos) to obtain a Facebook access token. - Substitute your access token for the placeholder value of FACEBOOK_ACCESS_TOKEN below. - - This example assumes basic familiarity with Arduino sketches, and that your Yún - is connected to the Internet. - - Want to use another social API with your Arduino Yún? We've got Twitter, Google+, - Instagram, Tumblr and more in our Library! - - This example code is in the public domain. -*/ - -#include <Bridge.h> -#include <Temboo.h> -#include "TembooAccount.h" // contains Temboo account information, - // as described in the footer comment below - -/*** SUBSTITUTE YOUR VALUES BELOW: ***/ - -// Note that for additional security and reusability, you could -// use a #define statement to specify this value in a .h file. - -// the Facebook Access Token, which can be obtained using the Temboo OAuth Wizard or Choreos -const String FACEBOOK_ACCESS_TOKEN = "xxxxxxxxxx"; - - -int numRuns = 1; // execution count, so this sketch doesn't run forever -int maxRuns = 10; // the max number of times the Facebook SetStatus Choreo should run - -void setup() { - Serial.begin(9600); - - // For debugging, wait until a serial console is connected. - delay(4000); - while(!Serial); - Bridge.begin(); -} - -void loop() { - // while we haven't reached the max number of runs... - if (numRuns <= maxRuns) { - - // print status - Serial.println("Running UpdateFacebookStatus - Run #" + String(numRuns++) + "..."); - - // Define the status message we want to post on Facebook; since Facebook - // doesn't allow duplicate status messages, we'll include a changing value. - String statusMsg = "My Arduino Yun has been running for " + String(millis()) + " milliseconds!"; - - // define the Process that will be used to call the "temboo" client - TembooChoreo SetStatusChoreo; - - // invoke the Temboo client - // NOTE that the client must be reinvoked and repopulated with - // appropriate arguments each time its run() method is called. - SetStatusChoreo.begin(); - - // set Temboo account credentials - SetStatusChoreo.setAccountName(TEMBOO_ACCOUNT); - SetStatusChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); - SetStatusChoreo.setAppKey(TEMBOO_APP_KEY); - - // tell the Temboo client which Choreo to run (Facebook > Publishing > SetStatus) - SetStatusChoreo.setChoreo("/Library/Facebook/Publishing/SetStatus"); - - // set the required choreo inputs - // see https://www.temboo.com/library/Library/Facebook/Publishing/SetStatus/ - // for complete details about the inputs for this Choreo - - SetStatusChoreo.addInput("AccessToken", FACEBOOK_ACCESS_TOKEN); - SetStatusChoreo.addInput("Message", statusMsg); - - - // tell the Process to run and wait for the results. The - // return code (returnCode) will tell us whether the Temboo client - // was able to send our request to the Temboo servers - unsigned int returnCode = SetStatusChoreo.run(); - - // print the response code and API response. - Serial.println("Response code: " + String(returnCode)); - - // note that in this case, we're just printing the raw response from Facebook. - // see the examples on using Temboo SDK output filters at http://www.temboo.com/arduino - // for information on how to filter this data - while(SetStatusChoreo.available()) { - char c = SetStatusChoreo.read(); - Serial.print(c); - } - - SetStatusChoreo.close(); - } - - Serial.println("Waiting..."); - Serial.println(""); - - delay(30000); // wait 30 seconds between SetStatus calls -} - -/* - IMPORTANT NOTE: TembooAccount.h: - - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, - by inserting your own Temboo account name and app key information. The contents of the file should - look like: - - #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name - #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name - #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - You can find your Temboo App Key information on the Temboo website, - under My Account > Application Keys - - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - - Keeping your account information in a separate file means you can share the main .ino file without worrying - that you forgot to delete your credentials. -*/ diff --git a/doc/Temboo/examples/ArduinoYun/UploadToDropbox/TembooAccount.h b/doc/Temboo/examples/ArduinoYun/UploadToDropbox/TembooAccount.h @@ -1,5 +0,0 @@ -#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name -#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name -#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - diff --git a/doc/Temboo/examples/ArduinoYun/UploadToDropbox/UploadToDropbox.ino b/doc/Temboo/examples/ArduinoYun/UploadToDropbox/UploadToDropbox.ino @@ -1,208 +0,0 @@ -/* - UploadToDropbox - - Demonstrates uploading a file to a Dropbox account using Temboo from an Arduino Yún. - - Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino - - A Temboo account and application key are necessary to run all Temboo examples. - If you don't already have one, you can register for a free Temboo account at - http://www.temboo.com - - You'll also need a valid Dropbox app and accompanying OAuth credentials. - To create a Dropbox app, visit https://www.dropbox.com/developers/apps and - do the following: - - 1. Create a "Dropbox API app" - 2. Select "Files and datastores" - 3. Select "Yes - my app only needs access to the files it creates." - - Once you've created your app, follow the instructions at - https://www.temboo.com/library/Library/Dropbox/OAuth/ to run the Initialize and Finalize - OAuth Choreos. These Choreos complete the OAuth handshake and retrieve your Dropbox OAuth access tokens. - - This example assumes basic familiarity with Arduino sketches, and that your Yún is connected - to the Internet. - - Looking for another API to use with your Arduino Yún? We've got over 100 in our Library! - - This example code is in the public domain. -*/ - -#include <Bridge.h> -#include <Temboo.h> -#include "TembooAccount.h" // contains Temboo account information - // as described in the footer comment below - - -/*** SUBSTITUTE YOUR VALUES BELOW: ***/ - -// Note that for additional security and reusability, you could -// use #define statements to specify these values in a .h file. - -// your Dropbox app key, available on the Dropbox developer console after registering an app -const String DROPBOX_APP_KEY = "xxxxxxxxxx"; - -// your Dropbox app secret, available on the Dropbox developer console after registering an app -const String DROPBOX_APP_SECRET = "xxxxxxxxxx"; - -// your Dropbox access token, which is returned by the FinalizeOAuth Choreo -const String DROPBOX_ACCESS_TOKEN = "xxxxxxxxxx"; - -// your Dropbox access token secret, which is returned by the FinalizeOAuth Choreo -const String DROPBOX_ACCESS_TOKEN_SECRET = "xxxxxxxxxx"; - - -boolean success = false; // a flag to indicate whether we've uploaded the file yet - -void setup() { - Serial.begin(9600); - - // For debugging, wait until a serial console is connected. - delay(4000); - while(!Serial); - Bridge.begin(); -} - -void loop() -{ - // only try to upload the file if we haven't already done so - if (!success) { - - Serial.println("Base64 encoding data to upload..."); - - // base64 encode the data to upload - String base64EncodedData = base64Encode("Hello, Arduino!"); - - - Serial.println("Uploading data to Dropbox..."); - - // we need a Process object to send a Choreo request to Temboo - TembooChoreo UploadFileChoreo; - - // invoke the Temboo client - // NOTE that the client must be reinvoked and repopulated with - // appropriate arguments each time its run() method is called. - UploadFileChoreo.begin(); - - // set Temboo account credentials - UploadFileChoreo.setAccountName(TEMBOO_ACCOUNT); - UploadFileChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); - UploadFileChoreo.setAppKey(TEMBOO_APP_KEY); - - // identify the Temboo Library choreo to run (Dropbox > FilesAndMetadata > UploadFile) - UploadFileChoreo.setChoreo("/Library/Dropbox/FilesAndMetadata/UploadFile"); - - // set the required choreo inputs - // see https://www.temboo.com/library/Library/Dropbox/FilesAndMetadata/UploadFile/ - // for complete details about the inputs for this Choreo - - // first specify the name of the file to create/update on Dropbox - UploadFileChoreo.addInput("FileName", "ArduinoTest.txt"); - - // next, the root folder on Dropbox relative to which the file path is specified. - // to work with the Dropbox app you created earlier, this should be left as "sandbox" - // if your Dropbox app has full access to your files, specify "dropbox" - UploadFileChoreo.addInput("Root","sandbox"); - - // next, the Base64 encoded file data to upload - UploadFileChoreo.addInput("FileContents", base64EncodedData); - - // finally, the Dropbox OAuth credentials defined above - UploadFileChoreo.addInput("AppSecret", DROPBOX_APP_SECRET); - UploadFileChoreo.addInput("AccessToken", DROPBOX_ACCESS_TOKEN); - UploadFileChoreo.addInput("AccessTokenSecret", DROPBOX_ACCESS_TOKEN_SECRET); - UploadFileChoreo.addInput("AppKey", DROPBOX_APP_KEY); - - // tell the Process to run and wait for the results. The - // return code (returnCode) will tell us whether the Temboo client - // was able to send our request to the Temboo servers - unsigned int returnCode = UploadFileChoreo.run(); - - // a return code of zero (0) means everything worked - if (returnCode == 0) { - Serial.println("Success! File uploaded!"); - success = true; - } else { - // a non-zero return code means there was an error - Serial.println("Uh-oh! Something went wrong!"); - } - - // print out the full response to the serial monitor in all - // cases, just for debugging - while (UploadFileChoreo.available()) { - char c = UploadFileChoreo.read(); - Serial.print(c); - } - UploadFileChoreo.close(); - - Serial.println("Waiting..."); - } - - delay(30000); // wait 30 seconds between upload attempts -} - - -/* - A utility function to Base64 encode the specified string - by calling a Temboo Utilities Choreo. -*/ -String base64Encode(String toEncode) { - - // we need a Process object to send a Choreo request to Temboo - TembooChoreo Base64EncodeChoreo; - - // invoke the Temboo client - Base64EncodeChoreo.begin(); - - // set Temboo account credentials - Base64EncodeChoreo.setAccountName(TEMBOO_ACCOUNT); - Base64EncodeChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); - Base64EncodeChoreo.setAppKey(TEMBOO_APP_KEY); - - // identify the Temboo Library choreo to run (Utilities > Encoding > Base64Encode) - Base64EncodeChoreo.setChoreo("/Library/Utilities/Encoding/Base64Encode"); - - // set choreo inputs - Base64EncodeChoreo.addInput("Text", toEncode); - - // run the choreo - Base64EncodeChoreo.run(); - - // read in the choreo results, and return the "Base64EncodedText" output value. - // see http://www.temboo.com/arduino for more details on using choreo outputs. - while(Base64EncodeChoreo.available()) { - // read the name of the output item - String name = Base64EncodeChoreo.readStringUntil('\x1F'); - name.trim(); - - // read the value of the output item - String data = Base64EncodeChoreo.readStringUntil('\x1E'); - data.trim(); - - if(name == "Base64EncodedText") { - return data; - } - } -} - -/* - IMPORTANT NOTE: TembooAccount.h: - - TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. - You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, - by inserting your own Temboo account name and app key information. The contents of the file should - look like: - - #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name - #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name - #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key - - You can find your Temboo App Key information on the Temboo website, - under My Account > Application Keys - - The same TembooAccount.h file settings can be used for all Temboo SDK sketches. - - Keeping your account information in a separate file means you can share the main .ino file without worrying - that you forgot to delete your credentials. -*/