├── .gitignore ├── JanServo ├── Examples │ ├── ContiniousServo │ │ └── ContiniousServo.ino │ ├── ContraintServo │ │ └── ContraintServo.ino │ └── latchServo │ │ └── latchServo.ino └── JanServo.cpp ├── SerialBridgeCommunicator ├── configure │ ├── dynamic │ │ ├── merge-sketch-with-bootloader.lua │ │ ├── startBonjour │ │ ├── stopReadingArduino.sh │ │ ├── dump.html │ │ ├── fixmount │ │ ├── cgiutil │ │ ├── do.cgi │ │ ├── kill-bridge │ │ ├── start.sh │ │ ├── getkeyValue │ │ ├── getkeyValueCommand │ │ ├── value │ │ ├── setkeyValue │ │ ├── setkeyValueCommand │ │ ├── doBackup │ │ ├── set.cgi │ │ ├── MakeWebPage.sh │ │ ├── move-log-files-to-nas.sh │ │ ├── index.html │ │ ├── startReadingArduino.sh │ │ ├── Bonjour │ │ ├── SetGlobalSettings.sh │ │ ├── ParseArduinoInput.sh │ │ └── upload.lua │ ├── static │ │ ├── input.end.html │ │ ├── 0.png │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── tabs.gif │ │ ├── default.html │ │ ├── tabs.css │ │ └── input.begin.html │ ├── read.me │ └── startup └── SerialBridgeCommunicator.h ├── Readme.txt ├── gdb ├── gdb.c └── gdb.h ├── wiebel ├── readme.txt └── wiebel.h ├── Sabertooth ├── SabertoothArduinoLibrary.chm ├── keywords.txt ├── license.txt ├── examples │ ├── 3.Advanced │ │ ├── SoftwareSerial │ │ │ └── SoftwareSerial.ino │ │ └── SharedLine │ │ │ └── SharedLine.ino │ ├── 2.Settings │ │ ├── MinVoltage │ │ │ └── MinVoltage.ino │ │ ├── Persistent │ │ │ ├── Deadband │ │ │ │ └── Deadband.ino │ │ │ ├── Ramping │ │ │ │ └── Ramping.ino │ │ │ ├── MaxVoltage │ │ │ │ └── MaxVoltage.ino │ │ │ └── BaudRate │ │ │ │ └── BaudRate.ino │ │ └── SerialTimeout │ │ │ └── SerialTimeout.ino │ └── 1.Basics │ │ ├── Jolty │ │ └── Jolty.ino │ │ └── Sweep │ │ └── Sweep.ino └── changes.txt ├── SabertoothSimplified ├── SabertoothSimplifiedArduinoLibrary.chm ├── keywords.txt ├── examples │ ├── SoftwareSerial │ │ └── SoftwareSerial.ino │ ├── SimpleExample │ │ └── SimpleExample.ino │ └── Sweep │ │ └── Sweep.ino ├── SabertoothSimplified.cpp └── SabertoothSimplified.h ├── MotorMegaMoto ├── Examples │ ├── engineTester │ │ ├── brains.cpp │ │ ├── brains.h │ │ └── engineTester.h │ └── megamotoHridgeDriver │ │ └── megamotoHbridgeDiver.ino ├── MotorMegaMoto.cpp ├── HalfBridge.cpp └── HalfBridge.h ├── .settings └── org.eclipse.core.resources.prefs ├── SerialStringReader ├── ReadMe.txt ├── Examples │ ├── serialCommunicatorStep1 │ │ └── serialCommunicatorStep1.ino │ └── serialCommunicatorStep2 │ │ └── serialCommunicatorStep2.ino ├── SerialStringReader.cpp └── SerialStringReader.h ├── .project ├── BlinkLed ├── examples │ ├── oneBlinkLed │ │ └── oneBlinkLed.ino │ └── twoBlinkLeds │ │ └── twoBlinkLeds.ino ├── BlinkLed.h └── BlinkLed.cpp ├── gtest ├── examples │ ├── blink │ │ ├── blink.h │ │ ├── blink.cpp │ │ └── gtest.cpp │ └── gtest │ │ └── gtest.cpp ├── gtest_main.cc └── gtest │ └── gtest_prod.h ├── I2CLiquidCrystal ├── mapper.h ├── Examples │ ├── LCDSlave │ │ └── mapper.h │ └── LCDMaster │ │ └── LCDMaster.ino ├── readme.txt └── I2CLiquidCrystal.h ├── DigitalPotmeterAD5171 ├── DigitalPotmeterAD5171.h └── DigitalPotmeterAD5171.cpp ├── BlinkLedSerial ├── BlinkLedSerial.cpp └── BlinkLedSerial.h ├── RCLib ├── Readme.txt └── Examples │ └── Maga6ChanelsA8_A13 │ └── Maga6ChanelsA8_A13.ino ├── SimpleSwitch ├── SimpleSwitch.h └── SimpleSwitch.cpp ├── SerialCommunicator ├── FakeComunicator.h ├── examples │ ├── AnalogTest │ │ ├── Analog.h │ │ ├── AnalogTest.ino │ │ └── Analog.cpp │ ├── webcalculator │ │ └── webcalculator.ino │ ├── PWMexample │ │ └── PWMexample.ino │ └── serialCommunicatorStep4 │ │ └── serialCommunicatorStep4.ino └── SerialCommunicator.h ├── simplot ├── examples │ ├── makerfairRome2017Demo │ │ ├── makerfairRome2017Demo.h │ │ ├── readme.md │ │ ├── gtest.cpp │ │ └── makerfairRome2017Demo.ino │ └── plotterExample │ │ └── plotterExample.ino ├── simplot.h └── simplot.cpp ├── TempMeterAdafruitmcp9808 ├── TempMeterAdafruitmcp9808.h └── TempMeterAdafruitmcp9808.cpp ├── DataTypes └── examples │ └── prescalerTest │ └── prescalertest.ino ├── SerialSDCommunicator └── SerialSDCommunicator.h ├── DigitalPotmeterMCP413 ├── DigitalPotmeterMCP413.h └── DigitalPotmeterMCP413.cpp ├── SerialEEPROMCommunicator └── SerialEEPROMCommunicator.h ├── DigitalPotmeterInterface ├── DigitalPotmeterInterface.h └── examples │ └── digital_potmeter │ └── digital_potmeter.ino ├── CurrentSensorLem ├── LemCurrentSensor.h └── LemCurrentSensor.cpp ├── CurrentSensorInterface └── CurrentSensorInterface.h ├── MotorBLDC ├── examples │ ├── BLDC1driverTester │ │ └── BLDC1DriverTester.cpp │ └── BLDC1motorTester │ │ └── BLDC1MotorTester.cpp ├── MotorBLDC.h └── MotorBLDC.cpp ├── SkidDriverSaberTooth ├── SkidDriversaberTooth.h └── SkidDriversaberTooth.cpp ├── CurrentSensorAnalog ├── CurrentSensorAnalog.h └── CurrentSensorAnalog.cpp ├── TempMeterTemperatureSensetiveResistor └── TempMeterTemperatureSensetiveResistor.h ├── minibridge ├── MiniBridge.h ├── MiniProcess.cpp └── MiniProcess.h ├── TempMeterInterface └── TempMeterInterface.h ├── SkidDriverInterface └── SkidDriverinterface.h ├── MotorPWM ├── examples │ └── pwmMotor │ │ └── PWMMotorTest.ino └── MotorPWM.h ├── SkidDriverBLDC └── SkidDriverBLDC.h ├── VoltMeter ├── VoltMeter.h └── VoltMeter.cpp ├── MotorPotmeterDirection └── MotorPotmeterDirection.h ├── gps_Library └── examples │ └── gpsTester │ └── gps_tester.ino ├── SerialDataInterface ├── FieldInfo.h └── FieldInfo.cpp ├── MotorMegaMotoLoadHBridge └── MotorMegaMotoLoadHBridge.h ├── SkidDriverMegaMoto └── SkidDriverMegaMoto.h ├── TempMeterDS18B20 ├── TempMeterDS18B20.h └── examples │ └── mulitple_DS18b20 │ └── mulitple_DS18b20.ino ├── MotorMegaMotoHBridge ├── MotorMegaMotoHBridge.h └── MotorMegaMotoHBridge.cpp └── MotorInterface └── MotorInterface.h /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /JanServo/Examples/ContiniousServo/ContiniousServo.ino: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/merge-sketch-with-bootloader.lua: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/static/input.end.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Readme.txt: -------------------------------------------------------------------------------- 1 | Here I keep libraries I developped for Arduino 2 | 3 | Jan Baeyens 4 | 5 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/startBonjour: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | Bonjour & 3 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/stopReadingArduino.sh: -------------------------------------------------------------------------------- 1 | killall ParseArduinoInput.sh -------------------------------------------------------------------------------- /gdb/gdb.c: -------------------------------------------------------------------------------- 1 | 2 | #include "gdb.h" 3 | void gdbstub_init() 4 | { 5 | } 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /wiebel/readme.txt: -------------------------------------------------------------------------------- 1 | This is a librarie that allows you to easily make a wobling (wiebel in dutch) movement with a servo. 2 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/dump.html: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . ./SetGlobalSettings.sh 3 | 4 | echo DUMP >> ${PortName} 5 | -------------------------------------------------------------------------------- /Sabertooth/SabertoothArduinoLibrary.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantje/ArduinoLibraries/HEAD/Sabertooth/SabertoothArduinoLibrary.chm -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/fixmount: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | umount /mnt/sda1 5 | dosfsck -a /dev/sda1 6 | block mount 7 | 8 | 9 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/static/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantje/ArduinoLibraries/HEAD/SerialBridgeCommunicator/configure/static/0.png -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/static/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantje/ArduinoLibraries/HEAD/SerialBridgeCommunicator/configure/static/1.png -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/static/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantje/ArduinoLibraries/HEAD/SerialBridgeCommunicator/configure/static/2.png -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/static/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantje/ArduinoLibraries/HEAD/SerialBridgeCommunicator/configure/static/3.png -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/static/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantje/ArduinoLibraries/HEAD/SerialBridgeCommunicator/configure/static/4.png -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/cgiutil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantje/ArduinoLibraries/HEAD/SerialBridgeCommunicator/configure/dynamic/cgiutil -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/do.cgi: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . SetGlobalSettings.sh 3 | 4 | echo >> ${PortName} 5 | echo $QUERY_STRING >> ${PortName} 6 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/static/tabs.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantje/ArduinoLibraries/HEAD/SerialBridgeCommunicator/configure/static/tabs.gif -------------------------------------------------------------------------------- /SabertoothSimplified/SabertoothSimplifiedArduinoLibrary.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jantje/ArduinoLibraries/HEAD/SabertoothSimplified/SabertoothSimplifiedArduinoLibrary.chm -------------------------------------------------------------------------------- /MotorMegaMoto/Examples/engineTester/brains.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * brains.cpp 3 | * 4 | * Created on: Nov 11, 2013 5 | * Author: jan 6 | */ 7 | 8 | #include "brains.h" 9 | 10 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//SerialBridgeCommunicator/configure/read.me=UTF-8 3 | encoding//SerialBridgeCommunicator/configure/startup=UTF-8 4 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/kill-bridge: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . SetGlobalSettings.sh 3 | if [ ${UploadPortName} == ${PortName} ] ; then 4 | stopReadingArduino.sh 5 | fi 6 | rm -f ${OutputValue} 7 | 8 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . SetGlobalSettings.sh 4 | ${SttyCommand} >/dev/null 5 | echo >> ${PortName} 6 | echo "LOG HEADER">> ${PortName} 7 | sleep 60 8 | echo DUMP>> ${PortName} -------------------------------------------------------------------------------- /gdb/gdb.h: -------------------------------------------------------------------------------- 1 | #ifndef GDBSTUB_H 2 | #define GDBSTUB_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void gdbstub_init(); 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #define RAMFUNC 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/getkeyValue: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #give the filename and key as params 3 | value=`grep ^${2}: <${1} |sed s#^${2}:##` 4 | echo file ${1} field ${2} value ${value} >> /tmp/getkeyValue.log 5 | echo ${value} 6 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/getkeyValueCommand: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . SetGlobalSettings.sh 3 | 4 | mkdir -p ${SlowBigStorage} 5 | cd ${SlowBigStorage} 6 | touch values 7 | res=`getkeyValue values $1` 8 | 9 | echo SET $1=$res 10 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/value: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #I'm using a script to return the file ${OutputValue} 3 | #to avoid the browser caching the data 4 | . SetGlobalSettings.sh 5 | 6 | echo Content-type: text/plain 7 | echo "" 8 | cat ${OutputValue} 9 | -------------------------------------------------------------------------------- /SerialStringReader/ReadMe.txt: -------------------------------------------------------------------------------- 1 | This is a library that allows for line by line reading of the serial interface. 2 | There is no keywords.txt file. 3 | Feel free to add. 4 | 5 | This source can be freely distributed and edited but the author can not be removed 6 | Jantje -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/setkeyValue: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #give the filename and key and value as params 3 | mkdir -p /tmp/jantje/ 4 | grep -v ^${2}: <${1} >/tmp/jantje/keyvalue.tmp 5 | mv /tmp/jantje/keyvalue.tmp ${1} 6 | echo ${2}:${3}>>${1} 7 | echo OK 8 | 9 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/setkeyValueCommand: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . SetGlobalSettings.sh 3 | 4 | mkdir -p ${SlowBigStorage} 5 | cd ${SlowBigStorage} 6 | touch values 7 | res=`setkeyValue values $1 $2` 8 | 9 | echo setkeyValueCommand $1 $res 10 | 11 | 12 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ArduinoLibraries 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /SabertoothSimplified/keywords.txt: -------------------------------------------------------------------------------- 1 | # Syntax Coloring for the Sabertooth Simplified Serial Library 2 | 3 | # Classes 4 | SabertoothSimplified KEYWORD1 5 | 6 | # SabertoothSimplified methods 7 | motor KEYWORD2 8 | drive KEYWORD2 9 | turn KEYWORD2 10 | stop KEYWORD2 11 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/doBackup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . SetGlobalSettings.sh 4 | mkdir -p ${backupLocation}/dynamic 5 | mkdir -p ${backupLocation}/static 6 | cp ${WebLocationDynamic}/* ${backupLocation}/dynamic 7 | cp ${WebLocationStatic}/* ${backupLocation}/static 8 | 9 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/set.cgi: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . SetGlobalSettings.sh 3 | 4 | echo >> ${PortName} 5 | echo SET $QUERY_STRING | sed 's/%20/ /g' |sed 's/%60/`/g'|sed 's/%3E/>/g'|sed 's/%22/"/g' |sed 's/%27/"/g' >> ${PortName} 6 | echo LOG VALUE >> ${PortName} 7 | echo $QUERY_STRING 8 | -------------------------------------------------------------------------------- /BlinkLed/examples/oneBlinkLed/oneBlinkLed.ino: -------------------------------------------------------------------------------- 1 | #include "BlinkLed.h" 2 | 3 | //use the default blinkled to blink 1s on 2s off 4 | BlinkLed buildInled(LED_BUILTIN,1000 ,2000); 5 | void setup() 6 | { 7 | buildInled.setup(); 8 | } 9 | 10 | // The loop function is called in an endless loop 11 | void loop() 12 | { 13 | buildInled.loop(); 14 | } 15 | -------------------------------------------------------------------------------- /gtest/examples/blink/blink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * blink.h 3 | * 4 | * Created on: Nov 27, 2015 5 | * Author: jan 6 | */ 7 | 8 | #ifndef BLINK_H_ 9 | #define BLINK_H_ 10 | #include "Arduino.h" 11 | #define INTERVAL 500 //The blinking interval 12 | 13 | uint8_t calcLedState(uint32_t currentMillis, uint8_t ledState); 14 | 15 | 16 | #endif /* BLINK_H_ */ 17 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/MakeWebPage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/ash 2 | . ./SetGlobalSettings.sh 3 | export DumpFile=${DumpFile} 4 | echo "" 5 | sed 's#SKETCHNAME#'"maairobot"'#' ${BeginHtml} | sed 's#STATICFOLDER#'"${staticfolderURL}"'#' 6 | echo "" 7 | ./MakeWebPage.lua 8 | echo "" 9 | cat ${EndHtml} 10 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/static/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to the Arduino 5 | 6 | 7 | 8 |

Welcome to Arduino

