├── .gitattributes ├── .gitignore ├── 99-serial-BBB.rules ├── 99-tty-serial.rules ├── AX12_Test ├── AX12_Test.cpp └── makefile ├── Adafruit_GFX.cpp ├── Adafruit_ILI9341B ├── Adafruit_GFX.cpp ├── Adafruit_GFX.h ├── Adafruit_ILI9341B.cpp ├── Adafruit_ILI9341B.h ├── Adafruit_STMPE610.cpp ├── Adafruit_STMPE610.h ├── README.txt ├── glcdfont.cpp └── makefile ├── Adafruit_ILI9341C ├── Adafruit_GFX.cpp ├── Adafruit_GFX.h ├── Adafruit_ILI9341.cpp ├── Adafruit_ILI9341.h ├── Adafruit_STMPE610.cpp ├── Adafruit_STMPE610.h ├── README.txt ├── glcdfont.cpp ├── glcdfont.d └── makefile ├── BBB files └── 99-serial-BBB.rules ├── BioloidEX ├── BioloidEX.cpp ├── BioloidEX.h ├── ReleaseNote.txt ├── ax12.h ├── dxl_hal - Copy.c ├── dxl_hal.cpp ├── dxl_hal.h ├── dynamixel.cpp ├── dynamixel.h └── makefile ├── BioloidEX_Usb2Ax ├── BioloidEX.cpp ├── BioloidEX.h ├── ReleaseNote.txt ├── ax12.h ├── dxl_hal - Copy.c ├── dxl_hal.cpp ├── dxl_hal.h ├── dynamixel.cpp ├── dynamixel.h └── makefile ├── Linux_Speak ├── Speak.cpp └── makefile ├── Phantom_Arm ├── Phantom_Arm.cpp └── makefile ├── Phantom_Arm_USB2EX ├── Phantom_Arm.cpp └── makefile ├── Phantom_Phoenix ├── 99-usb-serial.rules ├── ArduinoDefs.h ├── CommanderTest.cpp ├── Hex_Cfg.h ├── Phantom_Phoenix.cpp ├── Phoenix.h ├── Phoenix_Code.cpp ├── Phoenix_Driver_AX12.cpp ├── Phoenix_Input_Commander.cpp ├── Phoenix_Input_DIYXBee.cpp ├── bcpp.cfg ├── makefile ├── makefile_PhantomX └── makefile_test ├── Phoenix ├── 99-usb-serial.rules ├── ArduinoDefs.h ├── CommanderTest.cpp ├── Hex_Cfg.h ├── Phoenix.h ├── Phoenix_Code.cpp ├── Phoenix_Driver_SSC32.cpp ├── Phoenix_Input_Commander.cpp ├── Phoenix_Input_DIYXBee.cpp ├── PyPoseGen.h ├── PyPoseTest.ppr ├── THex3_Commander_SSC32.cpp ├── bcpp.cfg ├── foo.sh ├── makefile ├── makefile_THSC ├── makefile_THSX ├── makefile_test └── nohup.out ├── Phoenix_fixed ├── PhantomX │ ├── Hex_Cfg.h │ ├── Phantom_Phoenix.cpp │ └── makefile ├── PhantomX_joy │ ├── Hex_Cfg.h │ ├── Phantom_Phoenix.cpp │ └── makefile ├── THR4 │ ├── Hex_Cfg.h │ ├── THR4.cpp │ ├── makefile │ ├── makefile_THSX │ └── makefile_both ├── THex │ ├── Hex_Cfg.h │ ├── THR4.cpp │ ├── THex.cpp │ ├── makefile │ ├── makefile_THSX │ └── makefile_both ├── bcpp.cfg └── src │ ├── ArduinoDefs.h │ ├── Phoenix.h │ ├── Phoenix_Code.cpp │ ├── Phoenix_Driver_AX12.cpp │ ├── Phoenix_Driver_SSC32.cpp │ ├── Phoenix_Input_Commander.cpp │ ├── Phoenix_Input_DIYXBee.cpp │ ├── Phoenix_Input_Joystick.cpp │ └── Phoenix_Input_PS3.cpp ├── Phoenix_float ├── PhantomX │ ├── Hex_Cfg.h │ ├── Phantom_Phoenix.cpp │ └── makefile ├── THR4 │ ├── Hex_Cfg.h │ ├── THR4.cpp │ ├── makefile │ ├── makefile_THSX │ └── makefile_both ├── THex │ ├── Hex_Cfg.h │ ├── THR4.cpp │ ├── THex.cpp │ ├── makefile │ ├── makefile_THSX │ └── makefile_both ├── bcpp.cfg └── src │ ├── ArduinoDefs.h │ ├── Phoenix.h │ ├── Phoenix_Code.cpp │ ├── Phoenix_Driver_AX12.cpp │ ├── Phoenix_Driver_SSC32.cpp │ ├── Phoenix_Input_Commander.cpp │ ├── Phoenix_Input_DIYXBee.cpp │ └── Phoenix_Tables_and_Defines.h ├── Readme.md ├── Rover ├── Rover.cpp ├── Rover_Config.h └── makefile ├── TestJoystick ├── Joystick.cpp └── makefile ├── TestMraaPing.cpp ├── TestMraaPing ├── TestMraaPing.cpp └── makefile ├── Visual Studio 2012 └── Wifi Commander │ ├── Wifi Commander.sln │ └── Wifi Commander │ ├── App.config │ ├── Form1.Designer.vb │ ├── Form1.resx │ ├── Form1.vb │ ├── My Project │ ├── Application.Designer.vb │ ├── Application.myapp │ ├── AssemblyInfo.vb │ ├── Resources.Designer.vb │ ├── Resources.resx │ ├── Settings.Designer.vb │ └── Settings.settings │ └── Wifi Commander.vbproj ├── library ├── ArduinoDefs.h ├── CommanderEx.cpp ├── CommanderEx.h ├── JoystickController.cpp ├── JoystickController.h ├── PWM.cpp ├── PWM.h ├── Print.cpp ├── Print.h ├── Printable.h ├── RoboClaw.cpp ├── RoboClaw.h ├── Stream.cpp ├── Stream.h ├── Wiring.cpp ├── WrapperSerial.cpp ├── WrapperSerial.h ├── diyxbee.cpp ├── diyxbee.h └── makefile ├── library_extras ├── SDRFunctions.cpp ├── SDRFunctions.h ├── libPortExtras.a ├── makefile ├── msound.cpp ├── msound.h ├── speak.cpp └── speak.h ├── ntpdate └── ntpdate.c ├── testAdafruit_ILI9341B ├── cls.cpp ├── graphictest.cpp ├── makefile ├── readpixel.cpp └── touchpaint.cpp ├── testAdafruit_ILI9341C ├── cls.cpp ├── graphictest.cpp ├── makefile ├── readpixel.cpp └── touchpaint.cpp ├── testCMPS03 ├── makefile └── testCMPS03.cpp ├── testPCM ├── makefile └── testPCM.cpp ├── testPWM ├── BasicPWMExample.cpp ├── Motor.h ├── MotorExample.cpp └── makefile ├── testRoboClaw ├── makefile └── testRClaw.cpp ├── testSSC32 ├── makefile └── testSSC32.cpp └── testUPLeds ├── 50-leds.rules ├── makefile └── testUPLeds.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | [Dd]ebug/ 46 | [Rr]elease/ 47 | *_i.c 48 | *_p.c 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.vspscc 63 | .builds 64 | *.dotCover 65 | *.o 66 | *.d 67 | 68 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 69 | #packages/ 70 | 71 | # Visual C++ cache files 72 | ipch/ 73 | *.aps 74 | *.ncb 75 | *.opensdf 76 | *.sdf 77 | 78 | # Visual Studio profiler 79 | *.psess 80 | *.vsp 81 | 82 | # ReSharper is a .NET coding add-in 83 | _ReSharper* 84 | 85 | # Installshield output folder 86 | [Ee]xpress 87 | 88 | # DocProject is a documentation generator add-in 89 | DocProject/buildhelp/ 90 | DocProject/Help/*.HxT 91 | DocProject/Help/*.HxC 92 | DocProject/Help/*.hhc 93 | DocProject/Help/*.hhk 94 | DocProject/Help/*.hhp 95 | DocProject/Help/Html2 96 | DocProject/Help/html 97 | 98 | # Click-Once directory 99 | publish 100 | 101 | # Others 102 | [Bb]in 103 | [Oo]bj 104 | sql 105 | TestResults 106 | *.Cache 107 | ClientBin 108 | stylecop.* 109 | ~$* 110 | *.dbmdl 111 | Generated_Code #added for RIA/Silverlight projects 112 | 113 | # Backup & report files from converting an old project file to a newer 114 | # Visual Studio version. Backup files are not needed, because we have git ;-) 115 | _UpgradeReport_Files/ 116 | Backup*/ 117 | UpgradeLog*.XML 118 | 119 | 120 | 121 | ############ 122 | ## Windows 123 | ############ 124 | 125 | # Windows image file caches 126 | Thumbs.db 127 | 128 | # Folder config file 129 | Desktop.ini 130 | 131 | 132 | ############# 133 | ## Python 134 | ############# 135 | 136 | *.py[co] 137 | 138 | # Packages 139 | *.egg 140 | *.egg-info 141 | dist 142 | build 143 | eggs 144 | parts 145 | bin 146 | var 147 | sdist 148 | develop-eggs 149 | .installed.cfg 150 | 151 | # Installer logs 152 | pip-log.txt 153 | 154 | # Unit test / coverage reports 155 | .coverage 156 | .tox 157 | 158 | #Translations 159 | *.mo 160 | 161 | #Mr Developer 162 | .mr.developer.cfg 163 | 164 | # Mac crap 165 | .DS_Store 166 | -------------------------------------------------------------------------------- /99-serial-BBB.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM=="tty", ATTRS{port}=="0x0", ATTRS{line}=="1", SYMLINK+="ttyXBEE" 2 | SUBSYSTEM=="tty", ATTRS{port}=="0x0", ATTRS{line}=="2", SYMLINK+="ttyRCLAW" 3 | -------------------------------------------------------------------------------- /99-tty-serial.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM=="tty", KERNEL=="ttyO1", SYMLINK+="ttyXBEE" 2 | SUBSYSTEM=="tty", KERNEL=="ttyO2", SYMLINK+="ttySSC-32" 3 | 4 | 5 | -------------------------------------------------------------------------------- /AX12_Test/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = AX12_Test 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | AX12_Test.cpp 7 | 8 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 9 | 10 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 11 | 12 | #~~~~~~~~~~~~ Which version of USB2AX am I using ~~~~~~~~~~~~ 13 | BIOLOIDEX = BioloidEX 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 16 | INCLUDE_DIRS = -I. -I../library -I../$(BIOLOIDEX) 17 | 18 | 19 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 20 | ifeq ($(OSTYPE),linux-gnueabi) 21 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../$(BIOLOIDEX) -L../library 22 | else 23 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../$(BIOLOIDEX) -L../library 24 | endif 25 | 26 | 27 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 28 | COMPILE_OPTS = -pedantic -g -O2 -fno-rtti -Wno-write-strings 29 | 30 | 31 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 32 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lrt 33 | 34 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 35 | ifeq ($(OSTYPE),linux-gnueabi) 36 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 37 | else 38 | ifeq ($(OSTYPE),Edison) 39 | #Edison hard coded OSTYPE 40 | TCHAIN_PREFIX=i586-poky-linux- 41 | else 42 | #TCHAIN_PREFIX=arm-linux-gnueabihf- 43 | TCHAIN_PREFIX= 44 | endif 45 | endif 46 | #TCHAIN_PREFIX=x86_64-linux-gnu- 47 | 48 | CXX = $(TCHAIN_PREFIX)g++ 49 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 50 | 51 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 52 | 53 | all: LIBRARY $(BIOLOIDEX) begin gccversion build end 54 | 55 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 56 | LIBRARY: 57 | cd ../library; $(MAKE) 58 | 59 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 60 | $(BIOLOIDEX): 61 | cd ../$(BIOLOIDEX); $(MAKE) 62 | 63 | 64 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 65 | 66 | 67 | build: $(MAIN_OUT) 68 | 69 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a ../$(BIOLOIDEX)/libBioloidEX.a 70 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 71 | 72 | MSG_BEGIN = -------- begin -------- 73 | MSG_END = -------- end -------- 74 | 75 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 76 | begin: 77 | @echo 78 | @echo $(MSG_BEGIN) 79 | 80 | end: 81 | @echo $(MSG_END) 82 | @echo 83 | 84 | gccversion: 85 | @$(CC) --version 86 | 87 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 88 | clean: begin clean_list end 89 | 90 | clean_list: 91 | -rm $(MAIN_OBJS) 92 | -rm $(MAIN_OUT) 93 | -rm $(MAIN_DEPS) 94 | -cd ../library ; make clean 95 | -cd ../$(BIOLOIDEX) ; make clean 96 | 97 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 98 | backup: clean 99 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 100 | 101 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 102 | include $(subst .cpp,.d,$(SOURCES)) 103 | 104 | %.d: %.cpp 105 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 106 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 107 | rm -f $@.$$$$ 108 | -------------------------------------------------------------------------------- /Adafruit_ILI9341B/Adafruit_GFX.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADAFRUIT_GFX_H 2 | #define _ADAFRUIT_GFX_H 3 | #include "ArduinoDefs.h" 4 | #include "Print.h" 5 | 6 | #define swap(a, b) { int16_t t = a; a = b; b = t; } 7 | 8 | class Adafruit_GFX : public Print { 9 | 10 | public: 11 | 12 | Adafruit_GFX(int16_t w, int16_t h); // Constructor 13 | 14 | // This MUST be defined by the subclass: 15 | virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; 16 | 17 | // These MAY be overridden by the subclass to provide device-specific 18 | // optimized code. Otherwise 'generic' versions are used. 19 | virtual void 20 | drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color), 21 | drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), 22 | drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), 23 | drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 24 | fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 25 | fillScreen(uint16_t color), 26 | drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, 27 | uint16_t bg, uint8_t size), 28 | invertDisplay(boolean i); 29 | 30 | // These exist only with Adafruit_GFX (no subclass overrides) 31 | void 32 | drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 33 | drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, 34 | uint16_t color), 35 | fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 36 | fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, 37 | int16_t delta, uint16_t color), 38 | drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 39 | int16_t x2, int16_t y2, uint16_t color), 40 | fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 41 | int16_t x2, int16_t y2, uint16_t color), 42 | drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 43 | int16_t radius, uint16_t color), 44 | fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 45 | int16_t radius, uint16_t color), 46 | drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, 47 | int16_t w, int16_t h, uint16_t color), 48 | setCursor(int16_t x, int16_t y), 49 | setTextColor(uint16_t c), 50 | setTextColor(uint16_t c, uint16_t bg), 51 | setTextSize(uint8_t s), 52 | setTextWrap(boolean w), 53 | setRotation(uint8_t r); 54 | 55 | virtual size_t write(uint8_t); 56 | 57 | int16_t 58 | height(void), 59 | width(void); 60 | 61 | uint8_t getRotation(void); 62 | 63 | protected: 64 | const int16_t 65 | WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes 66 | int16_t 67 | _width, _height, // Display w/h as modified by current rotation 68 | cursor_x, cursor_y; 69 | uint16_t 70 | textcolor, textbgcolor; 71 | uint8_t 72 | textsize, 73 | rotation; 74 | boolean 75 | wrap; // If set, 'wrap' text at right edge of display 76 | static const unsigned char font[]; 77 | }; 78 | 79 | #endif // _ADAFRUIT_GFX_H 80 | -------------------------------------------------------------------------------- /Adafruit_ILI9341B/README.txt: -------------------------------------------------------------------------------- 1 | This is a library for the Adafruit ILI9341 display products 2 | 3 | This library works with the Adafruit 2.8" Touch Shield V2 (SPI) 4 | ----> http://www.adafruit.com/products/1651 5 | 6 | Check out the links above for our tutorials and wiring diagrams. 7 | These displays use SPI to communicate, 4 or 5 pins are required 8 | to interface (RST is optional). 9 | 10 | Adafruit invests time and resources providing this open source code, 11 | please support Adafruit and open-source hardware by purchasing 12 | products from Adafruit! 13 | 14 | Written by Limor Fried/Ladyada for Adafruit Industries. 15 | MIT license, all text above must be included in any redistribution 16 | 17 | To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_ILI9341. Check that the Adafruit_ILI9341 folder contains Adafruit_ILI9341.cpp and Adafruit_ILI9341. 18 | 19 | Place the Adafruit_ILI9341 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE 20 | 21 | Also requires the Adafruit_GFX library for Arduino. 22 | -------------------------------------------------------------------------------- /Adafruit_ILI9341B/makefile: -------------------------------------------------------------------------------- 1 | #try to create a static library of code for me to use for different programs 2 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 3 | MAIN_OUT = libAdafruit_ILI9341B.a 4 | 5 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 6 | COMMON_SOURCES = \ 7 | Adafruit_GFX.cpp \ 8 | Adafruit_ILI9341B.cpp \ 9 | Adafruit_STMPE610.cpp 10 | 11 | SOURCES = $(COMMON_SOURCES) $(EXTRA_SOURCES) 12 | 13 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 14 | 15 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 16 | 17 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 18 | INCLUDE_DIRS = -I. -I../library 19 | 20 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 21 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 22 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 23 | 24 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 25 | 26 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 27 | ifeq ($(OSTYPE),linux-gnueabi) 28 | #BBBk 29 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 30 | else 31 | ifeq ($(OSTYPE),Edison) 32 | #Edison hard coded OSTYPE 33 | TCHAIN_PREFIX=i586-poky-linux- 34 | else 35 | #RPI 36 | TCHAIN_PREFIX=arm-linux-gnueabihf- 37 | endif 38 | endif 39 | #TCHAIN_PREFIX=x86_64-linux-gnu- 40 | TCHAIN_PREFIX= 41 | 42 | CXX = $(TCHAIN_PREFIX)g++ 43 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 44 | AR = ar 45 | ARFLAGS = rcs 46 | 47 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 48 | all: begin gccversion build end 49 | 50 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 51 | build: $(MAIN_OUT) 52 | 53 | $(MAIN_OUT): $(MAIN_OBJS) 54 | $(AR) $(ARFLAGS) $(MAIN_OUT) $(MAIN_OBJS) 55 | 56 | MSG_BEGIN = -------- begin -------- 57 | MSG_END = -------- end -------- 58 | 59 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 60 | begin: 61 | @echo 62 | @echo $(MSG_BEGIN) 63 | @echo ${OSTYPE} 64 | 65 | end: 66 | @echo $(MSG_END) 67 | @echo 68 | 69 | gccversion: 70 | @$(CC) --version 71 | 72 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 73 | clean: begin clean_list end 74 | 75 | clean_list: 76 | -rm -f $(MAIN_OBJS) 77 | -rm -f $(MAIN_OUT) 78 | -rm -f $(MAIN_DEPS) 79 | 80 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 81 | backup: clean 82 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 85 | include $(subst .cpp,.d,$(SOURCES)) 86 | 87 | %.d: %.cpp 88 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 89 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 90 | rm -f $@.$$$$ 91 | -------------------------------------------------------------------------------- /Adafruit_ILI9341C/Adafruit_GFX.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADAFRUIT_GFX_H 2 | #define _ADAFRUIT_GFX_H 3 | #include "ArduinoDefs.h" 4 | #include "Print.h" 5 | 6 | #define swap(a, b) { int16_t t = a; a = b; b = t; } 7 | 8 | class Adafruit_GFX : public Print { 9 | 10 | public: 11 | 12 | Adafruit_GFX(int16_t w, int16_t h); // Constructor 13 | 14 | // This MUST be defined by the subclass: 15 | virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; 16 | 17 | // These MAY be overridden by the subclass to provide device-specific 18 | // optimized code. Otherwise 'generic' versions are used. 19 | virtual void 20 | drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color), 21 | drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), 22 | drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), 23 | drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 24 | fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 25 | fillScreen(uint16_t color), 26 | drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, 27 | uint16_t bg, uint8_t size), 28 | invertDisplay(boolean i); 29 | 30 | // These exist only with Adafruit_GFX (no subclass overrides) 31 | void 32 | drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 33 | drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, 34 | uint16_t color), 35 | fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 36 | fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, 37 | int16_t delta, uint16_t color), 38 | drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 39 | int16_t x2, int16_t y2, uint16_t color), 40 | fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 41 | int16_t x2, int16_t y2, uint16_t color), 42 | drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 43 | int16_t radius, uint16_t color), 44 | fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 45 | int16_t radius, uint16_t color), 46 | drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, 47 | int16_t w, int16_t h, uint16_t color), 48 | setCursor(int16_t x, int16_t y), 49 | setTextColor(uint16_t c), 50 | setTextColor(uint16_t c, uint16_t bg), 51 | setTextSize(uint8_t s), 52 | setTextWrap(boolean w), 53 | setRotation(uint8_t r); 54 | 55 | virtual size_t write(uint8_t); 56 | 57 | int16_t 58 | height(void), 59 | width(void); 60 | 61 | uint8_t getRotation(void); 62 | 63 | protected: 64 | const int16_t 65 | WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes 66 | int16_t 67 | _width, _height, // Display w/h as modified by current rotation 68 | cursor_x, cursor_y; 69 | uint16_t 70 | textcolor, textbgcolor; 71 | uint8_t 72 | textsize, 73 | rotation; 74 | boolean 75 | wrap; // If set, 'wrap' text at right edge of display 76 | static const unsigned char font[]; 77 | }; 78 | 79 | #endif // _ADAFRUIT_GFX_H 80 | -------------------------------------------------------------------------------- /Adafruit_ILI9341C/Adafruit_ILI9341.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KurtE/Raspberry_Pi/515f138ecb2ca2c0e96b7343ccf14b87653faaad/Adafruit_ILI9341C/Adafruit_ILI9341.cpp -------------------------------------------------------------------------------- /Adafruit_ILI9341C/README.txt: -------------------------------------------------------------------------------- 1 | This is a library for the Adafruit ILI9341 display products 2 | 3 | This library works with the Adafruit 2.8" Touch Shield V2 (SPI) 4 | ----> http://www.adafruit.com/products/1651 5 | 6 | Check out the links above for our tutorials and wiring diagrams. 7 | These displays use SPI to communicate, 4 or 5 pins are required 8 | to interface (RST is optional). 9 | 10 | Adafruit invests time and resources providing this open source code, 11 | please support Adafruit and open-source hardware by purchasing 12 | products from Adafruit! 13 | 14 | Written by Limor Fried/Ladyada for Adafruit Industries. 15 | MIT license, all text above must be included in any redistribution 16 | 17 | To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_ILI9341. Check that the Adafruit_ILI9341 folder contains Adafruit_ILI9341.cpp and Adafruit_ILI9341. 18 | 19 | Place the Adafruit_ILI9341 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE 20 | 21 | Also requires the Adafruit_GFX library for Arduino. 22 | -------------------------------------------------------------------------------- /Adafruit_ILI9341C/glcdfont.d: -------------------------------------------------------------------------------- 1 | glcdfont.o glcdfont.d : glcdfont.cpp /usr/include/stdc-predef.h 2 | -------------------------------------------------------------------------------- /Adafruit_ILI9341C/makefile: -------------------------------------------------------------------------------- 1 | #try to create a static library of code for me to use for different programs 2 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 3 | MAIN_OUT = libAdafruit_ILI9341C.a 4 | 5 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 6 | COMMON_SOURCES = \ 7 | Adafruit_GFX.cpp \ 8 | Adafruit_ILI9341.cpp \ 9 | Adafruit_STMPE610.cpp 10 | 11 | SOURCES = $(COMMON_SOURCES) $(EXTRA_SOURCES) 12 | 13 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 14 | 15 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 16 | 17 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 18 | INCLUDE_DIRS = -I. -I../library 19 | 20 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 21 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 22 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 23 | 24 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 25 | 26 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 27 | ifeq ($(OSTYPE),linux-gnueabi) 28 | #BBBk 29 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 30 | else 31 | ifeq ($(OSTYPE),Edison) 32 | #Edison hard coded OSTYPE 33 | TCHAIN_PREFIX=i586-poky-linux- 34 | else 35 | #RPI 36 | TCHAIN_PREFIX=arm-linux-gnueabihf- 37 | endif 38 | endif 39 | #TCHAIN_PREFIX=x86_64-linux-gnu- 40 | TCHAIN_PREFIX= 41 | 42 | CXX = $(TCHAIN_PREFIX)g++ 43 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 44 | AR = ar 45 | ARFLAGS = rcs 46 | 47 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 48 | all: begin gccversion build end 49 | 50 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 51 | build: $(MAIN_OUT) 52 | 53 | $(MAIN_OUT): $(MAIN_OBJS) 54 | $(AR) $(ARFLAGS) $(MAIN_OUT) $(MAIN_OBJS) 55 | 56 | MSG_BEGIN = -------- begin -------- 57 | MSG_END = -------- end -------- 58 | 59 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 60 | begin: 61 | @echo 62 | @echo $(MSG_BEGIN) 63 | @echo ${OSTYPE} 64 | 65 | end: 66 | @echo $(MSG_END) 67 | @echo 68 | 69 | gccversion: 70 | @$(CC) --version 71 | 72 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 73 | clean: begin clean_list end 74 | 75 | clean_list: 76 | -rm -f $(MAIN_OBJS) 77 | -rm -f $(MAIN_OUT) 78 | -rm -f $(MAIN_DEPS) 79 | 80 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 81 | backup: clean 82 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 85 | include $(subst .cpp,.d,$(SOURCES)) 86 | 87 | %.d: %.cpp 88 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 89 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 90 | rm -f $@.$$$$ 91 | -------------------------------------------------------------------------------- /BBB files/99-serial-BBB.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM=="tty", ATTRS{port}=="0x0", ATTRS{line}=="1", SYMLINK+="ttyXBEE" 2 | SUBSYSTEM=="tty", ATTRS{port}=="0x0", ATTRS{line}=="2", SYMLINK+="ttyRCLAW" 3 | -------------------------------------------------------------------------------- /BioloidEX/ReleaseNote.txt: -------------------------------------------------------------------------------- 1 | ================================================= 2 | Dynamixel SDK for platform porting v1.01 3 | ================================================= 4 | 5 | - Fixed bug that status packet included error flag is treated "RX_TIMEOUT". 6 | 7 | 8 | ================================================= 9 | Dynamixel SDK for platform porting v1.00 10 | ================================================= 11 | 12 | - First released -------------------------------------------------------------------------------- /BioloidEX/dxl_hal - Copy.c: -------------------------------------------------------------------------------- 1 | // Dynamixel SDK platform dependent source 2 | #include "dxl_hal.h" 3 | 4 | 5 | int dxl_hal_open( int devIndex, float baudrate ) 6 | { 7 | // Opening device 8 | // devIndex: Device index 9 | // baudrate: Real baudrate (ex> 115200, 57600, 38400...) 10 | // Return: 0(Failed), 1(Succeed) 11 | 12 | } 13 | 14 | void dxl_hal_close() 15 | { 16 | // Closing device 17 | 18 | } 19 | 20 | void dxl_hal_clear(void) 21 | { 22 | // Clear communication buffer 23 | 24 | } 25 | 26 | int dxl_hal_tx( unsigned char *pPacket, int numPacket ) 27 | { 28 | // Transmiting date 29 | // *pPacket: data array pointer 30 | // numPacket: number of data array 31 | // Return: number of data transmitted. -1 is error. 32 | 33 | } 34 | 35 | int dxl_hal_rx( unsigned char *pPacket, int numPacket ) 36 | { 37 | // Recieving date 38 | // *pPacket: data array pointer 39 | // numPacket: number of data array 40 | // Return: number of data recieved. -1 is error. 41 | 42 | } 43 | 44 | void dxl_hal_set_timeout( int NumRcvByte ) 45 | { 46 | // Start stop watch 47 | // NumRcvByte: number of recieving data(to calculate maximum waiting time) 48 | 49 | } 50 | 51 | int dxl_hal_timeout(void) 52 | { 53 | // Check timeout 54 | // Return: 0 is false, 1 is true(timeout occurred) 55 | 56 | } -------------------------------------------------------------------------------- /BioloidEX/dxl_hal.h: -------------------------------------------------------------------------------- 1 | // Dynamixel SDK platform dependent header 2 | #ifndef _DYNAMIXEL_HAL_HEADER 3 | #define _DYNAMIXEL_HAL_HEADER 4 | 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | 11 | int dxl_hal_open( int devIndex, float baudrate ); 12 | void dxl_hal_close(void); 13 | void dxl_hal_clear(void); 14 | void dxl_hal_flush(void); 15 | int dxl_hal_tx( unsigned char *pPacket, int numPacket ); 16 | int dxl_hal_rx( unsigned char *pPacket, int numPacket ); 17 | void dxl_hal_set_timeout( int NumRcvByte ); 18 | int dxl_hal_timeout(void); 19 | 20 | 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /BioloidEX/dynamixel.h: -------------------------------------------------------------------------------- 1 | // Dynamixel SDK platform independent header 2 | #ifndef _DYNAMIXEL_HEADER 3 | #define _DYNAMIXEL_HEADER 4 | 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | 11 | ///////////// device control methods //////////////////////// 12 | int dxl_initialize( int devIndex, int baudnum ); 13 | int dxl_initializeBaud( int devIndex, float baudrate ); 14 | void dxl_terminate(void); 15 | 16 | 17 | ///////////// set/get packet methods ////////////////////////// 18 | void dxl_set_txpacket_id( int id ); 19 | #define BROADCAST_ID (254) 20 | 21 | void dxl_set_txpacket_instruction( int instruction ); 22 | #define INST_PING (1) 23 | #define INST_READ (2) 24 | #define INST_WRITE (3) 25 | #define INST_REG_WRITE (4) 26 | #define INST_ACTION (5) 27 | #define INST_RESET (6) 28 | #define INST_SYNC_WRITE (131) 29 | #define INST_SYNC_READ (0x84) 30 | 31 | #define MAXNUM_TXPARAM (150) 32 | void dxl_set_txpacket_parameter( int index, int value ); 33 | void dxl_set_txpacket_length( int length ); 34 | 35 | int dxl_get_rxpacket_error( int errbit ); 36 | #define ERRBIT_VOLTAGE (1) 37 | #define ERRBIT_ANGLE (2) 38 | #define ERRBIT_OVERHEAT (4) 39 | #define ERRBIT_RANGE (8) 40 | #define ERRBIT_CHECKSUM (16) 41 | #define ERRBIT_OVERLOAD (32) 42 | #define ERRBIT_INSTRUCTION (64) 43 | 44 | #define MAXNUM_RXPARAM (60) 45 | int dxl_get_rxpacket_parameter( int index ); 46 | int dxl_get_rxpacket_length(void); 47 | 48 | // utility for value 49 | int dxl_makeword( int lowbyte, int highbyte ); 50 | int dxl_get_lowbyte( int word ); 51 | int dxl_get_highbyte( int word ); 52 | 53 | 54 | ////////// packet communication methods /////////////////////// 55 | void dxl_tx_packet(void); 56 | void dxl_rx_packet(void); 57 | void dxl_txrx_packet(void); 58 | 59 | int dxl_get_result(void); 60 | #define COMM_TXSUCCESS (0) 61 | #define COMM_RXSUCCESS (1) 62 | #define COMM_TXFAIL (2) 63 | #define COMM_RXFAIL (3) 64 | #define COMM_TXERROR (4) 65 | #define COMM_RXWAITING (5) 66 | #define COMM_RXTIMEOUT (6) 67 | #define COMM_RXCORRUPT (7) 68 | 69 | 70 | //////////// high communication methods /////////////////////// 71 | void dxl_ping( int id ); 72 | int dxl_read_byte( int id, int address ); 73 | void dxl_write_byte( int id, int address, int value ); 74 | int dxl_read_word( int id, int address ); 75 | void dxl_write_word( int id, int address, int value ); 76 | 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif -------------------------------------------------------------------------------- /BioloidEX/makefile: -------------------------------------------------------------------------------- 1 | #try to create a static library of code for me to use for different programs 2 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 3 | MAIN_OUT = libBioloidEX.a 4 | 5 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 6 | COMMON_SOURCES = \ 7 | BioloidEX.cpp \ 8 | dxl_hal.cpp \ 9 | dynamixel.cpp 10 | 11 | SOURCES = $(COMMON_SOURCES) $(EXTRA_SOURCES) 12 | 13 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 14 | 15 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 16 | 17 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 18 | ifeq ($(OSTYPE),linux-gnueabi) 19 | INCLUDE_DIRS = -I. 20 | 21 | else 22 | INCLUDE_DIRS = -I. 23 | endif 24 | 25 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 26 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 27 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 28 | 29 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 30 | 31 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 32 | ifeq ($(OSTYPE),linux-gnueabi) 33 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 34 | else 35 | ifeq ($(OSTYPE),Edison) 36 | #Edison hard coded OSTYPE 37 | TCHAIN_PREFIX=i586-poky-linux- 38 | else 39 | #TCHAIN_PREFIX=arm-linux-gnueabihf- 40 | TCHAIN_PREFIX= 41 | endif 42 | endif 43 | #TCHAIN_PREFIX=x86_64-linux-gnu- 44 | 45 | CXX = $(TCHAIN_PREFIX)g++ 46 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 47 | AR = ar 48 | ARFLAGS = rcs 49 | 50 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 51 | all: begin gccversion build end 52 | 53 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 54 | build: $(MAIN_OUT) 55 | 56 | $(MAIN_OUT): $(MAIN_OBJS) 57 | $(AR) $(ARFLAGS) $(MAIN_OUT) $(MAIN_OBJS) 58 | 59 | MSG_BEGIN = -------- begin -------- 60 | MSG_END = -------- end -------- 61 | 62 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 63 | begin: 64 | @echo 65 | @echo $(MSG_BEGIN) 66 | @echo ${OSTYPE} 67 | 68 | end: 69 | @echo $(MSG_END) 70 | @echo 71 | 72 | gccversion: 73 | @$(CC) --version 74 | 75 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 76 | clean: begin clean_list end 77 | 78 | clean_list: 79 | -rm -f $(MAIN_OBJS) 80 | -rm -f $(MAIN_OUT) 81 | -rm -f $(MAIN_DEPS) 82 | 83 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 84 | backup: clean 85 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 86 | 87 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 88 | include $(subst .cpp,.d,$(SOURCES)) 89 | 90 | %.d: %.cpp 91 | $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ 92 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 93 | rm -f $@.$$$$ 94 | -------------------------------------------------------------------------------- /BioloidEX_Usb2Ax/ReleaseNote.txt: -------------------------------------------------------------------------------- 1 | ================================================= 2 | Dynamixel SDK for platform porting v1.01 3 | ================================================= 4 | 5 | - Fixed bug that status packet included error flag is treated "RX_TIMEOUT". 6 | 7 | 8 | ================================================= 9 | Dynamixel SDK for platform porting v1.00 10 | ================================================= 11 | 12 | - First released -------------------------------------------------------------------------------- /BioloidEX_Usb2Ax/dxl_hal - Copy.c: -------------------------------------------------------------------------------- 1 | // Dynamixel SDK platform dependent source 2 | #include "dxl_hal.h" 3 | 4 | 5 | int dxl_hal_open( int devIndex, float baudrate ) 6 | { 7 | // Opening device 8 | // devIndex: Device index 9 | // baudrate: Real baudrate (ex> 115200, 57600, 38400...) 10 | // Return: 0(Failed), 1(Succeed) 11 | 12 | } 13 | 14 | void dxl_hal_close() 15 | { 16 | // Closing device 17 | 18 | } 19 | 20 | void dxl_hal_clear(void) 21 | { 22 | // Clear communication buffer 23 | 24 | } 25 | 26 | int dxl_hal_tx( unsigned char *pPacket, int numPacket ) 27 | { 28 | // Transmiting date 29 | // *pPacket: data array pointer 30 | // numPacket: number of data array 31 | // Return: number of data transmitted. -1 is error. 32 | 33 | } 34 | 35 | int dxl_hal_rx( unsigned char *pPacket, int numPacket ) 36 | { 37 | // Recieving date 38 | // *pPacket: data array pointer 39 | // numPacket: number of data array 40 | // Return: number of data recieved. -1 is error. 41 | 42 | } 43 | 44 | void dxl_hal_set_timeout( int NumRcvByte ) 45 | { 46 | // Start stop watch 47 | // NumRcvByte: number of recieving data(to calculate maximum waiting time) 48 | 49 | } 50 | 51 | int dxl_hal_timeout(void) 52 | { 53 | // Check timeout 54 | // Return: 0 is false, 1 is true(timeout occurred) 55 | 56 | } -------------------------------------------------------------------------------- /BioloidEX_Usb2Ax/dxl_hal.h: -------------------------------------------------------------------------------- 1 | // Dynamixel SDK platform dependent header 2 | #ifndef _DYNAMIXEL_HAL_HEADER 3 | #define _DYNAMIXEL_HAL_HEADER 4 | 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | 11 | int dxl_hal_open( int devIndex, float baudrate ); 12 | void dxl_hal_close(void); 13 | void dxl_hal_clear(void); 14 | int dxl_hal_tx( unsigned char *pPacket, int numPacket ); 15 | int dxl_hal_rx( unsigned char *pPacket, int numPacket ); 16 | void dxl_hal_set_timeout( int NumRcvByte ); 17 | int dxl_hal_timeout(void); 18 | 19 | 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /BioloidEX_Usb2Ax/dynamixel.h: -------------------------------------------------------------------------------- 1 | // Dynamixel SDK platform independent header 2 | #ifndef _DYNAMIXEL_HEADER 3 | #define _DYNAMIXEL_HEADER 4 | 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | 11 | ///////////// device control methods //////////////////////// 12 | int dxl_initialize( int devIndex, int baudnum ); 13 | void dxl_terminate(void); 14 | 15 | 16 | ///////////// set/get packet methods ////////////////////////// 17 | void dxl_set_txpacket_id( int id ); 18 | #define BROADCAST_ID (254) 19 | 20 | void dxl_set_txpacket_instruction( int instruction ); 21 | #define INST_PING (1) 22 | #define INST_READ (2) 23 | #define INST_WRITE (3) 24 | #define INST_REG_WRITE (4) 25 | #define INST_ACTION (5) 26 | #define INST_RESET (6) 27 | #define INST_SYNC_WRITE (131) 28 | 29 | // Added for USB2AX 30 | #define INST_SYNC_READ (0x84) 31 | #define INST_READ_POSE (0x85) 32 | #define INST_POSE_IDS (0x86) 33 | #define INST_POSE_MASK (0x87) 34 | #define INST_POSE_ABORT (0x88) 35 | 36 | #define MAXNUM_TXPARAM (150) 37 | void dxl_set_txpacket_parameter( int index, int value ); 38 | void dxl_set_txpacket_length( int length ); 39 | 40 | int dxl_get_rxpacket_error( int errbit ); 41 | #define ERRBIT_VOLTAGE (1) 42 | #define ERRBIT_ANGLE (2) 43 | #define ERRBIT_OVERHEAT (4) 44 | #define ERRBIT_RANGE (8) 45 | #define ERRBIT_CHECKSUM (16) 46 | #define ERRBIT_OVERLOAD (32) 47 | #define ERRBIT_INSTRUCTION (64) 48 | 49 | #define MAXNUM_RXPARAM (60) 50 | int dxl_get_rxpacket_parameter( int index ); 51 | int dxl_get_rxpacket_length(void); 52 | 53 | // utility for value 54 | int dxl_makeword( int lowbyte, int highbyte ); 55 | int dxl_get_lowbyte( int word ); 56 | int dxl_get_highbyte( int word ); 57 | 58 | 59 | ////////// packet communication methods /////////////////////// 60 | void dxl_tx_packet(void); 61 | void dxl_rx_packet(void); 62 | void dxl_txrx_packet(void); 63 | 64 | int dxl_get_result(void); 65 | #define COMM_TXSUCCESS (0) 66 | #define COMM_RXSUCCESS (1) 67 | #define COMM_TXFAIL (2) 68 | #define COMM_RXFAIL (3) 69 | #define COMM_TXERROR (4) 70 | #define COMM_RXWAITING (5) 71 | #define COMM_RXTIMEOUT (6) 72 | #define COMM_RXCORRUPT (7) 73 | 74 | 75 | //////////// high communication methods /////////////////////// 76 | void dxl_ping( int id ); 77 | int dxl_read_byte( int id, int address ); 78 | void dxl_write_byte( int id, int address, int value ); 79 | int dxl_read_word( int id, int address ); 80 | void dxl_write_word( int id, int address, int value ); 81 | 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif -------------------------------------------------------------------------------- /BioloidEX_Usb2Ax/makefile: -------------------------------------------------------------------------------- 1 | #try to create a static library of code for me to use for different programs 2 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 3 | MAIN_OUT = libBioloidEX.a 4 | 5 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 6 | COMMON_SOURCES = \ 7 | BioloidEX.cpp \ 8 | dxl_hal.cpp \ 9 | dynamixel.cpp 10 | 11 | SOURCES = $(COMMON_SOURCES) $(EXTRA_SOURCES) 12 | 13 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 14 | 15 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 16 | 17 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 18 | ifeq ($(OSTYPE),linux-gnueabi) 19 | INCLUDE_DIRS = -I. 20 | 21 | else 22 | INCLUDE_DIRS = -I. 23 | endif 24 | 25 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 26 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 27 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 28 | 29 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 30 | 31 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 32 | ifeq ($(OSTYPE),linux-gnueabi) 33 | #BBBk 34 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 35 | else 36 | ifeq ($(OSTYPE),Edison) 37 | #Edison hard coded OSTYPE 38 | TCHAIN_PREFIX=i586-poky-linux- 39 | else 40 | #RPI 41 | TCHAIN_PREFIX=arm-linux-gnueabihf- 42 | endif 43 | endif 44 | #TCHAIN_PREFIX=x86_64-linux-gnu- 45 | 46 | CXX = $(TCHAIN_PREFIX)g++ 47 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 48 | AR = ar 49 | ARFLAGS = rcs 50 | 51 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 52 | all: begin gccversion build end 53 | 54 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 55 | build: $(MAIN_OUT) 56 | 57 | $(MAIN_OUT): $(MAIN_OBJS) 58 | $(AR) $(ARFLAGS) $(MAIN_OUT) $(MAIN_OBJS) 59 | 60 | MSG_BEGIN = -------- begin -------- 61 | MSG_END = -------- end -------- 62 | 63 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 64 | begin: 65 | @echo 66 | @echo $(MSG_BEGIN) 67 | @echo ${OSTYPE} 68 | 69 | end: 70 | @echo $(MSG_END) 71 | @echo 72 | 73 | gccversion: 74 | @$(CC) --version 75 | 76 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 77 | clean: begin clean_list end 78 | 79 | clean_list: 80 | -rm -f $(MAIN_OBJS) 81 | -rm -f $(MAIN_OUT) 82 | -rm -f $(MAIN_DEPS) 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 85 | backup: clean 86 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 87 | 88 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 89 | include $(subst .cpp,.d,$(SOURCES)) 90 | 91 | %.d: %.cpp 92 | $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ 93 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 94 | rm -f $@.$$$$ 95 | -------------------------------------------------------------------------------- /Linux_Speak/Speak.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TITLE: Simple C/C++ Program showing use of speak_lib.h 3 | AUTHOR:Dhananjay Singh 4 | LICENSE: GPLv2 5 | */ 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | 12 | espeak_POSITION_TYPE position_type; 13 | espeak_AUDIO_OUTPUT output; 14 | char *path=NULL; 15 | int Buflength = 500, Options=0; 16 | void* user_data; 17 | t_espeak_callback *SynthCallback; 18 | espeak_PARAMETER Parm; 19 | 20 | /* 21 | FROM speak_lib.h : 22 | 23 | output: the audio data can either be played by eSpeak or passed back by the SynthCallback function. 24 | 25 | Buflength: The length in mS of sound buffers passed to the SynthCallback function. 26 | 27 | options: bit 0: 1=allow espeakEVENT_PHONEME events. 28 | 29 | path: The directory which contains the espeak-data directory, or NULL for the default location. 30 | 31 | espeak_Initialize() Returns: sample rate in Hz, or -1 (EE_INTERNAL_ERROR). 32 | */ 33 | 34 | char Voice[] = {"default"}; 35 | /* 36 | Voice: Refer to speak_lib.h 37 | */ 38 | 39 | char text[20] = {"Hello World!"}; 40 | unsigned int Size,position=0, end_position=0, flags=espeakCHARS_AUTO, *unique_identifier; 41 | 42 | /* 43 | text: The text to be spoken, terminated by a zero character. It may be either 8-bit characters, 44 | wide characters (wchar_t), or UTF8 encoding. Which of these is determined by the "flags" 45 | parameter. 46 | 47 | Size: Equal to (or greatrer than) the size of the text data, in bytes. This is used in order 48 | to allocate internal storage space for the text. This value is not used for 49 | AUDIO_OUTPUT_SYNCHRONOUS mode. 50 | 51 | position: The position in the text where speaking starts. Zero indicates speak from the 52 | start of the text. 53 | 54 | position_type: Determines whether "position" is a number of characters, words, or sentences. 55 | Values: 56 | 57 | end_position: If set, this gives a character position at which speaking will stop. A value 58 | of zero indicates no end position. 59 | 60 | flags: These may be OR'd together: 61 | Type of character codes, one of: 62 | espeakCHARS_UTF8 UTF8 encoding 63 | espeakCHARS_8BIT The 8 bit ISO-8859 character set for the particular language. 64 | espeakCHARS_AUTO 8 bit or UTF8 (this is the default) 65 | espeakCHARS_WCHAR Wide characters (wchar_t) 66 | 67 | espeakSSML Elements within < > are treated as SSML elements, or if not recognised are ignored. 68 | 69 | espeakPHONEMES Text within [[ ]] is treated as phonemes codes (in espeak's Hirshenbaum encoding). 70 | 71 | espeakENDPAUSE If set then a sentence pause is added at the end of the text. If not set then 72 | this pause is suppressed. 73 | 74 | unique_identifier: message identifier; helpful for identifying later 75 | data supplied to the callback. 76 | 77 | user_data: pointer which will be passed to the callback function. 78 | 79 | espeak_Synth() Returns: EE_OK: operation achieved 80 | EE_BUFFER_FULL: the command can not be buffered; 81 | you may try after a while to call the function again. 82 | EE_INTERNAL_ERROR. 83 | */ 84 | 85 | 86 | 87 | 88 | 89 | int main(int argc, char* argv[] ) 90 | { 91 | output = AUDIO_OUTPUT_PLAYBACK; 92 | int I, Run = 1, L; 93 | espeak_Initialize(output, Buflength, path, Options ); 94 | espeak_SetVoiceByName(Voice); 95 | Size = strlen(text)+1; 96 | printf("Saying '%s'",text); 97 | espeak_Synth( text, Size, position, position_type, end_position, flags, 98 | unique_identifier, user_data ); 99 | espeak_Synchronize( ); 100 | printf("\n:Done\n"); 101 | return 0; 102 | } 103 | -------------------------------------------------------------------------------- /Linux_Speak/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = Speakeasy 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | MAIN_OBJS = \ 6 | Speak.o 7 | 8 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 9 | INCLUDE_DIRS = -I. -I/usr/include/espeak 10 | 11 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 12 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf 13 | 14 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 15 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti 16 | #COMPILE_OPTS = -Wall -pedantic -g -O2 17 | 18 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 19 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lespeak 20 | 21 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 22 | TCHAIN_PREFIX=arm-linux-gnueabihf- 23 | #TCHAIN_PREFIX=x86_64-linux-gnu- 24 | 25 | CXX = $(TCHAIN_PREFIX)g++ 26 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 27 | 28 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 29 | all: begin gccversion build end 30 | 31 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 32 | build: $(MAIN_OUT) 33 | 34 | $(MAIN_OUT): $(MAIN_OBJS) 35 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 36 | 37 | MSG_BEGIN = -------- begin -------- 38 | MSG_END = -------- end -------- 39 | 40 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 41 | begin: 42 | @echo 43 | @echo $(MSG_BEGIN) 44 | 45 | end: 46 | @echo $(MSG_END) 47 | @echo 48 | 49 | gccversion: 50 | @$(CC) --version 51 | 52 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 53 | clean: begin clean_list end 54 | 55 | clean_list: 56 | -rm $(MAIN_OBJS) 57 | -rm $(MAIN_OUT) 58 | 59 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 60 | backup: clean 61 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * -------------------------------------------------------------------------------- /Phantom_Arm/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = Phantom_Arm 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | Phantom_Arm.cpp 7 | 8 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 9 | 10 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 11 | 12 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 13 | INCLUDE_DIRS = -I. -I../library -I../BioloidEX 14 | 15 | 16 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 17 | ifeq ($(OSTYPE),linux-gnueabi) 18 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../BioloidEX -L../library 19 | else 20 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../BioloidEX -L../library 21 | endif 22 | 23 | 24 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 25 | COMPILE_OPTS = -pedantic -g -O2 -fno-rtti -Wno-write-strings 26 | 27 | 28 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 29 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lmraa -lrt 30 | 31 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 32 | ifeq ($(OSTYPE),linux-gnueabi) 33 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 34 | else 35 | ifeq ($(OSTYPE),Edison) 36 | #Edison hard coded OSTYPE 37 | TCHAIN_PREFIX=i586-poky-linux- 38 | else 39 | TCHAIN_PREFIX=arm-linux-gnueabihf- 40 | endif 41 | endif 42 | #TCHAIN_PREFIX=x86_64-linux-gnu- 43 | 44 | CXX = $(TCHAIN_PREFIX)g++ 45 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 46 | 47 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 48 | 49 | all: LIBRARY BioloidEX begin gccversion build end 50 | 51 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 52 | LIBRARY: 53 | cd ../library; $(MAKE) 54 | 55 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 56 | BioloidEX: 57 | cd ../BioloidEX; $(MAKE) 58 | 59 | 60 | 61 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 62 | 63 | 64 | build: $(MAIN_OUT) 65 | 66 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a ../BioloidEX/libBioloidEX.a 67 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 68 | 69 | MSG_BEGIN = -------- begin -------- 70 | MSG_END = -------- end -------- 71 | 72 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 73 | begin: 74 | @echo 75 | @echo $(MSG_BEGIN) 76 | 77 | end: 78 | @echo $(MSG_END) 79 | @echo 80 | 81 | gccversion: 82 | @$(CC) --version 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 85 | clean: begin clean_list end 86 | 87 | clean_list: 88 | -rm $(MAIN_OBJS) 89 | -rm $(MAIN_OUT) 90 | -rm $(MAIN_DEPS) 91 | -cd ../library ; make clean 92 | -cd ../BioloidEX ; make clean 93 | 94 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 95 | backup: clean 96 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 97 | 98 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 99 | include $(subst .cpp,.d,$(SOURCES)) 100 | 101 | %.d: %.cpp 102 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 103 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 104 | rm -f $@.$$$$ 105 | -------------------------------------------------------------------------------- /Phantom_Arm_USB2EX/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = Phantom_Arm 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | Phantom_Arm.cpp 7 | 8 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 9 | 10 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 11 | 12 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 13 | INCLUDE_DIRS = -I. -I../library -I../BioloidEX_Usb2Ax 14 | 15 | 16 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 17 | ifeq ($(OSTYPE),linux-gnueabi) 18 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../BioloidEX_Usb2Ax -L../library 19 | else 20 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../BioloidEX_Usb2Ax -L../library 21 | endif 22 | 23 | 24 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 25 | COMPILE_OPTS = -pedantic -g -O2 -fno-rtti -Wno-write-strings 26 | 27 | 28 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 29 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lasound -lrt 30 | 31 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 32 | ifeq ($(OSTYPE),linux-gnueabi) 33 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 34 | else 35 | TCHAIN_PREFIX=arm-linux-gnueabihf- 36 | endif 37 | #TCHAIN_PREFIX=x86_64-linux-gnu- 38 | 39 | CXX = $(TCHAIN_PREFIX)g++ 40 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 41 | 42 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 43 | 44 | all: LIBRARY BioloidEX_Usb2Ax begin gccversion build end 45 | 46 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 47 | LIBRARY: 48 | cd ../library; $(MAKE) 49 | 50 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 51 | BioloidEX_Usb2Ax: 52 | cd ../BioloidEX_Usb2Ax; $(MAKE) 53 | 54 | 55 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 56 | 57 | 58 | build: $(MAIN_OUT) 59 | 60 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a ../BioloidEX_Usb2Ax/libBioloidEX.a 61 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 62 | 63 | MSG_BEGIN = -------- begin -------- 64 | MSG_END = -------- end -------- 65 | 66 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 67 | begin: 68 | @echo 69 | @echo $(MSG_BEGIN) 70 | 71 | end: 72 | @echo $(MSG_END) 73 | @echo 74 | 75 | gccversion: 76 | @$(CC) --version 77 | 78 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 79 | clean: begin clean_list end 80 | 81 | clean_list: 82 | -rm $(MAIN_OBJS) 83 | -rm $(MAIN_OUT) 84 | -rm $(MAIN_DEPS) 85 | -cd ../library ; make clean 86 | -cd ../BioloidEX_Usb2Ax ; make clean 87 | 88 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 89 | backup: clean 90 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 91 | 92 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 93 | include $(subst .cpp,.d,$(SOURCES)) 94 | 95 | %.d: %.cpp 96 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 97 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 98 | rm -f $@.$$$$ 99 | -------------------------------------------------------------------------------- /Phantom_Phoenix/99-usb-serial.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A800fclo", SYMLINK+="ttyXBEE" 2 | SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A4014UWE", SYMLINK+="ttySSC-32" -------------------------------------------------------------------------------- /Phantom_Phoenix/ArduinoDefs.h: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | // 5 | // 6 | // Arduino(ish) defines to get the Phoenix software to run on RPI 7 | // 8 | // This library is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU Lesser General Public 10 | // License as published by the Free Software Foundation; either 11 | // version 2.1 of the License, or (at your option) any later version. 12 | 13 | // This library is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | // Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public 19 | // License along with this library; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | // 22 | //============================================================================= 23 | #ifndef _ARDUINO_DEFS_ 24 | #define _ARDUINO_DEFS_ 25 | #include 26 | #define PROGMEM 27 | #define pgm_read_byte(x) (*((char *)x)) 28 | // #define pgm_read_word(x) (*((short *)(x & 0xfffffffe))) 29 | #define pgm_read_word(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 30 | #define pgm_read_byte_near(x) (*((char *)x)) 31 | #define pgm_read_byte_far(x) (*((char *)x)) 32 | // #define pgm_read_word_near(x) (*((short *)(x & 0xfffffffe)) 33 | // #define pgm_read_word_far(x) (*((short *)(x & 0xfffffffe))) 34 | #define pgm_read_word_near(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 35 | #define pgm_read_word_far(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))) 36 | #define PSTR(x) x 37 | #define F(x) x 38 | #define PGM_P const char * 39 | 40 | // Define some data types? 41 | #define byte unsigned char 42 | //#define uint8_t unsigned char 43 | //#define uint16_t unsigned short 44 | //#define uint32_t unsigned long 45 | #define word unsigned short 46 | #define boolean bool 47 | 48 | #define delay(x) usleep((x)*1000) 49 | #define delayMicroseconds(us) usleep((us)) 50 | extern unsigned long millis(void); 51 | extern unsigned long micros(void); 52 | extern long min(long a, long b); 53 | extern long max(long a, long b); 54 | extern long map(long x, long in_min, long in_max, long out_min, long out_max); 55 | #endif 56 | -------------------------------------------------------------------------------- /Phantom_Phoenix/CommanderTest.cpp: -------------------------------------------------------------------------------- 1 | #include "CommanderEx.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "mraa.h" 15 | 16 | //hello.cpp 17 | int fd; 18 | FILE *f; 19 | 20 | char szDevice[] = "/dev/ttyXBEE"; 21 | 22 | Commander command = Commander(); 23 | 24 | signed char rightV; // vertical stick movement = forward speed 25 | signed char rightH; // horizontal stick movement = sideways or angular speed 26 | signed char leftV; // vertical stick movement = tilt 27 | signed char leftH; // horizontal stick movement = pan (when we run out of pan, turn body?) 28 | unsigned char buttons; // 29 | unsigned char ext; // Extended function set 30 | 31 | uint8_t fRunning = true; 32 | 33 | void SignalHandler(int sig){ 34 | printf("Caught signal %d\n", sig); 35 | fRunning = false; 36 | } 37 | 38 | 39 | int main() 40 | { 41 | printf("Arbotox Commander XBee Test!\n"); 42 | 43 | // Install signal handler to allow us to do some cleanup... 44 | struct sigaction sigIntHandler; 45 | 46 | sigIntHandler.sa_handler = SignalHandler; 47 | sigemptyset(&sigIntHandler.sa_mask); 48 | sigIntHandler.sa_flags = 0; 49 | 50 | sigaction(SIGINT, &sigIntHandler, NULL); 51 | 52 | mraa_uart_context uart; 53 | mraa_init(); 54 | uart = mraa_uart_init(0); 55 | if (uart == NULL) { 56 | printf("MRAA UART failed to setup\n"); 57 | } 58 | 59 | // Lets try to open the XBee device... 60 | command.begin(szDevice, B38400); 61 | printf("After Begin!\n"); 62 | 63 | // loop simply echo what we receive from xbee to terminal 64 | // Now lets try to get data from the commander. 65 | while (fRunning) 66 | { 67 | if (command.ReadMsgs()) 68 | { 69 | // We have data. see if anything has changed before 70 | if ((command.rightV != rightV) || (command.rightH != rightH) || 71 | (command.leftV != leftV) || (command.leftH != leftH) || 72 | (command.buttons != buttons) || (command.ext != ext)) 73 | { 74 | // Something changed so print it out 75 | rightV = command.rightV; 76 | rightH = command.rightH; 77 | leftV = command.leftV; 78 | leftH = command.leftH; 79 | buttons = command.buttons; 80 | ext = command.ext; 81 | printf("%x %x - %d %d %d %d\n", buttons, ext, rightV, rightH, leftV, leftH); 82 | } 83 | } 84 | usleep(100); 85 | } 86 | return 0; 87 | } 88 | -------------------------------------------------------------------------------- /Phantom_Phoenix/Phantom_Phoenix.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | 28 | #include "Hex_Cfg.h" 29 | #include "Phoenix.h" 30 | #include "speak.h" 31 | #include 32 | 33 | 34 | 35 | extern void setup(void); 36 | extern void loop(void); 37 | extern void cleanup(void); 38 | 39 | //-------------------------------------------------------------------------- 40 | // SignalHandler - Try to free up things like servos if we abort. 41 | //-------------------------------------------------------------------------- 42 | volatile uint8_t g_fSignaled = false; 43 | 44 | void SignalHandler(int sig){ 45 | printf("Caught signal %d\n", sig); 46 | g_fSignaled = true; 47 | } 48 | 49 | 50 | int main() 51 | { 52 | // Install signal handler to allow us to do some cleanup... 53 | struct sigaction sigIntHandler; 54 | 55 | sigIntHandler.sa_handler = SignalHandler; 56 | sigemptyset(&sigIntHandler.sa_mask); 57 | sigIntHandler.sa_flags = 0; 58 | 59 | sigaction(SIGINT, &sigIntHandler, NULL); 60 | sigaction(SIGQUIT, &sigIntHandler, NULL); 61 | 62 | 63 | setup(); 64 | 65 | while (!g_fSignaled) 66 | { 67 | loop(); 68 | } 69 | // Call cleanup function and exit; 70 | cleanup(); 71 | } 72 | -------------------------------------------------------------------------------- /Phantom_Phoenix/Phoenix.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KurtE/Raspberry_Pi/515f138ecb2ca2c0e96b7343ccf14b87653faaad/Phantom_Phoenix/Phoenix.h -------------------------------------------------------------------------------- /Phantom_Phoenix/makefile: -------------------------------------------------------------------------------- 1 | lib:= LIBRARY BioloidEX_Usb2Ax 2 | 3 | Prog1:= Phantom_Phoenix 4 | 5 | Programs := $(lib) $(Prog1) 6 | 7 | 8 | .PHONY: all $(Programs) 9 | 10 | all: $(Programs) 11 | 12 | 13 | LIBRARY: 14 | cd ../library; $(MAKE) 15 | 16 | BioloidEX_Usb2Ax: 17 | cd ../BioloidEX_Usb2Ax; $(MAKE) 18 | 19 | Phantom_Phoenix: 20 | $(MAKE) -f makefile_PhantomX $(MAKECMDGOALS) 21 | 22 | 23 | clean: 24 | $(MAKE) -f makefile_PhantomX clean 25 | cd ../library ; $(MAKE) clean 26 | cd ../BioloidEX_Usb2Ax ; $(MAKE) clean 27 | -------------------------------------------------------------------------------- /Phantom_Phoenix/makefile_PhantomX: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = Phantom_Phoenix 3 | 4 | BIOLOIDEX = BioloidEX 5 | 6 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 7 | SOURCES = \ 8 | Phantom_Phoenix.cpp \ 9 | Phoenix_Code.cpp \ 10 | Phoenix_Driver_AX12.cpp \ 11 | Phoenix_Input_Commander.cpp 12 | 13 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 14 | 15 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 16 | 17 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 18 | ifeq ($(OSTYPE),linux-gnueabi) 19 | #BBBk 20 | INCLUDE_DIRS = -I. -I../library -I../$(BIOLOIDEX) 21 | else 22 | INCLUDE_DIRS = -I. -I../library -I../$(BIOLOIDEX) -I/usr/include/espeak 23 | endif 24 | 25 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 26 | ifeq ($(OSTYPE),linux-gnueabi) 27 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../$(BIOLOIDEX) -L../library 28 | else 29 | ifeq ($(OSTYPE),Edison) 30 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lrt 31 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../$(BIOLOIDEX) -L../library 32 | else 33 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library -L../$(BIOLOIDEX) -L../library 34 | endif 35 | endif 36 | 37 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 38 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 39 | #COMPILE_OPTS = -Wall -pedantic -g -O2 40 | 41 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 42 | ifeq ($(OSTYPE),linux-gnueabi) 43 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lBioloidEX -lespeak -lrt 44 | else 45 | ifeq ($(OSTYPE),Edison) 46 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lrt 47 | else 48 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lespeak -lasound -lrt 49 | endif 50 | endif 51 | 52 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 53 | ifeq ($(OSTYPE),linux-gnueabi) 54 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 55 | else 56 | ifeq ($(OSTYPE),Edison) 57 | #Edison hard coded OSTYPE 58 | TCHAIN_PREFIX=i586-poky-linux- 59 | else 60 | TCHAIN_PREFIX=arm-linux-gnueabihf- 61 | endif 62 | endif 63 | #TCHAIN_PREFIX=x86_64-linux-gnu- 64 | 65 | CXX = $(TCHAIN_PREFIX)g++ 66 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 67 | 68 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 69 | all: begin gccversion build end 70 | 71 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 72 | build: $(MAIN_OUT) 73 | 74 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a 75 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 76 | 77 | MSG_BEGIN = -------- begin -------- 78 | MSG_END = -------- end -------- 79 | 80 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 81 | begin: 82 | @echo 83 | @echo $(MSG_BEGIN) 84 | 85 | end: 86 | @echo $(MSG_END) 87 | @echo 88 | 89 | gccversion: 90 | @$(CC) --version 91 | 92 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 93 | clean: begin clean_list end 94 | 95 | clean_list: 96 | -rm -f $(MAIN_OBJS) 97 | -rm -f $(MAIN_OUT) 98 | -rm -f $(MAIN_DEPS) 99 | 100 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 101 | backup: clean 102 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 103 | 104 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 105 | include $(subst .cpp,.d,$(SOURCES)) 106 | 107 | %.d: %.cpp 108 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 109 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 110 | rm -f $@.$$$$ 111 | -------------------------------------------------------------------------------- /Phantom_Phoenix/makefile_test: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = CommanderTest 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | CommanderTest.cpp 7 | 8 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 9 | 10 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 11 | 12 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 13 | INCLUDE_DIRS = -I. -I../library 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 16 | ifeq ($(OSTYPE),linux-gnueabi) 17 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../BioloidEX_Usb2Ax -L../library 18 | else 19 | ifeq ($(OSTYPE),Edison) 20 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lrt 21 | LIBRARY_DIRS = -L/usr/local/libs -L/usr/lib/arm-linux-gnueabihf -L../BioloidEX_Usb2Ax -L../library 22 | else 23 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../BioloidEX_Usb2Ax -L../library 24 | endif 25 | endif 26 | 27 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 28 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 29 | #COMPILE_OPTS = -Wall -pedantic -g -O2 30 | 31 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 32 | ifeq ($(OSTYPE),linux-gnueabi) 33 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lBioloidEX -lespeak -lrt 34 | else 35 | ifeq ($(OSTYPE),Edison) 36 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lmraa -lrt 37 | else 38 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lespeak -lBioloidEX -lArduinoPort 39 | endif 40 | endif 41 | 42 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 43 | ifeq ($(OSTYPE),linux-gnueabi) 44 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 45 | else 46 | ifeq ($(OSTYPE),Edison) 47 | #Edison hard coded OSTYPE 48 | TCHAIN_PREFIX=i586-poky-linux- 49 | else 50 | TCHAIN_PREFIX=arm-linux-gnueabihf- 51 | endif 52 | endif 53 | #TCHAIN_PREFIX=x86_64-linux-gnu- 54 | 55 | CXX = $(TCHAIN_PREFIX)g++ 56 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 57 | 58 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 59 | all: begin gccversion build end 60 | 61 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 62 | build: $(MAIN_OUT) 63 | 64 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a 65 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 66 | 67 | MSG_BEGIN = -------- begin -------- 68 | MSG_END = -------- end -------- 69 | 70 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 71 | begin: 72 | @echo 73 | @echo $(MSG_BEGIN) 74 | 75 | end: 76 | @echo $(MSG_END) 77 | @echo 78 | 79 | gccversion: 80 | @$(CC) --version 81 | 82 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 83 | clean: begin clean_list end 84 | 85 | clean_list: 86 | -rm -f $(MAIN_OBJS) 87 | -rm -f $(MAIN_OUT) 88 | -rm -f $(MAIN_DEPS) 89 | 90 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 91 | backup: clean 92 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 93 | 94 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 95 | include $(subst .cpp,.d,$(SOURCES)) 96 | 97 | %.d: %.cpp 98 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 99 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 100 | rm -f $@.$$$$ 101 | -------------------------------------------------------------------------------- /Phoenix/99-usb-serial.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A800fclo", SYMLINK+="ttyXBEE" 2 | SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A4014UWE", SYMLINK+="ttySSC-32" -------------------------------------------------------------------------------- /Phoenix/ArduinoDefs.h: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | // 5 | // 6 | // Arduino(ish) defines to get the Phoenix software to run on RPI 7 | // 8 | // This library is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU Lesser General Public 10 | // License as published by the Free Software Foundation; either 11 | // version 2.1 of the License, or (at your option) any later version. 12 | 13 | // This library is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | // Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public 19 | // License along with this library; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | // 22 | //============================================================================= 23 | #ifndef _ARDUINO_DEFS_ 24 | #define _ARDUINO_DEFS_ 25 | #include 26 | #define PROGMEM 27 | #define pgm_read_byte(x) (*((char *)x)) 28 | // #define pgm_read_word(x) (*((short *)(x & 0xfffffffe))) 29 | #define pgm_read_word(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 30 | #define pgm_read_byte_near(x) (*((char *)x)) 31 | #define pgm_read_byte_far(x) (*((char *)x)) 32 | // #define pgm_read_word_near(x) (*((short *)(x & 0xfffffffe)) 33 | // #define pgm_read_word_far(x) (*((short *)(x & 0xfffffffe))) 34 | #define pgm_read_word_near(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 35 | #define pgm_read_word_far(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))) 36 | #define PSTR(x) x 37 | #define F(x) x 38 | #define PGM_P const char * 39 | 40 | // Define some data types? 41 | #define byte unsigned char 42 | //#define uint8_t unsigned char 43 | //#define uint16_t unsigned short 44 | //#define uint32_t unsigned long 45 | #define word unsigned short 46 | #define boolean bool 47 | 48 | #define delay(x) usleep((x)*1000) 49 | #define delayMicroseconds(us) usleep((us)) 50 | extern unsigned long millis(void); 51 | extern unsigned long micros(void); 52 | extern long min(long a, long b); 53 | extern long max(long a, long b); 54 | extern long map(long x, long in_min, long in_max, long out_min, long out_max); 55 | #endif 56 | -------------------------------------------------------------------------------- /Phoenix/CommanderTest.cpp: -------------------------------------------------------------------------------- 1 | #include "CommanderEx.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | //hello.cpp 15 | int fd; 16 | FILE *f; 17 | 18 | char szDevice[] = "/dev/ttyXBEE"; 19 | 20 | Commander command = Commander(); 21 | 22 | signed char rightV; // vertical stick movement = forward speed 23 | signed char rightH; // horizontal stick movement = sideways or angular speed 24 | signed char leftV; // vertical stick movement = tilt 25 | signed char leftH; // horizontal stick movement = pan (when we run out of pan, turn body?) 26 | unsigned char buttons; // 27 | unsigned char ext; // Extended function set 28 | 29 | int main() 30 | { 31 | printf("Arbotox Commander XBee Test!\n"); 32 | // Lets try to open the XBee device... 33 | command.begin(szDevice, B38400); 34 | printf("After Begin!\n"); 35 | 36 | // loop simply echo what we receive from xbee to terminal 37 | // Now lets try to get data from the commander. 38 | for (;;) 39 | { 40 | if (command.ReadMsgs()) 41 | { 42 | // We have data. see if anything has changed before 43 | if ((command.rightV != rightV) || (command.rightH != rightH) || 44 | (command.leftV != leftV) || (command.leftH != leftH) || 45 | (command.buttons != buttons) || (command.ext != ext)) 46 | { 47 | // Something changed so print it out 48 | rightV = command.rightV; 49 | rightH = command.rightH; 50 | leftV = command.leftV; 51 | leftH = command.leftH; 52 | buttons = command.buttons; 53 | ext = command.ext; 54 | printf("%x %x - %d %d %d %d\n", buttons, ext, rightV, rightH, leftV, leftH); 55 | } 56 | } 57 | usleep(100); 58 | } 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /Phoenix/Phoenix.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KurtE/Raspberry_Pi/515f138ecb2ca2c0e96b7343ccf14b87653faaad/Phoenix/Phoenix.h -------------------------------------------------------------------------------- /Phoenix/PyPoseGen.h: -------------------------------------------------------------------------------- 1 | #ifdef LATER 2 | #ifndef TEST_POSES 3 | #define TEST_POSES 4 | #define NOPROGMEM 5 | #if defined(NOPROGMEM) 6 | #define PROGMEM 7 | #define prog_uint16_t uint16_t 8 | #define pgm_read_byte(x) (*((char *)x)) 9 | // #define pgm_read_word(x) (*((short *)(x & 0xfffffffe))) 10 | #define pgm_read_word(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 11 | #define pgm_read_byte_near(x) (*((char *)x)) 12 | #define pgm_read_byte_far(x) (*((char *)x)) 13 | // #define pgm_read_word_near(x) (*((short *)(x & 0xfffffffe)) 14 | // #define pgm_read_word_far(x) (*((short *)(x & 0xfffffffe))) 15 | #define pgm_read_word_near(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 16 | #define pgm_read_word_far(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))) 17 | #define PSTR(x) x 18 | #else 19 | #include 20 | #endif 21 | 22 | PROGMEM prog_uint16_t R4[] = {18, 512, 511, 711, 595, 300, 899, 510, 510, 712, 596, 300, 900, 511, 510, 712, 800, 300, 970}; 23 | PROGMEM prog_uint16_t R5[] = {18, 512, 511, 711, 312, 201, 712, 509, 510, 712, 312, 201, 712, 511, 510, 711, 799, 207, 967}; 24 | PROGMEM prog_uint16_t R6[] = {18, 512, 512, 654, 224, 45, 506, 510, 512, 661, 225, 43, 506, 511, 510, 662, 799, 44, 967}; 25 | PROGMEM prog_uint16_t _Wag_6[] = {18, 511, 511, 297, 710, 113, 906, 628, 326, 260, 777, 368, 940, 663, 327, 306, 682, 62, 958}; 26 | PROGMEM prog_uint16_t _wag_1[] = {18, 512, 514, 280, 696, 50, 924, 492, 509, 280, 730, 42, 979, 509, 513, 273, 708, 47, 967}; 27 | PROGMEM prog_uint16_t R1[] = {18, 513, 513, 226, 796, 52, 971, 510, 510, 229, 795, 50, 970, 511, 510, 227, 796, 52, 970}; 28 | PROGMEM prog_uint16_t R2[] = {18, 512, 511, 226, 594, 52, 899, 509, 510, 229, 596, 50, 900, 511, 510, 428, 800, 124, 970}; 29 | PROGMEM prog_uint16_t R3[] = {18, 512, 511, 712, 595, 197, 899, 510, 510, 711, 596, 200, 900, 511, 510, 550, 800, 242, 970}; 30 | PROGMEM prog_uint16_t _wag_3[] = {18, 511, 512, 296, 710, 113, 906, 492, 509, 280, 730, 42, 981, 663, 327, 308, 682, 47, 967}; 31 | PROGMEM prog_uint16_t _wag_2[] = {18, 511, 511, 311, 696, 112, 920, 492, 508, 280, 731, 42, 979, 665, 326, 182, 795, 47, 967}; 32 | PROGMEM prog_uint16_t _wag_5[] = {18, 511, 512, 300, 710, 114, 906, 639, 331, 267, 779, 52, 651, 663, 327, 308, 682, 62, 962}; 33 | PROGMEM prog_uint16_t _wag_4[] = {18, 511, 512, 312, 712, 113, 906, 645, 331, 267, 772, 254, 767, 663, 327, 308, 682, 47, 967}; 34 | PROGMEM prog_uint16_t _wag_0[] = {18, 547, 514, 286, 719, 51, 935, 488, 509, 230, 788, 17, 977, 491, 518, 234, 723, 0, 921}; 35 | 36 | PROGMEM transition_t Wag[] = 37 | { 38 | { 39 | 0,17 40 | } 41 | , 42 | { 43 | _wag_0,500 44 | } 45 | , 46 | { 47 | _wag_1,500 48 | } 49 | , 50 | { 51 | _wag_2,500 52 | } 53 | , 54 | { 55 | _wag_3,500 56 | } 57 | , 58 | { 59 | _wag_4,500 60 | } 61 | , 62 | { 63 | _wag_5,500 64 | } 65 | , 66 | { 67 | _Wag_6,500 68 | } 69 | , 70 | { 71 | _wag_5,500 72 | } 73 | , 74 | { 75 | _Wag_6,500 76 | } 77 | , 78 | { 79 | _wag_5,500 80 | } 81 | , 82 | { 83 | _Wag_6,500 84 | } 85 | , 86 | { 87 | _wag_5,500 88 | } 89 | , 90 | { 91 | _wag_4,500 92 | } 93 | , 94 | { 95 | _wag_3,500 96 | } 97 | , 98 | { 99 | _wag_2,500 100 | } 101 | , 102 | { 103 | _wag_1,500 104 | } 105 | , 106 | { 107 | _wag_0,500 108 | } 109 | }; 110 | PROGMEM transition_t Rollover[] = 111 | { 112 | { 113 | 0,6 114 | } 115 | , 116 | { 117 | R1,500 118 | } 119 | , 120 | { 121 | R2,500 122 | } 123 | , 124 | { 125 | R3,500 126 | } 127 | , 128 | { 129 | R4,500 130 | } 131 | , 132 | { 133 | R5,500 134 | } 135 | , 136 | { 137 | R6,500 138 | } 139 | }; 140 | 141 | #ifdef EXPORT_POSE_LIST 142 | PROGMEM transition_t *PoseList[] = { Wag ,Rollover }; 143 | #endif 144 | #endif 145 | #endif 146 | -------------------------------------------------------------------------------- /Phoenix/PyPoseTest.ppr: -------------------------------------------------------------------------------- 1 | Test:18:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024:1024 2 | Pose=R4:512, 511, 711, 595, 300, 899, 510, 510, 712, 596, 300, 900, 511, 510, 712, 800, 300, 970 3 | Pose=R5:512, 511, 711, 312, 201, 712, 509, 510, 712, 312, 201, 712, 511, 510, 711, 799, 207, 967 4 | Pose=R6:512, 512, 654, 224, 45, 506, 510, 512, 661, 225, 43, 506, 511, 510, 662, 799, 44, 967 5 | Pose=_Wag_6:511, 511, 297, 710, 113, 906, 628, 326, 260, 777, 368, 940, 663, 327, 306, 682, 62, 958 6 | Pose=_wag_1:512, 514, 280, 696, 50, 924, 492, 509, 280, 730, 42, 979, 509, 513, 273, 708, 47, 967 7 | Pose=R1:513, 513, 226, 796, 52, 971, 510, 510, 229, 795, 50, 970, 511, 510, 227, 796, 52, 970 8 | Pose=R2:512, 511, 226, 594, 52, 899, 509, 510, 229, 596, 50, 900, 511, 510, 428, 800, 124, 970 9 | Pose=R3:512, 511, 712, 595, 197, 899, 510, 510, 711, 596, 200, 900, 511, 510, 550, 800, 242, 970 10 | Pose=_wag_3:511, 512, 296, 710, 113, 906, 492, 509, 280, 730, 42, 981, 663, 327, 308, 682, 47, 967 11 | Pose=_wag_2:511, 511, 311, 696, 112, 920, 492, 508, 280, 731, 42, 979, 665, 326, 182, 795, 47, 967 12 | Pose=_wag_5:511, 512, 300, 710, 114, 906, 639, 331, 267, 779, 52, 651, 663, 327, 308, 682, 62, 962 13 | Pose=_wag_4:511, 512, 312, 712, 113, 906, 645, 331, 267, 772, 254, 767, 663, 327, 308, 682, 47, 967 14 | Pose=_wag_0:547, 514, 286, 719, 51, 935, 488, 509, 230, 788, 17, 977, 491, 518, 234, 723, 0, 921 15 | Seq=Wag: _wag_0|500, _wag_1|500, _wag_2|500, _wag_3|500, _wag_4|500, _wag_5|500, _Wag_6|500, _wag_5|500, _Wag_6|500, _wag_5|500, _Wag_6|500, _wag_5|500, _wag_4|500, _wag_3|500, _wag_2|500, _wag_1|500, _wag_0|500 16 | Seq=Rollover: R1|500, R2|500, R3|500, R4|500, R5|500, R6|500 17 | Nuke=Lizard 3DOF,6,++++++++++++++++++,50,50,50,50,50,50,0,0,2,4,6,1,3,5,14,16,18,13,15,17,8,10,12,7,9,11 18 | -------------------------------------------------------------------------------- /Phoenix/THex3_Commander_SSC32.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | 28 | #include "Hex_Cfg.h" 29 | #include "Phoenix.h" 30 | #include "speak.h" 31 | extern void setup(void); 32 | extern void loop(void); 33 | 34 | int main() 35 | { 36 | setup(); 37 | 38 | for(;;) 39 | { 40 | loop(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Phoenix/foo.sh: -------------------------------------------------------------------------------- 1 | bcpp ArduinoDefs.h 2 | bcpp CommanderEx.cpp 3 | bcpp CommanderEx.h 4 | bcpp CommanderTest.cpp 5 | bcpp diyxbee.cpp 6 | bcpp diyxbee.h 7 | bcpp Hex_Cfg.h 8 | bcpp msound.cpp 9 | bcpp Phoenix_Code.cpp 10 | bcpp Phoenix_Driver_SSC32.cpp 11 | bcpp Phoenix.h 12 | bcpp Phoenix_Input_Commander.cpp 13 | bcpp Phoenix_Input_DIYXBee.cpp 14 | bcpp Printable.h 15 | bcpp Print.cpp 16 | bcpp Print.h 17 | bcpp PyPoseGen.h 18 | bcpp speak.cpp 19 | bcpp speak.h 20 | bcpp Stream.cpp 21 | bcpp Stream.h 22 | bcpp THex3_Commander_SSC32.cpp 23 | bcpp WrapperSerial.cpp 24 | bcpp WrapperSerial.h 25 | -------------------------------------------------------------------------------- /Phoenix/makefile: -------------------------------------------------------------------------------- 1 | lib:= LIBRARY 2 | Prog1:= THex3_Commander_SSC32 3 | Prog2:= THex3_DIY_SSC32 4 | 5 | Programs := $(lib) $(Prog1) $(Prog2) 6 | 7 | 8 | .PHONY: all $(Programs) 9 | 10 | all: $(Programs) 11 | 12 | 13 | LIBRARY: 14 | cd ../library; $(MAKE) 15 | 16 | THex3_Commander_SSC32: 17 | $(MAKE) -f makefile_THSC $(MAKECMDGOALS) 18 | 19 | THex3_DIY_SSC32: 20 | $(MAKE) -f makefile_THSX $(MAKECMDGOALS) 21 | 22 | clean: 23 | $(MAKE) -f makefile_THSC clean 24 | $(MAKE) -f makefile_THSX clean 25 | cd ../library ; $(MAKE) clean 26 | -------------------------------------------------------------------------------- /Phoenix/makefile_THSC: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = THex3_Commander_SSC32 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | THex3_Commander_SSC32.cpp \ 7 | Phoenix_Code.cpp \ 8 | Phoenix_Input_Commander.cpp \ 9 | Phoenix_Driver_SSC32.cpp 10 | 11 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 12 | 13 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 16 | ifeq ($(OSTYPE),linux-gnueabi) 17 | #BBBk 18 | INCLUDE_DIRS = -I. -I../library 19 | else 20 | INCLUDE_DIRS = -I. -I../library -I/usr/include/espeak 21 | endif 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 24 | ifeq ($(OSTYPE),linux-gnueabi) 25 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../library 26 | else 27 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 28 | endif 29 | 30 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 31 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 32 | 33 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 34 | ifeq ($(OSTYPE),linux-gnueabi) 35 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak -lrt 36 | else 37 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lespeak -lArduinoPort 38 | endif 39 | 40 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 41 | ifeq ($(OSTYPE),linux-gnueabi) 42 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 43 | else 44 | TCHAIN_PREFIX=arm-linux-gnueabihf- 45 | endif 46 | #TCHAIN_PREFIX=x86_64-linux-gnu- 47 | 48 | CXX = $(TCHAIN_PREFIX)g++ 49 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 50 | 51 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 52 | all: begin gccversion build end 53 | 54 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 55 | build: $(MAIN_OUT) 56 | 57 | # added specific dependence on my own library... 58 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a 59 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 60 | 61 | MSG_BEGIN = -------- begin -------- 62 | MSG_END = -------- end -------- 63 | 64 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 65 | begin: 66 | @echo 67 | @echo $(MSG_BEGIN) 68 | 69 | end: 70 | @echo $(MSG_END) 71 | @echo 72 | 73 | gccversion: 74 | @$(CC) --version 75 | 76 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 77 | clean: begin clean_list end 78 | 79 | clean_list: 80 | -rm -f $(MAIN_OBJS) 81 | -rm -f $(MAIN_OUT) 82 | -rm -f $(MAIN_DEPS) 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 85 | backup: clean 86 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 87 | 88 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 89 | include $(subst .cpp,.d,$(SOURCES)) 90 | 91 | %.d: %.cpp 92 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 93 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 94 | rm -f $@.$$$$ 95 | -------------------------------------------------------------------------------- /Phoenix/makefile_THSX: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = THex3_DIY_SSC32 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | THex3_Commander_SSC32.cpp \ 7 | Phoenix_Code.cpp \ 8 | Phoenix_Driver_SSC32.cpp \ 9 | Phoenix_Input_DIYXBee.cpp 10 | 11 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 12 | 13 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 16 | ifeq ($(OSTYPE),linux-gnueabi) 17 | #BBBk 18 | INCLUDE_DIRS = -I. -I../library 19 | else 20 | INCLUDE_DIRS = -I. -I../library -I/usr/include/espeak 21 | endif 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 24 | ifeq ($(OSTYPE),linux-gnueabi) 25 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../library 26 | else 27 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 28 | endif 29 | 30 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 31 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 32 | #COMPILE_OPTS = -Wall -pedantic -g -O2 33 | 34 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 35 | ifeq ($(OSTYPE),linux-gnueabi) 36 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak -lrt 37 | else 38 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lespeak -lArduinoPort 39 | endif 40 | 41 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 42 | ifeq ($(OSTYPE),linux-gnueabi) 43 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 44 | else 45 | TCHAIN_PREFIX=arm-linux-gnueabihf- 46 | endif 47 | #TCHAIN_PREFIX=x86_64-linux-gnu- 48 | 49 | CXX = $(TCHAIN_PREFIX)g++ 50 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 51 | 52 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 53 | all: begin gccversion build end 54 | 55 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 56 | build: $(MAIN_OUT) 57 | 58 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a 59 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 60 | 61 | MSG_BEGIN = -------- begin -------- 62 | MSG_END = -------- end -------- 63 | 64 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 65 | begin: 66 | @echo 67 | @echo $(MSG_BEGIN) 68 | 69 | end: 70 | @echo $(MSG_END) 71 | @echo 72 | 73 | gccversion: 74 | @$(CC) --version 75 | 76 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 77 | clean: begin clean_list end 78 | 79 | clean_list: 80 | -rm -f $(MAIN_OBJS) 81 | -rm -f $(MAIN_OUT) 82 | -rm -f $(MAIN_DEPS) 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 85 | backup: clean 86 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 87 | 88 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 89 | include $(subst .cpp,.d,$(SOURCES)) 90 | 91 | %.d: %.cpp 92 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 93 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 94 | rm -f $@.$$$$ 95 | -------------------------------------------------------------------------------- /Phoenix/makefile_test: -------------------------------------------------------------------------------- 1 | 2 | SHELL := /bin/sh 3 | 4 | .SUFFIXES: 5 | .SUFFIXES: .c .o .cpp 6 | 7 | DESTDIR = 8 | 9 | prefix = /usr/local 10 | bindir = $(prefix)/bin 11 | srcdir = . 12 | 13 | INSTALL = install 14 | INSTALL_PROGRAM = $(INSTALL) 15 | 16 | PROGRAM := CommanderTest 17 | OBJFILES := CommanderTest.o CommanderEx.o 18 | 19 | CommanderTest: $(OBJFILES) 20 | 21 | CommanderTest.o: CommanderTest.cpp CommanderEx.h 22 | 23 | CommanderEx.o: CommanderEx.cpp CommanderEx.h 24 | 25 | CFLAGS = -Wall -O2 26 | 27 | XCPLAY_CFLAGS := -pthread -g 28 | XCPLAY_LDFLAGS := -pthread -g 29 | 30 | all: $(PROGRAM) 31 | 32 | %.o: %.c 33 | $(CC) -o $@ -c $< $(CFLAGS) $(XCPLAY_CFLAGS) 34 | 35 | %.o: %.cpp 36 | g++ -o $@ -c $< $(CFLAGS) $(XCPLAY_CFLAGS) 37 | 38 | 39 | $(PROGRAM): $(OBJFILES) 40 | $(CC) -o $@ $(LDFLAGS) $(XCPLAY_LDFLAGS) $(OBJFILES) 41 | 42 | clean: 43 | rm -rf $(PROGRAM) dist *.o *.tar.gz 44 | -------------------------------------------------------------------------------- /Phoenix_fixed/PhantomX/Phantom_Phoenix.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | 28 | #include "Hex_Cfg.h" 29 | #include "Phoenix.h" 30 | #include "speak.h" 31 | #include 32 | 33 | 34 | 35 | extern void setup(void); 36 | extern void loop(void); 37 | extern void cleanup(void); 38 | 39 | //-------------------------------------------------------------------------- 40 | // SignalHandler - Try to free up things like servos if we abort. 41 | //-------------------------------------------------------------------------- 42 | volatile uint8_t g_fSignaled = false; 43 | 44 | void SignalHandler(int sig){ 45 | printf("Caught signal %d\n", sig); 46 | g_fSignaled = true; 47 | } 48 | 49 | 50 | int main() 51 | { 52 | // Install signal handler to allow us to do some cleanup... 53 | struct sigaction sigIntHandler; 54 | 55 | sigIntHandler.sa_handler = SignalHandler; 56 | sigemptyset(&sigIntHandler.sa_mask); 57 | sigIntHandler.sa_flags = 0; 58 | 59 | sigaction(SIGINT, &sigIntHandler, NULL); 60 | sigaction(SIGQUIT, &sigIntHandler, NULL); 61 | 62 | 63 | setup(); 64 | 65 | while (!g_fSignaled) 66 | { 67 | loop(); 68 | } 69 | // Call cleanup function and exit; 70 | cleanup(); 71 | } 72 | -------------------------------------------------------------------------------- /Phoenix_fixed/PhantomX/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = Phantom_Phoenix 3 | 4 | BIOLOIDEX = BioloidEX 5 | 6 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 7 | SOURCES = \ 8 | Phantom_Phoenix.cpp \ 9 | ../src/Phoenix_Code.cpp \ 10 | ../src/Phoenix_Input_Commander.cpp \ 11 | ../src/Phoenix_Driver_AX12.cpp 12 | 13 | MAIN_OBJS:= $(notdir $(subst .cpp,.o,$(SOURCES))) 14 | 15 | MAIN_DEPS:= $(notdir $(subst .cpp,.d,$(SOURCES))) 16 | 17 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 18 | ifeq ($(OSTYPE),linux-gnueabi) 19 | #BBBk 20 | INCLUDE_DIRS = -I. -I../src/ -I../../library -I../../library_extras -I../../$(BIOLOIDEX) 21 | else 22 | INCLUDE_DIRS = -I. -I../src/ -I../../library -I../../library_extras -I../../$(BIOLOIDEX) -I/usr/include/espeak 23 | endif 24 | 25 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 26 | ifeq ($(OSTYPE),linux-gnueabi) 27 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../../library -L../../library_extras -L../$(BIOLOIDEX) -L../library 28 | else 29 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../../library -L../../library_extras -L../../$(BIOLOIDEX) -L../library 30 | endif 31 | 32 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 33 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 34 | 35 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 36 | ifeq ($(OSTYPE),linux-gnueabi) 37 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lPortExtras -l-lasound -lespeak -lrt 38 | else 39 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lPortExtras -lespeak -lasound -lrt 40 | endif 41 | 42 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 43 | ifeq ($(OSTYPE),linux-gnueabi) 44 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 45 | else 46 | TCHAIN_PREFIX= 47 | #TCHAIN_PREFIX=arm-linux-gnueabihf- 48 | endif 49 | #TCHAIN_PREFIX=x86_64-linux-gnu- 50 | 51 | CXX = $(TCHAIN_PREFIX)g++ 52 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 53 | 54 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 55 | all: LIBRARY LIBRARY_EXTRAS BioloidEX begin gccversion build end 56 | 57 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 58 | BioloidEX: 59 | cd ../../$(BIOLOIDEX); $(MAKE) 60 | 61 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 62 | LIBRARY: 63 | cd ../../library; $(MAKE) 64 | 65 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 66 | LIBRARY_EXTRAS: 67 | cd ../../library_extras; $(MAKE) 68 | 69 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 70 | build: $(MAIN_OUT) 71 | 72 | %.o: ../src/%.cpp 73 | $(CXX) $(CXXFLAGS) -c $< 74 | 75 | 76 | # added specific dependence on my own library... 77 | $(MAIN_OUT): $(MAIN_OBJS) ../../library/libArduinoPort.a ../../BioloidEX/libBioloidEX.a 78 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 79 | 80 | MSG_BEGIN = -------- begin -------- 81 | MSG_END = -------- end -------- 82 | 83 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 84 | begin: 85 | @echo 86 | @echo $(MSG_BEGIN) 87 | 88 | end: 89 | @echo $(MSG_END) 90 | @echo 91 | 92 | gccversion: 93 | @$(CC) --version 94 | 95 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 96 | clean: begin clean_list end 97 | 98 | clean_list: 99 | -rm -f $(MAIN_OBJS) 100 | -rm -f $(MAIN_OUT) 101 | -rm -f $(MAIN_DEPS) 102 | -cd ../../library ; make clean 103 | 104 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 105 | backup: clean 106 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 107 | 108 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 109 | include $(notdir $(subst .cpp,.d,$(SOURCES))) 110 | 111 | %.d: %.cpp 112 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 113 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 114 | rm -f $@.$$$$ 115 | 116 | %.d: ../src/%.cpp 117 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 118 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 119 | rm -f $@.$$$$ 120 | -------------------------------------------------------------------------------- /Phoenix_fixed/PhantomX_joy/Phantom_Phoenix.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | 28 | #include "Hex_Cfg.h" 29 | #include "Phoenix.h" 30 | #include "speak.h" 31 | #include 32 | 33 | 34 | 35 | extern void setup(void); 36 | extern void loop(void); 37 | extern void cleanup(void); 38 | 39 | //-------------------------------------------------------------------------- 40 | // SignalHandler - Try to free up things like servos if we abort. 41 | //-------------------------------------------------------------------------- 42 | volatile uint8_t g_fSignaled = false; 43 | 44 | void SignalHandler(int sig){ 45 | printf("Caught signal %d\n", sig); 46 | g_fSignaled = true; 47 | } 48 | 49 | 50 | int main() 51 | { 52 | // Install signal handler to allow us to do some cleanup... 53 | struct sigaction sigIntHandler; 54 | 55 | sigIntHandler.sa_handler = SignalHandler; 56 | sigemptyset(&sigIntHandler.sa_mask); 57 | sigIntHandler.sa_flags = 0; 58 | 59 | sigaction(SIGINT, &sigIntHandler, NULL); 60 | sigaction(SIGQUIT, &sigIntHandler, NULL); 61 | 62 | 63 | setup(); 64 | 65 | while (!g_fSignaled) 66 | { 67 | loop(); 68 | } 69 | // Call cleanup function and exit; 70 | cleanup(); 71 | } 72 | -------------------------------------------------------------------------------- /Phoenix_fixed/PhantomX_joy/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = Phantom_Phoenix 3 | 4 | BIOLOIDEX = BioloidEX 5 | 6 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 7 | SOURCES = \ 8 | Phantom_Phoenix.cpp \ 9 | ../src/Phoenix_Code.cpp \ 10 | ../src/Phoenix_Input_Joystick.cpp \ 11 | ../src/Phoenix_Driver_AX12.cpp 12 | 13 | MAIN_OBJS:= $(notdir $(subst .cpp,.o,$(SOURCES))) 14 | 15 | MAIN_DEPS:= $(notdir $(subst .cpp,.d,$(SOURCES))) 16 | 17 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 18 | ifeq ($(OSTYPE),linux-gnueabi) 19 | #BBBk 20 | INCLUDE_DIRS = -I. -I../src/ -I../../library -I../../$(BIOLOIDEX) 21 | else 22 | INCLUDE_DIRS = -I. -I../src/ -I../../library -I../../$(BIOLOIDEX) -I/usr/include/espeak 23 | endif 24 | 25 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 26 | ifeq ($(OSTYPE),linux-gnueabi) 27 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../../library -L../$(BIOLOIDEX) -L../library 28 | else 29 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../../library -L../../$(BIOLOIDEX) -L../library 30 | endif 31 | 32 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 33 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 34 | 35 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 36 | ifeq ($(OSTYPE),linux-gnueabi) 37 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lasound -lespeak -lrt 38 | else 39 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lespeak -lasound -lrt 40 | endif 41 | 42 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 43 | ifeq ($(OSTYPE),linux-gnueabi) 44 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 45 | else 46 | TCHAIN_PREFIX=arm-linux-gnueabihf- 47 | endif 48 | #TCHAIN_PREFIX=x86_64-linux-gnu- 49 | 50 | CXX = $(TCHAIN_PREFIX)g++ 51 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 52 | 53 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 54 | all: LIBRARY BioloidEX begin gccversion build end 55 | 56 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 57 | BioloidEX: 58 | cd ../../$(BIOLOIDEX); $(MAKE) 59 | 60 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 61 | LIBRARY: 62 | cd ../../library; $(MAKE) 63 | 64 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 65 | build: $(MAIN_OUT) 66 | 67 | %.o: ../src/%.cpp 68 | $(CXX) $(CXXFLAGS) -c $< 69 | 70 | 71 | # added specific dependence on my own library... 72 | $(MAIN_OUT): $(MAIN_OBJS) ../../library/libArduinoPort.a ../../BioloidEX/libBioloidEX.a 73 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 74 | 75 | MSG_BEGIN = -------- begin -------- 76 | MSG_END = -------- end -------- 77 | 78 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 79 | begin: 80 | @echo 81 | @echo $(MSG_BEGIN) 82 | 83 | end: 84 | @echo $(MSG_END) 85 | @echo 86 | 87 | gccversion: 88 | @$(CC) --version 89 | 90 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 91 | clean: begin clean_list end 92 | 93 | clean_list: 94 | -rm -f $(MAIN_OBJS) 95 | -rm -f $(MAIN_OUT) 96 | -rm -f $(MAIN_DEPS) 97 | -cd ../../library ; make clean 98 | 99 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 100 | backup: clean 101 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 102 | 103 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 104 | include $(notdir $(subst .cpp,.d,$(SOURCES))) 105 | 106 | %.d: %.cpp 107 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 108 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 109 | rm -f $@.$$$$ 110 | 111 | %.d: ../src/%.cpp 112 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 113 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 114 | rm -f $@.$$$$ 115 | -------------------------------------------------------------------------------- /Phoenix_fixed/THR4/THR4.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | 28 | #include "Hex_Cfg.h" 29 | #include "Phoenix.h" 30 | #include "speak.h" 31 | extern void setup(void); 32 | extern void loop(void); 33 | 34 | int main() 35 | { 36 | setup(); 37 | 38 | for(;;) 39 | { 40 | loop(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Phoenix_fixed/THR4/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = THR4_Commander_SSC32 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | THR4.cpp \ 7 | ../src/Phoenix_Code.cpp \ 8 | ../src/Phoenix_Input_Commander.cpp \ 9 | ../src/Phoenix_Driver_SSC32.cpp 10 | 11 | MAIN_OBJS:= $(notdir $(subst .cpp,.o,$(SOURCES))) 12 | 13 | MAIN_DEPS:= $(notdir $(subst .cpp,.d,$(SOURCES))) 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 16 | ifeq ($(OSTYPE),linux-gnueabi) 17 | #BBBk 18 | INCLUDE_DIRS = -I. -I../src/ -I../../library 19 | else 20 | INCLUDE_DIRS = -I. -I../src/ -I../../library -I/usr/include/espeak 21 | endif 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 24 | ifeq ($(OSTYPE),linux-gnueabi) 25 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../../library 26 | else 27 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../../library 28 | endif 29 | 30 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 31 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 32 | 33 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 34 | ifeq ($(OSTYPE),linux-gnueabi) 35 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak -lrt 36 | else 37 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak 38 | endif 39 | 40 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 41 | ifeq ($(OSTYPE),linux-gnueabi) 42 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 43 | else 44 | TCHAIN_PREFIX=arm-linux-gnueabihf- 45 | endif 46 | #TCHAIN_PREFIX=x86_64-linux-gnu- 47 | 48 | CXX = $(TCHAIN_PREFIX)g++ 49 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 50 | 51 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 52 | all: LIBRARY begin gccversion build end 53 | 54 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 55 | LIBRARY: 56 | cd ../../library; $(MAKE) 57 | 58 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 59 | build: $(MAIN_OUT) 60 | 61 | %.o: ../src/%.cpp 62 | $(CXX) $(CXXFLAGS) -c $< 63 | 64 | 65 | # added specific dependence on my own library... 66 | $(MAIN_OUT): $(MAIN_OBJS) ../../library/libArduinoPort.a 67 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 68 | 69 | MSG_BEGIN = -------- begin -------- 70 | MSG_END = -------- end -------- 71 | 72 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 73 | begin: 74 | @echo 75 | @echo $(MSG_BEGIN) 76 | 77 | end: 78 | @echo $(MSG_END) 79 | @echo 80 | 81 | gccversion: 82 | @$(CC) --version 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 85 | clean: begin clean_list end 86 | 87 | clean_list: 88 | -rm -f $(MAIN_OBJS) 89 | -rm -f $(MAIN_OUT) 90 | -rm -f $(MAIN_DEPS) 91 | -cd ../../library ; make clean 92 | 93 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 94 | backup: clean 95 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 96 | 97 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 98 | include $(notdir $(subst .cpp,.d,$(SOURCES))) 99 | 100 | %.d: %.cpp 101 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 102 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 103 | rm -f $@.$$$$ 104 | 105 | %.d: ../src/%.cpp 106 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 107 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 108 | rm -f $@.$$$$ 109 | -------------------------------------------------------------------------------- /Phoenix_fixed/THR4/makefile_THSX: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = THR4_DIY_SSC32 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | THR4.cpp \ 7 | Phoenix_Code.cpp \ 8 | Phoenix_Driver_SSC32.cpp \ 9 | Phoenix_Input_DIYXBee.cpp 10 | 11 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 12 | 13 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 16 | ifeq ($(OSTYPE),linux-gnueabi) 17 | #BBBk 18 | INCLUDE_DIRS = -I. -I../library 19 | else 20 | INCLUDE_DIRS = -I. -I../library -I/usr/include/espeak 21 | endif 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 24 | ifeq ($(OSTYPE),linux-gnueabi) 25 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../library 26 | else 27 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 28 | endif 29 | 30 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 31 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 32 | #COMPILE_OPTS = -Wall -pedantic -g -O2 33 | 34 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 35 | ifeq ($(OSTYPE),linux-gnueabi) 36 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak -lrt 37 | else 38 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lespeak -lArduinoPort 39 | endif 40 | 41 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 42 | ifeq ($(OSTYPE),linux-gnueabi) 43 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 44 | else 45 | TCHAIN_PREFIX=arm-linux-gnueabihf- 46 | endif 47 | #TCHAIN_PREFIX=x86_64-linux-gnu- 48 | 49 | CXX = $(TCHAIN_PREFIX)g++ 50 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 51 | 52 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 53 | all: begin gccversion build end 54 | 55 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 56 | build: $(MAIN_OUT) 57 | 58 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a 59 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 60 | 61 | MSG_BEGIN = -------- begin -------- 62 | MSG_END = -------- end -------- 63 | 64 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 65 | begin: 66 | @echo 67 | @echo $(MSG_BEGIN) 68 | 69 | end: 70 | @echo $(MSG_END) 71 | @echo 72 | 73 | gccversion: 74 | @$(CC) --version 75 | 76 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 77 | clean: begin clean_list end 78 | 79 | clean_list: 80 | -rm -f $(MAIN_OBJS) 81 | -rm -f $(MAIN_OUT) 82 | -rm -f $(MAIN_DEPS) 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 85 | backup: clean 86 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 87 | 88 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 89 | include $(subst .cpp,.d,$(SOURCES)) 90 | 91 | %.d: %.cpp 92 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 93 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 94 | rm -f $@.$$$$ 95 | -------------------------------------------------------------------------------- /Phoenix_fixed/THR4/makefile_both: -------------------------------------------------------------------------------- 1 | lib:= LIBRARY 2 | Prog1:= THex3_Commander_SSC32 3 | Prog2:= THex3_DIY_SSC32 4 | 5 | Programs := $(lib) $(Prog1) $(Prog2) 6 | 7 | 8 | .PHONY: all $(Programs) 9 | 10 | all: $(Programs) 11 | 12 | 13 | LIBRARY: 14 | cd ../library; $(MAKE) 15 | 16 | THex3_Commander_SSC32: 17 | $(MAKE) -f makefile_THSC $(MAKECMDGOALS) 18 | 19 | THex3_DIY_SSC32: 20 | $(MAKE) -f makefile_THSX $(MAKECMDGOALS) 21 | 22 | clean: 23 | $(MAKE) -f makefile_THSC clean 24 | $(MAKE) -f makefile_THSX clean 25 | cd ../library ; $(MAKE) clean 26 | -------------------------------------------------------------------------------- /Phoenix_fixed/THex/THR4.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | 28 | #include "Hex_Cfg.h" 29 | #include "Phoenix.h" 30 | #include "speak.h" 31 | extern void setup(void); 32 | extern void loop(void); 33 | 34 | int main() 35 | { 36 | setup(); 37 | 38 | for(;;) 39 | { 40 | loop(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Phoenix_fixed/THex/THex.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | 28 | #include "Hex_Cfg.h" 29 | #include "Phoenix.h" 30 | #include "speak.h" 31 | extern void setup(void); 32 | extern void loop(void); 33 | 34 | int main() 35 | { 36 | setup(); 37 | 38 | for(;;) 39 | { 40 | loop(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Phoenix_fixed/THex/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = THex_Commander_SSC32 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | THex.cpp \ 7 | ../src/Phoenix_Code.cpp \ 8 | ../src/Phoenix_Input_Commander.cpp \ 9 | ../src/Phoenix_Driver_SSC32.cpp 10 | 11 | MAIN_OBJS:= $(notdir $(subst .cpp,.o,$(SOURCES))) 12 | 13 | MAIN_DEPS:= $(notdir $(subst .cpp,.d,$(SOURCES))) 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 16 | ifeq ($(OSTYPE),linux-gnueabi) 17 | #BBBk 18 | INCLUDE_DIRS = -I. -I../src/ -I../../library 19 | else 20 | INCLUDE_DIRS = -I. -I../src/ -I../../library -I/usr/include/espeak 21 | endif 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 24 | ifeq ($(OSTYPE),linux-gnueabi) 25 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../../library 26 | else 27 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../../library 28 | endif 29 | 30 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 31 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 32 | 33 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 34 | ifeq ($(OSTYPE),linux-gnueabi) 35 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak -lrt 36 | else 37 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak 38 | endif 39 | 40 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 41 | ifeq ($(OSTYPE),linux-gnueabi) 42 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 43 | else 44 | TCHAIN_PREFIX=arm-linux-gnueabihf- 45 | endif 46 | #TCHAIN_PREFIX=x86_64-linux-gnu- 47 | 48 | CXX = $(TCHAIN_PREFIX)g++ 49 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 50 | 51 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 52 | all: LIBRARY begin gccversion build end 53 | 54 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 55 | LIBRARY: 56 | cd ../../library; $(MAKE) 57 | 58 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 59 | build: $(MAIN_OUT) 60 | 61 | %.o: ../src/%.cpp 62 | $(CXX) $(CXXFLAGS) -c $< 63 | 64 | 65 | # added specific dependence on my own library... 66 | $(MAIN_OUT): $(MAIN_OBJS) ../../library/libArduinoPort.a 67 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 68 | 69 | MSG_BEGIN = -------- begin -------- 70 | MSG_END = -------- end -------- 71 | 72 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 73 | begin: 74 | @echo 75 | @echo $(MSG_BEGIN) 76 | 77 | end: 78 | @echo $(MSG_END) 79 | @echo 80 | 81 | gccversion: 82 | @$(CC) --version 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 85 | clean: begin clean_list end 86 | 87 | clean_list: 88 | -rm -f $(MAIN_OBJS) 89 | -rm -f $(MAIN_OUT) 90 | -rm -f $(MAIN_DEPS) 91 | -cd ../../library ; make clean 92 | 93 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 94 | backup: clean 95 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 96 | 97 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 98 | include $(notdir $(subst .cpp,.d,$(SOURCES))) 99 | 100 | %.d: %.cpp 101 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 102 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 103 | rm -f $@.$$$$ 104 | 105 | %.d: ../src/%.cpp 106 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 107 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 108 | rm -f $@.$$$$ 109 | -------------------------------------------------------------------------------- /Phoenix_fixed/THex/makefile_THSX: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = THR4_DIY_SSC32 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | THR4.cpp \ 7 | Phoenix_Code.cpp \ 8 | Phoenix_Driver_SSC32.cpp \ 9 | Phoenix_Input_DIYXBee.cpp 10 | 11 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 12 | 13 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 16 | ifeq ($(OSTYPE),linux-gnueabi) 17 | #BBBk 18 | INCLUDE_DIRS = -I. -I../library 19 | else 20 | INCLUDE_DIRS = -I. -I../library -I/usr/include/espeak 21 | endif 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 24 | ifeq ($(OSTYPE),linux-gnueabi) 25 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../library 26 | else 27 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 28 | endif 29 | 30 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 31 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 32 | #COMPILE_OPTS = -Wall -pedantic -g -O2 33 | 34 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 35 | ifeq ($(OSTYPE),linux-gnueabi) 36 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak -lrt 37 | else 38 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lespeak -lArduinoPort 39 | endif 40 | 41 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 42 | ifeq ($(OSTYPE),linux-gnueabi) 43 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 44 | else 45 | TCHAIN_PREFIX=arm-linux-gnueabihf- 46 | endif 47 | #TCHAIN_PREFIX=x86_64-linux-gnu- 48 | 49 | CXX = $(TCHAIN_PREFIX)g++ 50 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 51 | 52 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 53 | all: begin gccversion build end 54 | 55 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 56 | build: $(MAIN_OUT) 57 | 58 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a 59 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 60 | 61 | MSG_BEGIN = -------- begin -------- 62 | MSG_END = -------- end -------- 63 | 64 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 65 | begin: 66 | @echo 67 | @echo $(MSG_BEGIN) 68 | 69 | end: 70 | @echo $(MSG_END) 71 | @echo 72 | 73 | gccversion: 74 | @$(CC) --version 75 | 76 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 77 | clean: begin clean_list end 78 | 79 | clean_list: 80 | -rm -f $(MAIN_OBJS) 81 | -rm -f $(MAIN_OUT) 82 | -rm -f $(MAIN_DEPS) 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 85 | backup: clean 86 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 87 | 88 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 89 | include $(subst .cpp,.d,$(SOURCES)) 90 | 91 | %.d: %.cpp 92 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 93 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 94 | rm -f $@.$$$$ 95 | -------------------------------------------------------------------------------- /Phoenix_fixed/THex/makefile_both: -------------------------------------------------------------------------------- 1 | lib:= LIBRARY 2 | Prog1:= THex3_Commander_SSC32 3 | Prog2:= THex3_DIY_SSC32 4 | 5 | Programs := $(lib) $(Prog1) $(Prog2) 6 | 7 | 8 | .PHONY: all $(Programs) 9 | 10 | all: $(Programs) 11 | 12 | 13 | LIBRARY: 14 | cd ../library; $(MAKE) 15 | 16 | THex3_Commander_SSC32: 17 | $(MAKE) -f makefile_THSC $(MAKECMDGOALS) 18 | 19 | THex3_DIY_SSC32: 20 | $(MAKE) -f makefile_THSX $(MAKECMDGOALS) 21 | 22 | clean: 23 | $(MAKE) -f makefile_THSC clean 24 | $(MAKE) -f makefile_THSX clean 25 | cd ../library ; $(MAKE) clean 26 | -------------------------------------------------------------------------------- /Phoenix_fixed/src/ArduinoDefs.h: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | // 5 | // 6 | // Arduino(ish) defines to get the Phoenix software to run on RPI 7 | // 8 | // This library is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU Lesser General Public 10 | // License as published by the Free Software Foundation; either 11 | // version 2.1 of the License, or (at your option) any later version. 12 | 13 | // This library is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | // Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public 19 | // License along with this library; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | // 22 | //============================================================================= 23 | #ifndef _ARDUINO_DEFS_ 24 | #define _ARDUINO_DEFS_ 25 | #include 26 | #define PROGMEM 27 | #define pgm_read_byte(x) (*((char *)x)) 28 | // #define pgm_read_word(x) (*((short *)(x & 0xfffffffe))) 29 | #define pgm_read_word(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 30 | #define pgm_read_byte_near(x) (*((char *)x)) 31 | #define pgm_read_byte_far(x) (*((char *)x)) 32 | // #define pgm_read_word_near(x) (*((short *)(x & 0xfffffffe)) 33 | // #define pgm_read_word_far(x) (*((short *)(x & 0xfffffffe))) 34 | #define pgm_read_word_near(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 35 | #define pgm_read_word_far(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))) 36 | #define PSTR(x) x 37 | #define F(x) x 38 | #define PGM_P const char * 39 | 40 | // Define some data types? 41 | //#define byte unsigned char 42 | typedef unsigned char byte; 43 | //#define uint8_t unsigned char 44 | //#define uint16_t unsigned short 45 | //#define uint32_t unsigned long 46 | #define word unsigned short 47 | #define boolean bool 48 | 49 | #define delay(x) usleep((x)*1000) 50 | #define delayMicroseconds(us) usleep((us)) 51 | extern unsigned long millis(void); 52 | extern unsigned long micros(void); 53 | extern long min(long a, long b); 54 | extern long max(long a, long b); 55 | extern long map(long x, long in_min, long in_max, long out_min, long out_max); 56 | #endif 57 | -------------------------------------------------------------------------------- /Phoenix_fixed/src/Phoenix.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KurtE/Raspberry_Pi/515f138ecb2ca2c0e96b7343ccf14b87653faaad/Phoenix_fixed/src/Phoenix.h -------------------------------------------------------------------------------- /Phoenix_float/PhantomX/Phantom_Phoenix.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | 28 | #include "Hex_Cfg.h" 29 | #include "Phoenix.h" 30 | #include "speak.h" 31 | extern void setup(void); 32 | extern void loop(void); 33 | 34 | int main() 35 | { 36 | setup(); 37 | 38 | for(;;) 39 | { 40 | loop(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Phoenix_float/PhantomX/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = Phantom_Phoenix 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | Phantom_Phoenix.cpp \ 7 | ../src/Phoenix_Code.cpp \ 8 | ../src/Phoenix_Input_Commander.cpp \ 9 | ../src/Phoenix_Driver_AX12.cpp 10 | 11 | MAIN_OBJS:= $(notdir $(subst .cpp,.o,$(SOURCES))) 12 | 13 | MAIN_DEPS:= $(notdir $(subst .cpp,.d,$(SOURCES))) 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 16 | ifeq ($(OSTYPE),linux-gnueabi) 17 | #BBBk 18 | INCLUDE_DIRS = -I. -I../src/ -I../../library -I../../BioloidEX_Usb2Ax 19 | else 20 | INCLUDE_DIRS = -I. -I../src/ -I../../library -I../../BioloidEX_Usb2Ax -I/usr/include/espeak 21 | endif 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 24 | ifeq ($(OSTYPE),linux-gnueabi) 25 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../../library -L../BioloidEX_Usb2Ax -L../library 26 | else 27 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../../library -L../../BioloidEX_Usb2Ax -L../library 28 | endif 29 | 30 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 31 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 32 | 33 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 34 | ifeq ($(OSTYPE),linux-gnueabi) 35 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lasound -lespeak -lrt 36 | else 37 | ifeq ($(OSTYPE),Edison) 38 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lrt 39 | else 40 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lBioloidEX -lArduinoPort -lespeak -lasound 41 | endif 42 | endif 43 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 44 | ifeq ($(OSTYPE),linux-gnueabi) 45 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 46 | else 47 | ifeq ($(OSTYPE),Edison) 48 | #Edison hard coded OSTYPE 49 | TCHAIN_PREFIX=i586-poky-linux- 50 | else 51 | TCHAIN_PREFIX=arm-linux-gnueabihf- 52 | endif 53 | endif 54 | #TCHAIN_PREFIX=x86_64-linux-gnu- 55 | 56 | CXX = $(TCHAIN_PREFIX)g++ 57 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 58 | 59 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 60 | all: LIBRARY BioloidEX_Usb2Ax begin gccversion build end 61 | 62 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 63 | BioloidEX_Usb2Ax: 64 | cd ../../BioloidEX_Usb2Ax; $(MAKE) 65 | 66 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 67 | LIBRARY: 68 | cd ../../library; $(MAKE) 69 | 70 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 71 | build: $(MAIN_OUT) 72 | 73 | %.o: ../src/%.cpp 74 | $(CXX) $(CXXFLAGS) -c $< 75 | 76 | 77 | # added specific dependence on my own library... 78 | $(MAIN_OUT): $(MAIN_OBJS) ../../library/libArduinoPort.a 79 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 80 | 81 | MSG_BEGIN = -------- begin -------- 82 | MSG_END = -------- end -------- 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 85 | begin: 86 | @echo 87 | @echo $(MSG_BEGIN) 88 | 89 | end: 90 | @echo $(MSG_END) 91 | @echo 92 | 93 | gccversion: 94 | @$(CC) --version 95 | 96 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 97 | clean: begin clean_list end 98 | 99 | clean_list: 100 | -rm -f $(MAIN_OBJS) 101 | -rm -f $(MAIN_OUT) 102 | -rm -f $(MAIN_DEPS) 103 | -cd ../../library ; make clean 104 | 105 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 106 | backup: clean 107 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 108 | 109 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 110 | include $(notdir $(subst .cpp,.d,$(SOURCES))) 111 | 112 | %.d: %.cpp 113 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 114 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 115 | rm -f $@.$$$$ 116 | 117 | %.d: ../src/%.cpp 118 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 119 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 120 | rm -f $@.$$$$ 121 | -------------------------------------------------------------------------------- /Phoenix_float/THR4/THR4.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | 28 | #include "Hex_Cfg.h" 29 | #include "Phoenix.h" 30 | #include "speak.h" 31 | extern void setup(void); 32 | extern void loop(void); 33 | 34 | int main() 35 | { 36 | setup(); 37 | 38 | for(;;) 39 | { 40 | loop(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Phoenix_float/THR4/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = THR4_Commander_SSC32 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | THR4.cpp \ 7 | ../src/Phoenix_Code.cpp \ 8 | ../src/Phoenix_Input_Commander.cpp \ 9 | ../src/Phoenix_Driver_SSC32.cpp 10 | 11 | MAIN_OBJS:= $(notdir $(subst .cpp,.o,$(SOURCES))) 12 | 13 | MAIN_DEPS:= $(notdir $(subst .cpp,.d,$(SOURCES))) 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 16 | ifeq ($(OSTYPE),linux-gnueabi) 17 | #BBBk 18 | INCLUDE_DIRS = -I. -I../src/ -I../../library 19 | else 20 | INCLUDE_DIRS = -I. -I../src/ -I../../library -I/usr/include/espeak 21 | endif 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 24 | ifeq ($(OSTYPE),linux-gnueabi) 25 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../../library 26 | else 27 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../../library 28 | endif 29 | 30 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 31 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 32 | 33 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 34 | ifeq ($(OSTYPE),linux-gnueabi) 35 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak -lrt 36 | else 37 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak 38 | endif 39 | 40 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 41 | ifeq ($(OSTYPE),linux-gnueabi) 42 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 43 | else 44 | TCHAIN_PREFIX=arm-linux-gnueabihf- 45 | endif 46 | #TCHAIN_PREFIX=x86_64-linux-gnu- 47 | 48 | CXX = $(TCHAIN_PREFIX)g++ 49 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 50 | 51 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 52 | all: LIBRARY begin gccversion build end 53 | 54 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 55 | LIBRARY: 56 | cd ../../library; $(MAKE) 57 | 58 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 59 | build: $(MAIN_OUT) 60 | 61 | %.o: ../src/%.cpp 62 | $(CXX) $(CXXFLAGS) -c $< 63 | 64 | 65 | # added specific dependence on my own library... 66 | $(MAIN_OUT): $(MAIN_OBJS) ../../library/libArduinoPort.a 67 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 68 | 69 | MSG_BEGIN = -------- begin -------- 70 | MSG_END = -------- end -------- 71 | 72 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 73 | begin: 74 | @echo 75 | @echo $(MSG_BEGIN) 76 | 77 | end: 78 | @echo $(MSG_END) 79 | @echo 80 | 81 | gccversion: 82 | @$(CC) --version 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 85 | clean: begin clean_list end 86 | 87 | clean_list: 88 | -rm -f $(MAIN_OBJS) 89 | -rm -f $(MAIN_OUT) 90 | -rm -f $(MAIN_DEPS) 91 | -cd ../../library ; make clean 92 | 93 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 94 | backup: clean 95 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 96 | 97 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 98 | include $(notdir $(subst .cpp,.d,$(SOURCES))) 99 | 100 | %.d: %.cpp 101 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 102 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 103 | rm -f $@.$$$$ 104 | 105 | %.d: ../src/%.cpp 106 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 107 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 108 | rm -f $@.$$$$ 109 | -------------------------------------------------------------------------------- /Phoenix_float/THR4/makefile_THSX: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = THR4_DIY_SSC32 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | THR4.cpp \ 7 | Phoenix_Code.cpp \ 8 | Phoenix_Driver_SSC32.cpp \ 9 | Phoenix_Input_DIYXBee.cpp 10 | 11 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 12 | 13 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 16 | ifeq ($(OSTYPE),linux-gnueabi) 17 | #BBBk 18 | INCLUDE_DIRS = -I. -I../library 19 | else 20 | INCLUDE_DIRS = -I. -I../library -I/usr/include/espeak 21 | endif 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 24 | ifeq ($(OSTYPE),linux-gnueabi) 25 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../library 26 | else 27 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 28 | endif 29 | 30 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 31 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 32 | #COMPILE_OPTS = -Wall -pedantic -g -O2 33 | 34 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 35 | ifeq ($(OSTYPE),linux-gnueabi) 36 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak -lrt 37 | else 38 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lespeak -lArduinoPort 39 | endif 40 | 41 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 42 | ifeq ($(OSTYPE),linux-gnueabi) 43 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 44 | else 45 | TCHAIN_PREFIX=arm-linux-gnueabihf- 46 | endif 47 | #TCHAIN_PREFIX=x86_64-linux-gnu- 48 | 49 | CXX = $(TCHAIN_PREFIX)g++ 50 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 51 | 52 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 53 | all: begin gccversion build end 54 | 55 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 56 | build: $(MAIN_OUT) 57 | 58 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a 59 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 60 | 61 | MSG_BEGIN = -------- begin -------- 62 | MSG_END = -------- end -------- 63 | 64 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 65 | begin: 66 | @echo 67 | @echo $(MSG_BEGIN) 68 | 69 | end: 70 | @echo $(MSG_END) 71 | @echo 72 | 73 | gccversion: 74 | @$(CC) --version 75 | 76 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 77 | clean: begin clean_list end 78 | 79 | clean_list: 80 | -rm -f $(MAIN_OBJS) 81 | -rm -f $(MAIN_OUT) 82 | -rm -f $(MAIN_DEPS) 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 85 | backup: clean 86 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 87 | 88 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 89 | include $(subst .cpp,.d,$(SOURCES)) 90 | 91 | %.d: %.cpp 92 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 93 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 94 | rm -f $@.$$$$ 95 | -------------------------------------------------------------------------------- /Phoenix_float/THR4/makefile_both: -------------------------------------------------------------------------------- 1 | lib:= LIBRARY 2 | Prog1:= THex3_Commander_SSC32 3 | Prog2:= THex3_DIY_SSC32 4 | 5 | Programs := $(lib) $(Prog1) $(Prog2) 6 | 7 | 8 | .PHONY: all $(Programs) 9 | 10 | all: $(Programs) 11 | 12 | 13 | LIBRARY: 14 | cd ../library; $(MAKE) 15 | 16 | THex3_Commander_SSC32: 17 | $(MAKE) -f makefile_THSC $(MAKECMDGOALS) 18 | 19 | THex3_DIY_SSC32: 20 | $(MAKE) -f makefile_THSX $(MAKECMDGOALS) 21 | 22 | clean: 23 | $(MAKE) -f makefile_THSC clean 24 | $(MAKE) -f makefile_THSX clean 25 | cd ../library ; $(MAKE) clean 26 | -------------------------------------------------------------------------------- /Phoenix_float/THex/THR4.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | 28 | #include "Hex_Cfg.h" 29 | #include "Phoenix.h" 30 | #include "speak.h" 31 | extern void setup(void); 32 | extern void loop(void); 33 | 34 | int main() 35 | { 36 | setup(); 37 | 38 | for(;;) 39 | { 40 | loop(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Phoenix_float/THex/THex.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | //Software version: V2.0 5 | //Date: 29-10-2009 6 | //Programmer: Jeroen Janssen [aka Xan] 7 | // Kurt Eckhardt(KurtE) converted to C and Arduino 8 | // Kåre Halvorsen aka Zenta - Makes everything work correctly! 9 | // 10 | // This version of the Phoenix code was ported over to the Arduino Environement 11 | // and is specifically configured for the Arbotix Robocontroller board 12 | // 13 | //============================================================================= 14 | // 15 | //KNOWN BUGS: 16 | // - Lots ;) 17 | // 18 | //============================================================================= 19 | // Header Files 20 | //============================================================================= 21 | 22 | #define DEFINE_HEX_GLOBALS 23 | #if ARDUINO>99 24 | #include 25 | #else 26 | #endif 27 | 28 | #include "Hex_Cfg.h" 29 | #include "Phoenix.h" 30 | #include "speak.h" 31 | extern void setup(void); 32 | extern void loop(void); 33 | 34 | int main() 35 | { 36 | setup(); 37 | 38 | for(;;) 39 | { 40 | loop(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Phoenix_float/THex/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = THex_Commander_SSC32 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | THex.cpp \ 7 | ../src/Phoenix_Code.cpp \ 8 | ../src/Phoenix_Input_Commander.cpp \ 9 | ../src/Phoenix_Driver_SSC32.cpp 10 | 11 | MAIN_OBJS:= $(notdir $(subst .cpp,.o,$(SOURCES))) 12 | 13 | MAIN_DEPS:= $(notdir $(subst .cpp,.d,$(SOURCES))) 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 16 | ifeq ($(OSTYPE),linux-gnueabi) 17 | #BBBk 18 | INCLUDE_DIRS = -I. -I../src/ -I../../library 19 | else 20 | INCLUDE_DIRS = -I. -I../src/ -I../../library -I/usr/include/espeak 21 | endif 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 24 | ifeq ($(OSTYPE),linux-gnueabi) 25 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../../library 26 | else 27 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../../library 28 | endif 29 | 30 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 31 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 32 | 33 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 34 | ifeq ($(OSTYPE),linux-gnueabi) 35 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak -lrt 36 | else 37 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak 38 | endif 39 | 40 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 41 | ifeq ($(OSTYPE),linux-gnueabi) 42 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 43 | else 44 | TCHAIN_PREFIX=arm-linux-gnueabihf- 45 | endif 46 | #TCHAIN_PREFIX=x86_64-linux-gnu- 47 | 48 | CXX = $(TCHAIN_PREFIX)g++ 49 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 50 | 51 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 52 | all: LIBRARY begin gccversion build end 53 | 54 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 55 | LIBRARY: 56 | cd ../../library; $(MAKE) 57 | 58 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 59 | build: $(MAIN_OUT) 60 | 61 | %.o: ../src/%.cpp 62 | $(CXX) $(CXXFLAGS) -c $< 63 | 64 | 65 | # added specific dependence on my own library... 66 | $(MAIN_OUT): $(MAIN_OBJS) ../../library/libArduinoPort.a 67 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 68 | 69 | MSG_BEGIN = -------- begin -------- 70 | MSG_END = -------- end -------- 71 | 72 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 73 | begin: 74 | @echo 75 | @echo $(MSG_BEGIN) 76 | 77 | end: 78 | @echo $(MSG_END) 79 | @echo 80 | 81 | gccversion: 82 | @$(CC) --version 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 85 | clean: begin clean_list end 86 | 87 | clean_list: 88 | -rm -f $(MAIN_OBJS) 89 | -rm -f $(MAIN_OUT) 90 | -rm -f $(MAIN_DEPS) 91 | -cd ../../library ; make clean 92 | 93 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 94 | backup: clean 95 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 96 | 97 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 98 | include $(notdir $(subst .cpp,.d,$(SOURCES))) 99 | 100 | %.d: %.cpp 101 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 102 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 103 | rm -f $@.$$$$ 104 | 105 | %.d: ../src/%.cpp 106 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 107 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 108 | rm -f $@.$$$$ 109 | -------------------------------------------------------------------------------- /Phoenix_float/THex/makefile_THSX: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = THR4_DIY_SSC32 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | THR4.cpp \ 7 | Phoenix_Code.cpp \ 8 | Phoenix_Driver_SSC32.cpp \ 9 | Phoenix_Input_DIYXBee.cpp 10 | 11 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 12 | 13 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 16 | ifeq ($(OSTYPE),linux-gnueabi) 17 | #BBBk 18 | INCLUDE_DIRS = -I. -I../library 19 | else 20 | INCLUDE_DIRS = -I. -I../library -I/usr/include/espeak 21 | endif 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 24 | ifeq ($(OSTYPE),linux-gnueabi) 25 | LIBRARY_DIRS = -L/usr/lib/arm-angstrom-linux-gnueabi/4.7.3 -L../library 26 | else 27 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 28 | endif 29 | 30 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 31 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 32 | #COMPILE_OPTS = -Wall -pedantic -g -O2 33 | 34 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 35 | ifeq ($(OSTYPE),linux-gnueabi) 36 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lespeak -lrt 37 | else 38 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lespeak -lArduinoPort 39 | endif 40 | 41 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 42 | ifeq ($(OSTYPE),linux-gnueabi) 43 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 44 | else 45 | TCHAIN_PREFIX=arm-linux-gnueabihf- 46 | endif 47 | #TCHAIN_PREFIX=x86_64-linux-gnu- 48 | 49 | CXX = $(TCHAIN_PREFIX)g++ 50 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 51 | 52 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 53 | all: begin gccversion build end 54 | 55 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 56 | build: $(MAIN_OUT) 57 | 58 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a 59 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 60 | 61 | MSG_BEGIN = -------- begin -------- 62 | MSG_END = -------- end -------- 63 | 64 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 65 | begin: 66 | @echo 67 | @echo $(MSG_BEGIN) 68 | 69 | end: 70 | @echo $(MSG_END) 71 | @echo 72 | 73 | gccversion: 74 | @$(CC) --version 75 | 76 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 77 | clean: begin clean_list end 78 | 79 | clean_list: 80 | -rm -f $(MAIN_OBJS) 81 | -rm -f $(MAIN_OUT) 82 | -rm -f $(MAIN_DEPS) 83 | 84 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 85 | backup: clean 86 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 87 | 88 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 89 | include $(subst .cpp,.d,$(SOURCES)) 90 | 91 | %.d: %.cpp 92 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 93 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 94 | rm -f $@.$$$$ 95 | -------------------------------------------------------------------------------- /Phoenix_float/THex/makefile_both: -------------------------------------------------------------------------------- 1 | lib:= LIBRARY 2 | Prog1:= THex3_Commander_SSC32 3 | Prog2:= THex3_DIY_SSC32 4 | 5 | Programs := $(lib) $(Prog1) $(Prog2) 6 | 7 | 8 | .PHONY: all $(Programs) 9 | 10 | all: $(Programs) 11 | 12 | 13 | LIBRARY: 14 | cd ../library; $(MAKE) 15 | 16 | THex3_Commander_SSC32: 17 | $(MAKE) -f makefile_THSC $(MAKECMDGOALS) 18 | 19 | THex3_DIY_SSC32: 20 | $(MAKE) -f makefile_THSX $(MAKECMDGOALS) 21 | 22 | clean: 23 | $(MAKE) -f makefile_THSC clean 24 | $(MAKE) -f makefile_THSX clean 25 | cd ../library ; $(MAKE) clean 26 | -------------------------------------------------------------------------------- /Phoenix_float/src/ArduinoDefs.h: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | // 5 | // 6 | // Arduino(ish) defines to get the Phoenix software to run on RPI 7 | // 8 | // This library is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU Lesser General Public 10 | // License as published by the Free Software Foundation; either 11 | // version 2.1 of the License, or (at your option) any later version. 12 | 13 | // This library is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | // Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public 19 | // License along with this library; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | // 22 | //============================================================================= 23 | #ifndef _ARDUINO_DEFS_ 24 | #define _ARDUINO_DEFS_ 25 | #include 26 | #define PROGMEM 27 | #define pgm_read_byte(x) (*((char *)x)) 28 | // #define pgm_read_word(x) (*((short *)(x & 0xfffffffe))) 29 | #define pgm_read_word(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 30 | #define pgm_read_byte_near(x) (*((char *)x)) 31 | #define pgm_read_byte_far(x) (*((char *)x)) 32 | // #define pgm_read_word_near(x) (*((short *)(x & 0xfffffffe)) 33 | // #define pgm_read_word_far(x) (*((short *)(x & 0xfffffffe))) 34 | #define pgm_read_word_near(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 35 | #define pgm_read_word_far(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))) 36 | #define PSTR(x) x 37 | #define F(x) x 38 | #define PGM_P const char * 39 | 40 | // Define some data types? 41 | #define byte unsigned char 42 | //#define uint8_t unsigned char 43 | //#define uint16_t unsigned short 44 | //#define uint32_t unsigned long 45 | #define word unsigned short 46 | #define boolean bool 47 | 48 | #define delay(x) usleep((x)*1000) 49 | #define delayMicroseconds(us) usleep((us)) 50 | extern unsigned long millis(void); 51 | extern unsigned long micros(void); 52 | extern long min(long a, long b); 53 | extern long max(long a, long b); 54 | extern long map(long x, long in_min, long in_max, long out_min, long out_max); 55 | #endif 56 | -------------------------------------------------------------------------------- /Phoenix_float/src/Phoenix.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KurtE/Raspberry_Pi/515f138ecb2ca2c0e96b7343ccf14b87653faaad/Phoenix_float/src/Phoenix.h -------------------------------------------------------------------------------- /Rover/Rover_Config.h: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------- 2 | // Kurts Rover configuration file. 3 | // This configuration file is used to hide a bunch of the messy stuff where 4 | // we have a few different configurations defined and several tables depend 5 | // on which ones we have defined. This is especially true about what Servos 6 | // are defined, which we can use PWM type signals to control the motors or we 7 | // can use serial packet mode. Likewise we can define to have Pan and Tilt servos 8 | // or not... 9 | //-------------------------------------------------------------------------- 10 | 11 | // Define which way we will control motors, only uncomment one of these. 12 | #define PACKET_MODE 13 | 14 | 15 | // Packet Serial Mode 16 | #define PACKETS_ADDRESS 128 // Address of the device 17 | 18 | #ifdef PROC_BBB 19 | #define BBB_SERVO_SUPPORT 20 | #endif 21 | 22 | #define OPT_PCMSOUND 23 | 24 | #define DEADBAND 4 // How much dead band on stick values 25 | 26 | 27 | #define OUR_SERVOS_MIN 563 28 | #define OUR_SERVOS_MAX 2437 29 | 30 | 31 | #define VOLTAGE_MIN1 100 // 10 volts is the min that we will allow... 32 | 33 | 34 | #define PAN_MIN 750 // Min Pan 35 | #define PAN_MAX 2250 // Max Pan 36 | #define TILT_MIN 750 // Max tilt value 37 | #define TILT_MAX 2250 // Min ... 38 | #define ROTATE_MIN 750 39 | #define ROTATE_MAX 2250 40 | 41 | #ifdef BBB_SERVO_SUPPORT 42 | #define NUM_PAN_TILT_SERVOS 3 43 | #define MNUMSERVOS (NUM_PAN_TILT_SERVOS) 44 | enum {PANS_I=0, TILTS_I}; 45 | static char *g_apszServos[] = {"Pan", "Tilt", "Rotate"}; 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /Rover/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = rover 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | Rover.cpp 7 | 8 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 9 | 10 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 11 | 12 | #~~~~~~~~~~~~~~~~~~~~ Define Processor ~~~~~~~~~~~~~~~~~~~~ 13 | ifeq ($(OSTYPE),linux-gnueabi) 14 | PROC_DEFINE = -DPROC_BBB 15 | else 16 | PROC_DEFINE = -DPROC_RPI 17 | endif 18 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 19 | INCLUDE_DIRS = -I. -I../library 20 | 21 | 22 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 23 | ifeq ($(OSTYPE),linux-gnueabi) 24 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 25 | else 26 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 27 | endif 28 | 29 | 30 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 31 | COMPILE_OPTS = -pedantic -g -O2 -fno-rtti -Wno-write-strings 32 | 33 | 34 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 35 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lasound -lrt 36 | 37 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 38 | ifeq ($(OSTYPE),linux-gnueabi) 39 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 40 | else 41 | TCHAIN_PREFIX=arm-linux-gnueabihf- 42 | endif 43 | #TCHAIN_PREFIX=x86_64-linux-gnu- 44 | 45 | CXX = $(TCHAIN_PREFIX)g++ 46 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) $(PROC_DEFINE) 47 | 48 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 49 | 50 | all: LIBRARY begin gccversion build end 51 | 52 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 53 | LIBRARY: 54 | cd ../library; $(MAKE) 55 | 56 | 57 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 58 | 59 | 60 | build: $(MAIN_OUT) 61 | 62 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a 63 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 64 | 65 | MSG_BEGIN = -------- begin -------- 66 | MSG_END = -------- end -------- 67 | 68 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 69 | begin: 70 | @echo 71 | @echo $(MSG_BEGIN) 72 | 73 | end: 74 | @echo $(MSG_END) 75 | @echo 76 | 77 | gccversion: 78 | @$(CC) --version 79 | 80 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 81 | clean: begin clean_list end 82 | 83 | clean_list: 84 | -rm $(MAIN_OBJS) 85 | -rm $(MAIN_OUT) 86 | -rm $(MAIN_DEPS) 87 | -cd ../library ; make clean 88 | 89 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 90 | backup: clean 91 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 92 | 93 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 94 | include $(subst .cpp,.d,$(SOURCES)) 95 | 96 | %.d: %.cpp 97 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 98 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 99 | rm -f $@.$$$$ 100 | -------------------------------------------------------------------------------- /TestJoystick/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = testJoystick 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | Joystick.cpp 7 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 8 | 9 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 10 | 11 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 12 | INCLUDE_DIRS = -I. 13 | 14 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 15 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf 16 | 17 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 18 | COMPILE_OPTS = -pedantic -g -O2 -fno-rtti 19 | #COMPILE_OPTS = -Wall -pedantic -g -O2 20 | 21 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 22 | LDFLAGS = $(LIBRARY_DIRS) -lpthread 23 | 24 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 25 | ifeq ($(OSTYPE),linux-gnueabi) 26 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 27 | else 28 | ifeq ($(OSTYPE),Edison) 29 | #Edison hard coded OSTYPE 30 | TCHAIN_PREFIX=i586-poky-linux- 31 | else 32 | TCHAIN_PREFIX=arm-linux-gnueabihf- 33 | endif 34 | endif 35 | #TCHAIN_PREFIX=x86_64-linux-gnu- 36 | 37 | CXX = $(TCHAIN_PREFIX)g++ 38 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 39 | 40 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 41 | all: begin gccversion build end 42 | 43 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 44 | build: $(MAIN_OUT) 45 | 46 | $(MAIN_OUT): $(MAIN_OBJS) 47 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 48 | 49 | MSG_BEGIN = -------- begin -------- 50 | MSG_END = -------- end -------- 51 | 52 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 53 | begin: 54 | @echo 55 | @echo $(MSG_BEGIN) 56 | 57 | end: 58 | @echo $(MSG_END) 59 | @echo 60 | 61 | gccversion: 62 | @$(CC) --version 63 | 64 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 65 | clean: begin clean_list end 66 | 67 | clean_list: 68 | -rm $(MAIN_OBJS) 69 | -rm $(MAIN_OUT) 70 | -rm $(MAIN_DEPS) 71 | 72 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 73 | backup: clean 74 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 75 | 76 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 77 | include $(subst .cpp,.d,$(SOURCES)) 78 | 79 | %.d: %.cpp 80 | $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ 81 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 82 | rm -f $@.$$$$ 83 | -------------------------------------------------------------------------------- /TestMraaPing/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = TestMraaPing 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | TestMraaPing.cpp 7 | 8 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 9 | 10 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 11 | 12 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 13 | INCLUDE_DIRS = -I. 14 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 15 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 16 | 17 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 18 | COMPILE_OPTS = -pedantic -g -O2 -fno-rtti 19 | 20 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 21 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lmraa 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 24 | ifeq ($(OSTYPE),linux-gnueabi) 25 | #BBBk 26 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 27 | else 28 | ifeq ($(OSTYPE),Edison) 29 | #Edison hard coded OSTYPE 30 | TCHAIN_PREFIX=i586-poky-linux- 31 | else 32 | #RPI 33 | TCHAIN_PREFIX=arm-linux-gnueabihf- 34 | endif 35 | endif 36 | TCHAIN_PREFIX= 37 | CXX = $(TCHAIN_PREFIX)g++ 38 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 39 | 40 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 41 | all: begin gccversion build end 42 | 43 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 44 | build: $(MAIN_OUT) 45 | 46 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a 47 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 48 | 49 | MSG_BEGIN = -------- begin -------- 50 | MSG_END = -------- end -------- 51 | 52 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 53 | begin: 54 | @echo 55 | @echo $(MSG_BEGIN) 56 | 57 | end: 58 | @echo $(MSG_END) 59 | @echo 60 | 61 | gccversion: 62 | @$(CC) --version 63 | 64 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 65 | clean: begin clean_list end 66 | 67 | clean_list: 68 | -rm $(MAIN_OBJS) 69 | -rm $(MAIN_OUT) 70 | -rm $(MAIN_DEPS) 71 | 72 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 73 | backup: clean 74 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 75 | 76 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 77 | include $(subst .cpp,.d,$(SOURCES)) 78 | 79 | %.d: %.cpp 80 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 81 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 82 | rm -f $@.$$$$ 83 | -------------------------------------------------------------------------------- /Visual Studio 2012/Wifi Commander/Wifi Commander.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2012 for Windows Desktop 4 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Wifi Commander", "Wifi Commander\Wifi Commander.vbproj", "{7E04C964-C010-4BC0-A54C-DC6FE7CCB26B}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {7E04C964-C010-4BC0-A54C-DC6FE7CCB26B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {7E04C964-C010-4BC0-A54C-DC6FE7CCB26B}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {7E04C964-C010-4BC0-A54C-DC6FE7CCB26B}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {7E04C964-C010-4BC0-A54C-DC6FE7CCB26B}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Visual Studio 2012/Wifi Commander/Wifi Commander/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 0, 0 15 | 16 | 17 | 0, 0 18 | 19 | 20 | 21 | 22 | 23 | 100 24 | 25 | 26 | 27 | 28 | 29 | 0 30 | 31 | 32 | 0 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Visual Studio 2012/Wifi Commander/Wifi Commander/My Project/Application.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.18034 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | 15 | Namespace My 16 | 17 | 'NOTE: This file is auto-generated; do not modify it directly. To make changes, 18 | ' or if you encounter build errors in this file, go to the Project Designer 19 | ' (go to Project Properties or double-click the My Project node in 20 | ' Solution Explorer), and make changes on the Application tab. 21 | ' 22 | Partial Friend Class MyApplication 23 | 24 | _ 25 | Public Sub New() 26 | MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) 27 | Me.IsSingleInstance = false 28 | Me.EnableVisualStyles = true 29 | Me.SaveMySettingsOnExit = true 30 | Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses 31 | End Sub 32 | 33 | _ 34 | Protected Overrides Sub OnCreateMainForm() 35 | Me.MainForm = Global.Wifi_Commander.Form1 36 | End Sub 37 | End Class 38 | End Namespace 39 | -------------------------------------------------------------------------------- /Visual Studio 2012/Wifi Commander/Wifi Commander/My Project/Application.myapp: -------------------------------------------------------------------------------- 1 |  2 | 3 | true 4 | Form1 5 | false 6 | 0 7 | true 8 | 0 9 | 0 10 | true 11 | 12 | -------------------------------------------------------------------------------- /Visual Studio 2012/Wifi Commander/Wifi Commander/My Project/AssemblyInfo.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Reflection 3 | Imports System.Runtime.InteropServices 4 | 5 | ' General Information about an assembly is controlled through the following 6 | ' set of attributes. Change these attribute values to modify the information 7 | ' associated with an assembly. 8 | 9 | ' Review the values of the assembly attributes 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 'The following GUID is for the ID of the typelib if this project is exposed to COM 21 | 22 | 23 | ' Version information for an assembly consists of the following four values: 24 | ' 25 | ' Major Version 26 | ' Minor Version 27 | ' Build Number 28 | ' Revision 29 | ' 30 | ' You can specify all the values or you can default the Build and Revision Numbers 31 | ' by using the '*' as shown below: 32 | ' 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Visual Studio 2012/Wifi Commander/Wifi Commander/My Project/Resources.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.18034 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | 15 | Namespace My.Resources 16 | 17 | 'This class was auto-generated by the StronglyTypedResourceBuilder 18 | 'class via a tool like ResGen or Visual Studio. 19 | 'To add or remove a member, edit your .ResX file then rerun ResGen 20 | 'with the /str option, or rebuild your VS project. 21 | ''' 22 | ''' A strongly-typed resource class, for looking up localized strings, etc. 23 | ''' 24 | _ 28 | Friend Module Resources 29 | 30 | Private resourceMan As Global.System.Resources.ResourceManager 31 | 32 | Private resourceCulture As Global.System.Globalization.CultureInfo 33 | 34 | ''' 35 | ''' Returns the cached ResourceManager instance used by this class. 36 | ''' 37 | _ 38 | Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager 39 | Get 40 | If Object.ReferenceEquals(resourceMan, Nothing) Then 41 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Wifi_Commander.Resources", GetType(Resources).Assembly) 42 | resourceMan = temp 43 | End If 44 | Return resourceMan 45 | End Get 46 | End Property 47 | 48 | ''' 49 | ''' Overrides the current thread's CurrentUICulture property for all 50 | ''' resource lookups using this strongly typed resource class. 51 | ''' 52 | _ 53 | Friend Property Culture() As Global.System.Globalization.CultureInfo 54 | Get 55 | Return resourceCulture 56 | End Get 57 | Set(ByVal value As Global.System.Globalization.CultureInfo) 58 | resourceCulture = value 59 | End Set 60 | End Property 61 | End Module 62 | End Namespace 63 | -------------------------------------------------------------------------------- /Visual Studio 2012/Wifi Commander/Wifi Commander/My Project/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 0, 0 7 | 8 | 9 | 0, 0 10 | 11 | 12 | 13 | 14 | 15 | 100 16 | 17 | 18 | 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /library/ArduinoDefs.h: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Project Lynxmotion Phoenix 3 | //Description: Phoenix software 4 | // 5 | // 6 | // Arduino(ish) defines to get the Phoenix software to run on RPI 7 | // 8 | // This library is free software; you can redistribute it and/or 9 | // modify it under the terms of the GNU Lesser General Public 10 | // License as published by the Free Software Foundation; either 11 | // version 2.1 of the License, or (at your option) any later version. 12 | 13 | // This library is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | // Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public 19 | // License along with this library; if not, write to the Free Software 20 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | // 22 | //============================================================================= 23 | #ifndef _ARDUINO_DEFS_ 24 | #define _ARDUINO_DEFS_ 25 | #include 26 | #define PROGMEM 27 | #define pgm_read_byte(x) (*((char *)x)) 28 | // #define pgm_read_word(x) (*((short *)(x & 0xfffffffe))) 29 | #define pgm_read_word(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 30 | #define pgm_read_byte_near(x) (*((char *)x)) 31 | #define pgm_read_byte_far(x) (*((char *)x)) 32 | // #define pgm_read_word_near(x) (*((short *)(x & 0xfffffffe)) 33 | // #define pgm_read_word_far(x) (*((short *)(x & 0xfffffffe))) 34 | #define pgm_read_word_near(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) 35 | #define pgm_read_word_far(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))) 36 | #define PSTR(x) x 37 | #define F(x) x 38 | #define PGM_P const char * 39 | 40 | // Define some data types? 41 | //#define byte unsigned char 42 | typedef unsigned char byte; 43 | //#define uint8_t unsigned char 44 | //#define uint16_t unsigned short 45 | //#define uint32_t unsigned long 46 | #define word unsigned short 47 | #define boolean bool 48 | 49 | #define delay(x) usleep((x)*1000) 50 | #define delayMicroseconds(us) usleep((us)) 51 | extern unsigned long millis(void); 52 | extern unsigned long micros(void); 53 | extern long min(long a, long b); 54 | extern long max(long a, long b); 55 | extern long map(long x, long in_min, long in_max, long out_min, long out_max); 56 | #endif 57 | -------------------------------------------------------------------------------- /library/PWM.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * PWM.cpp 3 | * 4 | * Created on: May 30, 2013 5 | * Author: Saad Ahmad ( http://www.saadahmad.ca ) 6 | */ 7 | #include "PWM.h" 8 | #include 9 | //#define DEBUG_VERBOSE_OUTPUT 1 10 | 11 | namespace PWM 12 | { 13 | // A bunch of helper functions to get us locations in the file system. 14 | // They are used so that we can manipulate the pwm driver through the /sys interface 15 | std::string GetFullNameOfFileInDirectory(const std::string & dirName, const std::string & fileNameToFind) 16 | { 17 | DIR *pDir; 18 | 19 | dirent *pFile; 20 | if ((pDir = opendir(dirName.c_str())) == NULL) 21 | { 22 | std::cout << "Directory name: " << dirName << " doesnt exist!" << std::endl; 23 | throw std::bad_exception(); 24 | } 25 | while ((pFile = readdir(pDir)) != NULL) 26 | { 27 | std::string currentFileName = (pFile->d_name); 28 | if (currentFileName.find(fileNameToFind) != std::string::npos) 29 | { 30 | return currentFileName; 31 | } 32 | } 33 | return std::string(""); 34 | } 35 | 36 | std::string GetCapeManagerSlotsPath() 37 | { 38 | static std::string g_capeManagerSlotsPath; 39 | if (g_capeManagerSlotsPath.length() <= 0) 40 | { 41 | #if DEBUG_VERBOSE_OUTPUT 42 | std::cout << "Setting up cape manager path" << std::endl; 43 | #endif 44 | std::string capeBasePath("/sys/devices/"); 45 | std::string fileName = GetFullNameOfFileInDirectory(capeBasePath, std::string("bone_capemgr.")); 46 | g_capeManagerSlotsPath = capeBasePath + fileName + "/slots"; 47 | } 48 | return g_capeManagerSlotsPath; 49 | } 50 | 51 | std::string GetOCPPath() 52 | { 53 | static std::string g_ocpPath; 54 | if (g_ocpPath.length() == 0) 55 | { 56 | std::string ocpBasePath("/sys/devices/"); 57 | std::string ocpName = GetFullNameOfFileInDirectory(ocpBasePath, std::string("ocp.")); 58 | g_ocpPath = ocpBasePath + ocpName + '/'; 59 | } 60 | return g_ocpPath; 61 | } 62 | 63 | int GetCapeManagerSlot(const std::string & moduleName) 64 | { 65 | #if DEBUG_VERBOSE_OUTPUT 66 | std::cout << "Trying to find slot for module: " << moduleName << std::endl; 67 | #endif 68 | std::ifstream in(GetCapeManagerSlotsPath().c_str()); 69 | in.exceptions(std::ios::badbit); 70 | int slot = -1; 71 | while (in >> slot) 72 | { 73 | std::string restOfLine; 74 | std::getline(in, restOfLine); 75 | if (restOfLine.find(moduleName) != std::string::npos) 76 | { 77 | #if DEBUG_VERBOSE_OUTPUT 78 | std::cout << "Found Module: " << moduleName << " at slot: " << slot << std::endl; 79 | #endif 80 | return slot; 81 | } 82 | } 83 | #if DEBUG_VERBOSE_OUTPUT 84 | std::cout << "Module: " << moduleName << " not found in cape manager!" << std::endl; 85 | #endif 86 | return -1; 87 | } 88 | void LoadDeviceTreeModule(const std::string & name) 89 | { 90 | int slot = GetCapeManagerSlot(name); 91 | if (slot == -1) 92 | { 93 | #if DEBUG_VERBOSE_OUTPUT 94 | std::cout << "Adding Module: " << name << std::endl; 95 | std::cout << "Its going in: " << GetCapeManagerSlotsPath() << std::endl; 96 | #endif 97 | WriteToFile(GetCapeManagerSlotsPath(), name); 98 | 99 | usleep(MODULE_DELAY_TIME_US); 100 | } 101 | else 102 | { 103 | #if DEBUG_VERBOSE_OUTPUT 104 | std::cout << "Module " << name << " is already in here!" << std::endl; 105 | #endif 106 | } 107 | } 108 | void UnloadDeviceTreeModule(const std::string name) 109 | { 110 | int currentSlot = GetCapeManagerSlot(name); 111 | if (currentSlot == -1) 112 | { 113 | std::cout << "Why is the module " << name << " being unloaded when its not in use?" << std::endl; 114 | throw std::bad_exception(); 115 | } 116 | #if DEBUG_VERBOSE_OUTPUT 117 | std::cout << "Unloading module: " << name << std::endl; 118 | #endif 119 | WriteToFile(GetCapeManagerSlotsPath(), std::string("-") + ToString(currentSlot)); 120 | 121 | usleep(MODULE_DELAY_TIME_US); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /library/Print.h: -------------------------------------------------------------------------------- 1 | /* 2 | Print.h - Base class that provides print() and println() 3 | Copyright (c) 2008 David A. Mellis. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Print_h 21 | #define Print_h 22 | 23 | #include 24 | #include // for size_t 25 | 26 | //#include "WString.h" 27 | #include "Printable.h" 28 | #include 29 | 30 | #define DEC 10 31 | #define HEX 16 32 | #define OCT 8 33 | #define BIN 2 34 | 35 | class Print 36 | { 37 | private: 38 | int write_error; 39 | size_t printNumber(unsigned long, uint8_t); 40 | size_t printFloat(double, uint8_t); 41 | protected: 42 | void setWriteError(int err = 1) { write_error = err; } 43 | public: 44 | Print() : write_error(0) {} 45 | 46 | int getWriteError() { return write_error; } 47 | void clearWriteError() { setWriteError(0); } 48 | 49 | virtual size_t write(uint8_t) = 0; 50 | size_t write(const char *str) 51 | { 52 | if (str == NULL) return 0; 53 | return write((const uint8_t *)str, strlen(str)); 54 | } 55 | virtual size_t write(const uint8_t *buffer, size_t size); 56 | 57 | // size_t print(const String &); 58 | size_t print(const char[]); 59 | size_t print(char); 60 | size_t print(unsigned char, int = DEC); 61 | size_t print(int, int = DEC); 62 | size_t print(unsigned int, int = DEC); 63 | size_t print(long, int = DEC); 64 | size_t print(unsigned long, int = DEC); 65 | size_t print(double, int = 2); 66 | size_t print(const Printable&); 67 | 68 | // size_t println(const String &s); 69 | size_t println(const char[]); 70 | size_t println(char); 71 | size_t println(unsigned char, int = DEC); 72 | size_t println(int, int = DEC); 73 | size_t println(unsigned int, int = DEC); 74 | size_t println(long, int = DEC); 75 | size_t println(unsigned long, int = DEC); 76 | size_t println(double, int = 2); 77 | size_t println(const Printable&); 78 | size_t println(void); 79 | }; 80 | #endif 81 | -------------------------------------------------------------------------------- /library/Printable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Printable.h - Interface class that allows printing of complex types 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Printable_h 21 | #define Printable_h 22 | 23 | //#include 24 | 25 | class Print; 26 | 27 | /** The Printable class provides a way for new classes to allow themselves to be printed. 28 | By deriving from Printable and implementing the printTo method, it will then be possible 29 | for users to print out instances of this class by passing them into the usual 30 | Print::print and Print::println methods. 31 | */ 32 | 33 | class Printable 34 | { 35 | public: 36 | virtual size_t printTo(Print& p) const = 0; 37 | }; 38 | #endif 39 | -------------------------------------------------------------------------------- /library/Wiring.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | //Kurts Port support library for Raspberry Pi and BeagleBone Black 3 | //============================================================================= 4 | #include "ArduinoDefs.h" 5 | #include 6 | #include 7 | 8 | 9 | long min(long a, long b) 10 | { 11 | if (a <= b) 12 | return a; 13 | return b; 14 | } 15 | 16 | 17 | long max(long a, long b) 18 | { 19 | if (a >= b) 20 | return a; 21 | return b; 22 | } 23 | 24 | 25 | unsigned long millis(void) 26 | { 27 | struct timespec ts; 28 | clock_gettime(CLOCK_MONOTONIC, &ts ); 29 | return ( ts.tv_sec * 1000 + ts.tv_nsec / 1000000L ); 30 | } 31 | 32 | 33 | unsigned long micros(void) 34 | { 35 | struct timespec ts; 36 | clock_gettime(CLOCK_MONOTONIC, &ts ); 37 | return ( ts.tv_sec * 1000000L + ts.tv_nsec / 1000L ); 38 | } 39 | 40 | 41 | extern "C" void __cxa_pure_virtual() 42 | { 43 | while (1); 44 | } 45 | 46 | 47 | long map(long x, long in_min, long in_max, long out_min, long out_max) 48 | { 49 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /library/WrapperSerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | WrapperSerial.h - Hardware serial library for Wiring 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Modified 28 September 2010 by Mark Sproul 20 | Modified 14 August 2012 by Alarus 21 | */ 22 | 23 | #ifndef WrapperSerial_h 24 | #define WrapperSerial_h 25 | 26 | #include 27 | 28 | #include "Stream.h" 29 | #include 30 | #include 31 | 32 | struct ring_buffer; 33 | 34 | class WrapperSerial : public Stream 35 | { 36 | private: 37 | int _fdOut; // file descriptor 38 | int _fdIn; // file descript for input 39 | FILE *_pfileOut; // Pointer to file 40 | FILE *_pfileIn; // Make a seperate File pointer to handle stdin... 41 | int _peek; // last value we received from read/peek 42 | 43 | public: 44 | WrapperSerial(); 45 | bool begin(char *pszDevice, speed_t baud, bool fRtsCts = false); 46 | bool begin(); // special version for stdin, stdout 47 | void end(); 48 | virtual int available(void); 49 | virtual int peek(void); 50 | virtual int read(void); 51 | virtual void flush(void); 52 | virtual size_t write(uint8_t); 53 | inline size_t write(unsigned long n) { return write((uint8_t)n); } 54 | inline size_t write(long n) { return write((uint8_t)n); } 55 | inline size_t write(unsigned int n) { return write((uint8_t)n); } 56 | inline size_t write(int n) { return write((uint8_t)n); } 57 | using Print::write; // pull in write(str) and write(buf, size) from Print 58 | }; 59 | #endif 60 | -------------------------------------------------------------------------------- /library/makefile: -------------------------------------------------------------------------------- 1 | #try to create a static library of code for me to use for different programs 2 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 3 | MAIN_OUT = libArduinoPort.a 4 | 5 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 6 | COMMON_SOURCES = \ 7 | Wiring.cpp \ 8 | Print.cpp \ 9 | Stream.cpp \ 10 | WrapperSerial.cpp \ 11 | CommanderEx.cpp \ 12 | diyxbee.cpp \ 13 | PWM.cpp \ 14 | JoystickController.cpp \ 15 | RoboClaw.cpp 16 | 17 | SOURCES = $(COMMON_SOURCES) 18 | 19 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 20 | 21 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 24 | INCLUDE_DIRS = -I. 25 | 26 | 27 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 28 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 29 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 30 | 31 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 32 | 33 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 34 | ifeq ($(OSTYPE),linux-gnueabi) 35 | #BBBk 36 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 37 | 38 | else 39 | ifeq ($(OSTYPE),Edison) 40 | #Edison hard coded OSTYPE 41 | TCHAIN_PREFIX=i586-poky-linux- 42 | else 43 | TCHAIN_PREFIX= 44 | endif 45 | endif 46 | #TCHAIN_PREFIX=x86_64-linux-gnu- 47 | 48 | CXX = $(TCHAIN_PREFIX)g++ 49 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 50 | AR = ar 51 | ARFLAGS = rcs 52 | 53 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 54 | all: begin gccversion build end 55 | 56 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 57 | build: $(MAIN_OUT) 58 | 59 | $(MAIN_OUT): $(MAIN_OBJS) 60 | $(AR) $(ARFLAGS) $(MAIN_OUT) $(MAIN_OBJS) 61 | 62 | MSG_BEGIN = -------- begin -------- 63 | MSG_END = -------- end -------- 64 | 65 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 66 | begin: 67 | @echo 68 | @echo $(MSG_BEGIN) 69 | @echo ${OSTYPE} 70 | 71 | end: 72 | @echo $(MSG_END) 73 | @echo 74 | 75 | gccversion: 76 | @$(CC) --version 77 | 78 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 79 | clean: begin clean_list end 80 | 81 | clean_list: 82 | -rm -f $(MAIN_OBJS) 83 | -rm -f $(MAIN_OUT) 84 | -rm -f $(MAIN_DEPS) 85 | 86 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 87 | backup: clean 88 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 89 | 90 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 91 | include $(subst .cpp,.d,$(SOURCES)) 92 | 93 | %.d: %.cpp 94 | $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ 95 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 96 | rm -f $@.$$$$ 97 | -------------------------------------------------------------------------------- /library_extras/SDRFunctions.cpp: -------------------------------------------------------------------------------- 1 | //====================================================================================== 2 | // SDRFunctions.cpp - A way to allow multiple things register to use the sound system. 3 | // will relese the others if necessary. 4 | //====================================================================================== 5 | #include "SDRFunctions.h" 6 | 7 | static SDRFunc g_aSDRFuncs[MAX_SDRFUNCS]; 8 | unsigned char g_cSDRFuncs = 0; 9 | unsigned char g_iSCRFuncsCur = 0xff; 10 | 11 | unsigned char SDRRegisterReleaseFunction(SDRFunc func) 12 | { 13 | if (g_cSDRFuncs < MAX_SDRFUNCS) 14 | { 15 | g_aSDRFuncs[g_cSDRFuncs] = func; 16 | return (g_cSDRFuncs++); 17 | } 18 | return 0xff; 19 | } 20 | 21 | void SDRSetCurrent(unsigned char uID) 22 | { 23 | if (uID != g_iSCRFuncsCur) 24 | { 25 | for (unsigned char i = 0; i < g_cSDRFuncs; i++) 26 | { 27 | if (i != uID) 28 | g_aSDRFuncs[i](); 29 | } 30 | 31 | g_iSCRFuncsCur = uID; 32 | } 33 | } -------------------------------------------------------------------------------- /library_extras/SDRFunctions.h: -------------------------------------------------------------------------------- 1 | //====================================================================================== 2 | // SDRFunctions.h - A way to allow multiple things register to use the sound system. 3 | // will relese the others if necessary. 4 | //====================================================================================== 5 | #ifndef _SDRFUNCTIONS_H_ 6 | #define _SDRFUNCTIONS_H_ 7 | 8 | #define MAX_SDRFUNCS 3 // define how big our array should be 2 is all I know of... 9 | 10 | typedef void (*SDRFunc)(void); 11 | extern unsigned char SDRRegisterReleaseFunction(SDRFunc func); 12 | extern void SDRSetCurrent(unsigned char uID); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /library_extras/libPortExtras.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KurtE/Raspberry_Pi/515f138ecb2ca2c0e96b7343ccf14b87653faaad/library_extras/libPortExtras.a -------------------------------------------------------------------------------- /library_extras/makefile: -------------------------------------------------------------------------------- 1 | #try to create a static library of code for me to use for different programs 2 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 3 | MAIN_OUT = libPortExtras.a 4 | 5 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 6 | COMMON_SOURCES = \ 7 | msound.cpp \ 8 | speak.cpp \ 9 | SDRFunctions.cpp 10 | 11 | SOURCES = $(COMMON_SOURCES) 12 | 13 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 14 | 15 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 16 | 17 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 18 | INCLUDE_DIRS = -I. -I../library -I/usr/include/espeak -I/user/include/alsa 19 | 20 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 21 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 22 | COMPILE_OPTS = -Wall -pedantic -g -O2 -fno-rtti -Wno-write-strings 23 | 24 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 25 | 26 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 27 | TCHAIN_PREFIX= 28 | 29 | CXX = $(TCHAIN_PREFIX)g++ 30 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 31 | AR = ar 32 | ARFLAGS = rcs 33 | 34 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 35 | all: begin gccversion build end 36 | 37 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 38 | build: $(MAIN_OUT) 39 | 40 | $(MAIN_OUT): $(MAIN_OBJS) 41 | $(AR) $(ARFLAGS) $(MAIN_OUT) $(MAIN_OBJS) 42 | 43 | MSG_BEGIN = -------- begin -------- 44 | MSG_END = -------- end -------- 45 | 46 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 47 | begin: 48 | @echo 49 | @echo $(MSG_BEGIN) 50 | @echo ${OSTYPE} 51 | 52 | end: 53 | @echo $(MSG_END) 54 | @echo 55 | 56 | gccversion: 57 | @$(CC) --version 58 | 59 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 60 | clean: begin clean_list end 61 | 62 | clean_list: 63 | -rm -f $(MAIN_OBJS) 64 | -rm -f $(MAIN_OUT) 65 | -rm -f $(MAIN_DEPS) 66 | 67 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 68 | backup: clean 69 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 70 | 71 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 72 | include $(subst .cpp,.d,$(SOURCES)) 73 | 74 | %.d: %.cpp 75 | $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ 76 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 77 | rm -f $@.$$$$ 78 | -------------------------------------------------------------------------------- /library_extras/msound.h: -------------------------------------------------------------------------------- 1 | //====================================================================================== 2 | // msound.h - Some quick and dirty speach functions for my phoenix code 3 | //====================================================================================== 4 | #ifndef _MSOUND_H_ 5 | #define _MSOUND_H_ 6 | #include "ArduinoDefs.h" 7 | 8 | extern void MSound(byte cNotes, ...); 9 | #endif 10 | -------------------------------------------------------------------------------- /library_extras/speak.h: -------------------------------------------------------------------------------- 1 | /* 2 | speak.h - Speech header file for support for Kurt's robots 3 | By Kurt Eckhardt 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | //====================================================================================== 21 | // speak.h - Some quick and dirty speach functions for my phoenix code 22 | //====================================================================================== 23 | #ifndef _SPEAK_H_ 24 | #define _SPEAK_H_ 25 | 26 | class RobotSpeak 27 | { 28 | public: 29 | RobotSpeak(void); // Constructor 30 | void Speak(const char *psz, bool fWait); // A string to output to the speaker 31 | void EndSpeak(void); // End voice output 32 | 33 | void SetVoiceByName(const char *pszVoiceName); // specific voice file name 34 | 35 | // pszLanguage is something like "en" or "en-us" 36 | // gender: 0-none, 1-mail, 2-female 37 | void SetVoiceByProperties(const char *pszLanguage, unsigned char gender); 38 | 39 | private: 40 | bool _fSpeakInit; 41 | unsigned int _uSpeakIdentifier; // Unique identifier 42 | unsigned char _bIDSDRSpeak; 43 | 44 | const char *_pszVoiceFileName; // Do we have a voice file name? 45 | const char *_pszVoiceLanguage; // Default to not specified. 46 | unsigned char _bVoiceGender; // What gender voice should w 47 | // private members 48 | void InitSpeak(void); 49 | 50 | 51 | }; 52 | 53 | extern RobotSpeak Speak; 54 | #endif 55 | -------------------------------------------------------------------------------- /testAdafruit_ILI9341B/cls.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Quick and dirty program to clear the screen of the LCD... 3 | // 4 | 5 | #include "Adafruit_ILI9341B.h" 6 | #include "Adafruit_GFX.h" 7 | #include 8 | #include "WrapperSerial.h" 9 | 10 | 11 | //#include 12 | //#include 13 | //#include 14 | //#include 15 | //#include 16 | //#include 17 | //#include 18 | //#include 19 | //#include 20 | //#include 21 | //#include 22 | //#include 23 | //#include 24 | //#include 25 | //#include 26 | 27 | // For the Adafruit shield, these are the default. 28 | #define TFT_DC 29 29 | #define TFT_CS 22//-1 30 | #define TFT_RST 31 31 | Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); 32 | 33 | 34 | //-------------------------------------------------------------------------- 35 | // SignalHandler - Try to free up things like servos if we abort. 36 | //-------------------------------------------------------------------------- 37 | void SignalHandler(int sig){ 38 | printf("Caught signal %d\n", sig); 39 | 40 | tft.end(); // try to cleanup. 41 | 42 | exit(1); 43 | 44 | } 45 | 46 | extern void setup(void); 47 | extern void loop(void); 48 | 49 | int main() 50 | { 51 | // Install signal handler to allow us to do some cleanup... 52 | struct sigaction sigIntHandler; 53 | 54 | sigIntHandler.sa_handler = SignalHandler; 55 | sigemptyset(&sigIntHandler.sa_mask); 56 | sigIntHandler.sa_flags = 0; 57 | 58 | sigaction(SIGINT, &sigIntHandler, NULL); 59 | 60 | printf("ILI9341 Clear screen Test!\n"); 61 | 62 | tft.begin(0); 63 | tft.fillScreen(ILI9341_BLACK); 64 | printf("Done\n"); 65 | tft.fillRect(100, 100, 100, 100, ILI9341_RED); 66 | tft.update(); 67 | 68 | tft.end(); 69 | 70 | delay(5000); 71 | } 72 | 73 | -------------------------------------------------------------------------------- /testAdafruit_ILI9341C/cls.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Quick and dirty program to clear the screen of the LCD... 3 | // 4 | 5 | #include "Adafruit_ILI9341.h" 6 | #include "Adafruit_GFX.h" 7 | #include 8 | #include "WrapperSerial.h" 9 | 10 | 11 | //#include 12 | //#include 13 | //#include 14 | //#include 15 | //#include 16 | //#include 17 | //#include 18 | //#include 19 | //#include 20 | //#include 21 | //#include 22 | //#include 23 | //#include 24 | //#include 25 | //#include 26 | 27 | // For the Adafruit shield, these are the default. 28 | #define TFT_DC 29 29 | #define TFT_CS 22//-1 30 | #define TFT_RST 31 31 | Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); 32 | 33 | 34 | //-------------------------------------------------------------------------- 35 | // SignalHandler - Try to free up things like servos if we abort. 36 | //-------------------------------------------------------------------------- 37 | void SignalHandler(int sig){ 38 | printf("Caught signal %d\n", sig); 39 | 40 | tft.end(); // try to cleanup. 41 | 42 | exit(1); 43 | 44 | } 45 | 46 | extern void setup(void); 47 | extern void loop(void); 48 | 49 | int main() 50 | { 51 | // Install signal handler to allow us to do some cleanup... 52 | struct sigaction sigIntHandler; 53 | 54 | sigIntHandler.sa_handler = SignalHandler; 55 | sigemptyset(&sigIntHandler.sa_mask); 56 | sigIntHandler.sa_flags = 0; 57 | 58 | sigaction(SIGINT, &sigIntHandler, NULL); 59 | 60 | printf("ILI9341 Clear screen Test!\n"); 61 | 62 | tft.begin(0); 63 | tft.fillScreen(ILI9341_BLACK); 64 | printf("Done\n"); 65 | tft.fillRect(100, 100, 100, 100, ILI9341_RED); 66 | 67 | 68 | tft.end(); 69 | 70 | delay(5000); 71 | } 72 | 73 | -------------------------------------------------------------------------------- /testCMPS03/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = testCMPS03 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | testCMPS03.cpp 7 | 8 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 9 | 10 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 11 | 12 | 13 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 14 | INCLUDE_DIRS = -I. 15 | 16 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 17 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf 18 | 19 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 20 | COMPILE_OPTS = -pedantic -g -O2 -fno-rtti 21 | 22 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 23 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lmraa 24 | 25 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 26 | ifeq ($(OSTYPE),linux-gnueabi) 27 | #BBBk 28 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 29 | else 30 | ifeq ($(OSTYPE),Edison) 31 | #Edison hard coded OSTYPE 32 | TCHAIN_PREFIX=i586-poky-linux- 33 | else 34 | #RPI 35 | TCHAIN_PREFIX=arm-linux-gnueabihf- 36 | endif 37 | endif 38 | 39 | CXX = $(TCHAIN_PREFIX)g++ 40 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 41 | 42 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 43 | all: begin gccversion build end 44 | 45 | 46 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 47 | build: $(MAIN_OUT) 48 | 49 | $(MAIN_OUT): $(MAIN_OBJS) 50 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 51 | 52 | 53 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 54 | MSG_BEGIN = -------- begin -------- 55 | MSG_END = -------- end -------- 56 | begin: 57 | @echo 58 | @echo $(MSG_BEGIN) 59 | 60 | end: 61 | @echo $(MSG_END) 62 | @echo 63 | 64 | gccversion: 65 | @$(CC) --version 66 | 67 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 68 | clean: begin clean_list end 69 | 70 | clean_list: 71 | -rm $(MAIN_OBJS) 72 | -rm $(MAIN_OUT) 73 | -rm $(MAIN_DEPS) 74 | 75 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 76 | backup: clean 77 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 78 | 79 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 80 | include $(subst .cpp,.d,$(SOURCES)) 81 | 82 | %.d: %.cpp 83 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 84 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 85 | rm -f $@.$$$$ 86 | -------------------------------------------------------------------------------- /testCMPS03/testCMPS03.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Author: Brendan Le Foll 3 | * Copyright (c) 2014 Intel Corporation. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining 6 | * a copy of this software and associated documentation files (the 7 | * "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, 9 | * distribute, sublicense, and/or sell copies of the Software, and to 10 | * permit persons to whom the Software is furnished to do so, subject to 11 | * the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #include "mraa.h" 26 | #include "math.h" 27 | #include 28 | #define ADDRESS 0x60 //defines address of compass 29 | 30 | #define MAX_BUFFER_LENGTH 6 31 | 32 | int 33 | main(int argc, char **argv) 34 | { 35 | mraa_init(); 36 | uint16_t direction = 0; 37 | uint8_t rx_tx_buf[MAX_BUFFER_LENGTH]; 38 | 39 | mraa_i2c_context i2c; 40 | i2c = mraa_i2c_init(0); 41 | 42 | mraa_i2c_address(i2c, ADDRESS); 43 | uint8_t bVer = mraa_i2c_read_byte_data(i2c, 0); // read one byte 44 | printf("CMPS03 Version: %d\n\r", bVer); 45 | 46 | 47 | for(;;) { 48 | mraa_i2c_address(i2c, ADDRESS); 49 | mraa_i2c_write_byte(i2c, 2); // start read at byte 2 50 | 51 | mraa_i2c_address(i2c, ADDRESS); 52 | mraa_i2c_read(i2c, rx_tx_buf, 2); 53 | direction = (rx_tx_buf[0] << 8) + rx_tx_buf[1]; 54 | // direction = mraa_i2c_read_word_data(i2c, 2); 55 | printf("Heading : %d\n", direction) ; 56 | usleep(250000); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /testPCM/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = testPCM 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | testPCM.cpp 7 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 8 | 9 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 10 | 11 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 12 | INCLUDE_DIRS = -I. 13 | 14 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 15 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf 16 | 17 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 18 | COMPILE_OPTS = -pedantic -g -O2 -fno-rtti 19 | #COMPILE_OPTS = -Wall -pedantic -g -O2 20 | 21 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 22 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lasound 23 | 24 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 25 | ifeq ($(OSTYPE),linux-gnueabi) 26 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 27 | else 28 | TCHAIN_PREFIX=arm-linux-gnueabihf- 29 | endif 30 | #TCHAIN_PREFIX=x86_64-linux-gnu- 31 | 32 | CXX = $(TCHAIN_PREFIX)g++ 33 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 34 | 35 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 36 | all: begin gccversion build end 37 | 38 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 39 | build: $(MAIN_OUT) 40 | 41 | $(MAIN_OUT): $(MAIN_OBJS) 42 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 43 | 44 | MSG_BEGIN = -------- begin -------- 45 | MSG_END = -------- end -------- 46 | 47 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 48 | begin: 49 | @echo 50 | @echo $(MSG_BEGIN) 51 | 52 | end: 53 | @echo $(MSG_END) 54 | @echo 55 | 56 | gccversion: 57 | @$(CC) --version 58 | 59 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 60 | clean: begin clean_list end 61 | 62 | clean_list: 63 | -rm $(MAIN_OBJS) 64 | -rm $(MAIN_OUT) 65 | -rm $(MAIN_DEPS) 66 | 67 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 68 | backup: clean 69 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 70 | 71 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 72 | include $(subst .cpp,.d,$(SOURCES)) 73 | 74 | %.d: %.cpp 75 | $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ 76 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 77 | rm -f $@.$$$$ 78 | -------------------------------------------------------------------------------- /testPWM/BasicPWMExample.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BasicPWM.cpp 3 | * 4 | * Example of basic PWM usage and fading an LED. Also shows how periods should be changed 5 | * 6 | * Created on: May 29, 2013 7 | * Author: Saad Ahmad ( http://www.saadahmad.ca ) 8 | */ 9 | 10 | #include "PWM.h" 11 | #include 12 | #include 13 | #include 14 | int main() 15 | { 16 | const int delayMS = 50; 17 | const long periodNS = 20 * MILLISECONDS_TO_NANOSECONDS; 18 | 19 | PWM::Pin pinA("P8_13", periodNS); // Since both pins share the same channel, they're periods must be the same 20 | std::cout << "P8_13 created" << std::endl; 21 | 22 | PWM::Pin pinB("P8_19", periodNS); 23 | std::cout << "P8_19 created" << std::endl; 24 | 25 | int slot = PWM::GetCapeManagerSlot("P8_13"); 26 | std::stringstream ss; 27 | ss << slot; 28 | std::cout << "Found: " << ss.str() << std::endl; 29 | 30 | 31 | // Enable both only after we have set the periods properly. 32 | // Otherwise we will have conflicts since each pin will try to set its own period and conflict with the others 33 | std::cout << "Before PinA enable" << std::endl; 34 | pinA.Enable(); 35 | std::cout << "Before PinB enable" << std::endl; 36 | pinB.Enable(); 37 | std::cout << "Pins Setup and ready to go!" << std::endl; 38 | 39 | // I want to do a sweep of the two servos from 500us to 2500us 40 | for (int pw = 500; pw < 2500; pw+=100) 41 | { 42 | pinA.SetDutyUS(pw); 43 | pinB.SetDutyUS(3000-pw); // reverse this one. 44 | usleep(100 * 1000); // delay for a bit maybe 5 pulses per pw 45 | } 46 | // Tell both pins to stop. 47 | pinA.Disable(); 48 | pinB.Disable(); 49 | #if 0 50 | 51 | for (int i = 0; i < 100; i++) 52 | { 53 | std::clock_t startTime = std::clock(); 54 | while (((clock() - startTime) * 1000.0 / CLOCKS_PER_SEC) < delayMS) 55 | { 56 | pinA.SetDutyPercent(float(i) / 100); 57 | pinB.SetDutyPercent(1 - float(i) / 100); 58 | } 59 | 60 | } 61 | 62 | // Release the pins so they are disabled and so that we can also reset their periods 63 | // Note if you just call Disable() then you cant change the period as both channels will be treated as in use 64 | pinA.Release(); 65 | pinB.Release(); 66 | 67 | std::cout << "Setting new periods " << std::endl; 68 | 69 | pinA.SetPeriodNS(periodNS * 2); 70 | std::cout << "New period for Pin A set" << std::endl; 71 | 72 | pinB.SetPeriodNS(periodNS * 2); 73 | std::cout << "New period for Pin B set" << std::endl; 74 | 75 | // Once the periods have been set we can start again 76 | pinA.Enable(); 77 | std::cout << "Enabled pin A" << std::endl; 78 | 79 | pinB.Enable(); 80 | std::cout << "Enabled pin B" << std::endl; 81 | 82 | for (int i = 0; i < 100; i++) 83 | { 84 | std::clock_t startTime = std::clock(); 85 | while (((clock() - startTime) * 1000.0 / CLOCKS_PER_SEC) < delayMS) 86 | { 87 | pinA.SetDutyPercent(float(i) / 100); 88 | pinB.SetDutyPercent(1 - float(i) / 100); 89 | } 90 | } 91 | #endif 92 | 93 | std::cout << "Done everything. Quiting now!" << std::endl; 94 | } 95 | 96 | -------------------------------------------------------------------------------- /testPWM/MotorExample.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MotorExample.cpp 3 | * 4 | * Example of PWM used to control motors via an esc 5 | * 6 | * Created on: May 29, 2013 7 | * Author: Saad Ahmad ( http://www.saadahmad.ca ) 8 | */ 9 | 10 | #include 11 | #include "PWM.h" 12 | #include "Motor.h" 13 | #include 14 | #include 15 | 16 | const float MIN_SPEED = 0; 17 | const float MAX_SPEED = 100; 18 | const int MIN_MOTOR_PULSE_TIME = 1000; 19 | const int MAX_MOTOR_PULSE_TIME = 2000; 20 | const std::string PIN_MOTOR_YAW("P8_13"); 21 | const std::string PIN_MOTOR_RIGHT("P8_19"); 22 | const std::string PIN_MOTOR_LEFT("P9_14"); 23 | 24 | MotorControl motorControls[] = { MotorControl(PIN_MOTOR_LEFT, MIN_SPEED, MIN_SPEED, MAX_SPEED), MotorControl(PIN_MOTOR_RIGHT, MIN_SPEED, MIN_SPEED, MAX_SPEED), MotorControl(PIN_MOTOR_YAW, MIN_SPEED, MIN_SPEED, MAX_SPEED), }; 25 | 26 | 27 | #include 28 | 29 | // Stop all the motors when we interrupt the program so they don't keep going 30 | void sig_handler(int signum) 31 | { 32 | for (unsigned int iMotor = 0; iMotor < 3; iMotor++) 33 | { 34 | MotorControl & motor = motorControls[iMotor]; 35 | motor.SetOutputValue(0); 36 | motor.UpdatePWMSignal(); 37 | } 38 | 39 | exit(signum); 40 | } 41 | 42 | int main() 43 | { 44 | signal(SIGINT, sig_handler); 45 | signal(SIGSEGV, sig_handler); 46 | signal(SIGQUIT, sig_handler); 47 | signal(SIGHUP, sig_handler); 48 | signal(SIGABRT, sig_handler); 49 | 50 | for (int iMotor = 0; iMotor < 3; iMotor++) 51 | { 52 | motorControls[iMotor].Enable(); 53 | } 54 | 55 | while (true) 56 | { 57 | // Increase by 10% each time and view the output PPM signal 58 | for (int i = 0; i < 100; i += 10) 59 | { 60 | std::clock_t startTime = std::clock(); 61 | while ( ((clock() - startTime) * 1000.0 / CLOCKS_PER_SEC) < 500 ) 62 | { 63 | for (int iMotor = 0; iMotor < 3; iMotor++) 64 | { 65 | MotorControl & motor = motorControls[iMotor]; 66 | motor.SetOutputValue((i + iMotor * 20) % 100); // Offset the motors a bit 67 | motor.UpdatePWMSignal(); 68 | } 69 | } 70 | } 71 | } 72 | } 73 | 74 | -------------------------------------------------------------------------------- /testPWM/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = BasicPWMExample 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | BasicPWMExample.cpp 7 | 8 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 9 | 10 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 11 | 12 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 13 | INCLUDE_DIRS = -I. -I../library 14 | 15 | 16 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 17 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 18 | 19 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 20 | COMPILE_OPTS = -pedantic -g -O2 -fno-rtti 21 | 22 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 23 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lrt 24 | 25 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 26 | ifeq ($(OSTYPE),linux-gnueabi) 27 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 28 | else 29 | TCHAIN_PREFIX=arm-linux-gnueabihf- 30 | endif 31 | #TCHAIN_PREFIX=x86_64-linux-gnu- 32 | 33 | CXX = $(TCHAIN_PREFIX)g++ 34 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 35 | 36 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 37 | 38 | all: LIBRARY begin gccversion build end 39 | 40 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 41 | LIBRARY: 42 | cd ../library; $(MAKE) 43 | 44 | 45 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 46 | 47 | 48 | build: $(MAIN_OUT) 49 | 50 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a 51 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 52 | 53 | MSG_BEGIN = -------- begin -------- 54 | MSG_END = -------- end -------- 55 | 56 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 57 | begin: 58 | @echo 59 | @echo $(MSG_BEGIN) 60 | 61 | end: 62 | @echo $(MSG_END) 63 | @echo 64 | 65 | gccversion: 66 | @$(CC) --version 67 | 68 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 69 | clean: begin clean_list end 70 | 71 | clean_list: 72 | -rm $(MAIN_OBJS) 73 | -rm $(MAIN_OUT) 74 | -rm $(MAIN_DEPS) 75 | -cd ../library ; make clean 76 | 77 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 78 | backup: clean 79 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 80 | 81 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 82 | include $(subst .cpp,.d,$(SOURCES)) 83 | 84 | %.d: %.cpp 85 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 86 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 87 | rm -f $@.$$$$ 88 | -------------------------------------------------------------------------------- /testRoboClaw/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = testRClaw 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | testRClaw.cpp 7 | 8 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 9 | 10 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 11 | 12 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 13 | INCLUDE_DIRS = -I. -I../library 14 | 15 | 16 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 17 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 18 | 19 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 20 | COMPILE_OPTS = -pedantic -g -O2 -fno-rtti 21 | 22 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 23 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lArduinoPort -lrt 24 | 25 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 26 | ifeq ($(OSTYPE),linux-gnueabi) 27 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 28 | else 29 | TCHAIN_PREFIX=arm-linux-gnueabihf- 30 | endif 31 | #TCHAIN_PREFIX=x86_64-linux-gnu- 32 | 33 | CXX = $(TCHAIN_PREFIX)g++ 34 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 35 | 36 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 37 | 38 | all: LIBRARY begin gccversion build end 39 | 40 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 41 | LIBRARY: 42 | cd ../library; $(MAKE) 43 | 44 | 45 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 46 | 47 | 48 | build: $(MAIN_OUT) 49 | 50 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a 51 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 52 | 53 | MSG_BEGIN = -------- begin -------- 54 | MSG_END = -------- end -------- 55 | 56 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 57 | begin: 58 | @echo 59 | @echo $(MSG_BEGIN) 60 | 61 | end: 62 | @echo $(MSG_END) 63 | @echo 64 | 65 | gccversion: 66 | @$(CC) --version 67 | 68 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 69 | clean: begin clean_list end 70 | 71 | clean_list: 72 | -rm $(MAIN_OBJS) 73 | -rm $(MAIN_OUT) 74 | -rm $(MAIN_DEPS) 75 | -cd ../library ; make clean 76 | 77 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 78 | backup: clean 79 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 80 | 81 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 82 | include $(subst .cpp,.d,$(SOURCES)) 83 | 84 | %.d: %.cpp 85 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 86 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 87 | rm -f $@.$$$$ 88 | -------------------------------------------------------------------------------- /testRoboClaw/testRClaw.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Quick and dirty test of the SSC-32 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | #include "WrapperSerial.h" 23 | #include "RoboClaw.h" 24 | 25 | // definition of some helper functions 26 | typedef unsigned char byte; 27 | 28 | 29 | char szRCDevice[] ="/dev/ttyRCLAW"; 30 | 31 | RoboClaw RClaw; 32 | 33 | #define delay(x) usleep((x)*1000) 34 | #define address 0x80 35 | char szBuff[128]; 36 | 37 | int main(int argc, char *argv[]) 38 | { 39 | char abT[40]; // give a nice large buffer. 40 | byte cbRead; 41 | 42 | printf("Start\n"); 43 | if (argc > 1) 44 | { 45 | for (int i=1; i < argc; i++) 46 | { 47 | printf("%d - %s\n", i, argv[i]); 48 | } 49 | } 50 | bool f = RClaw.begin(argc > 1? argv[1] : szRCDevice, B38400); 51 | if (!f) { 52 | printf("RClaw begin failed!\n"); 53 | return (-1); 54 | } 55 | printf("Test Version command\n"); 56 | f = RClaw.ReadVersion(address, szBuff); 57 | printf("Ver %i : %s\n", f? 1 : 0, szBuff); 58 | 59 | printf("Exit\n"); 60 | 61 | 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /testSSC32/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = testSSC32 3 | 4 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 5 | SOURCES = \ 6 | testSSC32.cpp 7 | 8 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 9 | 10 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 11 | 12 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 13 | INCLUDE_DIRS = -I. -I../library -I/usr/include/espeak 14 | 15 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 16 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 17 | 18 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 19 | COMPILE_OPTS = -pedantic -g -O2 -fno-rtti 20 | 21 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 22 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lespeak -lArduinoPort 23 | 24 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 25 | TCHAIN_PREFIX=arm-linux-gnueabihf- 26 | #TCHAIN_PREFIX=x86_64-linux-gnu- 27 | 28 | CXX = $(TCHAIN_PREFIX)g++ 29 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 30 | 31 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 32 | all: LIBRARY begin gccversion build end 33 | 34 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 35 | LIBRARY: 36 | cd ../library; $(MAKE) 37 | 38 | 39 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 40 | build: $(MAIN_OUT) 41 | 42 | $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a 43 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 44 | 45 | MSG_BEGIN = -------- begin -------- 46 | MSG_END = -------- end -------- 47 | 48 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 49 | begin: 50 | @echo 51 | @echo $(MSG_BEGIN) 52 | 53 | end: 54 | @echo $(MSG_END) 55 | @echo 56 | 57 | gccversion: 58 | @$(CC) --version 59 | 60 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 61 | clean: begin clean_list end 62 | 63 | clean_list: 64 | -rm $(MAIN_OBJS) 65 | -rm $(MAIN_OUT) 66 | -rm $(MAIN_DEPS) 67 | -cd ../library ; make clean 68 | 69 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 70 | backup: clean 71 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 72 | 73 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 74 | include $(subst .cpp,.d,$(SOURCES)) 75 | 76 | %.d: %.cpp 77 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 78 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 79 | rm -f $@.$$$$ 80 | -------------------------------------------------------------------------------- /testSSC32/testSSC32.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Quick and dirty test of the SSC-32 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "ArduinoDefs.h" 22 | #include "WrapperSerial.h" 23 | 24 | // definition of some helper functions 25 | 26 | extern int SSCRead (byte* pb, int cb, unsigned long ulTimeout, int EOL); 27 | 28 | char szSSC32Device[] = "/dev/ttySSC-32"; 29 | WrapperSerial SSCSerial; 30 | 31 | int main(void) 32 | { 33 | char abT[40]; // give a nice large buffer. 34 | byte cbRead; 35 | 36 | printf("Start\n"); 37 | bool f = SSCSerial.begin(szSSC32Device, B115200); 38 | if (!f) { 39 | printf("SSCSeerial begin failed!\n"); 40 | return (-1); 41 | } 42 | printf("Test Ver command\n"); 43 | SSCSerial.println(" VER"); 44 | SSCSerial.flush(); 45 | cbRead = SSCRead((byte*)abT, sizeof(abT), 250000, 13); 46 | if (cbRead) { 47 | abT[cbRead-1] = 0; // clear out CR 48 | printf("Ver: %s\n", abT); 49 | } 50 | 51 | // Instead of hard checking version numbers instead ask it for 52 | // status of one of the players. If we do not get a response... 53 | // probably does not support 54 | SSCSerial.println("QPL0"); 55 | cbRead = SSCRead((byte*)abT, 4, 25000, -1); 56 | 57 | printf("Check GP Enable: %i\n", cbRead); 58 | 59 | // See if it will digital inputs work at all... 60 | for (char c = 'A'; c <= 'H'; c++) { 61 | SSCSerial.println(c); 62 | abT[0] = '?'; // Some unlikely value 63 | cbRead = SSCRead((byte*)abT, 1, 25000, -1); 64 | printf("%c cb: %i c: %c\n", c, cbRead, abT[0]); 65 | } 66 | 67 | // likewise check for Analog 68 | for (char c = 'A'; c <= 'H'; c++) { 69 | SSCSerial.print("V"); 70 | SSCSerial.println(c); 71 | abT[0] = 1; // Some unlikely value 72 | cbRead = SSCRead((byte*)abT, 1, 25000, -1); 73 | printf("V%c cb: %i c: %x\n", c, cbRead, (int)abT[0]); 74 | } 75 | 76 | // Try to read registers... 77 | printf("\nRegisters\n"); 78 | for (int i = 0; i< 96; i++) { 79 | SSCSerial.print("R"); 80 | SSCSerial.println(i, DEC); 81 | cbRead = SSCRead((byte*)abT, sizeof(abT), 250000, 13); 82 | if (cbRead > 0) { 83 | abT[cbRead-1] = 0; // Get rid of CR 84 | printf(" %s", abT); 85 | } else 86 | printf(" ???"); 87 | if ((i & 0xf) == 0xf) 88 | printf("\n"); 89 | } 90 | 91 | printf("\nCheck EEPROM\n"); 92 | // How about just the first 32 bytes which should be used for sequences 93 | SSCSerial.println("EER 0;32"); 94 | cbRead = SSCRead((byte*)abT, 32, 250000, -1); 95 | for (int i = 0; i< 32; i+=2) { 96 | unsigned int w = (byte)abT[i] + ((unsigned int)(byte)abT[i] >> 8); 97 | printf("%x ", w); 98 | } 99 | printf("\n"); 100 | 101 | printf("Exit\n"); 102 | 103 | 104 | return 0; 105 | } 106 | //============================================================================== 107 | // Quick and dirty helper function to read so many bytes in from the SSC with a timeout and an end of character marker... 108 | //============================================================================== 109 | int SSCRead (byte* pb, int cb, unsigned long ulTimeout, int EOL) 110 | { 111 | int ich; 112 | byte* pbIn = pb; 113 | unsigned long ulTimeLastChar = micros(); 114 | while (cb) { 115 | while ((ich = SSCSerial.read()) == -1) { 116 | // check for timeout 117 | if ((unsigned long)(micros()-ulTimeLastChar) > ulTimeout) { 118 | return (int)(pb-pbIn); 119 | } 120 | } 121 | *pb++ = (byte)ich; 122 | cb--; 123 | 124 | if (ich == EOL) 125 | break; // we matched so get out of here. 126 | ulTimeLastChar = micros(); // update to say we received something 127 | } 128 | 129 | return (int)(pb-pbIn); 130 | } 131 | 132 | -------------------------------------------------------------------------------- /testUPLeds/50-leds.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM=="leds*", PROGRAM="/bin/sh -c '\ 2 | chown -R root:leds /sys/class/leds && chmod -R 770 /sys/class/leds;\ 3 | chown -R root:leds /sys/devices/platform/up-pinctrl/leds && chmod -R 770 /sys/devices/platform/up-pinctrl/leds;\ 4 | chown -R root:leds /sys/devices/platform/AANT0F01:00/upboard-led.* && chmod -R 770 /sys/devices/platform/AANT0F01:00/upboard-led.*;\ 5 | '" 6 | -------------------------------------------------------------------------------- /testUPLeds/makefile: -------------------------------------------------------------------------------- 1 | #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~ 2 | MAIN_OUT = testUPLeds 3 | #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~ 4 | SOURCES = \ 5 | testUPLeds.cpp 6 | 7 | MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES)) 8 | 9 | MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES)) 10 | 11 | #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~ 12 | INCLUDE_DIRS = -I. 13 | 14 | #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~ 15 | LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 16 | 17 | #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~ 18 | COMPILE_OPTS = -pedantic -g -O2 -fno-rtti 19 | 20 | #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~ 21 | LDFLAGS = $(LIBRARY_DIRS) -lpthread -lmraa 22 | 23 | #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~ 24 | ifeq ($(OSTYPE),linux-gnueabi) 25 | #BBBk 26 | TCHAIN_PREFIX=arm-angstrom-linux-gnueabi- 27 | else 28 | ifeq ($(OSTYPE),Edison) 29 | #Edison hard coded OSTYPE 30 | TCHAIN_PREFIX=i586-poky-linux- 31 | else 32 | #RPI 33 | TCHAIN_PREFIX=arm-linux-gnueabihf- 34 | endif 35 | endif 36 | TCHAIN_PREFIX= 37 | 38 | CXX = $(TCHAIN_PREFIX)g++ 39 | CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS) 40 | 41 | #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~ 42 | all: begin gccversion build end 43 | 44 | #~~~~~~~~~~~~~~~~~~~~ library ~~~~~~~~~~~~~~~~~~~~ 45 | #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~ 46 | build: $(MAIN_OUT) 47 | 48 | $(MAIN_OUT): $(MAIN_OBJS) 49 | $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS) 50 | 51 | #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~ 52 | MSG_BEGIN = -------- begin -------- 53 | MSG_END = -------- end -------- 54 | begin: 55 | @echo 56 | @echo $(MSG_BEGIN) 57 | 58 | end: 59 | @echo $(MSG_END) 60 | @echo 61 | 62 | gccversion: 63 | @$(CC) --version 64 | 65 | #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~ 66 | clean: begin clean_list end 67 | 68 | clean_list: 69 | -rm $(MAIN_OBJS) 70 | -rm $(MAIN_OUT) 71 | -rm $(MAIN_DEPS) 72 | 73 | #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~ 74 | backup: clean 75 | tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz * 76 | 77 | #~~~~~~~~~~~~~~~~~~~~ Dependency Generation 78 | include $(subst .cpp,.d,$(SOURCES)) 79 | 80 | %.d: %.cpp 81 | $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \ 82 | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 83 | rm -f $@.$$$$ 84 | -------------------------------------------------------------------------------- /testUPLeds/testUPLeds.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define USE_MRAA 11 | #ifdef USE_MRAA 12 | #include "mraa.h" 13 | #endif 14 | 15 | volatile uint8_t g_continue = true; 16 | 17 | typedef enum {GREEN_LED = 0, YELLOW_LED = 1, RED_LED = 2, BLUE_LED = 3} Leds; 18 | 19 | extern bool set_led(Leds led, uint8_t value); 20 | 21 | //==================================================================================================== 22 | // SignalHandler - Try to free up things like servos if we abort. 23 | //==================================================================================================== 24 | void SignalHandler(int sig){ 25 | printf("Caught signal %d\n", sig); 26 | 27 | if (!g_continue) { 28 | printf("Second signal Abort\n"); 29 | exit(1); 30 | } 31 | // Set global telling main to abort and return 32 | g_continue = false; 33 | } 34 | 35 | 36 | int main(int argc, char** argv) 37 | { 38 | bool has_blue_led = false; 39 | uint8_t exit_loop_count = 8; 40 | 41 | struct sigaction sigIntHandler; 42 | 43 | sigIntHandler.sa_handler = SignalHandler; 44 | sigemptyset(&sigIntHandler.sa_mask); 45 | sigIntHandler.sa_flags = 0; 46 | 47 | sigaction(SIGINT, &sigIntHandler, NULL); 48 | 49 | // Pretty simple setup. 50 | printf("\n\n*** Start testing leds ***\n"); 51 | #ifdef USE_MRAA 52 | mraa_result_t rtv = mraa_init(); 53 | //if (rtv != MRAA_SUCCESS && rtv != MRAA_ERROR_PLATFORM_ALREADY_INITIALISED) 54 | if (rtv != MRAA_SUCCESS) 55 | { 56 | printf("MRAA Init Failed,Return Value is %d\n", rtv); 57 | return 0; 58 | } 59 | printf("MRAA Version: %s\nStarting Read\n",mraa_get_version()); 60 | printf("MRAA platform: %s\n", mraa_get_platform_name()); 61 | mraa_platform_t platform = mraa_get_platform_type(); 62 | if (platform == MRAA_UP) { 63 | printf("Running on UP board - 3 leds\n"); 64 | } else if (platform == MRAA_UP2) { 65 | printf("Running on UP2 board - 4 leds\n"); 66 | has_blue_led = true; 67 | exit_loop_count = 16; 68 | } 69 | #endif 70 | 71 | //usleep(250000L); 72 | while(g_continue) { 73 | for (int i = 0; i < exit_loop_count; i++) { 74 | set_led(GREEN_LED, (i&1)? 1 : 0); 75 | set_led(YELLOW_LED, (i&2)? 1 : 0); 76 | set_led(RED_LED, (i&4)? 1 : 0); 77 | if (has_blue_led) set_led(BLUE_LED, (i&8)? 1 : 0); 78 | usleep(250000L); // sleep 250ms 79 | } 80 | } 81 | // Make sure they are all off. 82 | set_led(GREEN_LED, 0); 83 | set_led(YELLOW_LED, 0); 84 | set_led(RED_LED, 0); 85 | if (has_blue_led) set_led(BLUE_LED, 0); 86 | } 87 | 88 | bool set_led(Leds led, uint8_t value) { 89 | int led_handle = -1; 90 | char value_string[4]; 91 | 92 | // Open file 93 | switch (led) { 94 | case GREEN_LED: 95 | led_handle = open("/sys/class/leds/upboard:green:/brightness", O_WRONLY); 96 | break; 97 | case YELLOW_LED: 98 | led_handle = open("/sys/class/leds/upboard:yellow:/brightness", O_WRONLY); 99 | break; 100 | case RED_LED: 101 | led_handle = open("/sys/class/leds/upboard:red:/brightness", O_WRONLY); 102 | break; 103 | case BLUE_LED: 104 | led_handle = open("/sys/class/leds/upboard:blue:/brightness", O_WRONLY); 105 | break; 106 | } 107 | if (led_handle == -1) { 108 | printf("set_led(%d, %d) failed to open file: %d\n\r", (uint8_t)led, value, errno); 109 | return false; 110 | } 111 | // Write file 112 | int length = snprintf(value_string, sizeof(value_string), "%d", value); 113 | if (write(led_handle, value_string, length * sizeof(char)) == -1) { 114 | printf("set_led(%d, %d) failed to write to file: %d\n\r", (uint8_t)led, value, errno); 115 | close(led_handle); 116 | return false; 117 | } 118 | close(led_handle); 119 | //printf("set_led(%d, %d) succeed\n\r", (uint8_t)led, value); 120 | return true; 121 | } 122 | --------------------------------------------------------------------------------