├── test ├── __init__.py ├── tone_test.py ├── ping.py ├── encoder.py ├── servo.py ├── stepper.py └── i2c │ ├── i2c_read │ ├── i2c_read_callback.py │ └── i2c_read_polled.py │ └── i2c_write │ └── i2c_write.py ├── .gitattributes ├── FirmataPlus ├── source │ └── libraries │ │ ├── FirmataPlusRB │ │ ├── .gitignore │ │ └── keywords.txt │ │ ├── FirmataPlusRBPixy │ │ ├── .gitignore │ │ └── keywords.txt │ │ ├── FirmataPlus │ │ ├── .gitignore │ │ └── keywords.txt │ │ ├── FirmataPlusDue │ │ ├── .gitignore │ │ └── keywords.txt │ │ ├── FirmataPlusLBT │ │ ├── .gitignore │ │ └── keywords.txt │ │ ├── FirmataPlus32u4 │ │ ├── .gitignore │ │ └── keywords.txt │ │ ├── Firmata │ │ ├── utility │ │ │ ├── BLEStream.cpp │ │ │ ├── EthernetClientStream.cpp │ │ │ ├── WiFiStream.cpp │ │ │ ├── firmataDebug.h │ │ │ └── FirmataFeature.h │ │ ├── library.properties │ │ ├── test │ │ │ └── readme.md │ │ ├── release.sh │ │ ├── examples │ │ │ ├── EchoString │ │ │ │ └── EchoString.ino │ │ │ ├── SimpleAnalogFirmata │ │ │ │ └── SimpleAnalogFirmata.ino │ │ │ ├── ServoFirmata │ │ │ │ └── ServoFirmata.ino │ │ │ └── SimpleDigitalFirmata │ │ │ │ └── SimpleDigitalFirmata.ino │ │ └── keywords.txt │ │ ├── NewPing │ │ ├── NewPing.h │ │ ├── keywords.txt │ │ └── examples │ │ │ ├── NewPingExample │ │ │ └── NewPingExample.ino │ │ │ └── TimerExample │ │ │ └── TimerExample.pde │ │ ├── EnableInterrupt │ │ ├── Interrupt Timing.odt │ │ ├── Interrupt Timing.pdf │ │ ├── examples │ │ │ ├── HiSpeed │ │ │ │ ├── README │ │ │ │ └── Makefile │ │ │ ├── AllPins2560 │ │ │ │ └── Makefile │ │ │ ├── HiSpeedAllPins2560 │ │ │ │ └── Makefile │ │ │ ├── OOSimple │ │ │ │ └── Makefile │ │ │ ├── AllPins328 │ │ │ │ └── Makefile │ │ │ ├── HiSpeedTest │ │ │ │ └── Makefile │ │ │ ├── HiSpeedAllPins328 │ │ │ │ └── Makefile │ │ │ ├── InterruptedPin2560 │ │ │ │ └── Makefile │ │ │ ├── InterruptedPin328 │ │ │ │ └── Makefile │ │ │ ├── SimpleWithLibrary │ │ │ │ ├── Makefile │ │ │ │ ├── Useless.cpp │ │ │ │ ├── Useless.h │ │ │ │ └── SimpleWithLibrary.ino │ │ │ ├── test.sh │ │ │ ├── Simple │ │ │ │ ├── Makefile │ │ │ │ └── Makefile-usbasp │ │ │ ├── ATtinyBlink │ │ │ │ ├── ATtinyBlink.ino │ │ │ │ └── Makefile │ │ │ └── SimpleDueZero │ │ │ │ └── SimpleDueZero.ino │ │ ├── findInH │ │ ├── library.json │ │ ├── keywords.txt │ │ ├── library.properties │ │ ├── ReleaseChecklist │ │ ├── utility │ │ │ ├── ei_ExternalTiny25.h │ │ │ ├── ei_portj_speed.h │ │ │ ├── ei_porta_speed.h │ │ │ ├── ei_portk_speed.h │ │ │ ├── ei_PinChangeTiny25.h │ │ │ ├── ei_PinChangeLeonardo.h │ │ │ ├── ei_ExternalTiny24.h │ │ │ ├── ei_External328.h │ │ │ ├── ei_portc_speed.h │ │ │ ├── ei_portd_speed.h │ │ │ ├── ei_PinChangeTiny24.h │ │ │ ├── ei_External1284.h │ │ │ └── ei_PinChange328.h │ │ └── extras │ │ │ └── NOTICE │ │ ├── readme.txt │ │ ├── Pixy │ │ ├── keywords.txt │ │ ├── examples │ │ │ ├── servo_move │ │ │ │ └── servo_move.ino │ │ │ ├── led_cycle │ │ │ │ └── led_cycle.ino │ │ │ ├── i2c │ │ │ │ └── i2c.ino │ │ │ ├── uart │ │ │ │ └── uart.ino │ │ │ └── hello_world │ │ │ │ └── hello_world.ino │ │ ├── PixyUART.h │ │ └── PixyI2C.h │ │ ├── ooPinChangeInt │ │ ├── keywords.txt │ │ └── Examples │ │ │ ├── ooPinChangeInt │ │ │ ├── uint8ToString.h │ │ │ ├── pushbuttonswitch.h │ │ │ └── ooPinChangeInt.pde │ │ │ └── ooPinChangeIntTest │ │ │ └── uint8ToString.h │ │ ├── AdaEncoder │ │ ├── keywords.txt │ │ ├── Examples │ │ │ ├── GetPSTR │ │ │ │ └── GetPSTR.h │ │ │ └── MyEncoder │ │ │ │ ├── MyEncoder.pde │ │ │ │ └── MyEncoder .pde.ORIG │ │ └── RELEASE_NOTES │ │ ├── RedBot │ │ ├── RedBotRadio.cpp │ │ ├── RedBot_Experiments │ │ │ ├── .gitattributes │ │ │ ├── Exp2_DriveForward │ │ │ │ └── Exp2_DriveForward.ino │ │ │ ├── Exp6_LineFollowing_IRSensors │ │ │ │ └── Exp6_LineFollowing_IRSensors.ino │ │ │ ├── Exp9_SerialDrive │ │ │ │ └── Exp9_SerialDrive.ino │ │ │ ├── Exp1_BasicTest │ │ │ │ └── Exp1_BasicTest.ino │ │ │ ├── Exp4_MakingSounds │ │ │ │ └── Exp4_MakingSounds.ino │ │ │ ├── Exp7_1_RotaryEncoder │ │ │ │ └── Exp7_1_RotaryEncoder.ino │ │ │ ├── Exp3_Turning │ │ │ │ └── Exp3_Turning.ino │ │ │ ├── Exp8_1_AccelerometerRead │ │ │ │ └── Exp8_1_AccelerometerRead.ino │ │ │ ├── Exp7_2_DriveDistance │ │ │ │ └── Exp7_2_DriveDistance.ino │ │ │ └── Exp5_Bumpers │ │ │ │ └── Exp5_Bumpers.ino │ │ └── RedBotButton.cpp │ │ ├── RedBot2 │ │ ├── RedBotRadio.cpp │ │ ├── RedBot_Experiments │ │ │ ├── .gitattributes │ │ │ ├── Exp2_DriveForward │ │ │ │ └── Exp2_DriveForward.ino │ │ │ ├── Exp6_LineFollowing_IRSensors │ │ │ │ └── Exp6_LineFollowing_IRSensors.ino │ │ │ ├── Exp9_SerialDrive │ │ │ │ └── Exp9_SerialDrive.ino │ │ │ ├── Exp1_BasicTest │ │ │ │ └── Exp1_BasicTest.ino │ │ │ ├── Exp4_MakingSounds │ │ │ │ └── Exp4_MakingSounds.ino │ │ │ ├── Exp7_1_RotaryEncoder │ │ │ │ └── Exp7_1_RotaryEncoder.ino │ │ │ ├── Exp3_Turning │ │ │ │ └── Exp3_Turning.ino │ │ │ ├── Exp7_2_DriveDistance │ │ │ │ └── Exp7_2_DriveDistance.ino │ │ │ ├── Exp5_Bumpers │ │ │ │ └── Exp5_Bumpers.ino │ │ │ └── Exp8_1_AccelerometerRead │ │ │ │ └── Exp8_1_AccelerometerRead.ino │ │ └── RedBotButton.cpp │ │ ├── cppfix │ │ └── cppfix.h │ │ └── cbiface │ │ └── cbiface.h └── libraries.zip ├── examples ├── sparkfun_redbot │ ├── sparkfun_experiments │ │ ├── library │ │ │ └── __init__.py │ │ ├── Exp2_DriveForward.py │ │ ├── Exp1_BasicTest.py │ │ ├── Exp9_SerialDrive.py │ │ └── Exp4_MakingSounds.py │ ├── basics │ │ └── simple_drive.py │ └── pixy │ │ ├── simple_servo_sweep_config_2.py │ │ ├── pixy_set_led.py │ │ └── pixy_set_brightness.py ├── servo_sweep.py ├── simple_digital_input.py ├── simple_analog_input_with_callback.py ├── encoder.py ├── 3_sample.py ├── blink.py ├── control_C_handlers │ ├── for_pymata3.py │ └── for_core.py ├── core_sample.py ├── keyboard_notes.py └── pwm_pin_example.html ├── documentation ├── images │ ├── logo.png │ ├── ping.png │ ├── plugins.png │ ├── arduino1.png │ ├── firmataplus.png │ └── arduinoSketchDir.png ├── html │ ├── objects.inv │ ├── _static │ │ ├── up.png │ │ ├── down.png │ │ ├── file.png │ │ ├── minus.png │ │ ├── plus.png │ │ ├── comment.png │ │ ├── ajax-loader.gif │ │ ├── up-pressed.png │ │ ├── comment-close.png │ │ ├── down-pressed.png │ │ └── comment-bright.png │ ├── .buildinfo │ └── _sources │ │ ├── index.txt │ │ └── pymata_aio.txt └── screenshots │ └── pymata_core │ └── logo.png ├── MANIFEST ├── pymata_aio ├── __init__.py ├── pin_data.py └── pymata_socket.py ├── pypi_desc.md ├── setup.py ├── utilities └── list_serial_ports.py └── .gitignore /test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | FirmataPlus/source/* linguist-vendored -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/FirmataPlusRB/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /examples/sparkfun_redbot/sparkfun_experiments/library/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/FirmataPlusRBPixy/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/FirmataPlus/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | release.sh 3 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/FirmataPlusDue/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | release.sh 3 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/FirmataPlusLBT/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | release.sh 3 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/FirmataPlus32u4/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | release.sh 3 | -------------------------------------------------------------------------------- /FirmataPlus/libraries.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/FirmataPlus/libraries.zip -------------------------------------------------------------------------------- /documentation/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/images/logo.png -------------------------------------------------------------------------------- /documentation/images/ping.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/images/ping.png -------------------------------------------------------------------------------- /documentation/html/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/html/objects.inv -------------------------------------------------------------------------------- /documentation/images/plugins.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/images/plugins.png -------------------------------------------------------------------------------- /documentation/html/_static/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/html/_static/up.png -------------------------------------------------------------------------------- /documentation/images/arduino1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/images/arduino1.png -------------------------------------------------------------------------------- /documentation/html/_static/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/html/_static/down.png -------------------------------------------------------------------------------- /documentation/html/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/html/_static/file.png -------------------------------------------------------------------------------- /documentation/html/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/html/_static/minus.png -------------------------------------------------------------------------------- /documentation/html/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/html/_static/plus.png -------------------------------------------------------------------------------- /documentation/images/firmataplus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/images/firmataplus.png -------------------------------------------------------------------------------- /documentation/html/_static/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/html/_static/comment.png -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Firmata/utility/BLEStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Implementation is in BLEStream.h to avoid linker issues. 3 | */ 4 | -------------------------------------------------------------------------------- /documentation/html/_static/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/html/_static/ajax-loader.gif -------------------------------------------------------------------------------- /documentation/html/_static/up-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/html/_static/up-pressed.png -------------------------------------------------------------------------------- /documentation/images/arduinoSketchDir.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/images/arduinoSketchDir.png -------------------------------------------------------------------------------- /documentation/html/_static/comment-close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/html/_static/comment-close.png -------------------------------------------------------------------------------- /documentation/html/_static/down-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/html/_static/down-pressed.png -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/NewPing/NewPing.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/FirmataPlus/source/libraries/NewPing/NewPing.h -------------------------------------------------------------------------------- /documentation/html/_static/comment-bright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/html/_static/comment-bright.png -------------------------------------------------------------------------------- /documentation/screenshots/pymata_core/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/documentation/screenshots/pymata_core/logo.png -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Firmata/utility/EthernetClientStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Implementation is in EthernetClientStream.h to avoid linker issues. 3 | */ 4 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/Interrupt Timing.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/FirmataPlus/source/libraries/EnableInterrupt/Interrupt Timing.odt -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/Interrupt Timing.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrYsLab/pymata-aio/HEAD/FirmataPlus/source/libraries/EnableInterrupt/Interrupt Timing.pdf -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/readme.txt: -------------------------------------------------------------------------------- 1 | For information on installing libraries, see: http://www.arduino.cc/en/Guide/Libraries 2 | FirmataPlusLBT (Bluetooth library) is compatible with 32u4 boards only (leonardo, mega). 3 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Firmata/utility/WiFiStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Implementation is in WiFiStream.h to avoid linker issues. Legacy WiFi and modern WiFi101 both define WiFiClass which 3 | * will cause linker errors whenever Firmata.h is included. 4 | */ 5 | -------------------------------------------------------------------------------- /documentation/html/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: 1e5dd2339da30c40ca9d26cc4c9022a0 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Pixy/keywords.txt: -------------------------------------------------------------------------------- 1 | Pixy KEYWORD1 2 | PixyI2C KEYWORD1 3 | PixyUART KEYWORD1 4 | PixySPI_SS KEYWORD1 5 | Block KEYWORD1 6 | getBlocks KEYWORD2 7 | init KEYWORD2 8 | print KEYWORD2 9 | setServos KEYWORD2 10 | setBrightness KEYWORD2 11 | setLED KEYWORD2 12 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/HiSpeed/README: -------------------------------------------------------------------------------- 1 | Note: This code has not been tested! Caveat Programmer. I will do it asap. 2 | (I have tested the HiSpeed code using the HiSpeedTest sketch, so I'm confident 3 | the library is working properly. Also this sketch compiles.). 4 | -GreyGnome 5 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/ooPinChangeInt/keywords.txt: -------------------------------------------------------------------------------- 1 | # LITERAL1 specifies constants 2 | 3 | # KEYWORD1 specifies datatypes and C/C++ keywords 4 | PCintPort KEYWORD1 PCInterruptPort 5 | 6 | # KEYWORD2 specifies methods and functions 7 | attachInterrupt KEYWORD2 AttachInterrupt 8 | detachInterrupt KEYWORD2 DetachInterrupt 9 | -------------------------------------------------------------------------------- /MANIFEST: -------------------------------------------------------------------------------- 1 | # file GENERATED by distutils, do NOT edit 2 | setup.py 3 | pymata_aio/__init__.py 4 | pymata_aio/constants.py 5 | pymata_aio/pin_data.py 6 | pymata_aio/private_constants.py 7 | pymata_aio/pymata3.py 8 | pymata_aio/pymata_core.py 9 | pymata_aio/pymata_iot.py 10 | pymata_aio/pymata_serial.py 11 | test/test_all.py 12 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/AllPins2560/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!) 2 | BOARD_TAG = 2560 3 | ARDUINO_PORT = /dev/ttyACM0 4 | ARDUINO_LIBS = 5 | AVR_TOOLS_DIR = /usr 6 | 7 | CFLAGS_STD = -g 8 | CXXFLAGS_STD = -g 9 | 10 | include /usr/share/arduino/Arduino.mk 11 | 12 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/HiSpeedAllPins2560/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!) 2 | BOARD_TAG = 2560 3 | ARDUINO_PORT = /dev/ttyACM0 4 | ARDUINO_LIBS = 5 | AVR_TOOLS_DIR = /usr 6 | 7 | CFLAGS_STD = -g 8 | CXXFLAGS_STD = -g 9 | 10 | include /usr/share/arduino/Arduino.mk 11 | 12 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/AdaEncoder/keywords.txt: -------------------------------------------------------------------------------- 1 | # LITERAL1 specifies constants 2 | 3 | # KEYWORD1 specifies datatypes and C/C++ keywords 4 | AdaEncoder KEYWORD1 AdaEncoder 5 | 6 | # KEYWORD2 specifies methods and functions 7 | addEncoder KEYWORD2 AddEncoder 8 | attachInterrupt KEYWORD2 AttachInterrupt 9 | encoderInterrupt KEYWORD2 encoderInterrupt 10 | turnOffPWM KEYWORD2 turnOffPWM 11 | genie KEYWORD2 Genie 12 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/HiSpeed/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!) 2 | BOARD_TAG = atmega328 3 | ARDUINO_PORT = /dev/ttyUSB0 4 | #BOARD_TAG = 2560 5 | #ARDUINO_PORT = /dev/ttyACM0 6 | ARDUINO_LIBS = 7 | AVR_TOOLS_DIR = /usr 8 | 9 | CFLAGS_STD = -g 10 | CXXFLAGS_STD = -g 11 | 12 | include /usr/share/arduino/Arduino.mk 13 | 14 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/OOSimple/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!) 2 | BOARD_TAG = atmega328 3 | ARDUINO_PORT = /dev/ttyUSB0 4 | #BOARD_TAG = 2560 5 | #ARDUINO_PORT = /dev/ttyACM0 6 | ARDUINO_LIBS = 7 | AVR_TOOLS_DIR = /usr 8 | 9 | CFLAGS_STD = -g 10 | CXXFLAGS_STD = -g 11 | 12 | include /usr/share/arduino/Arduino.mk 13 | 14 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/AllPins328/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!) 2 | BOARD_TAG = atmega328 3 | ARDUINO_PORT = /dev/ttyUSB0 4 | #BOARD_TAG = 2560 5 | #ARDUINO_PORT = /dev/ttyACM0 6 | ARDUINO_LIBS = 7 | AVR_TOOLS_DIR = /usr 8 | 9 | CFLAGS_STD = -g 10 | CXXFLAGS_STD = -g 11 | 12 | include /usr/share/arduino/Arduino.mk 13 | 14 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/HiSpeedTest/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!) 2 | BOARD_TAG = atmega328 3 | ARDUINO_PORT = /dev/ttyUSB0 4 | #BOARD_TAG = 2560 5 | #ARDUINO_PORT = /dev/ttyACM0 6 | ARDUINO_LIBS = 7 | AVR_TOOLS_DIR = /usr 8 | 9 | CFLAGS_STD = -g 10 | CXXFLAGS_STD = -g 11 | 12 | include /usr/share/arduino/Arduino.mk 13 | 14 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/HiSpeedAllPins328/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!) 2 | BOARD_TAG = atmega328 3 | ARDUINO_PORT = /dev/ttyUSB0 4 | #BOARD_TAG = 2560 5 | #ARDUINO_PORT = /dev/ttyACM0 6 | ARDUINO_LIBS = 7 | AVR_TOOLS_DIR = /usr 8 | 9 | CFLAGS_STD = -g 10 | CXXFLAGS_STD = -g 11 | 12 | include /usr/share/arduino/Arduino.mk 13 | 14 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/InterruptedPin2560/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!) 2 | #BOARD_TAG = atmega328 3 | #ARDUINO_PORT = /dev/ttyUSB0 4 | BOARD_TAG = 2560 5 | ARDUINO_PORT = /dev/ttyACM0 6 | ARDUINO_LIBS = 7 | AVR_TOOLS_DIR = /usr 8 | 9 | CFLAGS_STD = -g 10 | CXXFLAGS_STD = -g 11 | 12 | include /usr/share/arduino/Arduino.mk 13 | 14 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/InterruptedPin328/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!) 2 | BOARD_TAG = atmega328 3 | ARDUINO_PORT = /dev/ttyUSB0 4 | #BOARD_TAG = 2560 5 | #ARDUINO_PORT = /dev/ttyACM0 6 | ARDUINO_LIBS = 7 | AVR_TOOLS_DIR = /usr 8 | 9 | CFLAGS_STD = -g 10 | CXXFLAGS_STD = -g 11 | 12 | include /usr/share/arduino/Arduino.mk 13 | 14 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/SimpleWithLibrary/Makefile: -------------------------------------------------------------------------------- 1 | # Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!) 2 | BOARD_TAG = atmega328 3 | ARDUINO_PORT = /dev/ttyUSB0 4 | #BOARD_TAG = 2560 5 | #ARDUINO_PORT = /dev/ttyACM0 6 | ARDUINO_LIBS = 7 | AVR_TOOLS_DIR = /usr 8 | 9 | CFLAGS_STD = -g 10 | CXXFLAGS_STD = -g 11 | 12 | include /usr/share/arduino/Arduino.mk 13 | 14 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Firmata/utility/firmataDebug.h: -------------------------------------------------------------------------------- 1 | #ifndef FIRMATA_DEBUG_H 2 | #define FIRMATA_DEBUG_H 3 | 4 | #ifdef SERIAL_DEBUG 5 | #define DEBUG_BEGIN(baud) Serial.begin(baud); while(!Serial) {;} 6 | #define DEBUG_PRINTLN(x) Serial.println (x); Serial.flush() 7 | #define DEBUG_PRINT(x) Serial.print (x) 8 | #else 9 | #define DEBUG_BEGIN(baud) 10 | #define DEBUG_PRINTLN(x) 11 | #define DEBUG_PRINT(x) 12 | #endif 13 | 14 | #endif /* FIRMATA_DEBUG_H */ 15 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | examples=" 4 | AllPins2560 5 | AllPins328 6 | ATtinyBlink 7 | HiSpeed 8 | HiSpeedAllPins2560 9 | HiSpeedAllPins328 10 | InterruptedPin2560 11 | InterruptedPin328 12 | Mighty1284p 13 | OOSimple 14 | Simple 15 | SimpleWithLibrary 16 | " 17 | 18 | for example in $examples; do 19 | echo $example 20 | sleep 2 21 | ( cd $example; rm -rf build-*; make) 22 | echo $example done 23 | sleep 2 24 | done 25 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/findInH: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A utility program for looking for stuff in the #include directories on my system. 3 | # Tracked so I have a backup of it. 4 | 5 | arduinoToo=false 6 | 7 | [ "$1" = "-a" ] && arduinoToo=true && shift 8 | find /usr/avr/include /usr/lib/gcc/avr/*/include /usr/lib/gcc/avr/*/include-fixed \ 9 | /usr/lib/gcc/avr/*/plugin/include \ 10 | -type f -exec grep "$1" {} \; -print 11 | 12 | $arduinoToo && find /usr/share/arduino \ 13 | -type f -exec grep "$1" {} \; -print 14 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot/RedBotRadio.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | CPP header for various RedBot radio modes. 3 | 4 | Not yet implemented: coming soon! 5 | 6 | This code is beerware; if you use it, please buy me (or any other 7 | SparkFun employee) a cold beverage next time you run into one of 8 | us at the local. 9 | 10 | 21 Jan 2014- Mike Hord, SparkFun Electronics 11 | 12 | Code developed in Arduino 1.0.5, on an SparkFun Redbot v12. 13 | ****************************************************************/ -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot2/RedBotRadio.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | CPP header for various RedBot radio modes. 3 | 4 | Not yet implemented: coming soon! 5 | 6 | This code is beerware; if you use it, please buy me (or any other 7 | SparkFun employee) a cold beverage next time you run into one of 8 | us at the local. 9 | 10 | 21 Jan 2014- Mike Hord, SparkFun Electronics 11 | 12 | Code developed in Arduino 1.0.5, on an SparkFun Redbot v12. 13 | ****************************************************************/ -------------------------------------------------------------------------------- /documentation/html/_sources/index.txt: -------------------------------------------------------------------------------- 1 | .. pymata_aio documentation master file, created by 2 | sphinx-quickstart on Mon Nov 9 11:58:06 2015. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to pymata_aio's documentation! 7 | ====================================== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 4 13 | 14 | pymata_aio 15 | 16 | 17 | Indices and tables 18 | ================== 19 | 20 | * :ref:`genindex` 21 | * :ref:`modindex` 22 | * :ref:`search` 23 | 24 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/AdaEncoder/Examples/GetPSTR/GetPSTR.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDE_GETPSTR 2 | #define INCLUDE_GETPSTR 3 | 4 | #if defined(ARDUINO) && ARDUINO >= 100 5 | #include 6 | #else 7 | #include "pins_arduino.h" 8 | #include "WProgram.h" 9 | #include "wiring.h" 10 | #endif 11 | 12 | #define getPSTR(s) pgmStrToRAM(PSTR(s)) 13 | 14 | char *_pstr_to_print; 15 | char *pgmStrToRAM(PROGMEM char *theString) { 16 | free(_pstr_to_print); 17 | _pstr_to_print=(char *) malloc(strlen_P(theString)); 18 | strcpy_P(_pstr_to_print, theString); 19 | return (_pstr_to_print); 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Firmata/library.properties: -------------------------------------------------------------------------------- 1 | name=Firmata 2 | version=2.5.3 3 | author=Firmata Developers 4 | maintainer=https://github.com/firmata/arduino 5 | sentence=Enables the communication with computer apps using a standard serial protocol. For all Arduino/Genuino boards. 6 | paragraph=The Firmata library implements the Firmata protocol for communicating with software on the host computer. This allows you to write custom firmware without having to create your own protocol and objects for the programming environment that you are using. 7 | category=Device Control 8 | url=https://github.com/firmata/arduino 9 | architectures=* 10 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot/RedBot_Experiments/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot2/RedBot_Experiments/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "EnableInterrupt", 3 | "version": "0.9.5", 4 | "frameworks": "Arduino", 5 | "keywords": "interrupt, interrupts, pin, pins", 6 | "description": "Assign an interrupt to any supported pin on all Arduinos, plus ATtiny 84/85 and ATmega 644/1284.", 7 | "authors": [ 8 | { 9 | "name": "Mike 'GreyGnome' Schwager", 10 | "email": "mschwage@gmail.com", 11 | "url": "https://github.com/GreyGnome", 12 | "maintainer": true 13 | } 14 | ], 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/GreyGnome/EnableInterrupt" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For EnableInterrupt 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | 13 | enableInterrupt KEYWORD2 14 | disableInterrupt KEYWORD2 15 | 16 | ####################################### 17 | # Constants (LITERAL1) 18 | ####################################### 19 | 20 | PINCHANGEINTERRUPT LITERAL1 21 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Firmata/test/readme.md: -------------------------------------------------------------------------------- 1 | #Testing Firmata 2 | 3 | Tests tests are written using the [ArduinoUnit](https://github.com/mmurdoch/arduinounit) library (version 2.0). 4 | 5 | Follow the instructions in the [ArduinoUnit readme](https://github.com/mmurdoch/arduinounit/blob/master/readme.md) to install the library. 6 | 7 | Compile and upload the test sketch as you would any other sketch. Then open the 8 | Serial Monitor to view the test results. 9 | 10 | If you make changes to Firmata.cpp, run the tests in /test/ to ensure 11 | that your changes have not produced any unexpected errors. 12 | 13 | You should also perform manual tests against actual hardware. 14 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/cppfix/cppfix.h: -------------------------------------------------------------------------------- 1 | #ifndef cppfix_h 2 | #define cppfix_h 3 | 4 | #include 5 | 6 | // from http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=410870 7 | __extension__ typedef int __guard __attribute__((mode (__DI__))); 8 | 9 | void * operator new(size_t size); 10 | void operator delete(void * ptr); 11 | 12 | int __cxa_guard_acquire(__guard *g) {return !*(char *)(g);}; 13 | void __cxa_guard_release (__guard *g) {*(char *)g = 1;}; 14 | void __cxa_guard_abort (__guard *) {}; 15 | 16 | void * operator new(size_t size) 17 | { 18 | return malloc(size); 19 | } 20 | 21 | void operator delete(void * ptr) 22 | { 23 | free(ptr); 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/library.properties: -------------------------------------------------------------------------------- 1 | name=EnableInterrupt 2 | version=0.9.5 3 | author=Mike "GreyGnome" Schwager 4 | maintainer=Mike "GreyGnome" Schwager 5 | sentence=Assign an interrupt to any supported pin on all Arduinos, plus ATtiny 84/85 and ATmega 644/1284. 6 | paragraph=Provides a consistent API across chips, architectures, and interrupt types. Makes External and Pin Change on the ATmega series, and Due and Zero pin interrupts operate similarly. Code optimized for speed; includes an extra-high-speed mode for speed critical code. 7 | category=Signal Input/Output 8 | url=https://github.com/GreyGnome/EnableInterrupt 9 | architectures=* 10 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/SimpleWithLibrary/Useless.cpp: -------------------------------------------------------------------------------- 1 | // FOR TESTING, TO DEMONSTRATE HOW TO USE ENABLEINTERRUPT IN A LIBRARY. 2 | // See Useless.h for more information. 3 | #include "Useless.h" 4 | 5 | volatile uint8_t uselessVariable=0; 6 | 7 | void uselessFunction() { 8 | uselessVariable++; 9 | } 10 | 11 | void UselessClass::init(uint8_t pin, uint8_t mode) { 12 | pinMode(pin, INPUT_PULLUP); 13 | enableInterrupt(pin, uselessFunction, mode); 14 | } 15 | 16 | uint8_t UselessClass::getUselessVariable() { 17 | return uselessVariable; 18 | } 19 | 20 | void UselessClass::reset() { 21 | uselessVariable=0; 22 | } 23 | 24 | void UselessClass::disable(uint8_t pin) { 25 | disableInterrupt(pin); 26 | } 27 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/ooPinChangeInt/Examples/ooPinChangeInt/uint8ToString.h: -------------------------------------------------------------------------------- 1 | #ifndef UINT8TOSTRING 2 | #define UINT8TOSTRING 3 | 4 | void uint8ToString(char *outString, uint8_t number) { 5 | uint8_t hundreds=0; 6 | uint8_t tens=0; 7 | uint8_t ones=0; 8 | 9 | while (number >= 100 ) { 10 | hundreds++; 11 | number-=100; 12 | } 13 | while (number >= 10 ) { 14 | tens++; 15 | number-=10; 16 | } 17 | ones=number; 18 | ones+=48; 19 | if (hundreds > 0) { hundreds+=48; tens+=48; outString[0]=hundreds; outString[1]=tens; outString[2]=ones; outString[3]=0; } 20 | else if (tens > 0) { tens+=48; outString[0]=tens; outString[1]=ones; outString[2]=0; } 21 | else { outString[0]=ones; outString[1]=0; }; 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/ooPinChangeInt/Examples/ooPinChangeIntTest/uint8ToString.h: -------------------------------------------------------------------------------- 1 | #ifndef UINT8TOSTRING 2 | #define UINT8TOSTRING 3 | 4 | void uint8ToString(char *outString, uint8_t number) { 5 | uint8_t hundreds=0; 6 | uint8_t tens=0; 7 | uint8_t ones=0; 8 | 9 | while (number >= 100 ) { 10 | hundreds++; 11 | number-=100; 12 | } 13 | while (number >= 10 ) { 14 | tens++; 15 | number-=10; 16 | } 17 | ones=number; 18 | ones+=48; 19 | if (hundreds > 0) { hundreds+=48; tens+=48; outString[0]=hundreds; outString[1]=tens; outString[2]=ones; outString[3]=0; } 20 | else if (tens > 0) { tens+=48; outString[0]=tens; outString[1]=ones; outString[2]=0; } 21 | else { outString[0]=ones; outString[1]=0; }; 22 | } 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/ReleaseChecklist: -------------------------------------------------------------------------------- 1 | - examples/test.sh compiles 2 | - #pragma message in .h file up-to-date? 3 | - Use Arduino IDE, compile "SimpleDueZero" 4 | - Tests: 5 | - Simple 6 | - HiSpeed 7 | - HiSpeedAllPins328 8 | - AllPins328 9 | - HiSpeedAllPins2560 10 | - AllPins2560 11 | - ATtinyBlink 12 | - README.md up-to-date? 13 | - extras/RELEASE_NOTES consistent with README.md? 14 | - library.properties current? 15 | - library.json current? 16 | - Git Tagged? git tag -a 2.31 -m 'my version 1.4'; git push origin 2.31 OR git push origin --tags 17 | - Zip file created? ~/bin/zipei 0.9.0 18 | - BinTray: 19 | - Upload Zip file 20 | - Update the downloads area 21 | - Git commit 22 | - Push files to GitHub 23 | - Post to Arduino forums 24 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/NewPing/keywords.txt: -------------------------------------------------------------------------------- 1 | ################################### 2 | # Syntax Coloring Map For NewPing 3 | ################################### 4 | 5 | ################################### 6 | # Datatypes (KEYWORD1) 7 | ################################### 8 | 9 | NewPing KEYWORD1 10 | 11 | ################################### 12 | # Methods and Functions (KEYWORD2) 13 | ################################### 14 | 15 | ping KEYWORD2 16 | ping_in KEYWORD2 17 | ping_cm KEYWORD2 18 | ping_median KEYWORD2 19 | ping_timer KEYWORD2 20 | check_timer KEYWORD2 21 | timer_us KEYWORD2 22 | timer_ms KEYWORD2 23 | timer_stop KEYWORD2 24 | convert_in KEYWORD2 25 | convert_cm KEYWORD2 26 | 27 | ################################### 28 | # Constants (LITERAL1) 29 | ################################### 30 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/utility/ei_ExternalTiny25.h: -------------------------------------------------------------------------------- 1 | // Support for the 8-pin ATtiny25/45/85 2 | #ifdef EI_SECTION_ENABLEEXTERNAL 3 | // NO switch (arduinoPin) { // ONLY 1 External Interrupt pin. 4 | #ifndef EI_NOTINT0 5 | GIMSK &= ~_BV(6); 6 | #ifndef NEEDFORSPEED 7 | externalFunctionPointer = userFunction; 8 | #endif 9 | MCUCR &= (~_BV(0) & ~_BV(1)); // reset the flags prior to 10 | MCUCR |= mode; // set them the way we want 11 | GIFR |= _BV(6); 12 | GIMSK |= _BV(6); 13 | #endif // ! defined (EI_NOTINT0) 14 | #endif // EI_SECTION_ENABLEEXTERNAL 15 | 16 | #ifdef EI_SECTION_DISABLEEXTERNAL 17 | #ifndef EI_NOTINT0 18 | GIMSK &= ~_BV(6); 19 | GIFR |= _BV(6); // using a clue from the ATmega2560 datasheet. 20 | MCUCR &= (~_BV(0) & ~_BV(1)); 21 | #endif 22 | #endif // EI_SECTION_DISABLEEXTERNAL 23 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/utility/ei_portj_speed.h: -------------------------------------------------------------------------------- 1 | #if defined ARDUINO_MEGA 2 | #if defined INTERRUPT_FLAG_PIN15 3 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PIN15++; 4 | #endif 5 | #if defined INTERRUPT_FLAG_PIN14 6 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PIN14++; 7 | #endif 8 | #if defined INTERRUPT_FLAG_PIN70 9 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PIN70++; 10 | #endif 11 | #if defined INTERRUPT_FLAG_PIN71 12 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PIN71++; 13 | #endif 14 | #if defined INTERRUPT_FLAG_PIN72 15 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PIN72++; 16 | #endif 17 | #if defined INTERRUPT_FLAG_PIN73 18 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN73++; 19 | #endif 20 | #if defined INTERRUPT_FLAG_PIN74 21 | if (interruptMask & _BV(6)) INTERRUPT_FLAG_PIN74++; 22 | #endif 23 | #endif 24 | // NOTE: 75 and 76 are "fake" External interrupt pins. 25 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/utility/ei_porta_speed.h: -------------------------------------------------------------------------------- 1 | #if defined MIGHTY1284 2 | #ifdef INTERRUPT_FLAG_PIN24 3 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PIN24++; 4 | #endif 5 | #ifdef INTERRUPT_FLAG_PIN25 6 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PIN25++; 7 | #endif 8 | #ifdef INTERRUPT_FLAG_PIN26 9 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PIN26++; 10 | #endif 11 | #ifdef INTERRUPT_FLAG_PIN27 12 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PIN27++; 13 | #endif 14 | #ifdef INTERRUPT_FLAG_PIN28 15 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PIN28++; 16 | #endif 17 | #ifdef INTERRUPT_FLAG_PIN29 18 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN29++; 19 | #endif 20 | #ifdef INTERRUPT_FLAG_PIN30 21 | if (interruptMask & _BV(6)) INTERRUPT_FLAG_PIN30++; 22 | #endif 23 | #ifdef INTERRUPT_FLAG_PIN31 24 | if (interruptMask & _BV(7)) INTERRUPT_FLAG_PIN31++; 25 | #endif 26 | #endif 27 | -------------------------------------------------------------------------------- /pymata_aio/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2015-2017 Alan Yorinks All rights reserved. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE 6 | Version 3 as published by the Free Software Foundation; either 7 | or (at your option) any later version. 8 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | General Public License for more details. 12 | 13 | You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE 14 | along with this library; if not, write to the Free Software 15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | The pymata_aio package that implements a Python asyncio Arduino StandardFirmata client. 18 | """ 19 | -------------------------------------------------------------------------------- /examples/servo_sweep.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """ 3 | Pymata-aio port of the Arduino Servo --> Sweep Example 4 | """ 5 | 6 | from pymata_aio.pymata3 import PyMata3 7 | 8 | board = PyMata3() 9 | SERVO_PIN = 5 10 | 11 | 12 | def setup(): 13 | board.servo_config(SERVO_PIN) 14 | 15 | 16 | def loop(): 17 | print("Servo up") 18 | # The range of motion for some servos isn't all the way from 0 degrees to 180 degrees, change as needed. 19 | for pos in range(0, 180): # Start=0 degrees, Finish=180 degree, (Increment=1 degree which is the default) 20 | board.analog_write(SERVO_PIN, pos) 21 | board.sleep(0.015) 22 | print("Servo down") 23 | for pos in range(180, 0, -1): # Start=180 degrees, Finish=0 degrees, Increment=-1 degrees (moving down) 24 | board.analog_write(SERVO_PIN, pos) 25 | board.sleep(0.015) 26 | 27 | 28 | if __name__ == "__main__": 29 | setup() 30 | while True: 31 | loop() 32 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/utility/ei_portk_speed.h: -------------------------------------------------------------------------------- 1 | #if defined ARDUINO_MEGA 2 | #if defined INTERRUPT_FLAG_PINA8 3 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PINA8++; 4 | #endif 5 | #if defined INTERRUPT_FLAG_PINA9 6 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PINA9++; 7 | #endif 8 | #if defined INTERRUPT_FLAG_PINA10 9 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PINA10++; 10 | #endif 11 | #if defined INTERRUPT_FLAG_PINA11 12 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PINA11++; 13 | #endif 14 | #if defined INTERRUPT_FLAG_PINA12 15 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PINA12++; 16 | #endif 17 | #if defined INTERRUPT_FLAG_PINA13 18 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PINA13++; 19 | #endif 20 | #if defined INTERRUPT_FLAG_PINA14 21 | if (interruptMask & _BV(6)) INTERRUPT_FLAG_PINA14++; 22 | #endif 23 | #if defined INTERRUPT_FLAG_PINA15 24 | if (interruptMask & _BV(7)) INTERRUPT_FLAG_PINA15++; 25 | #endif 26 | #endif 27 | -------------------------------------------------------------------------------- /examples/simple_digital_input.py: -------------------------------------------------------------------------------- 1 | from pymata_aio.pymata3 import PyMata3 2 | from pymata_aio.constants import Constants 3 | import sys 4 | import signal 5 | 6 | # Change the state of a digital input pin and its value will be printed. 7 | # This example uses pin 13, but change to meet your needs 8 | 9 | 10 | try: 11 | board = PyMata3() 12 | board.set_pin_mode(13, Constants.INPUT) 13 | except KeyboardInterrupt: 14 | sys.exit(0) 15 | 16 | 17 | # Signal handler to trap control C 18 | def _signal_handler(sig, frame): 19 | if board is not None: 20 | print('\nYou pressed Ctrl+C') 21 | sys.exit(1) 22 | 23 | 24 | signal.signal(signal.SIGINT, _signal_handler) 25 | signal.signal(signal.SIGTERM, _signal_handler) 26 | 27 | # add SIGALRM if platform is not windows 28 | if not sys.platform.startswith('win32'): 29 | signal.signal(signal.SIGALRM, _signal_handler) 30 | 31 | while True: 32 | print(board.digital_read(13)) 33 | board.sleep(.1) 34 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/utility/ei_PinChangeTiny25.h: -------------------------------------------------------------------------------- 1 | #ifdef EI_SECTION_RISING 2 | #ifndef EI_NOTPORTB 3 | risingPinsPORTB |= portMask; 4 | #endif 5 | #endif // EI_SECTION_RISING 6 | 7 | #ifdef EI_SECTION_FALLING 8 | #ifndef EI_NOTPORTB 9 | fallingPinsPORTB |= portMask; 10 | #endif 11 | #endif // EI_SECTION_FALLING 12 | 13 | #if defined EI_SECTION_ASSIGNFUNCTIONSREGISTERS 14 | #ifndef EI_NOTPORTB 15 | #ifndef NEEDFORSPEED 16 | calculatedPointer=&portBFunctions.pinZero + portBitNumber; 17 | *calculatedPointer = userFunction; 18 | #endif 19 | portSnapshotB=*portInputRegister(portNumber); 20 | pcmsk=&PCMSK; 21 | GIMSK |= _BV(5); 22 | #endif 23 | #endif // EI_SECTION_ASSIGNFUNCTIONSREGISTERS 24 | 25 | #ifdef EI_SECTION_DISABLEPINCHANGE 26 | #ifndef EI_NOTPORTB 27 | PCMSK &= ~portMask; 28 | if (PCMSK == 0) { GIMSK &= ~_BV(5); }; 29 | risingPinsPORTB &= ~portMask; 30 | fallingPinsPORTB &= ~portMask; 31 | #endif 32 | #endif // EI_SECTION_DISABLEPINCHANGE 33 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Firmata/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # use this script to package Firmata for distribution 4 | 5 | # package for Arduino 1.0.x 6 | mkdir -p temp/Firmata 7 | cp -r examples temp/Firmata 8 | cp -r extras temp/Firmata 9 | cp -r utility temp/Firmata 10 | cp Boards.h temp/Firmata 11 | cp Firmata.cpp temp/Firmata 12 | cp Firmata.h temp/Firmata 13 | cp keywords.txt temp/Firmata 14 | cp readme.md temp/Firmata 15 | cd temp 16 | find . -name "*.DS_Store" -type f -delete 17 | zip -r Firmata.zip ./Firmata/ 18 | cd .. 19 | mv ./temp/Firmata.zip Firmata-2.5.3.zip 20 | 21 | #package for Arduino 1.6.x 22 | cp library.properties temp/Firmata 23 | cd temp/Firmata 24 | mv readme.md ./extras/ 25 | mkdir src 26 | mv Boards.h ./src/ 27 | mv Firmata.cpp ./src/ 28 | mv Firmata.h ./src/ 29 | mv utility ./src/ 30 | cd .. 31 | find . -name "*.DS_Store" -type f -delete 32 | zip -r Firmata.zip ./Firmata/ 33 | cd .. 34 | mv ./temp/Firmata.zip Arduino-1.6.x-Firmata-2.5.3.zip 35 | rm -r ./temp 36 | -------------------------------------------------------------------------------- /examples/simple_analog_input_with_callback.py: -------------------------------------------------------------------------------- 1 | from pymata_aio.pymata3 import PyMata3 2 | from pymata_aio.constants import Constants 3 | import sys 4 | import signal 5 | 6 | 7 | # this program monitors the A2 pin. Modify to meet your needs 8 | 9 | def my_callback(data): 10 | # data[0] is the pin number and data[1] is the changed value 11 | print(data[1]) 12 | 13 | 14 | try: 15 | board = PyMata3() 16 | board.set_pin_mode(2, Constants.ANALOG, my_callback) 17 | except KeyboardInterrupt: 18 | sys.exit(0) 19 | 20 | 21 | # Signal handler to trap control C 22 | def _signal_handler(sig, frame): 23 | if board is not None: 24 | print('\nYou pressed Ctrl+C') 25 | sys.exit(1) 26 | 27 | 28 | signal.signal(signal.SIGINT, _signal_handler) 29 | signal.signal(signal.SIGTERM, _signal_handler) 30 | 31 | # add SIGALRM if platform is not windows 32 | if not sys.platform.startswith('win32'): 33 | signal.signal(signal.SIGALRM, _signal_handler) 34 | 35 | while True: 36 | board.sleep(.1) 37 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/extras/NOTICE: -------------------------------------------------------------------------------- 1 | NOTICE 2 | EnableInterrupt Arduino Library 3 | Copyright 2014-2015 Michael Schwager (aka Mike Schwager aka "GreyGnome") 4 | 5 | This product includes software developed by Mike Schwager. 6 | 7 | This library was inspired and replaces the PinChangeInt library. 8 | 9 | GreyGnome is the current maintainer, and would like to thank all those 10 | Open Source coders, the Arduino makers and community, and especially Chris 11 | and Lex for lighting the flame and showing the way! And a big thank you to 12 | the users who have contributed comments and bug fixes along the way. 13 | Without you this project would not have overcome some significant hurdles. 14 | 15 | A HUGE thanks to Jan Baeyens ("jantje"), who has graciously DONATED an 16 | Arduino Mega ADK board to the PinChangeInt project!!! Wow, thanks Jan! 17 | This makes the 2560-based Arduino Mega a first class supported platform- 18 | I am able to test it and verify that it works. 19 | 20 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/utility/ei_PinChangeLeonardo.h: -------------------------------------------------------------------------------- 1 | // ALL pin change interrupts are on Port B on Leonardo. 2 | #ifdef EI_SECTION_RISING 3 | #ifndef EI_NOTPORTB 4 | risingPinsPORTB |= portMask; 5 | #endif 6 | #endif // EI_SECTION_RISING 7 | 8 | #ifdef EI_SECTION_FALLING 9 | #ifndef EI_NOTPORTB 10 | fallingPinsPORTB |= portMask; 11 | #endif 12 | #endif // EI_SECTION_FALLING 13 | 14 | #if defined EI_SECTION_ASSIGNFUNCTIONSREGISTERS 15 | #ifndef EI_NOTPORTB 16 | #ifndef NEEDFORSPEED 17 | calculatedPointer=&portBFunctions.pinZero + portBitNumber; 18 | *calculatedPointer = userFunction; 19 | #endif 20 | portSnapshotB=*portInputRegister(portNumber); 21 | pcmsk=&PCMSK0; 22 | PCICR |= _BV(0); 23 | #endif 24 | #endif // EI_SECTION_ASSIGNFUNCTIONSREGISTERS 25 | 26 | #ifdef EI_SECTION_DISABLEPINCHANGE 27 | #ifndef EI_NOTPORTB 28 | PCMSK0 &= ~portMask; 29 | if (PCMSK0 == 0) { PCICR &= ~_BV(0); }; 30 | risingPinsPORTB &= ~portMask; 31 | fallingPinsPORTB &= ~portMask; 32 | #endif 33 | #endif // EI_SECTION_DISABLEPINCHANGE 34 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot/RedBotButton.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | Main CPP for RedBot button control. 3 | 4 | This code is beerware; if you use it, please buy me (or any other 5 | SparkFun employee) a cold beverage next time you run into one of 6 | us at the local. 7 | 8 | 04 Oct 2014- B. Huang, SparkFun Electronics 9 | 10 | Code developed in Arduino 1.0.6, on an SparkFun Redbot rev02 11 | ****************************************************************/ 12 | 13 | #include "RedBot.h" 14 | #include 15 | 16 | #define BUTTON_PIN 12 17 | 18 | // Constructor. Mostly for pin setup; note that it's not necessary to configure 19 | // PWM pins as they will be automatically configured with the analogWrite() 20 | // function is called. 21 | RedBotButton::RedBotButton() 22 | { 23 | // Sets the "default" state of the button to be HIGH. 24 | pinMode(BUTTON_PIN, INPUT_PULLUP); 25 | } 26 | 27 | boolean RedBotButton::read() 28 | { 29 | return(!digitalRead(BUTTON_PIN)); 30 | } -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot2/RedBotButton.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | Main CPP for RedBot button control. 3 | 4 | This code is beerware; if you use it, please buy me (or any other 5 | SparkFun employee) a cold beverage next time you run into one of 6 | us at the local. 7 | 8 | 04 Oct 2014- B. Huang, SparkFun Electronics 9 | 10 | Code developed in Arduino 1.0.6, on an SparkFun Redbot rev02 11 | ****************************************************************/ 12 | 13 | #include "RedBot2.h" 14 | #include 15 | 16 | #define BUTTON_PIN 12 17 | 18 | // Constructor. Mostly for pin setup; note that it's not necessary to configure 19 | // PWM pins as they will be automatically configured with the analogWrite() 20 | // function is called. 21 | RedBotButton::RedBotButton() 22 | { 23 | // Sets the "default" state of the button to be HIGH. 24 | pinMode(BUTTON_PIN, INPUT_PULLUP); 25 | } 26 | 27 | boolean RedBotButton::read() 28 | { 29 | return(!digitalRead(BUTTON_PIN)); 30 | } 31 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/utility/ei_ExternalTiny24.h: -------------------------------------------------------------------------------- 1 | // Support for the 14-pin ATtiny24/24A/44/44A/84/84A 2 | #if ! defined(EI_NOTINT0) 3 | #ifdef EI_SECTION_ENABLEEXTERNAL 4 | // NO switch (arduinoPin) { // ONLY 1 External Interrupt pin. 5 | #ifndef EI_NOTINT0 6 | GIMSK &= ~_BV(6); // Disable interrupts since we are (possibly) changing interrupt settings 7 | #ifndef NEEDFORSPEED 8 | externalFunctionPointer = userFunction; 9 | #endif 10 | MCUCR &= (~_BV(0) & ~_BV(1)); // reset the flags prior to 11 | MCUCR |= mode; // set them the way we want 12 | GIFR |= _BV(6); 13 | GIMSK |= _BV(6); 14 | #endif 15 | #endif // EI_SECTION_ENABLEEXTERNAL 16 | 17 | #ifdef EI_SECTION_DISABLEEXTERNAL 18 | #ifndef EI_NOTINT0 19 | GIMSK &= ~_BV(6); 20 | MCUCR &= (~_BV(0) & ~_BV(1)); // reset the flags 21 | GIFR |= _BV(6); // using a clue from the ATmega2560 datasheet. 22 | #endif 23 | #endif // EI_SECTION_DISABLEEXTERNAL 24 | #endif // ! defined(EI_NOTINT0) && ! defined (EI_NOTINT1) && ! defined (EI_NOTINT2) 25 | -------------------------------------------------------------------------------- /examples/encoder.py: -------------------------------------------------------------------------------- 1 | # This is a simple rotary encoder test program. 2 | 3 | import sys 4 | 5 | from pymata_aio.constants import Constants 6 | from pymata_aio.pymata3 import PyMata3 7 | 8 | # encoder pins 9 | ENCODER_A = 14 10 | ENCODER_B = 15 11 | 12 | 13 | def encoder_callback(data): 14 | print(data) 15 | 16 | 17 | # create a PyMata instance 18 | try: 19 | board = PyMata3() 20 | except KeyboardInterrupt: 21 | sys.exit(0) 22 | 23 | # configure the pins for the encoder 24 | 25 | # for callback - enable the next line 26 | # for polling, comment out this line 27 | board.encoder_config(ENCODER_B, ENCODER_A, cb=encoder_callback, cb_type=Constants.CB_TYPE_DIRECT) 28 | 29 | # for polling enable this line 30 | # for callback comment out this line 31 | # board.encoder_config(ENCODER_B, ENCODER_A) 32 | 33 | print("Change the position on your rotary encoder.") 34 | while 1: 35 | try: 36 | board.sleep(.02) 37 | except KeyboardInterrupt: 38 | board.shutdown() 39 | 40 | # uncomment for polling 41 | # print(board.encoder_read(ENCODER_B)) 42 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/Simple/Makefile: -------------------------------------------------------------------------------- 1 | ## Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!) 2 | BOARD_TAG = atmega328 3 | ARDUINO_PORT = /dev/ttyUSB0 4 | ##BOARD_TAG = 2560 5 | ##ARDUINO_PORT = /dev/ttyACM0 6 | #ARDUINO_LIBS = 7 | #AVR_TOOLS_DIR = /usr 8 | # 9 | #CFLAGS_STD = -g 10 | #CXXFLAGS_STD = -g 11 | # 12 | #include /usr/share/arduino/Arduino.mk 13 | 14 | ######################################################################## 15 | ## Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile 16 | # 17 | 18 | #ARDUINO_DIR = /home/schwager/bin/arduino-1.6.4 19 | #BOARD_SUB = atmega1284p 20 | #CFLAGS_STD = -g -I /home/schwager/sketchbook/hardware/mighty-1284p-master/variants/standard 21 | #CXXFLAGS_STD = -g -I /home/schwager/sketchbook/hardware/mighty-1284p-master/variants/standard 22 | # 23 | 24 | #ISP_PROG = usbasp 25 | # from boards.txt 26 | #BOARD_TAG = mighty_opt 27 | #ALTERNATE_CORE = mighty-1284p-master 28 | # This is set in the boards.txt file. 29 | #F_CPU = 16000000L 30 | 31 | include /usr/share/arduino/Arduino.mk 32 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/Simple/Makefile-usbasp: -------------------------------------------------------------------------------- 1 | ## Arduino Makefile, see https://github.com/sudar/Arduino-Makefile (it's awesome!) 2 | #BOARD_TAG = atmega328 3 | #ARDUINO_PORT = /dev/ttyUSB0 4 | ##BOARD_TAG = 2560 5 | ##ARDUINO_PORT = /dev/ttyACM0 6 | #ARDUINO_LIBS = 7 | #AVR_TOOLS_DIR = /usr 8 | # 9 | #CFLAGS_STD = -g 10 | #CXXFLAGS_STD = -g 11 | # 12 | #include /usr/share/arduino/Arduino.mk 13 | 14 | ######################################################################## 15 | ## Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile 16 | # 17 | 18 | ARDUINO_DIR = /home/schwager/bin/arduino-1.6.4 19 | BOARD_SUB = atmega1284p 20 | CFLAGS_STD = -g -I /home/schwager/sketchbook/hardware/mighty-1284p-master/variants/standard 21 | CXXFLAGS_STD = -g -I /home/schwager/sketchbook/hardware/mighty-1284p-master/variants/standard 22 | # 23 | 24 | ISP_PROG = usbasp 25 | # from boards.txt 26 | BOARD_TAG = mighty_opt 27 | ALTERNATE_CORE = mighty-1284p-master 28 | # This is set in the boards.txt file. 29 | #F_CPU = 16000000L 30 | 31 | include /usr/share/arduino/Arduino.mk 32 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/SimpleWithLibrary/Useless.h: -------------------------------------------------------------------------------- 1 | // This is a useless library. To use such a useless thing, with the EnableInterrupt library, 2 | // you need to #define LIBCALL_ENABLEINTERRUPT in your library, like so: 3 | #define LIBCALL_ENABLEINTERRUPT 4 | // Thus, none of the functions or ISRs will get compiled but their prototypes are declared 5 | // so you can use them as illustrated in the Useless.cpp. 6 | 7 | // You also need to #include the EnableInterrupt.h file in your sketch. After you #include the 8 | // EnableInterrupt.h file, #include the library's .h file (ie, this one in this example). This 9 | // will compile the requisite components. See the SimpleWithLibrary.ino sketch. 10 | 11 | #include 12 | #include 13 | 14 | #define EI_ARDUINO_INTERRUPTED_PIN 15 | #include 16 | 17 | class UselessClass { 18 | public: 19 | UselessClass(uint8_t pin, uint8_t mode) { 20 | init(pin, mode); 21 | } 22 | uint8_t getUselessVariable(); 23 | void reset(); 24 | void disable(uint8_t pin); 25 | private: 26 | void init(uint8_t pin, uint8_t mode); 27 | }; 28 | 29 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/AdaEncoder/Examples/MyEncoder/MyEncoder.pde: -------------------------------------------------------------------------------- 1 | // Version 1.1: OO version 2 | #include 3 | #include // necessary otherwise we get undefined reference errors. 4 | #define DEBUG 5 | #ifdef DEBUG 6 | ByteBuffer printBuffer(200); 7 | #endif 8 | #include 9 | 10 | #define ENCA_a 2 11 | #define ENCA_b 3 12 | #define ENCB_a A0 13 | #define ENCB_b A1 14 | 15 | //AdaEncoder encoderA = AdaEncoder('a', ENCA_a, ENCA_b); 16 | AdaEncoder encoderB = AdaEncoder('b', ENCB_a, ENCB_b); 17 | 18 | int8_t clicks=0; 19 | char id=0; 20 | 21 | void setup() 22 | { 23 | Serial.begin(115200); Serial.println("---------------------------------------"); 24 | } 25 | 26 | void loop() 27 | { 28 | char outChar; 29 | while ((outChar=(char)printBuffer.get()) != 0) Serial.print(outChar); 30 | AdaEncoder *thisEncoder=NULL; 31 | thisEncoder=AdaEncoder::genie(); 32 | if (thisEncoder != NULL) { 33 | Serial.print(thisEncoder->getID()); Serial.print(':'); 34 | clicks=thisEncoder->query(); 35 | if (clicks > 0) { 36 | Serial.println(" CW"); 37 | } 38 | if (clicks < 0) { 39 | Serial.println(" CCW"); 40 | } 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/AdaEncoder/Examples/MyEncoder/MyEncoder .pde.ORIG: -------------------------------------------------------------------------------- 1 | // Version 1.1: OO version 2 | #include 3 | #include // necessary otherwise we get undefined reference errors. 4 | #define DEBUG 5 | #ifdef DEBUG 6 | ByteBuffer printBuffer(200); 7 | #endif 8 | #include 9 | 10 | #define ENCA_a 2 11 | #define ENCA_b 3 12 | #define ENCB_a A3 13 | #define ENCB_b A4 14 | 15 | AdaEncoder encoderA = AdaEncoder('a', ENCA_a, ENCA_b); 16 | AdaEncoder encoderB = AdaEncoder('b', ENCB_a, ENCB_b); 17 | 18 | int8_t clicks=0; 19 | char id=0; 20 | 21 | void setup() 22 | { 23 | Serial.begin(115200); Serial.println("---------------------------------------"); 24 | } 25 | 26 | void loop() 27 | { 28 | char outChar; 29 | while ((outChar=(char)printBuffer.get()) != 0) Serial.print(outChar); 30 | AdaEncoder *thisEncoder=NULL; 31 | thisEncoder=AdaEncoder::genie(); 32 | if (thisEncoder != NULL) { 33 | Serial.print(thisEncoder->getID()); Serial.print(':'); 34 | clicks=thisEncoder->query(); 35 | if (clicks > 0) { 36 | Serial.println(" CW"); 37 | } 38 | if (clicks < 0) { 39 | Serial.println(" CCW"); 40 | } 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot/RedBot_Experiments/Exp2_DriveForward/Exp2_DriveForward.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp2_DriveForward -- RedBot Experiment 2 3 | * 4 | * Drive forward and stop. 5 | * 6 | * Hardware setup: 7 | * The Power switch must be on, the motors must be connected, and the board must be receiving power 8 | * from the battery. The motor switch must also be switched to RUN. 9 | * 10 | * 23 Sept 2013 N. Seidle/M. Hord 11 | * 04 Oct 2014 B. Huang 12 | ***********************************************************************/ 13 | 14 | #include // This line "includes" the RedBot library into your sketch. 15 | // Provides special objects, methods, and functions for the RedBot. 16 | 17 | RedBotMotors motors; // Instantiate the motor control object. This only needs 18 | // to be done once. 19 | 20 | void setup() 21 | { 22 | motors.drive(255); // Turn on Left and right motors at full speed forward. 23 | delay(2000); // Waits for 2 seconds 24 | motors.stop(); // Stops both motors 25 | } 26 | 27 | void loop() 28 | { 29 | // Nothing here. We'll get to this in the next experiment. 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot2/RedBot_Experiments/Exp2_DriveForward/Exp2_DriveForward.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp2_DriveForward -- RedBot Experiment 2 3 | * 4 | * Drive forward and stop. 5 | * 6 | * Hardware setup: 7 | * The Power switch must be on, the motors must be connected, and the board must be receiving power 8 | * from the battery. The motor switch must also be switched to RUN. 9 | * 10 | * 23 Sept 2013 N. Seidle/M. Hord 11 | * 04 Oct 2014 B. Huang 12 | ***********************************************************************/ 13 | 14 | #include // This line "includes" the RedBot library into your sketch. 15 | // Provides special objects, methods, and functions for the RedBot. 16 | 17 | RedBotMotors motors; // Instantiate the motor control object. This only needs 18 | // to be done once. 19 | 20 | void setup() 21 | { 22 | motors.drive(255); // Turn on Left and right motors at full speed forward. 23 | delay(2000); // Waits for 2 seconds 24 | motors.stop(); // Stops both motors 25 | } 26 | 27 | void loop() 28 | { 29 | // Nothing here. We'll get to this in the next experiment. 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Firmata/examples/EchoString/EchoString.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Firmata is a generic protocol for communicating with microcontrollers 3 | * from software on a host computer. It is intended to work with 4 | * any host computer software package. 5 | * 6 | * To download a host software package, please clink on the following link 7 | * to open the download page in your default browser. 8 | * 9 | * http://firmata.org/wiki/Download 10 | */ 11 | 12 | /* This sketch accepts strings and raw sysex messages and echos them back. 13 | * 14 | * This example code is in the public domain. 15 | */ 16 | #include 17 | 18 | void stringCallback(char *myString) 19 | { 20 | Firmata.sendString(myString); 21 | } 22 | 23 | 24 | void sysexCallback(byte command, byte argc, byte *argv) 25 | { 26 | Firmata.sendSysex(command, argc, argv); 27 | } 28 | 29 | void setup() 30 | { 31 | Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION); 32 | Firmata.attach(STRING_DATA, stringCallback); 33 | Firmata.attach(START_SYSEX, sysexCallback); 34 | Firmata.begin(57600); 35 | } 36 | 37 | void loop() 38 | { 39 | while (Firmata.available()) { 40 | Firmata.processInput(); 41 | } 42 | } 43 | 44 | 45 | -------------------------------------------------------------------------------- /test/tone_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Copyright (c) 2015 Alan Yorinks All rights reserved. 5 | 6 | This program is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public 8 | License as published by the Free Software Foundation; either 9 | version 3 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | 21 | """ 22 | 23 | # import the API class 24 | from pymata_aio.pymata3 import PyMata3 25 | from pymata_aio.constants import Constants 26 | 27 | 28 | # create a PyMata instance 29 | board = PyMata3() 30 | 31 | # configure 4 pins for 4 SONAR modules 32 | board.play_tone(9, Constants.TONE_TONE, 2000, 1500) 33 | board.sleep(3) 34 | board.play_tone(9, Constants.TONE_NO_TONE, 2000, 500) 35 | 36 | board.shutdown() 37 | -------------------------------------------------------------------------------- /test/ping.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Copyright (c) 2015 Alan Yorinks All rights reserved. 5 | 6 | This program is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public 8 | License as published by the Free Software Foundation; either 9 | version 3 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | 21 | """ 22 | 23 | # import the API class 24 | 25 | 26 | from pymata_aio.pymata3 import PyMata3 27 | 28 | 29 | # ping callback function 30 | def cb_ping(data): 31 | print(str(data[1]) + ' centimeters') 32 | 33 | 34 | # create a PyMata instance 35 | board = PyMata3(2) 36 | 37 | # configure an HC-SR04 for single pin operation on pin 12 38 | board.sonar_config(12, 12, cb_ping) 39 | 40 | while True: 41 | board.sleep(.1) 42 | 43 | board.shutdown() 44 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Pixy/examples/servo_move/servo_move.ino: -------------------------------------------------------------------------------- 1 | // 2 | // begin license header 3 | // 4 | // This file is part of Pixy CMUcam5 or "Pixy" for short 5 | // 6 | // All Pixy source code is provided under the terms of the 7 | // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html). 8 | // Those wishing to use Pixy source code, software and/or 9 | // technologies under different licensing terms should contact us at 10 | // cmucam@cs.cmu.edu. Such licensing terms are available for 11 | // all portions of the Pixy codebase presented here. 12 | // 13 | // end license header 14 | // 15 | // This sketch is demonstrates the setServos() function. Running this sketch 16 | // will move the servos to their limits, back and forth, back and forth. 17 | // 18 | 19 | #include 20 | #include 21 | 22 | Pixy pixy; 23 | 24 | void setup() 25 | { 26 | 27 | Serial.begin(9600); 28 | Serial.print("Starting...\n"); 29 | 30 | pixy.init(); 31 | } 32 | 33 | void loop() 34 | { 35 | Serial.println("Moving pan-tilt to max positions"); 36 | pixy.setServos(PIXY_RCS_MAX_POS, PIXY_RCS_MAX_POS); 37 | delay(1000); 38 | 39 | Serial.println("Moving pan-tilt to min positions"); 40 | pixy.setServos(PIXY_RCS_MIN_POS, PIXY_RCS_MIN_POS); 41 | delay(1000); 42 | } 43 | 44 | 45 | -------------------------------------------------------------------------------- /pypi_desc.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | pymata_aio is a high performance, non-blocking, Python asyncio client 4 | for the Firmata Protocolthat supports the complete StandardFirmata 5 | protocol. 6 | 7 | Major features 8 | ============== 9 | 10 | * Python 3.5+ compatible. 11 | 12 | * Choose From 3 Included APIs 13 | * pymata_core - a pure asyncio method call API. 14 | * pymata3 - A non-asyncio proxy for pymata_core 15 | * pymata_iot - A websocket based backed to control an Arduino over a Web page. 16 | 17 | * Implements 100% of the StandardFirmata Protocol (StandardFirmata 2.5.3). 18 | 19 | * Auto-detects Arduino COM ports. 20 | 21 | * FirmataPlus (enhanced StandardFirmata sketch) included with distribution. It adds support for: 22 | * HC-SR04 Ultrasonic Distance Sensors using a single pin. 23 | * Stepper Motors. 24 | * Piezo Tone Generation. 25 | * 2 Pin Rotary Encoder Support. 26 | 27 | * FirmataPlusRB (enhanced StandaradFirmata sketch to control a SparkFun Redbot. It adds support for: 28 | * Piezo Tone Generation. 29 | * Wheel encoders. 30 | * RedBot Accelerometer. 31 | 32 | * Ability to automatically capture and time-stamp user specified analog and digital transient input events on a per-pin basis. 33 | * All 3 APIs support callback as well as a polled interface. 34 | 35 | 36 | -------------------------------------------------------------------------------- /test/encoder.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Copyright (c) 2015 Alan Yorinks All rights reserved. 5 | 6 | This program is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public 8 | License as published by the Free Software Foundation; either 9 | version 3 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | 21 | """ 22 | 23 | # import the API class 24 | 25 | 26 | from pymata_aio.pymata3 import PyMata3 27 | 28 | 29 | # ping callback function 30 | def encoder_val(data): 31 | print(str(data[2]) + ' centimeters') 32 | 33 | # create a PyMata instance 34 | board = PyMata3(2) 35 | 36 | board.encoder_config(15, 14) 37 | 38 | while True: 39 | board.sleep(.001) 40 | value = board.encoder_read(15) 41 | print(value) 42 | 43 | # board.sleep(.1) 44 | board.shutdown() 45 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/NewPing/examples/NewPingExample/NewPingExample.ino: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------- 2 | // Example NewPing library sketch that does a ping about 20 times per second. 3 | // --------------------------------------------------------------------------- 4 | 5 | #include 6 | 7 | #define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor. 8 | #define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor. 9 | #define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. 10 | 11 | NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. 12 | 13 | void setup() { 14 | Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results. 15 | } 16 | 17 | void loop() { 18 | delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings. 19 | unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS). 20 | Serial.print("Ping: "); 21 | Serial.print(uS / US_ROUNDTRIP_CM); // Convert ping time to distance in cm and print result (0 = outside set distance range) 22 | Serial.println("cm"); 23 | } 24 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/NewPing/examples/TimerExample/TimerExample.pde: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------- 2 | // While the NewPing library's primary goal is to interface with ultrasonic sensors, interfacing with 3 | // the Timer2 interrupt was a result of creating an interrupt-based ping method. Since these Timer2 4 | // interrupt methods were built, the library may as well provide the functionality to use these methods 5 | // in your sketches. This shows how simple it is (no ultrasonic sensor required). Keep in mind that 6 | // these methods use Timer2, as does NewPing's ping_timer method for using ultrasonic sensors. You 7 | // can't use ping_timer at the same time you're using timer_ms or timer_us as all use the same timer. 8 | // --------------------------------------------------------------------------- 9 | 10 | #include 11 | 12 | #define LED_PIN 13 // Pin with LED attached. 13 | 14 | void setup() { 15 | pinMode(LED_PIN, OUTPUT); 16 | NewPing::timer_ms(500, toggleLED); // Create a Timer2 interrupt that calls toggleLED in your sketch once every 500 milliseconds. 17 | } 18 | 19 | void loop() { 20 | // Do anything here, the Timer2 interrupt will take care of the flashing LED without your intervention. 21 | } 22 | 23 | void toggleLED() { 24 | digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Toggle the LED. 25 | } -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/utility/ei_External328.h: -------------------------------------------------------------------------------- 1 | #if ! defined(EI_NOTINT0) && ! defined(EI_NOTINT1) 2 | #ifdef EI_SECTION_ENABLEEXTERNAL 3 | #ifndef EI_NOTINT0 4 | if (arduinoPin == 2) { 5 | #ifndef NEEDFORSPEED 6 | functionPointerArrayEXTERNAL[0] = userFunction; 7 | #endif 8 | EIMSK &= ~_BV(0); 9 | EICRA &= (~_BV(0) & ~_BV(1)); 10 | EICRA |= mode; 11 | EIFR |= _BV(0); // using a clue from the ATmega2560 datasheet. 12 | EIMSK |= _BV(0); 13 | } 14 | #endif 15 | #ifndef EI_NOTINT1 16 | if (arduinoPin == 3) { 17 | #ifndef NEEDFORSPEED 18 | functionPointerArrayEXTERNAL[1] = userFunction; 19 | #endif 20 | EIMSK &= ~_BV(1); 21 | EICRA &= (~_BV(2) & ~_BV(3)); 22 | EICRA |= mode << 2; 23 | EIFR |= _BV(1); // using a clue from the ATmega2560 datasheet. 24 | EIMSK |= _BV(1); 25 | } 26 | #endif 27 | #endif // EI_SECTION_ENABLEEXTERNAL 28 | 29 | #ifdef EI_SECTION_DISABLEEXTERNAL 30 | #ifndef EI_NOTINT0 31 | if (arduinoPin == 2) { 32 | EIMSK &= ~_BV(0); 33 | EICRA &= (~_BV(0) & ~_BV(1)); 34 | EIFR |= _BV(0); // using a clue from the ATmega2560 datasheet. 35 | } 36 | #endif 37 | #ifndef EI_NOTINT1 38 | if (arduinoPin == 3) { 39 | EIMSK &= ~_BV(1); 40 | EICRA &= (~_BV(2) & ~_BV(3)); 41 | EIFR |= _BV(1); // using a clue from the ATmega2560 datasheet. 42 | } 43 | #endif 44 | #endif // EI_SECTION_DISABLEEXTERNAL 45 | #endif // ! defined(EI_NOTINT0) && ! defined(EI_NOTINT1) 46 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Firmata/utility/FirmataFeature.h: -------------------------------------------------------------------------------- 1 | /* 2 | FirmataFeature.h 3 | Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved. 4 | Copyright (C) 2010-2011 Paul Stoffregen. All rights reserved. 5 | Copyright (C) 2009 Shigeru Kobayashi. All rights reserved. 6 | Copyright (C) 2013 Norbert Truchsess. All rights reserved. 7 | Copyright (C) 2009-2016 Jeff Hoefs. All rights reserved. 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Lesser General Public 11 | License as published by the Free Software Foundation; either 12 | version 2.1 of the License, or (at your option) any later version. 13 | 14 | Interface for Firmata feature classes. 15 | 16 | This version of FirmataFeature.h differs from the ConfigurableFirmata 17 | version in the following ways: 18 | 19 | - Imports Firmata.h rather than ConfigurableFirmata.h 20 | 21 | See file LICENSE.txt for further informations on licensing terms. 22 | */ 23 | 24 | #ifndef FirmataFeature_h 25 | #define FirmataFeature_h 26 | 27 | #include 28 | 29 | class FirmataFeature 30 | { 31 | public: 32 | virtual void handleCapability(byte pin) = 0; 33 | virtual boolean handlePinMode(byte pin, int mode) = 0; 34 | virtual boolean handleSysex(byte command, byte argc, byte* argv) = 0; 35 | virtual void reset() = 0; 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /examples/3_sample.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Copyright (c) 2015 Alan Yorinks All rights reserved. 5 | 6 | This program is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public 8 | License as published by the Free Software Foundation; either 9 | version 3 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | """ 20 | from pymata_aio.pymata3 import PyMata3 21 | from pymata_aio.constants import Constants 22 | 23 | 24 | def pin_6_pwm_128(): 25 | """ 26 | Set digital pin 6 as a PWM output and set its output value to 128 27 | @return: 28 | """ 29 | # instantiate the pymata_core API 30 | board = PyMata3() 31 | 32 | # set the pin mode 33 | board.set_pin_mode(6, Constants.PWM) 34 | board.analog_write(6, 128) 35 | 36 | # wait for 3 seconds to see the LED lit 37 | board.sleep(3) 38 | 39 | # reset the board and exit 40 | board.shutdown() 41 | 42 | 43 | if __name__ == "__main__": 44 | pin_6_pwm_128() 45 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Firmata is a generic protocol for communicating with microcontrollers 3 | * from software on a host computer. It is intended to work with 4 | * any host computer software package. 5 | * 6 | * To download a host software package, please clink on the following link 7 | * to open the download page in your default browser. 8 | * 9 | * http://firmata.org/wiki/Download 10 | */ 11 | 12 | /* Supports as many analog inputs and analog PWM outputs as possible. 13 | * 14 | * This example code is in the public domain. 15 | */ 16 | #include 17 | 18 | byte analogPin = 0; 19 | 20 | void analogWriteCallback(byte pin, int value) 21 | { 22 | if (IS_PIN_PWM(pin)) { 23 | pinMode(PIN_TO_DIGITAL(pin), OUTPUT); 24 | analogWrite(PIN_TO_PWM(pin), value); 25 | } 26 | } 27 | 28 | void setup() 29 | { 30 | Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION); 31 | Firmata.attach(ANALOG_MESSAGE, analogWriteCallback); 32 | Firmata.begin(57600); 33 | } 34 | 35 | void loop() 36 | { 37 | while (Firmata.available()) { 38 | Firmata.processInput(); 39 | } 40 | // do one analogRead per loop, so if PC is sending a lot of 41 | // analog write messages, we will only delay 1 analogRead 42 | Firmata.sendAnalog(analogPin, analogRead(analogPin)); 43 | analogPin = analogPin + 1; 44 | if (analogPin >= TOTAL_ANALOG_PINS) analogPin = 0; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/SimpleWithLibrary/SimpleWithLibrary.ino: -------------------------------------------------------------------------------- 1 | // SimpleWithLibrary example sketch for the EnableInterrupt library. Demonstrates how to use 2 | // the EnableInterrupt library with a sketch that services an interrupt pin, and uses a library 3 | // that also requires the EnableInterrupt library. 4 | 5 | // This sketch has only been compiled to the Arduino Uno (ATmega328). 6 | // This sketch is only known to compile. It has not been tested functionally. 7 | 8 | // See https://github.com/GreyGnome/EnableInterrupt and the README.md for more information. 9 | #define EI_ARDUINO_INTERRUPTED_PIN 10 | #include 11 | #define USELESSPIN 10 12 | #include "Useless.h" 13 | 14 | #define ARDUINOPIN 9 15 | 16 | volatile uint16_t interruptCount=0; 17 | 18 | void interruptFunction() { 19 | interruptCount++; 20 | } 21 | 22 | // UselessClass uses the EnableInterrupt library. 23 | UselessClass uselessObject=UselessClass(USELESSPIN, CHANGE); 24 | 25 | void setup() { 26 | Serial.begin(115200); 27 | pinMode(ARDUINOPIN, INPUT_PULLUP); // See http://arduino.cc/en/Tutorial/DigitalPins 28 | enableInterrupt(ARDUINOPIN, interruptFunction, CHANGE); 29 | } 30 | 31 | void loop() { 32 | Serial.println("---------------------------------------"); 33 | delay(1000); 34 | Serial.print("Pin was interrupted: "); 35 | Serial.print(interruptCount, DEC); 36 | Serial.println(" times so far."); 37 | Serial.print("Useless interrupt count: "); 38 | Serial.print(uselessObject.getUselessVariable(), DEC); 39 | } 40 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | with open('pypi_desc.md', "r") as f: 4 | long_description = f.read() 5 | 6 | setup( 7 | name='pymata-aio', 8 | version='2.35', 9 | packages=['pymata_aio', 'utilities'], 10 | install_requires=['pyserial', 'websockets'], 11 | entry_points={ 12 | 'console_scripts': [ 13 | 'list_serial_ports = utilities.list_serial_ports:lsp', 14 | ] 15 | }, 16 | url='https://github.com/MrYsLab/pymata-aio/wiki', 17 | download_url='https://github.com/MrYsLab/pymata-aio', 18 | license='GNU Affero General Public License v3 or later (AGPLv3+)', 19 | author='Alan Yorinks', 20 | author_email='MisterYsLab@gmail.com', 21 | description='A Python Protocol Abstraction Library For Arduino Firmata using Python asyncio', 22 | long_description=long_description, 23 | long_description_content_type='text/markdown', 24 | keywords=['Firmata', 'Arduino', 'Protocol'], 25 | classifiers=[ 26 | 'Development Status :: 5 - Production/Stable', 27 | 'Environment :: Other Environment', 28 | 'Intended Audience :: Developers', 29 | 'Intended Audience :: Education', 30 | 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)', 31 | 'Operating System :: OS Independent', 32 | 'Programming Language :: Python :: 3.5', 33 | 'Programming Language :: Python :: 3 :: Only', 34 | 'Topic :: Utilities', 35 | 'Topic :: Education', 36 | 'Topic :: Home Automation', 37 | ], 38 | ) 39 | 40 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Pixy/examples/led_cycle/led_cycle.ino: -------------------------------------------------------------------------------- 1 | // 2 | // begin license header 3 | // 4 | // This file is part of Pixy CMUcam5 or "Pixy" for short 5 | // 6 | // All Pixy source code is provided under the terms of the 7 | // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html). 8 | // Those wishing to use Pixy source code, software and/or 9 | // technologies under different licensing terms should contact us at 10 | // cmucam@cs.cmu.edu. Such licensing terms are available for 11 | // all portions of the Pixy codebase presented here. 12 | // 13 | // end license header 14 | // 15 | // This sketch is demonstrates the setLED() function. Running this sketch 16 | // will cycle the Pixy's RGB LED through its colors. 17 | // 18 | 19 | #include 20 | #include 21 | 22 | Pixy pixy; 23 | 24 | void setup() 25 | { 26 | Serial.begin(9600); 27 | Serial.print("Starting...\n"); 28 | 29 | pixy.init(); 30 | } 31 | 32 | void loop() 33 | { 34 | uint32_t i=0; 35 | uint8_t r, g, b; 36 | 37 | while(1) 38 | { 39 | // calculate r, g, b such that it cycles through the colors 40 | r = i&0xff; 41 | g = (i*3)&0xff; 42 | b = (i/3)&0xff; 43 | pixy.setLED(r, g, b); 44 | // We need to delay here because serial requests are handled 45 | // every frame period (20ms). If we don't delay, we'll 46 | // overrun Pixy's receive queue. But that's all OK because 47 | // we normally only update the LED once per frame anyway. 48 | delay(20); 49 | 50 | i++; 51 | } 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot/RedBot_Experiments/Exp6_LineFollowing_IRSensors/Exp6_LineFollowing_IRSensors.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp6_LineFollowing_IRSensors -- RedBot Experiment 6 3 | * 4 | * This code reads the three line following sensors on A3, A6, and A7 5 | * and prints them out to the Serial Monitor. Upload this example to your 6 | * RedBot and open up the Serial Monitor by clicking the magnifying glass 7 | * in the upper-right hand corner. 8 | * 9 | * This sketch was written by SparkFun Electronics,with lots of help from 10 | * the Arduino community. This code is completely free for any use. 11 | * 12 | * 8 Oct 2013 M. Hord 13 | * Revised, 31 Oct 2014 B. Huang 14 | ***********************************************************************/ 15 | 16 | #include 17 | RedBotSensor IRSensor1 = RedBotSensor(A3); // initialize a sensor object on A3 18 | RedBotSensor IRSensor2 = RedBotSensor(A6); // initialize a sensor object on A6 19 | RedBotSensor IRSensor3 = RedBotSensor(A7); // initialize a sensor object on A7 20 | 21 | void setup() 22 | { 23 | Serial.begin(9600); 24 | Serial.println("Welcome to experiment 6!"); 25 | Serial.println("------------------------"); 26 | } 27 | 28 | void loop() 29 | { 30 | Serial.print("IR Sensor Readings: "); 31 | Serial.print(IRSensor1.read()); 32 | Serial.print("\t"); // tab character 33 | Serial.print(IRSensor2.read()); 34 | Serial.print("\t"); // tab character 35 | Serial.print(IRSensor3.read()); 36 | Serial.println(); 37 | delay(100); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot2/RedBot_Experiments/Exp6_LineFollowing_IRSensors/Exp6_LineFollowing_IRSensors.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp6_LineFollowing_IRSensors -- RedBot Experiment 6 3 | * 4 | * This code reads the three line following sensors on A3, A6, and A7 5 | * and prints them out to the Serial Monitor. Upload this example to your 6 | * RedBot and open up the Serial Monitor by clicking the magnifying glass 7 | * in the upper-right hand corner. 8 | * 9 | * This sketch was written by SparkFun Electronics,with lots of help from 10 | * the Arduino community. This code is completely free for any use. 11 | * 12 | * 8 Oct 2013 M. Hord 13 | * Revised, 31 Oct 2014 B. Huang 14 | ***********************************************************************/ 15 | 16 | #include 17 | RedBotSensor IRSensor1 = RedBotSensor(A3); // initialize a sensor object on A3 18 | RedBotSensor IRSensor2 = RedBotSensor(A6); // initialize a sensor object on A6 19 | RedBotSensor IRSensor3 = RedBotSensor(A7); // initialize a sensor object on A7 20 | 21 | void setup() 22 | { 23 | Serial.begin(9600); 24 | Serial.println("Welcome to experiment 6!"); 25 | Serial.println("------------------------"); 26 | } 27 | 28 | void loop() 29 | { 30 | Serial.print("IR Sensor Readings: "); 31 | Serial.print(IRSensor1.read()); 32 | Serial.print("\t"); // tab character 33 | Serial.print(IRSensor2.read()); 34 | Serial.print("\t"); // tab character 35 | Serial.print(IRSensor3.read()); 36 | Serial.println(); 37 | delay(100); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/ooPinChangeInt/Examples/ooPinChangeInt/pushbuttonswitch.h: -------------------------------------------------------------------------------- 1 | #if defined(ARDUINO) && ARDUINO >= 100 2 | #include 3 | #else 4 | #include 5 | #include 6 | #endif 7 | #include 8 | #include "uint8ToString.h" 9 | 10 | extern ByteBuffer printBuffer; 11 | char numBuffer[4] = { 0, 0, 0, 0 }; 12 | 13 | // To use the library, define a class that subclasses CallBackInterface. 14 | // And also, include a method (C++ talk for "subroutine") called "cbmethod()" in the class. 15 | // Use this class as a template to create your own; it's not hard. You don't 16 | // even have to understand what you're doing at first. 17 | // How do you subclass? Like this: 18 | class pushbuttonswitch : public CallBackInterface 19 | { 20 | public: 21 | uint8_t count; 22 | uint8_t pin; 23 | char *name; 24 | 25 | pushbuttonswitch (uint8_t _pin, char *_name): pin(_pin), name(_name) { 26 | init(); 27 | }; 28 | 29 | void cbmethod() { 30 | count++; 31 | uint8ToString(numBuffer, pin); 32 | printBuffer.putString("Int: "); printBuffer.putString(numBuffer); 33 | printBuffer.putString(" "); printBuffer.putString(name); 34 | }; 35 | 36 | uint8_t getCount() { 37 | return count; 38 | } 39 | 40 | char *getName() { 41 | return name; 42 | } 43 | 44 | uint8_t reset() { 45 | count=0; 46 | } 47 | 48 | private: 49 | void init () { 50 | pinMode(pin, INPUT); 51 | digitalWrite(pin, HIGH); 52 | PCintPort::attachInterrupt(pin, this, FALLING); 53 | }; 54 | }; 55 | 56 | -------------------------------------------------------------------------------- /examples/blink.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """ 3 | Turns on an LED on for one second, then off for one second, repeatedly. 4 | 5 | Most Arduinos have an on-board LED you can control. On the Uno and 6 | Leonardo, it is attached to digital pin 13. If you're unsure what 7 | pin the on-board LED is connected to on your Arduino model, check 8 | the documentation at http://www.arduino.cc 9 | """ 10 | 11 | from pymata_aio.pymata3 import PyMata3 12 | from pymata_aio.constants import Constants 13 | 14 | # Arduino LED is on pin 13 15 | BOARD_LED = 13 16 | 17 | # If you are having problems connecting, you may 18 | # wish to add some time the arduino_wait parameter. 19 | 20 | # replace: 21 | # board = PyMata3() 22 | # with: 23 | # board = PyMata3(arduino_wait=5) 24 | 25 | # adjust the arduino_wait value to meet the needs 26 | # of your computer 27 | 28 | # instantiate PyMata3 29 | board = PyMata3() 30 | 31 | 32 | def setup(): 33 | """ 34 | Set the Arduino BOARD_LED pin as an output 35 | :return: 36 | """ 37 | board.set_pin_mode(BOARD_LED, Constants.OUTPUT) 38 | 39 | 40 | def loop(): 41 | """ 42 | Toggle the LED by alternating the values written 43 | to the LED pin. Wait 1 second between writes. 44 | Also note the use of board.sleep and not 45 | time.sleep. 46 | :return: 47 | """ 48 | print("LED On") 49 | board.digital_write(BOARD_LED, 1) 50 | board.sleep(1.0) 51 | print("LED Off") 52 | board.digital_write(BOARD_LED, 0) 53 | board.sleep(1.0) 54 | 55 | 56 | if __name__ == "__main__": 57 | setup() 58 | while True: 59 | loop() 60 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot/RedBot_Experiments/Exp9_SerialDrive/Exp9_SerialDrive.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp9_SerialDrive -- RedBot Experiment 9 3 | * 4 | * The first step to controlling the RedBot remotely is to first drive it 5 | * from the Serial Monitor in a tethered setup. 6 | * 7 | * Hardware setup: 8 | * After uploading this sketch, keep the RedBot tethered to your computer with 9 | * the USB cable. Open up the Seral Monitor to send commands to the RedBot to 10 | * drive. 11 | * 12 | * This sketch was written by SparkFun Electronics, with lots of help from 13 | * the Arduino community. This code is completely free for any use. 14 | * 15 | * 15 Dec 2014 B. Huang 16 | * 17 | * This experiment was inspired by Paul Kassebaum at Mathworks, who made 18 | * one of the very first non-SparkFun demo projects and brought it to the 19 | * 2013 Open Hardware Summit in Boston. Thanks Paul! 20 | ***********************************************************************/ 21 | 22 | #include 23 | RedBotMotors motors; 24 | int motorPower; // variable for setting the drive power 25 | int data; // variable for holding incoming data from PC to Arduino 26 | 27 | void setup(void) 28 | { 29 | Serial.begin(9600); 30 | } 31 | 32 | void loop(void) 33 | { 34 | // if there is data coming in on the Serial monitor, do something with it. 35 | if(Serial.available() > 0) 36 | { 37 | data = Serial.parseInt(); 38 | data = constrain(data, -255, 255); // constrain the data to -255 to +255 39 | motors.drive(data); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot2/RedBot_Experiments/Exp9_SerialDrive/Exp9_SerialDrive.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp9_SerialDrive -- RedBot Experiment 9 3 | * 4 | * The first step to controlling the RedBot remotely is to first drive it 5 | * from the Serial Monitor in a tethered setup. 6 | * 7 | * Hardware setup: 8 | * After uploading this sketch, keep the RedBot tethered to your computer with 9 | * the USB cable. Open up the Seral Monitor to send commands to the RedBot to 10 | * drive. 11 | * 12 | * This sketch was written by SparkFun Electronics, with lots of help from 13 | * the Arduino community. This code is completely free for any use. 14 | * 15 | * 15 Dec 2014 B. Huang 16 | * 17 | * This experiment was inspired by Paul Kassebaum at Mathworks, who made 18 | * one of the very first non-SparkFun demo projects and brought it to the 19 | * 2013 Open Hardware Summit in Boston. Thanks Paul! 20 | ***********************************************************************/ 21 | 22 | #include 23 | RedBotMotors motors; 24 | int motorPower; // variable for setting the drive power 25 | int data; // variable for holding incoming data from PC to Arduino 26 | 27 | void setup(void) 28 | { 29 | Serial.begin(9600); 30 | } 31 | 32 | void loop(void) 33 | { 34 | // if there is data coming in on the Serial monitor, do something with it. 35 | if(Serial.available() > 0) 36 | { 37 | data = Serial.parseInt(); 38 | data = constrain(data, -255, 255); // constrain the data to -255 to +255 39 | motors.drive(data); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test/servo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Copyright (c) 2015 Alan Yorinks All rights reserved. 5 | 6 | This program is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public 8 | License as published by the Free Software Foundation; either 9 | version 3 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | """ 20 | 21 | """ 22 | This example illustrates manipulating a servo motor. 23 | """ 24 | 25 | from pymata_aio.pymata3 import PyMata3 26 | 27 | # instantiate PyMata with a 2 second start up delay to allow an Uno to complete its reset 28 | board = PyMata3(2) 29 | 30 | SERVO_MOTOR = 5 # servo attached to this pin 31 | 32 | # configure the servo 33 | board.servo_config(SERVO_MOTOR) 34 | 35 | for x in range(0, 3): 36 | # move the servo to 20 degrees 37 | board.analog_write(SERVO_MOTOR, 20) 38 | board.sleep(1) 39 | 40 | # move the servo to 100 degrees 41 | board.analog_write(SERVO_MOTOR, 100) 42 | board.sleep(1) 43 | 44 | # move the servo to 20 degrees 45 | board.analog_write(SERVO_MOTOR, 20) 46 | 47 | # close the interface down cleanly 48 | board.shutdown() 49 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/utility/ei_portc_speed.h: -------------------------------------------------------------------------------- 1 | #if defined MIGHTY1284 2 | #if defined INTERRUPT_FLAG_PIN16 3 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PIN16++; 4 | #endif 5 | #if defined INTERRUPT_FLAG_PIN17 6 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PIN17++; 7 | #endif 8 | #if defined INTERRUPT_FLAG_PIN18 9 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PIN18++; 10 | #endif 11 | #if defined INTERRUPT_FLAG_PIN19 12 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PIN19++; 13 | #endif 14 | #if defined INTERRUPT_FLAG_PIN20 15 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PIN20++; 16 | #endif 17 | #if defined INTERRUPT_FLAG_PIN21 18 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PIN21++; 19 | #endif 20 | #if defined INTERRUPT_FLAG_PIN22 21 | if (interruptMask & _BV(6)) INTERRUPT_FLAG_PIN22++; 22 | #endif 23 | #if defined INTERRUPT_FLAG_PIN23 24 | if (interruptMask & _BV(7)) INTERRUPT_FLAG_PIN23++; 25 | #endif 26 | #endif 27 | 28 | #if defined ARDUINO_328 29 | #if defined INTERRUPT_FLAG_PINA0 30 | if (interruptMask & _BV(0)) INTERRUPT_FLAG_PINA0++; 31 | #endif 32 | #if defined INTERRUPT_FLAG_PINA1 33 | if (interruptMask & _BV(1)) INTERRUPT_FLAG_PINA1++; 34 | #endif 35 | #if defined INTERRUPT_FLAG_PINA2 36 | if (interruptMask & _BV(2)) INTERRUPT_FLAG_PINA2++; 37 | #endif 38 | #if defined INTERRUPT_FLAG_PINA3 39 | if (interruptMask & _BV(3)) INTERRUPT_FLAG_PINA3++; 40 | #endif 41 | #if defined INTERRUPT_FLAG_PINA4 42 | if (interruptMask & _BV(4)) INTERRUPT_FLAG_PINA4++; 43 | #endif 44 | #if defined INTERRUPT_FLAG_PINA5 45 | if (interruptMask & _BV(5)) INTERRUPT_FLAG_PINA5++; 46 | #endif 47 | #endif 48 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/FirmataPlus/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Firmata 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Firmata KEYWORD1 10 | callbackFunction KEYWORD1 11 | systemResetCallbackFunction KEYWORD1 12 | stringCallbackFunction KEYWORD1 13 | sysexCallbackFunction KEYWORD1 14 | 15 | ####################################### 16 | # Methods and Functions (KEYWORD2) 17 | ####################################### 18 | 19 | begin KEYWORD2 20 | begin KEYWORD2 21 | printVersion KEYWORD2 22 | blinkVersion KEYWORD2 23 | printFirmwareVersion KEYWORD2 24 | setFirmwareVersion KEYWORD2 25 | setFirmwareNameAndVersion KEYWORD2 26 | available KEYWORD2 27 | processInput KEYWORD2 28 | sendAnalog KEYWORD2 29 | sendDigital KEYWORD2 30 | sendDigitalPortPair KEYWORD2 31 | sendDigitalPort KEYWORD2 32 | sendString KEYWORD2 33 | sendString KEYWORD2 34 | sendSysex KEYWORD2 35 | attach KEYWORD2 36 | detach KEYWORD2 37 | flush KEYWORD2 38 | 39 | 40 | ####################################### 41 | # Constants (LITERAL1) 42 | ####################################### 43 | 44 | MAX_DATA_BYTES LITERAL1 45 | 46 | DIGITAL_MESSAGE LITERAL1 47 | ANALOG_MESSAGE LITERAL1 48 | REPORT_ANALOG LITERAL1 49 | REPORT_DIGITAL LITERAL1 50 | REPORT_VERSION LITERAL1 51 | SET_PIN_MODE LITERAL1 52 | SYSTEM_RESET LITERAL1 53 | 54 | START_SYSEX LITERAL1 55 | END_SYSEX LITERAL1 56 | 57 | PWM LITERAL1 58 | 59 | TOTAL_ANALOG_PINS LITERAL1 60 | TOTAL_DIGITAL_PINS LITERAL1 61 | TOTAL_PORTS LITERAL1 62 | ANALOG_PORT LITERAL1 63 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/FirmataPlus32u4/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Firmata 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Firmata KEYWORD1 10 | callbackFunction KEYWORD1 11 | systemResetCallbackFunction KEYWORD1 12 | stringCallbackFunction KEYWORD1 13 | sysexCallbackFunction KEYWORD1 14 | 15 | ####################################### 16 | # Methods and Functions (KEYWORD2) 17 | ####################################### 18 | 19 | begin KEYWORD2 20 | begin KEYWORD2 21 | printVersion KEYWORD2 22 | blinkVersion KEYWORD2 23 | printFirmwareVersion KEYWORD2 24 | setFirmwareVersion KEYWORD2 25 | setFirmwareNameAndVersion KEYWORD2 26 | available KEYWORD2 27 | processInput KEYWORD2 28 | sendAnalog KEYWORD2 29 | sendDigital KEYWORD2 30 | sendDigitalPortPair KEYWORD2 31 | sendDigitalPort KEYWORD2 32 | sendString KEYWORD2 33 | sendString KEYWORD2 34 | sendSysex KEYWORD2 35 | attach KEYWORD2 36 | detach KEYWORD2 37 | flush KEYWORD2 38 | 39 | 40 | ####################################### 41 | # Constants (LITERAL1) 42 | ####################################### 43 | 44 | MAX_DATA_BYTES LITERAL1 45 | 46 | DIGITAL_MESSAGE LITERAL1 47 | ANALOG_MESSAGE LITERAL1 48 | REPORT_ANALOG LITERAL1 49 | REPORT_DIGITAL LITERAL1 50 | REPORT_VERSION LITERAL1 51 | SET_PIN_MODE LITERAL1 52 | SYSTEM_RESET LITERAL1 53 | 54 | START_SYSEX LITERAL1 55 | END_SYSEX LITERAL1 56 | 57 | PWM LITERAL1 58 | 59 | TOTAL_ANALOG_PINS LITERAL1 60 | TOTAL_DIGITAL_PINS LITERAL1 61 | TOTAL_PORTS LITERAL1 62 | ANALOG_PORT LITERAL1 63 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/FirmataPlusDue/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Firmata 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Firmata KEYWORD1 10 | callbackFunction KEYWORD1 11 | systemResetCallbackFunction KEYWORD1 12 | stringCallbackFunction KEYWORD1 13 | sysexCallbackFunction KEYWORD1 14 | 15 | ####################################### 16 | # Methods and Functions (KEYWORD2) 17 | ####################################### 18 | 19 | begin KEYWORD2 20 | begin KEYWORD2 21 | printVersion KEYWORD2 22 | blinkVersion KEYWORD2 23 | printFirmwareVersion KEYWORD2 24 | setFirmwareVersion KEYWORD2 25 | setFirmwareNameAndVersion KEYWORD2 26 | available KEYWORD2 27 | processInput KEYWORD2 28 | sendAnalog KEYWORD2 29 | sendDigital KEYWORD2 30 | sendDigitalPortPair KEYWORD2 31 | sendDigitalPort KEYWORD2 32 | sendString KEYWORD2 33 | sendString KEYWORD2 34 | sendSysex KEYWORD2 35 | attach KEYWORD2 36 | detach KEYWORD2 37 | flush KEYWORD2 38 | 39 | 40 | ####################################### 41 | # Constants (LITERAL1) 42 | ####################################### 43 | 44 | MAX_DATA_BYTES LITERAL1 45 | 46 | DIGITAL_MESSAGE LITERAL1 47 | ANALOG_MESSAGE LITERAL1 48 | REPORT_ANALOG LITERAL1 49 | REPORT_DIGITAL LITERAL1 50 | REPORT_VERSION LITERAL1 51 | SET_PIN_MODE LITERAL1 52 | SYSTEM_RESET LITERAL1 53 | 54 | START_SYSEX LITERAL1 55 | END_SYSEX LITERAL1 56 | 57 | PWM LITERAL1 58 | 59 | TOTAL_ANALOG_PINS LITERAL1 60 | TOTAL_DIGITAL_PINS LITERAL1 61 | TOTAL_PORTS LITERAL1 62 | ANALOG_PORT LITERAL1 63 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/FirmataPlusLBT/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Firmata 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Firmata KEYWORD1 10 | callbackFunction KEYWORD1 11 | systemResetCallbackFunction KEYWORD1 12 | stringCallbackFunction KEYWORD1 13 | sysexCallbackFunction KEYWORD1 14 | 15 | ####################################### 16 | # Methods and Functions (KEYWORD2) 17 | ####################################### 18 | 19 | begin KEYWORD2 20 | begin KEYWORD2 21 | printVersion KEYWORD2 22 | blinkVersion KEYWORD2 23 | printFirmwareVersion KEYWORD2 24 | setFirmwareVersion KEYWORD2 25 | setFirmwareNameAndVersion KEYWORD2 26 | available KEYWORD2 27 | processInput KEYWORD2 28 | sendAnalog KEYWORD2 29 | sendDigital KEYWORD2 30 | sendDigitalPortPair KEYWORD2 31 | sendDigitalPort KEYWORD2 32 | sendString KEYWORD2 33 | sendString KEYWORD2 34 | sendSysex KEYWORD2 35 | attach KEYWORD2 36 | detach KEYWORD2 37 | flush KEYWORD2 38 | 39 | 40 | ####################################### 41 | # Constants (LITERAL1) 42 | ####################################### 43 | 44 | MAX_DATA_BYTES LITERAL1 45 | 46 | DIGITAL_MESSAGE LITERAL1 47 | ANALOG_MESSAGE LITERAL1 48 | REPORT_ANALOG LITERAL1 49 | REPORT_DIGITAL LITERAL1 50 | REPORT_VERSION LITERAL1 51 | SET_PIN_MODE LITERAL1 52 | SYSTEM_RESET LITERAL1 53 | 54 | START_SYSEX LITERAL1 55 | END_SYSEX LITERAL1 56 | 57 | PWM LITERAL1 58 | 59 | TOTAL_ANALOG_PINS LITERAL1 60 | TOTAL_DIGITAL_PINS LITERAL1 61 | TOTAL_PORTS LITERAL1 62 | ANALOG_PORT LITERAL1 63 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Pixy/PixyUART.h: -------------------------------------------------------------------------------- 1 | // 2 | // begin license header 3 | // 4 | // This file is part of Pixy CMUcam5 or "Pixy" for short 5 | // 6 | // All Pixy source code is provided under the terms of the 7 | // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html). 8 | // Those wishing to use Pixy source code, software and/or 9 | // technologies under different licensing terms should contact us at 10 | // cmucam@cs.cmu.edu. Such licensing terms are available for 11 | // all portions of the Pixy codebase presented here. 12 | // 13 | // end license header 14 | // 15 | // This file is for defining the link class for UART communications. 16 | // 17 | 18 | #ifndef _PIXYUART_H 19 | #define _PIXYUART_H 20 | 21 | #include "TPixy.h" 22 | #include "Arduino.h" 23 | 24 | class LinkUART 25 | { 26 | public: 27 | void init() 28 | { 29 | Serial1.begin(19200); 30 | } 31 | void setArg(uint16_t arg) 32 | { 33 | } 34 | uint16_t getWord() 35 | { 36 | int16_t u, v; 37 | 38 | while(1) 39 | { 40 | u = Serial1.read(); 41 | if (u>=0) 42 | break; 43 | } 44 | while(1) 45 | { 46 | v = Serial1.read(); 47 | if (v>=0) 48 | break; 49 | } 50 | v <<= 8; 51 | v |= u&0xff; 52 | return v; 53 | } 54 | uint8_t getByte() 55 | { 56 | int16_t u; 57 | 58 | while(1) 59 | { 60 | u = Serial1.read(); 61 | if (u>=0) 62 | break; 63 | } 64 | return (uint8_t)u; 65 | } 66 | int8_t send(uint8_t *data, uint8_t len) 67 | { 68 | return Serial1.write(data, len); 69 | } 70 | }; 71 | 72 | typedef TPixy PixyUART; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /examples/control_C_handlers/for_pymata3.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """ 3 | Turns on an LED on for one second, then off for one second, repeatedly. 4 | 5 | Most Arduinos have an on-board LED you can control. On the Uno and 6 | Leonardo, it is attached to digital pin 13. If you're unsure what 7 | pin the on-board LED is connected to on your Arduino model, check 8 | the documentation at http://www.arduino.cc 9 | """ 10 | 11 | from pymata_aio.pymata3 import PyMata3 12 | from pymata_aio.constants import Constants 13 | import signal 14 | import sys 15 | 16 | 17 | BOARD_LED = 13 18 | 19 | 20 | # Signal handler to trap control C 21 | def _signal_handler(sig, frame): 22 | if board is not None: 23 | print('\nYou pressed Ctrl+C') 24 | sys.exit(1) 25 | 26 | 27 | signal.signal(signal.SIGINT, _signal_handler) 28 | signal.signal(signal.SIGTERM, _signal_handler) 29 | 30 | # add SIGALRM if platform is not windows 31 | if not sys.platform.startswith('win32'): 32 | signal.signal(signal.SIGALRM, _signal_handler) 33 | 34 | 35 | def setup(): 36 | board.set_pin_mode(BOARD_LED, Constants.OUTPUT) 37 | 38 | 39 | def loop(): 40 | print("LED On") 41 | board.digital_write(BOARD_LED, 1) 42 | board.sleep(1.0) 43 | print("LED Off") 44 | board.digital_write(BOARD_LED, 0) 45 | board.sleep(1.0) 46 | 47 | 48 | if __name__ == "__main__": 49 | board = PyMata3() 50 | try: 51 | setup() 52 | while True: 53 | loop() 54 | board.sleep(.1) 55 | # control-C can cause exceptions - the following suppresses them 56 | except RuntimeError: 57 | board.shutdown() 58 | sys.exit(0) 59 | 60 | 61 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Pixy/examples/i2c/i2c.ino: -------------------------------------------------------------------------------- 1 | // 2 | // begin license header 3 | // 4 | // This file is part of Pixy CMUcam5 or "Pixy" for short 5 | // 6 | // All Pixy source code is provided under the terms of the 7 | // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html). 8 | // Those wishing to use Pixy source code, software and/or 9 | // technologies under different licensing terms should contact us at 10 | // cmucam@cs.cmu.edu. Such licensing terms are available for 11 | // all portions of the Pixy codebase presented here. 12 | // 13 | // end license header 14 | // 15 | // This sketch is like hello_world but uses I2C communications. If you're 16 | // not sure what I2C is, run the hello_world sketch! 17 | // 18 | 19 | #include 20 | #include 21 | 22 | 23 | PixyI2C pixy; 24 | // PixyI2C pixy(0x55); // You can set the I2C address through PixyI2C object 25 | 26 | void setup() 27 | { 28 | Serial.begin(9600); 29 | Serial.print("Starting...\n"); 30 | 31 | pixy.init(); 32 | } 33 | 34 | 35 | void loop() 36 | { 37 | static int i = 0; 38 | int j; 39 | uint16_t blocks; 40 | char buf[32]; 41 | 42 | blocks = pixy.getBlocks(); 43 | 44 | if (blocks) 45 | { 46 | i++; 47 | 48 | // do this (print) every 50 frames because printing every 49 | // frame would bog down the Arduino 50 | if (i%50==0) 51 | { 52 | sprintf(buf, "Detected %d:\n", blocks); 53 | Serial.print(buf); 54 | for (j=0; j 17 | RedBotMotors motors; 18 | 19 | // Create a couple of constants for our pins. 20 | const int buzzerPin = 9; 21 | const int buttonPin = 12; 22 | 23 | void setup() 24 | { 25 | pinMode(buttonPin, INPUT_PULLUP); // configures the button as an INPUT 26 | // INPUT_PULLUP defaults it to HIGH. 27 | pinMode(buzzerPin, OUTPUT); // configures the buzzerPin as an OUTPUT 28 | } 29 | 30 | void loop() 31 | { 32 | if ( digitalRead(buttonPin) == LOW ) // if the button is pushed (LOW) 33 | { 34 | tone(buzzerPin, 1000); // Play a 1kHz tone on the pin number held in 35 | // the variable "buzzerPin". 36 | delay(125); // Wait for 125ms. 37 | noTone(buzzerPin); // Stop playing the tone. 38 | 39 | tone(buzzerPin, 2000); // Play a 2kHz tone on the buzzer pin 40 | 41 | motors.drive(255); // Start the motors. The whiskers will stop them. 42 | delay(1000); // delay for 1000 ms (1 second) 43 | 44 | noTone(buzzerPin); // Stop playing the tone. 45 | motors.brake(); // brake() or stop the motors. 46 | } 47 | else // otherwise, do this. 48 | { 49 | } 50 | } 51 | 52 | 53 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot2/RedBot_Experiments/Exp4_MakingSounds/Exp4_MakingSounds.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp4_MakingSounds -- RedBot Experiment 4 3 | * 4 | * Push the button (D12) to make some noise and start running! 5 | * 6 | * Hardware setup: 7 | * Plug the included RedBot Buzzer board into the Servo header labeled 9. 8 | * 9 | * This sketch was written by SparkFun Electronics,with lots of help from 10 | * the Arduino community. This code is completely free for any use. 11 | * 12 | * 23 Sept 2013 N. Seidle/M. Hord 13 | * 29 Oct 2014 B. Huang 14 | ***********************************************************************/ 15 | 16 | #include 17 | RedBotMotors motors; 18 | 19 | // Create a couple of constants for our pins. 20 | const int buzzerPin = 9; 21 | const int buttonPin = 12; 22 | 23 | void setup() 24 | { 25 | pinMode(buttonPin, INPUT_PULLUP); // configures the button as an INPUT 26 | // INPUT_PULLUP defaults it to HIGH. 27 | pinMode(buzzerPin, OUTPUT); // configures the buzzerPin as an OUTPUT 28 | } 29 | 30 | void loop() 31 | { 32 | if ( digitalRead(buttonPin) == LOW ) // if the button is pushed (LOW) 33 | { 34 | tone(buzzerPin, 1000); // Play a 1kHz tone on the pin number held in 35 | // the variable "buzzerPin". 36 | delay(125); // Wait for 125ms. 37 | noTone(buzzerPin); // Stop playing the tone. 38 | 39 | tone(buzzerPin, 2000); // Play a 2kHz tone on the buzzer pin 40 | 41 | motors.drive(255); // Start the motors. The whiskers will stop them. 42 | delay(1000); // delay for 1000 ms (1 second) 43 | 44 | noTone(buzzerPin); // Stop playing the tone. 45 | motors.brake(); // brake() or stop the motors. 46 | } 47 | else // otherwise, do this. 48 | { 49 | } 50 | } 51 | 52 | 53 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/utility/ei_PinChangeTiny24.h: -------------------------------------------------------------------------------- 1 | #ifdef EI_SECTION_RISING 2 | #ifndef EI_NOTPORTA 3 | if (portNumber==PA) { 4 | risingPinsPORTA |= portMask; 5 | } 6 | #endif 7 | #ifndef EI_NOTPORTB 8 | if (portNumber==PB) { 9 | risingPinsPORTB |= portMask; 10 | } 11 | #endif 12 | #endif // EI_SECTION_RISING 13 | 14 | #ifdef EI_SECTION_FALLING 15 | #ifndef EI_NOTPORTA 16 | if (portNumber==PA) { 17 | fallingPinsPORTA |= portMask; 18 | } 19 | #endif 20 | #ifndef EI_NOTPORTB 21 | if (portNumber==PB) { 22 | fallingPinsPORTB |= portMask; 23 | } 24 | #endif 25 | #endif // EI_SECTION_FALLING 26 | 27 | #if defined EI_SECTION_ASSIGNFUNCTIONSREGISTERS 28 | #ifndef EI_NOTPORTA 29 | if (portNumber==PA) { 30 | #ifndef NEEDFORSPEED 31 | calculatedPointer=&portAFunctions.pinZero + portBitNumber; 32 | *calculatedPointer = userFunction; 33 | #endif 34 | portSnapshotA=*portInputRegister(portNumber); 35 | pcmsk=&PCMSK0; 36 | GIMSK |= _BV(4); 37 | } 38 | #endif 39 | #ifndef EI_NOTPORTB 40 | if (portNumber==PB) { 41 | #ifndef NEEDFORSPEED 42 | calculatedPointer=&portBFunctions.pinZero + portBitNumber; 43 | *calculatedPointer = userFunction; 44 | #endif 45 | portSnapshotB=*portInputRegister(portNumber); 46 | pcmsk=&PCMSK1; 47 | GIMSK |= _BV(5); 48 | } 49 | #endif 50 | #endif // EI_SECTION_ASSIGNFUNCTIONSREGISTERS 51 | 52 | #ifdef EI_SECTION_DISABLEPINCHANGE 53 | #ifndef EI_NOTPORTA 54 | if (portNumber == PA) { 55 | PCMSK0 &= ~portMask; 56 | if (PCMSK0 == 0) { GIMSK &= ~_BV(4); }; 57 | risingPinsPORTA &= ~portMask; 58 | fallingPinsPORTA &= ~portMask; 59 | } 60 | #endif 61 | #ifndef EI_NOTPORTB 62 | if (portNumber == PB) { 63 | PCMSK1 &= ~portMask; 64 | if (PCMSK1 == 0) { GIMSK &= ~_BV(5); }; 65 | risingPinsPORTB &= ~portMask; 66 | fallingPinsPORTB &= ~portMask; 67 | } 68 | #endif 69 | #endif // EI_SECTION_DISABLEPINCHANGE 70 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Firmata/examples/ServoFirmata/ServoFirmata.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Firmata is a generic protocol for communicating with microcontrollers 3 | * from software on a host computer. It is intended to work with 4 | * any host computer software package. 5 | * 6 | * To download a host software package, please clink on the following link 7 | * to open the download page in your default browser. 8 | * 9 | * http://firmata.org/wiki/Download 10 | */ 11 | 12 | /* This firmware supports as many servos as possible using the Servo library 13 | * included in Arduino 0017 14 | * 15 | * This example code is in the public domain. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | Servo servos[MAX_SERVOS]; 22 | byte servoPinMap[TOTAL_PINS]; 23 | byte servoCount = 0; 24 | 25 | void analogWriteCallback(byte pin, int value) 26 | { 27 | if (IS_PIN_DIGITAL(pin)) { 28 | servos[servoPinMap[pin]].write(value); 29 | } 30 | } 31 | 32 | void systemResetCallback() 33 | { 34 | servoCount = 0; 35 | } 36 | 37 | void setup() 38 | { 39 | byte pin; 40 | 41 | Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION); 42 | Firmata.attach(ANALOG_MESSAGE, analogWriteCallback); 43 | Firmata.attach(SYSTEM_RESET, systemResetCallback); 44 | 45 | Firmata.begin(57600); 46 | systemResetCallback(); 47 | 48 | // attach servos from first digital pin up to max number of 49 | // servos supported for the board 50 | for (pin = 0; pin < TOTAL_PINS; pin++) { 51 | if (IS_PIN_DIGITAL(pin)) { 52 | if (servoCount < MAX_SERVOS) { 53 | servoPinMap[pin] = servoCount; 54 | servos[servoPinMap[pin]].attach(PIN_TO_DIGITAL(pin)); 55 | servoCount++; 56 | } 57 | } 58 | } 59 | } 60 | 61 | void loop() 62 | { 63 | while (Firmata.available()) 64 | Firmata.processInput(); 65 | } 66 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/ATtinyBlink/ATtinyBlink.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef EI_ATTINY24 4 | #define OUTPUTPIN 10 // == B0 5 | #define INTERRUPTEDPIN 9 // == B1 6 | // Modify this at your leisure. But you must be aware of which port it's on (see below). 7 | #elif defined EI_ATTINY25 8 | #define OUTPUTPIN 0 // == B0 9 | #define INTERRUPTEDPIN 1 // == B1 10 | #else 11 | #error Dang, only ATtiny chips supported by this sketch. 12 | #endif 13 | 14 | // Connect a LED to Pin 3. It might be different in different ATtiny micro controllers 15 | //const uint8_t outputBitMask = 0x01; 16 | const uint8_t outputBitMask = digital_pin_to_bit_mask_PGM[OUTPUTPIN]; 17 | const uint8_t inputBitMask = digital_pin_to_bit_mask_PGM[INTERRUPTEDPIN]; 18 | 19 | volatile uint16_t endlessCounter=0; // The count will go back to 0 after hitting 65535. 20 | volatile uint8_t interruptState=0; 21 | 22 | void interruptFunction() { 23 | if (interruptState) { 24 | interruptState=0; 25 | PORTB &= ~_BV(outputBitMask); 26 | } else { 27 | interruptState=1; 28 | PORTB |= 1 << outputBitMask; 29 | } 30 | } 31 | 32 | // the setup routine runs once when you press reset: 33 | void setup() { 34 | DDRB |= outputBitMask; // OUTPUTPIN is set to output 35 | DDRB &= ~inputBitMask; // INPUTPIN is set to input 36 | PORTB |= inputBitMask; // Pull up the resistor 37 | MCUCR &= ~PUD; // ensure Pull Up Disable is off 38 | enableInterrupt(INTERRUPTEDPIN, interruptFunction, CHANGE); 39 | } 40 | 41 | // the loop routine runs over and over again forever: 42 | void loop() { 43 | //digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) 44 | //delay(1000); // wait for a second 45 | //digitalWrite(led, LOW); // turn the LED off by making the voltage LOW 46 | //delay(1000); // wait for a second 47 | endlessCounter++; // give it something to do 48 | } 49 | -------------------------------------------------------------------------------- /test/stepper.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | 4 | """ 5 | Copyright (c) 2013 Alan Yorinks All rights reserved. 6 | This program is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public 8 | License as published by the Free Software Foundation; either 9 | version 3 of the License, or (at your option) any later version. 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | General Public License for more details. 14 | You should have received a copy of the GNU General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | 18 | """ 19 | 20 | """ 21 | This file demonstrates using PyMata to control a stepper motor. It requires the use of the FirmataPlus 22 | Arduino sketch included with this release. 23 | 24 | It is based upon the following tutorial: https://learn.adafruit.com/adafruit-arduino-lesson-16-stepper-motors/overview 25 | """ 26 | 27 | 28 | from pymata_aio.pymata3 import PyMata3 29 | 30 | 31 | # create a PyMata instance 32 | # ping callback function 33 | def vr(data): 34 | # print('hello') 35 | print('version') 36 | print(data) 37 | 38 | # create a PyMata instance 39 | # create a PyMata instance 40 | firmata = PyMata3(2) 41 | 42 | # send the arduino a firmata reset 43 | firmata.send_reset() 44 | 45 | # configure the stepper to use pins 9.10,11,12 and specify 512 steps per revolution 46 | firmata.stepper_config(180, [8, 9, 10, 11]) 47 | 48 | # allow time for config to complete 49 | firmata.sleep(.5) 50 | 51 | 52 | # move motor #0 500 steps forward at a speed of 20 53 | firmata.stepper_step(20, 500) 54 | 55 | # firmata.sleep(4) 56 | 57 | # move motor #0 500 steps reverse at a speed of 20 58 | # firmata.stepper_step(20, -500) 59 | 60 | # close firmata 61 | firmata.shutdown() 62 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/utility/ei_External1284.h: -------------------------------------------------------------------------------- 1 | #if ! defined(EI_NOTINT0) && ! defined (EI_NOTINT1) && ! defined (EI_NOTINT2) 2 | #ifdef EI_SECTION_ENABLEEXTERNAL 3 | switch (arduinoPin) { 4 | #ifndef EI_NOTINT0 5 | case 10 : // INT0 6 | EIMSK &= ~_BV(0); 7 | #ifndef NEEDFORSPEED 8 | functionPointerArrayEXTERNAL[0] = userFunction; 9 | #endif 10 | EICRA &= (~_BV(0) & ~_BV(1)); // reset the flags prior to 11 | EICRA |= mode; // set them the way we want 12 | EIFR |= _BV(0); 13 | EIMSK |= _BV(0); 14 | break; 15 | #endif 16 | #ifndef EI_NOTINT1 17 | case 11 : // INT1 18 | EIMSK &= ~_BV(1); 19 | #ifndef NEEDFORSPEED 20 | functionPointerArrayEXTERNAL[1] = userFunction; 21 | #endif 22 | EICRA &= (~_BV(2) & ~_BV(3)); 23 | EICRA |= (mode << 2); 24 | EIFR |= _BV(1); 25 | EIMSK |= _BV(1); 26 | break; 27 | #endif 28 | #ifndef EI_NOTINT2 29 | case 2 : // INT2 30 | EIMSK &= ~_BV(2); 31 | #ifndef NEEDFORSPEED 32 | functionPointerArrayEXTERNAL[2] = userFunction; 33 | #endif 34 | EICRA &= (~_BV(4) & ~_BV(5)); 35 | EICRA |= (mode << 4); 36 | EIFR |= _BV(2); 37 | EIMSK |= _BV(2); 38 | break; 39 | #endif 40 | } 41 | #endif // EI_SECTION_ENABLEEXTERNAL 42 | 43 | #ifdef EI_SECTION_DISABLEEXTERNAL 44 | #ifndef EI_NOTINT0 45 | if (arduinoPin == 10) { 46 | EIMSK &= ~_BV(0); 47 | EICRA &= (~_BV(0) & ~_BV(1)); 48 | EIFR |= _BV(0); // using a clue from the ATmega2560 datasheet. 49 | } 50 | #endif 51 | #ifndef EI_NOTINT1 52 | if (arduinoPin == 11) { 53 | EIMSK &= ~_BV(1); 54 | EICRA &= (~_BV(2) & ~_BV(3)); 55 | EIFR |= _BV(1); // using a clue from the ATmega2560 datasheet. 56 | } 57 | #endif 58 | #ifndef EI_NOTINT2 59 | if (arduinoPin == 2) { 60 | EIMSK &= ~_BV(2); 61 | EICRA &= (~_BV(4) & ~_BV(5)); 62 | EIFR |= _BV(2); // using a clue from the ATmega2560 datasheet. 63 | } 64 | #endif 65 | #endif // EI_SECTION_DISABLEEXTERNAL 66 | #endif // ! defined(EI_NOTINT0) && ! defined (EI_NOTINT1) && ! defined (EI_NOTINT2) 67 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Pixy/PixyI2C.h: -------------------------------------------------------------------------------- 1 | // 2 | // begin license header 3 | // 4 | // This file is part of Pixy CMUcam5 or "Pixy" for short 5 | // 6 | // All Pixy source code is provided under the terms of the 7 | // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html). 8 | // Those wishing to use Pixy source code, software and/or 9 | // technologies under different licensing terms should contact us at 10 | // cmucam@cs.cmu.edu. Such licensing terms are available for 11 | // all portions of the Pixy codebase presented here. 12 | // 13 | // end license header 14 | // 15 | // This file is for defining the link class for I2C communications. 16 | // 17 | // Note, the PixyI2C class takes an optional argument, which is the I2C address 18 | // of the Pixy you want to talk to. The default address is 0x54 (used when no 19 | // argument is used.) So, for example, if you wished to talk to Pixy at I2C 20 | // address 0x55, declare like this: 21 | // 22 | // PixyI2C pixy(0x55); 23 | // 24 | 25 | #ifndef _PIXYI2C_H 26 | #define _PIXYI2C_H 27 | 28 | #include "TPixy.h" 29 | #include "Wire.h" 30 | 31 | #define PIXY_I2C_DEFAULT_ADDR 0x54 32 | 33 | class LinkI2C 34 | { 35 | public: 36 | void init() 37 | { 38 | Wire.begin(); 39 | } 40 | void setArg(uint16_t arg) 41 | { 42 | if (arg==PIXY_DEFAULT_ARGVAL) 43 | addr = PIXY_I2C_DEFAULT_ADDR; 44 | else 45 | addr = arg; 46 | } 47 | uint16_t getWord() 48 | { 49 | uint16_t w; 50 | uint8_t c; 51 | Wire.requestFrom((int)addr, 2); 52 | c = Wire.read(); 53 | w = Wire.read(); 54 | w <<= 8; 55 | w |= c; 56 | return w; 57 | } 58 | uint8_t getByte() 59 | { 60 | Wire.requestFrom((int)addr, 1); 61 | return Wire.read(); 62 | } 63 | 64 | int8_t send(uint8_t *data, uint8_t len) 65 | { 66 | Wire.beginTransmission(addr); 67 | Wire.write(data, len); 68 | Wire.endTransmission(); 69 | return len; 70 | } 71 | 72 | private: 73 | uint8_t addr; 74 | }; 75 | 76 | typedef TPixy PixyI2C; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /examples/control_C_handlers/for_core.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """ 3 | Turns on an LED on for one second, then off for one second, repeatedly. 4 | 5 | Most Arduinos have an on-board LED you can control. On the Uno and 6 | Leonardo, it is attached to digital pin 13. If you're unsure what 7 | pin the on-board LED is connected to on your Arduino model, check 8 | the documentation at http://www.arduino.cc 9 | """ 10 | 11 | import asyncio 12 | 13 | from pymata_aio.pymata_core import PymataCore 14 | from pymata_aio.constants import Constants 15 | import sys 16 | import signal 17 | 18 | 19 | # Signal handler to trap control C 20 | def _signal_handler(sig, frame): 21 | print('\nYou pressed Ctrl+C') 22 | if board is not None: 23 | loop.run_until_complete(board.shutdown()) 24 | 25 | signal.signal(signal.SIGINT, _signal_handler) 26 | signal.signal(signal.SIGTERM, _signal_handler) 27 | 28 | # add SIGALRM if not platform is not windows 29 | if not sys.platform.startswith('win32'): 30 | signal.signal(signal.SIGALRM, _signal_handler) 31 | 32 | # your code goes here 33 | async def blink(my_board): 34 | """ 35 | Blink LED 13 36 | @return: No Return Value 37 | """ 38 | # set the pin mode 39 | await my_board.set_pin_mode(13, Constants.OUTPUT) 40 | 41 | for i in range(0, 5): 42 | await my_board.digital_write(13, 1) 43 | await asyncio.sleep(1) 44 | await my_board.digital_write(13, 0) 45 | await asyncio.sleep(1) 46 | 47 | 48 | if __name__ == "__main__": 49 | # create a PyMataCore instance and complete the initialization with a call to start_aio() 50 | board = PymataCore() 51 | 52 | loop = asyncio.get_event_loop() 53 | loop.run_until_complete(board.start_aio()) 54 | 55 | # now execute your code on the loop and shutdown when done 56 | try: 57 | loop.run_until_complete(blink(board)) 58 | loop.run_until_complete(board.shutdown()) 59 | except RuntimeError: 60 | loop.run_until_complete(board.shutdown()) 61 | exit(0) 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Pixy/examples/uart/uart.ino: -------------------------------------------------------------------------------- 1 | // 2 | // begin license header 3 | // 4 | // This file is part of Pixy CMUcam5 or "Pixy" for short 5 | // 6 | // All Pixy source code is provided under the terms of the 7 | // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html). 8 | // Those wishing to use Pixy source code, software and/or 9 | // technologies under different licensing terms should contact us at 10 | // cmucam@cs.cmu.edu. Such licensing terms are available for 11 | // all portions of the Pixy codebase presented here. 12 | // 13 | // end license header 14 | // 15 | // This sketch is like hello_world but uses UART communications. If you're 16 | // not sure what UART is, run the hello_world sketch! 17 | // 18 | // Note, the default baudrate for Pixy's UART communications is 19200. Given 19 | // the slow datarate and Arduino's shallow serial FIFO, this sletch sometimes 20 | // gets checksum errors, when more than 1 block is present. This is because 21 | // printing more than 1 object block to the serial console (as this sketch does) 22 | // causes the Arduino's serial FIFO to overrun, which leads to communication 23 | // errors. 24 | // 25 | 26 | #include "PixyUART.h" 27 | 28 | 29 | PixyUART pixy; 30 | 31 | void setup() 32 | { 33 | Serial.begin(9600); // 9600 baud for the serial *console* (not for the UART connected to Pixy) 34 | Serial.print("Starting...\n"); 35 | 36 | pixy.init(); 37 | } 38 | 39 | void loop() 40 | { 41 | static int i = 0; 42 | int j; 43 | uint16_t blocks; 44 | char buf[32]; 45 | 46 | blocks = pixy.getBlocks(); 47 | 48 | if (blocks) 49 | { 50 | i++; 51 | 52 | // do this (print) every 50 frames because printing every 53 | // frame would bog down the Arduino 54 | if (i%50==0) 55 | { 56 | sprintf(buf, "Detected %d:\n", blocks); 57 | Serial.print(buf); 58 | for (j=0; j 27 | #include 28 | 29 | // This is the main Pixy object 30 | Pixy pixy; 31 | 32 | void setup() 33 | { 34 | Serial.begin(9600); 35 | Serial.print("Starting...\n"); 36 | 37 | pixy.init(); 38 | } 39 | 40 | void loop() 41 | { 42 | static int i = 0; 43 | int j; 44 | uint16_t blocks; 45 | char buf[32]; 46 | 47 | // grab blocks! 48 | blocks = pixy.getBlocks(); 49 | 50 | // If there are detect blocks, print them! 51 | if (blocks) 52 | { 53 | i++; 54 | 55 | // do this (print) every 50 frames because printing every 56 | // frame would bog down the Arduino 57 | if (i%50==0) 58 | { 59 | sprintf(buf, "Detected %d:\n", blocks); 60 | Serial.print(buf); 61 | for (j=0; j 17 | RedBotMotors motors; 18 | 19 | RedBotEncoder encoder = RedBotEncoder(A2, 10); // initializes encoder on pins A2 and 10 20 | int buttonPin = 12; 21 | int countsPerRev = 192; // 4 pairs of N-S x 48:1 gearbox = 192 ticks per wheel rev 22 | 23 | // variables used to store the left and right encoder counts. 24 | int lCount; 25 | int rCount; 26 | 27 | void setup() 28 | { 29 | pinMode(buttonPin, INPUT_PULLUP); 30 | Serial.begin(9600); 31 | Serial.println("left right"); 32 | Serial.println("================"); 33 | } 34 | 35 | void loop(void) 36 | { 37 | // wait for a button press to start driving. 38 | if (digitalRead(buttonPin) == LOW) 39 | { 40 | encoder.clearEnc(BOTH); // Reset the counters. 41 | motors.drive(150); // Start driving forward. 42 | } 43 | 44 | // store the encoder counts to a variable. 45 | lCount = encoder.getTicks(LEFT); // read the left motor encoder 46 | rCount = encoder.getTicks(RIGHT); // read the right motor encoder 47 | 48 | // print out to Serial Monitor the left and right encoder counts. 49 | Serial.print(lCount); 50 | Serial.print("\t"); 51 | Serial.println(rCount); 52 | 53 | // if either left or right motor are more than 5 revolutions, stop 54 | if ((lCount >= 5*countsPerRev) || (rCount >= 5*countsPerRev) ) 55 | { 56 | motors.brake(); 57 | } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot2/RedBot_Experiments/Exp7_1_RotaryEncoder/Exp7_1_RotaryEncoder.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp7_1_RotaryEncoder -- RedBot Experiment 7 3 | * 4 | * Knowing where your robot is can be very important. The RedBot supports 5 | * the use of an encoder to track the number of revolutions each wheels has 6 | * made, so you can tell not only how far each wheel has traveled but how 7 | * fast the wheels are turning. 8 | * 9 | * This sketch was written by SparkFun Electronics, with lots of help from 10 | * the Arduino community. This code is completely free for any use. 11 | * 12 | * 8 Oct 2013 M. Hord 13 | * Revised, 31 Oct 2014 B. Huang 14 | ***********************************************************************/ 15 | 16 | #include 17 | RedBotMotors motors; 18 | 19 | RedBotEncoder encoder = RedBotEncoder(A2, 10); // initializes encoder on pins A2 and 10 20 | int buttonPin = 12; 21 | int countsPerRev = 192; // 4 pairs of N-S x 48:1 gearbox = 192 ticks per wheel rev 22 | 23 | // variables used to store the left and right encoder counts. 24 | int lCount; 25 | int rCount; 26 | 27 | void setup() 28 | { 29 | pinMode(buttonPin, INPUT_PULLUP); 30 | Serial.begin(9600); 31 | Serial.println("left right"); 32 | Serial.println("================"); 33 | } 34 | 35 | void loop(void) 36 | { 37 | // wait for a button press to start driving. 38 | if (digitalRead(buttonPin) == LOW) 39 | { 40 | encoder.clearEnc(BOTH); // Reset the counters. 41 | motors.drive(150); // Start driving forward. 42 | } 43 | 44 | // store the encoder counts to a variable. 45 | lCount = encoder.getTicks(LEFT); // read the left motor encoder 46 | rCount = encoder.getTicks(RIGHT); // read the right motor encoder 47 | 48 | // print out to Serial Monitor the left and right encoder counts. 49 | Serial.print(lCount); 50 | Serial.print("\t"); 51 | Serial.println(rCount); 52 | 53 | // if either left or right motor are more than 5 revolutions, stop 54 | if ((lCount >= 5*countsPerRev) || (rCount >= 5*countsPerRev) ) 55 | { 56 | motors.brake(); 57 | } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /examples/sparkfun_redbot/basics/simple_drive.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Drives the RedBot motors around without using a library at all. 4 | """ 5 | 6 | from pymata_aio.pymata3 import PyMata3 7 | from pymata_aio.constants import Constants 8 | 9 | # RedBot motor pins from RedBot.h 10 | L_CTRL_1 = 2 11 | L_CTRL_2 = 4 12 | PWM_L = 5 13 | 14 | R_CTRL_1 = 7 15 | R_CTRL_2 = 8 16 | PWM_R = 6 17 | 18 | board = PyMata3() 19 | 20 | 21 | def setup(): 22 | """Setup pins""" 23 | print("Simple drive") 24 | board.set_pin_mode(L_CTRL_1, Constants.OUTPUT) 25 | board.set_pin_mode(L_CTRL_2, Constants.OUTPUT) 26 | board.set_pin_mode(PWM_L, Constants.PWM) 27 | board.set_pin_mode(R_CTRL_1, Constants.OUTPUT) 28 | board.set_pin_mode(R_CTRL_2, Constants.OUTPUT) 29 | board.set_pin_mode(PWM_R, Constants.PWM) 30 | 31 | 32 | def loop(): 33 | """Function that gets called again as soon as it finishes (forever).""" 34 | print("Straight") 35 | board.digital_write(L_CTRL_1, 1) 36 | board.digital_write(L_CTRL_2, 0) 37 | board.analog_write(PWM_L, 245) 38 | board.digital_write(R_CTRL_1, 1) 39 | board.digital_write(R_CTRL_2, 0) 40 | board.analog_write(PWM_R, 245) 41 | board.sleep(2.0) 42 | 43 | print("CW spin") 44 | board.digital_write(L_CTRL_1, 1) 45 | board.digital_write(L_CTRL_2, 0) 46 | board.analog_write(PWM_L, 245) 47 | board.digital_write(R_CTRL_1, 0) 48 | board.digital_write(R_CTRL_2, 1) 49 | board.analog_write(PWM_R, 245) 50 | board.sleep(2.0) 51 | 52 | print("CCW spin") 53 | board.digital_write(L_CTRL_1, 0) 54 | board.digital_write(L_CTRL_2, 1) 55 | board.analog_write(PWM_L, 245) 56 | board.digital_write(R_CTRL_1, 1) 57 | board.digital_write(R_CTRL_2, 0) 58 | board.analog_write(PWM_R, 245) 59 | board.sleep(2.0) 60 | 61 | print("Stop") 62 | board.digital_write(L_CTRL_1, 1) 63 | board.digital_write(L_CTRL_2, 0) 64 | board.analog_write(PWM_L, 0) 65 | board.digital_write(R_CTRL_1, 1) 66 | board.digital_write(R_CTRL_2, 0) 67 | board.analog_write(PWM_R, 0) 68 | board.sleep(5.0) 69 | 70 | if __name__ == "__main__": 71 | setup() 72 | while True: 73 | loop() 74 | -------------------------------------------------------------------------------- /test/i2c/i2c_read/i2c_read_callback.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | 4 | """ 5 | Copyright (c) 2015 Alan Yorinks All rights reserved. 6 | 7 | This program is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU General Public 9 | License as published by the Free Software Foundation; either 10 | version 3 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | 21 | 22 | This file demonstrates using PyMata to read temperature values from a SparkFun Digital Temperature Sensor 23 | Breakout for the TMP102 device - SparkFun part #SEN-11931 24 | 25 | The code is based on a bildr article: http://bildr.org/2011/01/tmp102-arduino/ 26 | """ 27 | 28 | # import the API class 29 | 30 | from pymata_aio.pymata3 import PyMata3 31 | from pymata_aio.constants import Constants 32 | 33 | 34 | def my_callback(data): 35 | if data: 36 | # do some calculations on the raw data returned 37 | # reconstruct integer out of data 38 | 39 | raw_temperature = (data[4] << 8 | data[6]) >> 4 40 | 41 | celsius = raw_temperature * 0.0625 42 | print(celsius) 43 | fahrenheit = (1.8 * celsius) + 32 44 | print(fahrenheit) 45 | 46 | 47 | # create a PyMata instance 48 | board = PyMata3(2) 49 | 50 | # configure firmata for i2c on an UNO 51 | board.i2c_config(0) 52 | 53 | # read i2c device at address 0x48, with no register specified. Expect 2 bytes to be returned 54 | # and the operation is a single shot read 55 | 56 | # reading for 5 seconds 57 | board.i2c_read_request(0x48, 0, 2, Constants.I2C_READ_CONTINUOUSLY, my_callback) 58 | board.sleep(5) 59 | board.i2c_read_request(0x48, 0, 2, Constants.I2C_STOP_READING, my_callback) 60 | 61 | board.sleep(1) 62 | board.shutdown() 63 | -------------------------------------------------------------------------------- /pymata_aio/pymata_socket.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Copyright (c) 2015-2019 Alan Yorinks All rights reserved. 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE 7 | Version 3 as published by the Free Software Foundation; either 8 | or (at your option) any later version. 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | General Public License for more details. 13 | 14 | You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE 15 | along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | """ 18 | 19 | 20 | import asyncio 21 | import sys 22 | 23 | 24 | # noinspection PyStatementEffect,PyUnresolvedReferences,PyUnresolvedReferences 25 | class PymataSocket: 26 | def __init__(self, ip_address, port, loop): 27 | self.ip_address = ip_address 28 | self.port = port 29 | self.loop = loop 30 | self.reader = None 31 | self.writer = None 32 | 33 | async def start(self): 34 | """ 35 | This method opens an IP connection on the IP device 36 | 37 | :return: None 38 | """ 39 | try: 40 | self.reader, self.writer = await asyncio.open_connection( 41 | self.ip_address, self.port, loop=self.loop) 42 | except OSError: 43 | print("Can't open connection to " + self.ip_address) 44 | sys.exit(0) 45 | 46 | async def write(self, data): 47 | """ 48 | This method writes sends data to the IP device 49 | :param data: 50 | 51 | :return: None 52 | """ 53 | self.writer.write((bytes([ord(data)]))) 54 | await self.writer.drain() 55 | 56 | async def read(self): 57 | """ 58 | This method reads one byte of data from IP device 59 | 60 | :return: Next byte 61 | """ 62 | buffer = await self.reader.read(1) 63 | return ord(buffer) 64 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Firmata is a generic protocol for communicating with microcontrollers 3 | * from software on a host computer. It is intended to work with 4 | * any host computer software package. 5 | * 6 | * To download a host software package, please clink on the following link 7 | * to open the download page in your default browser. 8 | * 9 | * http://firmata.org/wiki/Download 10 | */ 11 | 12 | /* Supports as many digital inputs and outputs as possible. 13 | * 14 | * This example code is in the public domain. 15 | */ 16 | #include 17 | 18 | byte previousPIN[TOTAL_PORTS]; // PIN means PORT for input 19 | byte previousPORT[TOTAL_PORTS]; 20 | 21 | void outputPort(byte portNumber, byte portValue) 22 | { 23 | // only send the data when it changes, otherwise you get too many messages! 24 | if (previousPIN[portNumber] != portValue) { 25 | Firmata.sendDigitalPort(portNumber, portValue); 26 | previousPIN[portNumber] = portValue; 27 | } 28 | } 29 | 30 | void setPinModeCallback(byte pin, int mode) { 31 | if (IS_PIN_DIGITAL(pin)) { 32 | pinMode(PIN_TO_DIGITAL(pin), mode); 33 | } 34 | } 35 | 36 | void digitalWriteCallback(byte port, int value) 37 | { 38 | byte i; 39 | byte currentPinValue, previousPinValue; 40 | 41 | if (port < TOTAL_PORTS && value != previousPORT[port]) { 42 | for (i = 0; i < 8; i++) { 43 | currentPinValue = (byte) value & (1 << i); 44 | previousPinValue = previousPORT[port] & (1 << i); 45 | if (currentPinValue != previousPinValue) { 46 | digitalWrite(i + (port * 8), currentPinValue); 47 | } 48 | } 49 | previousPORT[port] = value; 50 | } 51 | } 52 | 53 | void setup() 54 | { 55 | Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION); 56 | Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback); 57 | Firmata.attach(SET_PIN_MODE, setPinModeCallback); 58 | Firmata.begin(57600); 59 | } 60 | 61 | void loop() 62 | { 63 | byte i; 64 | 65 | for (i = 0; i < TOTAL_PORTS; i++) { 66 | outputPort(i, readPort(i, 0xff)); 67 | } 68 | 69 | while (Firmata.available()) { 70 | Firmata.processInput(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /examples/sparkfun_redbot/pixy/simple_servo_sweep_config_2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Demo of using the pan and tilt servo kit. 4 | 5 | This demo assumes you have purchased the Pixy pan and tilt kit. You can connect the servos in two places: 6 | 1. Just plug the servos into servo ports on the Arduino 3, 9, or 10 (NOT 11!). This demo uses 3 and 10. 7 | 2. Plug the servos in on the Pixy board as recommended here http://cmucam.org/projects/cmucam5/wiki/Assembling_pantilt_Mechanism 8 | 9 | This code assumes you have connected the servos connected to the Pixy board directly. 10 | Due to power limitations we only use the pan servo in this demo. 11 | """ 12 | 13 | from pymata_aio.pymata3 import PyMata3 14 | 15 | WIFLY_IP_ADDRESS = None # Leave set as None if not using WiFly 16 | WIFLY_IP_ADDRESS = "10.0.1.19" # If using a WiFly on the RedBot, set the ip address here. 17 | #WIFLY_IP_ADDRESS = "r01.wlan.rose-hulman.edu" # If your WiFi network allows it, you can use the device hostname instead. 18 | if WIFLY_IP_ADDRESS: 19 | # arduino_wait is a timer parameter to allow for the arduino to reboot when the connection is made which is NA for WiFly. 20 | board = PyMata3(arduino_wait=0, ip_address=WIFLY_IP_ADDRESS) 21 | else: 22 | # Use a USB cable to RedBot or an XBee connection instead of WiFly. 23 | COM_PORT = None # Use None for automatic com port detection, or set if needed i.e. "COM7" 24 | board = PyMata3(com_port=COM_PORT) 25 | 26 | # Servo values 27 | PIXY_RCS_MIN_POS = 0 28 | PIXY_RCS_MAX_POS = 1000 29 | PIXY_RCS_CENTER_POS = 500 30 | 31 | def main(): 32 | board.keep_alive(period=2) 33 | board.pixy_init() 34 | while True: 35 | for s0 in range(PIXY_RCS_CENTER_POS, PIXY_RCS_MAX_POS, 10): 36 | board.pixy_set_servos(s0, PIXY_RCS_CENTER_POS) 37 | board.sleep(0.05) 38 | for s0 in range(PIXY_RCS_MAX_POS, PIXY_RCS_MIN_POS, -10): 39 | board.pixy_set_servos(s0, PIXY_RCS_CENTER_POS) 40 | board.sleep(0.05) 41 | for s0 in range(PIXY_RCS_MIN_POS, PIXY_RCS_CENTER_POS, 10): 42 | board.pixy_set_servos(s0, PIXY_RCS_CENTER_POS) 43 | board.sleep(0.05) 44 | print("Sweep complete") 45 | board.sleep(1.0) 46 | 47 | main() 48 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot/RedBot_Experiments/Exp3_Turning/Exp3_Turning.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp3_Turning -- RedBot Experiment 3 3 | * 4 | * Explore turning with the RedBot by controlling the Right and Left motors 5 | * separately. 6 | * 7 | * Hardware setup: 8 | * This code requires only the most basic setup: the motors must be 9 | * connected, and the board must be receiving power from the battery pack. 10 | * 11 | * 23 Sept 2013 N. Seidle/M. Hord 12 | * 04 Oct 2014 B. Huang 13 | ***********************************************************************/ 14 | #include // This line "includes" the library into your sketch. 15 | 16 | RedBotMotors motors; // Instantiate the motor control object. 17 | 18 | void setup() 19 | { 20 | // drive forward -- instead of using motors.drive(); Here is another way. 21 | motors.rightMotor(150); // Turn on right motor clockwise medium power (motorPower = 150) 22 | motors.leftMotor(-150); // Turn on left motor counter clockwise medium power (motorPower = 150) 23 | delay(1000); // for 1000 ms. 24 | motors.brake(); // brake() motors 25 | 26 | // pivot -- spinning both motors CCW causes the RedBot to turn to the right 27 | motors.rightMotor(-100); // Turn CCW at motorPower of 100 28 | motors.leftMotor(-100); // Turn CCW at motorPower of 100 29 | delay(500); // for 500 ms. 30 | motors.brake(); // brake() motors 31 | delay(500); // for 500 ms. 32 | 33 | // drive forward -- instead of using motors.drive(); Here is another way. 34 | motors.rightMotor(150); // Turn on right motor clockwise medium power (motorPower = 150) 35 | motors.leftMotor(-150); // Turn on left motor counter clockwise medium power (motorPower = 150) 36 | delay(1000); // for 1000 ms. 37 | motors.brake(); // brake() motors 38 | } 39 | 40 | void loop() 41 | { 42 | // Figure 8 pattern -- Turn Right, Turn Left, Repeat 43 | // motors.leftMotor(-200); // Left motor CCW at 200 44 | // motors.rightMotor(80); // Right motor CW at 80 45 | // delay(2000); 46 | // motors.leftMotor(-80); // Left motor CCW at 80 47 | // motors.rightMotor(200); // Right motor CW at 200 48 | // delay(2000); 49 | } 50 | 51 | 52 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot2/RedBot_Experiments/Exp3_Turning/Exp3_Turning.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp3_Turning -- RedBot Experiment 3 3 | * 4 | * Explore turning with the RedBot by controlling the Right and Left motors 5 | * separately. 6 | * 7 | * Hardware setup: 8 | * This code requires only the most basic setup: the motors must be 9 | * connected, and the board must be receiving power from the battery pack. 10 | * 11 | * 23 Sept 2013 N. Seidle/M. Hord 12 | * 04 Oct 2014 B. Huang 13 | ***********************************************************************/ 14 | #include // This line "includes" the library into your sketch. 15 | 16 | RedBotMotors motors; // Instantiate the motor control object. 17 | 18 | void setup() 19 | { 20 | // drive forward -- instead of using motors.drive(); Here is another way. 21 | motors.rightMotor(150); // Turn on right motor clockwise medium power (motorPower = 150) 22 | motors.leftMotor(-150); // Turn on left motor counter clockwise medium power (motorPower = 150) 23 | delay(1000); // for 1000 ms. 24 | motors.brake(); // brake() motors 25 | 26 | // pivot -- spinning both motors CCW causes the RedBot to turn to the right 27 | motors.rightMotor(-100); // Turn CCW at motorPower of 100 28 | motors.leftMotor(-100); // Turn CCW at motorPower of 100 29 | delay(500); // for 500 ms. 30 | motors.brake(); // brake() motors 31 | delay(500); // for 500 ms. 32 | 33 | // drive forward -- instead of using motors.drive(); Here is another way. 34 | motors.rightMotor(150); // Turn on right motor clockwise medium power (motorPower = 150) 35 | motors.leftMotor(-150); // Turn on left motor counter clockwise medium power (motorPower = 150) 36 | delay(1000); // for 1000 ms. 37 | motors.brake(); // brake() motors 38 | } 39 | 40 | void loop() 41 | { 42 | // Figure 8 pattern -- Turn Right, Turn Left, Repeat 43 | // motors.leftMotor(-200); // Left motor CCW at 200 44 | // motors.rightMotor(80); // Right motor CW at 80 45 | // delay(2000); 46 | // motors.leftMotor(-80); // Left motor CCW at 80 47 | // motors.rightMotor(200); // Right motor CW at 200 48 | // delay(2000); 49 | } 50 | 51 | 52 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/cbiface/cbiface.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************** 3 | * cbiface by GreyGnome aka Mike Schwager * 4 | * version 1.1 Sun Mar 11 14:25:08 CDT 2012 * 5 | * Based on version 1.0 of cb library, this is the first implementa- * 6 | * tion of cbifoce. * 7 | * * 8 | * Updates since version 1.0 of cb.h: * 9 | * Renamed this little library, to cbiface (from cb) because: * 10 | * Got rid of the CallBack class. My interrupt library can call the * 11 | * cbmethod() of any object that subclasses the CallBackInterface * 12 | * class (...Java style! :-) ). The CallBack class is not necessary * 13 | * for these purposes. * 14 | * * 15 | * based on: * 16 | * Variable Parameter Call-Back Template (version 0.0.1) * 17 | * * 18 | * Author: Arash Partow - 2000 * 19 | * URL: http://www.partow.net/programming/templatecallback/index.html * 20 | * * 21 | * Copyright Notice: * 22 | * Free use of this library is permitted under the guidelines and * 23 | * in accordance with the most current version of the Common Public * 24 | * License. * 25 | * http://www.opensource.org/licenses/cpl.php * 26 | * * 27 | ********************************************************************** 28 | */ 29 | 30 | 31 | #ifndef INCLUDE_CBIFACE_H 32 | #define INCLUDE_CBIFACE_H 33 | 34 | class CallBackInterface 35 | { 36 | public: 37 | 38 | CallBackInterface() {}; 39 | 40 | virtual void cbmethod() { 41 | }; 42 | 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /test/i2c/i2c_write/i2c_write.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | 4 | """ 5 | Copyright (c) 2015 Alan Yorinks All rights reserved. 6 | 7 | This program is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU General Public 9 | License as published by the Free Software Foundation; either 10 | version 3 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | 21 | 22 | This file demonstrates using PyMata to read temperature values from a SparkFun Digital Temperature Sensor 23 | Breakout for the TMP102 device - SparkFun part #SEN-11931 24 | 25 | The code is adapted from the Adafruit backpack library https://github.com/adafruit/Adafruit-LED-Backpack-Library 26 | 27 | It utilizes the bi_color_display_controller which, in turn, utilizes PyFirmata for I2C write control. 28 | """ 29 | 30 | 31 | # from examples.i2c.pymata_i2c_write.bicolor_display_controller import BiColorDisplayController 32 | 33 | 34 | from test.i2c.i2c_write.bicolor_display_controller import BiColorDisplayController 35 | 36 | frown = [0x3C, 0x42, 0xA5, 0x91, 0x91, 0xA5, 0x42, 0x3C] 37 | neutral = [0x3C, 0x42, 0x95, 0x91, 0x91, 0x95, 0x42, 0x3C] 38 | smile = [0x3C, 0x42, 0x95, 0xA1, 0xA1, 0x95, 0x42, 0x3C] 39 | 40 | 41 | # instantiate a controller object 42 | display = BiColorDisplayController(0x70, 0, 7) 43 | 44 | # turn off all leds in display 45 | display.clear_display_buffer() 46 | 47 | # let's make some faces 48 | display.set_bit_map(frown, display.LED_RED) 49 | display.firmata.sleep(1) 50 | display.clear_display_buffer() 51 | display.set_bit_map(neutral, display.LED_YELLOW) 52 | display.firmata.sleep(1) 53 | display.clear_display_buffer() 54 | display.set_bit_map(smile, display.LED_GREEN) 55 | display.firmata.sleep(1) 56 | display.clear_display_buffer() 57 | 58 | # short but sweet demo 59 | display.close() 60 | -------------------------------------------------------------------------------- /test/i2c/i2c_read/i2c_read_polled.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | 4 | """ 5 | Copyright (c) 2015 Alan Yorinks All rights reserved. 6 | 7 | This program is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU General Public 9 | License as published by the Free Software Foundation; either 10 | version 3 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public 18 | License along with this library; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | 21 | 22 | This file demonstrates using PyMata to read temperature values from a SparkFun Digital Temperature Sensor 23 | Breakout for the TMP102 device - SparkFun part #SEN-11931 24 | 25 | The code is based on a bildr article: http://bildr.org/2011/01/tmp102-arduino/ 26 | """ 27 | 28 | # import the API class 29 | 30 | from pymata_aio.pymata3 import PyMata3 31 | from pymata_aio.constants import Constants 32 | 33 | 34 | # create a PyMata instance 35 | board = PyMata3(2) 36 | 37 | 38 | # configure firmata for i2c on an UNO 39 | board.i2c_config(0) 40 | 41 | # read i2c device at address 0x48, with no register specified. Expect 2 bytes to be returned 42 | # and the operation is a single shot read 43 | 44 | 45 | board.i2c_read_request(0x48, 0, 2, Constants.I2C_READ) 46 | 47 | # give the serial interface time to send a read, for the device to execute the read 48 | # and to get things back across the interface 49 | board.sleep(.1) 50 | 51 | for x in range(0, 10): 52 | # retrieve the data sent from device 53 | data = board.i2c_read_data(0x48) 54 | 55 | if data: 56 | # do some calculations on the raw data returned 57 | raw_temperature = (data[4] << 8 | data[6]) >> 4 58 | 59 | celsius = raw_temperature * 0.0625 60 | print(celsius) 61 | 62 | fahrenheit = (1.8 * celsius) + 32 63 | print(fahrenheit) 64 | else: 65 | print('no data') 66 | 67 | board.shutdown() 68 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/AdaEncoder/RELEASE_NOTES: -------------------------------------------------------------------------------- 1 | // We use 4-character tabstops, so IN VIM: :set ts=4 sw=4 2 | // ...that's: ESCAPE key, colon key, then "s-e-t SPACE key t-s-=-4 SPACE key s-w-=-4 CARRIAGE RETURN key" 3 | /* 4 | AdaEncoder.h - A library for reading Lady Ada's or Sparkfun's rotary encoder. 5 | Should work for any rotary encoder with 2 pins (4 states). 6 | 7 | Version 0.7 Tue Nov 20 17:56:29 CST 2012 8 | Now works with the latest ooPinChangeInt. Should be much more reliable. 9 | 10 | Bugfixes: the clicks variable was supposed to be int8_t, but I had query() and getClicks() returning uint8_t types. 11 | 12 | Updated to utilize the ByteBuffer to fill a buffer of text for debug purposes. 13 | 14 | turnOffPWM has been moved into its own file, as that code is distributed under the LPGL license. I use the GPL. 15 | 16 | Version 0.5 Wed Feb 29 07:30:23 CST 2012 17 | Shipped without PinChangeInt, so we don't stomp on PinChangeInt if the user has both libraries. 18 | Includes the LIBCALL_PINCHANGEINT macro for work with PinChangeInt v1.70beta (and newer). 19 | Cleaned up some of the #includes. 20 | Included a copy of the gpl in the zip file, like a good citizen. The file is gpl.txt. 21 | Version 0.4 Sun Oct 9 12:09:17 CDT 2011 22 | Includes cppfix.h, so that we can use the new() operator with PinChangeInt-0.3 (and above). 23 | Version 0.3 Thu Sep 22 20:11:31 CDT 2011 24 | Updated to save the old value of the SREG prior to cli(). 25 | */ 26 | 27 | /* 28 | Copyright 2011 Michael Schwager (aka, "GreyGnome") 29 | 30 | This program is free software: you can redistribute it and/or modify 31 | it under the terms of the GNU General Public License as published by 32 | the Free Software Foundation, either version 3 of the License, or 33 | (at your option) any later version. 34 | 35 | This program is distributed in the hope that it will be useful, 36 | but WITHOUT ANY WARRANTY; without even the implied warranty of 37 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 38 | GNU General Public License for more details. 39 | 40 | You should have received a copy of the GNU General Public License 41 | along with this program. If not, see . 42 | 43 | Questions? Send mail to mschwage@gmail.com 44 | 45 | */ 46 | -------------------------------------------------------------------------------- /examples/sparkfun_redbot/sparkfun_experiments/Exp1_BasicTest.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """ 3 | Exp1_BasicTest -- RedBot Experiment 1 4 | 5 | Time to make sure the electronics work! To test everything out, we're 6 | going to blink the LED on the board. 7 | 8 | In Arduino, an LED is often connected to pin 13 for "debug" purposes. 9 | This LED is used as an indicator to make sure that we're able to upload 10 | code to the board. It's also a good indicator that your program is running. 11 | """ 12 | 13 | from pymata_aio.pymata3 import PyMata3 14 | from pymata_aio.constants import Constants 15 | 16 | # Note, this experiment is so simple that it doesn't need to use the redbot library. 17 | 18 | WIFLY_IP_ADDRESS = None # Leave set as None if not using WiFly 19 | WIFLY_IP_ADDRESS = "10.0.1.19" # If using a WiFly on the RedBot, set the ip address here. 20 | #WIFLY_IP_ADDRESS = "r01.wlan.rose-hulman.edu" # If your WiFi network allows it, you can use the device hostname instead. 21 | if WIFLY_IP_ADDRESS: 22 | # arduino_wait is a timer parameter to allow for the arduino to reboot when the connection is made which is NA for WiFly. 23 | board = PyMata3(arduino_wait=0, ip_address=WIFLY_IP_ADDRESS) 24 | else: 25 | # Use a USB cable to RedBot or an XBee connection instead of WiFly. 26 | COM_PORT = None # Use None for automatic com port detection, or set if needed i.e. "COM7" 27 | board = PyMata3(com_port=COM_PORT) 28 | 29 | def setup(): 30 | """setup() function runs once at the very beginning.""" 31 | board.set_pin_mode(13, Constants.OUTPUT) 32 | # The RedBot has an LED connected to pin 13. 33 | # Pins are all generic, so we have to first configure it 34 | # as an OUTPUT using this command. 35 | 36 | 37 | def loop(): 38 | """loop() function repeats over and over... forever!""" 39 | print("Blink sequence") 40 | board.digital_write(13, 1) # Turns LED ON -- HIGH puts 5V on pin 13. 41 | board.sleep(0.500) # "pauses" the program for 500 milliseconds 42 | board.digital_write(13, 0) # Turns LED OFF -- LOW puts 0V on pin 13. 43 | board.sleep(0.500) # "pauses" the program for 500 milliseconds 44 | # The total delay period is 1000 ms, or 1 second. 45 | 46 | 47 | if __name__ == "__main__": 48 | setup() 49 | while True: 50 | loop() 51 | 52 | 53 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/ATtinyBlink/Makefile: -------------------------------------------------------------------------------- 1 | ## Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile 2 | # 3 | #AVR_TOOLS_DIR = /usr 4 | #CFLAGS_STD = -g -I /home/schwager/.arduino15/packages/attiny/hardware/avr/1.0.1/variants/tiny8 5 | #CXXFLAGS_STD = -g -I /home/schwager/.arduino15/packages/attiny/hardware/avr/1.0.1/variants/tiny8 6 | # 7 | ## if you have placed the alternate core in your sketchbook directory, then you can just mention the core name alone. 8 | #ALTERNATE_CORE = attiny 9 | ## If not, you might have to include the full path. 10 | ##ALTERNATE_CORE_PATH = /home/schwager/bin/arduino-1.6.4/hardware/arduino/avr/cores/ 11 | #ALTERNATE_CORE_PATH = /home/schwager/.arduino15/packages/attiny/hardware/avr/1.0.1 12 | #ARDUINO_VAR_PATH = /home/schwager/Projects/Arduino/attiny-ide-1.6.x/attiny/avr/variants 13 | #ARDUINO_HEADER = /home/schwager/bin/arduino-1.6.4/hardware/arduino/avr/cores/arduino/Arduino.h 14 | # 15 | #BOARD_TAG = attiny85 16 | #BOARD_SUB = attiny85 17 | #ALTERNATE_CORE = attiny 18 | # 19 | #ISP_PROG = usbasp 20 | #ISP_PORT = /dev/ttyACM* 21 | # 22 | #F_CPU = 1000000L 23 | # 24 | ##include $(ARDMK_DIR)/Arduino.mk # the variable is unrecognized. 25 | #include /usr/share/arduino/Arduino.mk 26 | # 27 | ## !!! Important. You have to use make ispload to upload when using ISP programmer 28 | #ARDUINO_DIR = /home/schwager/bin/arduino-1.6.4/ 29 | #F_CPU = 16000000L 30 | # 31 | #include /usr/share/arduino/Arduino.mk 32 | # 33 | 34 | # NOTE: DAVID MELLIS' CODE INCLUDES ATTINY44/45/84/85 ONLY- NOT ATTINY24 35 | # (that said, you *could* include the appropriate lines in the boards.txt file to 36 | # support the smaller 'tinies). 37 | ARDUINO_DIR = /home/schwager/bin/arduino-1.6.4 38 | # 14-pin, ATtiny44/84 39 | #BOARD_SUB = attiny44 40 | #CFLAGS_STD = -g -I /home/schwager/sketchbook/hardware/attiny/variants/tiny14 41 | #CXXFLAGS_STD = -g -I /home/schwager/sketchbook/hardware/attiny/variants/tiny14 42 | # 43 | 44 | # 8-pin, ATtiny45/85 45 | BOARD_SUB = attiny85 46 | CFLAGS_STD = -g -I /home/schwager/sketchbook/hardware/attiny/variants/tiny8 47 | CXXFLAGS_STD = -g -I /home/schwager/sketchbook/hardware/attiny/variants/tiny8 48 | 49 | ISP_PROG = usbasp 50 | BOARD_TAG = attiny 51 | ALTERNATE_CORE = attiny 52 | # Set this as appropriate. See the data sheet. 53 | F_CPU = 1000000L 54 | 55 | include /usr/share/arduino/Arduino.mk 56 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/FirmataPlusRB/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Firmata 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Firmata KEYWORD1 10 | callbackFunction KEYWORD1 11 | systemResetCallbackFunction KEYWORD1 12 | stringCallbackFunction KEYWORD1 13 | sysexCallbackFunction KEYWORD1 14 | 15 | ####################################### 16 | # Methods and Functions (KEYWORD2) 17 | ####################################### 18 | 19 | begin KEYWORD2 20 | printVersion KEYWORD2 21 | blinkVersion KEYWORD2 22 | printFirmwareVersion KEYWORD2 23 | setFirmwareVersion KEYWORD2 24 | setFirmwareNameAndVersion KEYWORD2 25 | available KEYWORD2 26 | processInput KEYWORD2 27 | sendAnalog KEYWORD2 28 | sendDigital KEYWORD2 29 | sendDigitalPort KEYWORD2 30 | sendString KEYWORD2 31 | sendSysex KEYWORD2 32 | attach KEYWORD2 33 | detach KEYWORD2 34 | write KEYWORD2 35 | sendValueAsTwo7bitBytes KEYWORD2 36 | startSysex KEYWORD2 37 | endSysex KEYWORD2 38 | 39 | 40 | ####################################### 41 | # Constants (LITERAL1) 42 | ####################################### 43 | 44 | MAX_DATA_BYTES LITERAL1 45 | 46 | DIGITAL_MESSAGE LITERAL1 47 | ANALOG_MESSAGE LITERAL1 48 | REPORT_ANALOG LITERAL1 49 | REPORT_DIGITAL LITERAL1 50 | REPORT_VERSION LITERAL1 51 | SET_PIN_MODE LITERAL1 52 | SYSTEM_RESET LITERAL1 53 | START_SYSEX LITERAL1 54 | END_SYSEX LITERAL1 55 | 56 | ANALOG LITERAL1 57 | PWM LITERAL1 58 | SERVO LITERAL1 59 | SHIFT LITERAL1 60 | I2C LITERAL1 61 | ONEWIRE LITERAL1 62 | STEPPER LITERAL1 63 | ENCODER LITERAL1 64 | IGNORE LITERAL1 65 | 66 | 67 | TOTAL_ANALOG_PINS LITERAL1 68 | TOTAL_DIGITAL_PINS LITERAL1 69 | TOTAL_PIN_MODES LITERAL1 70 | TOTAL_PORTS LITERAL1 71 | ANALOG_PORT LITERAL1 72 | -------------------------------------------------------------------------------- /examples/sparkfun_redbot/sparkfun_experiments/Exp9_SerialDrive.py: -------------------------------------------------------------------------------- 1 | """ 2 | Exp9_SerialDrive -- RedBot Experiment 9 3 | 4 | The first step to controlling the RedBot remotely is to first drive it 5 | from the Serial Monitor in a tethered setup. 6 | 7 | Hardware setup: 8 | After uploading this sketch, keep the RedBot tethered to your computer with 9 | the USB cable. Open up the Serial Monitor to send commands to the RedBot to 10 | drive. 11 | 12 | This sketch was written by SparkFun Electronics, with lots of help from 13 | the Arduino community. This code is completely free for any use. 14 | 15 | 15 Dec 2014 B. Huang 16 | 17 | This experiment was inspired by Paul Kassebaum at Mathworks, who made 18 | one of the very first non-SparkFun demo projects and brought it to the 19 | 2013 Open Hardware Summit in Boston. Thanks Paul! 20 | 21 | Revised, 2 Oct, 2015 L. Mathews 22 | """ 23 | 24 | from pymata_aio.pymata3 import PyMata3 25 | import library.redbot as rb 26 | 27 | WIFLY_IP_ADDRESS = None # Leave set as None if not using WiFly 28 | WIFLY_IP_ADDRESS = "10.0.1.19" # If using a WiFly on the RedBot, set the ip address here. 29 | #WIFLY_IP_ADDRESS = "r01.wlan.rose-hulman.edu" # If your WiFi network allows it, you can use the device hostname instead. 30 | if WIFLY_IP_ADDRESS: 31 | # arduino_wait is a timer parameter to allow for the arduino to reboot when the connection is made which is NA for WiFly. 32 | board = PyMata3(arduino_wait=0, ip_address=WIFLY_IP_ADDRESS) 33 | else: 34 | # Use a USB cable to RedBot or an XBee connection instead of WiFly. 35 | COM_PORT = None # Use None for automatic com port detection, or set if needed i.e. "COM7" 36 | board = PyMata3(com_port=COM_PORT) 37 | 38 | 39 | motors = rb.RedBotMotors(board) 40 | 41 | 42 | def setup(): 43 | print("Type in a number between -255 to 255 to drive at that speed.") 44 | 45 | def loop(): 46 | speed = int(input()) # Note, adding a board.keep_alive to this program would be bad due the block nature of the input() command. 47 | speed = throttle(speed) 48 | motors.drive(speed) 49 | 50 | 51 | def throttle(n, min_value=-255, max_value=255): 52 | """Constraining the speed value between -255:255""" 53 | return max(min(max_value, n), min_value) 54 | 55 | if __name__ == "__main__": 56 | setup() 57 | while True: 58 | loop() 59 | 60 | 61 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/FirmataPlusRBPixy/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Firmata 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Firmata KEYWORD1 10 | callbackFunction KEYWORD1 11 | systemResetCallbackFunction KEYWORD1 12 | stringCallbackFunction KEYWORD1 13 | sysexCallbackFunction KEYWORD1 14 | 15 | ####################################### 16 | # Methods and Functions (KEYWORD2) 17 | ####################################### 18 | 19 | begin KEYWORD2 20 | printVersion KEYWORD2 21 | blinkVersion KEYWORD2 22 | printFirmwareVersion KEYWORD2 23 | setFirmwareVersion KEYWORD2 24 | setFirmwareNameAndVersion KEYWORD2 25 | available KEYWORD2 26 | processInput KEYWORD2 27 | sendAnalog KEYWORD2 28 | sendDigital KEYWORD2 29 | sendDigitalPort KEYWORD2 30 | sendString KEYWORD2 31 | sendSysex KEYWORD2 32 | attach KEYWORD2 33 | detach KEYWORD2 34 | write KEYWORD2 35 | sendValueAsTwo7bitBytes KEYWORD2 36 | startSysex KEYWORD2 37 | endSysex KEYWORD2 38 | 39 | 40 | ####################################### 41 | # Constants (LITERAL1) 42 | ####################################### 43 | 44 | MAX_DATA_BYTES LITERAL1 45 | 46 | DIGITAL_MESSAGE LITERAL1 47 | ANALOG_MESSAGE LITERAL1 48 | REPORT_ANALOG LITERAL1 49 | REPORT_DIGITAL LITERAL1 50 | REPORT_VERSION LITERAL1 51 | SET_PIN_MODE LITERAL1 52 | SYSTEM_RESET LITERAL1 53 | START_SYSEX LITERAL1 54 | END_SYSEX LITERAL1 55 | 56 | ANALOG LITERAL1 57 | PWM LITERAL1 58 | SERVO LITERAL1 59 | SHIFT LITERAL1 60 | I2C LITERAL1 61 | ONEWIRE LITERAL1 62 | STEPPER LITERAL1 63 | ENCODER LITERAL1 64 | IGNORE LITERAL1 65 | 66 | 67 | TOTAL_ANALOG_PINS LITERAL1 68 | TOTAL_DIGITAL_PINS LITERAL1 69 | TOTAL_PIN_MODES LITERAL1 70 | TOTAL_PORTS LITERAL1 71 | ANALOG_PORT LITERAL1 72 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/ooPinChangeInt/Examples/ooPinChangeInt/ooPinChangeInt.pde: -------------------------------------------------------------------------------- 1 | // ooPinChangeInt Example by GreyGnome aka Mike Schwager. Version numbers here refer to this sketch. 2 | // Version 1.0 - initial version 3 | // You can reduce the memory footprint of ooPinChangeInt by declaring that there will be no pin change interrupts 4 | // on any one or two of the three ports. If only a single port remains, the handler will be declared inline 5 | // reducing the size and latency of the handler. 6 | // #define NO_PORTB_PINCHANGES // to indicate that port b will not be used for pin change interrupts 7 | // #define NO_PORTC_PINCHANGES // to indicate that port c will not be used for pin change interrupts 8 | // #define NO_PORTD_PINCHANGES // to indicate that port d will not be used for pin change interrupts 9 | // if there is only one PCInt vector in use the code can be inlined 10 | // reducing latency and code size 11 | // define DISABLE_PCINT_MULTI_SERVICE below to limit the handler to servicing a single interrupt per invocation. 12 | // #define DISABLE_PCINT_MULTI_SERVICE 13 | 14 | #include 15 | 16 | #include 17 | 18 | // include "uint8ToString.h" 19 | // To use the library, define a class that subclasses CallBackInterface, and put it in a .h file. 20 | // And also, include a method (C++ talk for "subroutine") called "cbmethod()" in the class. 21 | // Use this class as a template to create your own; it's not hard. You don't 22 | // even have to understand what you're doing at first. 23 | #include "pushbuttonswitch.h" // How do you subclass? See the pushbuttonswitch.h file: 24 | ByteBuffer printBuffer(80); 25 | 26 | pushbuttonswitch redswitch=pushbuttonswitch(2, "red"); 27 | pushbuttonswitch greenswitch=pushbuttonswitch(3, "green"); 28 | pushbuttonswitch blueswitch=pushbuttonswitch(A3, "blue"); 29 | 30 | void setup() 31 | { 32 | Serial.begin(115200); Serial.println("---------------------------------------"); 33 | redswitch.getCount(); 34 | } 35 | 36 | void loop() { 37 | reportit(redswitch); 38 | reportit(greenswitch); 39 | reportit(blueswitch); 40 | delay(500); 41 | } 42 | 43 | void reportit(pushbuttonswitch& aswitch) { 44 | uint8_t tmp; 45 | if ((tmp=aswitch.getCount()) > 0) { 46 | Serial.print(aswitch.getName()); 47 | Serial.print(" accumulated: "); Serial.print(tmp, DEC); Serial.println(" transitions."); 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot/RedBot_Experiments/Exp8_1_AccelerometerRead/Exp8_1_AccelerometerRead.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp8_1_AccelerometerRead -- RedBot Experiment 8.1 3 | * 4 | * Measuring speed, velocity, and acceleration are all key 5 | * components to robotics. This first experiment will introduce 6 | * you to using the Accelerometer sensor on the RedBot. 7 | * 8 | * Hardware setup: 9 | * You'll need to attach the RedBot Accelerometer board to hader on the upper 10 | * right side of the mainboard. See the manual for details on how to do this. 11 | * 12 | * This sketch was written by SparkFun Electronics, with lots of help from 13 | * the Arduino community. This code is completely free for any use. 14 | * 15 | * 8 Oct 2013 M. Hord 16 | * Revised, 31 Oct 2014 B. Huang 17 | * 18 | * 8 Oct 2013 M. Hord 19 | * 20 | * This experiment was inspired by Paul Kassebaum at Mathworks, who made 21 | * one of the very first non-SparkFun demo projects and brought it to the 22 | * 2013 Open Hardware Summit in Boston. Thanks Paul! 23 | ***********************************************************************/ 24 | 25 | #include 26 | RedBotMotors motors; 27 | 28 | // The RedBot library includes support for the accelerometer. We've tried 29 | // to make using the accelerometer as easy as to use as possible. 30 | 31 | RedBotAccel accelerometer; 32 | 33 | void setup(void) 34 | { 35 | Serial.begin(9600); 36 | } 37 | 38 | void loop(void) 39 | { 40 | accelerometer.read(); // updates the x, y, and z axis readings on the acceleromter 41 | 42 | // Display out the X, Y, and Z - axis "acceleration" measurements and also 43 | // the relative angle between the X-Z, Y-Z, and X-Y vectors. (These give us 44 | // the orientation of the RedBot in 3D space. 45 | 46 | Serial.print("("); 47 | Serial.print(accelerometer.x); 48 | Serial.print(", "); // tab 49 | 50 | Serial.print(accelerometer.y); 51 | Serial.print(", "); // tab 52 | 53 | Serial.print(accelerometer.z); 54 | Serial.print(") -- "); // tab 55 | 56 | Serial.print("["); 57 | Serial.print(accelerometer.angleXZ); 58 | Serial.print(", "); 59 | Serial.print(accelerometer.angleYZ); 60 | Serial.print(", "); 61 | Serial.print(accelerometer.angleXY); 62 | Serial.println("]"); 63 | 64 | // short delay in between readings/ 65 | delay(100); 66 | } 67 | 68 | -------------------------------------------------------------------------------- /examples/sparkfun_redbot/pixy/pixy_set_led.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Just playing with changing the LED colors on Pixy. 4 | """ 5 | 6 | from pymata_aio.pymata3 import PyMata3 7 | from pymata_aio.constants import Constants 8 | 9 | 10 | WIFLY_IP_ADDRESS = None # Leave set as None if not using WiFly 11 | WIFLY_IP_ADDRESS = "10.0.1.19" # If using a WiFly on the RedBot, set the ip address here. 12 | #WIFLY_IP_ADDRESS = "r01.wlan.rose-hulman.edu" # If your WiFi network allows it, you can use the device hostname instead. 13 | if WIFLY_IP_ADDRESS: 14 | # arduino_wait is a timer parameter to allow for the arduino to reboot when the connection is made which is NA for WiFly. 15 | board = PyMata3(arduino_wait=0, ip_address=WIFLY_IP_ADDRESS) 16 | else: 17 | # Use a USB cable to RedBot or an XBee connection instead of WiFly. 18 | COM_PORT = None # Use None for automatic com port detection, or set if needed i.e. "COM7" 19 | board = PyMata3(com_port=COM_PORT) 20 | 21 | 22 | def print_pixy_blocks(blocks): 23 | """ Prints the Pixy blocks data.""" 24 | print("Detected " + str(len(blocks)) + " Pixy blocks:") 25 | if len(blocks) > 0 and not "signature" in blocks[0]: 26 | print("Something went wrong. This does not appear to be a printable block.") 27 | board.shutdown() 28 | return 29 | for block_index in range(len(blocks)): 30 | block = blocks[block_index] 31 | print(" block {}: sig: {} x: {} y: {} width: {} height: {}".format( 32 | block_index, block["signature"], block["x"], block["y"], block["width"], block["height"])) 33 | 34 | 35 | def main(): 36 | board.pixy_init() 37 | board.keep_alive(period=2) 38 | print("LED color changing") 39 | while True: 40 | board.pixy_set_led(255, 0, 0) # Red 41 | board.sleep(1.0) 42 | board.pixy_set_led(0, 255, 0) # Green 43 | board.sleep(1.0) 44 | board.pixy_set_led(0, 0, 255) # Blue 45 | board.sleep(1.0) 46 | board.pixy_set_led(255, 255, 255) # White 47 | board.sleep(1.0) 48 | board.pixy_set_led(0, 0, 0) # Off 49 | board.sleep(0.5) 50 | for i in range(3): 51 | board.pixy_set_led(255, 255, 0) # Yellow 52 | board.sleep(0.1) 53 | board.pixy_set_led(0, 0, 0) # Off 54 | board.sleep(0.25) 55 | 56 | print_pixy_blocks(board.pixy_get_blocks()) 57 | 58 | main() 59 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/examples/SimpleDueZero/SimpleDueZero.ino: -------------------------------------------------------------------------------- 1 | // EnableInterrupt Simple example sketch. Demonstrates operation on a single pin of your choice. 2 | // See https://github.com/GreyGnome/EnableInterrupt and the README.md for more information. 3 | #include 4 | 5 | // Modify this at your leisure. Refer to https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#Summary 6 | #define ARDUINOPIN 10 7 | 8 | volatile uint16_t interruptCount=0; // The count will go back to 0 after hitting 65535. 9 | 10 | void interruptFunction() { 11 | interruptCount++; 12 | } 13 | 14 | void setup() { 15 | Serial.begin(115200); 16 | pinMode(ARDUINOPIN, INPUT_PULLUP); // See http://arduino.cc/en/Tutorial/DigitalPins 17 | enableInterrupt(ARDUINOPIN, interruptFunction, CHANGE); 18 | } 19 | 20 | // In the loop we just display interruptCount. The value is updated by the interrupt routine. 21 | void loop() { 22 | Serial.println("---------------------------------------"); 23 | delay(1000); 24 | Serial.print("Pin was interrupted: "); 25 | Serial.print(interruptCount, DEC); 26 | Serial.println(" times so far."); 27 | } 28 | 29 | ////////////////////////////////////////////////////////////////////////////////////////// 30 | ////////////////////////////////////// GORY DETAILS ////////////////////////////////////// 31 | 32 | /* The EnableInterrupt library was designed to present a single API for interrupts to all 33 | * the Arduino processors. The problems have traditionally been caused by the varying and 34 | * complicated pin interrupt schemes of the ATmega line of processors. The SAM processors 35 | * present a more straightforward interrupt design. They already do what the EnableInterrupt 36 | * library is trying to present: To enable an interrupt on a pin, simply set up that pin 37 | * with the type of interrupt you want, no conversion to an "Interrupt Number" [see the 38 | * attachInterrupt() docs]. 39 | * 40 | * This means that the EnableInterrupt library's work on the Due and Zero is trivial: if 41 | * called on those platforms, we simply create a macro that converts enableInterrupt() and 42 | * disableInterrupt() to attachInterrupt()/detachInterrupt(). 43 | * 44 | * Since that's all it does, the ONLY advantage the EnableInterrupt library offers is as 45 | * a consistent API across the chip families. If you are not interested in this then don't use 46 | * the EnableInterrupt library. 47 | */ 48 | -------------------------------------------------------------------------------- /examples/pwm_pin_example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | pymata_aio 6 | 7 | 8 | 9 | 10 | 11 |