9 | 10 | The web page is not yet available. The creation has been requested.
11 | Please retry in 4 minutes. 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /BlinkLed/examples/twoBlinkLeds/twoBlinkLeds.ino: -------------------------------------------------------------------------------- 1 | #include "BlinkLed.h" 2 | 3 | //use the default blinkled to blink 1s on 2s off 4 | BlinkLed buildInled(LED_BUILTIN,1000 ,2000); 5 | //change the pin number of the second led 6 | BlinkLed anotherInled(12,2000 ,1000); 7 | void setup() 8 | { 9 | buildInled.setup(); 10 | anotherInled.setup(); 11 | } 12 | 13 | // The loop function is called in an endless loop 14 | void loop() 15 | { 16 | buildInled.loop(); 17 | anotherInled.loop(); 18 | } 19 | -------------------------------------------------------------------------------- /Sabertooth/keywords.txt: -------------------------------------------------------------------------------- 1 | # Syntax Coloring for the Sabertooth Library 2 | 3 | # Classes 4 | Sabertooth KEYWORD1 5 | 6 | # Sabertooth methods 7 | address KEYWORD2 8 | port KEYWORD2 9 | autobaud KEYWORD2 10 | 11 | # Common methods 12 | command KEYWORD2 13 | motor KEYWORD2 14 | drive KEYWORD2 15 | turn KEYWORD2 16 | setMinVoltage KEYWORD2 17 | setMaxVoltage KEYWORD2 18 | setBaudRate KEYWORD2 19 | setDeadband KEYWORD2 20 | setRamping KEYWORD2 21 | setTimeout KEYWORD2 22 | stop KEYWORD2 23 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/move-log-files-to-nas.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #This scripts starts the whole arduino openwrt communication. 3 | # start with DUMP the first time so that a web page is created. 4 | 5 | . SetGlobalSettings.sh 6 | 7 | mkdir -p ${CommonHugeRemoteMountPoint} 8 | umount ${CommonHugeRemoteMountPoint} 9 | mount -t cifs //${HugeRemoteStorageServer}/home ${CommonHugeRemoteMountPoint} -o user=Marvin2,pass=Marvin2 10 | mkdir -p ${backupLocation} 11 | 12 | mv ${SlowBigStorage)/log/* ${backupLocation}/log 13 | -------------------------------------------------------------------------------- /I2CLiquidCrystal/mapper.h: -------------------------------------------------------------------------------- 1 | 2 | #define _print 'p' 3 | #define _println 'P' 4 | #define _clear '3' 5 | #define _home 'h' 6 | #define _noDisplay 'd' 7 | #define _display 'D' 8 | #define _noBlink 'b' 9 | #define _blink 'B' 10 | #define _noCursor 'c' 11 | #define _cursor 'C' 12 | #define _scrollDisplayLeft 's' 13 | #define _scrollDisplayRight 'S' 14 | #define _rightToLeft 'r' 15 | #define _leftToRight 'l' 16 | #define _autoscroll 'a' 17 | #define _noAutoscroll 'A' 18 | #define _setCursor '1' 19 | #define _setBackground '2' 20 | 21 | #define sepperator ';' 22 | 23 | 24 | -------------------------------------------------------------------------------- /I2CLiquidCrystal/Examples/LCDSlave/mapper.h: -------------------------------------------------------------------------------- 1 | 2 | #define _print 'p' 3 | #define _println 'P' 4 | #define _clear '3' 5 | #define _home 'h' 6 | #define _noDisplay 'd' 7 | #define _display 'D' 8 | #define _noBlink 'b' 9 | #define _blink 'B' 10 | #define _noCursor 'c' 11 | #define _cursor 'C' 12 | #define _scrollDisplayLeft 's' 13 | #define _scrollDisplayRight 'S' 14 | #define _rightToLeft 'r' 15 | #define _leftToRight 'l' 16 | #define _autoscroll 'a' 17 | #define _noAutoscroll 'A' 18 | #define _setCursor '1' 19 | #define _setBackground '2' 20 | 21 | #define sepperator ';' 22 | 23 | 24 | -------------------------------------------------------------------------------- /DigitalPotmeterAD5171/DigitalPotmeterAD5171.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AD5171.h 3 | * 4 | * Created on: Jul 11, 2014 5 | * Author: jan 6 | */ 7 | 8 | #ifndef AD5171_H_ 9 | #define AD5171_H_ 10 | #include "Arduino.h" 11 | #include "Wire.h" 12 | #include "IDigitalPotmeter.h" 13 | 14 | class AD5171:public IDigitalPotmeter 15 | { 16 | private: 17 | uint8_t myI2CAdress; //the I2CAdress of the I2CPotmeter 18 | public: 19 | AD5171(uint8_t myMaxPotValue,uint8_t I2CAdress); 20 | virtual void setup(); 21 | virtual void loop(); 22 | }; 23 | 24 | #endif /* AD5171_H_ */ 25 | -------------------------------------------------------------------------------- /BlinkLedSerial/BlinkLedSerial.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BlinkLedSerial.cpp 3 | * 4 | * Created on: Nov 7, 2014 5 | * Author: jan 6 | */ 7 | 8 | #include 9 | 10 | void BlinkLedSerial::serialRegister(const __FlashStringHelper* Name) 11 | { 12 | FieldData::set(Name, F("OnInterval"),MOD_WRITE|MOD_SAVE,&myOnInterval); 13 | FieldData::set(Name, F("OffInterval"),MOD_WRITE|MOD_SAVE,&myOffInterval); 14 | FieldData::set(Name, F("LedState"),0,&myLedState); 15 | FieldData::set(Name, F("PreviousMillis"),0,&myPreviousMillis); 16 | FieldData::set(Name, F("LedPin"),0,&myLedPin); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /I2CLiquidCrystal/readme.txt: -------------------------------------------------------------------------------- 1 | A library that alows to save pins when using a liquid crystal LCD by using 2 arduinos communicating with TWI 2 | As a have a RGB backlight I also added a RGB setting method. 3 | Compile and upload LCDSlave to the arduino connected to the LCD (change the pins as needed) 4 | Compile and upload the LCDMaster tot he Arduino 2 5 | connect the 2 arduino's with the TWI pins (uno A4 and A5) 6 | The LCD should say on line 1: "Hello, ARDUINO" 7 | on lIne 2 you have a increasing number. 8 | If you have a RGB backlight connected than the RGB color should change with each increment between red green blue. 9 | -------------------------------------------------------------------------------- /RCLib/Readme.txt: -------------------------------------------------------------------------------- 1 | 2 | RCLib 3 | Is a library that is build to read the RC signal based on interrupts. 4 | This is a library that is based on the excelent code deliverd by duane 5 | Read following articles to know how this library works 6 | 7 | http://rcarduino.blogspot.be/2012/01/how-to-read-rc-receiver-with.html 8 | http://rcarduino.blogspot.be/2012/01/how-to-read-rc-receiver-with_20.html 9 | http://rcarduino.blogspot.com/2012/04/how-to-read-multiple-rc-channels-draft.html 10 | 11 | if you are serious about RC this may be of your interest to 12 | http://rcarduino.blogspot.be/2012/01/how-to-read-rc-receiver-with_25.html 13 | 14 | -------------------------------------------------------------------------------- /SimpleSwitch/SimpleSwitch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SimpleSwitch.h 3 | * 4 | * Created on: 29 sep. 2022 5 | * Author: jan 6 | */ 7 | #pragma once 8 | #include "Arduino.h" 9 | #include "FastRunningMedian.h" 10 | #define NUM_HIT_READS 4 11 | 12 | class SimpleSwitch 13 | { 14 | public: 15 | SimpleSwitch(uint8_t pin, uint8_t closedState); 16 | void setup(); 17 | void loop(); 18 | bool isClosed() 19 | { 20 | return myIsClosed; 21 | } 22 | private: 23 | FastRunningMedian myReads; 24 | uint8_t myPin; 25 | uint8_t myClosedState; 26 | bool myIsClosed; 27 | uint32_t last_Switchread; 28 | }; 29 | 30 | -------------------------------------------------------------------------------- /SerialCommunicator/FakeComunicator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FakeComunicator.h 3 | * 4 | * Created on: Jan 26, 2014 5 | * Author: jan 6 | */ 7 | 8 | #ifndef FAKECOMUNICATOR_H_ 9 | #define FAKECOMUNICATOR_H_ 10 | 11 | class FakeComunicator 12 | { 13 | public: 14 | 15 | FakeComunicator(uint8_t resetPin=0){}; 16 | virtual ~FakeComunicator() 17 | { 18 | } 19 | /** 20 | * Initializes the class. 21 | * Call this method in your setup() 22 | */ 23 | void setup(){}; 24 | void serialRegister(const __FlashStringHelper* Name){}; 25 | /** 26 | * Add the Loop() in your loop(); 27 | */ 28 | void loop(){}; 29 | }; 30 | 31 | #endif /* FAKECOMUNICATOR_H_ */ 32 | 33 | -------------------------------------------------------------------------------- /simplot/examples/makerfairRome2017Demo/makerfairRome2017Demo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * makerfairRome2017Demo.h 3 | * 4 | * Created on: 24 nov. 2017 5 | * Author: jan 6 | */ 7 | 8 | #ifndef MAKERFAIRROME2017DEMO_H_ 9 | #define MAKERFAIRROME2017DEMO_H_ 10 | 11 | 12 | #include "Arduino.h" 13 | #include "simplot.h" 14 | int getBlinkLedValue(const uint32_t currentMillis, const uint32_t onInterval, const uint32_t offInterval) ; 15 | int getFadeLedValue(const uint32_t currentMillis, const uint32_t onInterval, const uint32_t offInterval) ; 16 | uint32_t numTriggers(const uint32_t currentMillis,const uint32_t triggerInterval) ; 17 | 18 | 19 | #endif /* MAKERFAIRROME2017DEMO_H_ */ 20 | -------------------------------------------------------------------------------- /MotorMegaMoto/Examples/engineTester/brains.h: -------------------------------------------------------------------------------- 1 | /* 2 | * brains.h 3 | * 4 | * Created on: Nov 11, 2013 5 | * Author: jan 6 | */ 7 | 8 | #ifndef BRAINS_H_ 9 | #define BRAINS_H_ 10 | #include"MotorMegaMoto.h" 11 | #include "TempMeterInterface.h" 12 | #include "DataTypes.h" 13 | 14 | extern MotorMegaMoto myTestMotor; 15 | extern TempMeterInterface & myHeatSensor; 16 | 17 | class brains 18 | { 19 | protected: 20 | //For SerialDataInterface 21 | int field1; 22 | 23 | public: 24 | brains() 25 | { 26 | field1=0; 27 | } 28 | void setup(){}; 29 | void loop(){}; 30 | }; 31 | 32 | #endif /* BRAINS_H_ */ 33 | 34 | //Added by Sloeber 35 | #pragma once 36 | -------------------------------------------------------------------------------- /TempMeterAdafruitmcp9808/TempMeterAdafruitmcp9808.h: -------------------------------------------------------------------------------- 1 | /* 2 | * adafruitmcp9808.h 3 | * 4 | * Created on: May 12, 2015 5 | * Author: jan 6 | */ 7 | 8 | #ifndef LIBRARIES_TEMPMETER_ADAFRUITMCP9808_H_ 9 | #define LIBRARIES_TEMPMETER_ADAFRUITMCP9808_H_ 10 | 11 | #include "TempMeterInterface.h" 12 | 13 | class TempMeterAdafruitmcp9808: public TempMeterInterface 14 | { 15 | private: 16 | uint8_t myAddress; 17 | uint16_t read16(uint8_t reg); 18 | 19 | public: 20 | TempMeterAdafruitmcp9808(uint8_t address) 21 | { 22 | myAddress = address; 23 | } 24 | ; 25 | void setup(); 26 | void loop(); 27 | }; 28 | 29 | #endif /* LIBRARIES_TEMPMETER_ADAFRUITMCP9808_H_ */ 30 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/index.html: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #this script returns the generated.html (${OutputHtml}). 3 | #if that file is not existing 4 | # 1)the DUMP command will be launched so it will be available over time 5 | # 2) A default html is returned ($defaulthtmlFile) 6 | 7 | . SetGlobalSettings.sh 8 | 9 | #if the arduino dump data exists return it 10 | if [ -f ${OutputHtml} ]; then 11 | 12 | echo Content-type: text/html 13 | echo "" 14 | cat ${OutputHtml} 15 | #if not return he default and make the arduino to dump his data 16 | else 17 | echo Content-type: text/html 18 | echo "" 19 | cat ${defaulthtmlFile} 20 | 21 | ${WebLocationDynamic}/startReadingArduino.sh DUMP 22 | fi 23 | -------------------------------------------------------------------------------- /gtest/examples/blink/blink.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * blink.cpp 3 | * 4 | * Created on: Nov 27, 2015 5 | * Author: jan 6 | */ 7 | 8 | #include "blink.h" 9 | #include "Arduino.h" 10 | 11 | void setup() { 12 | pinMode(LED_BUILTIN, OUTPUT); 13 | } 14 | 15 | void loop() { 16 | static uint8_t ledState = LOW; 17 | ledState = calcLedState(millis(), ledState); 18 | digitalWrite(LED_BUILTIN, ledState); 19 | } 20 | 21 | uint8_t calcLedState(uint32_t currentMillis, uint8_t ledState) { 22 | static uint32_t previousMillis = 0; 23 | if (currentMillis - previousMillis >= INTERVAL) { 24 | previousMillis = currentMillis; 25 | 26 | if (ledState == LOW) 27 | return HIGH; 28 | else 29 | return LOW; 30 | } 31 | return ledState; 32 | } 33 | -------------------------------------------------------------------------------- /BlinkLedSerial/BlinkLedSerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BlinkLedSerial.h 3 | * 4 | * This is the extension needed to get blinkled to be controlled by the serial communication module 5 | * 6 | * Created on: Nov 7, 2014 7 | * Author: jan 8 | */ 9 | 10 | #ifndef LIBRARIES_BLINKLED_BLINKLEDSERIAL_H_ 11 | #define LIBRARIES_BLINKLED_BLINKLEDSERIAL_H_ 12 | 13 | #include 14 | #include "SerialDataInterface.h" 15 | 16 | class BlinkLedSerial: public BlinkLed { 17 | public: 18 | BlinkLedSerial(uint8_t ledPin, uint32_t onInterval, uint32_t offInterval) : 19 | BlinkLed(ledPin, onInterval, offInterval) { 20 | } 21 | ; 22 | void serialRegister(const __FlashStringHelper* Name); 23 | }; 24 | 25 | #endif /* LIBRARIES_BLINKLED_BLINKLEDSERIAL_H_ */ 26 | -------------------------------------------------------------------------------- /DigitalPotmeterAD5171/DigitalPotmeterAD5171.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * AD5171.cpp 3 | * 4 | * Created on: Jul 11, 2014 5 | * Author: jan 6 | */ 7 | 8 | #include "AD5171.h" 9 | 10 | AD5171::AD5171(uint8_t maxPotValue, uint8_t I2CAdress) 11 | { 12 | myI2CAdress = I2CAdress; 13 | myMaxPotValue = maxPotValue; 14 | } 15 | 16 | void AD5171::setup() 17 | { 18 | //I assume Wire.begin() has been called before this method is called 19 | } 20 | 21 | void AD5171::loop() 22 | { 23 | if (myNewPotValue != myPotValue) 24 | { 25 | Wire.beginTransmission(myI2CAdress); 26 | Wire.write(uint8_t(0x00)); 27 | Wire.write((uint8_t) map( myNewPotValue,0,255,0,myMaxPotValue)); 28 | Wire.endTransmission(); 29 | myPotValue = myNewPotValue; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /DataTypes/examples/prescalerTest/prescalertest.ino: -------------------------------------------------------------------------------- 1 | // Do not remove the include below 2 | 3 | #define pin 9 4 | 5 | //The setup function is called once at startup of the sketch 6 | void setup() 7 | { 8 | Serial.begin(115200); 9 | Serial.println("prescaler failure"); 10 | Serial.println("on a mega with prescaler 6 on pin 2 does not generate a pulse"); 11 | pinMode(pin,OUTPUT); 12 | int myEraser=7; 13 | int prescaler=6; //Works with 1,2,3,4,5 but not with 6 14 | TCCR2B &= ~myEraser; // this operation (AND plus NOT), set the three bits in TCCR2B to 0 15 | TCCR2B |= prescaler; //this operation (OR), replaces the last three bits in TCCR2B with our new value 011 16 | analogWrite(pin,160); 17 | } 18 | 19 | 20 | void loop() 21 | { 22 | //take your time to look at the scope 23 | } 24 | -------------------------------------------------------------------------------- /SimpleSwitch/SimpleSwitch.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SimpleSwitch.cpp 3 | * 4 | * Created on: 29 sep. 2022 5 | * Author: jan 6 | */ 7 | 8 | #include "SimpleSwitch.h" 9 | 10 | SimpleSwitch::SimpleSwitch(uint8_t pin, uint8_t closedState) 11 | { 12 | myPin=pin; 13 | myClosedState=closedState; 14 | myIsClosed=false; 15 | last_Switchread=0; 16 | } 17 | 18 | void SimpleSwitch::setup() 19 | { 20 | pinMode(myPin, INPUT_PULLUP); 21 | } 22 | 23 | void SimpleSwitch::loop() 24 | { 25 | #ifndef USE_MAIN_LOOP_MILLIS 26 | uint32_t loopMillis = millis(); 27 | #endif 28 | 29 | if (loopMillis - last_Switchread > 15) 30 | { 31 | last_Switchread = loopMillis; 32 | myReads.addValue(digitalRead(myPin) == myClosedState); 33 | myIsClosed=myReads.getMedian(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /MotorMegaMoto/Examples/engineTester/engineTester.h: -------------------------------------------------------------------------------- 1 | // Only modify this file to include 2 | // - function definitions (prototypes) 3 | // - include files 4 | // - extern variable definitions 5 | // In the appropriate section 6 | 7 | #ifndef engineTester_H_ 8 | #define engineTester_H_ 9 | #include "Arduino.h" 10 | //add your includes for the project engineTester here 11 | 12 | 13 | //end of add your includes here 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | void loop(); 18 | void setup(); 19 | #ifdef __cplusplus 20 | } // extern "C" 21 | #endif 22 | 23 | //add your function definitions for the project engineTester here 24 | 25 | 26 | 27 | 28 | //Do not add code below this line 29 | #endif /* engineTester_H_ */ 30 | 31 | //Added by Sloeber 32 | #pragma once 33 | -------------------------------------------------------------------------------- /SerialSDCommunicator/SerialSDCommunicator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SerialEEPROMCommunicator.h 3 | * 4 | * Created on: Jan 23, 2014 5 | * Author: jan 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Arduino.h" 11 | #include 12 | #include "SD.h" 13 | 14 | class SerialSDCommunicator: public SerialCommunicator 15 | { 16 | public: 17 | virtual void setReceivedMessage(const char* newMessage); 18 | SerialSDCommunicator(Stream &bridgeStream, Stream &errorStream); 19 | void saveData(); //Reads data in the variables and stores it in the EEPROM memory 20 | void readData(); //Reads data stored in the EEPROM and sets its values to the variables 21 | void setup(); 22 | // static void serialRegister(const __FlashStringHelper* Name){SerialCommunicator::serialRegister( Name);}; 23 | 24 | }; 25 | 26 | -------------------------------------------------------------------------------- /Sabertooth/license.txt: -------------------------------------------------------------------------------- 1 | Arduino Libraries for SyRen/Sabertooth 2 | Copyright (c) 2012-2013 Dimension Engineering LLC 3 | http://www.dimensionengineering.com/arduino 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- /DigitalPotmeterMCP413/DigitalPotmeterMCP413.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MCP413.h 3 | * This is a library for a digital pot meter MCP413 4 | * 5 | * Created on: Jul 11, 2014 6 | * Author: jan 7 | */ 8 | 9 | #ifndef MCP413_H_ 10 | #define MCP413_H_ 11 | #include "SPI.h" 12 | #include "DigitalPotmeterInterface.h" 13 | #include "SerialDataInterface.h" 14 | 15 | class DigitalPotmeterMCP413 :public DigitalPotmeterInterface 16 | { 17 | uint8_t mySlavePin; //the slave pin used to communicate with the MCP413 18 | uint8_t myActualSendValue; //The actual value send over SPI 19 | bool myInverted; 20 | public: 21 | DigitalPotmeterMCP413(uint8_t myMaxPotValue,uint8_t slavePin,bool inverted); 22 | virtual void setup(); 23 | virtual void loop(); 24 | void serialRegister(const __FlashStringHelper* Name); 25 | }; 26 | 27 | #endif /* MCP413_H_ */ 28 | -------------------------------------------------------------------------------- /SerialEEPROMCommunicator/SerialEEPROMCommunicator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SerialEEPROMCommunicator.h 3 | * 4 | * Created on: Jan 23, 2014 5 | * Author: jan 6 | */ 7 | 8 | #ifndef SERIALEEPROMCOMMUNICATOR_H_ 9 | #define SERIALEEPROMCOMMUNICATOR_H_ 10 | #include "Arduino.h" 11 | #include 12 | 13 | class SerialEEPROMCommunicator: public SerialCommunicator 14 | { 15 | private: 16 | virtual void setReceivedMessage(const char* newMessage); 17 | public: 18 | static void saveData(); //Reads data in the variables and stores it in the EEPROM memory 19 | static void readData(); //Reads data stored in the EEPROM and sets its values to the variables 20 | static void setup(); 21 | static void serialRegister(const __FlashStringHelper* Name){SerialCommunicator::serialRegister( Name);}; 22 | 23 | }; 24 | 25 | #endif /* SERIALEEPROMCOMMUNICATOR_H_ */ 26 | -------------------------------------------------------------------------------- /DigitalPotmeterInterface/DigitalPotmeterInterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IDigitalPotmeter.h 3 | * 4 | * Created on: Jul 11, 2014 5 | * Author: jan 6 | */ 7 | 8 | #ifndef IDIGITALPOTMETER_H_ 9 | #define IDIGITALPOTMETER_H_ 10 | 11 | class DigitalPotmeterInterface 12 | { 13 | protected : 14 | uint8_t myPotValue; //the value the potmeter is currently set to range 0 to 255 15 | uint8_t myNewPotValue; // the value the potmeter will be set to at the next loop range 0 to 255 16 | uint8_t myMaxPotValue; //the maximum value the potmeter can be set to 17 | 18 | public: 19 | /** 20 | * Set the value of the pot position with a range of 0 to 255 21 | */ 22 | virtual void setPotValue(uint8_t newPotValue){myNewPotValue=newPotValue;}; 23 | virtual void setup()=0; 24 | virtual void loop()=0; 25 | }; 26 | 27 | #endif /* IDIGITALPOTMETER_H_ */ 28 | -------------------------------------------------------------------------------- /I2CLiquidCrystal/Examples/LCDMaster/LCDMaster.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "I2CLiquidCrystal.h" 3 | #include "Wire.h" 4 | 5 | 6 | LiquidCrystal lcd(0x38); // Set the LCD I2C address 7 | 8 | 9 | 10 | void setup() 11 | { 12 | Serial.begin(115200); 13 | Serial.println("LCDMaster"); 14 | 15 | lcd.begin(); // initialize the lcd 16 | lcd.println("Hello, ARDUINO"); 17 | lcd.setCursor ( 0, 1 ); // go to the next line 18 | Serial.println("Setup done"); 19 | } 20 | 21 | void loop() 22 | { 23 | static int count=0; 24 | lcd.setCursor ( 0, 1 ); 25 | lcd.println(count); 26 | uint8_t red = 255 *(count%3==0); //((uint8_t)count) *(count%3==0); 27 | uint8_t green = 255 *(count%3==1); 28 | uint8_t blue = 255 *(count%3==2); 29 | lcd.setBackground(red,green,blue); 30 | Serial.print("Hello, ARDUINO "); 31 | Serial.println(count); 32 | count++; 33 | delay (500); 34 | } 35 | -------------------------------------------------------------------------------- /simplot/examples/plotterExample/plotterExample.ino: -------------------------------------------------------------------------------- 1 | 2 | #include "simplot.h" 3 | int plotBuffer[20]; 4 | float deltaAngle = 3.14/51; //Arbitrary angle increment size 5 | float angle = 0; 6 | int amplitude = 100; 7 | 8 | void setup() 9 | { 10 | Serial.begin(115200); 11 | 12 | } 13 | 14 | char buffer[80]; 15 | 16 | void loop() 17 | { 18 | 19 | int data1; 20 | int data2; 21 | int data3; 22 | int data4; 23 | 24 | //Generating data that will be plotted 25 | data1 = amplitude * sin(angle); 26 | data2 = amplitude * cos(angle); 27 | 28 | data3 = (amplitude/2) * sin(angle); 29 | data4 = (amplitude/2) * cos(angle); 30 | 31 | angle = angle + deltaAngle; 32 | 33 | plot4(Serial, data1,data2,data3,data4); 34 | sprintf(buffer,"%i %i %i %i",data1,data2,data3,data4); 35 | Serial.println(buffer); 36 | 37 | delay(100); //Need some delay else the program gets swamped with data 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/startReadingArduino.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #This scripts starts the whole arduino openwrt communication. 3 | # start with DUMP the first time so that a web page is created. 4 | 5 | . SetGlobalSettings.sh 6 | 7 | #make sure ParseArduinoInput.sh is stopped 8 | stopReadingArduino.sh 9 | 10 | ./fixmount 11 | 12 | move-log-files-to-nas.sh 13 | 14 | #reset the tty 15 | ${SttyCommand} 16 | 17 | #start the parsing 18 | cd ${WebLocationDynamic} 19 | mkdir -p ${ErrorFolder} 20 | mkdir -p ${FastSmallStorage} 21 | ./ParseArduinoInput.sh < ${PortName} 2>&1 >>${ErrorLog} & 22 | 23 | #send comand to arduino to setup the environment 24 | sleep 1 25 | echo P>> ${PortName} 26 | echo LOG HEADER>> ${PortName} 27 | echo SET>> ${PortName} 28 | if [ "$1" = "DUMP" ]; then 29 | sleep 1 30 | echo DUMP>> ${PortName} 31 | echo LOG VALUE>> ${PortName} 32 | else 33 | echo NODUMP 34 | fi 35 | -------------------------------------------------------------------------------- /DigitalPotmeterInterface/examples/digital_potmeter/digital_potmeter.ino: -------------------------------------------------------------------------------- 1 | #include "MCP413.h" 2 | #include "AD5171.h" 3 | uint8_t slavePin =49; 4 | uint8_t I2CAdress=44; 5 | 6 | 7 | // Activate the pot meter you have below 8 | MCP413 digitalPot(127, slavePin,true); 9 | //MCP413 digitalPot(255, slavePin); 10 | //AD5171 digitalPot( 64, I2CAdress); 11 | 12 | 13 | void setup() 14 | { 15 | Serial.begin(115200); 16 | Serial.println("digital potmeter"); 17 | 18 | SPI.begin(); 19 | digitalPot.setup(); 20 | Serial.println("setup done"); 21 | } 22 | 23 | uint8_t val = 0; 24 | 25 | void loop() 26 | { 27 | val++; // increment value;no need to do anything. vall will overflow and become zero 28 | if (val<100) val=130; //For my motor anything under 130 doesn't do anything 29 | 30 | digitalPot.setPotValue(val); 31 | digitalPot.loop(); 32 | 33 | Serial.print("val ="); 34 | Serial.println(val); 35 | delay(1000); 36 | } 37 | -------------------------------------------------------------------------------- /SabertoothSimplified/examples/SoftwareSerial/SoftwareSerial.ino: -------------------------------------------------------------------------------- 1 | // Software Serial Sample 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | #include 7 | 8 | SoftwareSerial SWSerial(NOT_A_PIN, 11); // RX on no pin (unused), TX on pin 11 (to S1). 9 | SabertoothSimplified ST(SWSerial); // Use SWSerial as the serial port. 10 | 11 | void setup() 12 | { 13 | SWSerial.begin(9600); 14 | } 15 | 16 | void loop() 17 | { 18 | int power; 19 | 20 | // Ramp from -127 to 127 (full reverse to full forward), waiting 20 ms (1/50th of a second) per value. 21 | for (power = -127; power <= 127; power ++) 22 | { 23 | ST.motor(1, power); 24 | delay(20); 25 | } 26 | 27 | // Now go back the way we came. 28 | for (power = 127; power >= -127; power --) 29 | { 30 | ST.motor(1, power); 31 | delay(20); 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /CurrentSensorLem/LemCurrentSensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LemCurrentSensor.h 3 | * 4 | * Created on: Jun 13, 2013 5 | * Author: jan 6 | */ 7 | 8 | #ifndef LEMCURRENTSENSOR_H_ 9 | #define LEMCURRENTSENSOR_H_ 10 | 11 | 12 | #include "Arduino.h" 13 | #include "ICurrentSensor.h" 14 | class LemCurrentSensor:public ICurrentSensor 15 | { 16 | private: 17 | int32_t myMultiplier; 18 | uint16_t myRefPinValue; 19 | uint16_t myCurrentPinValue; 20 | uint8_t myCurrentPin; 21 | uint8_t myRefPin; 22 | uint32_t myLoopduration; 23 | 24 | public: 25 | LemCurrentSensor( uint8_t CurrentPin, uint8_t refPin){ myCurrentPin=CurrentPin; 26 | myRefPin=refPin; 27 | myCurrentPinValue=0; 28 | myRefPinValue=0; 29 | myMultiplier=1; 30 | myLoopduration=0; 31 | }; 32 | void loop(); 33 | void serialRegister(const __FlashStringHelper* Name); 34 | void setup(){ } 35 | void setZeroAmp(){}; 36 | 37 | }; 38 | 39 | #endif /* LEMCURRENTSENSOR_H_ */ 40 | -------------------------------------------------------------------------------- /SerialCommunicator/examples/AnalogTest/Analog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Analog.h 3 | * 4 | * Created on: Nov 2, 2014 5 | * Author: jan 6 | */ 7 | 8 | #ifndef ANALOG_H_ 9 | #define ANALOG_H_ 10 | #include "Arduino.h" 11 | #include "SerialDataInterface.h" 12 | class Analog 13 | { 14 | private: 15 | uint16_t my_Pin_A0_value; 16 | uint16_t my_Pin_A1_value; 17 | uint16_t my_Pin_A2_value; 18 | uint16_t my_Pin_A3_value; 19 | uint16_t my_Pin_A4_value; 20 | uint16_t my_Pin_A5_value; 21 | uint16_t my_Pin_A6_value; 22 | uint16_t my_Pin_A7_value; 23 | uint16_t my_Pin_A8_value; 24 | uint16_t my_Pin_A9_value; 25 | uint16_t my_Pin_A10_value; 26 | uint16_t my_Pin_A11_value; 27 | uint16_t my_Pin_A12_value; 28 | uint16_t my_Pin_A13_value; 29 | uint16_t my_Pin_A14_value; 30 | uint16_t my_Pin_A15_value; 31 | public: 32 | Analog(); 33 | void serialRegister(const __FlashStringHelper* Name); 34 | void loop(); 35 | void setup(); 36 | 37 | }; 38 | 39 | #endif /* ANALOG_H_ */ 40 | -------------------------------------------------------------------------------- /Sabertooth/examples/3.Advanced/SoftwareSerial/SoftwareSerial.ino: -------------------------------------------------------------------------------- 1 | // Software Serial Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | #include 7 | 8 | SoftwareSerial SWSerial(NOT_A_PIN, 11); // RX on no pin (unused), TX on pin 11 (to S1). 9 | Sabertooth ST(128, SWSerial); // Address 128, and use SWSerial as the serial port. 10 | 11 | void setup() 12 | { 13 | SWSerial.begin(9600); 14 | ST.autobaud(); 15 | } 16 | 17 | void loop() 18 | { 19 | int power; 20 | 21 | // Ramp from -127 to 127 (full reverse to full forward), waiting 20 ms (1/50th of a second) per value. 22 | for (power = -127; power <= 127; power ++) 23 | { 24 | ST.motor(1, power); 25 | delay(20); 26 | } 27 | 28 | // Now go back the way we came. 29 | for (power = 127; power >= -127; power --) 30 | { 31 | ST.motor(1, power); 32 | delay(20); 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /CurrentSensorInterface/CurrentSensorInterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ICurrentSensor.h 3 | * 4 | * Created on: Jul 14, 2014 5 | * Author: jan 6 | */ 7 | 8 | #ifndef ICURRENTSENSOR_H_ 9 | #define ICURRENTSENSOR_H_ 10 | #include "Arduino.h" 11 | 12 | class CurrentSensorInterface 13 | { 14 | protected: 15 | uint16_t myCentiAmp; //current in centi amps 16 | uint16_t myAvgCentiAmp; //average current in centi amps 17 | public: 18 | CurrentSensorInterface(){ myCentiAmp=0; myAvgCentiAmp=0;} 19 | virtual void loop()=0; 20 | virtual void setup()=0; 21 | uint16_t getCurrent_cA() {return myCentiAmp;} 22 | uint16_t getCurrent_dA() {return (myCentiAmp+5)/10;} 23 | uint16_t getCurrent_A() {return (myCentiAmp+50)/100;} 24 | uint16_t getAvgCurrent_cA() {return myAvgCentiAmp;} 25 | uint16_t getAvgCurrent_dA() {return (myAvgCentiAmp+5)/10;} 26 | uint16_t getAvgCurrent_A() {return (myAvgCentiAmp+50)/100;} 27 | virtual void setZeroAmp()=0; 28 | }; 29 | 30 | #endif /* ICURRENTSENSOR_H_ */ 31 | -------------------------------------------------------------------------------- /MotorBLDC/examples/BLDC1driverTester/BLDC1DriverTester.cpp: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "SerialCommunicator.h" 3 | 4 | #include "SkidDriverBLDC.h" 5 | SkidDriverBLDC driver(7,5, 6,4); 6 | 7 | Stream &SerialOutput = Serial; 8 | Stream &SerialInput = Serial; 9 | 10 | const char mySketchName[] PROGMEM= "BLDC1DriverTester"; 11 | 12 | SerialCommunicator myCommunicator; 13 | 14 | void setup() 15 | { 16 | Serial.begin(115200); 17 | Serial.println("Start sketch BLDC1DriveTester"); 18 | myCommunicator.serialRegister(F("Admin")); 19 | 20 | driver.serialRegister(F("driver"),F("driver.left"),F("driver.right")); 21 | 22 | Serial.print(F("Current Datas ")); 23 | Serial.println(lastFieldIndex); 24 | Serial.println(F(" from ")); 25 | Serial.println(MAXFIELDS); 26 | driver.setup(); 27 | myCommunicator.setup(); 28 | } 29 | 30 | // The loop function is called in an endless loop 31 | void loop() 32 | { 33 | driver.loop(); 34 | myCommunicator.loop(); 35 | driver.plot(); 36 | delay(50); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /gtest/examples/blink/gtest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef UNITTEST 2 | #include "gtest.h" 3 | #include "blink.h" 4 | 5 | TEST(blink, start) { 6 | EXPECT_EQ(HIGH, calcLedState(0, HIGH)); 7 | EXPECT_EQ(LOW, calcLedState(0, LOW)); 8 | EXPECT_EQ(HIGH, calcLedState(1, HIGH)); 9 | EXPECT_EQ(LOW, calcLedState(1, LOW)); 10 | // EXPECT_EQ(2, calcLedState(INTERVAL-2, HIGH)); 11 | // EXPECT_EQ(2, calcLedState(INTERVAL-1, HIGH)); 12 | // EXPECT_EQ(2, calcLedState(INTERVAL, HIGH)); 13 | // EXPECT_EQ(2, calcLedState(INTERVAL+1, HIGH)); 14 | // EXPECT_EQ(2, calcLedState(INTERVAL+2, HIGH)); 15 | 16 | } 17 | 18 | TEST(blink, on) { 19 | uint32_t mill=0; 20 | for (mill = 0; mill < INTERVAL; mill++) { 21 | EXPECT_EQ(HIGH, calcLedState(mill, HIGH)) << mill; 22 | } 23 | EXPECT_EQ(LOW, calcLedState(INTERVAL, HIGH)) << INTERVAL; 24 | 25 | } 26 | 27 | TEST(blink, off) { 28 | uint32_t mill=0; 29 | for (mill = 0; mill < INTERVAL; mill++) { 30 | EXPECT_EQ(LOW, calcLedState(INTERVAL+mill, LOW)) << INTERVAL+mill; 31 | } 32 | EXPECT_EQ(HIGH, calcLedState(2*INTERVAL, LOW)) << INTERVAL; 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Sabertooth/examples/2.Settings/MinVoltage/MinVoltage.ino: -------------------------------------------------------------------------------- 1 | // Set Minimum Voltage Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | // The values in this sample are specifically for the Sabertooth 2x25, and may 6 | // not have the same effect on other models. 7 | #include 8 | 9 | Sabertooth ST(128); 10 | 11 | void setup() 12 | { 13 | SabertoothTXPinSerial.begin(9600); 14 | ST.autobaud(); 15 | 16 | // This setting does not persist between power cycles. 17 | // See the Packet Serial section of the documentation for what values to use 18 | // for the minimum voltage command. It may vary between Sabertooth models 19 | // (2x25, 2x60, etc.). 20 | // 21 | // On a Sabertooth 2x25, the value is (Desired Volts - 6) X 5. 22 | // So, in this sample, we'll make the low battery cutoff 12V: (12 - 6) X 5 = 30. 23 | ST.setMinVoltage(30); 24 | } 25 | 26 | void loop() 27 | { 28 | ST.motor(1, 50); 29 | delay(5000); 30 | 31 | ST.motor(1, -50); 32 | delay(5000); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /MotorBLDC/examples/BLDC1motorTester/BLDC1MotorTester.cpp: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "SerialEEPROMCommunicator.h" 3 | #include "simplot.h" 4 | 5 | #include "MotorBLDC.h" 6 | MotorBLDC driver1(7, 6); 7 | MotorBLDC driver2(5, 4); 8 | 9 | Stream &SerialOutput = Serial; 10 | Stream &SerialInput = Serial; 11 | 12 | 13 | const char mySketchName[] PROGMEM= "BLDC1MotorTester"; 14 | 15 | SerialEEPROMCommunicator myCommunicator; 16 | 17 | 18 | void setup() 19 | { 20 | Serial.begin(115200); 21 | Serial.println("Start sketch BLDC1MotorTester"); 22 | myCommunicator.serialRegister(F("Admin")); 23 | driver1.serialRegister(F("motor1")); 24 | driver2.serialRegister(F("motor2")); 25 | 26 | Serial.print(F("Current Datas ")); 27 | Serial.println(lastFieldIndex); 28 | Serial.println(F(" from ")); 29 | Serial.println(MAXFIELDS); 30 | driver1.setup(); 31 | driver2.setup(); 32 | myCommunicator.setup(); 33 | } 34 | 35 | 36 | void loop() 37 | { 38 | driver1.loop(); 39 | driver2.loop(); 40 | myCommunicator.loop(); 41 | //driver2.plotdata(); 42 | delay(20); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Sabertooth/examples/2.Settings/Persistent/Deadband/Deadband.ino: -------------------------------------------------------------------------------- 1 | // Set Deadband Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | // WARNING: This sample makes changes that will persist between restarts AND in all modes. 6 | #include 7 | 8 | Sabertooth ST(128); 9 | 10 | void setup() 11 | { 12 | SabertoothTXPinSerial.begin(9600); 13 | ST.autobaud(); 14 | 15 | // This makes the deadband from -20 to 20 (of 127). 16 | // If your commands for a motor stay entirely within the deadband for more than 17 | // a second, the motor driver will stop the motor. 18 | // WARNING: The Sabertooth remembers this command between restarts AND in all modes. 19 | // To change your Sabertooth back to its default, call ST.setDeadband(0) 20 | ST.setDeadband(20); 21 | } 22 | 23 | void loop() 24 | { 25 | // 50 is greater than 20, so the motor moves. 26 | ST.motor(1, 50); 27 | delay(5000); 28 | 29 | // 10 is NOT, so the motor does not move. 30 | ST.motor(1, 10); 31 | delay(5000); 32 | } 33 | 34 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/Bonjour: -------------------------------------------------------------------------------- 1 | #!/bin/ash 2 | HOSTS=/etc/hosts 3 | HOSTSORG=/etc/hosts.org 4 | HOSTSDYNAMICTMP=/tmp/jantje/hosts.tmp 5 | HOSTSDYNAMIC=/tmp/jantje/hosts 6 | mkdir -p /tmp/jantje 7 | if [ -f ${HOSTSORG} ]; then 8 | echo "the avahi workaround had not been undone properly" 9 | if [ -h ${HOSTS} ]; then 10 | echo "Nothing has been removed." 11 | echo "continuing" 12 | else 13 | if [ -f ${HOSTS} ]; then 14 | echo "both " ${HOSTS} " and " ${HOSTSORG} "exist. " 15 | echo "quiting" 16 | exit 17 | else 18 | echo ${HOSTS} " was removed but" ${HOSTSORG} " not put back." 19 | echo "relinking " ${HOSTS} " to " ${HOSTSDYNAMIC} 20 | echo continuing 21 | ln -s ${HOSTSDYNAMIC} ${HOSTS} 22 | fi 23 | fi 24 | else 25 | mv ${HOSTS} ${HOSTSORG} 26 | ln -s ${HOSTSDYNAMIC} ${HOSTS} 27 | fi 28 | 29 | while [ 1 ] 30 | do 31 | cat ${HOSTSORG} > ${HOSTSDYNAMICTMP} 32 | avahi-browse -t -r -a -p |grep "^=;wlan0"|awk -F";" '{print($8,$7)}'|sort -u >> ${HOSTSDYNAMICTMP} 33 | mv ${HOSTSDYNAMICTMP} ${HOSTSDYNAMIC} 34 | sleep 60 35 | done 36 | -------------------------------------------------------------------------------- /simplot/simplot.h: -------------------------------------------------------------------------------- 1 | /* 2 | A library to provide basic support for the simplot oscilloscope 3 | 4 | */ 5 | #ifndef simplot_H_ 6 | #define simplot_H_ 7 | #include "Arduino.h" 8 | 9 | 10 | /* use the general plot method or one of the wrapping macros*/ 11 | void _simple_plot_(Stream &output, uint8_t numData, int16_t data1, int16_t data2, int16_t data3, int16_t data4, int16_t data5, int16_t data6); 12 | 13 | 14 | 15 | #define plot6(output, data1, data2, data3, data4, data5, data6) _simple_plot_(output, 6, data1, data2, data3, data4, data5, data6) 16 | 17 | #define plot5(output, data1, data2, data3, data4, data5 ) _simple_plot_(output, 5, data1, data2, data3, data4, data5, 0) 18 | 19 | #define plot4(output, data1, data2, data3, data4) _simple_plot_(output, 4, data1, data2, data3, data4, 0, 0) 20 | 21 | #define plot3(output, data1, data2, data3) _simple_plot_(output, 3, data1, data2, data3, 0, 0, 0) 22 | 23 | #define plot2(output, data1, data2) _simple_plot_(output, 2, data1, data2, 0, 0, 0, 0) 24 | 25 | #define plot1(output, data1) _simple_plot_(output, 1, data1, 0, 0, 0, 0, 0) 26 | 27 | #endif //simplot_H_ 28 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/SerialBridgeCommunicator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SerialBridgeCommunicator.h 3 | * 4 | * Created on: Jan 24, 2014 5 | * Author: jan 6 | */ 7 | 8 | #pragma once 9 | #include "SerialCommunicator.h" 10 | 11 | class SerialBridgeCommunicator: public SerialCommunicator 12 | { 13 | 14 | public: 15 | 16 | SerialBridgeCommunicator(Stream &bridgeStream, Stream &errorStream); 17 | virtual void setReceivedMessage(const char *newMessage); 18 | void saveData(); //Reads data in the variables and stores it on the linux part of the yun 19 | void readData(); //Reads data on the linux part of the yun 20 | 21 | void setup(); 22 | void runShellCommand(const char *command) 23 | { 24 | mySerialOutput.print("EXEC:"); 25 | mySerialOutput.println(command); 26 | } 27 | ; 28 | void runShellCommand(const __FlashStringHelper* command) 29 | { 30 | mySerialOutput.print("EXEC:"); 31 | mySerialOutput.println(command); 32 | } 33 | void runSynchronousShellCommand(const char *command, char *returnBuffer, uint8_t ReturnBuffersize); 34 | virtual ~SerialBridgeCommunicator(){}; 35 | }; 36 | 37 | -------------------------------------------------------------------------------- /JanServo/JanServo.cpp: -------------------------------------------------------------------------------- 1 | #include "JanServo.h" 2 | 3 | void JanContiniousServo::setPosition(uint8_t Position) 4 | { 5 | myServoPosition = Position ; 6 | write(constrain((int)myServoPosition + myOffset,0,180)); 7 | } 8 | 9 | 10 | #ifdef I_USE_SERIAL_REGISTER 11 | void JanContiniousServo::serialRegister(const __FlashStringHelper* Name) 12 | { 13 | FieldData::set(Name, (__FlashStringHelper *) (PIN), 0, &myServoControlPin); 14 | FieldData::setNext( F("Position"),(uint8_t)0,&myServoPosition); 15 | FieldData::setNext( F("offset"),MOD_SAVE | MOD_WRITE,&myOffset); 16 | } 17 | 18 | void JanConstraintServo::serialRegister(const __FlashStringHelper* Name) 19 | { 20 | FieldData::set(Name, (__FlashStringHelper *) (PIN), MOD_NONE, &myServoControlPin); 21 | FieldData::setNext( F("Position"),MOD_NONE,&myServoPosition); 22 | FieldData::setNext( F("newPosition"),MOD_WRITE,&myNewServoPosition); 23 | FieldData::setNext( F("MaxServoPositionset"),MOD_WRITE|MOD_SAVE,&myMaxServoPosition); 24 | FieldData::setNext( F("minServoPosition"),MOD_WRITE|MOD_SAVE,&myMinServoPosition); 25 | FieldData::setNext( F("DefaultServoPosition"),MOD_WRITE|MOD_SAVE,&myDefaultServoPosition); 26 | 27 | } 28 | #endif 29 | 30 | 31 | -------------------------------------------------------------------------------- /SkidDriverSaberTooth/SkidDriversaberTooth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SkidDriversaberTooth.h 3 | * 4 | * Created on: 11-mei-2016 5 | * Author: jan 6 | */ 7 | 8 | #ifndef LIBRARIES_SKIDDRIVER_SABERTOOTH_SKIDDRIVERSABERTOOTH_H_ 9 | #define LIBRARIES_SKIDDRIVER_SABERTOOTH_SKIDDRIVERSABERTOOTH_H_ 10 | #include "SkidDriverinterface.h" 11 | #include 12 | #include "SerialDataInterface.h" 13 | #include "FieldInfo.h" 14 | 15 | class SkidDriverSaberTooth: public SkidDriverInterface { 16 | uint8_t myIsMotorOn; 17 | Sabertooth *myPSabertooth; 18 | SPEED_TYPE mySabertoothspeed; 19 | DIRECTION_TYPE mySabertoothDirection; 20 | public: 21 | SkidDriverSaberTooth(Sabertooth* pSabertooth); 22 | virtual ~SkidDriverSaberTooth(); 23 | virtual void motorOn(); 24 | virtual void motorOff(); 25 | virtual void setup(); 26 | virtual void loop(); 27 | 28 | virtual bool emergencyBreak(bool immediatlyReturn = false); 29 | virtual void turnOnTheSpot(SPEED_TYPE Speed); 30 | 31 | virtual SPEED_TYPE getActualSpeed() const; 32 | void serialRegister(const __FlashStringHelper* Name); 33 | 34 | }; 35 | 36 | #endif /* LIBRARIES_SKIDDRIVER_SABERTOOTH_SKIDDRIVERSABERTOOTH_H_ */ 37 | -------------------------------------------------------------------------------- /CurrentSensorAnalog/CurrentSensorAnalog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AmpMeter.h 3 | * 4 | * Created on: Jul 5, 2014 5 | * Author: jan 6 | */ 7 | 8 | #ifndef AMPMETER_H_ 9 | #define AMPMETER_H_ 10 | #include "SerialDataInterface.h" 11 | #include "CurrentSensorInterface.h" 12 | #include "FastRunningMedian.h" 13 | extern uint32_t loopMillis; 14 | 15 | class CurrentSensorAnalog:public CurrentSensorInterface 16 | { 17 | private : 18 | uint8_t myAnalogPin; 19 | int32_t myMultiplyerValue; 20 | int16_t myOffset; 21 | uint16_t myCurrentPinValue; 22 | FastRunningMedian myMedianPinValue; 23 | public: 24 | /** 25 | * Creates the ampmeter. You need to use serialRegister and Jan baeyens his 26 | * communication system to get the variables initialized. 27 | */ 28 | CurrentSensorAnalog(uint8_t analogPin); 29 | /* 30 | * Creates and Initializes the amp meter. 31 | */ 32 | CurrentSensorAnalog(uint8_t analogPin,int16_t MultiplyerValue,int16_t Offset); 33 | virtual void setup(void){;}; 34 | virtual void loop(void); 35 | void serialRegister(const __FlashStringHelper* Name); 36 | void setZeroAmp(); 37 | }; 38 | 39 | #endif /* AMPMETER_H_ */ 40 | -------------------------------------------------------------------------------- /Sabertooth/examples/2.Settings/SerialTimeout/SerialTimeout.ino: -------------------------------------------------------------------------------- 1 | // Set Serial Timeout Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | 7 | Sabertooth ST(128); 8 | 9 | void setup() 10 | { 11 | SabertoothTXPinSerial.begin(9600); 12 | ST.autobaud(); 13 | 14 | // setTimeout rounds up to the nearest 100 milliseconds, so this 950 will actually be 1 second. 15 | // A value of 0 disables the serial timeout. 16 | ST.setTimeout(950); 17 | } 18 | 19 | void loop() 20 | { 21 | // Set motor 1 to reverse 20 (out of 127), and sleep for 5 seconds. 22 | // Notice how it cuts out after 1 second -- this is the serial timeout in action. 23 | // Since we configured it in setup() for 1 second, 1 second without any new 24 | // commands will cause the motors to stop. 25 | ST.motor(1, -20); 26 | delay(5000); 27 | 28 | // Why do this? 29 | // If the S1 wire gets cut for some reason, or if your program crashes, 30 | // the Sabertooth will stop receiving commands from the Arduino. 31 | // With a timeout, your robot will stop. So, it's a safety feature mostly. 32 | } 33 | 34 | -------------------------------------------------------------------------------- /simplot/simplot.cpp: -------------------------------------------------------------------------------- 1 | #include "simplot.h" 2 | 3 | void _simple_plot_(Stream &output, byte numData, int16_t data1, int16_t data2, 4 | int16_t data3, int16_t data4, int16_t data5, int16_t data6) { 5 | uint8_t plotBuffer[16]; 6 | uint16_t pktSize; 7 | uint16_t numDataBytes = numData * sizeof(uint16_t); //Size of data in bytes. Does not include the header and size fields 8 | 9 | plotBuffer[0] = 0xAB; 10 | plotBuffer[1] = 0xCD; //SimPlot packet header. Indicates start of data packet 11 | plotBuffer[2] = lowByte(numDataBytes); 12 | plotBuffer[3] = highByte(numDataBytes); 13 | plotBuffer[4] = lowByte(data1); 14 | plotBuffer[5] = highByte(data1); 15 | plotBuffer[6] = lowByte(data2); 16 | plotBuffer[7] = highByte(data2); 17 | plotBuffer[8] = lowByte(data3); 18 | plotBuffer[9] = highByte(data3); 19 | plotBuffer[10] = lowByte(data4); 20 | plotBuffer[11] = highByte(data4); 21 | plotBuffer[12] = lowByte(data5); 22 | plotBuffer[13] = highByte(data5); 23 | plotBuffer[14] = lowByte(data6); 24 | plotBuffer[15] = highByte(data6); 25 | 26 | pktSize = (numData + 2) * sizeof(uint16_t); //Header bytes + size field bytes + data 27 | 28 | output.write((uint8_t *) plotBuffer, pktSize); 29 | //output.println(); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /TempMeterTemperatureSensetiveResistor/TempMeterTemperatureSensetiveResistor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TemperatureSensetiveResistorTempMeter.h 3 | * 4 | * Implementation of the temperature interface with a temperature sensitive resistor 5 | * 6 | * Created on: Jun 13, 2013 7 | * Author: jan 8 | */ 9 | 10 | #include "Arduino.h" 11 | #include "TempMeterInterface.h" 12 | #include "FastRunningMedian.h" 13 | #ifdef I_USE_SERIAL_REGISTER 14 | #include "SerialDataInterface.h" 15 | #endif 16 | extern uint32_t loopMillis; 17 | 18 | class TempMeterTemperatureSensetiveResistor:public TempMeterInterface 19 | { 20 | 21 | private: 22 | uint8_t myPin; 23 | int16_t myMultiplyerValue; 24 | uint16_t myActualReadValue; 25 | // uint16_t myAveragedReadValue; 26 | FastRunningMedian myReadValues; 27 | int16_t myOffset; 28 | uint32_t myLastRead; 29 | boolean myIgnore; 30 | 31 | public: 32 | TempMeterTemperatureSensetiveResistor( uint8_t Pin); 33 | TempMeterTemperatureSensetiveResistor( uint8_t Pin,int16_t multiplyerValue,int16_t offset); 34 | void serialRegister(const __FlashStringHelper* Name); 35 | void setup(); 36 | void loop(); 37 | virtual ~TempMeterTemperatureSensetiveResistor()=default; 38 | }; 39 | 40 | #pragma once 41 | -------------------------------------------------------------------------------- /Sabertooth/examples/2.Settings/Persistent/Ramping/Ramping.ino: -------------------------------------------------------------------------------- 1 | // Set Ramping Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | // WARNING: This sample makes changes that will persist between restarts AND in all modes. 6 | #include 7 | 8 | Sabertooth ST(128); 9 | 10 | void setup() 11 | { 12 | SabertoothTXPinSerial.begin(9600); 13 | ST.autobaud(); 14 | 15 | // See the Sabertooth 2x60 documentation for information on ramping values. 16 | // There are three ranges: 1-10 (Fast), 11-20 (Slow), and 21-80 (Intermediate). 17 | // The ramping value 14 used here sets a ramp time of 4 seconds for full 18 | // forward-to-full reverse. 19 | // 20 | // 0 turns off ramping. Turning off ramping requires a power cycle. 21 | // 22 | // WARNING: The Sabertooth remembers this command between restarts AND in all modes. 23 | // To change your Sabertooth back to its default, call ST.setRamping(0) 24 | ST.setRamping(14); 25 | } 26 | 27 | void loop() 28 | { 29 | // Full forward, both motors. 30 | ST.motor(1, 127); 31 | ST.motor(2, 127); 32 | delay(5000); 33 | 34 | // Full reverse 35 | ST.motor(1, -127); 36 | ST.motor(2, -127); 37 | delay(5000); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/static/tabs.css: -------------------------------------------------------------------------------- 1 | div.content { 2 | border: #48f solid 3px; 3 | clear: left; 4 | padding: 1em; 5 | } 6 | 7 | div.contentGroup { 8 | padding: 0em; 9 | } 10 | 11 | div.content.inactive { 12 | display: none; 13 | } 14 | 15 | ol#toc { 16 | height: 2em; 17 | list-style: none; 18 | margin: 0; 19 | padding: 0; 20 | } 21 | 22 | ol#toc a { 23 | background: #bdf url(tabs.gif); 24 | color: #008; 25 | display: block; 26 | float: left; 27 | height: 2em; 28 | padding-left: 10px; 29 | text-decoration: none; 30 | } 31 | 32 | ol#toc a:hover { 33 | background-color: #3af; 34 | background-position: 0 -120px; 35 | } 36 | 37 | ol#toc a:hover span { 38 | background-position: 100% -120px; 39 | } 40 | 41 | ol#toc li { 42 | float: left; 43 | margin: 0 1px 0 0; 44 | } 45 | 46 | ol#toc li a.active { 47 | background-color: #48f; 48 | background-position: 0 -60px; 49 | color: #fff; 50 | font-weight: bold; 51 | } 52 | 53 | ol#toc li a.active span { 54 | background-position: 100% -60px; 55 | } 56 | 57 | ol#toc span { 58 | background: url(tabs.gif) 100% 0; 59 | display: block; 60 | line-height: 2em; 61 | padding-right: 10px; 62 | } 63 | -------------------------------------------------------------------------------- /Sabertooth/changes.txt: -------------------------------------------------------------------------------- 1 | Arduino Libraries for SyRen/Sabertooth 2 | Copyright (c) 2012-2013 Dimension Engineering LLC 3 | http://www.dimensionengineering.com/arduino 4 | 5 | 1 July 2013, Version 1.5 6 | - USB Sabertooth Packet Serial Library 7 | - Initial release. 8 | 9 | 1 April 2013, Version 1.4 10 | - Added documentation. 11 | - Improved support for Arduino Leonardo. 12 | - Packet Serial Library 13 | - Simplified the code to save space and increase readability. 14 | 15 | 3 May 2012, Version 1.3 16 | - Improved compatibility with earlier versions of the Arduino software. 17 | Previous versions required Arduino 1.0 or newer, but this version 18 | should work back to Arduino 0018 (still in use by Debian Linux 6.0) 19 | and possibly earlier. 20 | 21 | If you are using a version of Arduino older than 1.0, you will need 22 | to rename the examples from .ino to .pde to see them in the Examples 23 | menu. 24 | 25 | 20 April 2012, Version 1.2 26 | - Packet Serial Library 27 | - Added a stop() function to match the command set of the Simplified 28 | Serial libraries. 29 | 30 | 19 April 2012, Version 1.1 31 | - Packet Serial Library 32 | - Added a single-argument motor() function as a convenience for SyRen. 33 | 34 | 18 April 2012, Version 1.0 35 | - Initial release. 36 | 37 | Please let us know if you run into any bugs! Thanks and enjoy the library! -------------------------------------------------------------------------------- /simplot/examples/makerfairRome2017Demo/readme.md: -------------------------------------------------------------------------------- 1 | requirements for the rome make fair demo 2 | 3 | 1-> code completion 4 | 2-> compiler warnings 5 | 3-> library manager 6 | 4-> boardmanager 7 | 5-> multi build configuration 8 | 6-> firmware upload 9 | 7-> serial console 10 | 8-> serial plotter 11 | 9- git(hub) 12 | 10-> debug 13 | 14 | Idea demo 15 | Part one simple out of the box with uno 16 | Start with blinkwithout delay with teensy. 17 | demo 1,2,6,7 18 | 19 | part 2 hardware debug (zero and esp8266) 20 | Both bords need to be installed using the boardsmanager (4) 21 | Install the simplot library. (3) 22 | create a new zero sketch based on a this example. 23 | Upload 24 | demo plotter 8 25 | Demo multiple serial connnection on serial monitor as demo 1 is still runnning 26 | Create new config for debugging with zero (5) 27 | Upload and short debug demo (10) 28 | Create a new config for esp8266 29 | verify compile upload show plotter (and blinking led on esp8266) 30 | 31 | part 3 local debug unit test 32 | Create new config for local debug 33 | Debug quickly 34 | Create new config for local unit test 35 | run unit test (still to be made) 36 | 37 | Part 4 github 38 | checkin the project in github 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /gtest/examples/gtest/gtest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef UNITTEST 2 | #include "gtest.h" 3 | #include "your header" 4 | 5 | 6 | TEST(Security, encryption) 7 | { 8 | PermissionHolder permission; 9 | DateTime testTime(2015,6,13,12,12,12); 10 | // DateTime (uint16_t year, uint8_t month, uint8_t day, 11 | // uint8_t hour =0, uint8_t min =0, uint8_t sec =0); 12 | int RobotID=1; 13 | permission.requestPermission(Cassis_terras,testTime,RobotID); 14 | memcpy(permission.answerCipher,permission.sendCipher,sizeof(permission.answerCipher)); 15 | permission.loop(); 16 | String answer=permission.answerPlain; 17 | String send=permission.sendPlain; 18 | EXPECT_EQ(answer,send); 19 | } 20 | 21 | TEST(gps, convertDegreesToDeci) 22 | { 23 | // GPSLocation in0 = 24 | // { 51031580, 3421810 }; 25 | // GPSLocation out0 = 26 | // { 51052633, 3703016 }; 27 | 28 | // 29 | // in0.convertDegreesToDeci(); 30 | // EXPECT_EQ(out0.myLatitude, in0.myLatitude); 31 | // EXPECT_EQ(out0.myLongitude, in0.myLongitude); 32 | } 33 | 34 | TEST(gps, distance) 35 | { 36 | // GPSLocation dist1_1 ={ 51057580, 3699610 }; 37 | // GPSLocation dist1_2 ={ 51054420, 3704980 }; 38 | // long dist1 = 51406; //in cm 51410; //in cm 39 | 40 | // EXPECT_EQ(0, dist1_1.distance(dist1_1)); 41 | // EXPECT_EQ(0, dist1_2.distance(dist1_2)); 42 | // EXPECT_EQ(dist1, dist1_2.distance(dist1_1)); 43 | // EXPECT_EQ(dist1, dist1_1.distance(dist1_2)); 44 | 45 | } 46 | 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /SerialStringReader/Examples/serialCommunicatorStep1/serialCommunicatorStep1.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a example sketch showing the basic functionality of reading line by line from 3 | * Serial (or any other stream) 4 | * 5 | * no rights reserved 6 | */ 7 | #include "SerialStringReader.h" 8 | //for the stream you want to read info from you need to declare a SerialStringReader 9 | //you can only have one 10 | SerialStringReader myCommunicator; 11 | 12 | //Define that the USB serial (pin 0 and 1 on the uno) is to be used by the mySerialReader 13 | //If you want to use the yun with the bridge use Serial1 14 | #define THESERIAL Serial 15 | Stream &SerialInput = THESERIAL; 16 | Stream &SerialOutput = THESERIAL; 17 | 18 | 19 | 20 | void setup() 21 | { 22 | delay(2000); 23 | THESERIAL.begin(115200); 24 | SerialOutput.println("serialStringReaderDemo2"); 25 | myCommunicator.setup(); 26 | } 27 | 28 | void loop() 29 | { 30 | //always add the following line to your loop 31 | myCommunicator.loop(); 32 | //mySerialReader.messageReceived() will only return true when a line of data has arrived 33 | if (myCommunicator.messageReceived()) 34 | { 35 | SerialOutput.println("You have send a message to Arduino."); 36 | SerialOutput.println("And the message is:"); 37 | // with mySerialReader.getMessage() we get the actual message 38 | // for the demo we simply play it back. 39 | SerialOutput.println(myCommunicator.getMessage()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /CurrentSensorLem/LemCurrentSensor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * LemCurrentSensor.cpp 3 | * 4 | * Created on: Jun 13, 2013 5 | * Author: jan 6 | */ 7 | 8 | #include "LemCurrentSensor.h" 9 | #include "SerialDataInterface.h" 10 | 11 | 12 | int myAnalogRead(uint8_t pin) 13 | { 14 | analogRead(pin); 15 | //delay(1); 16 | return analogRead(pin); 17 | } 18 | void LemCurrentSensor::loop() 19 | { 20 | unsigned long loopstart = millis(); 21 | myCurrentPinValue=myAnalogRead(myCurrentPin); 22 | myRefPinValue=myAnalogRead(myRefPin); 23 | myCentiAmp=abs((((int32_t)myCurrentPinValue-(int32_t)myRefPinValue)*myMultiplier)/100); 24 | myAvgCentiAmp=((uint32_t)myAvgCentiAmp*8ul+(uint32_t)myCentiAmp*2ul)/10ul; 25 | myLoopduration = millis() - loopstart; 26 | } 27 | 28 | void LemCurrentSensor::serialRegister(const __FlashStringHelper* Name) 29 | { 30 | 31 | FieldData::set(Name, F("Cur_cA"),0,&myCentiAmp); 32 | FieldData::set(Name, F("avg_cA"),0,&myAvgCentiAmp); 33 | FieldData::setNext( (__FlashStringHelper *)PINVALUE,0,&myCurrentPinValue); 34 | FieldData::setNext( F("RefPinValue"),0,&myRefPinValue); 35 | FieldData::setNext( (__FlashStringHelper *)PIN,(uint8_t)0,&myCurrentPin); 36 | FieldData::set(Name, F("RefPin"),0,&myRefPin); 37 | FieldData::set(Name, (__FlashStringHelper *)MULTIPLIER,MOD_SAVE|MOD_WRITE,&myMultiplier); 38 | FieldData::setNext( (__FlashStringHelper *)LOOPDURATION,0,&myLoopduration); 39 | } 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /SerialCommunicator/examples/webcalculator/webcalculator.ino: -------------------------------------------------------------------------------- 1 | #include "SerialCommunicator.h" 2 | 3 | //If you are not using yun use Serial instead of Serial1 in the line below 4 | #define THESERIAL Serial1 5 | //The stream used for reading standard input 6 | Stream &SerialInput = THESERIAL; 7 | //The stream for writing standard output 8 | Stream &SerialOutput = THESERIAL; 9 | //The stream for writing errors 10 | Stream &SerialError = THESERIAL; 11 | 12 | //The name of the program. This name is visible in the html page 13 | const char mySketchName[] PROGMEM= "Calculator"; 14 | 15 | 16 | //the communication channel 17 | SerialCommunicator myCommunicator; 18 | 19 | //The variables used to do the actual calculation 20 | int value1; 21 | int value2; 22 | int sum; 23 | 24 | void setup() 25 | { 26 | delay(5000); 27 | THESERIAL.begin(115200); 28 | // Wait for U-boot to finish startup. Consume all bytes until we are done. 29 | do 30 | { 31 | while (SerialInput.available() > 0) 32 | { 33 | SerialInput.read(); 34 | } 35 | delay(1000); 36 | } while (SerialInput.available() > 0); 37 | 38 | 39 | FieldData::set(F("Sum"), F("adding"),MOD_WRITE, &value1); 40 | FieldData::set(F("Sum"), F("to"),MOD_WRITE, &value2); 41 | FieldData::set(F("Sum"), F("gives"),MOD_NONE, &sum); 42 | 43 | myCommunicator.setup(); 44 | } 45 | 46 | void loop() 47 | { 48 | sum=value1+value2; 49 | myCommunicator.loop(); 50 | } 51 | -------------------------------------------------------------------------------- /minibridge/MiniBridge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MiniBridge.h 3 | * 4 | * Created on: Jan 27, 2014 5 | * Author: jan 6 | */ 7 | #ifdef I_USE_MINI_BRIDGE 8 | #ifndef MINIBRIDGE_H_ 9 | #define MINIBRIDGE_H_ 10 | #include "Arduino.h" 11 | 12 | 13 | extern HardwareSerial &BridgeSerial; 14 | 15 | class MiniBridge 16 | { 17 | public: 18 | MiniBridge(){max_retries=0;index=0; started=false;CRC=0;}; 19 | static void begin(); 20 | 21 | 22 | //void put(const char *key, const char *value); 23 | 24 | //unsigned int get(const char *key, uint8_t *buff, unsigned int size); 25 | 26 | static uint16_t transfer(const uint8_t *buff1, uint16_t len1, 27 | const uint8_t *buff2 , uint16_t len2, 28 | const uint8_t *buff3 , uint16_t len3, 29 | uint8_t *rxbuff , uint16_t rxlen ) ; 30 | 31 | 32 | static const unsigned int TRANSFER_TIMEOUT = 0xFFFF; 33 | 34 | private: 35 | static uint8_t index; 36 | static uint16_t CRC; 37 | static const char CTRL_C; 38 | static bool started; 39 | static uint8_t max_retries; 40 | static int timedRead(unsigned int timeout); 41 | static void dropAll(); 42 | 43 | 44 | 45 | static void crcUpdate(uint8_t c); 46 | static void crcReset(){CRC = 0xFFFF;}; 47 | static void crcWrite(); 48 | static bool crcCheck(uint16_t _CRC){ 49 | return CRC == _CRC; 50 | }; 51 | 52 | 53 | }; 54 | 55 | extern MiniBridge Bridge; 56 | #endif /* MINIBRIDGE_H_ */ 57 | #endif // I_USE_MINI_BRIDGE 58 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/read.me: -------------------------------------------------------------------------------- 1 | This started as an openwrt thing. 2 | Then yun came around so I adapted to yun 3 | Now yun is deprecated I moved to the pi 4 | I did not really bother downwards compatibility. So basically only the latest thing I used probably works 5 | And that is a pi and teensy 4.1+ 6 | 7 | Steps to make the yun(shield) work with webleds 8 | 9 | **prepare the yun** 10 | Make sure your yun(shield) runs the latest version 11 | it is a good idea to have a safe arduino sketch.If you are not sure upload the blink example 12 | When using the yunshield do not forget to disable the usb chip like explained here for the mega https://wiki1.dragino.com/index.php/Yun_Shield#Connect_to_Arduino_Mega2560 13 | 14 | Note that I had a yunshield that did not want to go to configuration mode after renaming it to marvin3 :-( 15 | 16 | 17 | **prepare storage** 18 | place a sd card (for yun) or a usb stick (for yun shield) in your computer 19 | copy the content of this eclipse project (currently named linksys_Arduino and in Jantje/ArduinoLibraries github repository) to the root of the storage 20 | 21 | **modify yun(shield) 22 | plug the storage in the yun(shield) 23 | ssh into the yun(shield) 24 | make sure the storage is recognised and mounted at /mnt/sda1 25 | 26 | create the folder /mnt/nas 27 | 28 | run the following command 29 | for yun /mnt/sda1/configure/startup 30 | 31 | The yun will reboot 32 | Upload a sketch (like mowrobot) and enjoy (well very unlikely it will run right away but anyways good luck) 33 | 34 | -------------------------------------------------------------------------------- /SerialCommunicator/examples/AnalogTest/AnalogTest.ino: -------------------------------------------------------------------------------- 1 | // Do not remove the include below 2 | #include "Arduino.h" 3 | #include "SerialDataInterface.h" 4 | #include "SerialCommunicator.h" 5 | #include "Analog.h" 6 | 7 | #define THESERIAL Serial2 8 | //#define THESERIAL Serial 9 | Stream &SerialInput = THESERIAL; 10 | Stream &SerialOutput = THESERIAL; 11 | Stream &SerialError = THESERIAL; 12 | 13 | 14 | const char mySketchName[] PROGMEM= "AnalogTester"; 15 | 16 | //the communication channel 17 | SerialCommunicator myCommunicator; 18 | 19 | //The analog pin reader 20 | Analog myAnalog; 21 | 22 | void setup() 23 | { 24 | 25 | // analogReference(INTERNAL2V56); 26 | 27 | delay(5000); 28 | THESERIAL.begin(115200); 29 | 30 | // Wait for U-boot to finish startup. Consume all bytes until we are done. 31 | do { 32 | while (SerialOutput.available() > 0) { 33 | SerialOutput.read(); 34 | } 35 | 36 | delay(1000); 37 | } while (SerialOutput.available()>0); 38 | 39 | SerialOutput.println ( (const __FlashStringHelper *)mySketchName); 40 | 41 | myCommunicator.serialRegister(F("Admin")); 42 | myAnalog.serialRegister(F("Analog")); 43 | 44 | SerialOutput.print(F("Current Datas ")); 45 | SerialOutput.println(lastFieldIndex); 46 | SerialOutput.println(F(" from ")); 47 | SerialOutput.println(MAXFIELDS); 48 | 49 | myCommunicator.setup(); 50 | 51 | myAnalog.setup(); 52 | 53 | } 54 | 55 | void loop() 56 | { 57 | 58 | myAnalog.loop(); 59 | myCommunicator.loop(); 60 | } 61 | -------------------------------------------------------------------------------- /TempMeterInterface/TempMeterInterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ITempMeter.h 3 | * 4 | * Created on: May 12, 2015 5 | * Author: jan 6 | */ 7 | 8 | #pragma once 9 | #include "Arduino.h" 10 | 11 | #ifdef I_USE_SERIAL_REGISTER 12 | #include "SerialDataInterface.h" 13 | #endif 14 | 15 | class TempMeterInterface 16 | { 17 | 18 | protected: 19 | uint32_t myMilliCelsius=0; 20 | boolean myIsError=false; 21 | uint16_t myReadInterval =1000; //default read every second 22 | public: 23 | 24 | #ifdef I_USE_SERIAL_REGISTER 25 | virtual void serialRegister(const __FlashStringHelper* Name) 26 | { 27 | FieldData::set(Name,F("MiliCelsius"),MOD_OVERVIEW,&myMilliCelsius); 28 | FieldData::set(Name,F("isError"),MOD_OVERVIEW,&myIsError); 29 | FieldData::set(Name,F("readEvery"),MOD_WRITE,&myReadInterval); 30 | } 31 | #endif 32 | virtual void setup()=0; 33 | virtual void loop()=0; 34 | virtual void setReadInterval(uint16_t newReadInterval) 35 | {myReadInterval=newReadInterval;} 36 | virtual uint16_t getReadInterval(){ 37 | return myReadInterval; 38 | } 39 | virtual ~TempMeterInterface()=default; 40 | int16_t getCelsius() const 41 | { 42 | return myMilliCelsius / 1000; 43 | } 44 | int16_t getCentiCelsius() const 45 | { 46 | return myMilliCelsius/10; 47 | } 48 | uint32_t getMiliCelsius() const 49 | { 50 | return myMilliCelsius; 51 | } 52 | bool isError() 53 | { 54 | return myIsError; 55 | } 56 | }; 57 | 58 | -------------------------------------------------------------------------------- /simplot/examples/makerfairRome2017Demo/gtest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef UNITTEST 2 | #include "gtest.h" 3 | #include "makerfairRome2017Demo.h" 4 | 5 | 6 | TEST(getBlinkLedValue, randomValues) 7 | { 8 | EXPECT_EQ(getBlinkLedValue(0,200,300),1); 9 | EXPECT_EQ(getBlinkLedValue(150,200,300),1); 10 | EXPECT_EQ(getBlinkLedValue(199,200,300),1); 11 | EXPECT_EQ(getBlinkLedValue(200,200,300),0); 12 | EXPECT_EQ(getBlinkLedValue(201,200,300),0); 13 | EXPECT_EQ(getBlinkLedValue(300,200,300),0); 14 | EXPECT_EQ(getBlinkLedValue(400,200,300),0); 15 | EXPECT_EQ(getBlinkLedValue(499,200,300),0); 16 | EXPECT_EQ(getBlinkLedValue(500,200,300),1); 17 | EXPECT_EQ(getBlinkLedValue(699,200,300),1); 18 | EXPECT_EQ(getBlinkLedValue(700,200,300),0); 19 | 20 | } 21 | 22 | TEST(getFadeLedValue, randomValues) 23 | { 24 | int error=5; 25 | EXPECT_NEAR(getFadeLedValue(0,200,300),0,error); 26 | EXPECT_NEAR(getFadeLedValue(100,200,300),125,error); 27 | EXPECT_NEAR(getFadeLedValue(150,200,300),190,error); 28 | EXPECT_NEAR(getFadeLedValue(199,200,300),255,error); 29 | EXPECT_NEAR(getFadeLedValue(200,200,300),255,error); 30 | EXPECT_NEAR(getFadeLedValue(201,200,300),255,error); 31 | EXPECT_NEAR(getFadeLedValue(300,200,300),170,error); 32 | EXPECT_NEAR(getFadeLedValue(400,200,300),85,error); 33 | EXPECT_NEAR(getFadeLedValue(499,200,300),0,error); 34 | EXPECT_NEAR(getFadeLedValue(500,200,300),0,error); 35 | EXPECT_NEAR(getFadeLedValue(699,200,300),255,error); 36 | EXPECT_NEAR(getFadeLedValue(700,200,300),255,error); 37 | 38 | } 39 | 40 | 41 | 42 | 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /SkidDriverInterface/SkidDriverinterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ISkidDriver.h 3 | * 4 | * Created on: Jul 4, 2014 5 | * Author: jan 6 | */ 7 | 8 | #ifndef ISKIDDRIVER_H_ 9 | #define ISKIDDRIVER_H_ 10 | #include "DataTypes.h" 11 | 12 | //typedef enum 13 | //{ 14 | // WHEELS_AT_SPEED = 0, WHEELS_DIRTY, WHEELS_OVERLOADED, WHEELS_NUM_STATES 15 | //} WHEELS_STATE; 16 | 17 | class SkidDriverInterface 18 | { 19 | protected: 20 | SPEED_TYPE myRequestedSpeed; 21 | DIRECTION_TYPE myRequestedDirection; 22 | SPEED_TYPE myNewRequestedSpeed; 23 | DIRECTION_TYPE myNewRequestedDirection; 24 | // WHEELS_STATE myWheelsState; 25 | 26 | 27 | public: 28 | 29 | virtual void motorOn()=0; 30 | virtual void motorOff()=0; 31 | virtual void setup()=0; 32 | virtual void loop()=0; 33 | void setSpeedAndDirection(SPEED_TYPE Speed, DIRECTION_TYPE Direction) 34 | { 35 | myNewRequestedSpeed=Speed; 36 | myNewRequestedDirection=Direction; 37 | }; 38 | 39 | virtual bool emergencyBreak(bool immediatlyReturn = false)=0; 40 | virtual void turnOnTheSpot(SPEED_TYPE Speed)=0; 41 | 42 | // WHEELS_STATE getState() const {return myWheelsState;}; 43 | virtual const __FlashStringHelper * getOverloadedWheelName(){ return F("no");}; 44 | 45 | virtual SPEED_TYPE getActualSpeed() const=0; 46 | 47 | SPEED_TYPE getRequestedSpeed() const 48 | { 49 | return myNewRequestedSpeed; 50 | } 51 | DIRECTION_TYPE getRequestedDirection() const 52 | { 53 | return myNewRequestedDirection; 54 | } 55 | 56 | 57 | }; 58 | 59 | #endif /* ISKIDDRIVER_H_ */ 60 | -------------------------------------------------------------------------------- /MotorPWM/examples/pwmMotor/PWMMotorTest.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * This sketch demonstrates the usage of the PWMMotor library. 3 | * 4 | * We will start the motor and let you use the SET command to set the motor speed 5 | * send 6 | * "SET Motor.RequestedSpeed=200"+CR 7 | * to arduino to set the motor speed to 200 8 | */ 9 | #include "PWMMotor.h" 10 | #include "SerialEEPROMCommunicator.h" 11 | 12 | /**!!!!!!!!!!!!!!!!This section you may have to change!!!!!!!!!!! */ 13 | #define PWMPIN 10 //the pin you connect the motor to 14 | #define STOPPWM 0 //the pwm frequency your motor is standing still (around 180) for bidirectional motors 15 | #define DIRPIN 5 //The pin to switch direction. Use -1 if no direction pin is used 16 | /**!!!!!!!!!!!!!!!!END OF This section you may have to change!!!!!!!!!!! */ 17 | 18 | Stream &SerialOutput = Serial; 19 | Stream &SerialInput = Serial; 20 | Stream &SerialError = Serial; 21 | 22 | 23 | const char mySketchName[] PROGMEM= "PWMMotorTester"; 24 | 25 | SerialEEPROMCommunicator myCommunicator; 26 | PWMMotor myMotor(PWMPIN,STOPPWM,DIRPIN); //This tests a one directional motor 27 | 28 | void setup() 29 | { 30 | Serial.begin(115200); 31 | myCommunicator.serialRegister(F("Admin")); 32 | myMotor.serialRegister(F("Motor")); 33 | myMotor.setup(); 34 | myCommunicator.setup(); 35 | 36 | } 37 | 38 | // The loop function is called in an endless loop 39 | void loop() 40 | { 41 | myMotor.loop(); 42 | myCommunicator.loop(); 43 | #ifdef I_USE_PLOT 44 | myMotor.plot(); 45 | delay(10);//Give the serial port some hope to catch up 46 | #endif 47 | } 48 | -------------------------------------------------------------------------------- /Sabertooth/examples/2.Settings/Persistent/MaxVoltage/MaxVoltage.ino: -------------------------------------------------------------------------------- 1 | // Set Maximum Voltage Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | // WARNING: This sample makes changes that will persist between restarts AND in all modes. 6 | // The values in this sample are specifically for the Sabertooth 2x25, and may 7 | // not have the same effect on other models. 8 | #include 9 | 10 | Sabertooth ST(128); 11 | 12 | void setup() 13 | { 14 | SabertoothTXPinSerial.begin(9600); 15 | ST.autobaud(); 16 | 17 | // See the Packet Serial section of the documentation for what values to use 18 | // for the maximum voltage command. It may vary between Sabertooth models 19 | // (2x25, 2x60, etc.). 20 | // 21 | // On a Sabertooth 2x25, the value is (Desired Volts) X 5.12. 22 | // In this sample, we'll cap the max voltage before the motor driver does 23 | // a hard brake at 14V. For a 12V ATX power supply this might be reasonable -- 24 | // at 16V they tend to shut off. Here, if the voltage climbs above 25 | // 14V due to regenerative braking, the Sabertooth will go into hard brake instead. 26 | // While this is occuring, the red Error LED will turn on. 27 | // 28 | // 14 X 5.12 = 71.68, so we'll go with 71, cutting off slightly below 14V. 29 | // 30 | // WARNING: This setting persists between power cycles. 31 | ST.setMaxVoltage(71); 32 | } 33 | 34 | void loop() 35 | { 36 | ST.motor(1, 50); 37 | delay(5000); 38 | 39 | ST.motor(1, -50); 40 | delay(5000); 41 | } 42 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/startup: -------------------------------------------------------------------------------- 1 | #to mount a cifs drive (linino) 2 | opkg update 3 | opkg install cifsmount 4 | opkg install kmod-fs-cifs 5 | 6 | #minicom is a program I use as serial monitor 7 | opkg install kmod-usb-acm 8 | opkg install minicom 9 | 10 | # tty ... 11 | opkg install coreutils-tty 12 | opkg install coreutils-stty 13 | 14 | #add /www/cgi-bin/jantje to the path 15 | echo 'export PATH=${PATH}:/www/cgi-bin/jantje' >>/etc/profile 16 | 17 | mkdir -p /www/cgi-bin/jantje 18 | mkdir -p /www/jantje 19 | 20 | 21 | #copy the latest version of the code to yun 22 | cp /mnt/sda1/dynamic/* /www/cgi-bin/jantje 23 | cp /mnt/sda1/static/* /www/jantje 24 | 25 | 26 | 27 | #add bonjour and arduino parser to startup 28 | #add the starting of my bridge to the start file of linux 29 | mv /etc/rc.local /etc/rc.local.org 30 | grep -v "exit 0" /etc/rc.local 31 | echo >>/etc/rc.local 32 | echo 'cd /www/cgi-bin/jantje/' >>/etc/rc.local 33 | echo './startReadingArduino.sh' >>/etc/rc.local 34 | echo 'exit 0' >>/etc/rc.local 35 | 36 | 37 | #remove - what I think - the security from the console by modifying /etc/inittab 38 | #remove the line ttyATH0::askfirst:/bin/ash --login 39 | #or the alternative line ::askconsole:/bin/ash --login 40 | mv /etc/inittab /etc/inittab.org 41 | grep -v "ttyATH0::askfirst:/bin/ash" /etc/inittab 42 | 43 | 44 | #reset the board together with linux to avoid unwanted serial data to arrive 45 | echo "#!/bin/ash" >/bin/reboot 46 | echo reset-mcu>>/bin/reboot 47 | echo /sbin/reboot >>/bin/reboot 48 | chmod +x /bin/reboot 49 | 50 | reboot 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /DigitalPotmeterMCP413/DigitalPotmeterMCP413.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MCP413.cpp 3 | * 4 | * Created on: Jul 11, 2014 5 | * Author: jan 6 | */ 7 | 8 | #include 9 | 10 | 11 | DigitalPotmeterMCP413::DigitalPotmeterMCP413(uint8_t maxPotValue, uint8_t slavePin,bool inverted) 12 | { 13 | myMaxPotValue=maxPotValue; 14 | mySlavePin=slavePin; 15 | myInverted=inverted; 16 | } 17 | 18 | void DigitalPotmeterMCP413::setup() 19 | { 20 | // I assume SPI.begin(); has been called before this method is called 21 | pinMode(mySlavePin,OUTPUT); 22 | myNewPotValue=0; 23 | myPotValue=1; 24 | loop(); 25 | } 26 | 27 | void DigitalPotmeterMCP413::loop() 28 | { 29 | if(myNewPotValue!=myPotValue) 30 | { 31 | digitalWrite(mySlavePin,LOW); 32 | SPI.transfer(0); 33 | if(myInverted) 34 | { 35 | myActualSendValue=map( 255-myNewPotValue,0,255,0,myMaxPotValue); 36 | } 37 | else 38 | { 39 | myActualSendValue= map( myNewPotValue,0,255,0,myMaxPotValue); 40 | } 41 | SPI.transfer(myActualSendValue); 42 | digitalWrite(mySlavePin,HIGH); 43 | myPotValue=myNewPotValue; 44 | } 45 | } 46 | 47 | void DigitalPotmeterMCP413::serialRegister(const __FlashStringHelper* Name) 48 | { 49 | FieldData::set( Name,F("myNewPotValue"), MOD_WRITE, &myNewPotValue); 50 | FieldData::setNext( F("myPotValue"), 0, &myPotValue); 51 | FieldData::setNext( F("myMaxPotValue"), 0, &myMaxPotValue); 52 | FieldData::setNext( F("myInverted"), 0, &myInverted); 53 | FieldData::setNext( F("myActualSendValue"),0,&myActualSendValue); 54 | FieldData::setNext( F("SlavePin"), 0, &mySlavePin); 55 | } 56 | -------------------------------------------------------------------------------- /SkidDriverBLDC/SkidDriverBLDC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BLDC1SkidDriver.h 3 | * 4 | * This is the skid driver implementation for the BLDC1 motor. 5 | * 6 | * Created on: May 9, 2014 7 | * Author: jan 8 | */ 9 | 10 | #ifndef _BLDC_SKID_DRIVER_H_ 11 | #define _BLDC_SKID_DRIVER_H_ 12 | #include "SkidDriverInterface.h" 13 | #include "MotorBLDC.h" 14 | 15 | //typedef enum 16 | //{ 17 | // WHEELS_AT_SPEED = 0, WHEELS_DIRTY, WHEELS_OVERLOADED, WHEELS_NUM_STATES 18 | //} WHEELS_STATE; 19 | 20 | class SkidDriverBLDC: public SkidDriverInterface 21 | { 22 | 23 | private: 24 | 25 | MotorBLDC myLeftMotor; 26 | MotorBLDC myRightMotor; 27 | 28 | public: 29 | void plot(); 30 | void motorOn(); 31 | void motorOff(); 32 | SkidDriverBLDC( uint8_t LeftForwardBackwardPin,uint8_t RightForwardBackwardPin, uint8_t LeftPWMPin,uint8_t RightPWMPin); 33 | void serialRegister(const __FlashStringHelper* Name, const __FlashStringHelper* LeftDriverName, const __FlashStringHelper* RightDriverName); 34 | 35 | void setup(); 36 | void loop(); 37 | void setSpeedAndDirection(SPEED_TYPE Speed, DIRECTION_TYPE Direction); 38 | 39 | bool emergencyBreak(); 40 | bool emergencyBreak( bool immediatlyReturn = false); 41 | void turn(DIRECTION_TYPE Corner); 42 | virtual void turnOnTheSpot(SPEED_TYPE Speed){};//TODO implement this method 43 | 44 | const __FlashStringHelper * getOverloadedWheelName(){return F("no");}; 45 | 46 | 47 | virtual SPEED_TYPE getActualSpeed() const {return (myLeftMotor.getActualSpeed()+myRightMotor.getActualSpeed())/2;}; 48 | 49 | 50 | }; 51 | 52 | #endif /* _BLDC_SKID_DRIVER_H_ */ 53 | -------------------------------------------------------------------------------- /SabertoothSimplified/examples/SimpleExample/SimpleExample.ino: -------------------------------------------------------------------------------- 1 | // Simple Example Sample 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | 7 | SabertoothSimplified ST; // We'll name the Sabertooth object ST. 8 | // For how to configure the Sabertooth, see the DIP Switch Wizard for 9 | // http://www.dimensionengineering.com/datasheets/SabertoothDIPWizard/start.htm 10 | // Be sure to select Simplified Serial Mode for use with this library. 11 | // This sample uses a baud rate of 9600. 12 | // 13 | // Connections to make: 14 | // Arduino TX->1 -> Sabertooth S1 15 | // Arduino GND -> Sabertooth 0V 16 | // Arduino VIN -> Sabertooth 5V (OPTIONAL, if you want the Sabertooth to power the Arduino) 17 | // 18 | // If you want to use a pin other than TX->1, see the SoftwareSerial example. 19 | 20 | void setup() 21 | { 22 | SabertoothTXPinSerial.begin(9600); // This is the baud rate you chose with the DIP switches. 23 | } 24 | 25 | 26 | void loop() 27 | { 28 | ST.motor(1, 127); // Go forward at full power. 29 | delay(2000); // Wait 2 seconds. 30 | ST.motor(1, 0); // Stop. 31 | delay(2000); // Wait 2 seconds. 32 | ST.motor(1, -127); // Reverse at full power. 33 | delay(2000); // Wait 2 seconds. 34 | ST.motor(1, 0); // Stop. 35 | delay(2000); 36 | } 37 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/SetGlobalSettings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | subfolder=jantje 3 | export PATH=${PATH}:/www/cgi-bin/${subfolder} 4 | SerialSpeed=115200 5 | Port=ttyATH0 6 | PortName=/dev/${Port} 7 | UploadPortName=/dev/${Port} 8 | HOST_NAME=`hostname` 9 | HugeRemoteStorageServer=nas.local 10 | WebLocationDynamic=/www/cgi-bin/${subfolder} 11 | WebLocationStatic=/www/${subfolder} 12 | LogFileSuffix=.csv 13 | staticfolderURL=/${subfolder}/ 14 | 15 | #the root of the storages 16 | CommonFastStorage=/tmp/${subfolder} 17 | CommonBigStorage=/mnt/sda1/${HOST_NAME}/${subfolder} 18 | CommonHugeRemoteMountPoint=/mnt/nas/ 19 | 20 | 21 | 22 | #the root of the storages per port (and system) 23 | FastSmallStorage=${CommonFastStorage}/${Port} 24 | SlowBigStorage=${CommonBigStorage}/${Port} 25 | HugeRemoteStorage=/mnt/nas/${HOST_NAME}/${Port} 26 | 27 | 28 | backupLocation=/mnt/nas/${HOST_NAME}/backup 29 | 30 | 31 | 32 | OutputHtml=${SlowBigStorage}/generated.html 33 | LogHeaderFile=${SlowBigStorage}/header.txt 34 | 35 | 36 | 37 | BeginHtml=${WebLocationStatic}/input.begin.html 38 | EndHtml=${WebLocationStatic}/input.end.html 39 | defaulthtmlFile=${WebLocationStatic}/default.html 40 | 41 | 42 | LogFilePrefix=${SlowBigStorage}/log/Arduino 43 | ErrorFolder=${SlowBigStorage}/log 44 | ErrorLog=${ErrorFolder}/error.log 45 | 46 | 47 | 48 | DumpFile=${FastSmallStorage}/dump.txt 49 | OutputValue=${FastSmallStorage}/value.txt 50 | logFile=${FastSmallStorage}/Arduino.log 51 | pid=${FastSmallStorage}/pid 52 | 53 | 54 | #script locations 55 | MakeWepPage=${WebLocationDynamic}/MakeWebPage.sh 56 | 57 | SttyCommand="stty -F ${PortName} ${SerialSpeed} raw -clocal -echo icrnl" 58 | 59 | -------------------------------------------------------------------------------- /VoltMeter/VoltMeter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * VoltMeter.h 3 | * 4 | * Created on: Mar 28, 2013 5 | * Author: jan 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | #include "Arduino.h" 12 | #ifdef USE_SERIAl_LOGGING 13 | #include "SerialDataInterface.h" 14 | #endif 15 | extern uint32_t loopMillis; 16 | class VoltMeter 17 | { 18 | private: 19 | uint8_t myPin; 20 | uint16_t myCentiVolt; 21 | uint16_t myMultiplyerValue; 22 | uint16_t myActualReadValue; 23 | uint16_t myAveragedReadValue; 24 | uint32_t my_last_read; 25 | 26 | 27 | public: 28 | #ifdef USE_SERIAl_LOGGING 29 | void serialRegister(const __FlashStringHelper* Name); 30 | VoltMeter( uint8_t Pin); 31 | #else 32 | /* 33 | * Constructor class if you do not use the serial logger. 34 | * This class allows you to initialize some constants that are otherwise 35 | * set via serial communication and remembered in FI eeprom 36 | * multiplyer is used to get from the adc cnverter (1 to 1023) to centivolt as follows 37 | * centivolt=adcvalue*multiplyer/1000 38 | * Assume you have a 10volt source and you uses a 50/50 deviding bridge on a uno 39 | * this means that 10 volt on source is 5 volt on the pin or 1023 adcvalue 40 | * the formula is the 41 | * 1000(10Volt=1000centivolt)=1023*multiplyer/1000 42 | * this mean multiplyer=1000*1000/1023=978 43 | */ 44 | VoltMeter(uint8_t Pin,uint16_t multiplyer); 45 | #endif 46 | 47 | void setup() 48 | { 49 | pinMode(myPin,INPUT); // This may not be needed 50 | myAveragedReadValue=myActualReadValue= analogRead(myPin); 51 | } 52 | 53 | void loop(); 54 | uint16_t getCentiVoltage() const { return myCentiVolt;} 55 | uint16_t get_dV() const { return (myCentiVolt+5)/10;} 56 | 57 | }; 58 | 59 | -------------------------------------------------------------------------------- /BlinkLed/BlinkLed.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BlinkLed.h 3 | * 4 | * Created on: Sep 11, 2013 5 | * Author: jan 6 | * This is the blink without delay example put in a class 7 | * I made the on interval different from the off interval 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "Arduino.h" 13 | #ifdef SOFTPWM 14 | #include "SoftPWM.h" 15 | #else 16 | #warning If the leds are to bright define SOFTPWM 17 | #endif 18 | 19 | 20 | class BlinkLed 21 | { 22 | public: 23 | enum ledState{blinking,on,off}; 24 | BlinkLed(uint8_t ledPin,uint16_t onInterval ,uint16_t offInterval); 25 | void setOnInterval(uint16_t onInterval){myOnInterval=onInterval;}; 26 | void setOffInterval(uint16_t offInterval){myOffInterval=offInterval;}; 27 | void setup(); 28 | void loop(); 29 | ledState getLedState(){return myLedState;}; 30 | void setLedState(ledState newLedState){myLedState=newLedState;}; 31 | protected: 32 | // constants won't change. Used here to 33 | // set pin numbers: 34 | uint8_t myLedPin ; // the number of the LED pin 35 | ledState myLedState=blinking; 36 | 37 | // the follow variables is a long because the time, measured in miliseconds, 38 | // will quickly become a bigger number than can be stored in an int. 39 | uint16_t myOnInterval ; // interval at which to blink (milliseconds) 40 | uint16_t myOffInterval ; // interval at which to blink (milliseconds) 41 | uint8_t myPrefPinState=LOW; 42 | uint32_t myPrefLoopMillis=0; 43 | #ifdef SOFTPWM 44 | //the usage of softpwm allows to coorect the brightness of the leds 45 | public: 46 | void setPwmValue(uint8_t newPwmValue){myPwmValue=newPwmValue;}; 47 | protected: 48 | uint8_t myPwmValue; 49 | #endif 50 | 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /Sabertooth/examples/3.Advanced/SharedLine/SharedLine.ino: -------------------------------------------------------------------------------- 1 | // Shared Line Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | 7 | // Up to 8 Sabertooth/SyRen motor drivers can share the same S1 line. 8 | // This sample uses three: address 128 and 129 on ST1[0] and ST1[2], 9 | // and address 130 on ST2. 10 | Sabertooth ST1[2] = { Sabertooth(128), Sabertooth(129) }; 11 | Sabertooth ST2(130); 12 | 13 | void setup() 14 | { 15 | SabertoothTXPinSerial.begin(9600); 16 | Sabertooth::autobaud(SabertoothTXPinSerial); // Autobaud is for the whole serial line -- you don't need to do 17 | // it for each individual motor driver. This is the version of 18 | // the autobaud command that is not tied to a particular 19 | // Sabertooth object. 20 | // See the examples in 1.Basics for information on whether you 21 | // need this line at all. 22 | } 23 | 24 | void loop() 25 | { 26 | // ST1[0] (address 128) has power 50 (of 127 max) on M1, 27 | // ST1[1] (address 129) has power 60 (of 127 max) on M2, and 28 | // ST2 (address 130) we'll do tank-style and have it drive 20 and turn right 50. 29 | // Do this for 5 seconds. 30 | ST1[0].motor(1, 50); 31 | ST1[1].motor(2, 60); 32 | ST2.drive(20); 33 | ST2.turn(50); 34 | delay(5000); 35 | 36 | // And now let's stop for 5 seconds, except address 130 -- we'll let it stop and turn left... 37 | ST1[0].motor(1, 0); 38 | ST1[1].motor(2, 0); 39 | ST2.drive(0); 40 | ST2.turn(-40); 41 | delay(5000); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /SabertoothSimplified/examples/Sweep/Sweep.ino: -------------------------------------------------------------------------------- 1 | // Sweep Sample 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | 7 | SabertoothSimplified ST; // We'll name the Sabertooth object ST. 8 | // For how to configure the Sabertooth, see the DIP Switch Wizard for 9 | // http://www.dimensionengineering.com/datasheets/SabertoothDIPWizard/start.htm 10 | // Be sure to select Simplified Serial Mode for use with this library. 11 | // This sample uses a baud rate of 9600. 12 | // 13 | // Connections to make: 14 | // Arduino TX->1 -> Sabertooth S1 15 | // Arduino GND -> Sabertooth 0V 16 | // Arduino VIN -> Sabertooth 5V (OPTIONAL, if you want the Sabertooth to power the Arduino) 17 | // 18 | // If you want to use a pin other than TX->1, see the SoftwareSerial example. 19 | 20 | void setup() 21 | { 22 | SabertoothTXPinSerial.begin(9600); // This is the baud rate you chose with the DIP switches. 23 | } 24 | 25 | void loop() 26 | { 27 | int power; 28 | 29 | // Ramp motor 1 and motor 2 from -127 to 127 (full reverse to full forward), 30 | // waiting 20 ms (1/50th of a second) per value. 31 | for (power = -127; power <= 127; power ++) 32 | { 33 | ST.motor(1, power); 34 | ST.motor(2, power); 35 | delay(20); 36 | } 37 | 38 | // Now go back the way we came. 39 | for (power = 127; power >= -127; power --) 40 | { 41 | ST.motor(1, power); 42 | ST.motor(2, power); 43 | delay(20); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Sabertooth/examples/2.Settings/Persistent/BaudRate/BaudRate.ino: -------------------------------------------------------------------------------- 1 | // Set Baud Rate Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | // WARNING: This sample makes changes that will persist between restarts. 6 | // NOTE: The setBaudRate function will only have an effect on V2 controllers (2x12, 2x25 V2, 2x60, SyRen 50). 7 | // Earlier controllers automatically detect the baud rate you choose in Serial.begin 8 | // when you call the autobaud function. Autobaud was replaced in V2 controllers for reliability 9 | // in the event that the Sabertooth lost power. 10 | #include 11 | 12 | Sabertooth ST(128); 13 | 14 | void setup() 15 | { 16 | // This sample will tell the Sabertooth *at 9600 baud* to *switch to 2400 baud*. 17 | // Keep in mind you must send the command to change the baud rate *at the baud rate 18 | // the Sabertooth is listening at* (factory default is 9600). After that, if it works, 19 | // you will be able to communicate using the new baud rate. 20 | // 21 | // Options are: 22 | // 2400 23 | // 9600 24 | // 19200 25 | // 38400 26 | // 115200 (only supported by some devices such as 2X60 -- check the device's datasheet) 27 | // 28 | // WARNING: The Sabertooth remembers this command between restarts. 29 | // To change your Sabertooth back to its default, you must *be at the baud rate you've 30 | // set the Sabertooth to*, and then call ST.setBaudRate(9600) 31 | SabertoothTXPinSerial.begin(9600); 32 | ST.setBaudRate(2400); 33 | SabertoothTXPinSerial.end(); 34 | 35 | // OK, we're at 2400. Let's talk to the Sabertooth at that speed. 36 | SabertoothTXPinSerial.begin(2400); 37 | } 38 | 39 | void loop() 40 | { 41 | ST.drive(0); 42 | ST.turn(20); 43 | delay(2000); 44 | 45 | ST.turn(-20); 46 | delay(2000); 47 | } 48 | 49 | -------------------------------------------------------------------------------- /MotorPotmeterDirection/MotorPotmeterDirection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ScooterMotor.h 3 | * 4 | * Created on: Jul 5, 2014 5 | * Author: jan 6 | */ 7 | 8 | #ifndef SCOOTERMOTOR_H_ 9 | #define SCOOTERMOTOR_H_ 10 | 11 | #include "MotorInterface.h" 12 | #include "SerialDataInterface.h" 13 | #include "CurrentSensorInterface.h" 14 | #include "DigitalPotmeterInterface.h" 15 | 16 | 17 | /** 18 | * This class is to control a scooter motor that can go clockwise and counterclockwise 19 | * The motor is controled by a digital potmeter AD5171 20 | * and a pin to switch between clockwise and counterclockwise 21 | * The load of the motor is measused with a ampere meter connected to a analog pin 22 | * The switch between clockwise and counterclockwise is only done when the motor is standing still. 23 | */ 24 | class MotorPotmeterDirection: public MotorInterface 25 | { 26 | protected : 27 | bool mySpinsClockWise; 28 | uint8_t myClockwisePin; 29 | uint32_t MyLastactionTime; 30 | CurrentSensorInterface &myCurrentSensor; 31 | DigitalPotmeterInterface &myPotmeter; 32 | void setPotValue(); 33 | public: 34 | #ifdef I_USE_SERIAL_REGISTER 35 | void serialRegister(const __FlashStringHelper* Name); 36 | #endif 37 | /** 38 | * The constructor of the scooter motor 39 | * 40 | * clockwisePin the digital pin to control clockwise or counter clockwise 41 | * ampPin the analog pin giving the amps used by the motor 42 | * I2CAdress the I2C adress to talk to the digital pot 43 | */ 44 | MotorPotmeterDirection(uint8_t clockwisePin,CurrentSensorInterface ¤tSensor,DigitalPotmeterInterface &poMeter); 45 | virtual void loop(); 46 | virtual void setup(); 47 | virtual void motorOn(); 48 | virtual void motorOff(); 49 | bool emergencyBreak(){emergencyBreak(false);}; 50 | virtual bool emergencyBreak(bool immediatlyReturn); 51 | 52 | }; 53 | 54 | #endif /* SCOOTERMOTOR_H_ */ 55 | -------------------------------------------------------------------------------- /SerialCommunicator/examples/PWMexample/PWMexample.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This is an example how you can set values to PWM pins 3 | * That can be used for any other setting that needs code triggering 4 | */ 5 | #include "SerialCommunicator.h" 6 | #include "SerialDataInterface.h" 7 | #include "SerialStringReader.h" 8 | SerialCommunicator myCommunicator; 9 | Stream &SerialInput = Serial; 10 | Stream &SerialOutput = Serial; 11 | Stream &SerialError = Serial; 12 | 13 | const char mySketchName[] PROGMEM="set PWM sample"; 14 | 15 | class pwmPin 16 | { 17 | private: 18 | uint8_t myPWM; 19 | uint8_t newPWM; 20 | uint8_t mypin; 21 | public: 22 | pwmPin(uint8_t pin){mypin=pin;myPWM=newPWM=0;} 23 | void setup() 24 | { 25 | pinMode(mypin,OUTPUT); 26 | analogWrite(mypin,myPWM); 27 | }; 28 | void loop() 29 | { 30 | if (myPWM!=newPWM) 31 | { 32 | myPWM=newPWM; 33 | analogWrite(mypin,myPWM); 34 | } 35 | } 36 | void serialRegister(const __FlashStringHelper* Name) 37 | { 38 | FieldData::set(Name, F("newPWMValue"),MOD_WRITE, &newPWM); 39 | FieldData::setNext( F("curPWMValue"), 0, &myPWM); 40 | FieldData::setNext( F("pin"), 0, &mypin); 41 | } 42 | 43 | }; 44 | 45 | pwmPin myPWMPin3(3); 46 | pwmPin myPWMPin4(4); 47 | pwmPin myPWMPin5(5); 48 | pwmPin myPWMPin6(6); 49 | void setup() 50 | { 51 | Serial.begin(115200); 52 | myCommunicator.serialRegister(F("communicator")); 53 | myPWMPin3.serialRegister(F("pin3")); 54 | myPWMPin4.serialRegister(F("pin4")); 55 | myPWMPin5.serialRegister(F("pin5")); 56 | myPWMPin6.serialRegister(F("pin6")); 57 | myPWMPin3.setup(); 58 | myPWMPin4.setup(); 59 | myPWMPin5.setup(); 60 | myPWMPin6.setup(); 61 | myCommunicator.setup(); 62 | } 63 | 64 | 65 | void loop() 66 | { 67 | myPWMPin3.loop(); 68 | myPWMPin4.loop(); 69 | myPWMPin5.loop(); 70 | myPWMPin6.loop(); 71 | myCommunicator.loop(); 72 | } 73 | -------------------------------------------------------------------------------- /SerialStringReader/SerialStringReader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SmartSerial.cpp 3 | * 4 | * Created on: Nov 28, 2012 5 | * Author: Jan baeyens aka Jantje 6 | */ 7 | 8 | #include "SerialStringReader.h" 9 | 10 | //char SerialStringReader::myMessage[MAX_MESSAGE_LENGTH + 1]; //The message (or part of) that has been received 11 | //uint8_t SerialStringReader::myMessageIndex = 0; //The length of the message (next character to write) 12 | //boolean SerialStringReader::myHasMessage = false; 13 | 14 | SerialStringReader::SerialStringReader( Stream & theStream ) 15 | :myStream(theStream) 16 | { myMessage[0]=0; 17 | }; 18 | 19 | void SerialStringReader::flush() 20 | { 21 | #ifndef LOCAL_RUN //if we do simulations with files there is no need to flush out data 22 | myHasMessage = false; 23 | myMessageIndex = 0; 24 | boolean hasReadSomething = false; 25 | do 26 | { 27 | if (hasReadSomething) delay(200); //If data has been found wait a while for more data 28 | hasReadSomething = false; 29 | while (myStream.available()) 30 | { 31 | myStream.read(); 32 | hasReadSomething = true; 33 | } 34 | } while (hasReadSomething); 35 | #endif 36 | } 37 | 38 | void SerialStringReader::loop() 39 | { 40 | while ((!myHasMessage) && (myStream.available() > 0)) 41 | { 42 | char aChar = myStream.read(); 43 | if ((aChar == '\n') || (aChar == '\r')) 44 | { 45 | myHasMessage = (myMessageIndex!=0); //this way if \n and \r are send we do not get 2 messages 46 | myMessageIndex = 0; 47 | } else 48 | { 49 | myMessage[myMessageIndex] = aChar; 50 | myMessage[++myMessageIndex] = 0; // Keep the string NULL terminated 51 | if (myMessageIndex >= MAX_MESSAGE_LENGTH) 52 | { 53 | SerialError.print(F("Message to long. Max: ")); 54 | SerialError.println(MAX_MESSAGE_LENGTH); 55 | SerialError.println(myMessage); 56 | myMessageIndex=0; 57 | } 58 | } 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /gtest/gtest_main.cc: -------------------------------------------------------------------------------- 1 | #ifdef UNITTEST 2 | // Copyright 2006, Google Inc. 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | 33 | #include "gtest.h" 34 | 35 | GTEST_API_ int main(int argc, char **argv) { 36 | printf("Running main() from gtest_main.cc\n"); 37 | testing::InitGoogleTest(&argc, argv); 38 | return RUN_ALL_TESTS(); 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /BlinkLed/BlinkLed.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BlinkLed.cpp 3 | * 4 | * Created on: Sep 11, 2013 5 | * Author: jan 6 | */ 7 | 8 | #include "BlinkLed.h" 9 | 10 | BlinkLed::BlinkLed(uint8_t ledPin, uint16_t onInterval, uint16_t offInterval) { 11 | 12 | myLedPin = ledPin; // the number of the LED pin 13 | myOnInterval = onInterval; 14 | myOffInterval = offInterval; 15 | #ifdef SOFTPWM 16 | myPwmValue=100; 17 | #endif 18 | } 19 | 20 | void BlinkLed::setup() { 21 | // set the digital pin as output: 22 | pinMode(myLedPin, OUTPUT); 23 | 24 | #ifdef SOFTPWM 25 | SoftPWMSet(myLedPin, 0); 26 | SoftPWMSetFadeTime(myLedPin, 1000, 1000); 27 | #else 28 | digitalWrite(myLedPin, LOW); 29 | #endif 30 | } 31 | 32 | void BlinkLed::loop() { 33 | #ifndef USE_MAIN_LOOP_MILLIS 34 | uint32_t loopMillis = millis(); 35 | #else 36 | extern uint32_t loopMillis; 37 | #endif 38 | 39 | uint8_t newPinState = myPrefPinState; 40 | switch (myLedState) { 41 | case blinking: { 42 | //this is a expensive calculation 43 | if (loopMillis - myPrefLoopMillis > 10) { 44 | myPrefLoopMillis = loopMillis; 45 | if ((loopMillis % (myOnInterval + myOffInterval)) >= myOffInterval) { 46 | newPinState = HIGH; 47 | } else { 48 | newPinState = LOW; 49 | } 50 | } else { 51 | return; 52 | } 53 | break; 54 | } 55 | case on: 56 | newPinState = HIGH; 57 | break; 58 | case off: 59 | newPinState = LOW; 60 | } 61 | if (myPrefPinState != newPinState) { 62 | #ifdef SOFTPWM 63 | SoftPWMSet(myLedPin, newPinState*myPwmValue); 64 | #else 65 | //Serial.println("led changed state"); 66 | digitalWrite(myLedPin, newPinState); 67 | #endif 68 | myPrefPinState = newPinState; 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /JanServo/Examples/ContraintServo/ContraintServo.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * A sample program demonstrating the behavior of the JanConstraintServo class 3 | * 3 Servos are sweeping with exactly the same values in the code but with different physical movement. 4 | * 1 servo uses the Arduino Servo class and will use the full sweeping range 5 | * 2 servos use the JanConstraintServo class and will not use the full sweeping range. One is constraint in the max value the other in the min value. 6 | * The 3th servo uses the standard Servo class 7 | * The 2 servo's do behave in sync. With which I mean that the servo with the smaller range does not stop moving when nearing the ned of its range. 8 | */ 9 | #include "Arduino.h" 10 | #include "JanServo.h" 11 | 12 | 13 | /* defines for positioning Servo's*/ 14 | #define STOP_POSITIE 90 15 | 16 | #define SERVO_1_MIN_POSITIE 45 17 | #define SERVO_2_MIN_POSITIE 0 18 | 19 | #define SERVO_1_MAX_POSITIE 180 20 | #define SERVO_2_MAX_POSITIE 135 21 | 22 | 23 | /* defines for the pins */ 24 | #define SERVO_1_PIN 20 25 | #define SERVO_2_PIN 21 26 | #define SERVO_3_PIN 22 27 | 28 | 29 | 30 | JanConstraintServo servo1(SERVO_1_PIN,SERVO_1_MIN_POSITIE,SERVO_1_MAX_POSITIE,STOP_POSITIE); 31 | JanConstraintServo servo2(SERVO_2_PIN,SERVO_2_MIN_POSITIE,SERVO_2_MAX_POSITIE,STOP_POSITIE); 32 | Servo servo3; 33 | 34 | 35 | 36 | void setup() 37 | { 38 | servo1.setup(); 39 | servo2.setup(); 40 | servo3.attach(SERVO_3_PIN); 41 | servo3.write(STOP_POSITIE); 42 | 43 | } 44 | 45 | void loop() { 46 | static int curPosition=0; 47 | static int step=1; 48 | servo1.SetPosition(curPosition); 49 | servo2.SetPosition(curPosition); 50 | servo3.write(curPosition); 51 | servo1.loop(); 52 | servo2.loop(); 53 | //calculate the new position 54 | curPosition=curPosition+step; 55 | if (curPosition>180) 56 | { 57 | curPosition=179; 58 | step=-1; 59 | } 60 | if(curPosition<0) 61 | { 62 | curPosition=1; 63 | step=1; 64 | } 65 | delay(500); //Only use delay is samples to make the code more readable 66 | } 67 | 68 | -------------------------------------------------------------------------------- /TempMeterAdafruitmcp9808/TempMeterAdafruitmcp9808.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * adafruitmcp9808.cpp 3 | * 4 | * Created on: May 12, 2015 5 | * Author: jan 6 | */ 7 | 8 | #include 9 | #include "Wire.h" 10 | #define MCP9808_I2CADDR_DEFAULT 0x18 11 | #define MCP9808_REG_CONFIG 0x01 12 | 13 | #define MCP9808_REG_CONFIG_SHUTDOWN 0x0100 14 | #define MCP9808_REG_CONFIG_CRITLOCKED 0x0080 15 | #define MCP9808_REG_CONFIG_WINLOCKED 0x0040 16 | #define MCP9808_REG_CONFIG_INTCLR 0x0020 17 | #define MCP9808_REG_CONFIG_ALERTSTAT 0x0010 18 | #define MCP9808_REG_CONFIG_ALERTCTRL 0x0008 19 | #define MCP9808_REG_CONFIG_ALERTSEL 0x0002 20 | #define MCP9808_REG_CONFIG_ALERTPOL 0x0002 21 | #define MCP9808_REG_CONFIG_ALERTMODE 0x0001 22 | 23 | #define MCP9808_REG_UPPER_TEMP 0x02 24 | #define MCP9808_REG_LOWER_TEMP 0x03 25 | #define MCP9808_REG_CRIT_TEMP 0x04 26 | #define MCP9808_REG_AMBIENT_TEMP 0x05 27 | #define MCP9808_REG_MANUF_ID 0x06 28 | #define MCP9808_REG_DEVICE_ID 0x07 29 | 30 | 31 | uint16_t TempMeterAdafruitmcp9808::read16(uint8_t reg) { 32 | uint16_t val; 33 | 34 | Wire.beginTransmission(myAddress); 35 | Wire.write((uint8_t)reg); 36 | Wire.endTransmission(); 37 | 38 | Wire.requestFrom((uint8_t)myAddress, (uint8_t)2); 39 | val = Wire.read(); 40 | val <<= 8; 41 | val |= Wire.read(); 42 | return val; 43 | } 44 | 45 | 46 | void TempMeterAdafruitmcp9808::setup() 47 | { 48 | Wire.begin(); 49 | myIsError =(read16(MCP9808_REG_MANUF_ID) != 0x0054); 50 | myIsError &= (read16(MCP9808_REG_DEVICE_ID) != 0x0400); 51 | if(myIsError) 52 | { 53 | myCentiCelsius=ERROR_CENTI_CELSIUS; 54 | } 55 | } 56 | 57 | void TempMeterAdafruitmcp9808::loop() 58 | { 59 | if(!myIsError) 60 | { 61 | uint16_t t = read16(MCP9808_REG_AMBIENT_TEMP); 62 | 63 | float temp = t & 0x0FFF; 64 | temp /= 16.0; 65 | if (t & 0x1000) temp -= 256; 66 | 67 | myCentiCelsius= temp*100; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /gps_Library/examples/gpsTester/gps_tester.ino: -------------------------------------------------------------------------------- 1 | #include "gps_Library.h" 2 | #define GPSBAUTRATE 9600 3 | 4 | 5 | #if defined(I_USE_SOFTWARESERIAL) || defined(I_USE_ALTSOFTSERIAL) 6 | #define GPSTX_PIN 13 7 | #define GPSRX_PIN 5 8 | SERIALTYPE myGPSserial(GPSTX_PIN, GPSRX_PIN); 9 | #else 10 | #define myGPSserial Serial1 11 | #endif 12 | #define MYSERIAL Serial1 13 | 14 | GPSModule MyGpsModule(GPSBAUTRATE,&myGPSserial); 15 | 16 | //The setup function is called once at startup of the sketch 17 | void setup() 18 | { 19 | delay(3000); //needed to be able to reboot both linino and leonardo. 20 | MYSERIAL.begin(115200); // Set the baud. 21 | 22 | // Wait for U-boot to finish startup. Consume all bytes until we are done. 23 | do { 24 | while (MYSERIAL.available() > 0) { 25 | MYSERIAL.read(); 26 | } 27 | 28 | delay(1000); 29 | } while (MYSERIAL.available()>0); 30 | 31 | MYSERIAL.println("\r\nGPSlogger"); 32 | 33 | MYSERIAL.println("initializing gps"); 34 | MyGpsModule.setup(); 35 | MYSERIAL.println("initializing gps is done "); 36 | } 37 | 38 | 39 | char buffer[100]; 40 | void loop() 41 | { 42 | static uint32_t lastLog=0; 43 | static DateTime lastTime; 44 | DateTime CurTime; 45 | MyGpsModule.loop(); 46 | CurTime = MyGpsModule.getLastMessageTimeStamp(); 47 | if (millis()-lastLog>30000) 48 | { 49 | lastTime = CurTime; 50 | MYSERIAL.println(CurTime.toString(buffer,100)); 51 | MYSERIAL.print("Has reception "); 52 | MYSERIAL.println(MyGpsModule.hasReception()); 53 | MYSERIAL.print("Latitude "); 54 | MYSERIAL.print(MyGpsModule.getLastMessageLocation().myLatitude); 55 | MYSERIAL.print(" Longitude "); 56 | MYSERIAL.println(MyGpsModule.getLastMessageLocation().myLongitude); 57 | MYSERIAL.print("Speed "); 58 | MYSERIAL.println(MyGpsModule.getLastMessageSpeed()); 59 | MYSERIAL.print("Direction "); 60 | MYSERIAL.println(MyGpsModule.getLastMessageDirection()); 61 | MYSERIAL.print("Buffer "); 62 | MYSERIAL.println(MyGpsModule.getBuffer()); 63 | lastLog=millis(); 64 | } 65 | 66 | 67 | } 68 | -------------------------------------------------------------------------------- /SerialDataInterface/FieldInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FieldInfo.h 3 | * 4 | * Created on: Feb 8, 2014 5 | * Author: jan 6 | */ 7 | 8 | #ifndef FIELDINFO_H_ 9 | #define FIELDINFO_H_ 10 | #include "Arduino.h" 11 | #include "SerialStringReader.h" 12 | 13 | 14 | #if defined(I_USE_GPS) || defined(I_USE_DATETIME) 15 | #include "DataTypes.h" 16 | #endif 17 | #define commonlyUsedBuffersize 300 18 | extern char commonlyUsedBuffer[commonlyUsedBuffersize]; //a buffer you use for temporary storage. 19 | //as this is a shared buffer don'texpect the data to be available after a while 20 | 21 | 22 | typedef enum 23 | { 24 | _uint8_t, _int8_t, _uint16_t, _int16_t, _uint32_t, _int32_t, _ppchar, _bool, _FlashStringHelper, 25 | #ifdef I_USE_GPS 26 | _GPSLocation, 27 | #endif 28 | #ifdef I_USE_STRING 29 | _String, 30 | #endif 31 | #ifdef I_USE_DATETIME 32 | _DateTime, 33 | #endif 34 | _LastDataType 35 | } DataTypes; 36 | 37 | #define MOD_NONE ((uint8_t)0) //Allow writes to this field 38 | #define MOD_WRITE ((uint8_t)1) //Allow writes to this field 39 | #define MOD_SAVE ((uint8_t)2) //Allow this field to be saved 40 | #define MOD_ERASE_ON_DUMP ((uint8_t)4) //When a dump is done this field is erased String="" integer values=0 pchar=/0 41 | #define MOD_OVERVIEW ((uint8_t)64) //When a overview page is made this field should be on the page 42 | class FieldInfo 43 | { 44 | public: 45 | const __FlashStringHelper * myClassName; 46 | const __FlashStringHelper * myFieldName; 47 | //DataTypes myType; 48 | uint8_t myType; 49 | uint8_t myModFlag; 50 | const FieldInfo & operator=(const FieldInfo &fieldInfo); 51 | bool operator==(const FieldInfo &fieldInfo) const; 52 | void dump(Stream &serial) const; 53 | 54 | #ifdef I_USE_GPS 55 | static DataTypes getType(GPSLocation){return _GPSLocation;}; 56 | #endif 57 | #ifdef I_USE_STRING 58 | static DataTypes getType(String){return _String;}; 59 | #endif 60 | #ifdef I_USE_DATETIME 61 | static DataTypes getType(DateTime){return _DateTime;}; 62 | #endif 63 | }; 64 | #endif /* FIELDINFO_H_ */ 65 | -------------------------------------------------------------------------------- /MotorMegaMotoLoadHBridge/MotorMegaMotoLoadHBridge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MegaMotoLoadHBridgeDriver.h 3 | * 4 | * Created on: May 24, 2012 5 | * Author: BE04258 6 | */ 7 | 8 | #ifndef MEGAMOTOLOADHBRIDGEDRIVER_H_ 9 | #define MEGAMOTOLOADHBRIDGEDRIVER_H_ 10 | #include "MegaMotoHBridgeDriver.h" 11 | #include "SerialDataInterface.h" 12 | #define BUSINESSACTIONSIZE 30 13 | 14 | class MegaMotoLoadHBridgeDriver 15 | { 16 | private: 17 | MegaMotoHBridgeDriver myMegaMotoHBridgeDriver; 18 | uint8_t myStandardPWM; //The pwm used when we get 255 to run 19 | uint8_t myMaxPWM; // the power used when we see more than current power is used 20 | uint16_t myMaxDurationAtMaxPWM; // The maximum time we use MyMaxPower 21 | uint16_t myCurrentTriggerToGoToMaxPWM; // The current we use to trigger (current is more than this) to go MyMaxPower 22 | uint32_t myMaxPWMStartTime; 23 | uint32_t myLoopDuration; 24 | int16_t myRequestedSpeed; 25 | char myBusinessAction[BUSINESSACTIONSIZE]; 26 | 27 | 28 | 29 | public: 30 | virtual ~MegaMotoLoadHBridgeDriver(){}; 31 | MegaMotoLoadHBridgeDriver( ENABLEPINPARAM uint8_t PWMAPin, uint8_t PWMBPin,uint8_t CurrentPin , uint8_t StandardVoltage, uint8_t MaxVoltage,uint16_t MaxDurationAtMaxVoltage,int CurrentTrigger); 32 | void serialRegister(const __FlashStringHelper* Name,const __FlashStringHelper* DriverName,const __FlashStringHelper* BrigeAName,const __FlashStringHelper* BrigeBName); 33 | void loop(); 34 | virtual void setSpeed(int16_t Speed); 35 | virtual int16_t getRequestedSpeed(); 36 | 37 | void setStandardPWM( uint8_t newStandardPWM) 38 | { myStandardPWM=newStandardPWM;}; 39 | uint8_t getStandardPWM() 40 | { return myStandardPWM;}; 41 | bool emergencyBreak(bool immediatlyReturn) 42 | { return myMegaMotoHBridgeDriver.emergencyBreak(immediatlyReturn);}; 43 | // void setSuppliedVoltage(uint8_t Voltage) 44 | // { myMegaMotoHBridgeDriver.setSuppliedVoltage( Voltage);} 45 | void engineOn(){myMegaMotoHBridgeDriver.engineOn();}; 46 | void engineOff(){myMegaMotoHBridgeDriver.engineOff();}; 47 | }; 48 | 49 | #endif /* MEGAMOTOLOADHBRIDGEDRIVER_H_ */ 50 | -------------------------------------------------------------------------------- /JanServo/Examples/latchServo/latchServo.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Controlling a servo position using serial communication 3 | */ 4 | 5 | #include "JanServo.h" 6 | #include "SerialDataInterface.h" 7 | #include "SerialCommunicator.h" 8 | #include "SerialStringReader.h" 9 | 10 | 11 | int servoLock = 75; // angle (deg) of "locked" servo 12 | int servoUnlock = 20; // angle (deg) of "unlocked" servo 13 | 14 | //This is a global variable used by the communicator which should hold 15 | // a nice name to recognize the program 16 | // The name is outputted as part of the DUMP command 17 | const char mySketchName[] PROGMEM="servo"; 18 | SerialCommunicator myCommunicator; 19 | 20 | #define THESERIAL Serial 21 | Stream &SerialInput = THESERIAL; 22 | Stream &SerialOutput = THESERIAL; 23 | Stream &SerialError = THESERIAL; //This channel has been added for error logging 24 | 25 | JanConstraintServo servoLatch(9, 0, 180, servoUnlock); 26 | 27 | 28 | 29 | 30 | int val; // variable to read the value from the analog pin 31 | 32 | void setup() 33 | { 34 | delay(2000); 35 | THESERIAL.begin(115200); 36 | //Here we register the communicator. This is not strictly needed but the communicator 37 | // contains some very handy features and setting so you probably want it. 38 | // Note that the name provided here is the name you will use to access it via the serial 39 | // monitor line commands 40 | // comment the line below and see what it does 41 | myCommunicator.serialRegister(F("Admin")); 42 | // We also register the led. Again we will access the led with the name provided here 43 | servoLatch.serialRegister(F("Servo")); 44 | //As MAXFIELDS needs to be big enough it is not a bad idea to know how big it is now 45 | SerialOutput.print(F("Current memory fields ")); 46 | SerialOutput.println(lastFieldIndex); //yes I do use global variables 47 | SerialOutput.println(F(" from ")); 48 | SerialOutput.println(MAXFIELDS); //13 of 70 that is way more than enough 49 | 50 | servoLatch.setup(); 51 | myCommunicator.setup(); 52 | } 53 | 54 | void loop() 55 | { 56 | servoLatch.loop(); 57 | myCommunicator.loop(); 58 | 59 | } 60 | 61 | -------------------------------------------------------------------------------- /SkidDriverMegaMoto/SkidDriverMegaMoto.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEGA_MOTO_SKID_DRIVER_H_ 2 | #define _MEGA_MOTO_SKID_DRIVER_H_ 3 | #include 4 | #include "MotorMegaMoto.h" 5 | #include "MotorMegaMotoHBridge.h" 6 | 7 | class SkidDriverMegaMoto: public SkidDriverInterface { 8 | private: 9 | // MegaMotoLoadHBridgeDriver myLeftEngines; 10 | // MegaMotoLoadHBridgeDriver myRightEngines; 11 | #ifdef UNITTEST 12 | public: 13 | #endif 14 | MotorMegaMotoHBridge myLeftMotor; 15 | MotorMegaMotoHBridge myRightMotor; 16 | 17 | uint16_t myMaxCurrent; //The maximum current to be "normal" 18 | uint16_t myMaxCurrentDuration; //The time we allow the current to be highr than the max current in millies 19 | uint32_t myLoopduration; 20 | 21 | boolean myUseWheelCorrection; 22 | int myCurrentDirectionCorrection; 23 | int8_t myPrefLeftCountPinState; 24 | int8_t myPrefRightCountPinState; 25 | int16_t myLeftCount; 26 | int16_t myRightCount; 27 | uint8_t myLeftCountPin; 28 | uint8_t myRightCountPin; 29 | uint32_t myLastDirectionModification; 30 | 31 | void calculateSpeedAndDirection(); 32 | 33 | public: 34 | 35 | virtual void motorOn(); 36 | virtual void motorOff(); 37 | SkidDriverMegaMoto( ENABLEPINPARAM uint8_t RightPWMAPin, 38 | uint8_t RightPWMBPin, ENABLEPINPARAMLEFT uint8_t LeftPWMAPin, 39 | uint8_t LeftPWMBPin, uint8_t ACurrentPin, uint8_t BCurrentPin); 40 | void serialRegister(const __FlashStringHelper* Name,const __FlashStringHelper*LeftDriverName,const __FlashStringHelper* LeftBrigeAName,const __FlashStringHelper* LeftBrigeBName,const __FlashStringHelper* RightDriverName,const __FlashStringHelper* RightBrigeAName,const __FlashStringHelper* RightBrigeBName); 41 | 42 | virtual void setup(); 43 | virtual void loop(); 44 | 45 | bool emergencyBreak( bool immediatlyReturn = false); 46 | 47 | virtual const __FlashStringHelper * getOverloadedWheelName(); 48 | 49 | virtual void turnOnTheSpot(SPEED_TYPE Speed); 50 | 51 | 52 | virtual SPEED_TYPE getActualSpeed() const{return (myLeftMotor.getActualSpeed()+myRightMotor.getActualSpeed())/2;}; 53 | 54 | }; 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /MotorBLDC/MotorBLDC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BLDC1Motor.h 3 | * This is a class that handles the BLDC motor I bought from topbrand (I do not advice the brand nor the motor !!!) 4 | * The motor needs a pull down resistor (no more then 800 ohms) on the PWM pin (no connection will make the motor spin) 5 | * The direction pin can not handle +5V so it needs a PNP resistor to. 6 | * 7 | * Once these connections are done the motor is controlled by PWM (255= full speed) for speed 8 | * and the direction pin for the direction. 9 | * 10 | * This class changes the PWM slowly based on experiments (I'm not sure it is needed) 11 | * 12 | * engine on and engine off are not powering the motors as should because I did not use a mosfet or simular to switch the motors on/off 13 | * 14 | * Created on: May 9, 2014 15 | * Author: jan 16 | */ 17 | 18 | #ifndef BLDC1_MOTOR_H_ 19 | #define BLDC1_MOTOR_H_ 20 | #include "DataTypes.h" 21 | #include "MotorInterface.h" 22 | 23 | #ifdef I_USE_PLOT 24 | #include "simplot.h" 25 | #endif 26 | 27 | class MotorBLDC: public MotorInterface 28 | { 29 | 30 | private: 31 | SPEED_TYPE myRequestedSpeed; 32 | SPEED_TYPE myActualSpeed; 33 | uint8_t myActualSpinDirection; 34 | uint32_t myLoopduration; 35 | uint8_t myForwardBackwardPin; 36 | uint8_t myPWMPin; 37 | 38 | 39 | public: 40 | #ifdef I_USE_PLOT 41 | void plotdata() 42 | { 43 | plot4(Serial,myRequestedSpeed,myActualSpeed,(myActualSpinDirection*500)-255,(millis() % 1000) / 4); 44 | 45 | } 46 | #endif 47 | void motorOn(){}; 48 | void motorOff(){setRequestedSpeed(0);}; 49 | MotorBLDC( uint8_t forwardBackwardPin, uint8_t PWMPin); 50 | void serialRegister(const __FlashStringHelper* Name); 51 | 52 | void setup(); 53 | void loop(); 54 | void setRequestedSpeed(SPEED_TYPE speed){myRequestedSpeed=speed;}; 55 | 56 | bool emergencyBreak(){emergencyBreak(false);}; 57 | bool emergencyBreak( bool immediatlyReturn = false); 58 | 59 | SPEED_TYPE getRequestedSpeed() const 60 | { return myRequestedSpeed;} 61 | 62 | SPEED_TYPE getActualSpeed() const 63 | { return myActualSpeed;}; 64 | 65 | }; 66 | 67 | 68 | #endif /* BLDC1_MOTOR_H_ */ 69 | -------------------------------------------------------------------------------- /SerialStringReader/Examples/serialCommunicatorStep2/serialCommunicatorStep2.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a example sketch showing the basic functionality of reading line by line from 3 | * Serial (or any other stream) 4 | * 5 | * This example skecth needs 2 libraries SerialStringReader and BlinkLed 6 | * Make sure they are configured and linked to properly 7 | * 8 | * after compiling and uploading send following commands to the arduino 9 | * LED SLOW 10 | * LED FAST 11 | * LED ASYNC 12 | * All the commands should change the blinking of led 13 13 | * 14 | * no rights reserved 15 | */ 16 | #include "SerialStringReader.h" 17 | #include "BlinkLed.h" 18 | 19 | 20 | //for the stream you want to read info from you need to declare a SerialStringReader 21 | //you can only have one 22 | SerialStringReader myCommunicator; 23 | 24 | //Define that the USB serial (pin 0 and 1 on the uno) is to be used by the mySerialReader 25 | //If you want to use the yun with the bridge use Serial1 26 | #define THESERIAL Serial 27 | Stream &SerialInput = THESERIAL; 28 | Stream &SerialOutput = THESERIAL; 29 | 30 | BlinkLed led13(13,500,2000); 31 | 32 | 33 | //The setup function is called once at startup of the sketch 34 | void setup() 35 | { 36 | delay(2000); 37 | THESERIAL.begin(115200); 38 | SerialOutput.println("serialStringReaderDemo2"); 39 | led13.setup(); 40 | myCommunicator.setup(); 41 | } 42 | 43 | // The loop function is called in an endless loop 44 | void loop() 45 | { 46 | myCommunicator.loop(); 47 | led13.loop(); 48 | if (myCommunicator.messageReceived()) 49 | { 50 | SerialOutput.println("You have send a message to Arduino."); 51 | SerialOutput.println("And the message is:"); 52 | char * message=myCommunicator.getMessage(); 53 | SerialOutput.println(message); 54 | if (strcasecmp(message,"LED SLOW")==0) 55 | { 56 | led13.setOnInterval(5000); 57 | led13.setOffInterval(5000); 58 | SerialOutput.println("changed to slow"); 59 | } 60 | if (strcasecmp(message,"LED FAST")==0) 61 | { 62 | led13.setOnInterval(100); 63 | led13.setOffInterval(100); 64 | SerialOutput.println("changed to fast"); 65 | } 66 | if (strcasecmp(message,"LED ASYNC")==0) 67 | { 68 | led13.setOnInterval(1000); 69 | led13.setOffInterval(200); 70 | SerialOutput.println("changed to async"); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /SerialCommunicator/examples/AnalogTest/Analog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Analog.cpp 3 | * 4 | * Created on: Nov 2, 2014 5 | * Author: jan 6 | */ 7 | 8 | #include "Analog.h" 9 | 10 | Analog::Analog() 11 | { 12 | my_Pin_A0_value=0; 13 | my_Pin_A1_value=0; 14 | my_Pin_A2_value=0; 15 | my_Pin_A3_value=0; 16 | my_Pin_A4_value=0; 17 | my_Pin_A5_value=0; 18 | my_Pin_A6_value=0; 19 | my_Pin_A7_value=0; 20 | my_Pin_A8_value=0; 21 | my_Pin_A9_value=0; 22 | my_Pin_A10_value=0; 23 | my_Pin_A11_value=0; 24 | my_Pin_A12_value=0; 25 | my_Pin_A13_value=0; 26 | my_Pin_A14_value=0; 27 | my_Pin_A15_value=0; 28 | 29 | } 30 | 31 | void Analog::serialRegister(const __FlashStringHelper* Name) 32 | { 33 | FieldData::set(Name, F("A0"), 0, &my_Pin_A0_value); 34 | FieldData::set(Name, F("A1"), 0, &my_Pin_A1_value); 35 | FieldData::set(Name, F("A2"), 0, &my_Pin_A2_value); 36 | FieldData::set(Name, F("A3"), 0, &my_Pin_A3_value); 37 | FieldData::set(Name, F("A4"), 0, &my_Pin_A4_value); 38 | FieldData::set(Name, F("A5"), 0, &my_Pin_A5_value); 39 | FieldData::set(Name, F("A6"), 0, &my_Pin_A6_value); 40 | FieldData::set(Name, F("A7"), 0, &my_Pin_A7_value); 41 | FieldData::set(Name, F("A8"), 0, &my_Pin_A8_value); 42 | FieldData::set(Name, F("A9"), 0, &my_Pin_A9_value); 43 | FieldData::set(Name, F("A10"), 0, &my_Pin_A10_value); 44 | FieldData::set(Name, F("A11"), 0, &my_Pin_A11_value); 45 | FieldData::set(Name, F("A12"), 0, &my_Pin_A12_value); 46 | FieldData::set(Name, F("A13"), 0, &my_Pin_A13_value); 47 | FieldData::set(Name, F("A14"), 0, &my_Pin_A14_value); 48 | FieldData::set(Name, F("A15"), 0, &my_Pin_A15_value); 49 | } 50 | 51 | void Analog::loop() 52 | { 53 | my_Pin_A0_value=analogRead(A0); 54 | my_Pin_A1_value=analogRead(A1); 55 | my_Pin_A2_value=analogRead(A2); 56 | my_Pin_A3_value=analogRead(A3); 57 | my_Pin_A4_value=analogRead(A4); 58 | my_Pin_A5_value=analogRead(A5); 59 | my_Pin_A6_value=analogRead(A6); 60 | my_Pin_A7_value=analogRead(A7); 61 | my_Pin_A8_value=analogRead(A8); 62 | my_Pin_A9_value=analogRead(A9); 63 | my_Pin_A10_value=analogRead(A10); 64 | my_Pin_A11_value=analogRead(A11); 65 | my_Pin_A12_value=analogRead(A12); 66 | my_Pin_A13_value=analogRead(A13); 67 | my_Pin_A14_value=analogRead(A14); 68 | my_Pin_A15_value=analogRead(A15); 69 | 70 | } 71 | 72 | void Analog::setup() 73 | { 74 | } 75 | -------------------------------------------------------------------------------- /TempMeterDS18B20/TempMeterDS18B20.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TempMeterDS18B20.h 3 | * 4 | * Implementation of the temperature interface with a DS18B20 5 | * This class assumes that there is only 1 sensor on the one wire 6 | * This is acceptable to me because I want to identify the sensor based on the pin 7 | * not on the ID of the sensor 8 | * 9 | * Created on: Jul 13, 2023 10 | * Author: jan 11 | */ 12 | 13 | #include "Arduino.h" 14 | #include "TempMeterInterface.h" 15 | #include "DallasTemperature.h" 16 | #include "OneWire.h" 17 | #ifdef I_USE_SERIAL_REGISTER 18 | #include "SerialDataInterface.h" 19 | #endif 20 | extern uint32_t loopMillis; 21 | 22 | class TempMeterDS18B20: public TempMeterInterface { 23 | 24 | private: 25 | 26 | uint16_t myReadResponseTime = calculateReadResponseTime(10); 27 | int8_t myIndex=-1; //using negative value to know index is not used 28 | int8_t myResolution=10; //The bit resolution used by the sensor (9->12) 29 | boolean myIgnore = false; 30 | boolean myValueRequested = true; 31 | DeviceAddress mySensorAddress; 32 | 33 | uint32_t myLastAction = 0; 34 | public: 35 | //I have made the DallasTemperature public so the programmer can have access to its functionality 36 | DallasTemperature mySensors; 37 | 38 | public: 39 | 40 | TempMeterDS18B20(OneWire &wire, DeviceAddress sensorAddress); 41 | TempMeterDS18B20(OneWire &wire, int sensorIndex); 42 | virtual ~TempMeterDS18B20() = default; 43 | void setResolution(int8_t newResolution){ 44 | if (newResolution>8 && newResolution<13 ){ 45 | myResolution=newResolution; 46 | myReadResponseTime=calculateReadResponseTime(myResolution); 47 | } 48 | } 49 | 50 | void setup(); 51 | void loop(); 52 | //For the calculation below I use resolution 10 and the formula provided 53 | //by robtillaart (thanks robtillaart) 54 | //https://forum.arduino.cc/t/dallas-temperature-libary-non-blocking-question/153430/2 55 | static uint16_t calculateReadResponseTime(uint8_t bitResolution){ 56 | uint16_t correctResolution=10; 57 | if (bitResolution>8 && bitResolution<13 ){ 58 | correctResolution=bitResolution; 59 | } 60 | return 750 / (1 << (12 - correctResolution)); 61 | } 62 | #ifdef I_USE_SERIAL_REGISTER 63 | void serialRegister(const __FlashStringHelper* Name); 64 | #endif 65 | }; 66 | 67 | #pragma once 68 | -------------------------------------------------------------------------------- /RCLib/Examples/Maga6ChanelsA8_A13/Maga6ChanelsA8_A13.ino: -------------------------------------------------------------------------------- 1 | /**This is an example of using the RCLib with a mega and pinchangeint 2 | * This example isprovided as is by Jantje 3 | * Congratualtions, constructive feedback and I like it can be send to eclipse@baeyens.it 4 | **/ 5 | 6 | #define NUM_RC_CHANNELS 6 //You need to specify how many pins you want to use 7 | #include "PinChangeInt.h" //If you need pinchangeint you need to include this header 8 | const uint8_t RC_Channel_Pin[NUM_RC_CHANNELS]={ 9 | A8,A9,A10,A11,A12,A13};//Here I specify I want to listen to pins A8 to A13 of my mega 10 | 11 | uint16_t RC_Channel_Value[NUM_RC_CHANNELS]; //This variable will contain the values read from the RC signal 12 | #include "RCLib.h" //This include needs all declarations above. Do not try to move it up or it won't compile 13 | 14 | /** plot is a general function I use to output data sets 15 | **/ 16 | void plot(int Data1, int Data2, int Data3, int Data4=0, int Data5=0, int Data6=0, int Data7=0, int Data8=0) 17 | { 18 | Serial.print(Data1); 19 | Serial.print(" "); 20 | Serial.print(Data2); 21 | Serial.print(" "); 22 | Serial.print(Data3); 23 | Serial.print(" "); 24 | Serial.print(Data4); 25 | Serial.print(" "); 26 | Serial.print(Data5); 27 | Serial.print(" "); 28 | Serial.print(Data6); 29 | Serial.print(" "); 30 | Serial.print(Data7); 31 | Serial.print(" "); 32 | Serial.println(Data8); 33 | } 34 | 35 | 36 | 37 | 38 | //The setup function is called once at startup of the sketch 39 | void setup() 40 | { 41 | Serial.begin(57600); 42 | Serial.println(F("Rc serial oscilloscope demo")); 43 | SetRCInterrupts(); //This method will do all the config foe you. 44 | //Note some problems will be reported on the serial monitor 45 | Serial.println(F("Interrupts Set; starting ")); 46 | } 47 | 48 | // The loop function is called in an endless loop 49 | void loop() 50 | { 51 | //Add your repeated code here 52 | int flag; 53 | if(flag=getChannelsReceiveInfo()) //Here you read the RC flag contains all the channels that have a response 54 | // see duane's excellent articles on how this works 55 | { 56 | plot(RC_Channel_Value[0],RC_Channel_Value[1],RC_Channel_Value[2],RC_Channel_Value[3],RC_Channel_Value[4],RC_Channel_Value[5]); 57 | } 58 | delay(50); //don't flood your serial monitor 59 | 60 | } 61 | 62 | -------------------------------------------------------------------------------- /CurrentSensorAnalog/CurrentSensorAnalog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * AmpMeter.cpp 3 | * 4 | * Created on: Jul 5, 2014 5 | * Author: jan 6 | */ 7 | 8 | #include 9 | 10 | CurrentSensorAnalog::CurrentSensorAnalog(uint8_t analogPin) 11 | { 12 | myAnalogPin = analogPin; 13 | myMultiplyerValue = 0; 14 | myCurrentPinValue = 0; 15 | myOffset = 505; 16 | } 17 | 18 | CurrentSensorAnalog::CurrentSensorAnalog(uint8_t analogPin, int16_t MultiplyerValue, int16_t Offset) 19 | { 20 | myAnalogPin = analogPin; 21 | myMultiplyerValue = MultiplyerValue; 22 | myCurrentPinValue = 0; 23 | myOffset = Offset; 24 | } 25 | 26 | void CurrentSensorAnalog::loop(void) 27 | { 28 | #ifndef USE_MAIN_LOOP_MILLIS 29 | uint32_t loopMillis = millis(); 30 | #endif 31 | uint32_t myLastRead = millis(); 32 | if (myAnalogPin != 255) 33 | { 34 | if ((loopMillis - myLastRead) > 50) 35 | { 36 | myLastRead=loopMillis; 37 | myCurrentPinValue = (analogRead(myAnalogPin) / 5) * 5; 38 | myMedianPinValue.addValue(myCurrentPinValue); 39 | int32_t tmpCurrentPinValue = myCurrentPinValue; 40 | int32_t tmpOffset = myOffset; 41 | int32_t tmpMultiplyerValue = myMultiplyerValue; 42 | int32_t tmpDevisor = 1000; 43 | int32_t tmpCentiAmp = myCentiAmp; 44 | tmpCentiAmp = abs(((tmpCurrentPinValue - tmpOffset) * tmpMultiplyerValue) / tmpDevisor); 45 | myCentiAmp = abs(tmpCentiAmp); 46 | tmpCurrentPinValue = myMedianPinValue.getMedian(); 47 | tmpCentiAmp = abs(((tmpCurrentPinValue - tmpOffset) * tmpMultiplyerValue) / tmpDevisor); 48 | myAvgCentiAmp = tmpCentiAmp; 49 | } 50 | } 51 | } 52 | 53 | void CurrentSensorAnalog::serialRegister(const __FlashStringHelper* Name) 54 | { 55 | FieldData::set(Name, F("Current_cA"), MOD_NONE, &myCentiAmp); 56 | #ifdef DETAILED_SERIAL_LOGGING 57 | FieldData::set(Name, F("Avg_cA"),MOD_NONE,&myAvgCentiAmp); 58 | FieldData::setNext( F("PinValue"),MOD_NONE,&myCurrentPinValue); 59 | #endif 60 | FieldData::setNext(F("MultiplyerValue_1000"), MOD_WRITE | MOD_SAVE, &myMultiplyerValue); 61 | FieldData::setNext(F("PinValue_Offset"), MOD_NONE, &myOffset); 62 | #ifdef DETAILED_SERIAL_LOGGING 63 | FieldData::setNext( F("Pin"),MOD_NONE,&myAnalogPin); 64 | #endif 65 | } 66 | 67 | void CurrentSensorAnalog::setZeroAmp() 68 | { 69 | // myOffset = myMedianPinValue.getMedian(); 70 | } 71 | -------------------------------------------------------------------------------- /SerialStringReader/SerialStringReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SmartSerial.h 3 | * 4 | * Created on: Nov 28, 2012 5 | * Author: jan baeyens aka Jantje 6 | */ 7 | 8 | #pragma once 9 | #include "Arduino.h" 10 | 11 | /* modify the line below if you want less memory used by the lib 12 | * and increase if you need a longer command line. 13 | */ 14 | #define MAX_MESSAGE_LENGTH (uint8_t)80 15 | /** 16 | * A class to read strings from the serial communication. 17 | * This class reads line by line. 18 | * If a message is read (meaning a end of line is read) no more characters 19 | * are read until the message has been received (by calling get message) 20 | * The string returned is the actual memory buffer used to read the serial monitor. 21 | * if you want to save the value you should make a copy. 22 | * 23 | * look at the example on how to use this 24 | */ 25 | 26 | extern Stream &SerialError; 27 | 28 | class SerialStringReader 29 | { 30 | private: 31 | char myMessage[MAX_MESSAGE_LENGTH + 1]; //The message (or part of) that has been received 32 | uint8_t myMessageIndex=0; //The length of the message (next character to write) 33 | boolean myHasMessage=false; //Is the message complete? 34 | 35 | public: 36 | Stream &myStream; 37 | SerialStringReader(Stream &theStream); 38 | /** 39 | * Initializes the class. It does not initialize the serial communication 40 | * This is something you will have to do before calling this method 41 | * Call this method in your setup() after setting up the serial monitor 42 | */ 43 | void setup() 44 | { 45 | } 46 | ; 47 | /** 48 | * Add the Loop() in your loop(); 49 | */ 50 | void loop(); 51 | /** 52 | * empty all data in the serial queue and buffer. 53 | */ 54 | void flush(); 55 | /** 56 | * Call this method to know whether a full message has arrived. 57 | */ 58 | boolean messageReceived() 59 | { 60 | return myHasMessage; 61 | } 62 | ; 63 | /** 64 | * GetMessage should only be called when MessageReceived returned true. 65 | * It resets the MessageReceived flag. 66 | * WARNING The value returned points to the same buffer as used by the class. 67 | * If you want to keep the value for later reference you need to make a copy. 68 | */ 69 | char* getMessage() 70 | { 71 | myHasMessage = false; 72 | return myMessage; 73 | } 74 | ; 75 | }; 76 | 77 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/ParseArduinoInput.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ./SetGlobalSettings.sh 4 | 5 | InDump=0 6 | NUM=0 7 | EVENT_SEPARATOR=; 8 | let LOGINDEX=0 9 | PAGENUM=0 10 | SPACE=" " 11 | let DUMPLINE=0 12 | 13 | MoveLogFile() 14 | { 15 | let NUM=0 16 | thetime=`date +%Y_%m_%d_%H_%M` 17 | dumpFile=${LogFilePrefix}${thetime}${LogFileSuffix} 18 | while [ -f ${dumpFile} ] 19 | do 20 | let NUM+=1 21 | dumpFile=${LogFilePrefix}${thetime}${NUM}${LogFileSuffix} 22 | done 23 | echo End Of Log>>${logFile} 24 | mv ${logFile} ${dumpFile} 25 | if [ ! -f ${LogHeaderFile} ]; 26 | then 27 | #The header file is missing so ask the header from arduino 28 | echo P>> ${PortName} 29 | echo LOG HEADER>> ${PortName} 30 | else 31 | cp ${LogHeaderFile} ${logFile} 32 | fi 33 | } 34 | 35 | 36 | MoveLogFile 37 | while true 38 | do 39 | while read line 40 | do 41 | let DUMPLINE+=1 42 | echo "${line}" >> $logFile 43 | 44 | if [ "$InDump" -eq 1 ]; then 45 | echo $line >> $DumpFile 46 | # if [ "$line" = "Dump done" ]; then 47 | # ${MakeWepPage} <$DumpFile > $OutputHtml 48 | # chmod 755 $OutputHtml 49 | # InDump=0 50 | # fi 51 | #OK it is 2 times the same thing but I changed the string wanted backwards compatibility 52 | #and didn't know how to do the if 53 | if [ "$line" = "done" ]; then 54 | ${MakeWepPage} <$DumpFile > $OutputHtml & 55 | chmod 755 $OutputHtml 56 | InDump=0 57 | fi 58 | 59 | else 60 | if [ $DUMPLINE -gt 10000 ]; then 61 | let DUMPLINE=0 62 | MoveLogFile 63 | fi 64 | if [ "$line" = "Dumping all fields" ]; then 65 | InDump=1 66 | echo "" > $DumpFile 67 | else 68 | FIRST=`echo $line | cut -d';' -f1 |cut -d':' -f1` 69 | if [ "$FIRST" = "LOG VALUE" ]; then 70 | echo "$line" > $OutputValue 71 | chmod 755 $OutputValue 72 | elif [ "$FIRST" = "LOG HEADER" ]; then 73 | echo "$line" > $LogHeaderFile 74 | elif [ "$FIRST" = "EXEC" ]; then 75 | #wait for this command to return. If the command is asynchronous the command must start the async action itself 76 | COMMAND=`echo $line | cut -d':' -f2` 77 | ${WebLocationDynamic}/${COMMAND} >> ${PortName} & 78 | fi 79 | fi 80 | fi 81 | done 82 | sleep 1 83 | done 84 | -------------------------------------------------------------------------------- /I2CLiquidCrystal/I2CLiquidCrystal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C_LiquidCrystal.h 3 | * 4 | * Created on: Dec 21, 2013 5 | * Author: jan 6 | */ 7 | 8 | #ifndef I2C_LIQUIDCRYSTAL_H_ 9 | #define I2C_LIQUIDCRYSTAL_H_ 10 | #include "Arduino.h" 11 | #include "Wire.h" 12 | 13 | class LiquidCrystal 14 | { 15 | private: 16 | static uint8_t myAddress; 17 | public: 18 | LiquidCrystal(uint8_t address) { myAddress=address;}; 19 | static void begin() { Wire.begin(myAddress); clear(); }; 20 | static void init(){}; 21 | 22 | static void clear(); 23 | static void home(); 24 | 25 | static void noDisplay(); 26 | static void display(); 27 | static void noBlink(); 28 | static void blink(); 29 | static void noCursor(); 30 | static void cursor(); 31 | static void scrollDisplayLeft(); 32 | static void scrollDisplayRight(); 33 | static void leftToRight(); 34 | static void rightToLeft(); 35 | static void autoscroll(); 36 | static void noAutoscroll(); 37 | 38 | static void createChar(uint8_t, uint8_t[]); 39 | static void setCursor(uint8_t col, uint8_t row); 40 | static void command(uint8_t); 41 | 42 | static size_t print(const __FlashStringHelper * info) ; 43 | static size_t print(const String &info) ; 44 | static size_t print(const char info[]); 45 | static size_t print(char info); 46 | static size_t print(unsigned char info1, int info2 = DEC); 47 | static size_t print(int info1, int info2= DEC); 48 | static size_t print(unsigned int info1, int info2= DEC); 49 | static size_t print(long info1, int info2= DEC); 50 | static size_t print(unsigned long info1, int info2= DEC); 51 | static size_t print(double info1, int info2= 2); 52 | static size_t print(const Printable& info); 53 | 54 | // size_t println(const __FlashStringHelper *info); 55 | // size_t println(const String &info); 56 | // size_t println(const char info[] ); 57 | // size_t println(char info); 58 | // size_t println(unsigned char info1, int info2= DEC); 59 | // size_t println(int info1, int info2= DEC); 60 | // size_t println(unsigned int info1, int info2= DEC); 61 | // size_t println(long info1, int info2= DEC); 62 | // size_t println(unsigned long info1, int info2= DEC); 63 | // size_t println(double info1, int info2= 2); 64 | // size_t println(const Printable& info); 65 | // size_t println(void); 66 | 67 | static void setBackground(uint8_t red,uint8_t green, uint8_t blue); 68 | 69 | }; 70 | 71 | #endif /* I2C_LIQUIDCRYSTAL_H_ */ 72 | -------------------------------------------------------------------------------- /MotorMegaMoto/Examples/megamotoHridgeDriver/megamotoHbridgeDiver.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "MotorMegaMoto.h" 4 | 5 | const char mySketchName[] = "MegaMoto tester"; 6 | Stream &SerialInput=Serial; 7 | Stream &SerialOutput=Serial; 8 | Stream &SerialError=Serial; 9 | 10 | #define ENGINE_ENABLE_PIN 8 11 | 12 | #define PWMA_PIN 6 13 | #define PWMB_PIN 5 14 | #define CURRENT_SENSOR_PIN A4 15 | 16 | //DriveEngine MyDriveEngine(RIGHT_ENGINE_ENABLE_PIN, RIGHT_ENGINE_PWMA_PIN, RIGHT_ENGINE_PWMB_PIN, LEFT_ENGINE_ENABLE_PIN, LEFT_ENGINE_PWMA_PIN, LEFT_ENGINE_PWMB_PIN); 17 | 18 | //Mower MyMower(MOWER_ENABLE_PIN, LEFT_MOW_ENGINE_PIN, RIGHT_MOW_ENGINE_PIN); 19 | 20 | MotorMegaMoto MyEngine( ENGINE_ENABLE_PIN, PWMA_PIN, PWMB_PIN, CURRENT_SENSOR_PIN, 255); 21 | 22 | #define OutputFile Serial 23 | 24 | 25 | 26 | 27 | void setup() 28 | { 29 | analogReference(DEFAULT); 30 | //delay(2000); 31 | Serial.begin(115200); 32 | Serial.println( "MegaMoto tester Starting Up"); 33 | MyEngine.motorOn(); 34 | 35 | } 36 | 37 | void loop() 38 | { 39 | static int CurMowSpeed = 0; 40 | MyEngine.loop(); 41 | 42 | if (Serial.available()) //data received see what we need to do 43 | { 44 | char incomingByte = Serial.read(); // read the incoming byte: 45 | switch (toupper(incomingByte)) 46 | { 47 | 48 | case 'Z': 49 | Serial.println( "Received Z Full ahead"); 50 | MyEngine.setRequestedSpeed(255); 51 | break; 52 | case 'X': 53 | Serial.println( "Received X full backwards"); 54 | MyEngine.setRequestedSpeed(-255); 55 | break; 56 | case 'U': 57 | Serial.println( "Received speed Up"); 58 | MyEngine.setRequestedSpeed(constrain( MyEngine.getRequestedSpeed()+1,-255,255)); 59 | break; 60 | 61 | case 'D': 62 | Serial.println( "Received speed Down"); 63 | MyEngine.setRequestedSpeed(constrain( MyEngine.getRequestedSpeed()-1,-255,255)); 64 | break; 65 | case 'S': 66 | Serial.println( "Received S stopping"); 67 | MyEngine.setRequestedSpeed(0); 68 | break; 69 | default: 70 | Serial.print( "Arduino received: '"); 71 | Serial.print( incomingByte); 72 | Serial.println("'. This is not supported. Send "); 73 | Serial.println( "Z/z to go Full ahead "); 74 | Serial.println( "X/x to go Full backwards "); 75 | Serial.println( "U/u speed up"); 76 | Serial.println( "D/d speed Down"); 77 | Serial.println( "S/s to stop "); 78 | 79 | break; 80 | } 81 | 82 | } 83 | 84 | 85 | } 86 | -------------------------------------------------------------------------------- /SerialDataInterface/FieldInfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * FieldInfo.cpp 3 | * 4 | * Created on: Feb 8, 2014 5 | * Author: jan 6 | */ 7 | 8 | #include "FieldInfo.h" 9 | /** 10 | * this buffer can be used to not have to allocate buffers at multiple locations 11 | */ 12 | char commonlyUsedBuffer[commonlyUsedBuffersize]; 13 | 14 | const FieldInfo& FieldInfo::operator =(const FieldInfo &fieldInfo) 15 | { 16 | myClassName = fieldInfo.myClassName; 17 | myFieldName = fieldInfo.myFieldName; 18 | myType = fieldInfo.myType; 19 | myModFlag = fieldInfo.myModFlag; 20 | return fieldInfo; 21 | } 22 | 23 | bool FieldInfo::operator ==(const FieldInfo &fieldInfo) const 24 | { 25 | return ((strcmp_P((const char*) fieldInfo.myClassName, (const char*) myClassName) == 0) 26 | && (strcmp_P((const char*) fieldInfo.myFieldName, (const char *) myFieldName) == 0) && (fieldInfo.myType == myType) 27 | && (fieldInfo.myModFlag == myModFlag)); 28 | 29 | } 30 | 31 | /** 32 | * This method dumps the content of the FieldInfoobject to the stream provided 33 | */ 34 | void FieldInfo::dump(Stream &serial) const 35 | { 36 | serial.print(F("name\t")); 37 | serial.print(myClassName); 38 | serial.print('.'); 39 | serial.println(myFieldName); 40 | serial.print(F("mod\t")); 41 | serial.println(myModFlag); 42 | serial.print(F("Type\t")); 43 | switch (myType) 44 | { 45 | case _uint8_t: 46 | case _uint16_t: 47 | case _uint32_t: 48 | serial.print('u'); 49 | break; 50 | default: 51 | break; 52 | } 53 | switch (myType) 54 | { 55 | case _bool: 56 | serial.println(F("bool")); 57 | break; 58 | case _uint8_t: 59 | case _int8_t: 60 | serial.println(F("int8")); 61 | break; 62 | case _uint16_t: 63 | case _int16_t: 64 | serial.println(F("int16")); 65 | break; 66 | case _uint32_t: 67 | case _int32_t: 68 | serial.println(F("int32")); 69 | break; 70 | case _ppchar: 71 | serial.println(F("char*")); 72 | break; 73 | 74 | #ifdef I_USE_GPS 75 | case _GPSLocation: 76 | serial.println(F("GPS")); 77 | break; 78 | #endif 79 | #ifdef I_USE_STRING 80 | case _String: 81 | serial.println(F("String")); 82 | break; 83 | #endif 84 | #ifdef I_USE_DATETIME 85 | case _DateTime: 86 | serial.println(F("DateTime")); 87 | break; 88 | #endif 89 | case _FlashStringHelper: 90 | serial.println('F'); 91 | break; 92 | 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /MotorMegaMotoHBridge/MotorMegaMotoHBridge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MegaMotoHBridgeDriver.h 3 | * 4 | * Created on: May 19, 2012 5 | * Author: BE04258 6 | */ 7 | 8 | #ifndef MEGAMOTOHBRIDGEDRIVER_H_ 9 | #define MEGAMOTOHBRIDGEDRIVER_H_ 10 | #include "MotorMegaMoto.h" 11 | 12 | class MotorMegaMotoHBridge: public MotorInterface 13 | { 14 | protected: 15 | MotorMegaMoto myMegaMotoDriver; 16 | int16_t myCurrentRequestedSpeed; 17 | uint32_t myLoopDuration; 18 | 19 | /* 20 | * changeSpeed changes the speed of the HBridge driven engine. 21 | * The speed is changes in small steps. 22 | * If the force flag is used the speed if forced immediately to the engine if the new speed is in the same 23 | * direction as the current speed direction 24 | * If the force flag is true and the speed direction is different from the current speed direction the 25 | * engine is forced to stop (PWM 0 on both halves) and will go to the speed requested in small steps 26 | * 27 | */ 28 | void changeSpeed(int16_t Speed); 29 | 30 | public: 31 | MotorMegaMotoHBridge( ENABLEPINPARAM uint8_t PWMAPin, uint8_t PWMBPin,uint8_t CurrentPinA,uint8_t CurrentPinB ); 32 | void serialRegister(const __FlashStringHelper* DriverName,const __FlashStringHelper* BrigeAName,const __FlashStringHelper* BrigeBName); 33 | 34 | virtual void loop(); 35 | virtual bool emergencyBreak() 36 | { myCurrentRequestedSpeed=0; return myMegaMotoDriver.emergencyBreak();}; 37 | //uint16_t GetCurrentUsage() const {return MyMegaMotoDriver.GetACurrentUsage()+MyMegaMotoDriver.GetBCurrentUsage();}; 38 | uint16_t getCurrentUsage() const 39 | { return (myMegaMotoDriver.myHalfBridgeA.getCurrentUsage_cA()+myMegaMotoDriver.myHalfBridgeB.getCurrentUsage_cA());}; 40 | uint16_t getCurrentUsageA() const 41 | { return myMegaMotoDriver.myHalfBridgeA.getCurrentUsage_cA();}; 42 | uint16_t getCurrentUsageB() const 43 | { return myMegaMotoDriver.myHalfBridgeB.getCurrentUsage_cA();}; 44 | uint16_t getPowerConsumptionA(uint8_t suppliedVoltage) const 45 | { return myMegaMotoDriver.getPowerConsumptionA(suppliedVoltage);}; 46 | uint16_t getPowerConsumptionB(uint8_t suppliedVoltage) const 47 | { return myMegaMotoDriver.getPowerConsumptionB(suppliedVoltage);}; 48 | 49 | virtual void motorOn() 50 | { myMegaMotoDriver.motorOn();}; 51 | virtual void motorOff() 52 | { myMegaMotoDriver.motorOff();}; 53 | virtual void setup() 54 | { myMegaMotoDriver.setup();}; 55 | }; 56 | 57 | #endif /* MEGAMOTOHBRIDGEDRIVER_H_ */ 58 | -------------------------------------------------------------------------------- /gtest/gtest/gtest_prod.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Google C++ Testing Framework definitions useful in production code. 33 | 34 | #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 35 | #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 36 | 37 | // When you need to test the private or protected members of a class, 38 | // use the FRIEND_TEST macro to declare your tests as friends of the 39 | // class. For example: 40 | // 41 | // class MyClass { 42 | // private: 43 | // void MyMethod(); 44 | // FRIEND_TEST(MyClassTest, MyMethod); 45 | // }; 46 | // 47 | // class MyClassTest : public testing::Test { 48 | // // ... 49 | // }; 50 | // 51 | // TEST_F(MyClassTest, MyMethod) { 52 | // // Can call MyClass::MyMethod() here. 53 | // } 54 | 55 | #define FRIEND_TEST(test_case_name, test_name)\ 56 | friend class test_case_name##_##test_name##_Test 57 | 58 | #endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 59 | -------------------------------------------------------------------------------- /MotorMegaMoto/MotorMegaMoto.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MegaMotoDriver.cpp 3 | * 4 | * Created on: 30-sep.-2011 5 | * Author: be4258 6 | */ 7 | 8 | #include "MotorMegaMoto.h" 9 | 10 | void MotorMegaMoto::motorOn() 11 | { 12 | #ifdef SHARED_ENABLEPIN 13 | #else 14 | digitalWrite(ENABLEPINNAME, HIGH); 15 | #endif 16 | } 17 | void MotorMegaMoto::motorOff() 18 | { 19 | #ifdef SHARED_ENABLEPIN 20 | myHalfBridgeA.setRequestedSpeed(0); 21 | myHalfBridgeB.setRequestedSpeed(0); 22 | #else 23 | digitalWrite(ENABLEPINNAME, LOW); 24 | myHalfBridgeA.setRequestedSpeed(0); 25 | myHalfBridgeB.setRequestedSpeed(0); 26 | #endif 27 | } 28 | 29 | MotorMegaMoto::MotorMegaMoto( ENABLEPINPARAM uint8_t PWMAPin, uint8_t PWMBPin, uint8_t ACurrentPin, uint8_t BCurrentPin) 30 | : myHalfBridgeA( PWMAPin, ACurrentPin), myHalfBridgeB( PWMBPin, BCurrentPin) 31 | { 32 | #ifndef SHARED_ENABLEPIN 33 | this->ENABLEPINNAME = ENABLEPINNAME; 34 | pinMode(ENABLEPINNAME, OUTPUT); 35 | #endif 36 | //mySuppliedVoltage = suppliedVoltage; 37 | // myLoopDuration = 0; 38 | //myMotorVoltage = MotorVoltage; 39 | myRequestedSpeedA = 0; 40 | myRequestedSpeedB = 0; 41 | } 42 | 43 | void MotorMegaMoto::serialRegister(const __FlashStringHelper* Name,const __FlashStringHelper* BrigeAName,const __FlashStringHelper* BrigeBName) 44 | { 45 | #ifdef DETAILED_SERIAL_LOGGING 46 | // FieldData::set(Name, F("MotorVoltage"),0,&myMotorVoltage); 47 | // FieldData::set(Name, F("SuppliedVoltage"),0,&mySuppliedVoltage); 48 | FieldData::set(Name, F("RequestedSpeedA"),0,&myRequestedSpeedA); 49 | FieldData::set(Name, F("RequestedSpeedB"),0,&myRequestedSpeedB); 50 | //FieldData::set(Name, F("LoopDuration"),0,&myLoopDuration); 51 | #endif 52 | myHalfBridgeA.serialRegister(BrigeAName); 53 | myHalfBridgeB.serialRegister(BrigeBName); 54 | } 55 | 56 | void MotorMegaMoto::loop() 57 | { 58 | // unsigned long loopStart = millis(); 59 | myHalfBridgeA.loop(); 60 | myHalfBridgeB.loop(); 61 | 62 | // myLoopDuration = millis() - loopStart; 63 | } 64 | 65 | /** 66 | * This method stops the engine directly only when immediatlyReturn is not true 67 | * If immediatlyReturn is true this method should be called in a tight loop without delay. 68 | * This is needed when more than one engine needs to be stopped immediately 69 | * The method returns true when the engine is stalled 70 | */ 71 | bool MotorMegaMoto::emergencyBreak() 72 | { 73 | myRequestedSpeedA = 0; 74 | myRequestedSpeedB = 0; 75 | return (myHalfBridgeA.emergencyBreak() && myHalfBridgeB.emergencyBreak()); 76 | } 77 | 78 | -------------------------------------------------------------------------------- /Sabertooth/examples/1.Basics/Jolty/Jolty.ino: -------------------------------------------------------------------------------- 1 | // Jolty Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | 7 | Sabertooth ST(128); // The Sabertooth is on address 128. We'll name its object ST. 8 | // If you've set up your Sabertooth on a different address, of course change 9 | // that here. For how to configure address, etc. see the DIP Switch Wizard for 10 | // Sabertooth - http://www.dimensionengineering.com/datasheets/SabertoothDIPWizard/start.htm 11 | // SyRen - http://www.dimensionengineering.com/datasheets/SyrenDIPWizard/start.htm 12 | // Be sure to select Packetized Serial Mode for use with this library. 13 | // 14 | // On that note, you can use this library for SyRen just as easily. 15 | // The diff-drive commands (drive, turn) do not work on a SyRen, of course, but it will respond correctly 16 | // if you command motor 1 to do something (ST.motor(1, ...)), just like a Sabertooth. 17 | // 18 | // In this sample, hardware serial TX connects to S1. 19 | // See the SoftwareSerial example in 3.Advanced for how to use other pins. 20 | 21 | void setup() 22 | { 23 | SabertoothTXPinSerial.begin(9600); // 9600 is the default baud rate for Sabertooth packet serial. 24 | ST.autobaud(); // Send the autobaud command to the Sabertooth controller(s). 25 | // NOTE: *Not all* Sabertooth controllers need this command. 26 | // It doesn't hurt anything, but V2 controllers use an 27 | // EEPROM setting (changeable with the function setBaudRate) to set 28 | // the baud rate instead of detecting with autobaud. 29 | // 30 | // If you have a 2x12, 2x25 V2, 2x60 or SyRen 50, you can remove 31 | // the autobaud line and save yourself two seconds of startup delay. 32 | } 33 | 34 | 35 | void loop() 36 | { 37 | ST.motor(1, 127); // Go forward at full power. 38 | delay(2000); // Wait 2 seconds. 39 | ST.motor(1, 0); // Stop. 40 | delay(2000); // Wait 2 seconds. 41 | ST.motor(1, -127); // Reverse at full power. 42 | delay(2000); // Wait 2 seconds. 43 | ST.motor(1, 0); // Stop. 44 | delay(2000); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /MotorPWM/MotorPWM.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /** 3 | * This library controls a motor based on PWM signal. 4 | * This can be a continuous rotation servo or a brushless motor run by a motor driver controlled by PWM 5 | */ 6 | 7 | #include "Arduino.h" 8 | #include "DataTypes.h" 9 | #include "SerialDataInterface.h" 10 | #include "IMotor.h" 11 | #ifdef I_USE_PLOT 12 | #include "simplot.h" 13 | #endif 14 | 15 | /** 16 | * Use this class to control a motor that only needs PWM as input for speed. 17 | */ 18 | class MotorPWM: public IMotor 19 | { 20 | private: 21 | uint8_t myPWMPin; //The pin the motor driver is attached to. 22 | uint8_t myStopSpeed; //The speed at which the motor is standing still. 23 | // for a continuous rotation servo that should be around 180 24 | // for a one directional motor this is 0 25 | uint8_t myDirectionPin; //the pin for reversed direction. Use 255 when you do not have a direction pin 26 | uint8_t myDirectionPinValue; // The Value of the directionPin 27 | boolean isMotorOn; //flag wether motor is on or off 28 | boolean myReversed; //high is low is high for the speed 29 | public: 30 | 31 | //PWMMotor( uint8_t PWMPin, uint8_t stopSpeed, uint8_t directionPin); 32 | /** 33 | * creates a PWMmotor object to control a motor based on PWM. 34 | * PWMPin the pin connected to the motor(controller) 35 | * stopSpeed the speed at which the motor is standing still 36 | * directionPin the pin to use to change the direction of the motor. 37 | * reversed when high is off and low is on or full speed 255 should be 0 on the pin 38 | * 39 | */ 40 | MotorPWM(uint8_t PWMPin, uint8_t stopSpeed, uint8_t directionPin, boolean reversed = false); 41 | void serialRegister(const __FlashStringHelper* Name); 42 | 43 | void setup(); 44 | void loop(); 45 | 46 | boolean emergencyBreak( ); 47 | 48 | /* 49 | * If you use simplot or the arduino eclipse plugin you can use 50 | * plotting functionality to better understand this code 51 | * the last value gives a tooth signal with 1 second interval 52 | */ 53 | #ifdef I_USE_PLOT 54 | void plot() 55 | { plot3(Serial,myRequestedSpeed,myActualSpeed,myStopSpeed);} 56 | #endif 57 | 58 | //for code compatibility 59 | void motorOff() 60 | { setRequestedSpeed(0);isMotorOn=false;}; 61 | void motorOn() 62 | { isMotorOn=true;}; 63 | // boolean motorUsesToMuchPower(){return false;}; 64 | // boolean areKnifesToLoaded(){return false;}; 65 | // boolean OKToIncreaseLoad(){return isAtSpeed();}; 66 | 67 | }; 68 | -------------------------------------------------------------------------------- /wiebel/wiebel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wiebel.h 3 | * 4 | * Created on: Aug 27, 2013 5 | * Author: jan 6 | */ 7 | 8 | #ifndef WIEBEL_H_ 9 | #define WIEBEL_H_ 10 | #include "Arduino.h" 11 | #include "JanServo.h" 12 | 13 | enum actieStatus 14 | { 15 | niks_te_doen, naar_groter, naar_kleiner, midden_positie_naar_kleinst, midden_positie_naar_grootst, helemaal_grootsts, helemaal_kleinst 16 | }; 17 | class wiebel 18 | { 19 | private: 20 | //uint32_t startTijd; 21 | uint8_t mijnStartPositie; 22 | uint8_t mijnWielbelStartPlaats; 23 | uint8_t mijnHuidigePositie; 24 | actieStatus mijnActieStatus; 25 | uint8_t mijnGrootsteHoek; 26 | uint8_t mijnKleinsteHoek; 27 | uint16_t mijnTijdNaarGroter; 28 | uint16_t mijnTijdNaarKleiner; 29 | uint16_t mijnWachtTijdGrootsteHoek; 30 | uint16_t mijnWachtTijdKleinsteHoek; 31 | uint16_t mijnWiebelStartPlaats_pause_naar_grootst; 32 | uint16_t mijnWiebelStartPlaats_pause_naar_kleinst; 33 | uint16_t mijnHerhalingen; 34 | uint32_t mijnStartTijd; 35 | iServo * mijnServo1; 36 | uint32_t lastlogTime; 37 | public: 38 | wiebel(); 39 | void setup(); 40 | void loop(); 41 | void startWiebel(iServo* mijnServo, uint8_t kleinsteHoek,uint8_t grootsteHoek, uint16_t tijdNaarGrootsteHoek, uint16_t tijdNaarKleinsteHoek, uint16_t wachtTijdGrootsteHoek, uint16_t wachtTijdKleinsteHoek, uint16_t startPlaats_pause_naar_grootst, uint16_t startPlaats_pause_naar_kleinst, 42 | uint16_t herhalingen); 43 | uint8_t getPositie() 44 | { 45 | return mijnHuidigePositie; 46 | } 47 | void setPositie(uint8_t nieuwe); 48 | actieStatus getActieStatus() 49 | { 50 | return mijnActieStatus; 51 | } 52 | const char * getStatusName(); 53 | }; 54 | 55 | 56 | 57 | class draaier 58 | { 59 | private: 60 | actieStatus mijnActieStatus; 61 | iServo* myWiebelServo; 62 | iServo* myBuigServo; 63 | uint8_t mijnStartHellingHoek; 64 | uint8_t mijnEindHellingHoek; 65 | uint8_t mijnStartDraaiHoek; 66 | uint8_t mijnEindDraaiHoek; 67 | uint32_t mijnLoopTijd; 68 | int16_t mijnAantalRondjes; 69 | uint32_t myStarttime; 70 | int32_t myTotalDegrees; 71 | int32_t myTotalHeightDegrees; 72 | int32_t previousHightCorner ; 73 | int32_t previousDirectionCorner ; 74 | 75 | public: 76 | draaier(){mijnActieStatus=niks_te_doen;} 77 | actieStatus getActieStatus() 78 | { 79 | return mijnActieStatus; 80 | } 81 | void startRondjes(iServo* Servo1, iServo* Servo2, uint8_t startHellingHoek, uint8_t eindHellingHoek, uint8_t startDraaiHoek, uint8_t eindDraaiHoek, uint32_t tijd, int16_t aantalRondjes); 82 | void setup(){}; 83 | void loop(); 84 | }; 85 | 86 | #endif /* WIEBEL_H_ */ 87 | -------------------------------------------------------------------------------- /MotorBLDC/MotorBLDC.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BLDC1Motor.cpp 3 | * 4 | * Created on: May 9, 2014 5 | * Author: jan 6 | */ 7 | 8 | #include "MotorBLDC.h" 9 | 10 | 11 | #define STEP 10 12 | MotorBLDC::MotorBLDC(uint8_t forwardBackwardPin, uint8_t PWMPin) 13 | { 14 | myRequestedSpeed = 0; 15 | myActualSpeed = 0; 16 | myActualSpinDirection = 0; 17 | myLoopduration = 0; 18 | myForwardBackwardPin = forwardBackwardPin; 19 | myPWMPin = PWMPin; 20 | } 21 | 22 | void MotorBLDC::serialRegister(const __FlashStringHelper* Name) 23 | { 24 | 25 | FieldData::set(Name, F("RequestedSpeed"),MOD_WRITE , &myRequestedSpeed); 26 | FieldData::setNext( F("ActualSpeed"), 0, &myActualSpeed); 27 | FieldData::setNext( F("ActualSpinDirection"), 0, &myActualSpinDirection); 28 | FieldData::setNext( F("ForwardBackwardPin"), 0, &myForwardBackwardPin); 29 | FieldData::setNext( F("PWMPin"), 0, &myPWMPin); 30 | FieldData::setNext((__FlashStringHelper *) LOOPDURATION, 0, &myLoopduration); 31 | } 32 | 33 | void MotorBLDC::setup() 34 | { 35 | pinMode(myForwardBackwardPin, OUTPUT); 36 | pinMode(myPWMPin, OUTPUT); 37 | digitalWrite(myForwardBackwardPin, LOW); 38 | analogWrite(myPWMPin, 0); 39 | } 40 | 41 | #define defaultDelay 10 42 | void MotorBLDC::loop() 43 | { 44 | if (myActualSpeed != myRequestedSpeed) 45 | { 46 | static unsigned long last_action_Time = millis(); 47 | static unsigned long cur_delay=defaultDelay; 48 | if (millis() - last_action_Time > cur_delay) 49 | { 50 | last_action_Time = millis(); 51 | SPEED_TYPE newActualSpeed = myActualSpeed; 52 | if (myActualSpeed < myRequestedSpeed) 53 | { 54 | newActualSpeed = min(newActualSpeed+STEP,myRequestedSpeed); 55 | } else 56 | { 57 | newActualSpeed = max(newActualSpeed-STEP,myRequestedSpeed); 58 | } 59 | 60 | cur_delay=defaultDelay; 61 | if (((int64_t)newActualSpeed * (int64_t)myActualSpeed) < 0) 62 | { 63 | cur_delay = 200; 64 | newActualSpeed = 0; 65 | } 66 | myActualSpeed = newActualSpeed; 67 | if (myActualSpeed < 0) 68 | { 69 | myActualSpinDirection = HIGH; 70 | } else 71 | { 72 | myActualSpinDirection = LOW; 73 | } 74 | digitalWrite(myForwardBackwardPin, myActualSpinDirection); 75 | uint8_t pwmValue=abs(myActualSpeed); 76 | analogWrite(myPWMPin,pwmValue ); 77 | // Serial.print("pwm value="); 78 | // Serial.println(pwmValue); 79 | } 80 | } 81 | } 82 | 83 | bool MotorBLDC::emergencyBreak(bool immediatlyReturn) 84 | { 85 | myActualSpeed=0; 86 | myRequestedSpeed=0; 87 | analogWrite(myPWMPin,myActualSpeed ); //I assume the motor does a decent stop 88 | return true; 89 | } 90 | -------------------------------------------------------------------------------- /VoltMeter/VoltMeter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * VoltMeter.cpp 3 | * 4 | * Created on: Mar 28, 2013 5 | * Author: jan 6 | */ 7 | 8 | #include "VoltMeter.h" 9 | 10 | #ifdef USE_SERIAl_LOGGING 11 | void VoltMeter::serialRegister(const __FlashStringHelper* Name) 12 | { 13 | FieldData::set(Name,F("CentiVolt"),0,&myCentiVolt); 14 | FieldData::setNext((__FlashStringHelper *)MULTIPLIER_DIV_1000,MOD_WRITE|MOD_SAVE,&myMultiplyerValue); 15 | 16 | #ifdef DETAILED_SERIAL_LOGGING 17 | FieldData::setNext(F("Value"),0,&myActualReadValue); 18 | FieldData::setNext(F("AvgValue"),0,&myAveragedReadValue); 19 | FieldData::setNext((__FlashStringHelper *)PIN,0,&myPin); 20 | // FieldData::setNext( (__FlashStringHelper *)LOOPDURATION,0,&myLoopduration); 21 | #endif 22 | 23 | } 24 | VoltMeter::VoltMeter(uint8_t Pin) { 25 | myPin = Pin; 26 | myCentiVolt = 0; 27 | myMultiplyerValue = 1000; 28 | myActualReadValue = 0; 29 | myAveragedReadValue = 0; 30 | my_last_read=0; 31 | } 32 | #else 33 | VoltMeter::VoltMeter(uint8_t Pin, uint16_t multiplyer) { 34 | myPin = Pin; 35 | myCentiVolt = 0; 36 | myMultiplyerValue = multiplyer; 37 | myActualReadValue = 0; 38 | myAveragedReadValue = 0; 39 | } 40 | #endif 41 | 42 | #ifdef PRECISE_VOLTAGE 43 | long readVcc() { 44 | long result; 45 | // Read 1.1V reference against AVcc 46 | //ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); 47 | ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); 48 | ADCSRB &= ~_BV(MUX5); 49 | delay(2);// Wait for Vref to settle 50 | ADCSRA |= _BV(ADSC);// Convert 51 | while (bit_is_set(ADCSRA,ADSC)); 52 | result = ADCL; 53 | result |= ADCH<<8; 54 | result = 1125300L / result;// Back-calculate AVcc in mV 55 | return result; 56 | } 57 | #endif //PRECISE_VOLTAGE 58 | 59 | void VoltMeter::loop() { 60 | #ifndef USE_MAIN_LOOP_MILLIS 61 | uint32_t loopMillis = millis(); 62 | #endif 63 | //only reed every 100 ms 64 | if (loopMillis - my_last_read > 100) { 65 | my_last_read = loopMillis; 66 | #ifdef PRECISE_VOLTAGE 67 | long vcc=readVcc(); 68 | myActualReadValue= (analogRead(myPin) *vcc) / 1023; 69 | //as we do precise reading there is no need to average 70 | myAveragedReadValue=myActualReadValue; 71 | #else 72 | myActualReadValue = analogRead(myPin); 73 | //As we do not read precisely we average the result 74 | myAveragedReadValue = (myAveragedReadValue * 8 + (2 * myActualReadValue)) / 10; 75 | #endif 76 | 77 | myCentiVolt = (uint16_t)(((uint32_t) myAveragedReadValue * (uint32_t) myMultiplyerValue) / 1000UL); 78 | } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /SerialCommunicator/examples/serialCommunicatorStep4/serialCommunicatorStep4.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a example sketch showing the use of EEPROM to save values 3 | * 4 | * This example sketch needs quite some libraries as you can see below with the includes 5 | * Make sure they are configured and linked to properly 6 | * 7 | * This example is a follow up of SerialCommunicatorStep3 which is bundled as an example in 8 | * the SerialCommunicator library 9 | * 10 | * This example is slightly different from the previous in code and allows saving values in 11 | * EEPROM 12 | * 13 | * In the previous example we could change the blink rhythm of the led on pin 13 14 | * and the logging parameters but each time the Arduino is reset these object values 15 | * are lost. 16 | * In this example we will add a the possibility to save the object values that are 17 | * tagged as possible to save. 18 | * 19 | * 20 | * verify and upload the code; connect with the serial monitor and send following 21 | * lines to the Arduino (do not forget to add a CR or LF or both) 22 | * ? 23 | * ->note that a SAVE and LOAD have been added 24 | * SET Admin.DelaybetweenLogs=5000 25 | * -> reboot the arduino 26 | * SET 27 | * -> Admin.DelaybetweenLogs is set to the default value (probably garbage) 28 | * * SET Admin.DelaybetweenLogs=5000 29 | * SAVE 30 | * -> reboot the arduino 31 | * SET 32 | * -> Admin.DelaybetweenLogs is still set on 5000 33 | * SET Admin.DelaybetweenLogs=800 34 | * LOAD 35 | * -> Admin.DelaybetweenLogs is reset to 5000 36 | * 37 | * no rights reserved 38 | */ 39 | 40 | 41 | #include "BlinkLed.h" 42 | #include "BlinkLedSerial.h" 43 | #include "SerialDataInterface.h" 44 | #include "SerialCommunicator.h" 45 | #include "SerialEEPROMCommunicator.h" 46 | #include "SerialStringReader.h" 47 | 48 | 49 | const char mySketchName[] PROGMEM="Serial Communicator step4"; 50 | 51 | //We replaced the SerialCommunicator by the SerialEEPROMCommunicator, 52 | // with no impact on the code 53 | SerialEEPROMCommunicator myCommunicator; 54 | BlinkLedSerial led13(13,500,2000); 55 | 56 | 57 | #define THESERIAL Serial 58 | Stream &SerialInput = THESERIAL; 59 | Stream &SerialOutput = THESERIAL; 60 | Stream &SerialError = THESERIAL; 61 | 62 | 63 | 64 | void setup() 65 | { 66 | delay(2000); 67 | THESERIAL.begin(115200); 68 | myCommunicator.serialRegister(F("Admin")); 69 | led13.serialRegister(F("BuildInLed")); 70 | SerialOutput.print(F("Current memory fields ")); 71 | SerialOutput.println(lastFieldIndex); 72 | SerialOutput.println(F(" from ")); 73 | SerialOutput.println(MAXFIELDS); 74 | 75 | led13.setup(); 76 | myCommunicator.setup(); 77 | } 78 | 79 | 80 | void loop() 81 | { 82 | myCommunicator.loop(); 83 | led13.loop(); 84 | } 85 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/static/input.begin.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Arduino control center 7 | 8 | 62 | 63 | 64 | 66 | 67 | 68 | 69 | 70 |

