├── .gitignore ├── .travis.yml ├── AccelerometerSensorShield.cpp ├── AccelerometerSensorShield.h ├── BarcodeScannerShield.cpp ├── BarcodeScannerShield.h ├── BuzzerShield.cpp ├── BuzzerShield.h ├── CHANGELOG.md ├── CameraShield.cpp ├── CameraShield.h ├── ChartShield.cpp ├── ChartShield.h ├── CircularBuffer.h ├── ClockShield.cpp ├── ClockShield.h ├── ColorShield.cpp ├── ColorShield.h ├── DataLoggerShield.cpp ├── DataLoggerShield.h ├── EmailShield.cpp ├── EmailShield.h ├── FaceDetectionShield.cpp ├── FaceDetectionShield.h ├── FacebookShield.cpp ├── FacebookShield.h ├── FingerprintScannerShield.cpp ├── FingerprintScannerShield.h ├── FoursquareShield.cpp ├── FoursquareShield.h ├── GLCDAnalogGauge.cpp ├── GLCDAnalogGauge.h ├── GLCDButton.cpp ├── GLCDButton.h ├── GLCDCheckBox.cpp ├── GLCDCheckBox.h ├── GLCDEllipse.cpp ├── GLCDEllipse.h ├── GLCDLine.cpp ├── GLCDLine.h ├── GLCDPoint.cpp ├── GLCDPoint.h ├── GLCDProgressBar.cpp ├── GLCDProgressBar.h ├── GLCDRadioButton.cpp ├── GLCDRadioButton.h ├── GLCDRectangle.cpp ├── GLCDRectangle.h ├── GLCDShield.cpp ├── GLCDShield.h ├── GLCDSlider.cpp ├── GLCDSlider.h ├── GLCDTextBox.cpp ├── GLCDTextBox.h ├── GPSShield.cpp ├── GPSShield.h ├── GamePadShield.cpp ├── GamePadShield.h ├── GravitySensorShield.cpp ├── GravitySensorShield.h ├── GyroscopeSensorShield.cpp ├── GyroscopeSensorShield.h ├── HttpRequest.cpp ├── HttpRequest.h ├── HttpResponse.cpp ├── HttpResponse.h ├── IOTShield.cpp ├── IOTShield.h ├── IncludedShieldsDefines.h ├── InternetShield.cpp ├── InternetShield.h ├── JsonKey.cpp ├── JsonKey.h ├── JsonKeyChain.cpp ├── JsonKeyChain.h ├── KeyboardShield.cpp ├── KeyboardShield.h ├── KeypadShield.cpp ├── KeypadShield.h ├── LCDShield.cpp ├── LCDShield.h ├── LICENSE.md ├── LedShield.cpp ├── LedShield.h ├── LightSensorShield.cpp ├── LightSensorShield.h ├── MagnetometerSensorShield.cpp ├── MagnetometerSensorShield.h ├── MicShield.cpp ├── MicShield.h ├── MusicPlayerShield.cpp ├── MusicPlayerShield.h ├── NFCRecord.cpp ├── NFCRecord.h ├── NFCShield.cpp ├── NFCShield.h ├── NFCTag.cpp ├── NFCTag.h ├── NotificationShield.cpp ├── NotificationShield.h ├── OneSheeld.cpp ├── OneSheeld.h ├── OneSheeldPrint.cpp ├── OneSheeldPrint.h ├── OneSheeldPrintln.cpp ├── OneSheeldPrintln.h ├── OrientationSensorShield.cpp ├── OrientationSensorShield.h ├── PatternShield.cpp ├── PatternShield.h ├── PhoneShield.cpp ├── PhoneShield.h ├── PressureSensorShield.cpp ├── PressureSensorShield.h ├── ProximitySensorShield.cpp ├── ProximitySensorShield.h ├── PushButtonShield.cpp ├── PushButtonShield.h ├── README.md ├── SMSShield.cpp ├── SMSShield.h ├── SevenSegmentShield.cpp ├── SevenSegmentShield.h ├── ShapeClass.cpp ├── ShapeClass.h ├── ShieldParent.cpp ├── ShieldParent.h ├── ShieldsIds.h ├── ShieldsIncludes.h ├── ShieldsInstantiation.h ├── ShieldsSelection.h ├── SkypeShield.cpp ├── SkypeShield.h ├── SliderShield.cpp ├── SliderShield.h ├── TTSShield.cpp ├── TTSShield.h ├── TemperatureSensorShield.cpp ├── TemperatureSensorShield.h ├── TerminalShield.cpp ├── TerminalShield.h ├── ToggleButtonShield.cpp ├── ToggleButtonShield.h ├── TwitterShield.cpp ├── TwitterShield.h ├── VibrationShield.cpp ├── VibrationShield.h ├── VoiceRecognitionShield.cpp ├── VoiceRecognitionShield.h ├── examples ├── Advanced │ ├── Accelerometer │ │ └── Accelerometer.ino │ ├── BarcodeScanner │ │ └── BarcodeScanner.ino │ ├── Buzzer │ │ └── Buzzer.ino │ ├── Camera │ │ └── Camera.ino │ ├── Clock │ │ └── Clock.ino │ ├── Color │ │ └── Color.ino │ ├── Email │ │ └── Email.ino │ ├── Facebook │ │ └── Facebook.ino │ ├── Foursquare │ │ └── Foursquare.ino │ ├── GLCD │ │ └── GLCD.ino │ ├── GPS │ │ └── GPS.ino │ ├── GamePad │ │ └── GamePad.ino │ ├── Gravity │ │ └── Gravity.ino │ ├── IOT │ │ └── IOT.ino │ ├── Internet │ │ └── Internet.ino │ ├── Keypad │ │ └── Keypad.ino │ ├── LCD │ │ └── LCD.ino │ ├── Light │ │ └── Light.ino │ ├── Magnetometer │ │ └── Magnetometer.ino │ ├── Mic │ │ └── Mic.ino │ ├── MusicPlayer │ │ └── MusicPlayer.ino │ ├── NFC │ │ └── NFC.ino │ ├── Notification │ │ └── Notification.ino │ ├── Orientation │ │ └── Orientation.ino │ ├── Phone │ │ └── Phone.ino │ ├── Pressure │ │ └── Pressure.ino │ ├── Proximity │ │ └── Proximity.ino │ ├── SMS │ │ └── SMS.ino │ ├── SevenSegment │ │ └── SevenSegment.ino │ ├── Skype │ │ └── Skype.ino │ ├── TextToSpeech │ │ └── TextToSpeech.ino │ ├── ToggleButton │ │ └── ToggleButton.ino │ ├── Twitter │ │ └── Twitter.ino │ ├── Vibration │ │ └── Vibration.ino │ └── VoiceRecognition │ │ └── VoiceRecognition.ino └── Simple │ ├── Accelerometer │ └── Accelerometer.ino │ ├── BarcodeScanner │ └── BarcodeScanner.ino │ ├── Buzzer │ └── Buzzer.ino │ ├── Camera │ └── Camera.ino │ ├── Chart │ └── Chart.ino │ ├── Color │ └── Color.ino │ ├── DataLogger │ └── DataLogger.ino │ ├── FaceDetector │ └── FaceDetector.ino │ ├── Facebook │ └── Facebook.ino │ ├── FingerprintScanner │ └── FingerprintScanner.ino │ ├── Foursquare │ └── Foursquare.ino │ ├── GLCD │ └── GLCD.ino │ ├── GamePad │ └── GamePad.ino │ ├── Gravity │ └── Gravity.ino │ ├── Gyroscope │ └── Gyroscope.ino │ ├── IOT │ └── IOT.ino │ ├── Internet │ └── Internet.ino │ ├── Keyboard │ └── Keyboard.ino │ ├── Keypad │ └── Keypad.ino │ ├── Led │ └── Led.ino │ ├── Light │ └── Light.ino │ ├── Magnetometer │ └── Magnetometer.ino │ ├── Mic │ └── Mic.ino │ ├── MusicPlayer │ └── MusicPlayer.ino │ ├── NFC │ └── NFC.ino │ ├── Notification │ └── Notification.ino │ ├── Orientation │ └── Orientation.ino │ ├── Pattern │ └── Pattern.ino │ ├── Phone │ └── Phone.ino │ ├── Proximity │ └── Proximity.ino │ ├── PushButton │ └── PushButton.ino │ ├── Slider │ └── Slider.ino │ ├── Temperature │ └── Temperature.ino │ ├── Terminal │ └── Terminal.ino │ ├── Twitter │ └── Twitter.ino │ ├── Vibration │ └── Vibration.ino │ └── VoiceRecognition │ └── VoiceRecognition.ino ├── keywords.txt └── library.properties /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | thumbs.db 3 | *.zip 4 | *.sublime-project 5 | *.sublime-workspace -------------------------------------------------------------------------------- /AccelerometerSensorShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: AccelerometerSensorShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "AccelerometerSensorShield.h" 18 | 19 | 20 | 21 | //Class Constructor 22 | AccelerometerSensorShield::AccelerometerSensorShield(): ShieldParent(ACCELEROMETER_ID) 23 | { 24 | valueX=0; 25 | valueY=0; 26 | valueZ=0; 27 | isCallBackAssigned=false; 28 | } 29 | 30 | //X-Axis getter function 31 | float AccelerometerSensorShield::getX() 32 | { 33 | return valueX; 34 | } 35 | 36 | //Y-Axis getter function 37 | float AccelerometerSensorShield::getY() 38 | { 39 | return valueY; 40 | } 41 | 42 | //Z-Axis getter function 43 | float AccelerometerSensorShield::getZ() 44 | { 45 | return valueZ; 46 | } 47 | 48 | //AccelerometerSensor Input Data processing 49 | void AccelerometerSensorShield::processData() 50 | { 51 | //Check Function-ID 52 | byte functionId=getOneSheeldInstance().getFunctionId(); 53 | 54 | if(functionId==ACCELEROMETER_VALUE) 55 | { 56 | //Process X-Axis Value 57 | valueX=getOneSheeldInstance().convertBytesToFloat(getOneSheeldInstance().getArgumentData(0)); 58 | //Process Y-Axis Value 59 | valueY=getOneSheeldInstance().convertBytesToFloat(getOneSheeldInstance().getArgumentData(1)); 60 | //Process Z-Axis Value 61 | valueZ=getOneSheeldInstance().convertBytesToFloat(getOneSheeldInstance().getArgumentData(2)); 62 | 63 | //User Function Invoked 64 | if(isCallBackAssigned && !isInACallback()) 65 | { 66 | enteringACallback(); 67 | (*changeCallBack)(valueX,valueY,valueZ); 68 | exitingACallback(); 69 | } 70 | } 71 | } 72 | 73 | //Users Function Setter 74 | void AccelerometerSensorShield::setOnValueChange(void (* usersFunction)(float valueX,float valueY,float valueZ)) 75 | { 76 | changeCallBack=usersFunction; 77 | isCallBackAssigned=true; 78 | } 79 | 80 | -------------------------------------------------------------------------------- /AccelerometerSensorShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: AccelerometerSensorShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef AccelerometerSensorShield_h 17 | #define AccelerometerSensorShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Input Function ID 22 | #define ACCELEROMETER_VALUE 0x01 23 | 24 | 25 | 26 | 27 | class AccelerometerSensorShield : public ShieldParent 28 | { 29 | public: 30 | //Constructor 31 | AccelerometerSensorShield(); 32 | //Getter Functions 33 | float getX(); 34 | float getY(); 35 | float getZ(); 36 | //setOnChange for Users Function 37 | void setOnValueChange(void (*)(float,float,float)); 38 | private: 39 | //Reserve Variables 40 | float valueX,valueY,valueZ; 41 | //Boolean for setOnChange Function 42 | bool isCallBackAssigned; 43 | //Process Input Data 44 | void processData(); 45 | void (*changeCallBack)(float,float,float); 46 | }; 47 | 48 | //Extern Object 49 | extern AccelerometerSensorShield AccelerometerSensor; 50 | #endif -------------------------------------------------------------------------------- /BuzzerShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: BuzzerShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "BuzzerShield.h" 18 | 19 | //Class Constructor 20 | BuzzerShieldClass::BuzzerShieldClass():ShieldParent(BUZZER_ID) 21 | { 22 | buzzing = false; 23 | } 24 | 25 | //Buzzing On 26 | void BuzzerShieldClass::buzzOn() 27 | { 28 | if(buzzing == false) 29 | { 30 | setValue(BUZZER_ON); 31 | buzzing=true; 32 | } 33 | 34 | } 35 | 36 | //Buzzing Off 37 | void BuzzerShieldClass::buzzOff() 38 | { 39 | if(buzzing == true) 40 | { 41 | setValue(BUZZER_OFF); 42 | buzzing=false; 43 | } 44 | 45 | } 46 | 47 | //Buzz Setter 48 | void BuzzerShieldClass::setValue(byte x) 49 | { 50 | OneSheeld.sendShieldFrame(BUZZER_ID,0,BUZZER_SET,1,new FunctionArg(1,&x)); 51 | } 52 | 53 | -------------------------------------------------------------------------------- /BuzzerShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: BuzzerShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef BuzzerShield_h 17 | #define BuzzerShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Ouput Functions ID's 22 | #define BUZZER_SET 0x01 23 | #define BUZZER_OFF 0x00 24 | #define BUZZER_ON 0x01 25 | 26 | 27 | class BuzzerShieldClass : public ShieldParent 28 | { 29 | public: 30 | //Constructor 31 | BuzzerShieldClass(); 32 | //Setters 33 | void buzzOn(); 34 | void buzzOff(); 35 | 36 | private: 37 | //Boolean for buzz check 38 | bool buzzing; 39 | //Setter 40 | void setValue(byte x); 41 | 42 | }; 43 | 44 | //Extern Object 45 | extern BuzzerShieldClass Buzzer; 46 | #endif -------------------------------------------------------------------------------- /CameraShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: CameraShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "CameraShield.h" 18 | 19 | 20 | void CameraShieldClass::resetParameters() 21 | { 22 | OneSheeld.sendShieldFrame(CAMERA_ID,0,CAMERA_RESET,0); 23 | } 24 | 25 | //Rear Capture 26 | void CameraShieldClass::rearCapture() 27 | { 28 | OneSheeld.sendShieldFrame(CAMERA_ID,0,CAMERA_REAR_CAPTURE,0); 29 | } 30 | //Camera Flash 31 | void CameraShieldClass::setFlash(byte x) 32 | { 33 | OneSheeld.sendShieldFrame(CAMERA_ID,0,CAMERA_SET_FLASH,1,new FunctionArg(1,&x)); 34 | } 35 | //Front Capture 36 | void CameraShieldClass::frontCapture() 37 | { 38 | OneSheeld.sendShieldFrame(CAMERA_ID,0,CAMERA_FRONT_CAPTURE,0); 39 | } 40 | //Quality Set 41 | void CameraShieldClass::setQuality(byte x) 42 | { 43 | OneSheeld.sendShieldFrame(CAMERA_ID,0,CAMERA_SET_QUALITY,1,new FunctionArg(1,&x)); 44 | } 45 | 46 | void CameraShieldClass::record(unsigned long seconds,byte cameraPosition) 47 | { 48 | OneSheeld.sendShieldFrame(CAMERA_ID,0,CAMERA_RECORD_VIDEO,2,new FunctionArg(4,(byte*)&seconds),new FunctionArg(1,&cameraPosition)); 49 | } 50 | 51 | void CameraShieldClass::zoom(byte zoomValue,bool smoothZoom) 52 | { 53 | if(zoomValue>100){zoomValue=100;} 54 | OneSheeld.sendShieldFrame(CAMERA_ID,0,CAMERA_ZOOM,2,new FunctionArg(1,&zoomValue),new FunctionArg(1,(byte*)&smoothZoom)); 55 | } -------------------------------------------------------------------------------- /CameraShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: CameraShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef CameraShield_h 17 | #define CameraShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Output Functions ID's 22 | #define CAMERA_RESET 0x00 23 | #define CAMERA_REAR_CAPTURE 0x01 24 | #define CAMERA_SET_FLASH 0x02 25 | #define CAMERA_FRONT_CAPTURE 0x03 26 | #define CAMERA_SET_QUALITY 0x04 27 | #define CAMERA_RECORD_VIDEO 0x05 28 | #define CAMERA_ZOOM 0x06 29 | 30 | //Setting Flash (Literals) 31 | #define OFF 0x00 32 | #define ON 0x01 33 | #define AUTO 0x02 34 | #define TORCH 0x03 35 | //Literals used by users 36 | #define LOW_QUALITY 0x01 37 | #define MID_QUALITY 0x02 38 | #define HIGH_QUALITY 0x03 39 | #define BACK_CAMERA 0x00 40 | #define FRONT_CAMERA 0x01 41 | 42 | class CameraShieldClass : public ShieldParent 43 | { 44 | public: 45 | //Constructor 46 | CameraShieldClass():ShieldParent(CAMERA_ID){}; 47 | //Setters 48 | void resetParameters(); 49 | void frontCapture(); 50 | void rearCapture (); 51 | void setFlash(byte ); 52 | void setQuality(byte); 53 | void record(unsigned long,byte); 54 | void zoom(byte,bool=false); 55 | private: 56 | 57 | }; 58 | 59 | //Extern Object 60 | extern CameraShieldClass Camera; 61 | #endif -------------------------------------------------------------------------------- /ChartShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: ChartShield.h 5 | 6 | Version: 1.12.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2016.12 13 | 14 | */ 15 | #ifndef ChartShield_h 16 | #define ChartShield_h 17 | 18 | #include "ShieldParent.h" 19 | 20 | //Output Function ID 21 | #define CHART_PLOT 0x01 22 | #define CHART_CLEAR 0x02 23 | #define CHART_AUTO_SCROLL 0x03 24 | #define CHART_SAVE_CSV 0x04 25 | #define CHART_SAVE_SCREENSHOT 0x05 26 | 27 | //Input Function ID 28 | 29 | //Literals 30 | #define CHART_0 0x00 31 | #define CHART_1 0x01 32 | #define CHART_2 0x02 33 | #define CHART_3 0x03 34 | #define CHART_4 0x04 35 | 36 | 37 | class ChartShield : public ShieldParent 38 | { 39 | public: 40 | ChartShield(); 41 | void clear(byte); 42 | void add(const char *,float,byte =0); 43 | void plot(); 44 | void saveCsv(const char *,byte); 45 | void saveScreenshot(byte=0); 46 | void autoScroll(byte); 47 | private: 48 | byte keysCounter; 49 | char * key; 50 | char * namesArray[5]; 51 | float floatArray[5]; 52 | byte chartIDArray[5]; 53 | }; 54 | 55 | extern ChartShield Chart; 56 | #endif -------------------------------------------------------------------------------- /CircularBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | CircularBuffer.h - circular buffer library for Arduino. 3 | 4 | Copyright (c) 2009 Hiroki Yagita. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | 'Software'), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | #ifndef CIRCULARBUFFER_h 26 | #define CIRCULARBUFFER_h 27 | #include 28 | 29 | template 30 | class CircularBuffer { 31 | public: 32 | CircularBuffer() : 33 | wp_(buf_), rp_(buf_), tail_(buf_+Size), remain_(0) {} 34 | ~CircularBuffer() {} 35 | void push(T value) { 36 | if(remain_==Size)return; 37 | *wp_++ = value; 38 | remain_++; 39 | if (wp_ == tail_) wp_ = buf_; 40 | } 41 | T pop() { 42 | T result = *rp_++; 43 | remain_--; 44 | if (rp_ == tail_) rp_ = buf_; 45 | return result; 46 | } 47 | int remain() const { 48 | return remain_; 49 | } 50 | 51 | private: 52 | T buf_[Size]; 53 | T *wp_; 54 | T *rp_; 55 | T *tail_; 56 | uint16_t remain_; 57 | }; 58 | 59 | #endif -------------------------------------------------------------------------------- /ClockShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: ClockShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef ClockShield_h 17 | #define ClockShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Output Function ID 22 | #define CLOCK_BEGIN 0x01 23 | 24 | 25 | //Input Function ID 26 | #define CLOCK_DATE_VALUE 0x01 27 | 28 | class ClockShield : public ShieldParent 29 | { 30 | public: 31 | //Constructor 32 | ClockShield(); 33 | //Begin Clock 34 | void queryDateAndTime(); 35 | //Getters 36 | byte getSeconds(); 37 | byte getHours(); 38 | byte getMinutes(); 39 | byte getDay(); 40 | byte getMonth(); 41 | short getYear(); 42 | private: 43 | //Reserve Variables 44 | byte seconds; 45 | byte hours; 46 | byte minutes; 47 | byte day; 48 | byte month; 49 | short year; 50 | //Process Input Data 51 | void processData(); 52 | }; 53 | 54 | //Extern Object 55 | extern ClockShield Clock; 56 | #endif -------------------------------------------------------------------------------- /DataLoggerShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: DataLogger.h 5 | 6 | Version: 1.2 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.9 13 | 14 | */ 15 | #ifndef DataLogger_h 16 | #define DataLogger_h 17 | 18 | #include "ShieldParent.h" 19 | 20 | //Ouput Function ID's 21 | #define LOGGER_START_LOG 0x01 22 | #define LOGGER_STOP_LOG 0x02 23 | #define LOGGER_ADD_FLOAT 0x03 24 | #define LOGGER_ADD_STRING 0x04 25 | #define LOGGER_LOG_DATA 0x05 26 | 27 | 28 | class DataLoggerShield : public ShieldParent 29 | { 30 | public: 31 | DataLoggerShield():ShieldParent(DATA_LOGGER_ID){}; 32 | //Starters 33 | void start(); 34 | void start(const char *,bool=0); 35 | void start(String ,bool=0); 36 | //Stopper 37 | void stop(); 38 | //Process 39 | void add(const char * , float); 40 | void add(String , float); 41 | void add(const char * ,const char*); 42 | void add(String , String); 43 | //Save data 44 | void log(); 45 | private: 46 | 47 | 48 | }; 49 | 50 | //Extern Object 51 | extern DataLoggerShield Logger; 52 | #endif 53 | -------------------------------------------------------------------------------- /EmailShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: EmailShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef EmailShield_h 17 | #define EmailShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Output Function ID 22 | #define EMAIL_SEND 0x01 23 | #define EMAIL_ATTACH_FILE 0x02 24 | #define EMAIL_ATTACH_FILE_PATH 0x03 25 | 26 | /* LITERALS */ 27 | #define LAST_CAMERA_PIC_ONESHEELD_FOLDER 0x00 28 | #define LAST_CAMERA_PIC_CAMERA_FOLDER 0x01 29 | #define LAST_CAMERA_VIDEO 0x02 30 | #define LAST_CHART_CSV 0x04 31 | #define LAST_DATA_LOGGER_CSV 0x05 32 | #define LAST_MIC_RECORD 0x06 33 | #define LAST_MUSIC_TRACK 0x07 34 | 35 | class EmailShieldClass : public ShieldParent 36 | { 37 | public: 38 | //Constructor 39 | EmailShieldClass() : ShieldParent(EMAIL_ID){}; 40 | //Sender 41 | void send(const char* ,const char*,const char* ); 42 | void send(String , String ,String ); 43 | void attachLastPicture(const char* ,const char*,const char*,byte =0); 44 | void attachLastPicture(String , String , String , byte =0); 45 | void attachFile(int); 46 | void attachFile(const char *); 47 | void attachFile(String); 48 | private: 49 | 50 | }; 51 | 52 | //Extern Object 53 | extern EmailShieldClass Email; 54 | #endif -------------------------------------------------------------------------------- /FacebookShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: FacebookShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "FacebookShield.h" 18 | 19 | //Post Sender 20 | void FacebookShieldClass::post(const char* status) 21 | { 22 | //Check length of string 23 | int statusLength = strlen(status); 24 | if(!statusLength) return; 25 | OneSheeld.sendShieldFrame(FACEBOOK_ID,0,FACEBOOK_UPDATE_STATUS,1,new FunctionArg(statusLength,(byte*)status)); 26 | } 27 | 28 | void FacebookShieldClass::post(String status) 29 | { 30 | post(&status[0]); 31 | } 32 | 33 | void FacebookShieldClass::postLastPicture(const char * pictureText, byte imageSource) 34 | { 35 | //Check length of string 36 | int pictureTextLength = strlen(pictureText); 37 | if(!pictureTextLength) return; 38 | OneSheeld.sendShieldFrame(FACEBOOK_ID,0,FACEBOOK_POST_LAST_PIC,2,new FunctionArg(pictureTextLength,(byte*)pictureText), 39 | new FunctionArg(1,(byte *)&imageSource)); 40 | } 41 | 42 | void FacebookShieldClass::postLastPicture(String pictureText , byte imageSource) 43 | { 44 | postLastPicture(&pictureText[0],imageSource); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /FacebookShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: FacebookShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef FacebookShield_h 17 | #define FacebookShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Output Functions ID's 22 | #define FACEBOOK_UPDATE_STATUS 0x01 23 | #define FACEBOOK_POST_LAST_PIC 0x02 24 | 25 | class FacebookShieldClass : public ShieldParent 26 | { 27 | public: 28 | //Constructor 29 | FacebookShieldClass() : ShieldParent(FACEBOOK_ID){}; 30 | //Senders 31 | void post(const char* ); 32 | void post(String ); 33 | void postLastPicture(const char *,byte =0); 34 | void postLastPicture(String , byte); 35 | 36 | private: 37 | 38 | }; 39 | 40 | //Extern Object 41 | extern FacebookShieldClass Facebook; 42 | #endif -------------------------------------------------------------------------------- /FingerprintScannerShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: FingerprintScannerShield.h 5 | 6 | Version: 1.9.3 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2016.11 13 | 14 | */ 15 | #ifndef FingerprintScannerShield_h 16 | #define FingerprintScannerShield_h 17 | 18 | #include "ShieldParent.h" 19 | 20 | //Output function ID's 21 | #define FINGERPRINT_SCAN 0x01 22 | 23 | //Input Function ID's 24 | #define FINGERPRINT_GET 0x01 25 | #define FINGERPRINT_GET_ERROR 0x02 26 | 27 | //Errors messages 28 | #define AUTHENTICATION_FAILED 0x01 29 | #define USER_CANCEL 0x02 30 | #define USER_FALLBACK 0x03 31 | #define SYSTEM_CANCEL 0x04 32 | #define PASSCODE_NOT_SET 0x05 33 | #define TOUCHID_NOT_AVAILABLE 0x06 34 | #define TOUCHID_NOT_ENROLLED 0x07 35 | #define TOUCHID_LOCKOUT 0x08 36 | #define APP_CANCEL 0x09 37 | #define INVALID_CONTEXT 0x0A 38 | 39 | 40 | class FingerprintScannerShield : public ShieldParent 41 | { 42 | public: 43 | //Constructor 44 | FingerprintScannerShield(); 45 | bool isVerified(); 46 | bool isNewFingerScanned(); 47 | void scan(); 48 | void setOnError(void (*)(byte)); 49 | void setOnNewFingerScanned(void (*)(bool)); 50 | 51 | private: 52 | bool isFingerVerified; 53 | bool isNewFingerprintScanned; 54 | bool isErrorCallbackAssigned; 55 | bool isFingerprintCallbackAssigned; 56 | void (*errorCallback)(byte); 57 | void (*fingerprintCallback)(bool); 58 | void processData(); 59 | }; 60 | //Extern Object 61 | extern FingerprintScannerShield FingerprintScanner; 62 | #endif -------------------------------------------------------------------------------- /FoursquareShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: FoursquareShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "FoursquareShield.h" 18 | 19 | 20 | //Checking-In Sender 21 | void FoursquareShieldClass::checkIn(const char* placeId,const char* message) 22 | { 23 | //Check length of string 24 | int placeIdLength = strlen(placeId); 25 | int messageLength = strlen(message); 26 | if(!placeIdLength || !messageLength) return; 27 | OneSheeld.sendShieldFrame(FOURSQUARE_ID,0,FOURSQUARE_CHECK_IN,2,new FunctionArg(placeIdLength,(byte*)placeId), 28 | new FunctionArg(messageLength,(byte*)message)); 29 | } 30 | 31 | void FoursquareShieldClass::checkIn(String placeId , String message) 32 | { 33 | checkIn(&placeId[0],&message[0]); 34 | } 35 | 36 | -------------------------------------------------------------------------------- /FoursquareShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: FoursquareShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef FoursquareShield_h 17 | #define FoursquareShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Output Function ID 22 | #define FOURSQUARE_CHECK_IN 0x01 23 | 24 | class FoursquareShieldClass : public ShieldParent 25 | { 26 | public: 27 | //Constructor 28 | FoursquareShieldClass() : ShieldParent(FOURSQUARE_ID){}; 29 | //Sender 30 | void checkIn(const char* ,const char* ); 31 | void checkIn(String , String ); 32 | private: 33 | 34 | }; 35 | 36 | //Extern Object 37 | extern FoursquareShieldClass Foursquare; 38 | #endif -------------------------------------------------------------------------------- /GLCDAnalogGauge.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GLCDAnalogGauge.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | 16 | #ifndef GLCDAnalogGauge_h 17 | #define GLCDAnalogGauge_h 18 | 19 | #define GLCD_ANALOG_GAUGE_TYPE 0x07 20 | #define GLCD_ANALOG_GAUGE_RANGE 0x03 21 | #define GLCD_ANALOG_GAUGE_VALUE 0x04 22 | #define GLCD_ANALOG_GAUGE_RADIUS 0x05 23 | 24 | #include "ShapeClass.h" 25 | 26 | class GLCDAnalogGauge : public ShapeClass 27 | { 28 | public: 29 | GLCDAnalogGauge(int , int , int ); 30 | void setRange(int , int); 31 | void setValue(int ); 32 | void setRadius(int); 33 | private: 34 | void draw(); 35 | int radius; 36 | }; 37 | 38 | #endif -------------------------------------------------------------------------------- /GLCDButton.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GLCDButton.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | 16 | #ifndef GLCDButton_h 17 | #define GLCDButton_h 18 | 19 | #define GLCD_BUTTON_TYPE 0x08 20 | #define GLCD_BUTTON_TEXT 0x03 21 | #define GLCD_BUTTON_DIMENSIONS 0x04 22 | #define GLCD_BUTTON_STYLE 0x05 23 | 24 | #define GLCD_BUTTON_VALUE 0x01 25 | 26 | #define STYLE_2D 0x00 27 | #define STYLE_3D 0x01 28 | 29 | #include "ShapeClass.h" 30 | 31 | class GLCDButton : public ShapeClass 32 | { 33 | friend class GLCDShield; 34 | public: 35 | GLCDButton(int , int , int ,int , const char * ); 36 | GLCDButton(int , int , int ,int); 37 | bool isPressed(); 38 | void setText(const char *); 39 | void setStyle(byte ); 40 | void setDimensions(int,int); 41 | void setOnChange(void(*)(bool)); 42 | ~GLCDButton(); 43 | private: 44 | void draw(); 45 | int width; 46 | int height; 47 | int dataStringLength; 48 | char * dataString; 49 | bool dataMalloced; 50 | bool value; 51 | bool buttonHasName; 52 | bool isCallBackAssigned; 53 | void (*onChangeCallback)(bool); 54 | }; 55 | 56 | #endif -------------------------------------------------------------------------------- /GLCDCheckBox.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GLCDCheckBox.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | 16 | #ifndef GLCDCheckBox_h 17 | #define GLCDCheckBox_h 18 | 19 | #define GLCD_CHECK_BOX_TYPE 0x0A 20 | #define GLCD_CHECK_BOX_SET_TEXT 0x03 21 | #define GLCD_CHECK_BOX_SET_SIZE 0x04 22 | #define GLCD_CHECK_BOX_SELECT 0x05 23 | #define GLCD_CHECK_BOX_UNSELECT 0x06 24 | 25 | 26 | #include "ShapeClass.h" 27 | 28 | class GLCDCheckBox : public ShapeClass 29 | { 30 | friend class GLCDShield; 31 | public: 32 | GLCDCheckBox(int , int , char *); 33 | void setText(char *); 34 | void setSize(byte ); 35 | bool isSelected(); 36 | void select(); 37 | void deselect(); 38 | void setOnChange(void(*)(bool)); 39 | ~GLCDCheckBox(); 40 | private: 41 | void draw(); 42 | int dataStringLength; 43 | char * dataString; 44 | bool dataMalloced; 45 | bool isCallbackAssigned; 46 | bool value; 47 | void (*onChangeCallback)(bool); 48 | }; 49 | 50 | #endif -------------------------------------------------------------------------------- /GLCDEllipse.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GLCDEllipse.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | 16 | #ifndef GLCDEllipse_h 17 | #define GLCDEllipse_h 18 | 19 | #define GLCD_ELLIPSE_TYPE 0x04 20 | #define GLCD_ELLIPSE_RADIUS 0x03 21 | #define GLCD_ELLIPSE_FILL 0x04 22 | 23 | 24 | #include "ShapeClass.h" 25 | 26 | class GLCDEllipse : public ShapeClass 27 | { 28 | public: 29 | GLCDEllipse(int , int , int ,int ); 30 | void setRadius(int ,int); 31 | void setFill(bool ); 32 | private: 33 | void draw(); 34 | int radius1; 35 | int radius2; 36 | }; 37 | 38 | #endif -------------------------------------------------------------------------------- /GLCDLine.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GLCDLine.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | 16 | #ifndef GLCDLine_h 17 | #define GLCDLine_h 18 | 19 | #define GLCD_LINE_TYPE 0x03 20 | #define GLCD_LINE_COORDINATES 0x03 21 | 22 | 23 | #include "ShapeClass.h" 24 | 25 | class GLCDLine : public ShapeClass 26 | { 27 | public: 28 | GLCDLine(int , int , int ,int ); 29 | void setCoordinates(int , int ,int, int); 30 | private: 31 | void draw(); 32 | int x2Position; 33 | int y2Position; 34 | }; 35 | 36 | #endif -------------------------------------------------------------------------------- /GLCDPoint.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GLCDPoint.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "GLCDPoint.h" 18 | 19 | 20 | void GLCDPoint::draw() 21 | { 22 | byte xPositionArray[2] ; 23 | xPositionArray[1] = (xposition >> 8) & 0xFF; 24 | xPositionArray[0] = xposition & 0xFF; 25 | 26 | byte yPositionArray[2] ; 27 | yPositionArray[1] = (yposition >> 8) & 0xFF; 28 | yPositionArray[0] = yposition & 0xFF; 29 | 30 | byte shapeIdArray[2] ; 31 | shapeIdArray[1] = (shapeID >> 8) & 0xFF; 32 | shapeIdArray[0] = shapeID & 0xFF; 33 | 34 | byte functionId = SHAPE_DRAW; 35 | OneSheeld.sendShieldFrame(GLCD_ID,0,GLCD_POINT_TYPE,4,new FunctionArg(1,&functionId),new FunctionArg(2,shapeIdArray) 36 | ,new FunctionArg(2,xPositionArray) 37 | ,new FunctionArg(2,yPositionArray)); 38 | } -------------------------------------------------------------------------------- /GLCDPoint.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GLCDPoint.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | 16 | #ifndef GLCDPoint_h 17 | #define GLCDPoint_h 18 | 19 | #define GLCD_POINT_TYPE 0x01 20 | 21 | #include "ShapeClass.h" 22 | 23 | class GLCDPoint : public ShapeClass 24 | { 25 | public: 26 | GLCDPoint(int x , int y): ShapeClass(GLCD_POINT_TYPE,x,y){}; 27 | private: 28 | void draw(); 29 | }; 30 | 31 | #endif -------------------------------------------------------------------------------- /GLCDProgressBar.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GLCDProgressBar.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | 16 | #ifndef GLCDProgressBar_h 17 | #define GLCDProgressBar_h 18 | 19 | #define GLCD_PROGRESS_BAR_TYPE 0x06 20 | #define GLCD_PROGRESS_BAR_RANGE 0x03 21 | #define GLCD_PROGRESS_BAR_VALUE 0x04 22 | #define GLCD_PROGRESS_BAR_DIMENSIONS 0x05 23 | 24 | #include "ShapeClass.h" 25 | 26 | class GLCDProgressBar : public ShapeClass 27 | { 28 | public: 29 | GLCDProgressBar(int , int , int ,int ); 30 | void setRange(int , int); 31 | void setValue(int ); 32 | void setDimensions(int,int); 33 | private: 34 | void draw(); 35 | int width; 36 | int height; 37 | }; 38 | 39 | #endif -------------------------------------------------------------------------------- /GLCDRadioButton.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GLCDRadioButton.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | 16 | #ifndef GLCDRadioButton_h 17 | #define GLCDRadioButton_h 18 | 19 | #define GLCD_RADIO_BUTTON_TYPE 0x09 20 | #define GLCD_RADIO_BUTTON_SET_TEXT 0x03 21 | #define GLCD_RADIO_BUTTON_SET_SIZE 0x04 22 | #define GLCD_RADIO_BUTTON_SET_GROUP 0x05 23 | #define GLCD_RADIO_BUTTON_SELECT 0x06 24 | 25 | #include "ShapeClass.h" 26 | 27 | class GLCDRadioButton : public ShapeClass 28 | { 29 | friend class GLCDShield; 30 | public: 31 | GLCDRadioButton(int , int , char *); 32 | GLCDRadioButton(int , int , char * , int ); 33 | bool isSelected(); 34 | int getGroupNumber(); 35 | void setText(char *); 36 | void setSize(byte ); 37 | void setGroup(int ); 38 | void select(); 39 | void setOnChange(void (*)(bool)); 40 | ~GLCDRadioButton(); 41 | private: 42 | void draw(); 43 | char * dataString; 44 | int dataStringLength; 45 | int groupNumber; 46 | bool dataMalloced; 47 | bool sendAsGroup; 48 | bool value; 49 | bool isCallbackAssigned; 50 | void (*onChangeCallback)(bool); 51 | }; 52 | 53 | #endif -------------------------------------------------------------------------------- /GLCDRectangle.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GLCDRectangle.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | 16 | #ifndef GLCDRectangle_h 17 | #define GLCDRectangle_h 18 | 19 | #define GLCD_RECTANGLE_TYPE 0x02 20 | #define GLCD_RECTANGLE_RADIUS 0x03 21 | #define GLCD_RECTANLGE_FILL 0x04 22 | #define GLCD_RECTANGLE_DIMENSIONS 0x05 23 | 24 | #include "ShapeClass.h" 25 | 26 | class GLCDRectangle : public ShapeClass 27 | { 28 | public: 29 | GLCDRectangle(int , int , int , int , int =0); 30 | void setRadius(int); 31 | void setFill(bool ); 32 | void setDimensions(int,int); 33 | private: 34 | void draw(); 35 | int width; 36 | int height; 37 | int radius; 38 | }; 39 | 40 | #endif -------------------------------------------------------------------------------- /GLCDShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GLCDShield.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | 16 | #ifndef GLCDShield_h 17 | #define GLCDShield_h 18 | 19 | #define GLCD_TYPE 0x00 20 | #define GLCD_CLEAR 0x00 21 | 22 | #define GLCD_GET_DATA_FROM_SHAPE 0x01 23 | 24 | #define MAX_NO_OF_SHAPE_USED 32 25 | 26 | #include "ShieldParent.h" 27 | #include "ShapeClass.h" 28 | #include "GLCDPoint.h" 29 | #include "GLCDRectangle.h" 30 | #include "GLCDLine.h" 31 | #include "GLCDEllipse.h" 32 | #include "GLCDTextBox.h" 33 | #include "GLCDProgressBar.h" 34 | #include "GLCDAnalogGauge.h" 35 | #include "GLCDButton.h" 36 | #include "GLCDRadioButton.h" 37 | #include "GLCDCheckBox.h" 38 | #include "GLCDSlider.h" 39 | 40 | class GLCDShield : public ShieldParent 41 | { 42 | public: 43 | GLCDShield(); 44 | void clear(); 45 | void draw(ShapeClass &); 46 | private: 47 | ShapeClass * interactiveShapesArray[MAX_NO_OF_SHAPE_USED]; 48 | bool addToShapesArray(ShapeClass &); 49 | void processData(); 50 | }; 51 | extern GLCDShield GLCD; 52 | #endif -------------------------------------------------------------------------------- /GLCDSlider.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GLCDSlider.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | 16 | #ifndef GLCDSlider_h 17 | #define GLCDSlider_h 18 | 19 | #define GLCD_SLIDER_TYPE 0x0B 20 | #define GLCD_SLIDER_RANGE 0x03 21 | #define GLCD_SLIDER_VALUE 0x04 22 | #define GLCD_SLIDER_DIMENSIONS 0x05 23 | 24 | #include "ShapeClass.h" 25 | 26 | class GLCDSlider : public ShapeClass 27 | { 28 | friend class GLCDShield; 29 | public: 30 | GLCDSlider(int , int , int ,int ); 31 | void setRange(int , int); 32 | void setValue(int ); 33 | int getValue(); 34 | void setDimensions(int ,int); 35 | void setOnChange(void (*)(int)); 36 | private: 37 | void draw(); 38 | int width; 39 | int height; 40 | int value; 41 | bool isCallbackAssigned; 42 | void (*onChangeCallback)(int); 43 | }; 44 | 45 | #endif -------------------------------------------------------------------------------- /GLCDTextBox.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GLCDTextBox.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | 16 | #ifndef GLCDTextBox_h 17 | #define GLCDTextBox_h 18 | 19 | #define GLCD_TEXTBOX_TYPE 0x05 20 | #define GLCD_TEXTBOX_SET_FONT 0x03 21 | #define GLCD_TEXTBOX_SET_SIZE 0x04 22 | #define GLCD_TEXTBOX_TEXT 0x05 23 | 24 | /* Fonts Literals. */ 25 | #define ARIAL 0x00 26 | #define ARIAL_BOLD 0x01 27 | #define ARIAL_ITALIC 0x02 28 | #define COMIC_SANS 0x03 29 | #define SERIF 0x04 30 | /* Size Literals. */ 31 | #define SMALL 0x00 32 | #define MEDIUM 0x01 33 | #define LARGE 0x02 34 | 35 | #include "ShapeClass.h" 36 | 37 | class GLCDTextBox : public ShapeClass 38 | { 39 | public: 40 | GLCDTextBox(int , int ,char * ); 41 | void setFont(byte ); 42 | void setSize(byte ); 43 | void setText(char *); 44 | ~GLCDTextBox(); 45 | private: 46 | int dataStringLength; 47 | bool dataMalloced; 48 | char * dataString; 49 | void draw(); 50 | }; 51 | 52 | #endif -------------------------------------------------------------------------------- /GPSShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GPSShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef GPSShield_h 17 | #define GPSShield_h 18 | 19 | #include 20 | #include "ShieldParent.h" 21 | 22 | //Literal Constants 23 | #define RADIUS_OF_EARTH 6371 24 | #define PI 3.1415926535897932384626433832795 25 | 26 | //Input Function ID 27 | #define GPS_VALUE 0x01 28 | 29 | 30 | class GPSShieldClass : public ShieldParent 31 | { 32 | public: 33 | //Constructor 34 | GPSShieldClass(); 35 | //Getters 36 | float getLatitude(); 37 | float getLongitude(); 38 | //Checkers 39 | bool isInRange(float , float , float ); 40 | //Distance Calculator 41 | float getDistance(float , float ); 42 | //Radian Calculator 43 | float radian(float); 44 | //setOnChange for Users Function 45 | void setOnValueChange(void (*)(float ,float )); 46 | 47 | private: 48 | //Reserving Variables 49 | float LatValue,LonValue; 50 | //Boolean checkers 51 | bool isInit; 52 | bool isCallBackAssigned; 53 | //Processing Input Data 54 | void processData (); 55 | void (*changeCallBack)(float ,float); 56 | }; 57 | 58 | //Extern Object 59 | extern GPSShieldClass GPS; 60 | #endif -------------------------------------------------------------------------------- /GamePadShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GamePadShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef GamePadShield_h 17 | #define GamePadShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Input Function ID 22 | #define GAMEPAD_VALUE 0x01 23 | 24 | //GamePad Bit Reference 25 | #define ORANGE_BIT 0 26 | #define RED_BIT 1 27 | #define GREEN_BIT 2 28 | #define BLUE_BIT 3 29 | #define UP_BIT 4 30 | #define DOWN_BIT 5 31 | #define LEFT_BIT 6 32 | #define RIGHT_BIT 7 33 | 34 | 35 | 36 | class GamePadShield : public ShieldParent 37 | { 38 | public: 39 | //Constructor 40 | GamePadShield(); 41 | //Checker Functions 42 | bool isUpPressed(); 43 | bool isDownPressed(); 44 | bool isLeftPressed(); 45 | bool isRightPressed(); 46 | bool isOrangePressed(); 47 | bool isRedPressed(); 48 | bool isGreenPressed(); 49 | bool isBluePressed(); 50 | 51 | //setOnChange for Users Function 52 | void setOnButtonChange(void (*)(unsigned char , unsigned char , 53 | unsigned char , unsigned char , 54 | unsigned char , unsigned char , 55 | unsigned char , unsigned char )); 56 | private: 57 | //Reserve Variables 58 | byte value; 59 | bool isCallBackAssigned; 60 | //Process Input Data 61 | void processData(); 62 | void (*buttonChangeCallBack)(unsigned char , unsigned char , 63 | unsigned char , unsigned char , 64 | unsigned char ,unsigned char , 65 | unsigned char ,unsigned char ); 66 | }; 67 | 68 | //Extern Object 69 | extern GamePadShield GamePad; 70 | #endif -------------------------------------------------------------------------------- /GravitySensorShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GravitySensorShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "GravitySensorShield.h" 18 | 19 | 20 | //Class Constructor 21 | GravitySensorShield::GravitySensorShield() : ShieldParent(GRAVITY_ID) 22 | { 23 | valueX=0; 24 | valueY=0; 25 | valueZ=0; 26 | isCallBackAssigned=false; 27 | 28 | } 29 | 30 | //X-Axis getter function 31 | float GravitySensorShield::getX() 32 | { 33 | return valueX; 34 | } 35 | //Y-Axis getter function 36 | float GravitySensorShield::getY() 37 | { 38 | return valueY; 39 | } 40 | //Z-Axis getter function 41 | float GravitySensorShield::getZ() 42 | { 43 | return valueZ; 44 | } 45 | 46 | //Gravity Input Data Processing 47 | void GravitySensorShield::processData() 48 | { 49 | //Check Function-ID 50 | byte functionId=getOneSheeldInstance().getFunctionId(); 51 | 52 | if(functionId==GRAVITY_VALUE) 53 | { 54 | //Process X-Axis Value 55 | valueX=getOneSheeldInstance().convertBytesToFloat(getOneSheeldInstance().getArgumentData(0)); 56 | //Process Y-Axis Value 57 | valueY=getOneSheeldInstance().convertBytesToFloat(getOneSheeldInstance().getArgumentData(1)); 58 | //Process Z-Axis Value 59 | valueZ=getOneSheeldInstance().convertBytesToFloat(getOneSheeldInstance().getArgumentData(2)); 60 | 61 | //User Function Invoked 62 | if(isCallBackAssigned && !isInACallback()) 63 | { 64 | enteringACallback(); 65 | (*changeCallBack)(valueX,valueY,valueZ); 66 | exitingACallback(); 67 | } 68 | } 69 | } 70 | 71 | //User Function Setter 72 | void GravitySensorShield::setOnValueChange(void (*userFunction)(float valueX,float valueY,float valueZ)) 73 | { 74 | changeCallBack=userFunction; 75 | isCallBackAssigned=true; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /GravitySensorShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GravitySensorShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef GravitySensorShield_h 17 | #define GravitySensorShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Input Function ID 22 | #define GRAVITY_VALUE 0x01 23 | 24 | class GravitySensorShield : public ShieldParent 25 | { 26 | public: 27 | //Constructor 28 | GravitySensorShield(); 29 | //Getter Functions 30 | float getX(); 31 | float getY(); 32 | float getZ(); 33 | //setOnChange for Users Function 34 | void setOnValueChange(void (*)(float,float,float)); 35 | 36 | private: 37 | //Reserve Variables 38 | float valueX ,valueY,valueZ; 39 | //Boolean for set On change Function 40 | bool isCallBackAssigned; 41 | //Process Input Data 42 | void processData(); 43 | void (*changeCallBack)(float,float,float); 44 | }; 45 | 46 | //Extern Object 47 | extern GravitySensorShield GravitySensor; 48 | #endif -------------------------------------------------------------------------------- /GyroscopeSensorShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GyroscopeSensorShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "GyroscopeSensorShield.h" 18 | 19 | //Class Constructor 20 | GyroscopeSensorShield::GyroscopeSensorShield() : ShieldParent(GYROSCOPE_ID) 21 | { 22 | valueX=0; 23 | valueY=0; 24 | valueZ=0; 25 | isCallBackAssigned=false; 26 | } 27 | 28 | //X-Axis getter function 29 | float GyroscopeSensorShield::getX() 30 | { 31 | return valueX; 32 | } 33 | //Y-Axis getter function 34 | float GyroscopeSensorShield::getY() 35 | { 36 | return valueY; 37 | } 38 | //Z-Axis getter function 39 | float GyroscopeSensorShield::getZ() 40 | { 41 | return valueZ; 42 | } 43 | 44 | //GyroscopeSensor Input Data processing 45 | void GyroscopeSensorShield::processData() 46 | { 47 | //Check Function-ID 48 | byte functionId=getOneSheeldInstance().getFunctionId(); 49 | 50 | if(functionId==GYROSCOPE_VALUE) 51 | { 52 | //Process X-Axis Value 53 | valueX=getOneSheeldInstance().convertBytesToFloat(getOneSheeldInstance().getArgumentData(0)); 54 | //Process Y-Axis Value 55 | valueY=getOneSheeldInstance().convertBytesToFloat(getOneSheeldInstance().getArgumentData(1)); 56 | //Process Z-Axis Value 57 | valueZ=getOneSheeldInstance().convertBytesToFloat(getOneSheeldInstance().getArgumentData(2)); 58 | 59 | //User Function Invoked 60 | if(isCallBackAssigned && !isInACallback()) 61 | { 62 | enteringACallback(); 63 | (*changeCallBack)(valueX,valueY,valueZ); 64 | exitingACallback(); 65 | } 66 | } 67 | } 68 | 69 | //Users Function Setter 70 | void GyroscopeSensorShield::setOnValueChange(void (*userFunction)(float valueX, float valueY ,float valueZ)) 71 | { 72 | changeCallBack=userFunction; 73 | isCallBackAssigned=true; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /GyroscopeSensorShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: GyroscopeSensorShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef GyroscopeSensorShield_h 17 | #define GyroscopeSensorShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Input Function ID 22 | #define GYROSCOPE_VALUE 0x01 23 | 24 | class GyroscopeSensorShield : public ShieldParent 25 | { 26 | public: 27 | //Constructor 28 | GyroscopeSensorShield(); 29 | //Getter Functions 30 | float getX(); 31 | float getY(); 32 | float getZ(); 33 | //setOnChange for Users Fucntion 34 | void setOnValueChange(void (*)(float,float,float)); 35 | 36 | private: 37 | //Reserve Variables 38 | float valueX ,valueY,valueZ; 39 | //Boolean for the setOnChange Function 40 | bool isCallBackAssigned; 41 | //Process Input Data 42 | void processData(); 43 | void (*changeCallBack)(float,float,float); 44 | }; 45 | 46 | //Extern Object 47 | extern GyroscopeSensorShield GyroscopeSensor; 48 | #endif -------------------------------------------------------------------------------- /IncludedShieldsDefines.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: IncludedShieldsDefines.h 5 | 6 | Version: 1.2 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.9 13 | 14 | */ 15 | 16 | #define INCLUDE_KEYPAD_SHIELD 17 | #define INCLUDE_GPS_SHIELD 18 | #define INCLUDE_SLIDER_SHIELD 19 | #define INCLUDE_PUSH_BUTTON_SHIELD 20 | #define INCLUDE_TOGGLE_BUTTON_SHIELD 21 | #define INCLUDE_GAMEPAD_SHIELD 22 | #define INCLUDE_PROXIMITY_SENSOR_SHIELD 23 | #define INCLUDE_MIC_SHIELD 24 | #define INCLUDE_TEMPERATURE_SENSOR_SHIELD 25 | #define INCLUDE_LIGHT_SENSOR_SHIELD 26 | #define INCLUDE_PRESSURE_SENSOR_SHIELD 27 | #define INCLUDE_GRAVITY_SENSOR_SHIELD 28 | #define INCLUDE_ACCELEROMETER_SENSOR_SHIELD 29 | #define INCLUDE_GYROSCOPE_SENSOR_SHIELD 30 | #define INCLUDE_ORIENTATION_SENSOR_SHIELD 31 | #define INCLUDE_MAGNETOMETER_SENSOR_SHIELD 32 | #define INCLUDE_PHONE_SHIELD 33 | #define INCLUDE_SMS_SHIELD 34 | #define INCLUDE_CLOCK_SHIELD 35 | #define INCLUDE_KEYBOARD_SHIELD 36 | #define INCLUDE_TWITTER_SHIELD 37 | #define INCLUDE_VOICE_RECOGNIZER_SHIELD 38 | #define INCLUDE_TERMINAL_SHIELD 39 | #define INCLUDE_FACEBOOK_SHIELD 40 | #define INCLUDE_NOTIFICATION_SHIELD 41 | #define INCLUDE_SEVEN_SEGMENT_SHIELD 42 | #define INCLUDE_SKYPE_SHIELD 43 | #define INCLUDE_MUSIC_PLAYER_SHIELD 44 | #define INCLUDE_EMAIL_SHIELD 45 | #define INCLUDE_FOURSQUARE_SHIELD 46 | #define INCLUDE_CAMERA_SHIELD 47 | #define INCLUDE_BUZZER_SHIELD 48 | #define INCLUDE_LED_SHIELD 49 | #define INCLUDE_LCD_SHIELD 50 | #define INCLUDE_TEXT_TO_SPEECH_SHIELD 51 | #define INCLUDE_DATA_LOGGER_SHIELD 52 | #define INCLUDE_PATTERN_SHIELD 53 | #define INCLUDE_INTERNET_SHIELD 54 | #define INCLUDE_COLOR_DETECTOR_SHIELD 55 | #define INCLUDE_NFC_SHIELD 56 | #define INCLUDE_GLCD_SHIELD 57 | #define INCLUDE_VIBRATION_SHIELD 58 | #define INCLUDE_BARCODE_SCANNER_SHIELD 59 | #define INCLUDE_FINGERPRINT_SCANNER_SHIELD 60 | #define INCLUDE_FACE_DETECTOR_SHIELD 61 | #define INCLUDE_CHART_SHIELD 62 | #define INCLUDE_IOT_SHIELD 63 | -------------------------------------------------------------------------------- /InternetShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: InternetShield.h 5 | 6 | Version: 1.4 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.1 13 | 14 | */ 15 | #ifndef InternetShield_h 16 | #define InternetShield_h 17 | 18 | #define MAX_NO_OF_REQUESTS 20 19 | 20 | #include "ShieldParent.h" 21 | #include "HttpResponse.h" 22 | #include "HttpRequest.h" 23 | 24 | 25 | //Output Function ID's for Internet calss 26 | #define INTERNET_GET 0x09 27 | #define INTERNET_POST 0x0A 28 | #define INTERNET_PUT 0x0B 29 | #define INTERNET_DELETE 0x0C 30 | #define INTERNET_CANCEL_ALL_REQUESTS 0x0D 31 | #define INTERNET_SET_AUTHENTICATION 0x0E 32 | #define INTERNET_CLEAR_AUTHENTICATIOM 0x0F 33 | #define INTERNET_SET_DEFAULT_MAX_RESPONSE 0x10 34 | #define INTERNET_QUERY_JSON 0x14 35 | #define INTERNET_QUERY_JSON_ARRAY_LENGTH 0x17 36 | 37 | //Input Function ID's for Internet class 38 | #define INTERNET_GET_ERROR 0x06 39 | 40 | //Literals 41 | #define REQUEST_CAN_NOT_BE_FOUND 0x00 42 | #define NOT_CONNECTED_TO_NETWORK 0x01 43 | #define URL_IS_NOT_FOUND 0x02 44 | #define ALREADY_EXECUTING_REQUEST 0x03 45 | #define URL_IS_WRONG 0x04 46 | 47 | 48 | 49 | class InternetShield : public ShieldParent 50 | { 51 | public: 52 | //Constructor 53 | InternetShield(); 54 | //Senders 55 | bool performGet(HttpRequest &); 56 | bool performPost(HttpRequest &); 57 | bool performPut(HttpRequest &); 58 | bool performDelete(HttpRequest &); 59 | void cancelAllRequests(); 60 | void ignoreResponse(HttpRequest &); 61 | void setBasicAuthentication(const char * ,const char *); 62 | void clearBasicAuthentication(); 63 | void setIntialResponseMaxBytesCount(int ); 64 | //Set on for userFunction 65 | void setOnError(void (*)(int,int)); 66 | private: 67 | bool isSetOnErrorCallBackAssigned; 68 | void processData(); 69 | bool addToRequestsArray(HttpRequest &); 70 | void (*internetErrorCallBack)(int,int); 71 | HttpRequest * requestsArray[MAX_NO_OF_REQUESTS]; 72 | friend class HttpRequest; 73 | }; 74 | //Extern Object 75 | extern InternetShield Internet; 76 | #endif -------------------------------------------------------------------------------- /JsonKey.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: JsonKey.cpp 5 | 6 | Version: 1.4 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.1 13 | 14 | */ 15 | #include "JsonKey.h" 16 | 17 | 18 | 19 | 20 | JsonKey::JsonKey(int key) 21 | { 22 | number=key; 23 | isText=false; 24 | } 25 | /* Copy Constructor */ 26 | JsonKey::JsonKey(const JsonKey & old) 27 | { 28 | isText=old.isText; 29 | if(isText) 30 | { 31 | int textSize=strlen(old.text); 32 | text=(char *)malloc(sizeof(char)*(textSize+1)); 33 | for (int i = 0; i < textSize; i++) 34 | { 35 | text[i]=old.text[i]; 36 | } 37 | text[textSize]='\0'; 38 | } 39 | else 40 | { 41 | number=old.number; 42 | } 43 | } 44 | 45 | JsonKey::JsonKey(const char * key) 46 | { 47 | int textSize=strlen(key); 48 | text=(char *)malloc(sizeof(char)*(textSize+1)); 49 | for (int i = 0; i < textSize; i++) 50 | { 51 | text[i]=key[i]; 52 | } 53 | text[textSize]='\0'; 54 | isText=true; 55 | } 56 | 57 | bool JsonKey::isString() 58 | { 59 | return isText; 60 | } 61 | 62 | bool JsonKey::isNumber() 63 | { 64 | return !isText; 65 | } 66 | 67 | const char * JsonKey::getString() 68 | { 69 | return text; 70 | } 71 | 72 | int JsonKey::getNumber() 73 | { 74 | return number; 75 | } 76 | 77 | 78 | JsonKey::~JsonKey() 79 | { 80 | if(isText)free(text); 81 | } -------------------------------------------------------------------------------- /JsonKey.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: JsonKey.h 5 | 6 | Version: 1.4 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.1 13 | 14 | */ 15 | #ifndef JsonKey_h 16 | #define JsonKey_h 17 | 18 | #include "Arduino.h" 19 | 20 | class JsonKey{ 21 | public: 22 | 23 | JsonKey(int ); 24 | JsonKey(const char * ); 25 | JsonKey(const JsonKey & old); 26 | bool isString(); 27 | bool isNumber(); 28 | 29 | const char * getString(); 30 | int getNumber(); 31 | 32 | ~JsonKey(); 33 | private: 34 | bool isText; 35 | int number; 36 | char * text; 37 | }; 38 | 39 | 40 | #endif -------------------------------------------------------------------------------- /JsonKeyChain.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: JsonKeyChain.h 5 | 6 | Version: 1.4 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.1 13 | 14 | */ 15 | #ifndef JsonKeyChain_h 16 | #define JsonKeyChain_h 17 | 18 | #include "JsonKey.h" 19 | 20 | //This number should not exceed 16 21 | #define MAX_JSON_KEY_DEPTH 8 22 | 23 | class JsonKeyChain { 24 | 25 | public: 26 | JsonKeyChain(); 27 | JsonKeyChain(int ); 28 | JsonKeyChain(const JsonKeyChain& old); 29 | JsonKeyChain & operator[](int ); 30 | JsonKeyChain & operator[](const char *key); 31 | bool operator==(const JsonKeyChain& other); 32 | bool operator!=(const JsonKeyChain& other); 33 | void query(); 34 | void queryArrayLength(); 35 | void dispose(); 36 | ~JsonKeyChain(); 37 | 38 | private: 39 | int counter; 40 | int request; 41 | JsonKey * keysArray[MAX_JSON_KEY_DEPTH]; 42 | void sendQueryFrame(byte); 43 | }; 44 | 45 | #endif -------------------------------------------------------------------------------- /KeyboardShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: KeyboardShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "KeyboardShield.h" 18 | 19 | //Class Constructor 20 | KeyboardShield::KeyboardShield() : ShieldParent(KEYBOARD_ID) 21 | { 22 | character=0; 23 | isCallBackAssigned=false; 24 | } 25 | 26 | //Getter 27 | char KeyboardShield::getCharacter() 28 | { 29 | return character; 30 | } 31 | 32 | //Keyboard Input Data Processing 33 | void KeyboardShield::processData() 34 | { 35 | //Checking Function-ID 36 | byte functionId=getOneSheeldInstance().getFunctionId(); 37 | if (functionId==KEYBOARD_GET_CHAR) 38 | { 39 | 40 | character=getOneSheeldInstance().getArgumentData(0)[0]; 41 | //Users Function Invoked 42 | if(isCallBackAssigned && !isInACallback()) 43 | { 44 | enteringACallback(); 45 | (*buttonChangeCallBack)(character); 46 | exitingACallback(); 47 | } 48 | } 49 | } 50 | //Users Function Setter 51 | void KeyboardShield::setOnButtonChange(void (*userFunction)(char data)) 52 | { 53 | buttonChangeCallBack=userFunction; 54 | isCallBackAssigned=true; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /KeyboardShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: KeyboardShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef Keyboard_h 17 | #define Keyboard_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Input Function ID 22 | #define KEYBOARD_GET_CHAR 0x01 23 | 24 | class KeyboardShield : public ShieldParent 25 | { 26 | public: 27 | //Constructor 28 | KeyboardShield(); 29 | //Getter 30 | char getCharacter(); 31 | //setOnChange Function for User Function 32 | void setOnButtonChange(void (*)(char)); 33 | 34 | private: 35 | //Reserve Variable 36 | char character; 37 | //Boolean for the setOnChange Function 38 | bool isCallBackAssigned; 39 | //Process Input Data 40 | void processData(); 41 | void (*buttonChangeCallBack)(char); 42 | }; 43 | 44 | //Extern Object 45 | extern KeyboardShield AsciiKeyboard; 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /KeypadShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: KeypadShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "KeypadShield.h" 18 | 19 | 20 | //Class Constructor 21 | KeypadShieldClass::KeypadShieldClass() : ShieldParent(KEYPAD_SHIELD_ID) 22 | { 23 | row=0; 24 | col=0; 25 | isCallbackAssigned=false; 26 | } 27 | //Row Checker 28 | bool KeypadShieldClass::isRowPressed(byte x) 29 | { 30 | if(x>7)return false; 31 | return !!(row&(1<7)return false; 37 | return !!(col&(1<10) x=10; 69 | OneSheeld.sendShieldFrame(MUSIC_PLAYER_ID,0,MUSIC_VOLUME,1,new FunctionArg(1,&x)); 70 | } 71 | 72 | -------------------------------------------------------------------------------- /MusicPlayerShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: MusicPlayerShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef MusicPlayerShield_h 17 | #define MusicPlayerShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Output Functions ID's 22 | #define MUSIC_STOP 0x01 23 | #define MUSIC_PLAY 0x02 24 | #define MUSIC_PAUSE 0x03 25 | #define MUSIC_PREVIOUS 0x04 26 | #define MUSIC_NEXT 0x05 27 | #define MUSIC_SEEK_FORWARD 0x06 28 | #define MUSIC_SEEK_BACKWARD 0x07 29 | #define MUSIC_VOLUME 0x08 30 | #define MUSIC_PLAY_FILE_NAME 0x09 31 | #define MUSIC_PLAYD_FILE_INDEX 0x0A 32 | 33 | class MusicPlayerShieldClass : public ShieldParent 34 | { 35 | 36 | public: 37 | //Constructor 38 | MusicPlayerShieldClass():ShieldParent(MUSIC_PLAYER_ID){}; 39 | //Setters 40 | void stop(); 41 | void play(); 42 | void play(const char *); 43 | void play(int); 44 | void pause(); 45 | void previous(); 46 | void next(); 47 | void seekForward(byte ); 48 | void seekBackward(byte ); 49 | void setVolume(byte ); 50 | 51 | private: 52 | 53 | }; 54 | 55 | //Extern Object 56 | extern MusicPlayerShieldClass MusicPlayer; 57 | #endif -------------------------------------------------------------------------------- /NFCRecord.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: NFCRecord.cpp 5 | 6 | Version: 1.5 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.3 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "NFCRecord.h" 18 | 19 | 20 | 21 | NFCRecord::NFCRecord(byte _recordNumber) 22 | { 23 | recordType =0; 24 | recordTypeLength =0; 25 | recordDataLength =0; 26 | recordNumber = _recordNumber; 27 | isRecordNull = false; 28 | } 29 | 30 | NFCRecord::NFCRecord() 31 | { 32 | recordType =0; 33 | recordTypeLength =0; 34 | recordDataLength =0; 35 | recordNumber = 0; 36 | isRecordNull = true; 37 | } 38 | 39 | bool NFCRecord::isNull() 40 | { 41 | return isRecordNull; 42 | } 43 | 44 | byte NFCRecord::getTypeCategory() 45 | { 46 | return recordType; 47 | } 48 | 49 | int NFCRecord::getTypeLength() 50 | { 51 | return recordTypeLength; 52 | } 53 | 54 | int NFCRecord::getDataLength() 55 | { 56 | return recordDataLength; 57 | } 58 | 59 | void NFCRecord::queryData(int start,byte size) 60 | { 61 | byte startArray[2] ; 62 | startArray[1] = (start >> 8) & 0xFF; 63 | startArray[0] = start & 0xFF; 64 | 65 | if(!isRecordNull) 66 | OneSheeld.sendShieldFrame(NFC_ID,0,NFC_RECORD_QUERY_DATA,3,new FunctionArg(1,&recordNumber), 67 | new FunctionArg(2,startArray), 68 | new FunctionArg(1,&size)); 69 | } 70 | 71 | void NFCRecord::queryType(int start,byte size) 72 | { 73 | byte startArray[2] ; 74 | startArray[1] = (start >> 8) & 0xFF; 75 | startArray[0] = start & 0xFF; 76 | 77 | if(!isRecordNull) 78 | OneSheeld.sendShieldFrame(NFC_ID,0,NFC_RECORD_QUERY_TYPE,3,new FunctionArg(1,&recordNumber), 79 | new FunctionArg(2,startArray), 80 | new FunctionArg(1,&size)); 81 | 82 | } 83 | 84 | void NFCRecord::queryParsedData() 85 | { 86 | if(!isRecordNull) 87 | OneSheeld.sendShieldFrame(NFC_ID,0,NFC_RECORD_QUERY_PARSED_DATA,1,new FunctionArg(1,&recordNumber)); 88 | } -------------------------------------------------------------------------------- /NFCRecord.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: NFCRecord.h 5 | 6 | Version: 1.5 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.3 13 | 14 | */ 15 | 16 | #ifndef NFCRecord_h 17 | #define NFCRecord_h 18 | 19 | //Output Function ID 20 | #define NFC_RECORD_QUERY_DATA 0x01 21 | #define NFC_RECORD_QUERY_TYPE 0x02 22 | #define NFC_RECORD_QUERY_PARSED_DATA 0x03 23 | 24 | //Literals 25 | #define TNF_UNKNOWN 0x00 26 | #define TNF_EMPTY 0x01 27 | #define TNF_EXTERNAL_TYPE 0x02 28 | #define TNF_MIME_MEDIA 0x03 29 | #define TNF_UNCHANGED 0x04 30 | #define TNF_ABSOLUTE_URI 0x05 31 | #define RTD_TEXT 0x06 32 | #define RTD_URI 0x07 33 | #define RTD_UNSUPPORTED 0x08 34 | 35 | class NFCRecord 36 | { 37 | public: 38 | NFCRecord(byte ); 39 | NFCRecord(); 40 | byte getTypeCategory(); 41 | int getTypeLength(); 42 | int getDataLength(); 43 | void queryData(int=0 ,byte=64); 44 | void queryType(int=0 ,byte=64); 45 | void queryParsedData(); 46 | bool isNull(); 47 | private: 48 | bool isRecordNull; 49 | byte recordType; 50 | int recordTypeLength; 51 | int recordDataLength; 52 | byte recordNumber; 53 | friend class NFCShield; 54 | }; 55 | 56 | #endif -------------------------------------------------------------------------------- /NFCShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: NFCShield.h 5 | 6 | Version: 1.5 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.3 13 | 14 | */ 15 | 16 | #ifndef NFCShield_h 17 | #define NFCShield_h 18 | 19 | // Input Function ID 20 | #define NFC_GET_BASIC_INFO 0x01 21 | #define NFC_ON_ERROR 0x02 22 | 23 | //Error Literals 24 | #define INDEX_OUT_OF_BOUNDS 0x00 25 | #define RECORD_CAN_NOT_BE_PARSED 0x01 26 | #define TAG_NOT_SUPPORTED 0x02 27 | #define NO_ENOUGH_BYTES 0x03 28 | #define TAG_READING_ERROR 0x04 29 | #define RECORD_NOT_FOUND 0x05 30 | 31 | #include "ShieldParent.h" 32 | #include "NFCTag.h" 33 | #include "NFCRecord.h" 34 | 35 | class NFCShield : public ShieldParent 36 | { 37 | public: 38 | NFCShield(); 39 | NFCTag & getLastTag(); 40 | bool isNewTagScanned(); 41 | void finishedReading(); 42 | void enableTagInterrupts(); 43 | void disableTagInterrupts(); 44 | void setOnNewTagScanned(void (*)(NFCTag &)); 45 | void setOnError(void (*)(byte)); 46 | 47 | private: 48 | bool isErrorAssigned; 49 | bool isNewTag; 50 | bool isNewTagSetOnAssigned; 51 | bool isReadingInProgress; 52 | bool isTagInterruptsEnabled; 53 | NFCTag * tag; 54 | void processData(); 55 | void (*errorCallBack)(byte); 56 | void (*newTagCallBack)(NFCTag &); 57 | static NFCTag nullTag; 58 | }; 59 | 60 | //Extern Object 61 | extern NFCShield NFC; 62 | #endif -------------------------------------------------------------------------------- /NFCTag.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: NFCTag.h 5 | 6 | Version: 1.5 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.3 13 | 14 | */ 15 | 16 | #ifndef TagClass_h 17 | #define TagClass_h 18 | 19 | 20 | #include "NFCRecord.h" 21 | 22 | //Input Function ID 23 | #define NFC_TAG_ON_TYPE 0x03 24 | #define NFC_TAG_ON_PARSED 0x04 25 | #define NFC_TAG_ON_DATA 0x05 26 | 27 | class NFCTag 28 | { 29 | public: 30 | NFCTag(byte *,byte, int, int, byte); 31 | bool isEmpty(); 32 | byte * getId(); 33 | byte getIdLength(); 34 | byte getNumberOfRecords(); 35 | NFCRecord & getRecord(int); 36 | int getSize(); 37 | int getMaxSize(); 38 | void setOnRecordTypeResponse(void (*userFunction)(byte , byte [],byte )); 39 | void setOnRecordParsedDataResponse(void (*userFunction)(byte , char[])); 40 | void setOnRecordDataResponse(void (userFunction)(byte ,byte [],byte )); 41 | bool isNull(); 42 | ~NFCTag(); 43 | private: 44 | NFCTag(); 45 | bool isTypeCallBackAssigned; 46 | bool isDataCallBackAssigned; 47 | bool isParsedDataCallBackAssigned; 48 | byte * tagId; 49 | int tagSize; 50 | int tagMaxSize; 51 | byte recordsNumber; 52 | byte tagIdLength; 53 | NFCRecord ** recordsArray; 54 | static NFCRecord nullRecord; 55 | 56 | void (*recordTypeCallBack)(byte , byte[],byte); 57 | void (*recordParsedCallBack)(byte , char[]); 58 | void (*recordDataCallBack)(byte , byte[],byte); 59 | friend class NFCShield; 60 | }; 61 | 62 | #endif -------------------------------------------------------------------------------- /NotificationShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: NotificationShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "NotificationShield.h" 18 | 19 | //Notification Sender 20 | void NotificationShieldClass::notifyPhone(const char* data) 21 | { 22 | //Check length of string 23 | int dataLength = strlen(data); 24 | if(!dataLength) return; 25 | OneSheeld.sendShieldFrame(NOTIFICATION_ID,0,NOTIFICATION_NOTIFY_PHONE,1,new FunctionArg(dataLength,(byte*)data)); 26 | } 27 | 28 | void NotificationShieldClass::notifyPhone(String data) 29 | { 30 | notifyPhone(&data[0]); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /NotificationShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: NotificationShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef NotificationShield_h 17 | #define NotificationShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Output Function ID 22 | #define NOTIFICATION_NOTIFY_PHONE 0x01 23 | 24 | class NotificationShieldClass : public ShieldParent 25 | { 26 | public: 27 | //Constructror 28 | NotificationShieldClass():ShieldParent(NOTIFICATION_ID){}; 29 | //Sender 30 | void notifyPhone(const char* ); 31 | void notifyPhone(String ); 32 | 33 | private: 34 | 35 | }; 36 | 37 | //Extern Object 38 | extern NotificationShieldClass Notification; 39 | #endif -------------------------------------------------------------------------------- /OneSheeldPrint.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: OneSheeldPrint.h 5 | 6 | Version: 1.2 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.9 13 | 14 | */ 15 | 16 | #ifndef PrintClass_h 17 | #define PrintClass_h 18 | 19 | //Defining decimal 20 | #define DEC 10 21 | 22 | class PrintClass 23 | { 24 | public: 25 | PrintClass(byte, byte, byte); 26 | //Write 27 | void write(char); 28 | //Printing functions 29 | void print(char); 30 | void print(int); 31 | void print(unsigned int); 32 | void print(long); 33 | void print(unsigned long); 34 | void print(const char *); 35 | void print(String ); 36 | //Unsupported by Intel Galileo board and Arduino Due 37 | #if !defined(ARDUINO_LINUX) && !defined(SAM3X8) 38 | void print(double ,int = 3 ); 39 | #endif 40 | private: 41 | //Reserve variables for function ID's 42 | byte print_fn_id; 43 | byte write_fn_id; 44 | //Reserve variable for the shield ID 45 | byte shieldId; 46 | }; 47 | 48 | #endif -------------------------------------------------------------------------------- /OneSheeldPrintln.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: OneSheeldPrintln.h 5 | 6 | Version: 1.2 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.9 13 | 14 | */ 15 | 16 | #ifndef PrintlnClass_h 17 | #define PrintlnClass_h 18 | 19 | #include "OneSheeldPrint.h" 20 | 21 | class PrintlnClass: public PrintClass 22 | { 23 | public: 24 | PrintlnClass(byte, byte, byte); 25 | //Printing in new line 26 | void println(); 27 | void println(char); 28 | void println(int); 29 | void println(unsigned int); 30 | void println(long); 31 | void println(unsigned long); 32 | void println(const char *); 33 | void println(String); 34 | //Unsupported by Intel Galileo board and Arduino Due 35 | #if !defined(ARDUINO_LINUX) && !defined(SAM3X8) 36 | void println(double , int = 3); 37 | #endif 38 | }; 39 | 40 | #endif -------------------------------------------------------------------------------- /OrientationSensorShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: OrientationSensorShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "OrientationSensorShield.h" 18 | 19 | 20 | //Class Constructor 21 | OrientationSensorShield::OrientationSensorShield() : ShieldParent(ORIENTATION_ID) 22 | { 23 | valueX=0; 24 | valueY=0; 25 | valueZ=0; 26 | isCallBackAssigned=false; 27 | } 28 | 29 | //X-Axis getter function 30 | float OrientationSensorShield::getX() 31 | { 32 | return valueX; 33 | } 34 | //Y-Axis getter function 35 | float OrientationSensorShield::getY() 36 | { 37 | return valueY; 38 | } 39 | //Z-Axis getter function 40 | float OrientationSensorShield::getZ() 41 | { 42 | return valueZ; 43 | } 44 | 45 | //AccelerometerSensor Data processing 46 | void OrientationSensorShield::processData() 47 | { 48 | //Check Function-ID 49 | byte functionId=getOneSheeldInstance().getFunctionId(); 50 | 51 | if(functionId==ORIENTATION_VALUE) 52 | { 53 | //Process X-Axis Value 54 | valueX=getOneSheeldInstance().convertBytesToFloat(getOneSheeldInstance().getArgumentData(0)); 55 | //Process Y-Axis Value 56 | valueY=getOneSheeldInstance().convertBytesToFloat(getOneSheeldInstance().getArgumentData(1)); 57 | //Process Z-Axis Value 58 | valueZ=getOneSheeldInstance().convertBytesToFloat(getOneSheeldInstance().getArgumentData(2)); 59 | //User Function Invoked 60 | if(isCallBackAssigned && !isInACallback()) 61 | { 62 | enteringACallback(); 63 | (*changeCallBack)(valueX,valueY,valueZ); 64 | exitingACallback(); 65 | } 66 | } 67 | } 68 | 69 | //Users Function Setter 70 | void OrientationSensorShield::setOnValueChange(void (*userFunction)(float valueX,float valueY ,float valueZ)) 71 | { 72 | changeCallBack=userFunction; 73 | isCallBackAssigned=true; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /OrientationSensorShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: OrientationSensorShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef OrientationSensorShield_h 17 | #define OrientationSensorShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Input Function ID 22 | #define ORIENTATION_VALUE 0x01 23 | 24 | class OrientationSensorShield : public ShieldParent 25 | { 26 | public: 27 | //Constructor 28 | OrientationSensorShield(); 29 | //Getters 30 | float getX(); 31 | float getY(); 32 | float getZ(); 33 | //setOnChange for Users Function 34 | void setOnValueChange(void (*)(float,float,float)); 35 | 36 | private: 37 | //Reserve Variables 38 | float valueX ,valueY,valueZ; 39 | //Boolean for the setOnChange Function 40 | bool isCallBackAssigned; 41 | //Process Input Data 42 | void processData(); 43 | void (*changeCallBack)(float,float,float); 44 | 45 | friend class OneSheeldClass; 46 | }; 47 | 48 | //Extern Object 49 | extern OrientationSensorShield OrientationSensor; 50 | #endif -------------------------------------------------------------------------------- /PatternShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: PatternShield.cpp 5 | 6 | Version: 1.4 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.1 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "PatternShield.h" 18 | 19 | 20 | //Constructor 21 | PatternShield::PatternShield() : ShieldParent(PATTERN_ID) 22 | { 23 | isNewPattern =false; 24 | isCallBackAssigned = false; 25 | length=0; 26 | for(int i=0;iMAX_PATTERN_SIZE)return; 62 | for (int i = 0; i < length; i++) 63 | { 64 | PatternNode node; 65 | node.setValue(getOneSheeldInstance().getArgumentData(0)[i]); 66 | nodes[i]=node; 67 | } 68 | 69 | if(isCallBackAssigned && !isInACallback()) 70 | { 71 | enteringACallback(); 72 | (*changeCallBack)(nodes,length); 73 | exitingACallback(); 74 | } 75 | 76 | } 77 | 78 | } 79 | 80 | -------------------------------------------------------------------------------- /PatternShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: PatternShield.h 5 | 6 | Version: 1.4 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.1 13 | 14 | */ 15 | #ifndef PatternShield_h 16 | #define PatternShield_h 17 | 18 | #include "ShieldParent.h" 19 | 20 | // Input Function ID 21 | #define PATTERN_VALUE 0x01 22 | #define MAX_PATTERN_SIZE 9 23 | 24 | 25 | struct PatternNode{ 26 | byte row; 27 | byte col; 28 | void setValue(byte val) 29 | { 30 | row=val&0x0F; 31 | col=(val&0xF0)>>4; 32 | } 33 | bool operator==(const PatternNode& other) 34 | { 35 | return (row==other.row)&&(col==other.col); 36 | } 37 | 38 | bool operator!=(const PatternNode& other) 39 | { 40 | return !(*this == other); 41 | } 42 | 43 | }; 44 | 45 | class PatternShield : public ShieldParent 46 | { 47 | public: 48 | //Constructor 49 | PatternShield(); 50 | PatternNode * getLastPattern(); 51 | int getLastPatternLength(); 52 | bool isNewPatternReceived(); 53 | void setOnNewPattern(void (*)(PatternNode[] ,int )); 54 | 55 | private: 56 | int length; 57 | bool isNewPattern; 58 | bool isCallBackAssigned; 59 | PatternNode nodes[MAX_PATTERN_SIZE]; 60 | 61 | void processData(); 62 | void (*changeCallBack)(PatternNode[], int ); 63 | 64 | }; 65 | 66 | //Extern Object 67 | extern PatternShield Pattern; 68 | #endif -------------------------------------------------------------------------------- /PhoneShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: PhoneShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef PhoneShield_h 17 | #define PhoneShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Output Function ID 22 | #define PHONE_CALL 0x01 23 | 24 | //Input Function ID's 25 | #define PHONE_IS_RINGING 0x01 26 | #define PHONE_GET_NUMBER 0x02 27 | 28 | class PhoneShieldClass : public ShieldParent 29 | { 30 | public: 31 | //Constructor 32 | PhoneShieldClass(); 33 | //Setter 34 | void call(const char* ); 35 | void call(String); 36 | //Checker 37 | bool isRinging(); 38 | //Getter 39 | char * getNumber(); 40 | String getNumberAsString(); 41 | //setOnChange for Users Function 42 | void setOnCallStatusChange(void (*)(bool ,char [])); 43 | void setOnCallStatusChange(void (*)(bool , String)); 44 | 45 | private: 46 | //Reserve Variable 47 | byte value ; 48 | char * number; 49 | //Boolean For the setOnChange Function 50 | bool isCallBackAssigned; 51 | bool usedSetOnString; 52 | //Process Input Data 53 | void processData(); 54 | void (*changeCallBack)(bool ,char []); 55 | void (*changeCallBackString)(bool , String); 56 | }; 57 | 58 | //Extern Object 59 | extern PhoneShieldClass Phone; 60 | #endif -------------------------------------------------------------------------------- /PressureSensorShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: PressureSensorShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "PressureSensorShield.h" 18 | 19 | //Class Constructor 20 | PressureSensorShield::PressureSensorShield() : ShieldParent(PRESSURE_ID) 21 | { 22 | value=0; 23 | isCallBackAssigned=false; 24 | } 25 | //Pressure Getter 26 | int PressureSensorShield::getValue() 27 | { 28 | 29 | return value; 30 | 31 | } 32 | 33 | //PressureSensor Input Data Processing 34 | void PressureSensorShield::processData() 35 | { 36 | //Checking Function-ID 37 | byte functionId =getOneSheeldInstance().getFunctionId(); 38 | if(functionId==PRESSURE_VALUE) 39 | { 40 | value=(getOneSheeldInstance().getArgumentData(0)[1]<<8)|(getOneSheeldInstance().getArgumentData(0)[0]); 41 | //Users Function Invoked 42 | if(isCallBackAssigned && !isInACallback()) 43 | { 44 | enteringACallback(); 45 | (*changeCallBack)(value); 46 | exitingACallback(); 47 | } 48 | } 49 | } 50 | //Users Function Setter 51 | void PressureSensorShield::setOnValueChange(void (*userFunction)(unsigned long pressureValue)) 52 | { 53 | changeCallBack=userFunction; 54 | isCallBackAssigned=true; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /PressureSensorShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: PressureSensorShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef PressureSensorShield_h 17 | #define PressureSensorShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Input Function ID 22 | #define PRESSURE_VALUE 0x01 23 | 24 | class PressureSensorShield : public ShieldParent 25 | { 26 | public: 27 | //Constructor 28 | PressureSensorShield(); 29 | //Getter 30 | int getValue(); 31 | //setOnChange for Users Function 32 | void setOnValueChange(void (*)(unsigned long)); 33 | 34 | private: 35 | //Reserve Variables 36 | int value; 37 | //Boolean For the setOnChange Function 38 | bool isCallBackAssigned; 39 | //Process Input Data 40 | void processData(); 41 | void (*changeCallBack)(unsigned long); 42 | }; 43 | 44 | //Extern Object 45 | extern PressureSensorShield PressureSensor; 46 | #endif -------------------------------------------------------------------------------- /ProximitySensorShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: ProximitySensorShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "ProximitySensorShield.h" 18 | 19 | 20 | //Class Constructor 21 | ProximitySensorShield::ProximitySensorShield() : ShieldParent(PROXIMITY_ID) 22 | { 23 | value=0; 24 | isCallBackAssigned=false; 25 | } 26 | //Proximity Getter 27 | byte ProximitySensorShield::getValue() 28 | { 29 | return value; 30 | } 31 | 32 | //ProximitySensor Input Data Processing 33 | void ProximitySensorShield::processData() 34 | { 35 | //Checking Function-ID 36 | byte functionId =getOneSheeldInstance().getFunctionId(); 37 | if(functionId==PROXIMITY_VALUE) 38 | { 39 | value=getOneSheeldInstance().getArgumentData(0)[0]; 40 | //Users Function Invoked 41 | if (isCallBackAssigned && !isInACallback()) 42 | { 43 | enteringACallback(); 44 | (*changeCallBack)(value); 45 | exitingACallback(); 46 | } 47 | } 48 | } 49 | //Users Function Setter 50 | void ProximitySensorShield::setOnValueChange(void (*userFunction)(byte proximityValue)) 51 | { 52 | changeCallBack=userFunction; 53 | isCallBackAssigned=true; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /ProximitySensorShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: ProximitySensorShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef ProximitySensorShield_h 17 | #define ProximitySensorShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Input Function ID 22 | #define PROXIMITY_VALUE 0x01 23 | 24 | class ProximitySensorShield : public ShieldParent 25 | { 26 | public: 27 | //Constructor 28 | ProximitySensorShield(); 29 | //Getter 30 | byte getValue(); 31 | //setOnChange for Users Function 32 | void setOnValueChange(void (*userFunction)(byte)); 33 | 34 | private: 35 | //Reserve Variables 36 | byte value; 37 | //Boolean For the setOnChange Function 38 | bool isCallBackAssigned; 39 | //Process Input Data 40 | void processData(); 41 | void (* changeCallBack)(byte); 42 | }; 43 | 44 | //Extern Object 45 | extern ProximitySensorShield ProximitySensor; 46 | 47 | #endif -------------------------------------------------------------------------------- /PushButtonShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: PushButtonShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "PushButtonShield.h" 18 | 19 | //Class Constructor 20 | PushButtonShield::PushButtonShield() : ShieldParent(PUSH_BUTTON_ID) 21 | { 22 | value=0; 23 | isCallBackAssigned=false; 24 | } 25 | //PushButton Checker 26 | bool PushButtonShield::isPressed() 27 | { 28 | return !!value; 29 | } 30 | 31 | //Phone Input Data Processing 32 | void PushButtonShield::processData() 33 | { 34 | //Checking Function-ID 35 | byte functionId =getOneSheeldInstance().getFunctionId(); 36 | if(functionId==PUSHBUTTON_VALUE) 37 | { 38 | value=getOneSheeldInstance().getArgumentData(0)[0]; 39 | //Users Function Invoked 40 | if(isCallBackAssigned && !isInACallback()) 41 | { 42 | enteringACallback(); 43 | (*changeCallBack)(!!value); 44 | exitingACallback(); 45 | } 46 | } 47 | } 48 | //Users Function Setter 49 | void PushButtonShield::setOnButtonStatusChange(void (*userFunction)(bool pushButtonValue)) 50 | { 51 | changeCallBack=userFunction; 52 | isCallBackAssigned=true; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /PushButtonShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: PushButtonShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef PushButtonShield_h 17 | #define PushButtonShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Input Function ID 22 | #define PUSHBUTTON_VALUE 0x01 23 | 24 | class PushButtonShield : public ShieldParent 25 | { 26 | public: 27 | //Constructor 28 | PushButtonShield(); 29 | //Checker 30 | bool isPressed(); 31 | //setOnChange for Users Function 32 | void setOnButtonStatusChange(void (*userFunction)(bool )); 33 | 34 | private: 35 | //Reserve Variable 36 | byte value; 37 | //Boolean For the setOnChange Function 38 | bool isCallBackAssigned; 39 | //Process Input Data 40 | void processData(); 41 | void (*changeCallBack)(bool); 42 | }; 43 | 44 | //Extern Object 45 | extern PushButtonShield PushButton; 46 | #endif -------------------------------------------------------------------------------- /SMSShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: SMSShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef SMSShield_h 17 | #define SMSShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Outputs Functions ID's 22 | #define SMS_SEND 0x01 23 | 24 | //Input Functions ID's 25 | #define SMS_GET 0x01 26 | 27 | class SMSShieldClass : public ShieldParent 28 | { 29 | public: 30 | //Constructor 31 | SMSShieldClass(); 32 | //Sender 33 | void send(const char* ,const char*); 34 | void send(String , String ); 35 | bool isNewSms(); 36 | //Getter 37 | char * getSms(); 38 | String getSmsAsString(); 39 | char * getNumber(); 40 | String getNumberAsString(); 41 | //setOnChange for Users Function 42 | void setOnSmsReceive(void (*)(char [],char [])); 43 | void setOnSmsReceive(void (*)(String ,String )); 44 | 45 | private: 46 | //Reserve Variable 47 | char * text; 48 | char * number; 49 | //Boolean For the setOnChange Function 50 | bool isCallBackAssigned; 51 | //Boolean to check if new SMS arrived 52 | bool isItNewSms; 53 | //Boolean for setOnSmsString 54 | bool usedSetOnWithString; 55 | //Process Input Data 56 | void processData(); 57 | void (*changeCallBack)(char [],char []); 58 | void (*changeCallBackString)(String ,String); 59 | }; 60 | 61 | //Extern Object 62 | extern SMSShieldClass SMS; 63 | #endif -------------------------------------------------------------------------------- /SevenSegmentShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: SevenSegmentShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "SevenSegmentShield.h" 18 | 19 | //Number Setter 20 | void SevenSegmentShieldClass::setNumber(byte x) 21 | { 22 | byte data2[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; 23 | 24 | switch (x) 25 | { 26 | 27 | case 0 : setValue(data2[0]);break; 28 | case 1 : setValue(data2[1]);break; 29 | case 2 : setValue(data2[2]);break; 30 | case 3 : setValue(data2[3]);break; 31 | case 4 : setValue(data2[4]);break; 32 | case 5 : setValue(data2[5]);break; 33 | case 6 : setValue(data2[6]);break; 34 | case 7 : setValue(data2[7]);break; 35 | case 8 : setValue(data2[8]);break; 36 | case 9 : setValue(data2[9]);break; 37 | } 38 | 39 | } 40 | //Setter 41 | void SevenSegmentShieldClass::setValue(byte shape) 42 | { 43 | 44 | OneSheeld.sendShieldFrame(SEV_SEG_ID,0,SEVENSEGMENT_SET_VALUE,1,new FunctionArg(1,&shape)); 45 | 46 | } 47 | //Dot Setter 48 | void SevenSegmentShieldClass::setDot() 49 | { 50 | 51 | OneSheeld.sendShieldFrame(SEV_SEG_ID,0,SEVENSEGMENT_SET_DOT,0); 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /SevenSegmentShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: SevenSegmentShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef SevenSegmentShield_h 17 | #define SevenSegmentShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Output Function ID's 22 | #define SEVENSEGMENT_SET_VALUE 0x01 23 | #define SEVENSEGMENT_SET_DOT 0x02 24 | 25 | class SevenSegmentShieldClass : public ShieldParent 26 | { 27 | 28 | public: 29 | //Constructor 30 | SevenSegmentShieldClass():ShieldParent(SEV_SEG_ID){}; 31 | //Setters 32 | void setNumber(byte ); 33 | void setValue(byte ); 34 | void setDot(); 35 | 36 | private: 37 | 38 | }; 39 | 40 | //Extern Object 41 | extern SevenSegmentShieldClass SevenSegment; 42 | #endif 43 | -------------------------------------------------------------------------------- /ShapeClass.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: ShapeClass.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "ShapeClass.h" 18 | 19 | int ShapeClass::currentShapeId=0; 20 | 21 | ShapeClass::ShapeClass(byte _shapeType,int _xPosition, int _yPosition) 22 | { 23 | shapeType = _shapeType; 24 | shapeID =currentShapeId++; 25 | xposition=_xPosition; 26 | yposition=_yPosition; 27 | isInteractiveShape=false; 28 | } 29 | 30 | 31 | void ShapeClass::setVisibility(byte visbilityType) 32 | { 33 | byte functionId = SHAPE_VISIBILITY; 34 | 35 | byte shapeIdArray[2] ; 36 | shapeIdArray[1] = (shapeID >> 8) & 0xFF; 37 | shapeIdArray[0] = shapeID & 0xFF; 38 | 39 | OneSheeld.sendShieldFrame(GLCD_ID,0,shapeType,3,new FunctionArg(1,&functionId),new FunctionArg(2,shapeIdArray) 40 | ,new FunctionArg(1,&visbilityType)); 41 | } 42 | 43 | void ShapeClass::setPosition(int xposition , int yposition) 44 | { 45 | byte functionId = SHAPE_POSITION; 46 | 47 | byte xPositionArray[2] ; 48 | xPositionArray[1] = (xposition >> 8) & 0xFF; 49 | xPositionArray[0] = xposition & 0xFF; 50 | 51 | byte yPositionArray[2] ; 52 | yPositionArray[1] = (yposition >> 8) & 0xFF; 53 | yPositionArray[0] = yposition & 0xFF; 54 | 55 | byte shapeIdArray[2] ; 56 | shapeIdArray[1] = (shapeID >> 8) & 0xFF; 57 | shapeIdArray[0] = shapeID & 0xFF; 58 | 59 | OneSheeld.sendShieldFrame(GLCD_ID,0,shapeType,4,new FunctionArg(1,&functionId),new FunctionArg(2,shapeIdArray) 60 | ,new FunctionArg(2,xPositionArray) 61 | ,new FunctionArg(2,yPositionArray)); 62 | } -------------------------------------------------------------------------------- /ShapeClass.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: Shape.h 5 | 6 | Version: 7.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.7 13 | 14 | */ 15 | 16 | #ifndef ShapeClass_h 17 | #define ShapeClass_h 18 | 19 | #define SHAPE_DRAW 0x00 20 | #define SHAPE_POSITION 0x01 21 | #define SHAPE_VISIBILITY 0x02 22 | 23 | class ShapeClass 24 | { 25 | public: 26 | virtual void setVisibility(byte); 27 | virtual void setPosition(int ,int ); 28 | friend class GLCDShield; 29 | protected: 30 | ShapeClass(byte,int,int); 31 | int shapeID; 32 | byte shapeType; 33 | int xposition; 34 | int yposition; 35 | bool isInteractiveShape; 36 | virtual void draw()=0; 37 | 38 | private: 39 | static int currentShapeId; 40 | 41 | 42 | }; 43 | 44 | #endif -------------------------------------------------------------------------------- /ShieldParent.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: ShieldParent.h 5 | 6 | Version: 1.3 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2015.1 13 | 14 | */ 15 | 16 | #ifndef ShieldParent_h 17 | #define ShieldParent_h 18 | 19 | 20 | /* Output functions ID. */ 21 | #define QUERY_SELECTED 0xFF 22 | #define SELECT_SHIELD 0xFE 23 | #define DESELECT_SHIELD 0xFD 24 | 25 | 26 | /* Input functions ID. */ 27 | #define CHECK_SELECTED 0xFF 28 | 29 | class OneSheeldClass; 30 | 31 | class ShieldParent 32 | { 33 | protected: 34 | ShieldParent(byte); 35 | virtual void processFrame(void); 36 | virtual void processData(void){}; 37 | void enteringACallback(); 38 | void exitingACallback(); 39 | bool isInACallback(); 40 | OneSheeldClass & getOneSheeldInstance(); 41 | public: 42 | /* Functions will be inherited by all shields. */ 43 | void select(void); 44 | void deselect(void); 45 | void setOnSelected(void(*)(void)); 46 | byte getShieldId(void); 47 | private: 48 | bool isCallBackSet; 49 | byte shieldID; 50 | void (*selectedCallBack)(void); 51 | static OneSheeldClass * oneSheeldInstance; 52 | static bool oneSheeldInstanceAvailable; 53 | static void setOneSheeldInstance(OneSheeldClass &); 54 | static void unSetOneSheeldInstance(); 55 | 56 | friend class OneSheeldClass; 57 | }; 58 | 59 | #endif -------------------------------------------------------------------------------- /ShieldsIds.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: ShieldsIds.h 5 | 6 | Version: 1.2 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.9 13 | 14 | */ 15 | 16 | //Shields ID's 17 | #define ONESHEELD_ID 0x00 18 | #define SLIDER_ID 0x01 19 | #define LED_ID 0x02 20 | #define PUSH_BUTTON_ID 0x03 21 | #define TOGGLE_BUTTON_ID 0x04 22 | #define COLOR_ID 0x05 23 | #define NOTIFICATION_ID 0x06 24 | #define SEV_SEG_ID 0x07 25 | #define BUZZER_ID 0x08 26 | #define KEYPAD_SHIELD_ID 0x09 27 | #define MAGNETOMETER_ID 0x0A 28 | #define ACCELEROMETER_ID 0x0B 29 | #define GAMEPAD_ID 0x0C 30 | #define SMS_ID 0x0D 31 | #define GYROSCOPE_ID 0x0E 32 | #define ORIENTATION_ID 0x0F 33 | #define LIGHT_ID 0x10 34 | #define PRESSURE_ID 0x11 35 | #define TEMPERATURE_ID 0x12 36 | #define PROXIMITY_ID 0x13 37 | #define GRAVITY_ID 0x14 38 | #define CAMERA_ID 0x15 39 | #define NFC_ID 0x16 40 | #define LCD_ID 0x17 41 | #define MIC_ID 0x18 42 | #define FACEBOOK_ID 0x19 43 | #define TWITTER_ID 0x1A 44 | #define FOURSQUARE_ID 0x1B 45 | #define GPS_ID 0x1C 46 | #define MUSIC_PLAYER_ID 0x1D 47 | #define EMAIL_ID 0x1E 48 | #define SKYPE_ID 0x1F 49 | #define PHONE_ID 0x20 50 | #define CLOCK_ID 0x21 51 | #define KEYBOARD_ID 0x22 52 | #define TTS_ID 0x23 53 | #define VOICE_RECOGNITION_ID 0x24 54 | #define DATA_LOGGER_ID 0x25 55 | #define TERMINAL_ID 0x26 56 | #define PATTERN_ID 0x27 57 | #define GLCD_ID 0x28 58 | #define INTERNET_ID 0x29 59 | #define VIBRATION_ID 0x2A 60 | #define BARCODE_ID 0x2B 61 | #define FINGERPRINT_ID 0x2C 62 | #define FACE_DETECTOR_ID 0x2D 63 | #define CHART_ID 0x2E 64 | #define IOT_ID 0x2F 65 | -------------------------------------------------------------------------------- /ShieldsIncludes.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: ShieldsIncludes.h 5 | 6 | Version: 1.2 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.9 13 | 14 | */ 15 | 16 | //Inlcuding Shields Headers 17 | #include "TwitterShield.h" 18 | #include "FacebookShield.h" 19 | #include "KeypadShield.h" 20 | #include "NotificationShield.h" 21 | #include "SMSShield.h" 22 | #include "PhoneShield.h" 23 | #include "GPSShield.h" 24 | #include "SevenSegmentShield.h" 25 | #include "SkypeShield.h" 26 | #include "MusicPlayerShield.h" 27 | #include "EmailShield.h" 28 | #include "FoursquareShield.h" 29 | #include "CameraShield.h" 30 | #include "BuzzerShield.h" 31 | #include "LedShield.h" 32 | #include "SliderShield.h" 33 | #include "PushButtonShield.h" 34 | #include "ToggleButtonShield.h" 35 | #include "GamePadShield.h" 36 | #include "ProximitySensorShield.h" 37 | #include "MicShield.h" 38 | #include "TemperatureSensorShield.h" 39 | #include "LightSensorShield.h" 40 | #include "PressureSensorShield.h" 41 | #include "GravitySensorShield.h" 42 | #include "AccelerometerSensorShield.h" 43 | #include "GyroscopeSensorShield.h" 44 | #include "OrientationSensorShield.h" 45 | #include "MagnetometerSensorShield.h" 46 | #include "LCDShield.h" 47 | #include "ClockShield.h" 48 | #include "KeyboardShield.h" 49 | #include "TTSShield.h" 50 | #include "VoiceRecognitionShield.h" 51 | #include "DataLoggerShield.h" 52 | #include "TerminalShield.h" 53 | #include "PatternShield.h" 54 | #include "InternetShield.h" 55 | #include "ColorShield.h" 56 | #include "NFCShield.h" 57 | #include "GLCDShield.h" 58 | #include "VibrationShield.h" 59 | #include "BarcodeScannerShield.h" 60 | #include "FingerprintScannerShield.h" 61 | #include "FaceDetectionShield.h" 62 | #include "ChartShield.h" 63 | #include "IOTShield.h" 64 | -------------------------------------------------------------------------------- /SkypeShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: SkypeShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "SkypeShield.h" 18 | 19 | //Call Setter 20 | void SkypeShieldClass::call(const char *username) 21 | { 22 | //Check length of string 23 | int usernameLength = strlen(username); 24 | if(!usernameLength) return; 25 | OneSheeld.sendShieldFrame(SKYPE_ID,0,SKYPE_CALL,1,new FunctionArg(usernameLength,(byte *)username)); 26 | } 27 | 28 | void SkypeShieldClass::call(String username) 29 | { 30 | call(&username[0]); 31 | } 32 | 33 | //VideoCall Setter 34 | void SkypeShieldClass::videoCall(const char * username) 35 | { 36 | //Check length of string 37 | int usernameLength = strlen(username); 38 | if(!usernameLength) return; 39 | OneSheeld.sendShieldFrame(SKYPE_ID,0,SKYPE_VIDEO_CALL,1,new FunctionArg(usernameLength,(byte *)username)); 40 | } 41 | 42 | void SkypeShieldClass::videoCall(String username) 43 | { 44 | call(&username[0]); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /SkypeShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: SkypeShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef SkypeShield_h 17 | #define SkypeShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Output Function ID's 22 | #define SKYPE_CALL 0x01 23 | #define SKYPE_VIDEO_CALL 0x02 24 | 25 | class SkypeShieldClass : public ShieldParent 26 | { 27 | 28 | public: 29 | //Constructor 30 | SkypeShieldClass(): ShieldParent(SKYPE_ID){}; 31 | //Setters 32 | void call(const char *); 33 | void call(String ); 34 | void videoCall(const char *); 35 | void videoCall(String ); 36 | 37 | private: 38 | 39 | }; 40 | 41 | //Extern Object 42 | extern SkypeShieldClass Skype; 43 | #endif -------------------------------------------------------------------------------- /SliderShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: SliderShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "SliderShield.h" 18 | 19 | //Class Constructor 20 | SliderShield::SliderShield() : ShieldParent(SLIDER_ID) 21 | { 22 | value=0; 23 | isCallBackAssigned=false; 24 | } 25 | //Slider Getter 26 | byte SliderShield::getValue() 27 | { 28 | return value; 29 | } 30 | 31 | void SliderShield::setValue(int value) 32 | { 33 | byte copiedValue ; 34 | if(value>255) 35 | { 36 | copiedValue= 255; 37 | } 38 | else if (value < 0) 39 | { 40 | copiedValue= 0; 41 | } 42 | else 43 | { 44 | copiedValue = value; 45 | } 46 | OneSheeld.sendShieldFrame(SLIDER_ID,0,SLIDER_SET,1,new FunctionArg(1,&copiedValue)); 47 | } 48 | 49 | //Phone Input Data Processing 50 | void SliderShield::processData() 51 | { 52 | //Checking Function-ID 53 | byte functionId= getOneSheeldInstance().getFunctionId(); 54 | 55 | if(functionId==SLIDER_VALUE) 56 | { 57 | value= getOneSheeldInstance().getArgumentData(0)[0]; 58 | //Users Function Invoked 59 | if(isCallBackAssigned && !isInACallback()) 60 | { 61 | enteringACallback(); 62 | (*changeCallBack)(value); 63 | exitingACallback(); 64 | } 65 | } 66 | } 67 | //Users Function Setter 68 | void SliderShield::setOnValueChange(void (*userFunction)(byte sliderValue)) 69 | { 70 | changeCallBack=userFunction; 71 | isCallBackAssigned=true; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /SliderShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: SliderShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef SliderShield_h 17 | #define SliderShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | 22 | //Input Function ID 23 | #define SLIDER_VALUE 0x01 24 | 25 | //Output Function ID 26 | #define SLIDER_SET 0x01 27 | 28 | class SliderShield : public ShieldParent 29 | { 30 | public: 31 | //Constructor 32 | SliderShield(); 33 | //Getter 34 | byte getValue(); 35 | //Setter 36 | void setValue(int ); 37 | //setOnChange for Users Function 38 | void setOnValueChange(void (*userFunction)(byte)); 39 | 40 | private: 41 | //Reserve Variable 42 | byte value; 43 | //Boolean For setOnChange Function 44 | bool isCallBackAssigned; 45 | //Process Input Data 46 | void processData(); 47 | void(*changeCallBack)(byte); 48 | }; 49 | 50 | //Extern Object 51 | extern SliderShield Slider; 52 | #endif 53 | -------------------------------------------------------------------------------- /TTSShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: TTSShield.cpp 5 | 6 | Version: 1.2 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.9 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "TTSShield.h" 18 | 19 | //Give text to be said by the phone 20 | void TTSShield::say(const char * text) 21 | { 22 | //Check length of string 23 | int textLength = strlen(text); 24 | if(!textLength) return; 25 | OneSheeld.sendShieldFrame(TTS_ID,0,TTS_SAY,1,new FunctionArg(textLength,(byte*)text)); 26 | } 27 | 28 | void TTSShield::say(String text) 29 | { 30 | say(&text[0]); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /TTSShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: TTSShield.h 5 | 6 | Version: 1.2 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.9 13 | 14 | */ 15 | 16 | #ifndef TTSShield_h 17 | #define TTSShield_h 18 | 19 | 20 | #include "ShieldParent.h" 21 | 22 | //Output Function ID 23 | #define TTS_SAY 0x01 24 | 25 | 26 | class TTSShield: public ShieldParent 27 | { 28 | public: 29 | // Constructor 30 | TTSShield():ShieldParent(TTS_ID){}; 31 | //Process 32 | void say(const char *); 33 | void say(String ); 34 | private: 35 | 36 | }; 37 | 38 | //Extern Object 39 | extern TTSShield TextToSpeech ; 40 | #endif -------------------------------------------------------------------------------- /TemperatureSensorShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: TemperatureSensorShield.cpp 5 | 6 | Version: 1.1 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "TemperatureSensorShield.h" 18 | 19 | 20 | //Class Constructor 21 | TemperatureSensorShield::TemperatureSensorShield() : ShieldParent(TEMPERATURE_ID) 22 | { 23 | value=0xff; 24 | isCallBackAssigned=false; 25 | } 26 | //Temperature Getter 27 | char TemperatureSensorShield::getValue() 28 | { 29 | return value; 30 | } 31 | 32 | //TemperatureSensor Input Data Processing 33 | void TemperatureSensorShield::processData() 34 | { 35 | //Checking Function-ID 36 | byte functionId =getOneSheeldInstance().getFunctionId(); 37 | 38 | if(functionId==TEMPERATURE_VALUE) 39 | { 40 | value=getOneSheeldInstance().getArgumentData(0)[0]; 41 | //Users Function Invocation 42 | if(isCallBackAssigned && !isInACallback()) 43 | { 44 | enteringACallback(); 45 | (*changeOnCallBack)(value); 46 | exitingACallback(); 47 | } 48 | } 49 | } 50 | //Users Function Setter 51 | void TemperatureSensorShield::setOnValueChange(void(*userFunction)(char temp)) 52 | { 53 | changeOnCallBack=userFunction; 54 | isCallBackAssigned=true; 55 | } 56 | 57 | float TemperatureSensorShield::getAsFahrenheit() 58 | { 59 | float fahrenheit; 60 | fahrenheit = (float)value*(1.8)+32; 61 | return fahrenheit; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /TemperatureSensorShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: TemperatureSensorShield.h 5 | 6 | Version: 1.1 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef TemperatureSensorShield_h 17 | #define TemperatureSensorShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | 22 | //Input Function ID 23 | #define TEMPERATURE_VALUE 0x01 24 | 25 | class TemperatureSensorShield : public ShieldParent 26 | { 27 | public: 28 | //Constructor 29 | TemperatureSensorShield(); 30 | //Getter 31 | char getValue(); 32 | //setOnChange for Users Function 33 | void setOnValueChange(void (*)(char)); 34 | //Helper Function 35 | float getAsFahrenheit(); 36 | 37 | private: 38 | //Reserve Variable 39 | char value; 40 | //Boolean For the setOnChange Function 41 | bool isCallBackAssigned; 42 | //Process Input Data 43 | void processData(); 44 | void(*changeOnCallBack)(char); 45 | }; 46 | 47 | //Extern Object 48 | extern TemperatureSensorShield TemperatureSensor; 49 | #endif -------------------------------------------------------------------------------- /TerminalShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: TerminalShield.cpp 5 | 6 | Version: 1.2 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.9 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "TerminalShield.h" 18 | 19 | //Constructor 20 | TerminalShield::TerminalShield():PrintlnClass(TERMINAL_ID,TERMINAL_WRITE,TERMINAL_PRINT),ShieldParent(TERMINAL_ID) 21 | {} 22 | 23 | //Read from Android 24 | char TerminalShield::read() 25 | { 26 | if(buffer.remain()<=0)return -1; 27 | return buffer.pop(); 28 | } 29 | //Flush buffer contents 30 | void TerminalShield::flush() 31 | { 32 | while(read()!=-1); 33 | } 34 | //Check Data avialable in Buffer 35 | int TerminalShield::available() 36 | { 37 | return buffer.remain(); 38 | } 39 | //Read bytes from Buffer 40 | int TerminalShield::readBytes(char *arr, int length) 41 | { 42 | int count = 0; 43 | while (count < length) { 44 | int c = read(); 45 | if (c < 0) break; 46 | *arr++ = (char)c; 47 | count++; 48 | } 49 | return count; 50 | } 51 | 52 | //Terminal Incomming Data processing 53 | void TerminalShield::processData() 54 | { 55 | byte functionID = getOneSheeldInstance().getFunctionId(); 56 | byte dataLength = getOneSheeldInstance().getArgumentLength(0); 57 | if(functionID == TERMINAL_READ) 58 | { 59 | for (int j=0; j buffer; 48 | //Process Input data 49 | void processData(); 50 | }; 51 | //Extern Object 52 | extern TerminalShield Terminal; 53 | #endif -------------------------------------------------------------------------------- /ToggleButtonShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: ToggleButtonShield.cpp 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | #define FROM_ONESHEELD_LIBRARY 16 | #include "OneSheeld.h" 17 | #include "ToggleButtonShield.h" 18 | 19 | 20 | //Class Constructor 21 | ToggleButtonShield::ToggleButtonShield() : ShieldParent(TOGGLE_BUTTON_ID) 22 | { 23 | value=0; 24 | isCallBackAssigned=false; 25 | } 26 | //ToggleButton Checker 27 | bool ToggleButtonShield::getStatus() 28 | { 29 | return !!value; 30 | } 31 | 32 | //ToggleButton Input Data Processing 33 | void ToggleButtonShield::processData() 34 | { 35 | //Checking Function-ID 36 | byte functionId= getOneSheeldInstance().getFunctionId(); 37 | if(functionId==TOGGLEBUTTON_VALUE) 38 | { 39 | value=getOneSheeldInstance().getArgumentData(0)[0]; 40 | //Users Function Invoked 41 | if(isCallBackAssigned && !isInACallback()) 42 | { 43 | enteringACallback(); 44 | (*changeCallBack)(!!value); 45 | exitingACallback(); 46 | } 47 | } 48 | } 49 | //Users Function Setter 50 | void ToggleButtonShield::setOnButtonStatusChange(void (*userFunction)(bool toggleButtonValue)) 51 | { 52 | changeCallBack=userFunction; 53 | isCallBackAssigned=true; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /ToggleButtonShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: ToggleButtonShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef ToggleButtonShield_h 17 | #define ToggleButtonShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Input Function ID 22 | #define TOGGLEBUTTON_VALUE 0x01 23 | 24 | class ToggleButtonShield : public ShieldParent 25 | { 26 | public: 27 | //Constructor 28 | ToggleButtonShield(); 29 | //Checker 30 | bool getStatus(); 31 | //setOnChange for Users Function 32 | void setOnButtonStatusChange(void (*userFunction)(bool)); 33 | 34 | private: 35 | //Reserve Variable 36 | byte value; 37 | //Boolean for the setOnChange Function 38 | bool isCallBackAssigned; 39 | //Process Input Data 40 | void processData(); 41 | void (*changeCallBack)(bool); 42 | }; 43 | 44 | //Extern Object 45 | extern ToggleButtonShield ToggleButton; 46 | #endif -------------------------------------------------------------------------------- /TwitterShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: TwitterShield.h 5 | 6 | Version: 1.0 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.5 13 | 14 | */ 15 | 16 | #ifndef TwitterShield_h 17 | #define TwitterShield_h 18 | 19 | #include "ShieldParent.h" 20 | 21 | //Output Function ID 22 | #define TWITTER_SEND 0x01 23 | #define TWITTER_SEND_DIRECT_MESSAGE 0x02 24 | #define TWITTER_POST_LAST_PIC 0x03 25 | #define TWITTER_TRACK_KEYWORD 0x04 26 | #define TWITTER_UNTRACK_KEYWORD 0x05 27 | 28 | //Input Functions ID's 29 | #define TWITTER_GET_TWEET 0x01 30 | 31 | 32 | class TwitterShieldClass : public ShieldParent 33 | { 34 | public: 35 | //Constructor 36 | TwitterShieldClass(); 37 | //Send tweet 38 | void tweet(const char* ); 39 | void tweet(String ); 40 | //Send Direct Message 41 | void sendMessage(const char* ,const char* ); 42 | void sendMessage(String , String); 43 | //Checkers 44 | bool isNewTweet(); 45 | //Getters 46 | char * getUserName(); 47 | String getUserNameAsString(); 48 | //Getters 49 | char * getTweet(); 50 | String getTweetAsString(); 51 | //setOnChange for Users Function 52 | void setOnNewTweet(void (*)(char [],char [])); 53 | void setOnNewTweet(void (*)(String , String )); 54 | //Posting Pictures 55 | void tweetLastPicture(const char *,byte =0); 56 | void tweetLastPicture(String , byte =0); 57 | //Track certain words 58 | void trackKeyword(const char * ); 59 | void trackKeyword(String ); 60 | void untrackKeyword(const char *); 61 | void untrackKeyword(String); 62 | 63 | private: 64 | //Reserve Variables 65 | char * userName; 66 | char * tweetText; 67 | //Boolean for setOnChange Function 68 | bool isCallBackAssigned; 69 | //Boolean for incoming String support 70 | bool usedSetOnWithString; 71 | //Boolean to check if a new tweet 72 | bool isItNewTweet; 73 | //Process Input Data 74 | void processData(); 75 | void (*changeCallBack)(char [],char []); 76 | void (*changeCallBackString)(String , String); 77 | }; 78 | //Extern Object 79 | extern TwitterShieldClass Twitter; 80 | #endif -------------------------------------------------------------------------------- /VibrationShield.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: VibrationShield.cpp 5 | 6 | Version: 1.6.1 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Mostafa Mahmoud 11 | 12 | Email: mostafa_mahmoud@protonmail.com 13 | 14 | Date: 2015.11 15 | 16 | */ 17 | #define FROM_ONESHEELD_LIBRARY 18 | #include "OneSheeld.h" 19 | #include "VibrationShield.h" 20 | 21 | //Constructor 22 | VibrationShield::VibrationShield() : ShieldParent(VIBRATION_ID){ 23 | } 24 | 25 | void VibrationShield::start(byte patternLength,int pattern[],int repetitionDelay){ 26 | uint16_t *uint16Pattern = (uint16_t*) malloc(patternLength*sizeof(uint16_t)); 27 | for(int i = 0; i < patternLength;i++){ 28 | uint16Pattern[i] = (uint16_t) pattern[i]; 29 | } 30 | OneSheeld.sendShieldFrame(VIBRATION_ID,0,VIBRATION_START_PATTERN,2,new FunctionArg(patternLength*sizeof(uint16_t),(byte*)uint16Pattern),new FunctionArg(sizeof(uint16_t),(byte*)&repetitionDelay)); 31 | free(uint16Pattern); 32 | } 33 | 34 | void VibrationShield::start(int duration,int repetitionDelay){ 35 | OneSheeld.sendShieldFrame(VIBRATION_ID,0,VIBRATION_START_DURATION,2,new FunctionArg(sizeof(uint16_t),(byte*)&duration),new FunctionArg(sizeof(uint16_t),(byte*)&repetitionDelay)); 36 | } 37 | 38 | void VibrationShield::stop(){ 39 | OneSheeld.sendShieldFrame(VIBRATION_ID,0,VIBRATION_STOP,0); 40 | } 41 | -------------------------------------------------------------------------------- /VibrationShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: VibrationShield.h 5 | 6 | Version: 1.6.1 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Mostafa Mahmoud 11 | 12 | Email: mostafa_mahmoud@protonmail.com 13 | 14 | Date: 2015.11 15 | 16 | */ 17 | #ifndef VibrationShield_h 18 | #define VibrationShield_h 19 | 20 | #include "ShieldParent.h" 21 | 22 | #define VIBRATION_NO_REPEAT 65535 23 | 24 | //Output Function IDs 25 | #define VIBRATION_START_PATTERN 0x01 26 | #define VIBRATION_START_DURATION 0x02 27 | #define VIBRATION_STOP 0x03 28 | 29 | class VibrationShield : public ShieldParent{ 30 | public: 31 | //Empty Constructor 32 | VibrationShield(); 33 | //duration and repetitionDelay values range from 0 to 65534 34 | void start(int duration,int repetitionDelay = VIBRATION_NO_REPEAT); 35 | //Pattern array has maximum length of 127 36 | //Each element in the pattern array range from 0 to 65534 37 | //repetitionDelay value range from 0 to 65534 38 | void start(byte patternLength,int pattern[],int repetitionDelay = VIBRATION_NO_REPEAT); 39 | //Stop function stops vibrations 40 | void stop(); 41 | }; 42 | //External Object 43 | extern VibrationShield Vibration; 44 | #endif 45 | -------------------------------------------------------------------------------- /VoiceRecognitionShield.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Project: 1Sheeld Library 4 | File: VoiceRecognitionShield.h 5 | 6 | Version: 1.2 7 | 8 | Compiler: Arduino avr-gcc 4.3.2 9 | 10 | Author: Integreight 11 | 12 | Date: 2014.9 13 | 14 | */ 15 | #ifndef VoiceRecognitionShield_h 16 | #define VoiceRecognitionShield_h 17 | 18 | #include "ShieldParent.h" 19 | 20 | //Output function ID's 21 | #define VOICE_START_LISTENING 0x01 22 | 23 | //Input Function ID's 24 | #define VOICE_GET 0x01 25 | #define VOICE_GET_ERROR 0x02 26 | 27 | //Errors messages 28 | #define NETWORK_TIMEOUT_ERROR 0x01 29 | #define NETWORK_ERROR 0x02 30 | #define AUDIO_ERROR 0x03 31 | #define SERVER_ERROR 0x04 32 | #define SPEECH_TIMEOUT_ERROR 0x06 33 | #define NO_MATCH_ERROR 0x07 34 | #define RECOGNIZER_BUSY_ERROR 0x08 35 | 36 | 37 | class VoiceRecognitionShield : public ShieldParent 38 | { 39 | public: 40 | //Constructor 41 | VoiceRecognitionShield(); 42 | //Listener 43 | void start(); 44 | //Getter 45 | char * getLastCommand(); 46 | //Getter 47 | String getCommandAsString(); 48 | //Getter 49 | int getLastCommandLength(); 50 | //Checker 51 | bool isNewCommandReceived(); 52 | //Setter 53 | void setOnNewCommand(void (*)(char [])); 54 | //Setter using Strings 55 | void setOnNewCommand(void (*)(String)); 56 | //Setter 57 | void setOnError(void (*)(byte)); 58 | 59 | private: 60 | //Pointer to voice data in memory 61 | char * voice; 62 | //Voice length 63 | int voicetextLength; 64 | //Boolean for Users function 65 | bool isCallBackAssigned; 66 | bool errorAssigned; 67 | bool didDataCame; 68 | bool usedSetOnWithString; 69 | bool newCommand; 70 | //Error number for user function 71 | byte errorNumber; 72 | //Process Input Data 73 | void processData(); 74 | //Setter 75 | void (*changeCallBack)(char*); 76 | //Setter 77 | void (*changeCallBackString)(String); 78 | //Setter 79 | void (*errorCallBack)(byte); 80 | }; 81 | //Extern Object 82 | extern VoiceRecognitionShield VoiceRecognition; 83 | #endif -------------------------------------------------------------------------------- /examples/Advanced/Accelerometer/Accelerometer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Accelerometer Shield Example 4 | 5 | This example shows an application on 1Sheeld's accelerometer shield. 6 | 7 | By using this example, you can grab your smartphone and strike as if 8 | you are bowling so you can turn on the LED on pin 13. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_ACCELEROMETER_SENSOR_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* Variables for the accelerometer's values in 3 dimensions. */ 24 | float x, y, z; 25 | 26 | /* A name for the LED on pin 13. */ 27 | int ledPin = 13 ; 28 | int magnitudeThreshold = 25; 29 | 30 | void setup() 31 | { 32 | /* Start communication. */ 33 | OneSheeld.begin(); 34 | /* Set the LED pin as output. */ 35 | pinMode(ledPin,OUTPUT); 36 | } 37 | 38 | void loop() 39 | { 40 | /* Always get the values of the accelerometer in the 3 dimensions (X, Y and Z). */ 41 | x=AccelerometerSensor.getX(); 42 | y=AccelerometerSensor.getY(); 43 | z=AccelerometerSensor.getZ(); 44 | 45 | /* Check the motion of the smartphone, if it exceeded a limit, turn the LED on. */ 46 | /* We do that by calcuating the magnitude of the 3D vectors. */ 47 | if (sqrt((x*x) + (y*y) + (z*z)) > magnitudeThreshold) 48 | { 49 | /* Turn on the LED. */ 50 | digitalWrite(ledPin,HIGH); 51 | } 52 | else 53 | { 54 | /* Turn off the LED. */ 55 | digitalWrite(ledPin,LOW); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /examples/Advanced/Buzzer/Buzzer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Buzzer Shield Example 4 | 5 | This example shows an application on 1Sheeld's buzzer shield. 6 | 7 | By using this example, you can buzz each and every time you get 8 | near your smartphone using the phone's proximity sensor. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_BUZZER_SHIELD 19 | #define INCLUDE_PROXIMITY_SENSOR_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | void setup() 25 | { 26 | /* Start communication. */ 27 | OneSheeld.begin(); 28 | } 29 | 30 | void loop() 31 | { 32 | /* Check out if something is near the phone, buzz immediately. */ 33 | if (ProximitySensor.getValue() == 0) 34 | { 35 | /* Always buzz when there's something near the phone. */ 36 | Buzzer.buzzOn(); 37 | } 38 | else 39 | { 40 | /* Turn of the buzzer. */ 41 | Buzzer.buzzOff(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /examples/Advanced/Camera/Camera.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Camera Shield Example 4 | 5 | This example shows an application on 1Sheeld's camera shield. 6 | 7 | By using this example, you can take a photo using your phone's 8 | camera if the light sensor reads data above a certain threshold. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_CAMERA_SHIELD 19 | #define INCLUDE_LIGHT_SENSOR_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | void setup() 25 | { 26 | /* Start communication. */ 27 | OneSheeld.begin(); 28 | } 29 | 30 | void loop() 31 | { 32 | /* Always get the value of the light sensor and make sure it is in a certain range. */ 33 | if(LightSensor.getValue()<100 && LightSensor.getValue()>0) 34 | { 35 | /* Turn on the camera's flash while capturing. */ 36 | Camera.setFlash(ON); 37 | /* Take a photo using the phone's rear camera. */ 38 | Camera.rearCapture(); 39 | /* Delay for 5 seconds. */ 40 | OneSheeld.delay(5000); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /examples/Advanced/Clock/Clock.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Clock Shield Example 4 | 5 | This example shows an application on 1Sheeld's clock shield. 6 | 7 | By using this example, you can send an SMS to a friend on his 8 | birthday and update your status on Facebook when the phone's 9 | time reaches a certain time you specify. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_CLOCK_SHIELD 20 | #define INCLUDE_SMS_SHIELD 21 | #define INCLUDE_FACEBOOK_SHIELD 22 | 23 | /* Include 1Sheeld library. */ 24 | #include 25 | 26 | /* Define some variables for the date and time. */ 27 | int hour, minute, second, day, month, year; 28 | 29 | void setup() 30 | { 31 | /* Start communication. */ 32 | OneSheeld.begin(); 33 | /* Start the clock shield. */ 34 | Clock.queryDateAndTime(); 35 | } 36 | 37 | void loop() 38 | { 39 | /* Always get the date and time. */ 40 | hour = Clock.getHours(); 41 | minute = Clock.getMinutes(); 42 | second = Clock.getSeconds(); 43 | day = Clock.getDay(); 44 | month = Clock.getMonth(); 45 | year = Clock.getYear(); 46 | 47 | /* If the date is my friends's birthday date send me 48 | SMS at 3 pm that day and post on Facebook. */ 49 | if(hour == 15 && minute == 0 && second == 0 && day == 6 && month == 2 && year == 2014) 50 | { 51 | /* Send the SMS. */ 52 | SMS.send("1234567890","Happy birthday buddy, sent from 1Sheeld."); 53 | /* Update my Facebook status. */ 54 | Facebook.post("It is my friend birthday."); 55 | /* Delay 2 sec. */ 56 | OneSheeld.delay(2000); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /examples/Advanced/Color/Color.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Color Detector Shield Example 4 | 5 | This example shows an application on 1Sheeld's color detector shield. 6 | 7 | By using this example, you can play a game with your friends by tracking 8 | a black track on a white paper and win by not letting 1Sheeld guide your 9 | direction twice. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_TERMINAL_SHIELD 20 | #define INCLUDE_COLOR_DETECTOR_SHIELD 21 | #define INCLUDE_TEXT_TO_SPEECH_SHIELD 22 | 23 | /* Include 1Sheeld library. */ 24 | #include 25 | 26 | /* Reserve a variable for black color. */ 27 | unsigned long black = 0x000000; 28 | 29 | void setup() 30 | { 31 | /* Start communincation. */ 32 | OneSheeld.begin(); 33 | /* Subscribe to setOnSelected event for the color shield. */ 34 | ColorDetector.setOnSelected(&onColorDetectorSelection); 35 | } 36 | 37 | void loop() 38 | { 39 | /* Leave the loop empty. */ 40 | } 41 | 42 | /* onColorDetectorSelection callback. */ 43 | void onColorDetectorSelection() 44 | { 45 | /* Set color palette to a 1 bit gray scale. */ 46 | ColorDetector.setPalette(_1_BIT_GRAYSCALE_PALETTE); 47 | /* Enable full operation mode to get 9 colors.*/ 48 | ColorDetector.enableFullOperation(); 49 | /* Grab the most dominant color in each patch. */ 50 | ColorDetector.setCalculationMode(MOST_DOMINANT_COLOR); 51 | /* Subscribe to setOnNewColor event. */ 52 | ColorDetector.setOnNewColor(&onNewColor); 53 | } 54 | 55 | /* onNewColor callback. */ 56 | void onNewColor(Color one,Color two,Color three,Color four,Color five,Color six,Color seven,Color eight,Color nine) 57 | { 58 | /* Check upper-left and upper-right patches. */ 59 | if (three == black && one != black) 60 | { 61 | /* Guide me to the Right. */ 62 | TextToSpeech.say("Turn Right"); 63 | OneSheeld.delay(300); 64 | } 65 | else if (one == black && three != black) 66 | { 67 | /* Guide me to the Left. */ 68 | TextToSpeech.say("Turn Left"); 69 | OneSheeld.delay(300); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /examples/Advanced/Email/Email.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Email Shield Example 4 | 5 | This example shows an application on 1Sheeld's email shield. 6 | 7 | By using this example, you can send an email when the app's 8 | Push button is pressed. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_EMAIL_SHIELD 19 | #define INCLUDE_PUSH_BUTTON_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | void setup() 25 | { 26 | /* Start communication.*/ 27 | OneSheeld.begin(); 28 | /* Call a specific function when the push button is pressed or unpressed. */ 29 | PushButton.setOnButtonStatusChange(&onButtonStatusChanged); 30 | } 31 | 32 | void loop() 33 | { 34 | /* Do nothing. */ 35 | } 36 | 37 | void onButtonStatusChanged(bool isPressed) 38 | { 39 | /* Check the buttons status. */ 40 | if(isPressed) 41 | { 42 | /* Send an email. */ 43 | Email.send("example@example.com","Button pressed!","Hi, someone pressed the button!"); 44 | } 45 | } -------------------------------------------------------------------------------- /examples/Advanced/Facebook/Facebook.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Facebook Shield Example 4 | 5 | This example shows an application on 1Sheeld's Facebook shield. 6 | 7 | By using this example, you can update your Facebook status 8 | everyday at 8 am. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_FACEBOOK_SHIELD 19 | #define INCLUDE_CLOCK_SHIELD 20 | 21 | 22 | /* Include 1Sheeld library. */ 23 | #include 24 | /* Include LiquidCrystal library. */ 25 | #include 26 | 27 | /* Initialize the LCD interfacing pins. */ 28 | LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 29 | 30 | /* Define some variables for the time. */ 31 | int hours, minutes, seconds; 32 | /* LCD contrast level on pin 9. */ 33 | int lcdContrast = 9; 34 | 35 | void setup() 36 | { 37 | /* Start communication. */ 38 | OneSheeld.begin(); 39 | /* Start clock shield. */ 40 | Clock.queryDateAndTime(); 41 | /* Set up the LCD's columns and rows. */ 42 | lcd.begin(16, 2); 43 | /*Set lcd contrast pin as output. */ 44 | pinMode(lcdContrast,OUTPUT); 45 | /* Use a range from 0 till 255 to control the contrast of the LCD. */ 46 | analogWrite(lcdContrast,0); 47 | } 48 | 49 | void loop() 50 | { 51 | hours = Clock.getHours(); 52 | minutes = Clock.getMinutes(); 53 | seconds = Clock.getSeconds(); 54 | 55 | /* Check the clock. */ 56 | if(hours == 8 && minutes == 0 && seconds == 0) 57 | { 58 | /* Update my Facebook status. */ 59 | Facebook.post("Good morning!"); 60 | /* Update the LCD screen. */ 61 | lcd.print("Status updated!"); 62 | /* Delay for 2 seconds. */ 63 | OneSheeld.delay(2000); 64 | /* Clear the LCD. */ 65 | lcd.clear(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /examples/Advanced/Foursquare/Foursquare.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Foursquare Shield Example 4 | 5 | This example shows an application on 1Sheeld's Foursquare shield. 6 | 7 | By using this example, you can check-in at the Great Pyramids 8 | of Giza (Egypt) using the Foursquare shield along with the GPS shield. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_FOURSQUARE_SHIELD 19 | #define INCLUDE_GPS_SHIELD 20 | 21 | /* Include 1Sheeld library.*/ 22 | #include 23 | 24 | /* Define a variable to check-in only once.*/ 25 | boolean didIcheckedIn = false; 26 | 27 | void setup() 28 | { 29 | /* Start communication. */ 30 | OneSheeld.begin(); 31 | } 32 | 33 | void loop() 34 | { 35 | /* Always check if the GPS coordinates is in a range of 100 meters from 36 | the coordinates of the pyramids then make a check-in on Foursquare. */ 37 | if (GPS.isInRange(31.134358,29.979175,100)) 38 | { 39 | /* Check only once. */ 40 | if (!didIcheckedIn) 41 | { 42 | /* Check-in at the pyramids. */ 43 | Foursquare.checkIn("4b9f7a50f964a520422537e3","Whao! what a great place."); 44 | /* Reset the value of the variable. */ 45 | didIcheckedIn = true; 46 | } 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /examples/Advanced/GPS/GPS.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | GPS Shield Example 4 | 5 | This example shows an application on 1Sheeld's GPS shield. 6 | 7 | By using this example, you can send an SMS when the smartphone 8 | is in a hundred meters distance from a fixed coordinates you 9 | provide. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_GPS_SHIELD 20 | #define INCLUDE_SMS_SHIELD 21 | 22 | /* Include 1Sheeld library.*/ 23 | #include 24 | 25 | /* Define a boolean flag. */ 26 | boolean isInRange = false; 27 | 28 | void setup() 29 | { 30 | /* Start communication.*/ 31 | OneSheeld.begin(); 32 | } 33 | 34 | void loop() 35 | { 36 | /* Always check if the smartphone's GPS and a given latitude and longitude are in a range of 100 meters. */ 37 | if(GPS.isInRange(30.0831008,31.3242943,100)) 38 | { 39 | if(!isInRange) 40 | { 41 | /* Send SMS. */ 42 | SMS.send("+1234567890","Smartphone is In Range."); 43 | isInRange = true; 44 | } 45 | 46 | } 47 | else 48 | { 49 | if(isInRange) 50 | { 51 | /* Send SMS. */ 52 | SMS.send("1234567890","Smartphone is not In Range."); 53 | isInRange = false; 54 | } 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /examples/Advanced/Gravity/Gravity.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Gravity Shield Example 4 | 5 | This example shows an application on 1Sheeld's gravity shield. 6 | 7 | By using this example, you can send a notification to your 8 | smartphone when you roll it three times left. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_GRAVITY_SENSOR_SHIELD 19 | #define INCLUDE_NOTIFICATION_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* Define a counter. */ 25 | int counter = 0 ; 26 | /* Define a boolean flag. */ 27 | boolean isRolled = true; 28 | /* A name for the LED on pin 13. */ 29 | int ledPin = 13; 30 | 31 | void setup() 32 | { 33 | /* Start communication. */ 34 | OneSheeld.begin(); 35 | /* Set the LED as output. */ 36 | pinMode(ledPin,OUTPUT); 37 | } 38 | 39 | void loop() 40 | { 41 | /* Always check if the smartphone has been rolled on its X-axis. */ 42 | if(GravitySensor.getX() > 9) 43 | { 44 | /* Check if is has been rolled. */ 45 | if(isRolled) 46 | { 47 | /* Increment the counter. */ 48 | counter++; 49 | /* Reset the flag. */ 50 | isRolled = false; 51 | } 52 | } 53 | else 54 | { 55 | /* Set the flag. */ 56 | isRolled = true; 57 | } 58 | 59 | /*Check if is has been rolled 3 times. */ 60 | if (counter == 3) 61 | { 62 | /* Send a notification. */ 63 | Notification.notifyPhone("SmartPhone has been rolled three times."); 64 | /* Turn on the LED. */ 65 | digitalWrite(ledPin,HIGH); 66 | /* Wait half a second. */ 67 | OneSheeld.delay(500); 68 | /* Reset the Counter. */ 69 | counter = 0; 70 | } 71 | else 72 | { 73 | /* Turn off the LED. */ 74 | digitalWrite(ledPin,LOW); 75 | } 76 | 77 | 78 | } 79 | -------------------------------------------------------------------------------- /examples/Advanced/LCD/LCD.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | LCD Shield Example 4 | 5 | This example shows an application on 1Sheeld's LCD shield. 6 | 7 | By using this example, you can print some text on the 8 | LCD shield available in our app. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_LCD_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* A name for a button on pin 12. */ 24 | int buttonPin = 12; 25 | 26 | void setup() 27 | { 28 | /* Start communication. */ 29 | OneSheeld.begin(); 30 | /* Set the button pin as input. */ 31 | pinMode(buttonPin,INPUT); 32 | } 33 | 34 | void loop() 35 | { 36 | /* Always check the button pin if pressed. */ 37 | if(digitalRead(buttonPin) == HIGH) 38 | { 39 | /* Begin the LCD cursor at the first row and first column. */ 40 | LCD.begin(); 41 | /* Blink the cursor and for 5 seconds. */ 42 | LCD.blink(); 43 | OneSheeld.delay(5000); 44 | /* Stop blinking. */ 45 | LCD.noBlink(); 46 | /* Write some characters. */ 47 | LCD.write('A'); 48 | LCD.write('B'); 49 | LCD.write('C'); 50 | /* Wait for 2 seconds. */ 51 | OneSheeld.delay(2000); 52 | /* Clear the LCD. */ 53 | LCD.clear(); 54 | /* Print "Hello, World!" */ 55 | LCD.print("Hello, World!"); 56 | /* Set the cursor to begin writing from the second row and first column. */ 57 | LCD.setCursor(1,0); 58 | /* Print "This is 1Sheeld" */ 59 | LCD.print("This is 1Sheeld"); 60 | /* Wait 10 seconds. */ 61 | OneSheeld.delay(10000); 62 | /*Clear LCD*/ 63 | LCD.clear(); 64 | /* Print "Closing!" */ 65 | LCD.print("Closing!"); 66 | /* Wait for 2 seconds. */ 67 | OneSheeld.delay(10000); 68 | } 69 | 70 | 71 | 72 | } 73 | -------------------------------------------------------------------------------- /examples/Advanced/Magnetometer/Magnetometer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Magnetometer Shield Example 4 | 5 | This example shows an application on 1Sheeld's magnetometer shield. 6 | 7 | By using this example, you can send a SMS when the magnetic 8 | field strength read by the smartphone's magnetometer exceeds 9 | a certain value. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_MAGNETOMETER_SENSOR_SHIELD 20 | #define INCLUDE_SMS_SHIELD 21 | 22 | /* Include 1Sheeld library*/ 23 | #include 24 | 25 | /* Define a boolean flag. */ 26 | boolean isPhoneNotified = false; 27 | /* A name for a LED on pin 13. */ 28 | int ledPin = 13; 29 | 30 | void setup() 31 | { 32 | /* Start communication. */ 33 | OneSheeld.begin(); 34 | /* Set the LED pin as output. */ 35 | pinMode(ledPin,HIGH); 36 | } 37 | 38 | void loop() 39 | { 40 | 41 | /* Check if the magnetic strength exceeded a certain value. */ 42 | if (MagnetometerSensor.getMagneticStrength() > 50) 43 | { 44 | /* This makes sure that the SMS will be sent only one time. */ 45 | if (!isPhoneNotified) 46 | { 47 | /* Send the SMS. */ 48 | SMS.send("1234567890","Danger: Magnetic field increased checkout what's the problem."); 49 | /* Turn on the LED. */ 50 | digitalWrite(ledPin,HIGH); 51 | /* Reset the flag. */ 52 | isPhoneNotified = true; 53 | } 54 | } 55 | else 56 | { 57 | /* Set the flag. */ 58 | isPhoneNotified = false ; 59 | /* Turn off the LED. */ 60 | digitalWrite(ledPin,LOW); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /examples/Advanced/Mic/Mic.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Mic Shield Example 4 | 5 | This example shows an application on 1Sheeld's mic shield. 6 | 7 | By using this example, you can tweet when the sound level in 8 | the room exceeds a certain threshold. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_MIC_SHIELD 19 | #define INCLUDE_TWITTER_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* Define a boolean flag. */ 25 | boolean isTweetSent = false; 26 | 27 | void setup() 28 | { 29 | /* Start communication. */ 30 | OneSheeld.begin(); 31 | } 32 | 33 | void loop() 34 | { 35 | /* Always get the noise level from the mic and check if it exceeds a certain value. */ 36 | if(Mic.getValue() > 100) 37 | { 38 | if(!isTweetSent) 39 | { 40 | /*Send the tweet*/ 41 | Twitter.tweet("We are making some noise! sent from @1Sheeld"); 42 | /* Set the flag. */ 43 | isTweetSent = true; 44 | } 45 | 46 | } 47 | 48 | /* Reset the flag. */ 49 | if(Mic.getValue() < 100) 50 | { 51 | isTweetSent = false; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /examples/Advanced/MusicPlayer/MusicPlayer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Music Player Shield Example 4 | 5 | This example shows an application on 1Sheeld's music player shield. 6 | 7 | By using this example, you can play and stop music from 8 | your smartphone at certain times. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_MUSIC_PLAYER_SHIELD 19 | #define INCLUDE_CLOCK_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* Define some variables for the timer. */ 25 | int seconds, minutes, hours; 26 | 27 | void setup() 28 | { 29 | /* Start communication. */ 30 | OneSheeld.begin(); 31 | /* Start the clock shield. */ 32 | Clock.queryDateAndTime(); 33 | } 34 | 35 | void loop() 36 | { 37 | /* Always get the time. */ 38 | seconds = Clock.getSeconds(); 39 | minutes = Clock.getMinutes(); 40 | hours = Clock.getHours(); 41 | 42 | /* Play music at 8 am. */ 43 | if (hours == 8 && minutes == 0 && seconds == 00) 44 | { 45 | /* Play the music. */ 46 | MusicPlayer.play(); 47 | /* Set the volume. */ 48 | MusicPlayer.setVolume(5); 49 | } 50 | /* Stop music at 9 am. */ 51 | else if(hours == 9 && minutes == 0 && seconds == 00) 52 | { 53 | /* Turn off the music. */ 54 | MusicPlayer.stop(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /examples/Advanced/Notification/Notification.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Notification Shield Example 4 | 5 | This example shows an application on 1Sheeld's notification shield. 6 | 7 | By using this example, you can send a notification to 8 | your smartphone if the temperature of the room exceeds 9 | a certain value. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_NOTIFICATION_SHIELD 20 | #define INCLUDE_TEMPERATURE_SENSOR_SHIELD 21 | 22 | /* Inlcude 1Sheeld library. */ 23 | #include 24 | 25 | /* Define a boolean flag. */ 26 | boolean isPhoneNotified = false; 27 | 28 | void setup() 29 | { 30 | /* Start communication. */ 31 | OneSheeld.begin(); 32 | } 33 | 34 | void loop() 35 | { 36 | /* Always get the temperature. */ 37 | if(TemperatureSensor.getValue() > 25) 38 | { 39 | /* Check if the phone has been notified once. */ 40 | if(!isPhoneNotified) 41 | { 42 | /* Notify the phone. */ 43 | Notification.notifyPhone("Temperature increased!"); 44 | /* Set the flag. */ 45 | isPhoneNotified = true; 46 | } 47 | 48 | } 49 | else 50 | { 51 | /* Reset the flag. */ 52 | isPhoneNotified = false; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /examples/Advanced/Orientation/Orientation.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Orientation Shield Example 4 | 5 | This example shows an application on 1Sheeld's orientation shield. 6 | 7 | By using this example, you can allign a portrait on 8 | the wall using your smartphone's orientation sensor 9 | along with the buzzer shield. 10 | 11 | PS: X-axis ranges from 0 to 360 degrees, Y-axis 12 | ranges from -180 to 180 degrees and Z-axis ranges 13 | from -90 to 90. 14 | 15 | OPTIONAL: 16 | To reduce the library compiled size and limit its memory usage, you 17 | can specify which shields you want to include in your sketch by 18 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 19 | 20 | */ 21 | 22 | #define CUSTOM_SETTINGS 23 | #define INCLUDE_ORIENTATION_SENSOR_SHIELD 24 | #define INCLUDE_BUZZER_SHIELD 25 | 26 | /* Include 1Sheeld library. */ 27 | #include 28 | 29 | void setup() 30 | { 31 | /* Start communication. */ 32 | OneSheeld.begin(); 33 | } 34 | 35 | void loop() 36 | { 37 | /* Always get the Y-axis and Z-axis values and check if they are near zero. */ 38 | if (OrientationSensor.getY() > -1 && OrientationSensor.getY() < 1 && OrientationSensor.getZ() > -1 && OrientationSensor.getZ() < 1) 39 | { 40 | /* Turn on the buzzer. */ 41 | Buzzer.buzzOn(); 42 | } 43 | /* If they are not aligned, turn off the buzzer. */ 44 | else 45 | { 46 | Buzzer.buzzOff(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/Advanced/Phone/Phone.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Phone Shield Example 4 | 5 | This example shows an application on 1Sheeld's phone shield. 6 | 7 | By using this example, you can open your home's door 8 | for a friend by calling a smartphone connected to 9 | 1Sheeld. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_PHONE_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* Phone number to check if it called. */ 25 | char callingNumber[]= "1234567890"; 26 | /* A name for the LED on pin 13. */ 27 | int ledPin = 13; 28 | /* A name for the relay on pin 12. */ 29 | int relayPin = 12; 30 | 31 | void setup() 32 | { 33 | /* Start communication. */ 34 | OneSheeld.begin(); 35 | /* Set the LED pin as output. */ 36 | pinMode(ledPin,OUTPUT); 37 | /* Set the relay pin as output. */ 38 | pinMode(relayPin,OUTPUT); 39 | } 40 | 41 | void loop() 42 | { 43 | /* Check if the phone is ringing. */ 44 | if(Phone.isRinging()) 45 | { 46 | /* Check if the phone number calling is the same as our variable. */ 47 | if(strcmp(Phone.getNumber(),callingNumber) == 0) 48 | { 49 | /* Turn on the LED. */ 50 | digitalWrite(ledPin,HIGH); 51 | /* Turn on the relay to open the door. */ 52 | digitalWrite(relayPin,HIGH); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /examples/Advanced/Pressure/Pressure.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Pressure Shield Example 4 | 5 | This example shows an application on 1Sheeld's pressure shield. 6 | 7 | By using this example, you can send a SMS when the value 8 | of the smartphone's pressure sensor exceeds a certain limit. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_PRESSURE_SENSOR_SHIELD 19 | #define INCLUDE_SMS_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* Define a boolean flag. */ 25 | boolean isMessageSent = false; 26 | 27 | void setup() 28 | { 29 | /* Start communication. */ 30 | OneSheeld.begin(); 31 | } 32 | 33 | void loop() 34 | { 35 | /* Always read the pressure value and check if it exceeds a certain value. */ 36 | if (PressureSensor.getValue() > 1008) 37 | { 38 | /* Check that we haven't sent the SMS already. */ 39 | if (!isMessageSent) 40 | { 41 | /* Send the SMS. */ 42 | SMS.send("1234567890","Pressure is getting high in here!"); 43 | /* Set the flag. */ 44 | isMessageSent = true; 45 | } 46 | } 47 | else 48 | { 49 | /* Reset the flag. */ 50 | isMessageSent = false; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /examples/Advanced/Proximity/Proximity.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Proximity Shield Example 4 | 5 | This example shows an application on 1Sheeld's proximity shield. 6 | 7 | By using this example, you can campture a picture and 8 | send a SMS when the value of the smartphone's proximity 9 | sensor exceeds a certain limit. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_PROXIMITY_SENSOR_SHIELD 20 | #define INCLUDE_CAMERA_SHIELD 21 | #define INCLUDE_SMS_SHIELD 22 | 23 | /* Include 1Sheeld library. */ 24 | #include 25 | 26 | void setup() 27 | { 28 | /* Start communication. */ 29 | OneSheeld.begin(); 30 | /* Call a specific function when the proximity value change. */ 31 | ProximitySensor.setOnValueChange(&OnValueChange); 32 | } 33 | 34 | void loop() 35 | { 36 | /* Do nothing. */ 37 | } 38 | 39 | void OnValueChange(byte value) 40 | { 41 | /* Always check if the proximity sensor value doesn't equal to zero cm. */ 42 | if (ProximitySensor.getValue() == 0) 43 | { 44 | /* Set the flash of the Camera. */ 45 | Camera.setFlash(ON); 46 | /* Take a photo. */ 47 | Camera.rearCapture(); 48 | /* Send the SMS. */ 49 | SMS.send("1234567890","Something or Someone passed near the place!"); 50 | } 51 | } -------------------------------------------------------------------------------- /examples/Advanced/SMS/SMS.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | SMS Shield Example 4 | 5 | This example shows an application on 1Sheeld's SMS shield. 6 | 7 | By using this example, you can send a SMS when the value 8 | of the smartphone's temperature sensor exceeds a certain 9 | limit. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_SMS_SHIELD 20 | #define INCLUDE_TEMPERATURE_SENSOR_SHIELD 21 | 22 | /* Include 1Sheeld library. */ 23 | #include 24 | 25 | /* Define a boolean flag. */ 26 | boolean isMessageSent = false; 27 | 28 | void setup() 29 | { 30 | /* Start communication. */ 31 | OneSheeld.begin(); 32 | } 33 | 34 | void loop() 35 | { 36 | /* Always check if the temperature value is larger than a certain value. */ 37 | if (TemperatureSensor.getValue() > 30) 38 | { 39 | if(!isMessageSent) 40 | { 41 | /* Send the SMS. */ 42 | SMS.send("1234567890","Room Temperature is higher than 30 degree!"); 43 | /* Set the flag. */ 44 | isMessageSent = true; 45 | } 46 | 47 | } 48 | else 49 | { 50 | /* Reset the flag. */ 51 | isMessageSent = false; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /examples/Advanced/SevenSegment/SevenSegment.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Seven Segment Shield Example 4 | 5 | This example shows an application on 1Sheeld's seven segment shield. 6 | 7 | By using this example, you can display the numbers from 8 | 0 till 9 on the app's seven segment every time you press 9 | the button on pin 12. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_SEVEN_SEGMENT_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* Define a variable to hold the seven segment digit. */ 25 | int number = 0; 26 | /* A name for the button on pin 12. */ 27 | int buttonPin = 12; 28 | 29 | void setup() 30 | { 31 | /* Start communication. */ 32 | OneSheeld.begin(); 33 | /* Set the button pin as input. */ 34 | pinMode(buttonPin,INPUT); 35 | } 36 | 37 | void loop() 38 | { 39 | if (digitalRead(buttonPin) == HIGH) 40 | { 41 | /* Display the number on the seven segment. */ 42 | SevenSegment.setNumber(number); 43 | /* Wait for a second. */ 44 | OneSheeld.delay(1000); 45 | /* Increment the number. */ 46 | number++; 47 | /* If the number reaches 9, return it back to zero. */ 48 | if(number > 9) 49 | { 50 | number = 0; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /examples/Advanced/Skype/Skype.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Skype Shield Example 4 | 5 | This example shows an application on 1Sheeld's Skype shield. 6 | 7 | By using this example, you can call one of your Skype's 8 | contacts when you press the button on pin 12. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_SKYPE_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* Define a boolean flag. */ 24 | boolean didWeCall = false; 25 | /* A name for the button on pin 12. */ 26 | int buttonPin = 12; 27 | 28 | void setup() 29 | { 30 | /* Start communication. */ 31 | OneSheeld.begin(); 32 | /* Set the button pin as input. */ 33 | pinMode(buttonPin,INPUT); 34 | } 35 | 36 | void loop() 37 | { 38 | if (digitalRead(buttonPin) == HIGH) 39 | { 40 | if(!didWeCall) 41 | { 42 | /* Call one of your Skype's contacts. */ 43 | Skype.call("echo123"); 44 | /* Set the flag. */ 45 | didWeCall = true; 46 | } 47 | } 48 | else 49 | { 50 | /* Reset the flag. */ 51 | didWeCall = false; 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /examples/Advanced/Twitter/Twitter.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Twitter Shield Example 4 | 5 | This example shows an application on 1Sheeld's Twitter shield. 6 | 7 | By using this example, you can flash a LED once a certain keyword 8 | is mentioned on Twitter. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_TWITTER_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* A name for led on pin 13. */ 24 | int ledPin = 13; 25 | /* A variable to track number of tracked tweets returned. */ 26 | int trackingCounter = 0; 27 | 28 | void setup() { 29 | /* Start communication. */ 30 | OneSheeld.begin(); 31 | /* Set the LED pin as output. */ 32 | pinMode(ledPin,OUTPUT); 33 | /* Subscribe to setOnSelected event for the Twitter shield. */ 34 | Twitter.setOnSelected(&shieldSelection); 35 | /* Subscribe to onNewTweet event. */ 36 | Twitter.setOnNewTweet(&myTweet); 37 | } 38 | 39 | void loop() 40 | { 41 | /* Leave the loop empty. */ 42 | } 43 | 44 | void shieldSelection() 45 | { 46 | /* Track keyword 1Sheeld on Twitter. */ 47 | Twitter.trackKeyword("1Sheeld"); 48 | } 49 | 50 | void myTweet(char * userName , char * userTweet) 51 | { 52 | /* Check if the tweet has 1Sheeld keyword. */ 53 | if(strstr(userTweet,"1Sheeld")!=0) 54 | { 55 | /* Turn on the LED. */ 56 | digitalWrite(ledPin,HIGH); 57 | /* Use OneSheeld delay for better performance. */ 58 | OneSheeld.delay(1000); 59 | /* Increment the counter. */ 60 | trackingCounter++; 61 | /* Turn off the LED. */ 62 | digitalWrite(ledPin,LOW); 63 | } 64 | /* Check if the counter reached three times. */ 65 | if(trackingCounter == 3) 66 | { 67 | /* Stop tracking the word 1Sheeld. */ 68 | Twitter.untrackKeyword("1Sheeld"); 69 | /* Reset the counter. */ 70 | trackingCounter = 0; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /examples/Advanced/Vibration/Vibration.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Vibration Shield Example 4 | 5 | This example shows an application on 1Sheeld's vibration shield. 6 | 7 | By using this example, you can make your phone vibrate in 2 different 8 | patterns. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_VIBRATION_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* This pattern waits for 1 second and vibrate for 2, 3 times. */ 24 | int patternOne[6] = {1000,2000,1000,2000,1000,2000}; 25 | int patternOneSize = 6; 26 | 27 | /* A sample heart beat pattern. */ 28 | int patternTwo[4] = {100, 250, 100, 400}; 29 | int patternTwoSize = 4; 30 | 31 | void setup() { 32 | /* Start communication. */ 33 | OneSheeld.begin(); 34 | } 35 | 36 | void loop() { 37 | /* Vibrate as the first pattern once. */ 38 | Vibration.start(patternOneSize,patternOne); 39 | 40 | /* Wait for 9 seconds. */ 41 | OneSheeld.delay(9000); 42 | 43 | /* Vibrate as the second pattern and keep repeating the vibration every 300 ms. */ 44 | Vibration.start(patternTwoSize,patternTwo,300); 45 | 46 | /* Wait for 10 seconds. */ 47 | OneSheeld.delay(10000); 48 | 49 | /* Stop the vibration. */ 50 | Vibration.stop(); 51 | } 52 | -------------------------------------------------------------------------------- /examples/Simple/Accelerometer/Accelerometer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Accelerometer Shield Example 4 | 5 | This example shows an application on 1Sheeld's accelerometer shield. 6 | 7 | By using this example, you can turn on the LED on pin 13 if the 8 | smartphone's accelerometer sensor reaches the maximum 9 | acceleration in any of the x, y and z axises. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_ACCELEROMETER_SENSOR_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* A name for the LED on pin 13. */ 25 | int ledPin = 13; 26 | 27 | void setup() 28 | { 29 | /* Start communication. */ 30 | OneSheeld.begin(); 31 | /* Set the LED pin as output. */ 32 | pinMode(ledPin,OUTPUT); 33 | } 34 | 35 | void loop() 36 | { 37 | /* Check X-axis acceleration. */ 38 | if(AccelerometerSensor.getX() > 8) 39 | { 40 | digitalWrite(ledPin,HIGH); 41 | } 42 | else 43 | { 44 | digitalWrite(ledPin,LOW); 45 | } 46 | 47 | /* Check Y-axis acceleration. */ 48 | if(AccelerometerSensor.getY() > 8) 49 | { 50 | digitalWrite(ledPin,HIGH); 51 | } 52 | else 53 | { 54 | digitalWrite(ledPin,LOW); 55 | } 56 | 57 | /* Check z-Axis acceleration. */ 58 | if(AccelerometerSensor.getZ() > 8) 59 | { 60 | digitalWrite(ledPin,HIGH); 61 | } 62 | else 63 | { 64 | digitalWrite(ledPin,LOW); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /examples/Simple/Buzzer/Buzzer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Buzzer Shield Example 4 | 5 | This example shows an application on 1Sheeld's buzzer shield. 6 | 7 | By using this example, you can buzz each time you press the 8 | hardware push button placed on pin 12. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_BUZZER_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* A name for the button on pin 12. */ 24 | int buttonPin = 12; 25 | /* A name for the LED on pin 13. */ 26 | int ledPin = 13; 27 | 28 | void setup() 29 | { 30 | /* Start communication. */ 31 | OneSheeld.begin(); 32 | /* Set the button pin as input. */ 33 | pinMode(buttonPin,INPUT); 34 | /* Set the LED pin as output. */ 35 | pinMode(ledPin,OUTPUT); 36 | } 37 | 38 | void loop() 39 | { 40 | /* Always check the button state. */ 41 | if(digitalRead(buttonPin) == HIGH) 42 | { 43 | /* Turn on the buzzer. */ 44 | Buzzer.buzzOn(); 45 | /* Turn on the LED. */ 46 | digitalWrite(ledPin,HIGH); 47 | } 48 | else 49 | { 50 | /* Turn off the buzzer. */ 51 | Buzzer.buzzOff(); 52 | /* Turn off the LED. */ 53 | digitalWrite(ledPin,LOW); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /examples/Simple/Camera/Camera.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Camera Shield Example 4 | 5 | This example shows an application on 1Sheeld's camera shield. 6 | 7 | By using this example, you can take a photo using your phone's 8 | camera each time you press the hardware push button placed on 9 | pin 12. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_CAMERA_SHIELD 20 | #define INCLUDE_TWITTER_SHIELD 21 | 22 | /* Include 1Sheeld library. */ 23 | #include 24 | 25 | /* A name for the button on pin 12. */ 26 | int buttonPin = 12; 27 | /* A name for the LED on pin 13. */ 28 | int ledPin = 13; 29 | 30 | void setup() 31 | { 32 | /* Start communication. */ 33 | OneSheeld.begin(); 34 | /* Set the button pin as input. */ 35 | pinMode(buttonPin,INPUT); 36 | /* Set the LED pin as output. */ 37 | pinMode(ledPin,OUTPUT); 38 | } 39 | 40 | void loop() 41 | { 42 | /* Always check the button state. */ 43 | if(digitalRead(buttonPin) == HIGH) 44 | { 45 | /* Turn on the LED. */ 46 | digitalWrite(ledPin,HIGH); 47 | /* Turn on the camera flash. */ 48 | Camera.setFlash(ON); 49 | /* Take the picture. */ 50 | Camera.rearCapture(); 51 | /* Wait for 10 seconds. */ 52 | OneSheeld.delay(10000); 53 | /* Post the picture on Twitter. */ 54 | Twitter.tweetLastPicture("Posted by @1Sheeld and @Arduino"); 55 | } 56 | else 57 | { 58 | /* Turn off the LED. */ 59 | digitalWrite(ledPin,LOW); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /examples/Simple/Chart/Chart.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Chart Shield Example 4 | 5 | This example shows an application on 1Sheeld's chart shield. 6 | 7 | By using this example, you can plot and display noise data using mic 8 | over a line chart and save it as a CSV. 9 | 10 | Note: Chart shield will automatically save a CSV file after reaching 11 | 10000 plots and will clear the screen for optimal app performance. 12 | 13 | OPTIONAL: 14 | To reduce the library compiled size and limit its memory usage, you 15 | can specify which shields you want to include in your sketch by 16 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 17 | 18 | */ 19 | 20 | #define CUSTOM_SETTINGS 21 | #define INCLUDE_MIC_SHIELD 22 | #define INCLUDE_CHART_SHIELD 23 | 24 | /* Include 1Sheeld library. */ 25 | #include 26 | 27 | void setup() 28 | { 29 | /* Start communication. */ 30 | OneSheeld.begin(); 31 | /* Save a screenshot for chart 0. */ 32 | Chart.saveScreenshot(CHART_0); 33 | /* Save a csv file for chart 0. */ 34 | Chart.saveCsv("MicValues",CHART_0); 35 | /* Clear Chart 0. */ 36 | Chart.clear(CHART_0); 37 | } 38 | 39 | void loop() { 40 | /* Add mic values to be ploted over chart. */ 41 | Chart.add("Mic/db",Mic.getValue()); 42 | /* Plot the values. */ 43 | Chart.plot(); 44 | /* Delay for 1 second. */ 45 | OneSheeld.delay(1000); 46 | } 47 | -------------------------------------------------------------------------------- /examples/Simple/Color/Color.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Color Detector Shield Example 4 | 5 | This example shows an application on 1Sheeld's color detector shield. 6 | 7 | By using this example, you can control the color of a RGB LED according 8 | to the color read by our color detector shield. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_COLOR_DETECTOR_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* Reserve PWM pins for the RGB LED. */ 24 | int redPin = 9; 25 | int greenPin =10; 26 | int bluePin = 11; 27 | 28 | void setup() { 29 | /* Start communication. */ 30 | OneSheeld.begin(); 31 | /* Set the RGB LED pins as output. */ 32 | pinMode(redPin, OUTPUT); 33 | pinMode(greenPin, OUTPUT); 34 | pinMode(bluePin, OUTPUT); 35 | /* Set the color detection palette to get only 8 different colors instead of the default 16 million. */ 36 | ColorDetector.setPalette(_3_BIT_RGB_PALETTE); 37 | } 38 | 39 | void loop() { 40 | /* Check if there's a new color received. */ 41 | if(ColorDetector.isNewColorReceived()) 42 | { 43 | /* Read the last received color and save it locally. */ 44 | Color readColor = ColorDetector.getLastColor(); 45 | 46 | /* Get red, blue and green components values. */ 47 | byte redValue = readColor.getRed(); 48 | byte greenValue = readColor.getGreen(); 49 | byte blueValue = readColor.getBlue(); 50 | 51 | /* Output the values on the RGB LED pins. */ 52 | digitalWrite(redPin,redValue); 53 | digitalWrite(greenPin,greenValue); 54 | digitalWrite(bluePin,blueValue); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /examples/Simple/DataLogger/DataLogger.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Data-Logger Shield Example 4 | 5 | This example shows an application on 1Sheeld's data logger shield. 6 | 7 | By using this example, you can check the variation of noise level using 8 | Mic shield by logging each 20 successive readings in separate CSV files. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_DATA_LOGGER_SHIELD 19 | #define INCLUDE_MIC_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* Reserve a counter. */ 25 | int counter = 0; 26 | /* Button on pin 12. */ 27 | int buttonPin = 12; 28 | /* Boolean to start logging. */ 29 | bool startFlag = false; 30 | 31 | void setup() 32 | { 33 | /* Start communication. */ 34 | OneSheeld.begin(); 35 | /* Save any previous logged values. */ 36 | Logger.stop(); 37 | /* Set buttonPin as input. */ 38 | pinMode(buttonPin,INPUT); 39 | } 40 | 41 | void loop() 42 | { 43 | /* Check if button pressed. */ 44 | if(digitalRead(buttonPin) == HIGH) 45 | { 46 | /* First insure to save previous logged values. */ 47 | Logger.stop(); 48 | /* Set a delay. */ 49 | OneSheeld.delay(500); 50 | /* Start logging in a new CSV file. */ 51 | Logger.start("Mic values"); 52 | /* Set startFlag. */ 53 | startFlag = true; 54 | } 55 | 56 | /* Check logging started. */ 57 | if(startFlag) 58 | { 59 | /* Add noise level values as a column in the CSV file. */ 60 | Logger.add("Decibles",Mic.getValue()); 61 | /* Log the row in the file. */ 62 | Logger.log(); 63 | /* Delay for 1 second. */ 64 | OneSheeld.delay(1000); 65 | /* Increment counter. */ 66 | counter++; 67 | /* Stop logging after 20 readings and save the CSV file. */ 68 | if(counter==20) 69 | { 70 | /* Save the logging CSV file. */ 71 | Logger.stop(); 72 | /* Reset counter. */ 73 | counter=0; 74 | /* Start Logging again. */ 75 | Logger.start("Mic values"); 76 | } 77 | } 78 | 79 | } -------------------------------------------------------------------------------- /examples/Simple/FaceDetector/FaceDetector.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Face Detector Shield Example 4 | 5 | This example shows an application on 1Sheeld's face detector shield. 6 | 7 | By using this example, you can unlock a door by winking three times to 8 | the front camera. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_FACE_DETECTOR_SHIELD 19 | #define INCLUDE_TERMINAL_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* A name for the LED on pin 13. */ 25 | int ledPin = 13; 26 | 27 | /* A name for the relay on pin 12. */ 28 | int relayPin = 12; 29 | 30 | /* A name for the winks counter. */ 31 | int counter = 0; 32 | 33 | void setup() 34 | { 35 | /* Start communication. */ 36 | OneSheeld.begin(); 37 | /* Set the LED pin as output. */ 38 | pinMode(ledPin,OUTPUT); 39 | /* Set the relay pin as output. */ 40 | pinMode(relayPin,OUTPUT); 41 | } 42 | 43 | void loop() 44 | { 45 | /* Get the first face and check if it winks. */ 46 | if(FaceDetector.getVisibleFace(0).getLeftEyeOpenProbability()==0) 47 | { 48 | /* Turn on the LED when winking. */ 49 | digitalWrite(ledPin,HIGH); 50 | /* Count the winks. */ 51 | counter++; 52 | /* A slight delay. */ 53 | OneSheeld.delay(1000); 54 | }else 55 | { 56 | /* Turn off the LED. */ 57 | digitalWrite(ledPin,LOW); 58 | } 59 | 60 | /* Check the number of winks. */ 61 | if(counter == 3) 62 | { 63 | /* Send success. */ 64 | Terminal.println("Success"); 65 | /* Open the lock. */ 66 | digitalWrite(relayPin,HIGH); 67 | /* Reset counter. */ 68 | counter=0; 69 | } 70 | } -------------------------------------------------------------------------------- /examples/Simple/Facebook/Facebook.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Facebook Shield Example 4 | 5 | This example shows an application on 1Sheeld's Facebook shield. 6 | 7 | By using this example, you can update your Facebook status each 8 | time you press the hardware push button placed on pin 12. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_FACEBOOK_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* A name for the button on pin 12. */ 24 | int buttonPin = 12; 25 | /* A name for the LED on pin 13. */ 26 | int ledPin = 13; 27 | 28 | void setup() 29 | { 30 | /* Start communication. */ 31 | OneSheeld.begin(); 32 | /* Set the button pin as input. */ 33 | pinMode(buttonPin,INPUT); 34 | /* Set the LED pin as output. */ 35 | pinMode(ledPin,OUTPUT); 36 | } 37 | 38 | void loop() 39 | { 40 | /* Always check the button state. */ 41 | if(digitalRead(buttonPin) == HIGH) 42 | { 43 | /* Turn on the LED. */ 44 | digitalWrite(ledPin,HIGH); 45 | /* Update your status on Facebook. */ 46 | Facebook.post("I'm home folks!"); 47 | /* Wait for 300 ms. */ 48 | OneSheeld.delay(300); 49 | } 50 | else 51 | { 52 | /* Turn off the LED. */ 53 | digitalWrite(ledPin,LOW); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /examples/Simple/FingerprintScanner/FingerprintScanner.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | FingerprintScanner Shield Example 4 | 5 | This example shows an application on 1Sheeld's fingerprint scanner shield. 6 | 7 | By using this example, you can turn on an LED using your fingerprint. 8 | 9 | OPTIONAL: 10 | To reduce the library compiled size and limit its memory usage, you 11 | can specify which shields you want to include in your sketch by 12 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 13 | 14 | */ 15 | 16 | #define CUSTOM_SETTINGS 17 | #define INCLUDE_FINGERPRINT_SCANNER_SHIELD 18 | 19 | /* Include 1Sheeld library. */ 20 | #include 21 | 22 | /* A name for the LED on pin 13. */ 23 | int ledPin = 13; 24 | 25 | void setup() 26 | { 27 | /* Start communication. */ 28 | OneSheeld.begin(); 29 | /* Set the LED pin as output. */ 30 | pinMode(ledPin,OUTPUT); 31 | } 32 | 33 | void loop() 34 | { 35 | if(FingerprintScanner.isNewFingerScanned() && FingerprintScanner.isVerified()) 36 | { 37 | digitalWrite(ledPin,HIGH); 38 | delay(1000); 39 | digitalWrite(ledPin,LOW); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/Simple/Foursquare/Foursquare.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Foursquare Shield Example 4 | 5 | This example shows an application on 1Sheeld's Foursquare shield. 6 | 7 | By using this example, you can check-in at a place on Foursquare 8 | each time you press the hardware push button placed on pin 12. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_FOURSQUARE_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* A name for the button on pin 12. */ 24 | int buttonPin = 12; 25 | /* A name for the LED on pin 13. */ 26 | int ledPin = 13; 27 | 28 | void setup() 29 | { 30 | /* Start communication. */ 31 | OneSheeld.begin(); 32 | /* Set the button pin as input. */ 33 | pinMode(buttonPin,INPUT); 34 | /* Set the LED pin as output. */ 35 | pinMode(ledPin,OUTPUT); 36 | } 37 | 38 | void loop() 39 | { 40 | /* Always check the button state. */ 41 | if(digitalRead(buttonPin) == HIGH) 42 | { 43 | /* Turn on the LED. */ 44 | digitalWrite(ledPin,HIGH); 45 | /* Check-in at Integreight. */ 46 | Foursquare.checkIn("511759f2e4b0b0ae6ed91067","Back to work!"); 47 | /* Wait for 300 ms. */ 48 | OneSheeld.delay(300); 49 | } 50 | else 51 | { 52 | /* Turn off the LED. */ 53 | digitalWrite(ledPin,LOW); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /examples/Simple/GamePad/GamePad.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Gamepad Shield Example 4 | 5 | This example shows an application on 1Sheeld's gamepad shield. 6 | 7 | By using this example, you can light up some LEDs placed on 8 | different Arduino pins using the gamepad in our app. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_GAMEPAD_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | void setup() 24 | { 25 | /* Start communication. */ 26 | OneSheeld.begin(); 27 | /* Set some pins as output. */ 28 | pinMode(13,OUTPUT); 29 | pinMode(12,OUTPUT); 30 | pinMode(11,OUTPUT); 31 | pinMode(10,OUTPUT); 32 | 33 | } 34 | 35 | void loop() 36 | { 37 | /* Always check the status of gamepad buttons. */ 38 | if (GamePad.isUpPressed()) 39 | { 40 | /* Turn on the LED on pin 13 when up is pressed. */ 41 | digitalWrite(13,HIGH); 42 | /* Turn off the other LEDs. */ 43 | digitalWrite(12,LOW); 44 | digitalWrite(11,LOW); 45 | digitalWrite(10,LOW); 46 | } 47 | if(GamePad.isDownPressed()) 48 | { 49 | /* Turn on the LED on pin 12 when down is pressed. */ 50 | digitalWrite(12,HIGH); 51 | /* Turn off the other LEDs. */ 52 | digitalWrite(13,LOW); 53 | digitalWrite(11,LOW); 54 | digitalWrite(10,LOW); 55 | } 56 | if (GamePad.isUpPressed()&&GamePad.isOrangePressed()) 57 | { 58 | /* Turn on the LED on pin 11 when up and orange are pressed. */ 59 | digitalWrite(11,HIGH); 60 | /* Turn off the other LEDs. */ 61 | digitalWrite(13,LOW); 62 | digitalWrite(12,LOW); 63 | digitalWrite(10,LOW); 64 | } 65 | if (GamePad.isDownPressed()&&GamePad.isRedPressed()) 66 | { 67 | /* Turn on the LED on pin 10 when down and red are pressed. */ 68 | digitalWrite(10,HIGH); 69 | /* Turn off the other LEDs. */ 70 | digitalWrite(13,LOW); 71 | digitalWrite(12,LOW); 72 | digitalWrite(11,LOW); 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /examples/Simple/Gravity/Gravity.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Gravity Shield Example 4 | 5 | This example shows an application on 1Sheeld's gravity shield. 6 | 7 | By using this example, you can turn on some LEDs if the 8 | smartphone's gravity sensor reaches the maximum gravity 9 | acceleration in any of the x, y and z axises. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_GRAVITY_SENSOR_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* A name for the LED on pin 13. */ 25 | int ledPin1 = 13; 26 | /* A name for the LED on pin 12. */ 27 | int ledPin2 = 12; 28 | /* A name for the LED on pin 11. */ 29 | int ledPin3 = 11; 30 | 31 | void setup() 32 | { 33 | /* Start communication. */ 34 | OneSheeld.begin(); 35 | /* Set LEDs 1, 2 and 3 as output. */ 36 | pinMode(ledPin1,OUTPUT); 37 | pinMode(ledPin2,OUTPUT); 38 | pinMode(ledPin3,OUTPUT); 39 | } 40 | 41 | void loop() 42 | { 43 | /* Check X-axis gravitational value. */ 44 | if(GravitySensor.getX() >= 9) 45 | { 46 | /* Turn on the LED 1. */ 47 | digitalWrite(ledPin1,HIGH); 48 | /* Turn off the other LEDs. */ 49 | digitalWrite(ledPin2,LOW); 50 | digitalWrite(ledPin3,LOW); 51 | } 52 | 53 | /* Check Y-axis gravitational value. */ 54 | if(GravitySensor.getY() >= 9) 55 | { 56 | /* Turn on the LED 2. */ 57 | digitalWrite(ledPin2,HIGH); 58 | /* Turn off the other LEDs. */ 59 | digitalWrite(ledPin1,LOW); 60 | digitalWrite(ledPin3,LOW); 61 | } 62 | 63 | /* Check Z-axis gravitational value. */ 64 | if(GravitySensor.getZ() >= 9) 65 | { 66 | /* Turn on the LED 3. */ 67 | digitalWrite(ledPin3,HIGH); 68 | /* Turn off the other LEDs. */ 69 | digitalWrite(ledPin1,LOW); 70 | digitalWrite(ledPin2,LOW); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /examples/Simple/Gyroscope/Gyroscope.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Gyroscope Shield Example 4 | 5 | This example shows an application on 1Sheeld's gyroscope shield. 6 | 7 | By using this example, you can turn on some LEDs if the 8 | smartphone's gyroscope sensor moves in any of the x, y 9 | and z axises. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_GYROSCOPE_SENSOR_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* A name for the LED on pin 13. */ 25 | int ledPin1 = 13; 26 | /* A name for the LED on pin 12. */ 27 | int ledPin2 = 12; 28 | /* A name for the LED on pin 11. */ 29 | int ledPin3 = 11; 30 | 31 | void setup() 32 | { 33 | /* Start communication. */ 34 | OneSheeld.begin(); 35 | /* Set LEDs 1, 2 and 3 as output. */ 36 | pinMode(ledPin1,OUTPUT); 37 | pinMode(ledPin2,OUTPUT); 38 | pinMode(ledPin3,OUTPUT); 39 | } 40 | 41 | void loop() 42 | { 43 | /* Check X-axis motion value. */ 44 | if(GyroscopeSensor.getX() > 1) 45 | { 46 | /* Turn on the LED 1. */ 47 | digitalWrite(ledPin1,HIGH); 48 | /* Turn off the other LEDs. */ 49 | digitalWrite(ledPin2,LOW); 50 | digitalWrite(ledPin3,LOW); ; 51 | } 52 | 53 | /* Check Y-axis motion value. */ 54 | if(GyroscopeSensor.getY() > 1) 55 | { 56 | /* Turn on the LED 2. */ 57 | digitalWrite(ledPin2,HIGH); 58 | /* Turn off the other LEDs. */ 59 | digitalWrite(ledPin1,LOW); 60 | digitalWrite(ledPin3,LOW); 61 | } 62 | 63 | /* Check Z-axis motion value. */ 64 | if(GyroscopeSensor.getZ() > 1) 65 | { 66 | /* Turn on the LED 3. */ 67 | digitalWrite(ledPin3,HIGH); 68 | /* Turn off the other LEDs. */ 69 | digitalWrite(ledPin1,LOW); 70 | digitalWrite(ledPin2,LOW); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /examples/Simple/Keyboard/Keyboard.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Keyboard Shield Example 4 | 5 | This example shows an application on 1Sheeld's keyboard shield. 6 | 7 | By using this example, you can turn on LEDs using certain characters. 8 | 9 | OPTIONAL: 10 | To reduce the library compiled size and limit its memory usage, you 11 | can specify which shields you want to include in your sketch by 12 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 13 | 14 | */ 15 | 16 | #define CUSTOM_SETTINGS 17 | #define INCLUDE_KEYBOARD_SHIELD 18 | 19 | /* Include 1Sheeld library. */ 20 | #include 21 | 22 | /* LED on pin 13. */ 23 | int ledPin = 13; 24 | 25 | void setup() 26 | { 27 | /* Start communication. */ 28 | OneSheeld.begin(); 29 | /* Set the LED as output. */ 30 | pinMode(ledPin,OUTPUT); 31 | /* Keyboard callBack function. */ 32 | AsciiKeyboard.setOnButtonChange(&keyboardFunction); 33 | } 34 | 35 | void loop() 36 | {} 37 | 38 | /* Function to be invoked once a new character is pressed. */ 39 | void keyboardFunction(char data) 40 | { 41 | /* Check on the incoming character. */ 42 | if(data == 'A') 43 | { 44 | /* Turn on the LED. */ 45 | digitalWrite(ledPin,HIGH); 46 | } 47 | else 48 | { 49 | /* Turn off the LED.*/ 50 | digitalWrite(ledPin,LOW); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /examples/Simple/Led/Led.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | LED Shield Example 4 | 5 | This example shows an application on 1Sheeld's LED shield. 6 | 7 | By using this example, you can turn on control the app's 8 | LED shield. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_LED_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | void setup() 24 | { 25 | /* Start communication. */ 26 | OneSheeld.begin(); 27 | } 28 | 29 | void loop() 30 | { 31 | /* Turn on the LED. */ 32 | LED.setHigh(); 33 | OneSheeld.delay(1000); 34 | /* Turn off the LED. */ 35 | LED.setLow(); 36 | OneSheeld.delay(1000); 37 | } 38 | -------------------------------------------------------------------------------- /examples/Simple/Light/Light.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Light Shield Example 4 | 5 | This example shows an application on 1Sheeld's light shield. 6 | 7 | By using this example, you can turn on the LED on pin 13 if the 8 | smartphone's light sensor reports a certain value. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_LIGHT_SENSOR_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* A name for the LED on pin 13. */ 24 | int ledPin = 13; 25 | 26 | void setup() 27 | { 28 | /* Start communication. */ 29 | OneSheeld.begin(); 30 | /* Set the LED pin as output. */ 31 | pinMode(ledPin,OUTPUT); 32 | } 33 | 34 | void loop() 35 | { 36 | /* Always check the light intensity. */ 37 | if(LightSensor.getValue() < 100 && LightSensor.getValue() > 0) 38 | { 39 | /* Turn on the LED. */ 40 | digitalWrite(ledPin,HIGH); 41 | } 42 | else 43 | { 44 | /* Turn off the LED. */ 45 | digitalWrite(ledPin,LOW); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /examples/Simple/Magnetometer/Magnetometer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Magnetometer Shield Example 4 | 5 | This example shows an application on 1Sheeld's magnetometer shield. 6 | 7 | By using this example, you can display the magnetic field 8 | strength read by the smartphone's on a hardware LCD. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_MAGNETOMETER_SENSOR_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | /* Include LiquidCrystal library. */ 23 | #include 24 | 25 | /* Initialize the LCD interfacing pins. */ 26 | LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 27 | 28 | /* A name for the LED on pin 13. */ 29 | int ledPin = 13 ; 30 | /* LCD contrast level on pin 9. */ 31 | int lcdContrast = 9; 32 | 33 | void setup() 34 | { 35 | /* Start communication. */ 36 | OneSheeld.begin(); 37 | /* Set up the LCD's columns and rows. */ 38 | lcd.begin(16, 2); 39 | /* Set the LED pin as output. */ 40 | pinMode(ledPin,OUTPUT); 41 | /*Set lcd contrast pin as output. */ 42 | pinMode(lcdContrast,OUTPUT); 43 | /* Use a range from 0 till 255 to control the contrast of the LCD. */ 44 | analogWrite(lcdContrast,0); 45 | /* Print a title and a unit. */ 46 | lcd.print("MagneticStrength"); 47 | /* Move the cursor. */ 48 | lcd.setCursor(7,1); 49 | lcd.print("Tesla"); 50 | } 51 | 52 | void loop() 53 | { 54 | /* Move the cursor. */ 55 | lcd.setCursor(0,1); 56 | /* Display the magnetic strength. */ 57 | lcd.print(MagnetometerSensor.getMagneticStrength()); 58 | /* Wait for 1 second. */ 59 | OneSheeld.delay(1000); 60 | } -------------------------------------------------------------------------------- /examples/Simple/Mic/Mic.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Mic Shield Example 4 | 5 | This example shows an application on 1Sheeld's mic shield. 6 | 7 | By using this example, you can turn on the LED on pin 13 if the 8 | smartphone's mic reports a certain noise level. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_MIC_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* A name for the LED on pin 13. */ 24 | int ledPin = 13; 25 | 26 | void setup() 27 | { 28 | /* Start communication. */ 29 | OneSheeld.begin(); 30 | /* Set the LED pin as output. */ 31 | pinMode(ledPin,OUTPUT); 32 | } 33 | 34 | void loop () 35 | { 36 | /* Always check the noise level. */ 37 | if(Mic.getValue() > 80) 38 | { 39 | /* Turn on the LED. */ 40 | digitalWrite(ledPin,HIGH); 41 | } 42 | else 43 | { 44 | /* Turn off the LED. */ 45 | digitalWrite(ledPin,LOW); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /examples/Simple/MusicPlayer/MusicPlayer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Music Player Shield Example 4 | 5 | This example shows an application on 1Sheeld's music player shield. 6 | 7 | By using this example, you can play and pause music from 8 | your smartphone using 2 hardware push buttons. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_MUSIC_PLAYER_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* A name for the button on pin 12. */ 24 | int buttonPin1 = 12; 25 | /* A name for the button on pin 11. */ 26 | int buttonPin2 = 11; 27 | /* A name for the LED on pin 13. */ 28 | int ledPin = 13; 29 | 30 | void setup() 31 | { 32 | /* Start communication. */ 33 | OneSheeld.begin(); 34 | /* Set the LED pin as output. */ 35 | pinMode(ledPin,OUTPUT); 36 | /* Set the two buttons pins as input. */ 37 | pinMode(buttonPin1,INPUT); 38 | pinMode(buttonPin2,INPUT); 39 | 40 | } 41 | 42 | void loop() 43 | { 44 | /* Always check button 1 state. */ 45 | if(digitalRead(buttonPin1) == HIGH) 46 | { 47 | /* Turn on the LED. */ 48 | digitalWrite(ledPin,HIGH); 49 | /* Set the volume. */ 50 | MusicPlayer.setVolume(5); 51 | /* Turn on the music. */ 52 | MusicPlayer.play(); 53 | /* Wait for 300 ms. */ 54 | OneSheeld.delay(300); 55 | } 56 | /* Always check button 2 state. */ 57 | if(digitalRead(buttonPin2) == HIGH) 58 | { 59 | /* Turn off the LED. */ 60 | digitalWrite(ledPin,LOW); 61 | /* Turn off the music. */ 62 | MusicPlayer.pause(); 63 | /* Wait for 300 ms. */ 64 | OneSheeld.delay(300); 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /examples/Simple/NFC/NFC.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | NFC Shield Example 4 | 5 | This example shows an application on 1Sheeld's NFC shield. 6 | 7 | By using this example, you can check records number, used size and 8 | maximum size of NFC tags. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_NFC_SHIELD 19 | #define INCLUDE_TERMINAL_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | 25 | void setup() 26 | { 27 | /* Start Communication. */ 28 | OneSheeld.begin(); 29 | } 30 | 31 | void loop() 32 | { 33 | /* Check if there's a new tag scanned. */ 34 | if(NFC.isNewTagScanned()) 35 | { 36 | /* Get that last scanned tag. */ 37 | NFCTag & myTag = NFC.getLastTag(); 38 | /* Print all the data about the scanned tag. */ 39 | Terminal.print("Number of Records in Tag = "); 40 | /* Print number of records. */ 41 | Terminal.println(myTag.getNumberOfRecords()); 42 | /* Print tag used size. */ 43 | Terminal.print("Used Tag Size = "); 44 | Terminal.println(myTag.getSize()); 45 | /* Print tag maximum size. */ 46 | Terminal.print("Maximum Tag Size = "); 47 | Terminal.println(myTag.getMaxSize()); 48 | Terminal.print("Tag id length = "); 49 | Terminal.println(myTag.getIdLength()); 50 | switch(myTag.getRecord(0).getTypeCategory()) 51 | { 52 | case TNF_UNKNOWN : Terminal.println("TNF_UNKNOWN");break; 53 | case TNF_EMPTY : Terminal.println("TNF_EMPTY");break; 54 | case TNF_EXTERNAL_TYPE : Terminal.println("TNF_EXTERNAL_TYPE");break; 55 | case TNF_MIME_MEDIA : Terminal.println("TNF_MIME_MEDIA");break; 56 | case TNF_UNCHANGED : Terminal.println("TNF_UNCHANGED");break; 57 | case TNF_ABSOLUTE_URI : Terminal.println("TNF_ABSOLUTE_URI");break; 58 | case RTD_TEXT : Terminal.println("RTD_TEXT");break; 59 | case RTD_URI : Terminal.println("RTD_URI");break; 60 | case RTD_UNSUPPORTED : Terminal.println("RTD_UNSUPPORTED");break; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /examples/Simple/Notification/Notification.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Notification Shield Example 4 | 5 | This example shows an application on 1Sheeld's notification shield. 6 | 7 | By using this example, you can send notifications to your 8 | smartphone each time you press the hardware push button 9 | placed on pin 12. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_NOTIFICATION_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* A name for the button on pin 12. */ 25 | int buttonPin = 12; 26 | /* A name for the LED on pin 13. */ 27 | int ledPin = 13; 28 | 29 | void setup() 30 | { 31 | /* Start communication. */ 32 | OneSheeld.begin(); 33 | /* Set the button pin as input. */ 34 | pinMode(buttonPin,INPUT); 35 | /* Set the LED pin as output. */ 36 | pinMode(ledPin,OUTPUT); 37 | } 38 | 39 | void loop() 40 | { 41 | /* Always check the button state. */ 42 | if(digitalRead(buttonPin) == HIGH) 43 | { 44 | /* Turn on the LED. */ 45 | digitalWrite(ledPin,HIGH); 46 | /* Send a notification to your phone. */ 47 | Notification.notifyPhone("Someone pressed the button!"); 48 | /* Wait for 300 ms. */ 49 | OneSheeld.delay(300); 50 | } 51 | else 52 | { 53 | /* Turn off the LED. */ 54 | digitalWrite(ledPin,LOW); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /examples/Simple/Orientation/Orientation.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Orientation Shield Example 4 | 5 | This example shows an application on 1Sheeld's orientation shield. 6 | 7 | By using this example, you can turn on some LEDs if the 8 | smartphone's orientation sensor moves in any of the x, y 9 | and z axises. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_ORIENTATION_SENSOR_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* A name for the LED on pin 13. */ 25 | int ledPin1 = 13; 26 | /* A name for the LED on pin 12. */ 27 | int ledPin2 = 12; 28 | /* A name for the LED on pin 11. */ 29 | int ledPin3 = 11; 30 | 31 | void setup() 32 | { 33 | /* Start communication. */ 34 | OneSheeld.begin(); 35 | /* Set LEDs 1, 2 and 3 as output. */ 36 | pinMode(ledPin1,OUTPUT); 37 | pinMode(ledPin2,OUTPUT); 38 | pinMode(ledPin3,OUTPUT); 39 | } 40 | 41 | void loop() 42 | { 43 | /* Check X-axis orientation. */ 44 | if(OrientationSensor.getX() > 350) 45 | { 46 | /* Turn on the LED 1. */ 47 | digitalWrite(ledPin1,HIGH); 48 | } 49 | else 50 | { 51 | /* Turn on the LED 1. */ 52 | digitalWrite(ledPin1,LOW); 53 | } 54 | 55 | /* Check Y-axis orientation. */ 56 | if(OrientationSensor.getY() > 170) 57 | { 58 | /* Turn on the LED 2. */ 59 | digitalWrite(ledPin2,HIGH); 60 | } 61 | else 62 | { 63 | /* Turn off the LED 2. */ 64 | digitalWrite(ledPin2,LOW); 65 | } 66 | 67 | /* Check Z-axis orientation. */ 68 | if(OrientationSensor.getZ() > 80) 69 | { 70 | /* Turn on the LED 3. */ 71 | digitalWrite(ledPin3,HIGH); 72 | } 73 | else 74 | { 75 | /* Turn off the LED 3. */ 76 | digitalWrite(ledPin3,LOW); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /examples/Simple/Phone/Phone.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Phone Shield Example 4 | 5 | This example shows an application on 1Sheeld's phone shield. 6 | 7 | By using this example, you can call someone from your 8 | smartphone each time you press the hardware push button 9 | placed on pin 12. 10 | 11 | OPTIONAL: 12 | To reduce the library compiled size and limit its memory usage, you 13 | can specify which shields you want to include in your sketch by 14 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 15 | 16 | */ 17 | 18 | #define CUSTOM_SETTINGS 19 | #define INCLUDE_PHONE_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* A name for the button on pin 12. */ 25 | int buttonPin = 12; 26 | /* A name for the LED on pin 13. */ 27 | int ledPin = 13; 28 | 29 | void setup() 30 | { 31 | /* Start communication. */ 32 | OneSheeld.begin(); 33 | /* Set the button pin as input. */ 34 | pinMode(buttonPin,INPUT); 35 | /* Set the LED pin as output. */ 36 | pinMode(ledPin,OUTPUT); 37 | } 38 | 39 | void loop() 40 | { 41 | /* Always check the button state. */ 42 | if(digitalRead(buttonPin) == HIGH) 43 | { 44 | /* Turn on the LED. */ 45 | digitalWrite(ledPin,HIGH); 46 | /* Call a friend. */ 47 | Phone.call("1234567890"); 48 | /* Wait for 300 ms. */ 49 | OneSheeld.delay(300); 50 | } 51 | 52 | /* Turn off the LED. */ 53 | digitalWrite(ledPin,LOW); 54 | } 55 | -------------------------------------------------------------------------------- /examples/Simple/Proximity/Proximity.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Proximity Shield Example 4 | 5 | This example shows an application on 1Sheeld's proximity shield. 6 | 7 | By using this example, you can turn on the LED on pin 13 if the 8 | smartphone's proximity sensor reports a certain value. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_PROXIMITY_SENSOR_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* A name for the LED on pin 13. */ 24 | int ledPin = 13; 25 | 26 | void setup() 27 | { 28 | /* Start communication. */ 29 | OneSheeld.begin(); 30 | /* Set the LED pin as output. */ 31 | pinMode(ledPin,OUTPUT); 32 | } 33 | 34 | void loop() 35 | { 36 | /* Always check the value of proximity sensor. */ 37 | if(ProximitySensor.getValue() > 0) 38 | { 39 | /* Turn on the LED. */ 40 | digitalWrite(ledPin,HIGH); 41 | } 42 | else 43 | { 44 | /* Turn off the LED. */ 45 | digitalWrite(ledPin,LOW); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /examples/Simple/PushButton/PushButton.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Push Button Shield Example 4 | 5 | This example shows an application on 1Sheeld's push button shield. 6 | 7 | By using this example, you can turn on the LED on pin 13 8 | when you press the app's push button. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_PUSH_BUTTON_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* A name for the LED on pin 13. */ 24 | int ledPin = 13; 25 | 26 | void setup() 27 | { 28 | /* Start communication. */ 29 | OneSheeld.begin(); 30 | /* Set the LED pin as output. */ 31 | pinMode(ledPin,OUTPUT); 32 | } 33 | 34 | void loop() 35 | { 36 | /* Always check if the push button is pressed. */ 37 | if(PushButton.isPressed()) 38 | { 39 | /* Turn on the LED. */ 40 | digitalWrite(ledPin,HIGH); 41 | } 42 | else 43 | { 44 | /* Turn on the LED. */ 45 | digitalWrite(ledPin,LOW); 46 | } 47 | 48 | } 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /examples/Simple/Slider/Slider.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Slider Shield Example 4 | 5 | This example shows an application on 1Sheeld's slider shield. 6 | 7 | By using this example, you can control the frequency 8 | of a piezo speaker using the app's slider. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_SLIDER_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* Define a variable to hold the value of the slider. */ 24 | int value; 25 | /* A name for the speaker on pin 11. */ 26 | int speakerPin = 11; 27 | 28 | void setup() 29 | { 30 | /* Start communication. */ 31 | OneSheeld.begin(); 32 | /* Set the speaker pin as output. */ 33 | pinMode(speakerPin,OUTPUT); 34 | } 35 | 36 | void loop() 37 | { 38 | /* Always get the value of the slider and output it as PWM to pin 11. */ 39 | value = Slider.getValue(); 40 | analogWrite(speakerPin,value); 41 | } 42 | -------------------------------------------------------------------------------- /examples/Simple/Temperature/Temperature.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Temperature Shield Example 4 | 5 | This example shows an application on 1Sheeld's temperature shield. 6 | 7 | By using this example, you can turn on the LED on pin 13 if the 8 | smartphone's temperature sensor reports a certain value. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_TEMPERATURE_SENSOR_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* A name for the LED on pin 13. */ 24 | int ledPin = 13; 25 | 26 | void setup() 27 | { 28 | /* Start communication. */ 29 | OneSheeld.begin(); 30 | /* Set the LED pin as output. */ 31 | pinMode(ledPin,OUTPUT); 32 | } 33 | 34 | void loop () 35 | { 36 | /* Always check the value of temperature sensor. */ 37 | if(TemperatureSensor.getValue() < 10) 38 | { 39 | /* Turn on the LED. */ 40 | digitalWrite(ledPin,HIGH); 41 | } 42 | else 43 | { 44 | /* Turn off the LED. */ 45 | digitalWrite(ledPin,LOW); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /examples/Simple/Terminal/Terminal.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Terminal Shield Example 4 | 5 | This example shows an application on 1Sheeld's terminal shield. 6 | 7 | By using this example, you can debug your Arduino code easily and send 8 | temperature sensor data and check the values on our app. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_TERMINAL_SHIELD 19 | #define INCLUDE_TEMPERATURE_SENSOR_SHIELD 20 | 21 | /* Include 1Sheeld library. */ 22 | #include 23 | 24 | /* Fan on Pin 13. */ 25 | int fanPin = 13; 26 | /* Reserve a byte for Temperature value. */ 27 | int tempValue = 0; 28 | 29 | void setup() 30 | { 31 | /* Start communication. */ 32 | OneSheeld.begin(); 33 | /* Fan on pin 13. */ 34 | pinMode(fanPin,OUTPUT); 35 | } 36 | 37 | void loop() 38 | { 39 | /* Always get Temperature sensor value. */ 40 | tempValue = TemperatureSensor.getValue(); 41 | /* Check the temperature in the room. */ 42 | if(tempValue > 30) 43 | { 44 | /* Turn on the fan. */ 45 | digitalWrite(fanPin,HIGH); 46 | /* Display the value on the terminal. */ 47 | Terminal.println(tempValue); 48 | } 49 | else 50 | { 51 | /* Turn off the fan. */ 52 | digitalWrite(fanPin,LOW); 53 | /* Display the value on the terminal. */ 54 | Terminal.println(tempValue); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /examples/Simple/Twitter/Twitter.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Twitter Shield Example 4 | 5 | This example shows an application on 1Sheeld's Twitter shield. 6 | 7 | By using this example, you can tweet each time you press 8 | the hardware push button placed on pin 12. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_TWITTER_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | /* A name for the button on pin 12. */ 24 | int buttonPin = 12; 25 | /* A name for the LED on pin 13. */ 26 | int ledPin = 13; 27 | 28 | void setup() 29 | { 30 | /* Start communication. */ 31 | OneSheeld.begin(); 32 | /* Set the button pin as input. */ 33 | pinMode(buttonPin,INPUT); 34 | /* Set the LED pin as output. */ 35 | pinMode(ledPin,OUTPUT); 36 | } 37 | 38 | void loop() 39 | { 40 | /* Always check the button state. */ 41 | if(digitalRead(buttonPin) == HIGH) 42 | { 43 | /* Turn on the LED. */ 44 | digitalWrite(ledPin,HIGH); 45 | /* Tweet. */ 46 | Twitter.tweet("I'm tweeting from @Arduino via @1Sheeld!"); 47 | /* Wait for 300 ms. */ 48 | OneSheeld.delay(300); 49 | } 50 | else 51 | { 52 | /* Turn off the LED. */ 53 | digitalWrite(ledPin,LOW); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /examples/Simple/Vibration/Vibration.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Vibration Shield Example 4 | 5 | This example shows an application on 1Sheeld's vibration shield. 6 | 7 | By using this example, you can make your phone vibrate for a given 8 | amount of time. 9 | 10 | OPTIONAL: 11 | To reduce the library compiled size and limit its memory usage, you 12 | can specify which shields you want to include in your sketch by 13 | defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 14 | 15 | */ 16 | 17 | #define CUSTOM_SETTINGS 18 | #define INCLUDE_VIBRATION_SHIELD 19 | 20 | /* Include 1Sheeld library. */ 21 | #include 22 | 23 | void setup() { 24 | /* Start communication. */ 25 | OneSheeld.begin(); 26 | } 27 | 28 | void loop() { 29 | /* Vibrate once for 1 second. */ 30 | Vibration.start(1000); 31 | 32 | /* Wait for 8 seconds. */ 33 | OneSheeld.delay(8000); 34 | 35 | /* Vibrate for 1 second every 5 seconds. */ 36 | Vibration.start(1000,5000); 37 | 38 | /* Wait for 12 seconds. */ 39 | OneSheeld.delay(12000); 40 | 41 | /* Stop the vibration. */ 42 | Vibration.stop(); 43 | } 44 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=OneSheeld 2 | version=1.14.0 3 | author=Integreight, Inc. 4 | maintainer=Eslam Ali , Islam Mustafa , Mustafa Fayez 5 | sentence=It allows you to control your 1Sheeld(s). 6 | paragraph=1Sheeld is an All-In-One Arduino shield that lets you use your smartphone capabilites (Sensors, Internet,...etc) to power your Arduino projects. 7 | category=Device Control 8 | url=http://www.1sheeld.com/ 9 | architectures=* --------------------------------------------------------------------------------