Press A Button To Activate Pin 6 PWM Controlled LED

12 | 13 |   14 | 15 | 16 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot/RedBot_Experiments/Exp7_2_DriveDistance/Exp7_2_DriveDistance.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp7_2_DriveDistance -- RedBot Experiment 7.2 3 | * 4 | * In an earlier experiment, we used a combination of speed and time to 5 | * drive a certain distance. Using the encoders, we can me much more accurate. 6 | * In this example, we will show you how to setup your robot to drive a certain 7 | * distance regardless of the motorPower. 8 | * 9 | * This sketch was written by SparkFun Electronics, with lots of help from 10 | * the Arduino community. This code is completely free for any use. 11 | * 12 | * 8 Oct 2013 M. Hord 13 | * Revised, 31 Oct 2014 B. Huang 14 | ***********************************************************************/ 15 | #include 16 | 17 | RedBotMotors motors; 18 | 19 | RedBotEncoder encoder = RedBotEncoder(A2, 10); 20 | int buttonPin = 12; 21 | int countsPerRev = 192; // 4 pairs of N-S x 48:1 gearbox = 192 ticks per wheel rev 22 | 23 | float wheelDiam = 2.56; // diam = 65mm / 25.4 mm/in 24 | float wheelCirc = PI*wheelDiam; // Redbot wheel circumference = pi*D 25 | 26 | void setup() 27 | { 28 | pinMode(buttonPin, INPUT_PULLUP); 29 | Serial.begin(9600); 30 | } 31 | 32 | void loop(void) 33 | { 34 | // drive on button press. 35 | if (digitalRead(buttonPin) == LOW) 36 | { 37 | driveDistance(12, 150); // drive 12 inches, at motorPower = 150. 38 | } 39 | } 40 | 41 | void driveDistance(float distance, int motorPower) 42 | { 43 | long lCount = 0; 44 | long rCount = 0; 45 | float numRev; 46 | // debug 47 | Serial.print("driveDistance() "); 48 | Serial.print(distance); 49 | Serial.print(" inches at "); 50 | Serial.print(motorPower); 51 | Serial.println(" power."); 52 | 53 | numRev = (float) distance / wheelCirc; 54 | Serial.println(numRev, 3); 55 | encoder.clearEnc(BOTH); // clear the encoder count 56 | motors.drive(motorPower); 57 | 58 | while (rCount < numRev*countsPerRev) 59 | { 60 | // while the left encoder is less than the target count -- debug print 61 | // the encoder values and wait -- this is a holding loop. 62 | lCount = encoder.getTicks(LEFT); 63 | rCount = encoder.getTicks(RIGHT); 64 | Serial.print(lCount); 65 | Serial.print("\t"); 66 | Serial.print(rCount); 67 | Serial.print("\t"); 68 | Serial.println(numRev*countsPerRev); 69 | } 70 | // now apply "brakes" to stop the motors. 71 | motors.brake(); 72 | } 73 | 74 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot2/RedBot_Experiments/Exp7_2_DriveDistance/Exp7_2_DriveDistance.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp7_2_DriveDistance -- RedBot Experiment 7.2 3 | * 4 | * In an earlier experiment, we used a combination of speed and time to 5 | * drive a certain distance. Using the encoders, we can me much more accurate. 6 | * In this example, we will show you how to setup your robot to drive a certain 7 | * distance regardless of the motorPower. 8 | * 9 | * This sketch was written by SparkFun Electronics, with lots of help from 10 | * the Arduino community. This code is completely free for any use. 11 | * 12 | * 8 Oct 2013 M. Hord 13 | * Revised, 31 Oct 2014 B. Huang 14 | ***********************************************************************/ 15 | #include 16 | 17 | RedBotMotors motors; 18 | 19 | RedBotEncoder encoder = RedBotEncoder(A2, 10); 20 | int buttonPin = 12; 21 | int countsPerRev = 192; // 4 pairs of N-S x 48:1 gearbox = 192 ticks per wheel rev 22 | 23 | float wheelDiam = 2.56; // diam = 65mm / 25.4 mm/in 24 | float wheelCirc = PI*wheelDiam; // Redbot wheel circumference = pi*D 25 | 26 | void setup() 27 | { 28 | pinMode(buttonPin, INPUT_PULLUP); 29 | Serial.begin(9600); 30 | } 31 | 32 | void loop(void) 33 | { 34 | // drive on button press. 35 | if (digitalRead(buttonPin) == LOW) 36 | { 37 | driveDistance(12, 150); // drive 12 inches, at motorPower = 150. 38 | } 39 | } 40 | 41 | void driveDistance(float distance, int motorPower) 42 | { 43 | long lCount = 0; 44 | long rCount = 0; 45 | float numRev; 46 | // debug 47 | Serial.print("driveDistance() "); 48 | Serial.print(distance); 49 | Serial.print(" inches at "); 50 | Serial.print(motorPower); 51 | Serial.println(" power."); 52 | 53 | numRev = (float) distance / wheelCirc; 54 | Serial.println(numRev, 3); 55 | encoder.clearEnc(BOTH); // clear the encoder count 56 | motors.drive(motorPower); 57 | 58 | while (rCount < numRev*countsPerRev) 59 | { 60 | // while the left encoder is less than the target count -- debug print 61 | // the encoder values and wait -- this is a holding loop. 62 | lCount = encoder.getTicks(LEFT); 63 | rCount = encoder.getTicks(RIGHT); 64 | Serial.print(lCount); 65 | Serial.print("\t"); 66 | Serial.print(rCount); 67 | Serial.print("\t"); 68 | Serial.println(numRev*countsPerRev); 69 | } 70 | // now apply "brakes" to stop the motors. 71 | motors.brake(); 72 | } 73 | 74 | -------------------------------------------------------------------------------- /examples/sparkfun_redbot/pixy/pixy_set_brightness.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Just playing with changing the Pixy brightness setting. 4 | We strongly recommend you figure out an appropriate brightness value in PixyMon then use this command once 5 | to set the brightness to the value you found works well. 6 | """ 7 | 8 | from pymata_aio.pymata3 import PyMata3 9 | from pymata_aio.constants import Constants 10 | 11 | 12 | WIFLY_IP_ADDRESS = None # Leave set as None if not using WiFly 13 | WIFLY_IP_ADDRESS = "10.0.1.19" # If using a WiFly on the RedBot, set the ip address here. 14 | #WIFLY_IP_ADDRESS = "r01.wlan.rose-hulman.edu" # If your WiFi network allows it, you can use the device hostname instead. 15 | if WIFLY_IP_ADDRESS: 16 | # arduino_wait is a timer parameter to allow for the arduino to reboot when the connection is made which is NA for WiFly. 17 | board = PyMata3(arduino_wait=0, ip_address=WIFLY_IP_ADDRESS) 18 | else: 19 | # Use a USB cable to RedBot or an XBee connection instead of WiFly. 20 | COM_PORT = None # Use None for automatic com port detection, or set if needed i.e. "COM7" 21 | board = PyMata3(com_port=COM_PORT) 22 | 23 | 24 | def print_pixy_blocks(blocks): 25 | """ Prints the Pixy blocks data.""" 26 | print("Detected " + str(len(blocks)) + " Pixy blocks:") 27 | if len(blocks) > 0 and not "signature" in blocks[0]: 28 | print("Something went wrong. This does not appear to be a printable block.") 29 | board.shutdown() 30 | return 31 | for block_index in range(len(blocks)): 32 | block = blocks[block_index] 33 | print(" block {}: sig: {} x: {} y: {} width: {} height: {}".format( 34 | block_index, block["signature"], block["x"], block["y"], block["width"], block["height"])) 35 | 36 | 37 | def main(): 38 | board.pixy_init() 39 | board.keep_alive(period=2) 40 | print("Set brightness example") 41 | while True: 42 | print("Normal room") 43 | board.pixy_set_brightness(80) 44 | board.sleep(0.25) 45 | print_pixy_blocks(board.pixy_get_blocks()) 46 | board.sleep(2.0) 47 | 48 | print("Darker room") 49 | board.pixy_set_brightness(100) 50 | board.sleep(0.25) 51 | print_pixy_blocks(board.pixy_get_blocks()) 52 | board.sleep(2.0) 53 | 54 | print("Very dark room") 55 | board.pixy_set_brightness(150) 56 | board.sleep(0.25) 57 | print_pixy_blocks(board.pixy_get_blocks()) 58 | board.sleep(2.0) 59 | 60 | 61 | main() 62 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/EnableInterrupt/utility/ei_PinChange328.h: -------------------------------------------------------------------------------- 1 | #ifdef EI_SECTION_RISING 2 | #ifndef EI_NOTPORTB 3 | if (portNumber==PB) { 4 | risingPinsPORTB |= portMask; 5 | } 6 | #endif 7 | #ifndef EI_NOTPORTC 8 | if (portNumber==PC) { 9 | risingPinsPORTC |= portMask; 10 | } 11 | #endif 12 | #ifndef EI_NOTPORTD 13 | if (portNumber==PD) { 14 | risingPinsPORTD |= portMask; 15 | } 16 | #endif 17 | #endif // EI_SECTION_RISING 18 | 19 | #ifdef EI_SECTION_FALLING 20 | #ifndef EI_NOTPORTB 21 | if (portNumber==PB) { 22 | fallingPinsPORTB |= portMask; 23 | } 24 | #endif 25 | #ifndef EI_NOTPORTC 26 | if (portNumber==PC) { 27 | fallingPinsPORTC |= portMask; 28 | } 29 | #endif 30 | #ifndef EI_NOTPORTD 31 | if (portNumber==PD) { 32 | fallingPinsPORTD |= portMask; 33 | } 34 | #endif 35 | #endif // EI_SECTION_FALLING 36 | 37 | #if defined EI_SECTION_ASSIGNFUNCTIONSREGISTERS 38 | #ifndef EI_NOTPORTB 39 | if (portNumber==PB) { 40 | #ifndef NEEDFORSPEED 41 | calculatedPointer=&portBFunctions.pinZero + portBitNumber; 42 | *calculatedPointer = userFunction; 43 | #endif 44 | portSnapshotB=*portInputRegister(portNumber); 45 | pcmsk=&PCMSK0; 46 | PCICR |= _BV(0); 47 | } 48 | #endif 49 | #ifndef EI_NOTPORTC 50 | if (portNumber==PC) { 51 | #ifndef NEEDFORSPEED 52 | calculatedPointer=&portCFunctions.pinZero + portBitNumber; 53 | *calculatedPointer = userFunction; 54 | #endif 55 | portSnapshotC=*portInputRegister(portNumber); 56 | pcmsk=&PCMSK1; 57 | PCICR |= _BV(1); 58 | } 59 | #endif 60 | #ifndef EI_NOTPORTD 61 | if (portNumber==PD) { 62 | #ifndef NEEDFORSPEED 63 | calculatedPointer=&portDFunctions.pinZero + portBitNumber; 64 | *calculatedPointer = userFunction; 65 | #endif 66 | portSnapshotD=*portInputRegister(portNumber); 67 | pcmsk=&PCMSK2; 68 | PCICR |= _BV(2); 69 | } 70 | #endif 71 | #endif // EI_SECTION_ASSIGNFUNCTIONSREGISTERS 72 | 73 | #ifdef EI_SECTION_DISABLEPINCHANGE 74 | #ifndef EI_NOTPORTB 75 | if (portNumber == PB) { 76 | PCMSK0 &= ~portMask; 77 | if (PCMSK0 == 0) { PCICR &= ~_BV(0); }; 78 | risingPinsPORTB &= ~portMask; 79 | fallingPinsPORTB &= ~portMask; 80 | } 81 | #endif 82 | #ifndef EI_NOTPORTC 83 | if (portNumber == PC) { 84 | PCMSK1 &= ~portMask; 85 | if (PCMSK1 == 0) { PCICR &= ~_BV(1); }; 86 | risingPinsPORTC &= ~portMask; 87 | fallingPinsPORTC &= ~portMask; 88 | } 89 | #endif 90 | #ifndef EI_NOTPORTD 91 | if (portNumber == PD) { 92 | PCMSK2 &= ~portMask; 93 | if (PCMSK2 == 0) { PCICR &= ~_BV(2); }; 94 | risingPinsPORTD &= ~portMask; 95 | fallingPinsPORTD &= ~portMask; 96 | } 97 | #endif 98 | #endif // EI_SECTION_DISABLEPINCHANGE 99 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/Firmata/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Firmata 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Firmata KEYWORD1 Firmata 10 | callbackFunction KEYWORD1 callbackFunction 11 | systemResetCallbackFunction KEYWORD1 systemResetCallbackFunction 12 | stringCallbackFunction KEYWORD1 stringCallbackFunction 13 | sysexCallbackFunction KEYWORD1 sysexCallbackFunction 14 | 15 | ####################################### 16 | # Methods and Functions (KEYWORD2) 17 | ####################################### 18 | 19 | begin KEYWORD2 20 | printVersion KEYWORD2 21 | blinkVersion KEYWORD2 22 | printFirmwareVersion KEYWORD2 23 | setFirmwareVersion KEYWORD2 24 | setFirmwareNameAndVersion KEYWORD2 25 | available KEYWORD2 26 | processInput KEYWORD2 27 | isParsingMessage KEYWORD2 28 | parse KEYWORD2 29 | sendAnalog KEYWORD2 30 | sendDigital KEYWORD2 31 | sendDigitalPort KEYWORD2 32 | sendString KEYWORD2 33 | sendSysex KEYWORD2 34 | getPinMode KEYWORD2 35 | setPinMode KEYWORD2 36 | getPinState KEYWORD2 37 | setPinState KEYWORD2 38 | attach KEYWORD2 39 | detach KEYWORD2 40 | write KEYWORD2 41 | sendValueAsTwo7bitBytes KEYWORD2 42 | startSysex KEYWORD2 43 | endSysex KEYWORD2 44 | writePort KEYWORD2 45 | readPort KEYWORD2 46 | disableBlinkVersion KEYWORD2 47 | 48 | 49 | ####################################### 50 | # Constants (LITERAL1) 51 | ####################################### 52 | 53 | FIRMATA_MAJOR_VERSION LITERAL1 54 | FIRMATA_MINOR_VERSION LITERAL1 55 | FIRMATA_BUGFIX_VERSION LITERAL1 56 | 57 | MAX_DATA_BYTES LITERAL1 58 | 59 | DIGITAL_MESSAGE LITERAL1 60 | ANALOG_MESSAGE LITERAL1 61 | REPORT_ANALOG LITERAL1 62 | REPORT_DIGITAL LITERAL1 63 | REPORT_VERSION LITERAL1 64 | SET_PIN_MODE LITERAL1 65 | SET_DIGITAL_PIN_VALUE LITERAL1 66 | SYSTEM_RESET LITERAL1 67 | START_SYSEX LITERAL1 68 | END_SYSEX LITERAL1 69 | REPORT_FIRMWARE LITERAL1 70 | STRING_DATA LITERAL1 71 | 72 | PIN_MODE_ANALOG LITERAL1 73 | PIN_MODE_PWM LITERAL1 74 | PIN_MODE_SERVO LITERAL1 75 | PIN_MODE_SHIFT LITERAL1 76 | PIN_MODE_I2C LITERAL1 77 | PIN_MODE_ONEWIRE LITERAL1 78 | PIN_MODE_STEPPER LITERAL1 79 | PIN_MODE_ENCODER LITERAL1 80 | PIN_MODE_SERIAL LITERAL1 81 | PIN_MODE_PULLUP LITERAL1 82 | PIN_MODE_IGNORE LITERAL1 83 | 84 | TOTAL_PINS LITERAL1 85 | TOTAL_ANALOG_PINS LITERAL1 86 | TOTAL_DIGITAL_PINS LITERAL1 87 | TOTAL_PIN_MODES LITERAL1 88 | TOTAL_PORTS LITERAL1 89 | ANALOG_PORT LITERAL1 90 | MAX_SERVOS LITERAL1 91 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot/RedBot_Experiments/Exp5_Bumpers/Exp5_Bumpers.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp5_Bumpers -- RedBot Experiment 5 3 | * 4 | * Now let's experiment with the whisker bumpers. These super-simple switches 5 | * let you detect a collision before it really happens- the whisker will 6 | * bump something before your robot crashes into it. 7 | * 8 | * This sketch was written by SparkFun Electronics, with lots of help from 9 | * the Arduino community. 10 | * This code is completely free for any use. 11 | * Visit https://learn.sparkfun.com/tutorials/redbot-inventors-kit-guide 12 | * for SIK information. 13 | * 14 | * 8 Oct 2013 M. Hord 15 | * Revised 30 Oct 2014 B. Huang 16 | ***********************************************************************/ 17 | 18 | #include 19 | RedBotMotors motors; 20 | 21 | RedBotBumper lBumper = RedBotBumper(3); // initialzes bumper object on pin 3 22 | RedBotBumper rBumper = RedBotBumper(11); // initialzes bumper object on pin 11 23 | 24 | int buttonPin = 12; // variable to store the button Pin 25 | 26 | int lBumperState; // state variable to store the bumper value 27 | int rBumperState; // state variable to store the bumper value 28 | 29 | void setup() 30 | { 31 | // nothing here. 32 | } 33 | 34 | void loop() 35 | { 36 | motors.drive(255); 37 | lBumperState = lBumper.read(); // default INPUT state is HIGH, it is LOW when bumped 38 | rBumperState = rBumper.read(); // default INPUT state is HIGH, it is LOW when bumped 39 | 40 | if (lBumperState == LOW) // left side is bumped/ 41 | { 42 | reverse(); // backs up 43 | turnRight(); // turns 44 | } 45 | 46 | if (rBumperState == LOW) // right side is bumped/ 47 | { 48 | reverse(); // backs up 49 | turnLeft(); // turns 50 | } 51 | 52 | } 53 | 54 | // reverse() function -- backs up at full power 55 | void reverse() 56 | { 57 | motors.drive(-255); 58 | delay(500); 59 | motors.brake(); 60 | delay(100); // short delay to let robot fully stop 61 | } 62 | 63 | // turnRight() function -- turns RedBot to the Right 64 | void turnRight() 65 | { 66 | motors.leftMotor(-150); // spin CCW 67 | motors.rightMotor(-150); // spin CCW 68 | delay(500); 69 | motors.brake(); 70 | delay(100); // short delay to let robot fully stop 71 | } 72 | 73 | // turnRight() function -- turns RedBot to the Left 74 | void turnLeft() 75 | { 76 | motors.leftMotor(+150); // spin CW 77 | motors.rightMotor(+150); // spin CW 78 | delay(500); 79 | motors.brake(); 80 | delay(100); // short delay to let robot fully stop 81 | } 82 | 83 | 84 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot2/RedBot_Experiments/Exp5_Bumpers/Exp5_Bumpers.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp5_Bumpers -- RedBot Experiment 5 3 | * 4 | * Now let's experiment with the whisker bumpers. These super-simple switches 5 | * let you detect a collision before it really happens- the whisker will 6 | * bump something before your robot crashes into it. 7 | * 8 | * This sketch was written by SparkFun Electronics, with lots of help from 9 | * the Arduino community. 10 | * This code is completely free for any use. 11 | * Visit https://learn.sparkfun.com/tutorials/redbot-inventors-kit-guide 12 | * for SIK information. 13 | * 14 | * 8 Oct 2013 M. Hord 15 | * Revised 30 Oct 2014 B. Huang 16 | ***********************************************************************/ 17 | 18 | #include 19 | RedBotMotors motors; 20 | 21 | RedBotBumper lBumper = RedBotBumper(3); // initialzes bumper object on pin 3 22 | RedBotBumper rBumper = RedBotBumper(11); // initialzes bumper object on pin 11 23 | 24 | int buttonPin = 12; // variable to store the button Pin 25 | 26 | int lBumperState; // state variable to store the bumper value 27 | int rBumperState; // state variable to store the bumper value 28 | 29 | void setup() 30 | { 31 | // nothing here. 32 | } 33 | 34 | void loop() 35 | { 36 | motors.drive(255); 37 | lBumperState = lBumper.read(); // default INPUT state is HIGH, it is LOW when bumped 38 | rBumperState = rBumper.read(); // default INPUT state is HIGH, it is LOW when bumped 39 | 40 | if (lBumperState == LOW) // left side is bumped/ 41 | { 42 | reverse(); // backs up 43 | turnRight(); // turns 44 | } 45 | 46 | if (rBumperState == LOW) // right side is bumped/ 47 | { 48 | reverse(); // backs up 49 | turnLeft(); // turns 50 | } 51 | 52 | } 53 | 54 | // reverse() function -- backs up at full power 55 | void reverse() 56 | { 57 | motors.drive(-255); 58 | delay(500); 59 | motors.brake(); 60 | delay(100); // short delay to let robot fully stop 61 | } 62 | 63 | // turnRight() function -- turns RedBot to the Right 64 | void turnRight() 65 | { 66 | motors.leftMotor(-150); // spin CCW 67 | motors.rightMotor(-150); // spin CCW 68 | delay(500); 69 | motors.brake(); 70 | delay(100); // short delay to let robot fully stop 71 | } 72 | 73 | // turnRight() function -- turns RedBot to the Left 74 | void turnLeft() 75 | { 76 | motors.leftMotor(+150); // spin CW 77 | motors.rightMotor(+150); // spin CW 78 | delay(500); 79 | motors.brake(); 80 | delay(100); // short delay to let robot fully stop 81 | } 82 | 83 | 84 | -------------------------------------------------------------------------------- /examples/sparkfun_redbot/sparkfun_experiments/Exp4_MakingSounds.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """ 3 | Exp4_MakingSounds -- RedBot Experiment 4 4 | 5 | Push the button (D12) to make some noise and start running! 6 | 7 | Hardware setup: 8 | Plug the included RedBot Buzzer board into the Servo header labeled 9. 9 | 10 | This sketch was written by SparkFun Electronics, with lots of help from 11 | the Arduino community. This code is completely free for any use. 12 | """ 13 | 14 | from pymata_aio.pymata3 import PyMata3 15 | from pymata_aio.constants import Constants 16 | import library.redbot as rb 17 | 18 | WIFLY_IP_ADDRESS = None # Leave set as None if not using WiFly 19 | WIFLY_IP_ADDRESS = "10.0.1.19" # If using a WiFly on the RedBot, set the ip address here. 20 | #WIFLY_IP_ADDRESS = "r01.wlan.rose-hulman.edu" # If your WiFi network allows it, you can use the device hostname instead. 21 | if WIFLY_IP_ADDRESS: 22 | # arduino_wait is a timer parameter to allow for the arduino to reboot when the connection is made which is NA for WiFly. 23 | board = PyMata3(arduino_wait=0, ip_address=WIFLY_IP_ADDRESS) 24 | else: 25 | # Use a USB cable to RedBot or an XBee connection instead of WiFly. 26 | COM_PORT = None # Use None for automatic com port detection, or set if needed i.e. "COM7" 27 | board = PyMata3(com_port=COM_PORT) 28 | 29 | # Instantiate the motor control object. This only needs to be done once. 30 | motors = rb.RedBotMotors(board) 31 | 32 | BUZZER_PIN = 9 33 | BUTTON_PIN = 12 34 | 35 | 36 | def setup(): 37 | board.set_pin_mode(BUTTON_PIN, Constants.INPUT) # configures the button as an INPUT 38 | board.digital_write(BUTTON_PIN, 1) # Turns ON the pull up on the INPUT 39 | board.set_pin_mode(BUZZER_PIN, Constants.OUTPUT) # configures the buzzerPin as an OUTPUT 40 | 41 | 42 | def loop(): 43 | if board.digital_read(BUTTON_PIN) == 0: 44 | board.play_tone(BUZZER_PIN, Constants.TONE_TONE, 1000, None) 45 | board.sleep(0.125) # Wait for 125ms. 46 | board.play_tone(BUZZER_PIN, Constants.TONE_NO_TONE, 0, 0) # Stop playing the tone. 47 | 48 | # Turn on Tone again, at 2khz 49 | board.play_tone(BUZZER_PIN, Constants.TONE_TONE, 2000, 1000) # Play a 2kHz tone on the buzzer pin 50 | motors.drive(255) # Drive forward for a while 51 | board.sleep(1.0) 52 | # board.play_tone(BUZZER_PIN, Constants.TONE_NO_TONE, 0, 0) # Not needed since set already. 53 | motors.brake() 54 | else: 55 | pass # Otherwise do this. 56 | 57 | if __name__ == "__main__": 58 | setup() 59 | while True: 60 | loop() 61 | board.sleep(0.025) 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .project 3 | .pydevproject 4 | 5 | *.prefs 6 | .cache/ 7 | .idea/ 8 | Adventures in The Cloud_ Documenting python code using sphinx and github.html 9 | Adventures in The Cloud_ Documenting python code using sphinx and github_files/ 10 | FirmataPlus/libraries/ 11 | __init__.py 12 | __pycache__/ 13 | abtests/ 14 | build/ 15 | creating_sphinx_docs.txt 16 | dist/ 17 | docs/ 18 | documentation/__pycache__/ 19 | documentation/images/Screenshot from 2016-01-05 11-45-39.png 20 | examples/__init__.py 21 | examples/__pycache__/ 22 | examples/adxl345.py 23 | examples/bug.py 24 | examples/callback_example.py 25 | examples/core_sample.py~ 26 | examples/jimmy2.py 27 | examples/mma8452q2.py 28 | examples/mma8452qSave.py 29 | examples/new_blink.py 30 | examples/new_blink2.py 31 | examples/osx_serial.py 32 | examples/prof 33 | examples/prof.txt 34 | examples/rbEncoder.py 35 | examples/rbStandAloneTalk.py 36 | examples/red_bot/ 37 | examples/redbot_accel.py 38 | examples/simpleMotors.py 39 | examples/simple_mult_input.py 40 | examples/sock.py 41 | examples/sock3.py 42 | examples/sonar.py 43 | examples/sparkfun_redbot/MrYLogo.png 44 | examples/sparkfun_redbot/__init__.py 45 | examples/sparkfun_redbot/__pycache__/ 46 | examples/sparkfun_redbot/abc.py 47 | examples/sparkfun_redbot/accel_basic_pymata3.py 48 | examples/sparkfun_redbot/accel_basic_pymata_core.py 49 | examples/sparkfun_redbot/get_page.py 50 | examples/sparkfun_redbot/html/ 51 | examples/sparkfun_redbot/newStandAlone.py 52 | examples/sparkfun_redbot/rbDash.html 53 | examples/sparkfun_redbot/rbStandAlone.py 54 | examples/sparkfun_redbot/rb_accel.py 55 | examples/sparkfun_redbot/redbot.py 56 | examples/sparkfun_redbot/redbot2.py 57 | examples/sparkfun_redbot/redbot_accel.py 58 | examples/sparkfun_redbot/redbot_control.py 59 | examples/sparkfun_redbot/redbot_controller.py 60 | examples/sparkfun_redbot/redbot_dash.py 61 | examples/sparkfun_redbot/sparkfun_experiments/library/__pycache__/ 62 | examples/sparkfun_redbot/test_socket_client.py 63 | examples/test3.py 64 | examples/test3accel.py 65 | examples/tmp102.py 66 | keepAliveCalcs.ods 67 | keepAliveCalcs.xls 68 | Would skip repository pymata-aio.wiki/ 69 | pymata_aio.egg-info/ 70 | pymata_aio/.pymata_core.log 71 | pymata_aio/__pycache__/ 72 | pymata_aio/jimmy2.py 73 | pymata_aio/latching.py 74 | pymata_aio/pymata_aio.html 75 | pymata_aio/pymata_aio.log 76 | pymata_aio/pymata_iot.py~ 77 | talk/ 78 | tcp_stuff.py 79 | test/__pycache__/ 80 | test/all.py 81 | test/buttonTest.py 82 | test/dave.py 83 | test/dave2.py 84 | test/dave3.py 85 | test/dave4.py 86 | test/dave5.py 87 | test/i2c/i2c_write/__pycache__/ 88 | test/keep_alive.py 89 | test/leigh1.py 90 | test/redbot_demo.py 91 | test/testDigitalReporting.py 92 | test/xyz.py 93 | test_allx.py 94 | wiki_Backup/ 95 | -------------------------------------------------------------------------------- /FirmataPlus/source/libraries/RedBot2/RedBot_Experiments/Exp8_1_AccelerometerRead/Exp8_1_AccelerometerRead.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Exp8_1_AccelerometerRead -- RedBot Experiment 8.1 3 | * 4 | * Measuring speed, velocity, and acceleration are all key 5 | * components to robotics. This first experiment will introduce 6 | * you to using the Accelerometer sensor on the RedBot. 7 | * 8 | * Hardware setup: 9 | * You'll need to attach the RedBot Accelerometer board to hader on the upper 10 | * right side of the mainboard. See the manual for details on how to do this. 11 | * 12 | * This sketch was written by SparkFun Electronics, with lots of help from 13 | * the Arduino community. This code is completely free for any use. 14 | * 15 | * 8 Oct 2013 M. Hord 16 | * Revised, 31 Oct 2014 B. Huang 17 | * 18 | * 8 Oct 2013 M. Hord 19 | * 20 | * This experiment was inspired by Paul Kassebaum at Mathworks, who made 21 | * one of the very first non-SparkFun demo projects and brought it to the 22 | * 2013 Open Hardware Summit in Boston. Thanks Paul! 23 | ***********************************************************************/ 24 | 25 | #include 26 | RedBotMotors motors; 27 | 28 | // The RedBot library includes support for the accelerometer. We've tried 29 | // to make using the accelerometer as easy as to use as possible. 30 | 31 | RedBotAccel accelerometer; 32 | 33 | void setup(void) 34 | { 35 | Serial.begin(9600); 36 | } 37 | 38 | void loop(void) 39 | { 40 | accelerometer.read(); // updates the x, y, and z axis readings on the acceleromter 41 | 42 | // Display out the X, Y, and Z - axis "acceleration" measurements and also 43 | // the relative angle between the X-Z, Y-Z, and X-Y vectors. (These give us 44 | // the orientation of the RedBot in 3D space. 45 | 46 | Serial.print("("); 47 | Serial.print(accelerometer.xm); 48 | Serial.print(", "); // tab 49 | Serial.print(accelerometer.xl); 50 | Serial.print(", "); // tab 51 | 52 | Serial.print(accelerometer.ym); 53 | Serial.print(", "); // tab 54 | Serial.print(accelerometer.yl); 55 | Serial.print(", "); // tab] 56 | 57 | Serial.print(accelerometer.zm); 58 | Serial.print(", "); // tab 59 | Serial.print(accelerometer.zl); 60 | Serial.print(", "); // tab 61 | 62 | /* 63 | Serial.print(accelerometer.y); 64 | Serial.print(", "); // tab 65 | 66 | Serial.print(accelerometer.z); 67 | */ 68 | Serial.print(") -- "); // tab 69 | 70 | Serial.print("["); 71 | Serial.print(accelerometer.angleXZ); 72 | Serial.print(", "); 73 | Serial.print(accelerometer.angleYZ); 74 | Serial.print(", "); 75 | Serial.print(accelerometer.angleXY); 76 | Serial.println("]"); 77 | 78 | // short delay in between readings/ 79 | delay(100); 80 | } 81 | 82 | --------------------------------------------------------------------------------