SKETCHNAME

65 |
71 | 72 | -------------------------------------------------------------------------------- /Sabertooth/examples/1.Basics/Sweep/Sweep.ino: -------------------------------------------------------------------------------- 1 | // Sweep Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | 7 | Sabertooth ST(128); // The Sabertooth is on address 128. We'll name its object ST. 8 | // If you've set up your Sabertooth on a different address, of course change 9 | // that here. For how to configure address, etc. see the DIP Switch Wizard for 10 | // Sabertooth - http://www.dimensionengineering.com/datasheets/SabertoothDIPWizard/start.htm 11 | // SyRen - http://www.dimensionengineering.com/datasheets/SyrenDIPWizard/start.htm 12 | // Be sure to select Packetized Serial Mode for use with this library. 13 | // 14 | // On that note, you can use this library for SyRen just as easily. 15 | // The diff-drive commands (drive, turn) do not work on a SyRen, of course, but it will respond correctly 16 | // if you command motor 1 to do something (ST.motor(1, ...)), just like a Sabertooth. 17 | // 18 | // In this sample, hardware serial TX connects to S1. 19 | // See the SoftwareSerial example in 3.Advanced for how to use other pins. 20 | 21 | void setup() 22 | { 23 | SabertoothTXPinSerial.begin(9600); // 9600 is the default baud rate for Sabertooth packet serial. 24 | ST.autobaud(); // Send the autobaud command to the Sabertooth controller(s). 25 | // NOTE: *Not all* Sabertooth controllers need this command. 26 | // It doesn't hurt anything, but V2 controllers use an 27 | // EEPROM setting (changeable with the function setBaudRate) to set 28 | // the baud rate instead of detecting with autobaud. 29 | // 30 | // If you have a 2x12, 2x25 V2, 2x60 or SyRen 50, you can remove 31 | // the autobaud line and save yourself two seconds of startup delay. 32 | } 33 | 34 | void loop() 35 | { 36 | int power; 37 | 38 | // Ramp motor 1 from -127 to 127 (full reverse to full forward), 39 | // waiting 20 ms (1/50th of a second) per value. 40 | for (power = -127; power <= 127; power ++) 41 | { 42 | ST.motor(1, power); 43 | delay(20); 44 | } 45 | 46 | // Now go back the way we came. 47 | for (power = 127; power >= -127; power --) 48 | { 49 | ST.motor(1, power); // Tip for SyRen users: Typing ST.motor(power) does the same thing as ST.motor(1, power). 50 | delay(20); // Since SyRen doesn't have a motor 2, this alternative can save you typing. 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /MotorMegaMotoHBridge/MotorMegaMotoHBridge.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MegaMotoHBridgeDriver.cpp 3 | * 4 | * Created on: May 19, 2012 5 | * Author: BE04258 6 | */ 7 | 8 | 9 | #include "MotorMegaMotoHBridge.h" 10 | #define MINIMUMPWM 120 11 | #define MINIMUMSPEEDTORUN 10 //used to be 10 12 | 13 | MotorMegaMotoHBridge::MotorMegaMotoHBridge( ENABLEPINPARAM uint8_t PWMAPin, uint8_t PWMBPin, uint8_t CurrentPinA, uint8_t CurrentPinB) 14 | : myMegaMotoDriver( ENABLEPINATTRIBUTE PWMAPin, PWMBPin, CurrentPinA, CurrentPinB) 15 | { 16 | myCurrentRequestedSpeed = 0; 17 | myIsDirty = true; /*Set this to true so we know for sure everything is properly initialised */ 18 | myLoopDuration=0; 19 | 20 | } 21 | #define DETAILED_SERIAL_LOGGING 22 | void MotorMegaMotoHBridge::serialRegister(const __FlashStringHelper* DriverName,const __FlashStringHelper* BrigeAName,const __FlashStringHelper* BrigeBName) 23 | { 24 | 25 | FieldData::set(DriverName, F("RequestedSpeed"),MOD_WRITE,&myCurrentRequestedSpeed); 26 | #ifdef DETAILED_SERIAL_LOGGING 27 | FieldData::set(DriverName, F("myNewRequestedSpeed"),MOD_WRITE,&myNewRequestedSpeed); 28 | FieldData::set(DriverName, F("IsDirty"),0,&myIsDirty); 29 | FieldData::set(DriverName, F("LoopDuration"),0,&myLoopDuration); 30 | #endif 31 | 32 | myMegaMotoDriver.serialRegister( DriverName, BrigeAName, BrigeBName); 33 | 34 | } 35 | 36 | 37 | 38 | void MotorMegaMotoHBridge::changeSpeed(int16_t requestedSpeed) 39 | { 40 | 41 | myCurrentRequestedSpeed = requestedSpeed; 42 | if (abs(requestedSpeed) < MINIMUMSPEEDTORUN) myCurrentRequestedSpeed = 0; 43 | 44 | uint8_t ReqSpeedA = (myCurrentRequestedSpeed > 0) * abs(myCurrentRequestedSpeed); 45 | uint8_t ReqSpeedB = (myCurrentRequestedSpeed < 0) * abs(myCurrentRequestedSpeed); 46 | if (((myMegaMotoDriver.myHalfBridgeA.getRequestedSpeed() == 0) && (myMegaMotoDriver.myHalfBridgeA.getActualSpeed() == 0) && (ReqSpeedA == 0)) 47 | || ((myMegaMotoDriver.myHalfBridgeB.getRequestedSpeed() == 0) && (myMegaMotoDriver.myHalfBridgeB.getActualSpeed() == 0) && (ReqSpeedB == 0))) 48 | { 49 | myMegaMotoDriver.setRequestedSpeedA(ReqSpeedA); 50 | myMegaMotoDriver.setRequestedSpeedB(ReqSpeedB); 51 | myIsDirty = false; 52 | } else 53 | { 54 | myMegaMotoDriver.setRequestedSpeedA(0); 55 | myMegaMotoDriver.setRequestedSpeedB(0); 56 | myIsDirty = true; 57 | } 58 | } 59 | 60 | void MotorMegaMotoHBridge::loop() 61 | { 62 | unsigned long loopStart = millis(); 63 | if ((myIsDirty) || (myCurrentRequestedSpeed!=myNewRequestedSpeed)) 64 | { 65 | changeSpeed(myNewRequestedSpeed); 66 | } 67 | myMegaMotoDriver.loop(); 68 | //myIsAtSpeed = !myMegaMotoDriver.isDirty(); 69 | myCurrentUsage_cA=myMegaMotoDriver.getCurrentUsage_cA(); 70 | myActualSpeed=myMegaMotoDriver.myHalfBridgeA.getActualSpeed()-myMegaMotoDriver.myHalfBridgeB.getActualSpeed(); 71 | myLoopDuration = millis() - loopStart; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /SerialCommunicator/SerialCommunicator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MessageHandler.h 3 | * 4 | * Created on: Nov 28, 2012 5 | * Author: BE04258 6 | */ 7 | 8 | #pragma once 9 | #include "Arduino.h" 10 | #include "SerialStringReader.h" 11 | #include "SerialDataInterface.h" 12 | 13 | /** 14 | * Messages to Arduino are 15 | * DUMP shows all variables with their type and value 16 | * SET [name] [value] set a variable with name [name] equal to [value] 17 | * GET [name] get the value of the variable with name [name] 18 | * RESET to reset the Arduino 19 | * LOG HEADER to print the LOG Header 20 | * LOG VALUE to print the LOG values 21 | * 22 | * Messages From Arduino ARE 23 | * HTMLGET [data] Request to do a HTML GET 24 | * HTMLPOST [data] Request to do a HTML POST 25 | * LOG VALUE;[data] Request to do log the data to disk 26 | */ 27 | 28 | class SerialCommunicator 29 | { 30 | protected: 31 | 32 | uint8_t myLogLevel = 1; // The Log Level used 33 | uint32_t mylastLog = 0; //the last time we logged 34 | SerialStringReader mySerialStringReader; //the class to read string from the serial monitor 35 | uint16_t myLogDelay = 1000; //The time to wait after a log has been done 36 | 37 | uint32_t myLoopCounter = 0; //Counts the number of times loop has been called 38 | uint32_t myLastLoopMillis = 0; 39 | uint16_t myAveragebetweenLoops = 0; //The average millis between loop counts 40 | uint16_t myMaxbetweenLoops = 0; //The maximum millis between loop counts 41 | uint32_t myLoopduration = 0; //the duration of the loop 42 | uint32_t myLogduration = 0; //the duration of the last log 43 | int16_t mySerialQueueSize = 0; //The size of the serial queue 44 | /** 45 | * Call this method when a message has been received. 46 | * The message will be parsed in the next call to Loop. 47 | */ 48 | virtual void setReceivedMessage(const char *newMessage); 49 | virtual ~SerialCommunicator() 50 | { 51 | } 52 | ; 53 | 54 | void logValue(); 55 | void dumpCommands(); 56 | 57 | //#ifdef I_USE_RESET 58 | // static uint8_t myResetPin; //The pin used to rest Arduino 59 | // static void ForceHardReset();//Forces the Arduino to restart so the boot loader can load a new sketch 60 | // static uint16_t myResetDelay;//The delay before a reset is actioned 61 | //#endif 62 | 63 | public: 64 | Stream &mySerialOutput; 65 | Stream &mySerialError; 66 | SerialCommunicator(Stream &commStream, Stream &errorStream); 67 | 68 | /** 69 | * Initializes the class. 70 | * Call this method in your setup() 71 | */ 72 | void serialRegister(const __FlashStringHelper* Name); 73 | void setup(); 74 | 75 | /** 76 | * Add the Loop() in your loop(); 77 | */ 78 | void loop(); 79 | 80 | }; 81 | 82 | extern const char mySketchName[] PROGMEM; 83 | void waitForYunToBoot(); 84 | 85 | -------------------------------------------------------------------------------- /SabertoothSimplified/SabertoothSimplified.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino Library for Sabertooth Simplified Serial 3 | Copyright (c) 2012-2013 Dimension Engineering LLC 4 | http://www.dimensionengineering.com/arduino 5 | 6 | Permission to use, copy, modify, and/or distribute this software for any 7 | purpose with or without fee is hereby granted, provided that the above 8 | copyright notice and this permission notice appear in all copies. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 13 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 14 | RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 15 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE 16 | USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include "SabertoothSimplified.h" 20 | 21 | SabertoothSimplified::SabertoothSimplified() 22 | : _port(SabertoothTXPinSerial) 23 | { 24 | 25 | } 26 | 27 | SabertoothSimplified::SabertoothSimplified(Print& port) 28 | : _port(port) 29 | { 30 | 31 | } 32 | 33 | void SabertoothSimplified::motor(int power) 34 | { 35 | motor(1, power); 36 | } 37 | 38 | void SabertoothSimplified::motor(byte motor, int power) 39 | { 40 | mixedMode(false); 41 | raw(motor, power); 42 | } 43 | 44 | void SabertoothSimplified::drive(int power) 45 | { 46 | mixedMode(true); 47 | _mixedDrive = constrain(power, -127, 127); 48 | _mixedDriveSet = true; 49 | mixedUpdate(); 50 | } 51 | 52 | void SabertoothSimplified::turn(int power) 53 | { 54 | mixedMode(true); 55 | _mixedTurn = constrain(power, -127, 127); 56 | _mixedTurnSet = true; 57 | mixedUpdate(); 58 | } 59 | 60 | void SabertoothSimplified::stop() 61 | { 62 | _port.write((uint8_t)0); 63 | _mixedDriveSet = false; 64 | _mixedTurnSet = false; 65 | } 66 | 67 | void SabertoothSimplified::mixedMode(boolean enable) 68 | { 69 | if (_mixed == enable) { return; } 70 | 71 | stop(); 72 | _mixed = enable; 73 | } 74 | 75 | void SabertoothSimplified::mixedUpdate() 76 | { 77 | if (!_mixedDriveSet || !_mixedTurnSet) { return; } 78 | raw(1, _mixedDrive - _mixedTurn); 79 | raw(2, _mixedDrive + _mixedTurn); 80 | } 81 | 82 | void SabertoothSimplified::raw(byte motor, int power) 83 | { 84 | byte command, magnitude; 85 | power = constrain(power, -127, 127); 86 | magnitude = abs(power) >> 1; 87 | 88 | if (motor == 1) 89 | { 90 | command = power < 0 ? 63 - magnitude : 64 + magnitude; 91 | } 92 | else if (motor == 2) 93 | { 94 | command = power < 0 ? 191 - magnitude : 192 + magnitude; 95 | } 96 | 97 | command = constrain(command, 1, 254); 98 | _port.write(command); 99 | } 100 | -------------------------------------------------------------------------------- /SabertoothSimplified/SabertoothSimplified.h: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino Library for Sabertooth Simplified Serial 3 | Copyright (c) 2012-2013 Dimension Engineering LLC 4 | http://www.dimensionengineering.com/arduino 5 | 6 | Permission to use, copy, modify, and/or distribute this software for any 7 | purpose with or without fee is hereby granted, provided that the above 8 | copyright notice and this permission notice appear in all copies. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 13 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 14 | RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 15 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE 16 | USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #ifndef SabertoothSimplified_h 20 | #define SabertoothSimplified_h 21 | 22 | #if defined(ARDUINO) && ARDUINO >= 100 23 | #include 24 | #else 25 | #include 26 | #endif 27 | 28 | #if defined(USBCON) 29 | #define SabertoothTXPinSerial Serial1 // Arduino Leonardo has TX->1 on Serial1, not Serial. 30 | #else 31 | #define SabertoothTXPinSerial Serial 32 | #endif 33 | #define SyRenTXPinSerial SabertoothTXPinSerial 34 | 35 | /*! 36 | \class SabertoothSimplified 37 | \brief Controls a %Sabertooth motor driver running in Simplified Serial mode. 38 | */ 39 | class SabertoothSimplified 40 | { 41 | public: 42 | /*! 43 | Initializes a new instance of the SabertoothSimplified class. 44 | The Arduino TX serial port is used. 45 | */ 46 | SabertoothSimplified(); 47 | 48 | /*! 49 | Initializes a new instance of the SabertoothSimplified class. 50 | The specified serial port is used. 51 | \param port The port to use. 52 | */ 53 | SabertoothSimplified(Print& port); 54 | 55 | public: 56 | /*! 57 | Sets the power of motor 1. 58 | \param power The power, between -127 and 127. 59 | */ 60 | void motor(int power); 61 | 62 | /*! 63 | Sets the power of the specified motor. 64 | \param motor The motor number, 1 or 2. 65 | \param power The power, between -127 and 127. 66 | */ 67 | void motor(byte motor, int power); 68 | 69 | /*! 70 | Sets the driving power. 71 | \param power The power, between -127 and 127. 72 | */ 73 | void drive(int power); 74 | 75 | /*! 76 | Sets the turning power. 77 | \param power The power, between -127 and 127. 78 | */ 79 | void turn(int power); 80 | 81 | /*! 82 | Stops. 83 | */ 84 | void stop(); 85 | 86 | private: 87 | void mixedMode(boolean enable); 88 | void mixedUpdate(); 89 | void raw(byte motor, int power); 90 | 91 | private: 92 | boolean _mixed; 93 | int _mixedDrive, _mixedTurn; 94 | boolean _mixedDriveSet, _mixedTurnSet; 95 | Print& _port; 96 | }; 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /minibridge/MiniProcess.cpp: -------------------------------------------------------------------------------- 1 | #include "MiniProcess.h" 2 | 3 | void runShellCommand(const __FlashStringHelper* command, char * retbuffer, uint8_t size) 4 | { 5 | strlcpy_P(commonlyUsedBuffer,(prog_char *)command,commonlyUsedBuffersize); 6 | runShellCommand((char*) commonlyUsedBuffer, retbuffer, size); 7 | } 8 | 9 | void runShellCommand(const char* command, char * retbuffer, uint8_t size) 10 | { 11 | Process p; 12 | p.runShellCommand(command); 13 | int count = 0; 14 | while (p.available() && (count < (size - 1))) 15 | { 16 | char curchar = (char) p.read(); 17 | if (curchar == '\n') 18 | { 19 | retbuffer[count++] = '\r'; 20 | retbuffer[count++] = '\n'; 21 | } else 22 | { 23 | retbuffer[count++] = curchar; 24 | } 25 | } 26 | if (count > 2) count -= 2; 27 | retbuffer[count] = 0; 28 | // size_t readSize = p.readBytes(retbuffer, size); 29 | // retbuffer[readSize+1]=0; 30 | 31 | } 32 | 33 | 34 | // Process::Process(){started=false;readPos=0;}; 35 | 36 | // unsigned int Process::runShellCommand(const char *command) 37 | // { 38 | // close(); 39 | // uint8_t cmd[] = {'R'}; 40 | // uint8_t res[2]; 41 | // Bridge.transfer(cmd, 1,(uint8_t*)"/bin/ash\xFE-c\xFE",12, (uint8_t*)command, strlen(command), res, 2); 42 | // handle = res[1]; 43 | // 44 | // 45 | // if (res[0] == 0) // res[0] contains error code 46 | // started = true; 47 | // while (running()) 48 | // delay(100); 49 | // return exitValue(); 50 | // } 51 | 52 | 53 | 54 | 55 | // boolean Process::running() 56 | // { 57 | // uint8_t cmd[] = {'r', handle}; 58 | // uint8_t res[1]; 59 | // Bridge.transfer(cmd, 2,0,0,0,0, res, 1); 60 | // return (res[0] == 1); 61 | // } 62 | 63 | int Process::available() 64 | { 65 | // Look if there is new data available 66 | doBuffer(); 67 | return buffered; 68 | } 69 | 70 | 71 | // void Process::doBuffer() { 72 | // // If there are already char in buffer exit 73 | // if (buffered > 0) 74 | // return; 75 | // 76 | // // Try to buffer up to 32 characters 77 | // readPos = 0; 78 | // uint8_t cmd[] = {'O', handle, sizeof(buffer)}; 79 | // buffered = Bridge.transfer(cmd, 3,0,0,0,0, buffer, sizeof(buffer)); 80 | // } 81 | 82 | int Process::read() { 83 | doBuffer(); 84 | if (buffered == 0) 85 | return -1; // no chars available 86 | else { 87 | buffered--; 88 | return buffer[readPos++]; 89 | } 90 | } 91 | 92 | 93 | // void Process::close() { 94 | // if (started) { 95 | // uint8_t cmd[] = {'w', handle}; 96 | // Bridge.transfer(cmd, 2,0,0,0,0,0,0); 97 | // } 98 | // started = false; 99 | // } 100 | // unsigned int Process::exitValue() { 101 | // uint8_t cmd[] = {'W', handle}; 102 | // uint8_t res[2]; 103 | // Bridge.transfer(cmd, 2,0,0,0,0, res, 2); 104 | // return (res[0] << 8) + res[1]; 105 | // } 106 | 107 | 108 | -------------------------------------------------------------------------------- /simplot/examples/makerfairRome2017Demo/makerfairRome2017Demo.ino: -------------------------------------------------------------------------------- 1 | #include "makerfairRome2017Demo.h" 2 | const int ledPin1 = LED_BUILTIN; 3 | 4 | void setup() { 5 | pinMode(ledPin1, OUTPUT); 6 | Serial.begin(115200); 7 | } 8 | 9 | void loop() { 10 | const uint32_t currentMillis = millis(); 11 | 12 | // calculate the state of the leds 13 | int ledValue1 = getBlinkLedValue(currentMillis, 1000, 2000); 14 | int ledValue2 = getFadeLedValue(currentMillis, 1000, 2000); 15 | 16 | // decide on which actions we need to do 17 | bool printAliveMessage = shouldIPrintKeepAliveMessage(currentMillis); 18 | bool shouldIPlotData = shouldIPlot(currentMillis); 19 | 20 | //change the led state 21 | digitalWrite(ledPin1, ledValue1); 22 | 23 | //Plot from time to time 24 | if (shouldIPlotData) { 25 | plot2(Serial, ledValue1 * 255, ledValue2); 26 | } 27 | 28 | //show we are still alive 29 | if (printAliveMessage) { 30 | Serial.println("I'm alive"); 31 | } 32 | 33 | } 34 | 35 | 36 | /** 37 | * Based on the parameters tells you whether the led should 38 | * be on or off 39 | */ 40 | int getBlinkLedValue(const uint32_t currentMillis, const uint32_t onInterval, 41 | const uint32_t offInterval) { 42 | uint32_t currentFrame = currentMillis % (onInterval + offInterval); 43 | int ret = currentFrame < onInterval; 44 | return ret; 45 | } 46 | /** 47 | * Based on the parameters tells you how hard the led should shine 48 | * return value between 0 255 49 | */ 50 | int getFadeLedValue(const uint32_t currentMillis, const uint32_t onInterval, 51 | const uint32_t offInterval) { 52 | uint32_t currentFrame = currentMillis % (onInterval + offInterval); 53 | if (currentFrame > onInterval) { 54 | return 255 - map(currentFrame - onInterval, 0, offInterval, 0, 255); 55 | }; 56 | int ret = map(currentFrame, 0, onInterval, 0, 255); 57 | return ret; 58 | } 59 | 60 | /** 61 | *Tells you how many times there should have been triggered since the start of the cpu 62 | */ 63 | uint32_t numTriggers(const uint32_t currentMillis, 64 | const uint32_t triggerInterval) { 65 | uint32_t ret = currentMillis / triggerInterval; 66 | return ret; 67 | } 68 | 69 | /** 70 | * Decide whether plotting is needed or not. 71 | * Plotting is done every XX milliseconds 72 | */ 73 | bool shouldIPlot(const uint32_t currentMillis){ 74 | static int prefNumPlottriggers = 0; 75 | int curNumPlotTriggers = numTriggers(currentMillis, 20); 76 | bool plotData = (curNumPlotTriggers != prefNumPlottriggers); 77 | prefNumPlottriggers = curNumPlotTriggers; 78 | return plotData; 79 | } 80 | 81 | /** 82 | * Decide whether the sending a keep alive message is needed or not. 83 | * Plotting is done every XX milliseconds 84 | */ 85 | bool shouldIPrintKeepAliveMessage(const uint32_t currentMillis){ 86 | static int prefNumtriggers = 0; 87 | int curNumTriggers = numTriggers(currentMillis, 2000); 88 | bool printAliveMessage = (curNumTriggers != prefNumtriggers); 89 | prefNumtriggers = curNumTriggers; 90 | return printAliveMessage; 91 | } 92 | -------------------------------------------------------------------------------- /SkidDriverSaberTooth/SkidDriversaberTooth.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SkidDriversaberTooth.cpp 3 | * 4 | * Created on: 11-mei-2016 5 | * Author: jan 6 | */ 7 | 8 | #include 9 | 10 | SkidDriverSaberTooth::SkidDriverSaberTooth(Sabertooth* pSabertooth) 11 | { 12 | myIsMotorOn = false; 13 | myPSabertooth = pSabertooth; 14 | mySabertoothspeed = 0; 15 | mySabertoothDirection = 0; 16 | } 17 | 18 | SkidDriverSaberTooth::~SkidDriverSaberTooth() 19 | { 20 | } 21 | 22 | void SkidDriverSaberTooth::motorOn() 23 | { 24 | myIsMotorOn = true; 25 | } 26 | 27 | void SkidDriverSaberTooth::motorOff() 28 | { 29 | myIsMotorOn = false; 30 | } 31 | 32 | void SkidDriverSaberTooth::setup() 33 | { 34 | myPSabertooth->autobaud(); // Send the autobaud command to the Sabertooth controller(s). 35 | // NOTE: *Not all* Sabertooth controllers need this command. 36 | // It doesn't hurt anything, but V2 controllers use an 37 | // EEPROM setting (changeable with the function setBaudRate) to set 38 | // the baud rate instead of detecting with autobaud. 39 | // 40 | // If you have a 2x12, 2x25 V2, 2x60 or SyRen 50, you can remove 41 | // the autobaud line and save yourself two seconds of startup delay. 42 | 43 | myPSabertooth->drive(0); // The Sabertooth won't act on mixed mode packet serial commands until 44 | myPSabertooth->turn(0); // it has received power levels for BOTH throttle and turning, since it 45 | // mixes the two together to get diff-drive power levels for both motors. 46 | } 47 | 48 | void SkidDriverSaberTooth::loop() 49 | { 50 | if ((myNewRequestedDirection != myRequestedDirection) || (myNewRequestedSpeed != myRequestedSpeed)) 51 | { 52 | myRequestedDirection = myNewRequestedDirection * SIGN(myNewRequestedSpeed); 53 | myRequestedSpeed = myNewRequestedSpeed; 54 | mySabertoothspeed = myRequestedSpeed / 2; //maps {-255, 255} to {-127, 127} 55 | mySabertoothDirection = map(myRequestedDirection, -90, 90, -127, 127); 56 | myPSabertooth->drive(mySabertoothspeed); 57 | myPSabertooth->turn(mySabertoothDirection); 58 | 59 | } 60 | } 61 | 62 | bool SkidDriverSaberTooth::emergencyBreak(bool immediatlyReturn) 63 | { 64 | myPSabertooth->stop(); 65 | myNewRequestedDirection = myRequestedDirection = myNewRequestedSpeed = myRequestedSpeed = 0; 66 | return true; 67 | } 68 | 69 | void SkidDriverSaberTooth::turnOnTheSpot(SPEED_TYPE Speed) 70 | { 71 | myPSabertooth->drive(0); 72 | myPSabertooth->turn(map(myRequestedDirection, -90, 90, -255, 255)); 73 | } 74 | 75 | SPEED_TYPE SkidDriverSaberTooth::getActualSpeed() const 76 | { 77 | return myRequestedSpeed; 78 | } 79 | 80 | void SkidDriverSaberTooth::serialRegister(const __FlashStringHelper* Name) 81 | { 82 | 83 | FieldData::set(Name, F("RequestedSpeed"),MOD_OVERVIEW,&myRequestedSpeed); 84 | FieldData::set(Name, F("RequestedDirection"),MOD_OVERVIEW,&myRequestedDirection); 85 | FieldData::set(Name, F("mySabertoothspeed"),MOD_NONE,&mySabertoothspeed); 86 | FieldData::set(Name, F("mySabertoothDirection"),MOD_NONE,&mySabertoothDirection); 87 | 88 | } 89 | -------------------------------------------------------------------------------- /SerialBridgeCommunicator/configure/dynamic/upload.lua: -------------------------------------------------------------------------------- 1 | #! /usr/bin/lua 2 | 3 | -- HTTP header 4 | print [[ 5 | Content-Type: text/html; charset=iso-8859-1 6 | 7 | 8 | 9 | ]] 10 | 11 | print [[ 12 | 13 | Arduino system page 14 | 15 | 16 |

Arduino Control Center

17 |
18 |

Select your hex file:

19 |

Upload to server:

20 |
21 |
22 |

23 | to

28 |
29 | 30 | Application admin 31 |
32 | ]] 33 | 34 | ---- end form test 35 | 36 | 37 | 38 | if get_data.to == "server" then 39 | print "

Uploading to server

\n" 40 | POST_DATA = io.read ("*all") -- read all of stdin 41 | contentType = os.getenv ("CONTENT_TYPE") 42 | 43 | if contentType then 44 | pos = string.find (contentType, "=", 2, true) 45 | if pos then 46 | pos =string.find(POST_DATA, "\r\n\r\n",1,true) + 4 47 | if pos then 48 | lastpos = string.find(POST_DATA, "\r\n\r\n" , pos,true) 49 | HEX_DATA = string.sub(POST_DATA, pos, lastpos +1 ) 50 | end 51 | end 52 | end 53 | if HEX_DATA then 54 | print "data arrived
\n" 55 | 56 | local f = assert(io.open ("/tmp/upload.hex", "wb")) 57 | s = assert( f:write (HEX_DATA)) 58 | f:close () -- close it 59 | print [[ hex file dumped in /tmp/upload.hex
]] 60 | end 61 | 62 | elseif get_data.to == "arduino" then 63 | print "

Uploading to arduino

\n" 64 | 65 | if get_data.board == "atmega2560" then 66 | programmer = "-cstk500v2" 67 | else 68 | programmer = "-arduino" 69 | end 70 | --PortName = os.getenv("PortName") 71 | 72 | 73 | PortName = "/dev/tts/1" 74 | 75 | io.write( "run_avrdude -v -p"..get_data.board.." > /tmp/upload.out 2>&1
") 76 | os.execute("rm -p /tmp/value.txt") 77 | os.execute("pkill -f \".*ParseArduinoInput\" > /tmp/upload.out 2>&1") 78 | os.execute("echo p >> "..PortName.."") 79 | os.execute("echo Admin.logLevel=0 >> "..PortName..";sleep 3") 80 | os.execute("run_avrdude -v -p"..get_data.board.." >> /tmp/upload.out 2>&1") 81 | os.execute("echo upload done >> /tmp/upload.out") 82 | os.execute("/www/cgi-bin/jantje/startReadingArduino.sh >> /tmp/upload.out 2>&1") 83 | f= assert(io.open ("/tmp/upload.out", "r")) 84 | t = f:read("*all") 85 | t= string.gsub( fixhtml(t), "\n", "
\n") 86 | io.write ( t ) 87 | f:close () 88 | end 89 | 90 | print [[ 91 | 92 | 93 | ]] 94 | 95 | 96 | -------------------------------------------------------------------------------- /MotorInterface/MotorInterface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MotorInterface.h 3 | * 4 | * Created on: Jul 4, 2014 5 | * Author: jan 6 | */ 7 | #pragma once 8 | #include "SerialDataInterface.h" 9 | #include "DataTypes.h" 10 | 11 | #ifdef USE_MAIN_LOOP_MILLIS 12 | extern uint32_t loopMillis; 13 | #endif 14 | 15 | 16 | class MotorInterface 17 | { 18 | protected: 19 | SPEED_TYPE myRequestedSpeed; 20 | SPEED_TYPE myNewRequestedSpeed; 21 | SPEED_TYPE myActualSpeed; 22 | uint16_t myMaxTurnCurrent_cA; 23 | bool myIsDirty; 24 | uint16_t myCurrentUsage_cA; 25 | uint32_t myLastSpeedChangeTime; 26 | 27 | public: 28 | virtual void loop()=0; 29 | virtual void setup()=0; 30 | virtual void motorOn()=0; 31 | virtual void motorOff()=0; 32 | 33 | /** 34 | * EmergencyBreak stops the drive engines directly powering the coils 35 | * To avoid powerspikes the power is gradually decreased 36 | * This method waits untill the motor is stopped 37 | * The method returns true when the attached motors are stalled 38 | */ 39 | virtual bool emergencyBreak()=0; 40 | 41 | /** 42 | * The last time the speed has changed. 43 | */ 44 | uint64_t getLastSpeedChangeTime() 45 | { 46 | return myLastSpeedChangeTime; 47 | } 48 | 49 | 50 | /** 51 | * returns wether the motor is running at the requested speed. 52 | * As we do not have a speed meter we wqait a while after we requested the speed. (slow start) 53 | */ 54 | boolean isAtSpeed() const 55 | { 56 | return ((myRequestedSpeed == myActualSpeed) && (loopMillis - myLastSpeedChangeTime > 10000)); 57 | } 58 | ; 59 | 60 | SPEED_TYPE getActualSpeed() const 61 | { 62 | return myActualSpeed; 63 | } 64 | bool isDirty() 65 | { 66 | return myIsDirty; 67 | } 68 | 69 | /* 70 | * SetSpeed changes the speed of the motor. 71 | * The speed is changed in small steps. 72 | */ 73 | void setRequestedSpeed(int16_t Speed) 74 | { 75 | myNewRequestedSpeed = Speed; 76 | myIsDirty = true; 77 | } 78 | 79 | int16_t getRequestedSpeed() const 80 | { 81 | return myNewRequestedSpeed; 82 | } 83 | 84 | uint16_t getCurrentUsage_cA() const 85 | { 86 | return myCurrentUsage_cA; 87 | } 88 | 89 | virtual ~MotorInterface()=default; 90 | #ifdef I_USE_SERIAL_REGISTER 91 | virtual void serialRegister(const __FlashStringHelper* Name) 92 | { 93 | FieldData::set(Name, F("RequestedSpeed"),MOD_OVERVIEW , &myRequestedSpeed); 94 | FieldData::setNext( F("NewRequestedSpeed"), MOD_WRITE, &myNewRequestedSpeed); 95 | FieldData::setNext( F("LastSpeedChangeTime"), MOD_NONE, &myLastSpeedChangeTime); 96 | 97 | FieldData::setNext( F("Max_current_to_switchDir_cA"), MOD_WRITE|MOD_SAVE, &myMaxTurnCurrent_cA); 98 | #ifdef DETAILED_SERIAL_LOGGING 99 | FieldData::setNext( F("IsDirty"), 0, &myIsDirty); 100 | // FieldData::setNext( F("IsAtSpeed"), 0, &myIsAtSpeed); 101 | FieldData::setNext( F("CurrentUsage_cA"), 0, &myCurrentUsage_cA); 102 | #endif 103 | } 104 | #endif 105 | }; 106 | 107 | -------------------------------------------------------------------------------- /MotorMegaMoto/HalfBridge.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * HalfBridge.cpp 3 | * 4 | * Created on: Mar 31, 2013 5 | * Author: jan 6 | */ 7 | 8 | #include "HalfBridge.h" 9 | #include "FastRunningMedian.h" 10 | 11 | 12 | //FastRunningMedian medianCurrent; 13 | 14 | 15 | /** 16 | * calculatePower calculates the power usage in watt. 17 | * batteryVoltage is the voltage in volt 18 | */ 19 | uint16_t HalfBridge::calculatePower(uint8_t batteryVoltage) const 20 | { 21 | if (myCurrentPin != 255) 22 | { 23 | return (uint16_t) (((uint32_t) myCurrent_cA * (uint32_t) batteryVoltage) / 100UL); //in watts 24 | } 25 | return 0; 26 | } 27 | 28 | void HalfBridge::loop() 29 | { 30 | if (myIsDirty) 31 | { 32 | if ((millis() - MyLastactionTime) >= DRIVE_MOTOR_DELAY ) 33 | { 34 | myIsDirty = (myRequestedSpeed != myActualSpeed); 35 | CalculatenewPWMValuee(); 36 | powerEngine(); 37 | } 38 | } 39 | if (myCurrentPin != 255) 40 | { 41 | // medianCurrent.addValue(analogRead(myCurrentPin)); 42 | // myCurrentPinValue = medianCurrent.getMedian(); 43 | myCurrentPinValue=analogRead(myCurrentPin); 44 | myCurrent_cA = ((uint32_t) myCurrentPinValue * (uint32_t) myMultiplyerValue) / 1000UL; //* (uint32_t) myActualSpeed) / 255000UL; 45 | } 46 | } 47 | 48 | void HalfBridge::CalculatenewPWMValuee()//int ReqValue, int CurValue) myRequestedSpeed, myActualSpeed 49 | { 50 | uint8_t ret=0; 51 | if (myRequestedSpeed > myActualSpeed) 52 | { 53 | ret= min( myActualSpeed + DRIVE_MOTER_MAX_STEP , myRequestedSpeed); 54 | myActualSpeed=(ret 0) 69 | return; 70 | 71 | // Try to buffer up to 32 characters 72 | readPos = 0; 73 | uint8_t cmd[] = {'O', handle, sizeof(buffer)}; 74 | buffered = Bridge.transfer(cmd, 3,0,0,0,0, buffer, sizeof(buffer)); 75 | } 76 | ; 77 | 78 | int read() 79 | // { 80 | // doBuffer(); 81 | // if (buffered == 0) 82 | // return -1; // no chars available 83 | // else { 84 | // buffered--; 85 | // return buffer[readPos++]; 86 | // } 87 | // } 88 | ; 89 | private: 90 | unsigned int handle; 91 | boolean started; 92 | void close() 93 | { 94 | if (started) { 95 | uint8_t cmd[] = {'w', handle}; 96 | Bridge.transfer(cmd, 2,0,0,0,0,0,0); 97 | } 98 | started = false; 99 | } 100 | ; 101 | unsigned int exitValue() 102 | { 103 | uint8_t cmd[] = {'W', handle}; 104 | uint8_t res[2]; 105 | Bridge.transfer(cmd, 2,0,0,0,0, res, 2); 106 | return (res[0] << 8) + res[1]; 107 | } 108 | ; 109 | 110 | 111 | uint8_t buffered; 112 | uint8_t readPos; 113 | static const int BUFFER_SIZE = 64; 114 | uint8_t buffer[BUFFER_SIZE]; 115 | }; 116 | 117 | #endif /* MINIPROCESS_H_ */ 118 | #endif //#ifdef I_USE_MINI_BRIDGE 119 | 120 | -------------------------------------------------------------------------------- /MotorMegaMoto/HalfBridge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HalfBridge.h 3 | * 4 | * Created on: Mar 31, 2013 5 | * Author: jan 6 | */ 7 | 8 | #ifndef HALFBRIDGE_H_ 9 | #define HALFBRIDGE_H_ 10 | #include "Arduino.h" 11 | #include "SerialDataInterface.h" 12 | #include "FieldInfo.h" 13 | #include "PwmFrequency.h" 14 | 15 | #define MINPWM 120 16 | #define DRIVE_MOTER_MAX_STEP 10 17 | #define DRIVE_MOTOR_DELAY 5 18 | //100 is way to slow reaction 19 | // with 10 delay step 30 he is pretty aggressive and the bumper sensors get triggered 20 | // with 20 delay step 30 less aggressive but the bumper still gets triggered from time to time 21 | // with 30 delay step 30 /way to slow cra 22 | // trying 10 delay step 10 fixed bumper being loose seems to help a lot 23 | // was on 30 30 moved to 10 5 for doga motors as mega moto goes in safety 24 | class HalfBridge 25 | { 26 | private: 27 | //pins 28 | uint8_t myPWMPin; 29 | 30 | uint8_t myRequestedSpeed; 31 | uint8_t myActualSpeed; //The PWM value on the myPWMPin 32 | uint32_t MyLastactionTime; 33 | bool myIsDirty; 34 | 35 | uint8_t myCurrentPin; 36 | uint16_t myCurrentPinValue; 37 | uint16_t myCurrent_cA; 38 | uint16_t myMultiplyerValue; //multiplier (factor 1000) for current calc 39 | 40 | 41 | 42 | void powerEngine() 43 | { 44 | analogWrite(myPWMPin, myActualSpeed); 45 | MyLastactionTime = millis(); 46 | } 47 | void CalculatenewPWMValuee(); 48 | 49 | public: 50 | HalfBridge( uint8_t PWMPin, uint8_t CurrentPin); 51 | void serialRegister(const __FlashStringHelper* Name); 52 | 53 | uint8_t getRequestedSpeed() const 54 | { 55 | return myRequestedSpeed; 56 | } 57 | uint8_t getActualSpeed() const 58 | { 59 | return myActualSpeed; 60 | } 61 | 62 | uint16_t getCurrentUsage_cA() const 63 | { 64 | return myCurrent_cA; 65 | } 66 | 67 | bool isDirty() const 68 | { 69 | return myIsDirty; 70 | } 71 | 72 | uint16_t calculatePower(uint8_t batteryVoltage) const; 73 | 74 | #define PRESCALER 1 75 | void setup(Stream &Error) 76 | { 77 | MyLastactionTime = millis(); 78 | pinMode(myPWMPin, OUTPUT); 79 | if (!setPwmFrequency(myPWMPin, PRESCALER)) 80 | { 81 | Error.print( F("failed to set PWM frequency; pin:")); 82 | Error.print(myPWMPin); 83 | Error.print(F(" prescaler : ")); 84 | Error.println(PRESCALER); 85 | } 86 | 87 | } 88 | void loop(); 89 | void setRequestedSpeed(uint8_t Speed); 90 | /** 91 | * Slow down the engine as much as possible to be still save 92 | * return true if the engine is stalled 93 | * return false if the engine is not yet stalled. 94 | * call this method in a loop untill the method returns true to be sure the engine stopped 95 | * 96 | */ 97 | bool emergencyBreak() 98 | { 99 | myIsDirty=false; /*make sure loop does not interfere */ 100 | if ( (myActualSpeed > 0 ) && (millis() -MyLastactionTime >10) ) 101 | { 102 | myRequestedSpeed=myActualSpeed= constrain(myActualSpeed - 30, 0, 255); 103 | powerEngine(); 104 | } 105 | return (myActualSpeed ==0) && ((millis() - MyLastactionTime >200) ); 106 | } 107 | 108 | }; 109 | 110 | #endif /* HALFBRIDGE_H_ */ 111 | -------------------------------------------------------------------------------- /TempMeterDS18B20/examples/mulitple_DS18b20/mulitple_DS18b20.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Example showing how to read 3 DS18B20 temp sensors 3 | * The example is originally written for a mega and uses 4 | * pins 43 45 and 47 when the sensors are all on a 5 | * different pin. 6 | * Pin 43 is used when all sensors are on the same pin. 7 | * You will have to modify the code if you want to use diferent pins. 8 | * 9 | * If speed is important define USE_MAIN_LOOP_MILLIS on the command line. 10 | * When the define is set there will be less calls to millis() which 11 | * will speed up the code 12 | * 13 | * did not get the maximum time spend during a loop to read the 3 sensors 14 | * below 18 millis. If you hit numbers bigger than 20 consider to define 15 | * MAX_MILLIS_IN_LOOP_TO_START as 15 (this way there will never be 2 wire calls in the same loop) 16 | * 17 | */ 18 | #include "Arduino.h" 19 | #include "TempMeterDS18B20.h" 20 | #include "OneWire.h" 21 | uint32_t loopMillis; 22 | uint32_t lastLogMillis; 23 | 24 | //remove define below to test 3 sensors on same pin 25 | #define DIFFERENT_PINS 26 | 27 | #ifdef DIFFERENT_PINS 28 | OneWire oneWireTemp1(43); 29 | TempMeterDS18B20 meter1(oneWireTemp1,0); 30 | 31 | OneWire oneWireTemp2(45); 32 | TempMeterDS18B20 meter2(oneWireTemp2,0); 33 | 34 | OneWire oneWireTemp3(47); 35 | TempMeterDS18B20 meter3(oneWireTemp3,0); 36 | #else 37 | OneWire oneWireTemp(43); 38 | TempMeterDS18B20 meter1(oneWireTemp,0); 39 | 40 | TempMeterDS18B20 meter2(oneWireTemp,1); 41 | 42 | TempMeterDS18B20 meter3(oneWireTemp,2); 43 | 44 | #endif 45 | 46 | 47 | void setup() 48 | { 49 | 50 | Serial.begin(115200); 51 | delay(2000); 52 | Serial.println("Example on using the TempMeterDS18B20 library "); 53 | Serial.println("Originally written for a Mega using pins 47 , 45 , 43"); 54 | meter1.setup(); 55 | meter2.setup(); 56 | meter3.setup(); 57 | } 58 | 59 | int16_t logValue(int16_t prefCelcius,int16_t curCelcius,char meterName[]){ 60 | if(prefCelcius==curCelcius){ 61 | return curCelcius; 62 | } 63 | Serial.print("new temp reading on meter : "); 64 | Serial.print(meterName); 65 | Serial.print(" : "); 66 | Serial.print(curCelcius); 67 | Serial.print(" centi Celcius at "); 68 | Serial.println(loopMillis); 69 | 70 | lastLogMillis=loopMillis; 71 | return curCelcius; 72 | } 73 | 74 | // The loop function is called in an endless loop 75 | void loop() 76 | { 77 | static int16_t prefCelcius1=0; 78 | static int16_t prefCelcius2=0; 79 | static int16_t prefCelcius3=0; 80 | loopMillis=millis(); 81 | meter1.loop(); 82 | meter2.loop(); 83 | meter3.loop(); 84 | 85 | 86 | unsigned long endMillis=millis(); 87 | 88 | prefCelcius1 = logValue(prefCelcius1,meter1.getCentiCelsius(),"celcius1"); 89 | prefCelcius2 = logValue(prefCelcius2,meter2.getCentiCelsius(),"celcius2"); 90 | prefCelcius3 = logValue(prefCelcius3,meter3.getCentiCelsius(),"celcius3"); 91 | 92 | 93 | 94 | if(endMillis-loopMillis>=15){ 95 | Serial.print("getting the temp took: "); 96 | Serial.print(endMillis-loopMillis); 97 | Serial.println(" millis"); 98 | lastLogMillis=loopMillis; 99 | } 100 | if(loopMillis-lastLogMillis>3000){ 101 | //to long no serial output 102 | Serial.println("No meter provided a different value for 3 seconds "); 103 | lastLogMillis=loopMillis; 104 | } 105 | } 106 | --------------------------------------------------------------------------------