├── Arduino-Mega-2560-Pinout.webp ├── Chopper └── Chopper.ino ├── LICENSE ├── Libraries ├── Adafruit_Soundboard_library │ ├── .github │ │ ├── ISSUE_TEMPLATE.md │ │ └── PULL_REQUEST_TEMPLATE.md │ ├── Adafruit_Soundboard.cpp │ ├── Adafruit_Soundboard.h │ ├── README.md │ ├── examples │ │ └── menucommands │ │ │ └── menucommands.ino │ └── library.properties ├── Sabertooth │ ├── Sabertooth.cpp │ ├── Sabertooth.h │ ├── SabertoothArduinoLibrary.chm │ ├── changes.txt │ ├── examples │ │ ├── 1.Basics │ │ │ ├── Jolty │ │ │ │ └── Jolty.ino │ │ │ ├── Sweep │ │ │ │ └── Sweep.ino │ │ │ └── TankStyleSweep │ │ │ │ └── TankStyleSweep.ino │ │ ├── 2.Settings │ │ │ ├── MinVoltage │ │ │ │ └── MinVoltage.ino │ │ │ ├── Persistent │ │ │ │ ├── BaudRate │ │ │ │ │ └── BaudRate.ino │ │ │ │ ├── Deadband │ │ │ │ │ └── Deadband.ino │ │ │ │ ├── MaxVoltage │ │ │ │ │ └── MaxVoltage.ino │ │ │ │ └── Ramping │ │ │ │ │ └── Ramping.ino │ │ │ └── SerialTimeout │ │ │ │ └── SerialTimeout.ino │ │ └── 3.Advanced │ │ │ ├── SharedLine │ │ │ └── SharedLine.ino │ │ │ └── SoftwareSerial │ │ │ └── SoftwareSerial.ino │ ├── keywords.txt │ └── license.txt └── USB_Host_Shield_2.0 │ ├── .gitattributes │ ├── .gitignore │ ├── .gitmodules │ ├── .travis.yml │ ├── BTD.cpp │ ├── BTD.h │ ├── BTHID.cpp │ ├── BTHID.h │ ├── PS3BT.cpp │ ├── PS3BT.h │ ├── PS3Enums.h │ ├── PS3USB.cpp │ ├── PS3USB.h │ ├── PS4BT.h │ ├── PS4Parser.cpp │ ├── PS4Parser.h │ ├── PS4USB.h │ ├── PSBuzz.cpp │ ├── PSBuzz.h │ ├── README.md │ ├── SPP.cpp │ ├── SPP.h │ ├── Usb.cpp │ ├── Usb.h │ ├── UsbCore.h │ ├── Wii.cpp │ ├── Wii.h │ ├── WiiCameraReadme.md │ ├── XBOXOLD.cpp │ ├── XBOXOLD.h │ ├── XBOXONE.cpp │ ├── XBOXONE.h │ ├── XBOXRECV.cpp │ ├── XBOXRECV.h │ ├── XBOXUSB.cpp │ ├── XBOXUSB.h │ ├── address.h │ ├── adk.cpp │ ├── adk.h │ ├── avrpins.h │ ├── cdc_XR21B1411.cpp │ ├── cdc_XR21B1411.h │ ├── cdcacm.cpp │ ├── cdcacm.h │ ├── cdcftdi.cpp │ ├── cdcftdi.h │ ├── cdcprolific.cpp │ ├── cdcprolific.h │ ├── confdescparser.h │ ├── controllerEnums.h │ ├── examples │ ├── Bluetooth │ │ ├── BTHID │ │ │ ├── BTHID.ino │ │ │ ├── KeyboardParser.h │ │ │ └── MouseParser.h │ │ ├── PS3BT │ │ │ └── PS3BT.ino │ │ ├── PS3Multi │ │ │ └── PS3Multi.ino │ │ ├── PS3SPP │ │ │ └── PS3SPP.ino │ │ ├── PS4BT │ │ │ └── PS4BT.ino │ │ ├── SPP │ │ │ └── SPP.ino │ │ ├── SPPMulti │ │ │ └── SPPMulti.ino │ │ ├── Wii │ │ │ └── Wii.ino │ │ ├── WiiBalanceBoard │ │ │ └── WiiBalanceBoard.ino │ │ ├── WiiIRCamera │ │ │ └── WiiIRCamera.ino │ │ ├── WiiMulti │ │ │ └── WiiMulti.ino │ │ └── WiiUProController │ │ │ └── WiiUProController.ino │ ├── HID │ │ ├── SRWS1 │ │ │ ├── SRWS1.cpp │ │ │ ├── SRWS1.h │ │ │ └── SRWS1.ino │ │ ├── USBHIDBootKbd │ │ │ └── USBHIDBootKbd.ino │ │ ├── USBHIDBootKbdAndMouse │ │ │ └── USBHIDBootKbdAndMouse.ino │ │ ├── USBHIDBootMouse │ │ │ └── USBHIDBootMouse.ino │ │ ├── USBHIDJoystick │ │ │ ├── USBHIDJoystick.ino │ │ │ ├── hidjoystickrptparser.cpp │ │ │ └── hidjoystickrptparser.h │ │ ├── USBHIDMultimediaKbd │ │ │ └── USBHIDMultimediaKbd.ino │ │ ├── USBHID_desc │ │ │ ├── USBHID_desc.ino │ │ │ └── pgmstrings.h │ │ ├── le3dp │ │ │ ├── le3dp.ino │ │ │ ├── le3dp_rptparser.cpp │ │ │ └── le3dp_rptparser.h │ │ └── scale │ │ │ ├── scale.ino │ │ │ ├── scale_rptparser.cpp │ │ │ └── scale_rptparser.h │ ├── PS3USB │ │ └── PS3USB.ino │ ├── PS4USB │ │ └── PS4USB.ino │ ├── PSBuzz │ │ └── PSBuzz.ino │ ├── USBH_MIDI │ │ ├── USBH_MIDI_dump │ │ │ └── USBH_MIDI_dump.ino │ │ ├── USB_MIDI_converter │ │ │ └── USB_MIDI_converter.ino │ │ ├── USB_MIDI_converter_multi │ │ │ └── USB_MIDI_converter_multi.ino │ │ ├── bidirectional_converter │ │ │ └── bidirectional_converter.ino │ │ └── eVY1_sample │ │ │ └── eVY1_sample.ino │ ├── USB_desc │ │ ├── USB_desc.ino │ │ └── pgmstrings.h │ ├── Xbox │ │ ├── XBOXOLD │ │ │ └── XBOXOLD.ino │ │ ├── XBOXONE │ │ │ └── XBOXONE.ino │ │ ├── XBOXRECV │ │ │ └── XBOXRECV.ino │ │ └── XBOXUSB │ │ │ └── XBOXUSB.ino │ ├── acm │ │ └── acm_terminal │ │ │ ├── acm_terminal.ino │ │ │ └── pgmstrings.h │ ├── adk │ │ ├── ArduinoBlinkLED │ │ │ └── ArduinoBlinkLED.ino │ │ ├── adk_barcode │ │ │ └── adk_barcode.ino │ │ ├── demokit_20 │ │ │ └── demokit_20.ino │ │ ├── term_test │ │ │ └── term_test.ino │ │ └── term_time │ │ │ └── term_time.ino │ ├── board_qc │ │ └── board_qc.ino │ ├── cdc_XR21B1411 │ │ └── XR_terminal │ │ │ └── XR_terminal.ino │ ├── ftdi │ │ └── USBFTDILoopback │ │ │ ├── USBFTDILoopback.ino │ │ │ └── pgmstrings.h │ ├── hub_demo │ │ ├── hub_demo.ino │ │ └── pgmstrings.h │ ├── max_LCD │ │ └── max_LCD.ino │ ├── pl2303 │ │ ├── pl2303_gprs_terminal │ │ │ └── pl2303_gprs_terminal.ino │ │ ├── pl2303_gps │ │ │ └── pl2303_gps.ino │ │ ├── pl2303_tinygps │ │ │ └── pl2303_tinygps.ino │ │ └── pl2303_xbee_terminal │ │ │ └── pl2303_xbee_terminal.ino │ └── testusbhostFAT │ │ ├── Makefile │ │ ├── README.md │ │ └── testusbhostFAT.ino │ ├── gpl2.txt │ ├── hexdump.h │ ├── hid.cpp │ ├── hid.h │ ├── hidboot.cpp │ ├── hidboot.h │ ├── hidcomposite.cpp │ ├── hidcomposite.h │ ├── hidescriptorparser.cpp │ ├── hidescriptorparser.h │ ├── hiduniversal.cpp │ ├── hiduniversal.h │ ├── hidusagestr.h │ ├── hidusagetitlearrays.cpp │ ├── keywords.txt │ ├── library.json │ ├── library.properties │ ├── macros.h │ ├── masstorage.cpp │ ├── masstorage.h │ ├── max3421e.h │ ├── max_LCD.cpp │ ├── max_LCD.h │ ├── message.cpp │ ├── message.h │ ├── parsetools.cpp │ ├── parsetools.h │ ├── printhex.h │ ├── settings.h │ ├── sink_parser.h │ ├── usb_ch9.h │ ├── usbh_midi.cpp │ ├── usbh_midi.h │ ├── usbhid.cpp │ ├── usbhid.h │ ├── usbhost.h │ ├── usbhub.cpp │ ├── usbhub.h │ ├── version_helper.h │ └── xboxEnums.h ├── Models ├── AmazonMotorBracket.stl ├── FlatPackE100FootDrive │ ├── Scooter_drive_center_x2_v1.stl │ ├── Scooter_drive_center_x2_v2.dxf │ ├── Scooter_drive_center_x2_v2.stl │ ├── Scooter_drive_motor_mount.dxf │ ├── Scooter_drive_motor_mount.stl │ ├── Scooter_drive_side_inner.dxf │ ├── Scooter_drive_side_inner.stl │ ├── Scooter_drive_side_outer.dxf │ ├── Scooter_drive_side_outer.stl │ ├── Scooter_drive_spacers_frame.stl │ ├── Scooter_drive_spacers_motor_mount.stl │ └── Scooter_drive_spacers_rear_wheel.stl ├── LockingStrip1_0.stl ├── LockingStrip1_1.stl ├── LockingStrip1_2.stl ├── LockingStrip1_3.stl ├── RingGear_77_0.stl ├── RingGear_77_1.stl ├── RingGear_77_2.stl ├── RingGear_77_3.stl ├── RingGear_77_4.stl ├── RingGear_77_5.stl ├── RingGear_77_6.stl ├── RingGear_77_7.stl ├── RingGear_77_8.stl ├── battery_mount.stl ├── body_electronics_mount_center.stl ├── body_electronics_mount_left.stl ├── body_electronics_mount_right.stl ├── buck_converter_mount.stl ├── dome_adapter_with_platform.stl ├── dome_electronics_holder.stl ├── eye_neo_holder .stl ├── leg_lock_v3.stl ├── motor gear_77.stl ├── new_wheel_mount.stl ├── power_bar_holder.stl ├── speaker_body.stl ├── speaker_mount.stl ├── strong_wheel_mount.stl ├── strong_wood_mount_back.stl ├── strong_wood_mount_front.stl ├── switch_housing.stl └── voltage_holder.stl ├── README.md ├── Robotics Meeting Chopper Presentation 7-21-18.pdf ├── body_wiring.png ├── chopper_board_back.jpg ├── chopper_board_front.jpg └── chopper_wiring.png /Arduino-Mega-2560-Pinout.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Arduino-Mega-2560-Pinout.webp -------------------------------------------------------------------------------- /Libraries/Adafruit_Soundboard_library/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening an issue on an Adafruit Arduino library repository. To 2 | improve the speed of resolution please review the following guidelines and 3 | common troubleshooting steps below before creating the issue: 4 | 5 | - **Do not use GitHub issues for troubleshooting projects and issues.** Instead use 6 | the forums at http://forums.adafruit.com to ask questions and troubleshoot why 7 | something isn't working as expected. In many cases the problem is a common issue 8 | that you will more quickly receive help from the forum community. GitHub issues 9 | are meant for known defects in the code. If you don't know if there is a defect 10 | in the code then start with troubleshooting on the forum first. 11 | 12 | - **If following a tutorial or guide be sure you didn't miss a step.** Carefully 13 | check all of the steps and commands to run have been followed. Consult the 14 | forum if you're unsure or have questions about steps in a guide/tutorial. 15 | 16 | - **For Arduino projects check these very common issues to ensure they don't apply**: 17 | 18 | - For uploading sketches or communicating with the board make sure you're using 19 | a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes 20 | very hard to tell the difference between a data and charge cable! Try using the 21 | cable with other devices or swapping to another cable to confirm it is not 22 | the problem. 23 | 24 | - **Be sure you are supplying adequate power to the board.** Check the specs of 25 | your board and plug in an external power supply. In many cases just 26 | plugging a board into your computer is not enough to power it and other 27 | peripherals. 28 | 29 | - **Double check all soldering joints and connections.** Flakey connections 30 | cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints. 31 | 32 | - **Ensure you are using an official Arduino or Adafruit board.** We can't 33 | guarantee a clone board will have the same functionality and work as expected 34 | with this code and don't support them. 35 | 36 | If you're sure this issue is a defect in the code and checked the steps above 37 | please fill in the following fields to provide enough troubleshooting information. 38 | You may delete the guideline and text above to just leave the following details: 39 | 40 | - Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE** 41 | 42 | - Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO 43 | VERSION HERE** 44 | 45 | - List the steps to reproduce the problem below (if possible attach a sketch or 46 | copy the sketch code in too): **LIST REPRO STEPS BELOW** 47 | -------------------------------------------------------------------------------- /Libraries/Adafruit_Soundboard_library/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for creating a pull request to contribute to Adafruit's GitHub code! 2 | Before you open the request please review the following guidelines and tips to 3 | help it be more easily integrated: 4 | 5 | - **Describe the scope of your change--i.e. what the change does and what parts 6 | of the code were modified.** This will help us understand any risks of integrating 7 | the code. 8 | 9 | - **Describe any known limitations with your change.** For example if the change 10 | doesn't apply to a supported platform of the library please mention it. 11 | 12 | - **Please run any tests or examples that can exercise your modified code.** We 13 | strive to not break users of the code and running tests/examples helps with this 14 | process. 15 | 16 | Thank you again for contributing! We will try to test and integrate the change 17 | as soon as we can, but be aware we have many GitHub repositories to manage and 18 | can't immediately respond to every request. There is no need to bump or check in 19 | on a pull request (it will clutter the discussion of the request). 20 | 21 | Also don't be worried if the request is closed or not integrated--sometimes the 22 | priorities of Adafruit's GitHub code (education, ease of use) might not match the 23 | priorities of the pull request. Don't fret, the open source community thrives on 24 | forks and GitHub makes it easy to keep your changes in a forked repo. 25 | 26 | After reviewing the guidelines above you can delete this text from the pull request. 27 | -------------------------------------------------------------------------------- /Libraries/Adafruit_Soundboard_library/Adafruit_Soundboard.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_Soundboard.h 3 | */ 4 | 5 | #ifndef _ADAFRUIT_SOUNDBOARD_H_ 6 | #define _ADAFRUIT_SOUNDBOARD_H_ 7 | 8 | #include "Arduino.h" 9 | 10 | #define LINE_BUFFER_SIZE 80 //!< Size of the line buffer 11 | #define MAXFILES 25 //!< Max number of files 12 | 13 | /*! 14 | * @brief Class that stores the state and functions of the soundboard object 15 | */ 16 | class Adafruit_Soundboard : public Print { 17 | public: 18 | /*! 19 | * @brief Adafruit_Soundboard constructor 20 | * @param s Pointer to the Serial stream 21 | * @param d Pointer to the debug port 22 | * @param r Reset pin 23 | */ 24 | Adafruit_Soundboard(Stream *s, Stream *d, int8_t r); 25 | 26 | boolean reset(void); 27 | 28 | /*! 29 | * @brief Reads a line from the stream 30 | * @return Returns the line read 31 | */ 32 | int readLine(void); 33 | uint8_t listFiles(void); 34 | 35 | /*! 36 | * @brief Returns the filename 37 | * @param n Id of the file 38 | * @return Returns the filename 39 | */ 40 | char *fileName(uint8_t n); 41 | /*! 42 | * @brief Returns the size of the file 43 | * @param n id of the file 44 | * @return Returns the filesize 45 | */ 46 | uint32_t fileSize(uint8_t n); 47 | 48 | /*! 49 | * @brief Raises the volume 50 | * @return Returns the current volume 51 | */ 52 | uint8_t volUp(void); 53 | /*! 54 | * @brief Lowers the volume 55 | * @return Returns the current volume 56 | */ 57 | uint8_t volDown(void); 58 | 59 | /*! 60 | * @brief Play the specified track 61 | * @param n track id 62 | * @return Returns true if the track was played 63 | */ 64 | boolean playTrack(uint8_t n); 65 | /*! 66 | * @brief Play the specified track 67 | * @param name track name 68 | * @return Returns true if the track was played 69 | */ 70 | boolean playTrack(char *name); 71 | /*! 72 | * @brief Pauses track 73 | * @return Returns if pausing was successful 74 | */ 75 | boolean pause(void); 76 | /*! 77 | * @brief Unpauses track 78 | * @return Returns if unpausing was successful 79 | */ 80 | boolean unpause(void); 81 | /*! 82 | * @brief Stops track 83 | * @return Returns if stopping was successful 84 | */ 85 | boolean stop(void); 86 | 87 | /*! 88 | * @brief Returns the track time 89 | * @param current Buffer with the current track time 90 | * @param total Buffer with the total track time 91 | * @return Returns the current track time 92 | */ 93 | boolean trackTime(uint32_t *current, uint32_t *total); 94 | /*! 95 | * @brief Returns the track size 96 | * @param current Buffer with the current track size 97 | * @param total Buffer with the total track size 98 | * @return Returns how many bytes are remaining over the total track size 99 | */ 100 | boolean trackSize(uint32_t *current, uint32_t *total); 101 | 102 | private: 103 | Stream *stream; // -> sound board, e.g. SoftwareSerial or Serial1 104 | Stream *debug; // -> host, e.g. Serial 105 | 106 | int8_t reset_pin; 107 | char line_buffer[LINE_BUFFER_SIZE]; 108 | boolean writing; 109 | 110 | // File name & size caching 111 | uint8_t files; 112 | char filenames[MAXFILES][12]; 113 | uint32_t filesizes[MAXFILES]; 114 | 115 | virtual size_t write(uint8_t); // Because Print subclass 116 | }; 117 | #endif 118 | -------------------------------------------------------------------------------- /Libraries/Adafruit_Soundboard_library/README.md: -------------------------------------------------------------------------------- 1 | # Adafruit_Soundboard_library [![Build Status](https://github.com/adafruit/Adafruit_Soundboard_library/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/Adafruit_Soundboard_library/actions)[![Documentation](https://github.com/adafruit/ci-arduino/blob/master/assets/doxygen_badge.svg)](http://adafruit.github.io/Adafruit_Soundboard_library/html/index.html) 2 | 3 | This is a library for the Adafruit Audio FX Sound Boards in UART mode 4 | 5 | * [Adafruit Audio FX Mini Sound Board - WAV/OGG Trigger - 2MB Flash](https://www.adafruit.com/products/2342) 6 | * [Adafruit Audio FX Mini Sound Board - WAV/OGG Trigger - 16MB Flash](https://www.adafruit.com/products/2341) 7 | * [Adafruit Audio FX Sound Board + 2x2W Amp - WAV/OGG Trigger - 2MB](https://www.adafruit.com/products/2210) 8 | * [Adafruit Audio FX Sound Board + 2x2W Amp - WAV/OGG Trigger - 16MB](https://www.adafruit.com/products/2217) 9 | * [Adafruit Audio FX Sound Board - WAV/OGG Trigger with 2MB Flash](https://www.adafruit.com/products/2133) 10 | * [Adafruit Audio FX Sound Board - WAV/OGG Trigger with 16MB Flash](https://www.adafruit.com/products/2220) 11 | 12 | Check out the links above for our tutorials and wiring diagrams 13 | This sound fx driver uses TTL Serial to communicate 14 | 15 | This is a list of the UART strings that will trigger actions on the Sound Board. For more details, see [Adafruit_Soundboard.cpp](Adafruit_Soundboard.cpp) (all commands must be followed by a carriage return character (`\r`) and then a new line character(`\n`), just like Serial.println()) 16 | 17 | | ASCII Character(s) sent to Sound Board | Description | 18 | | :---: | :---: | 19 | | `L` | [return a list of all the files on the Sound Board over the serial connection](Adafruit_Soundboard.cpp#L94) | 20 | | `#{n}` | [play song number "{n}"](Adafruit_Soundboard.cpp#L142) | 21 | | `P{name}` | [play song with a name of "{name}"](Adafruit_Soundboard.cpp#L170) | 22 | | `+` | [increase the volume](Adafruit_Soundboard.cpp#L195) | 23 | | `-` | [decrease the volume](Adafruit_Soundboard.cpp#L208) | 24 | | `=` | [pause playback](Adafruit_Soundboard.cpp#L221) | 25 | | `>` | [resume playback](Adafruit_Soundboard.cpp#L235) | 26 | | `q` | [stop playback](Adafruit_Soundboard.cpp#L248) | 27 | | `t` | [return the current time in the track and the total time of the track in seconds over the serial connection](Adafruit_Soundboard.cpp#L262) | 28 | | `s` | [return the remaining size of the track and the total size of the track in bytes over the serial connection](Adafruit_Soundboard.cpp#L277) | 29 | 30 | 31 | Adafruit invests time and resources providing this open source code, 32 | please support Adafruit and open-source hardware by purchasing 33 | products from Adafruit! 34 | 35 | Written by Limor Fried/Ladyada for Adafruit Industries. 36 | MIT license, all text above must be included in any redistribution 37 | 38 | To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_Soundboard. Check that the Adafruit_Soundboard folder contains Adafruit_Soundboard.cpp and Adafruit_Soundboard.h 39 | 40 | Place the Adafruit_Soundboard library folder your *arduinosketchfolder*/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE 41 | 42 | We also have a great tutorial at: 43 | https://learn.adafruit.com/adafruit-audio-fx-sound-board 44 | -------------------------------------------------------------------------------- /Libraries/Adafruit_Soundboard_library/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit Soundboard library 2 | version=1.1.0 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Arduino Library for UART control of the Adafruit Soundboard 6 | paragraph=Arduino Library for UART control of the Adafruit Soundboard 7 | category=Device Control 8 | url=https://github.com/adafruit/Adafruit_Soundboard_library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /Libraries/Sabertooth/SabertoothArduinoLibrary.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Libraries/Sabertooth/SabertoothArduinoLibrary.chm -------------------------------------------------------------------------------- /Libraries/Sabertooth/changes.txt: -------------------------------------------------------------------------------- 1 | Arduino Libraries for SyRen/Sabertooth 2 | Copyright (c) 2012-2013 Dimension Engineering LLC 3 | http://www.dimensionengineering.com/arduino 4 | 5 | 1 July 2013, Version 1.5 6 | - USB Sabertooth Packet Serial Library 7 | - Initial release. 8 | 9 | 1 April 2013, Version 1.4 10 | - Added documentation. 11 | - Improved support for Arduino Leonardo. 12 | - Packet Serial Library 13 | - Simplified the code to save space and increase readability. 14 | 15 | 3 May 2012, Version 1.3 16 | - Improved compatibility with earlier versions of the Arduino software. 17 | Previous versions required Arduino 1.0 or newer, but this version 18 | should work back to Arduino 0018 (still in use by Debian Linux 6.0) 19 | and possibly earlier. 20 | 21 | If you are using a version of Arduino older than 1.0, you will need 22 | to rename the examples from .ino to .pde to see them in the Examples 23 | menu. 24 | 25 | 20 April 2012, Version 1.2 26 | - Packet Serial Library 27 | - Added a stop() function to match the command set of the Simplified 28 | Serial libraries. 29 | 30 | 19 April 2012, Version 1.1 31 | - Packet Serial Library 32 | - Added a single-argument motor() function as a convenience for SyRen. 33 | 34 | 18 April 2012, Version 1.0 35 | - Initial release. 36 | 37 | Please let us know if you run into any bugs! Thanks and enjoy the library! -------------------------------------------------------------------------------- /Libraries/Sabertooth/examples/1.Basics/Jolty/Jolty.ino: -------------------------------------------------------------------------------- 1 | // Jolty Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | 7 | Sabertooth ST(128); // The Sabertooth is on address 128. We'll name its object ST. 8 | // If you've set up your Sabertooth on a different address, of course change 9 | // that here. For how to configure address, etc. see the DIP Switch Wizard for 10 | // Sabertooth - http://www.dimensionengineering.com/datasheets/SabertoothDIPWizard/start.htm 11 | // SyRen - http://www.dimensionengineering.com/datasheets/SyrenDIPWizard/start.htm 12 | // Be sure to select Packetized Serial Mode for use with this library. 13 | // 14 | // On that note, you can use this library for SyRen just as easily. 15 | // The diff-drive commands (drive, turn) do not work on a SyRen, of course, but it will respond correctly 16 | // if you command motor 1 to do something (ST.motor(1, ...)), just like a Sabertooth. 17 | // 18 | // In this sample, hardware serial TX connects to S1. 19 | // See the SoftwareSerial example in 3.Advanced for how to use other pins. 20 | 21 | void setup() 22 | { 23 | SabertoothTXPinSerial.begin(9600); // 9600 is the default baud rate for Sabertooth packet serial. 24 | ST.autobaud(); // Send the autobaud command to the Sabertooth controller(s). 25 | // NOTE: *Not all* Sabertooth controllers need this command. 26 | // It doesn't hurt anything, but V2 controllers use an 27 | // EEPROM setting (changeable with the function setBaudRate) to set 28 | // the baud rate instead of detecting with autobaud. 29 | // 30 | // If you have a 2x12, 2x25 V2, 2x60 or SyRen 50, you can remove 31 | // the autobaud line and save yourself two seconds of startup delay. 32 | } 33 | 34 | 35 | void loop() 36 | { 37 | ST.motor(1, 127); // Go forward at full power. 38 | delay(2000); // Wait 2 seconds. 39 | ST.motor(1, 0); // Stop. 40 | delay(2000); // Wait 2 seconds. 41 | ST.motor(1, -127); // Reverse at full power. 42 | delay(2000); // Wait 2 seconds. 43 | ST.motor(1, 0); // Stop. 44 | delay(2000); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Libraries/Sabertooth/examples/1.Basics/Sweep/Sweep.ino: -------------------------------------------------------------------------------- 1 | // Sweep Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | 7 | Sabertooth ST(128); // The Sabertooth is on address 128. We'll name its object ST. 8 | // If you've set up your Sabertooth on a different address, of course change 9 | // that here. For how to configure address, etc. see the DIP Switch Wizard for 10 | // Sabertooth - http://www.dimensionengineering.com/datasheets/SabertoothDIPWizard/start.htm 11 | // SyRen - http://www.dimensionengineering.com/datasheets/SyrenDIPWizard/start.htm 12 | // Be sure to select Packetized Serial Mode for use with this library. 13 | // 14 | // On that note, you can use this library for SyRen just as easily. 15 | // The diff-drive commands (drive, turn) do not work on a SyRen, of course, but it will respond correctly 16 | // if you command motor 1 to do something (ST.motor(1, ...)), just like a Sabertooth. 17 | // 18 | // In this sample, hardware serial TX connects to S1. 19 | // See the SoftwareSerial example in 3.Advanced for how to use other pins. 20 | 21 | void setup() 22 | { 23 | SabertoothTXPinSerial.begin(9600); // 9600 is the default baud rate for Sabertooth packet serial. 24 | ST.autobaud(); // Send the autobaud command to the Sabertooth controller(s). 25 | // NOTE: *Not all* Sabertooth controllers need this command. 26 | // It doesn't hurt anything, but V2 controllers use an 27 | // EEPROM setting (changeable with the function setBaudRate) to set 28 | // the baud rate instead of detecting with autobaud. 29 | // 30 | // If you have a 2x12, 2x25 V2, 2x60 or SyRen 50, you can remove 31 | // the autobaud line and save yourself two seconds of startup delay. 32 | } 33 | 34 | void loop() 35 | { 36 | int power; 37 | 38 | // Ramp motor 1 from -127 to 127 (full reverse to full forward), 39 | // waiting 20 ms (1/50th of a second) per value. 40 | for (power = -127; power <= 127; power ++) 41 | { 42 | ST.motor(1, power); 43 | delay(20); 44 | } 45 | 46 | // Now go back the way we came. 47 | for (power = 127; power >= -127; power --) 48 | { 49 | ST.motor(1, power); // Tip for SyRen users: Typing ST.motor(power) does the same thing as ST.motor(1, power). 50 | delay(20); // Since SyRen doesn't have a motor 2, this alternative can save you typing. 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Libraries/Sabertooth/examples/1.Basics/TankStyleSweep/TankStyleSweep.ino: -------------------------------------------------------------------------------- 1 | // Tank-Style Sweep Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | 7 | // Mixed mode is for tank-style diff-drive robots. 8 | 9 | Sabertooth ST(128); // The Sabertooth is on address 128. We'll name its object ST. 10 | // If you've set up your Sabertooth on a different address, of course change 11 | // that here. For how to configure address, etc. see the DIP Switch Wizard for 12 | // Sabertooth - http://www.dimensionengineering.com/datasheets/SabertoothDIPWizard/start.htm 13 | // SyRen - http://www.dimensionengineering.com/datasheets/SyrenDIPWizard/start.htm 14 | // Be sure to select Packetized Serial Mode for use with this library. 15 | // 16 | // This sample uses the mixed mode (diff-drive) commands, which require two motors 17 | // and hence do not work on a SyRen. 18 | // 19 | // In this sample, hardware serial TX connects to S1. 20 | // See the SoftwareSerial example in 3.Advanced for how to use other pins. 21 | 22 | void setup() 23 | { 24 | SabertoothTXPinSerial.begin(9600); // 9600 is the default baud rate for Sabertooth packet serial. 25 | ST.autobaud(); // Send the autobaud command to the Sabertooth controller(s). 26 | // NOTE: *Not all* Sabertooth controllers need this command. 27 | // It doesn't hurt anything, but V2 controllers use an 28 | // EEPROM setting (changeable with the function setBaudRate) to set 29 | // the baud rate instead of detecting with autobaud. 30 | // 31 | // If you have a 2x12, 2x25 V2, 2x60 or SyRen 50, you can remove 32 | // the autobaud line and save yourself two seconds of startup delay. 33 | 34 | ST.drive(0); // The Sabertooth won't act on mixed mode packet serial commands until 35 | ST.turn(0); // it has received power levels for BOTH throttle and turning, since it 36 | // mixes the two together to get diff-drive power levels for both motors. 37 | } 38 | 39 | // The SLOW ramp here is turning, and the FAST ramp is throttle. 40 | // If that's the opposite of what you're seeing, swap M2A and M2B. 41 | void loop() 42 | { 43 | int power; 44 | 45 | // Don't turn. Ramp from going backwards to going forwards, waiting 20 ms (1/50th of a second) per value. 46 | for (power = -127; power <= 127; power ++) 47 | { 48 | ST.drive(power); 49 | delay(20); 50 | } 51 | 52 | // Now, let's use a power level of 20 (out of 127) forward. 53 | // This way, our turning will have a radius. 54 | ST.drive(20); 55 | 56 | // Ramp turning from full left to full right SLOWLY by waiting 50 ms (1/20th of a second) per value. 57 | for (power = -127; power <= 127; power ++) 58 | { 59 | ST.turn(power); 60 | delay(50); 61 | } 62 | 63 | // Now stop turning, and stop driving. 64 | ST.turn(0); 65 | ST.drive(0); 66 | 67 | // Wait a bit. This is so you can catch your robot if you want to. :-) 68 | delay(5000); 69 | } 70 | -------------------------------------------------------------------------------- /Libraries/Sabertooth/examples/2.Settings/MinVoltage/MinVoltage.ino: -------------------------------------------------------------------------------- 1 | // Set Minimum Voltage Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | // The values in this sample are specifically for the Sabertooth 2x25, and may 6 | // not have the same effect on other models. 7 | #include 8 | 9 | Sabertooth ST(128); 10 | 11 | void setup() 12 | { 13 | SabertoothTXPinSerial.begin(9600); 14 | ST.autobaud(); 15 | 16 | // This setting does not persist between power cycles. 17 | // See the Packet Serial section of the documentation for what values to use 18 | // for the minimum voltage command. It may vary between Sabertooth models 19 | // (2x25, 2x60, etc.). 20 | // 21 | // On a Sabertooth 2x25, the value is (Desired Volts - 6) X 5. 22 | // So, in this sample, we'll make the low battery cutoff 12V: (12 - 6) X 5 = 30. 23 | ST.setMinVoltage(30); 24 | } 25 | 26 | void loop() 27 | { 28 | ST.motor(1, 50); 29 | delay(5000); 30 | 31 | ST.motor(1, -50); 32 | delay(5000); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /Libraries/Sabertooth/examples/2.Settings/Persistent/BaudRate/BaudRate.ino: -------------------------------------------------------------------------------- 1 | // Set Baud Rate Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | // WARNING: This sample makes changes that will persist between restarts. 6 | // NOTE: The setBaudRate function will only have an effect on V2 controllers (2x12, 2x25 V2, 2x60, SyRen 50). 7 | // Earlier controllers automatically detect the baud rate you choose in Serial.begin 8 | // when you call the autobaud function. Autobaud was replaced in V2 controllers for reliability 9 | // in the event that the Sabertooth lost power. 10 | #include 11 | 12 | Sabertooth ST(128); 13 | 14 | void setup() 15 | { 16 | // This sample will tell the Sabertooth *at 9600 baud* to *switch to 2400 baud*. 17 | // Keep in mind you must send the command to change the baud rate *at the baud rate 18 | // the Sabertooth is listening at* (factory default is 9600). After that, if it works, 19 | // you will be able to communicate using the new baud rate. 20 | // 21 | // Options are: 22 | // 2400 23 | // 9600 24 | // 19200 25 | // 38400 26 | // 115200 (only supported by some devices such as 2X60 -- check the device's datasheet) 27 | // 28 | // WARNING: The Sabertooth remembers this command between restarts. 29 | // To change your Sabertooth back to its default, you must *be at the baud rate you've 30 | // set the Sabertooth to*, and then call ST.setBaudRate(9600) 31 | SabertoothTXPinSerial.begin(9600); 32 | ST.setBaudRate(2400); 33 | SabertoothTXPinSerial.end(); 34 | 35 | // OK, we're at 2400. Let's talk to the Sabertooth at that speed. 36 | SabertoothTXPinSerial.begin(2400); 37 | } 38 | 39 | void loop() 40 | { 41 | ST.drive(0); 42 | ST.turn(20); 43 | delay(2000); 44 | 45 | ST.turn(-20); 46 | delay(2000); 47 | } 48 | 49 | -------------------------------------------------------------------------------- /Libraries/Sabertooth/examples/2.Settings/Persistent/Deadband/Deadband.ino: -------------------------------------------------------------------------------- 1 | // Set Deadband Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | // WARNING: This sample makes changes that will persist between restarts AND in all modes. 6 | #include 7 | 8 | Sabertooth ST(128); 9 | 10 | void setup() 11 | { 12 | SabertoothTXPinSerial.begin(9600); 13 | ST.autobaud(); 14 | 15 | // This makes the deadband from -20 to 20 (of 127). 16 | // If your commands for a motor stay entirely within the deadband for more than 17 | // a second, the motor driver will stop the motor. 18 | // WARNING: The Sabertooth remembers this command between restarts AND in all modes. 19 | // To change your Sabertooth back to its default, call ST.setDeadband(0) 20 | ST.setDeadband(20); 21 | } 22 | 23 | void loop() 24 | { 25 | // 50 is greater than 20, so the motor moves. 26 | ST.motor(1, 50); 27 | delay(5000); 28 | 29 | // 10 is NOT, so the motor does not move. 30 | ST.motor(1, 10); 31 | delay(5000); 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Libraries/Sabertooth/examples/2.Settings/Persistent/MaxVoltage/MaxVoltage.ino: -------------------------------------------------------------------------------- 1 | // Set Maximum Voltage Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | // WARNING: This sample makes changes that will persist between restarts AND in all modes. 6 | // The values in this sample are specifically for the Sabertooth 2x25, and may 7 | // not have the same effect on other models. 8 | #include 9 | 10 | Sabertooth ST(128); 11 | 12 | void setup() 13 | { 14 | SabertoothTXPinSerial.begin(9600); 15 | ST.autobaud(); 16 | 17 | // See the Packet Serial section of the documentation for what values to use 18 | // for the maximum voltage command. It may vary between Sabertooth models 19 | // (2x25, 2x60, etc.). 20 | // 21 | // On a Sabertooth 2x25, the value is (Desired Volts) X 5.12. 22 | // In this sample, we'll cap the max voltage before the motor driver does 23 | // a hard brake at 14V. For a 12V ATX power supply this might be reasonable -- 24 | // at 16V they tend to shut off. Here, if the voltage climbs above 25 | // 14V due to regenerative braking, the Sabertooth will go into hard brake instead. 26 | // While this is occuring, the red Error LED will turn on. 27 | // 28 | // 14 X 5.12 = 71.68, so we'll go with 71, cutting off slightly below 14V. 29 | // 30 | // WARNING: This setting persists between power cycles. 31 | ST.setMaxVoltage(71); 32 | } 33 | 34 | void loop() 35 | { 36 | ST.motor(1, 50); 37 | delay(5000); 38 | 39 | ST.motor(1, -50); 40 | delay(5000); 41 | } 42 | -------------------------------------------------------------------------------- /Libraries/Sabertooth/examples/2.Settings/Persistent/Ramping/Ramping.ino: -------------------------------------------------------------------------------- 1 | // Set Ramping Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | // WARNING: This sample makes changes that will persist between restarts AND in all modes. 6 | #include 7 | 8 | Sabertooth ST(128); 9 | 10 | void setup() 11 | { 12 | SabertoothTXPinSerial.begin(9600); 13 | ST.autobaud(); 14 | 15 | // See the Sabertooth 2x60 documentation for information on ramping values. 16 | // There are three ranges: 1-10 (Fast), 11-20 (Slow), and 21-80 (Intermediate). 17 | // The ramping value 14 used here sets a ramp time of 4 seconds for full 18 | // forward-to-full reverse. 19 | // 20 | // 0 turns off ramping. Turning off ramping requires a power cycle. 21 | // 22 | // WARNING: The Sabertooth remembers this command between restarts AND in all modes. 23 | // To change your Sabertooth back to its default, call ST.setRamping(0) 24 | ST.setRamping(14); 25 | } 26 | 27 | void loop() 28 | { 29 | // Full forward, both motors. 30 | ST.motor(1, 127); 31 | ST.motor(2, 127); 32 | delay(5000); 33 | 34 | // Full reverse 35 | ST.motor(1, -127); 36 | ST.motor(2, -127); 37 | delay(5000); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /Libraries/Sabertooth/examples/2.Settings/SerialTimeout/SerialTimeout.ino: -------------------------------------------------------------------------------- 1 | // Set Serial Timeout Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | 7 | Sabertooth ST(128); 8 | 9 | void setup() 10 | { 11 | SabertoothTXPinSerial.begin(9600); 12 | ST.autobaud(); 13 | 14 | // setTimeout rounds up to the nearest 100 milliseconds, so this 950 will actually be 1 second. 15 | // A value of 0 disables the serial timeout. 16 | ST.setTimeout(950); 17 | } 18 | 19 | void loop() 20 | { 21 | // Set motor 1 to reverse 20 (out of 127), and sleep for 5 seconds. 22 | // Notice how it cuts out after 1 second -- this is the serial timeout in action. 23 | // Since we configured it in setup() for 1 second, 1 second without any new 24 | // commands will cause the motors to stop. 25 | ST.motor(1, -20); 26 | delay(5000); 27 | 28 | // Why do this? 29 | // If the S1 wire gets cut for some reason, or if your program crashes, 30 | // the Sabertooth will stop receiving commands from the Arduino. 31 | // With a timeout, your robot will stop. So, it's a safety feature mostly. 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Libraries/Sabertooth/examples/3.Advanced/SharedLine/SharedLine.ino: -------------------------------------------------------------------------------- 1 | // Shared Line Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | 7 | // Up to 8 Sabertooth/SyRen motor drivers can share the same S1 line. 8 | // This sample uses three: address 128 and 129 on ST1[0] and ST1[2], 9 | // and address 130 on ST2. 10 | Sabertooth ST1[2] = { Sabertooth(128), Sabertooth(129) }; 11 | Sabertooth ST2(130); 12 | 13 | void setup() 14 | { 15 | SabertoothTXPinSerial.begin(9600); 16 | Sabertooth::autobaud(SabertoothTXPinSerial); // Autobaud is for the whole serial line -- you don't need to do 17 | // it for each individual motor driver. This is the version of 18 | // the autobaud command that is not tied to a particular 19 | // Sabertooth object. 20 | // See the examples in 1.Basics for information on whether you 21 | // need this line at all. 22 | } 23 | 24 | void loop() 25 | { 26 | // ST1[0] (address 128) has power 50 (of 127 max) on M1, 27 | // ST1[1] (address 129) has power 60 (of 127 max) on M2, and 28 | // ST2 (address 130) we'll do tank-style and have it drive 20 and turn right 50. 29 | // Do this for 5 seconds. 30 | ST1[0].motor(1, 50); 31 | ST1[1].motor(2, 60); 32 | ST2.drive(20); 33 | ST2.turn(50); 34 | delay(5000); 35 | 36 | // And now let's stop for 5 seconds, except address 130 -- we'll let it stop and turn left... 37 | ST1[0].motor(1, 0); 38 | ST1[1].motor(2, 0); 39 | ST2.drive(0); 40 | ST2.turn(-40); 41 | delay(5000); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Libraries/Sabertooth/examples/3.Advanced/SoftwareSerial/SoftwareSerial.ino: -------------------------------------------------------------------------------- 1 | // Software Serial Sample for Packet Serial 2 | // Copyright (c) 2012 Dimension Engineering LLC 3 | // See license.txt for license details. 4 | 5 | #include 6 | #include 7 | 8 | SoftwareSerial SWSerial(NOT_A_PIN, 11); // RX on no pin (unused), TX on pin 11 (to S1). 9 | Sabertooth ST(128, SWSerial); // Address 128, and use SWSerial as the serial port. 10 | 11 | void setup() 12 | { 13 | SWSerial.begin(9600); 14 | ST.autobaud(); 15 | } 16 | 17 | void loop() 18 | { 19 | int power; 20 | 21 | // Ramp from -127 to 127 (full reverse to full forward), waiting 20 ms (1/50th of a second) per value. 22 | for (power = -127; power <= 127; power ++) 23 | { 24 | ST.motor(1, power); 25 | delay(20); 26 | } 27 | 28 | // Now go back the way we came. 29 | for (power = 127; power >= -127; power --) 30 | { 31 | ST.motor(1, power); 32 | delay(20); 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /Libraries/Sabertooth/keywords.txt: -------------------------------------------------------------------------------- 1 | # Syntax Coloring for the Sabertooth Library 2 | 3 | # Classes 4 | Sabertooth KEYWORD1 5 | 6 | # Sabertooth methods 7 | address KEYWORD2 8 | port KEYWORD2 9 | autobaud KEYWORD2 10 | 11 | # Common methods 12 | command KEYWORD2 13 | motor KEYWORD2 14 | drive KEYWORD2 15 | turn KEYWORD2 16 | setMinVoltage KEYWORD2 17 | setMaxVoltage KEYWORD2 18 | setBaudRate KEYWORD2 19 | setDeadband KEYWORD2 20 | setRamping KEYWORD2 21 | setTimeout KEYWORD2 22 | stop KEYWORD2 23 | -------------------------------------------------------------------------------- /Libraries/Sabertooth/license.txt: -------------------------------------------------------------------------------- 1 | Arduino Libraries for SyRen/Sabertooth 2 | Copyright (c) 2012-2013 Dimension Engineering LLC 3 | http://www.dimensionengineering.com/arduino 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | * text eol=lf 4 | 5 | # Custom for Visual Studio 6 | *.cs diff=csharp 7 | *.sln merge=union 8 | *.csproj merge=union 9 | *.vbproj merge=union 10 | *.fsproj merge=union 11 | *.dbproj merge=union 12 | 13 | # Standard to msysgit 14 | *.doc diff=astextplain 15 | *.DOC diff=astextplain 16 | *.docx diff=astextplain 17 | *.DOCX diff=astextplain 18 | *.dot diff=astextplain 19 | *.DOT diff=astextplain 20 | *.pdf diff=astextplain 21 | *.PDF diff=astextplain 22 | *.rtf diff=astextplain 23 | *.RTF diff=astextplain 24 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/.gitignore: -------------------------------------------------------------------------------- 1 | *.bak 2 | *.zip 3 | *.rar 4 | build/ -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "examples/testusbhostFAT/generic_storage"] 2 | path = examples/testusbhostFAT/generic_storage 3 | url = https://github.com/xxxajk/generic_storage 4 | [submodule "examples/testusbhostFAT/xmem2"] 5 | path = examples/testusbhostFAT/xmem2 6 | url = https://github.com/xxxajk/xmem2 7 | [submodule "examples/testusbhostFAT/Arduino_Makefile_master"] 8 | path = examples/testusbhostFAT/Arduino_Makefile_master 9 | url = https://github.com/xxxajk/Arduino_Makefile_master 10 | [submodule "examples/testusbhostFAT/RTClib"] 11 | path = examples/testusbhostFAT/RTClib 12 | url = https://github.com/xxxajk/RTClib 13 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.7" 4 | 5 | # Cache PlatformIO packages using Travis CI container-based infrastructure 6 | sudo: false 7 | cache: 8 | directories: 9 | - "~/.platformio" 10 | 11 | # Generated using: find examples -type f -name "*.ino" | rev | cut -d/ -f2- | rev | sed 's/^/ - PLATFORMIO_CI_SRC=/' > tmp.yml 12 | env: 13 | - PLATFORMIO_CI_SRC=examples/acm/acm_terminal 14 | - PLATFORMIO_CI_SRC=examples/adk/adk_barcode 15 | - PLATFORMIO_CI_SRC=examples/adk/ArduinoBlinkLED 16 | - PLATFORMIO_CI_SRC=examples/adk/demokit_20 17 | - PLATFORMIO_CI_SRC=examples/adk/term_test 18 | - PLATFORMIO_CI_SRC=examples/adk/term_time 19 | - PLATFORMIO_CI_SRC=examples/Bluetooth/BTHID 20 | - PLATFORMIO_CI_SRC=examples/Bluetooth/PS3BT 21 | - PLATFORMIO_CI_SRC=examples/Bluetooth/PS3Multi 22 | - PLATFORMIO_CI_SRC=examples/Bluetooth/PS3SPP 23 | - PLATFORMIO_CI_SRC=examples/Bluetooth/PS4BT 24 | - PLATFORMIO_CI_SRC=examples/Bluetooth/SPP 25 | - PLATFORMIO_CI_SRC=examples/Bluetooth/SPPMulti 26 | - PLATFORMIO_CI_SRC=examples/Bluetooth/Wii 27 | - PLATFORMIO_CI_SRC=examples/Bluetooth/WiiBalanceBoard 28 | - PLATFORMIO_CI_SRC=examples/Bluetooth/WiiIRCamera PLATFORMIO_BUILD_FLAGS="-DWIICAMERA" 29 | - PLATFORMIO_CI_SRC=examples/Bluetooth/WiiMulti 30 | - PLATFORMIO_CI_SRC=examples/Bluetooth/WiiUProController 31 | - PLATFORMIO_CI_SRC=examples/board_qc 32 | - PLATFORMIO_CI_SRC=examples/cdc_XR21B1411/XR_terminal 33 | - PLATFORMIO_CI_SRC=examples/ftdi/USBFTDILoopback 34 | - PLATFORMIO_CI_SRC=examples/HID/le3dp 35 | - PLATFORMIO_CI_SRC=examples/HID/scale 36 | - PLATFORMIO_CI_SRC=examples/HID/SRWS1 37 | - PLATFORMIO_CI_SRC=examples/HID/USBHID_desc 38 | - PLATFORMIO_CI_SRC=examples/HID/USBHIDBootKbd 39 | - PLATFORMIO_CI_SRC=examples/HID/USBHIDBootKbdAndMouse 40 | - PLATFORMIO_CI_SRC=examples/HID/USBHIDBootMouse 41 | - PLATFORMIO_CI_SRC=examples/HID/USBHIDJoystick 42 | - PLATFORMIO_CI_SRC=examples/HID/USBHIDMultimediaKbd 43 | - PLATFORMIO_CI_SRC=examples/hub_demo 44 | - PLATFORMIO_CI_SRC=examples/max_LCD 45 | - PLATFORMIO_CI_SRC=examples/pl2303/pl2303_gprs_terminal 46 | - PLATFORMIO_CI_SRC=examples/pl2303/pl2303_gps 47 | - PLATFORMIO_CI_SRC=examples/pl2303/pl2303_tinygps 48 | - PLATFORMIO_CI_SRC=examples/pl2303/pl2303_xbee_terminal 49 | - PLATFORMIO_CI_SRC=examples/PS3USB 50 | - PLATFORMIO_CI_SRC=examples/PS4USB 51 | - PLATFORMIO_CI_SRC=examples/PSBuzz 52 | # - PLATFORMIO_CI_SRC=examples/testusbhostFAT 53 | - PLATFORMIO_CI_SRC=examples/USB_desc 54 | - PLATFORMIO_CI_SRC=examples/USBH_MIDI/bidirectional_converter 55 | - PLATFORMIO_CI_SRC=examples/USBH_MIDI/eVY1_sample 56 | - PLATFORMIO_CI_SRC=examples/USBH_MIDI/USB_MIDI_converter 57 | - PLATFORMIO_CI_SRC=examples/USBH_MIDI/USB_MIDI_converter_multi 58 | - PLATFORMIO_CI_SRC=examples/USBH_MIDI/USBH_MIDI_dump 59 | - PLATFORMIO_CI_SRC=examples/Xbox/XBOXOLD 60 | - PLATFORMIO_CI_SRC=examples/Xbox/XBOXONE 61 | - PLATFORMIO_CI_SRC=examples/Xbox/XBOXRECV 62 | - PLATFORMIO_CI_SRC=examples/Xbox/XBOXUSB 63 | 64 | install: 65 | - pip install -U platformio 66 | - export PLATFORMIO_BUILD_FLAGS="$PLATFORMIO_BUILD_FLAGS -DDEBUG_USB_HOST -Wall -Werror" 67 | 68 | # 69 | # Libraries from PlatformIO Library Registry: 70 | # 71 | # http://platformio.org/lib/show/62/MIDI 72 | # http://platformio.org/lib/show/416/TinyGPS 73 | # http://platformio.org/lib/show/417/SPI4Teensy3 74 | - platformio lib install 62 416 417 75 | 76 | script: 77 | - platformio ci --lib="." --board=uno --board=due --board=genuino101 --board=teensy30 --board=teensy31 --board=teensy35 --board=teensy36 --board=teensylc --board=esp12e --board=nodemcu --board=esp32dev 78 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/PSBuzz.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Kristian Lauszus, TKJ Electronics. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Kristian Lauszus, TKJ Electronics 14 | Web : http://www.tkjelectronics.com 15 | e-mail : kristianl@tkjelectronics.com 16 | */ 17 | 18 | #include "PSBuzz.h" 19 | 20 | // To enable serial debugging see "settings.h" 21 | //#define PRINTREPORT // Uncomment to print the report send by the PS Buzz Controllers 22 | 23 | void PSBuzz::ParseHIDData(USBHID *hid __attribute__((unused)), bool is_rpt_id __attribute__((unused)), uint8_t len, uint8_t *buf) { 24 | if (HIDUniversal::VID == PSBUZZ_VID && HIDUniversal::PID == PSBUZZ_PID && len > 2 && buf) { 25 | #ifdef PRINTREPORT 26 | Notify(PSTR("\r\n"), 0x80); 27 | for (uint8_t i = 0; i < len; i++) { 28 | D_PrintHex (buf[i], 0x80); 29 | Notify(PSTR(" "), 0x80); 30 | } 31 | #endif 32 | memcpy(&psbuzzButtons, buf + 2, min((uint8_t)(len - 2), MFK_CASTUINT8T sizeof(psbuzzButtons))); 33 | 34 | if (psbuzzButtons.val != oldButtonState.val) { // Check if anything has changed 35 | buttonClickState.val = psbuzzButtons.val & ~oldButtonState.val; // Update click state variable 36 | oldButtonState.val = psbuzzButtons.val; 37 | } 38 | } 39 | }; 40 | 41 | uint8_t PSBuzz::OnInitSuccessful() { 42 | if (HIDUniversal::VID == PSBUZZ_VID && HIDUniversal::PID == PSBUZZ_PID) { 43 | Reset(); 44 | if (pFuncOnInit) 45 | pFuncOnInit(); // Call the user function 46 | else 47 | setLedOnAll(); // Turn the LED on, on all four controllers 48 | }; 49 | return 0; 50 | }; 51 | 52 | bool PSBuzz::getButtonPress(ButtonEnum b, uint8_t controller) { 53 | return psbuzzButtons.val & (1UL << (b + 5 * controller)); // Each controller uses 5 bits, so the value is shifted 5 for each controller 54 | }; 55 | 56 | bool PSBuzz::getButtonClick(ButtonEnum b, uint8_t controller) { 57 | uint32_t mask = (1UL << (b + 5 * controller)); // Each controller uses 5 bits, so the value is shifted 5 for each controller 58 | bool click = buttonClickState.val & mask; 59 | buttonClickState.val &= ~mask; // Clear "click" event 60 | return click; 61 | }; 62 | 63 | // Source: http://www.developerfusion.com/article/84338/making-usb-c-friendly/ and https://github.com/torvalds/linux/blob/master/drivers/hid/hid-sony.c 64 | void PSBuzz::setLedRaw(bool value, uint8_t controller) { 65 | ledState[controller] = value; // Save value for next time it is called 66 | 67 | uint8_t buf[7]; 68 | buf[0] = 0x00; 69 | buf[1] = ledState[0] ? 0xFF : 0x00; 70 | buf[2] = ledState[1] ? 0xFF : 0x00; 71 | buf[3] = ledState[2] ? 0xFF : 0x00; 72 | buf[4] = ledState[3] ? 0xFF : 0x00; 73 | buf[5] = 0x00; 74 | buf[6] = 0x00; 75 | 76 | PSBuzz_Command(buf, sizeof(buf)); 77 | }; 78 | 79 | void PSBuzz::PSBuzz_Command(uint8_t *data, uint16_t nbytes) { 80 | // bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x00), Report Type (Output 0x02), interface (0x00), datalength, datalength, data) 81 | pUsb->ctrlReq(bAddress, epInfo[0].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL); 82 | }; 83 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/Usb.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; either version 2 of the License, or 6 | (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | Contact information 18 | ------------------- 19 | 20 | Circuits At Home, LTD 21 | Web : http://www.circuitsathome.com 22 | e-mail : support@circuitsathome.com 23 | */ 24 | /* USB functions */ 25 | #ifndef _usb_h_ 26 | #define _usb_h_ 27 | 28 | // WARNING: Do not change the order of includes, or stuff will break! 29 | #include 30 | #include 31 | #include 32 | 33 | // None of these should ever be included by a driver, or a user's sketch. 34 | #include "settings.h" 35 | #include "printhex.h" 36 | #include "message.h" 37 | #include "hexdump.h" 38 | #include "sink_parser.h" 39 | #include "max3421e.h" 40 | #include "address.h" 41 | #include "avrpins.h" 42 | #include "usb_ch9.h" 43 | #include "usbhost.h" 44 | #include "UsbCore.h" 45 | #include "parsetools.h" 46 | #include "confdescparser.h" 47 | 48 | #endif //_usb_h_ 49 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/WiiCameraReadme.md: -------------------------------------------------------------------------------- 1 | Please see for the complete capabilities of the Wii camera. The IR camera code was written based on the above website and with support from Kristian Lauszus. 2 | 3 | This library is large, if you run into memory problems when uploading to the Arduino, disable serial debugging. 4 | 5 | To enable the IR camera code, simply set ```ENABLE_WII_IR_CAMERA``` to 1 in [settings.h](settings.h). 6 | 7 | This library implements the following settings: 8 | 9 | * Report sensitivity mode: 00 00 00 00 00 00 90 00 41 40 00 Suggested by inio (high sensitivity) 10 | * Data Format: Extended mode (0x03). Full mode is not working yet. The output reports 0x3e and 0x3f need tampering with 11 | * In this mode the camera outputs x and y coordinates and a size dimension for the 4 brightest points. 12 | 13 | Again, read through to get an understanding of the camera and its settings. 14 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/BTHID.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example sketch for the HID Bluetooth library - developed by Kristian Lauszus 3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or 4 | send me an e-mail: kristianl@tkjelectronics.com 5 | */ 6 | 7 | #include 8 | #include 9 | #include "KeyboardParser.h" 10 | #include "MouseParser.h" 11 | 12 | // Satisfy the IDE, which needs to see the include statment in the ino too. 13 | #ifdef dobogusinclude 14 | #include 15 | #endif 16 | #include 17 | 18 | USB Usb; 19 | //USBHub Hub1(&Usb); // Some dongles have a hub inside 20 | BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so 21 | 22 | /* You can create the instance of the class in two ways */ 23 | // This will start an inquiry and then pair with your device - you only have to do this once 24 | // If you are using a Bluetooth keyboard, then you should type in the password on the keypad and then press enter 25 | BTHID bthid(&Btd, PAIR, "0000"); 26 | 27 | // After that you can simply create the instance like so and then press any button on the device 28 | //BTHID hid(&Btd); 29 | 30 | KbdRptParser keyboardPrs; 31 | MouseRptParser mousePrs; 32 | 33 | void setup() { 34 | Serial.begin(115200); 35 | #if !defined(__MIPSEL__) 36 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 37 | #endif 38 | if (Usb.Init() == -1) { 39 | Serial.print(F("\r\nOSC did not start")); 40 | while (1); // Halt 41 | } 42 | 43 | bthid.SetReportParser(KEYBOARD_PARSER_ID, &keyboardPrs); 44 | bthid.SetReportParser(MOUSE_PARSER_ID, &mousePrs); 45 | 46 | // If "Boot Protocol Mode" does not work, then try "Report Protocol Mode" 47 | // If that does not work either, then uncomment PRINTREPORT in BTHID.cpp to see the raw report 48 | bthid.setProtocolMode(USB_HID_BOOT_PROTOCOL); // Boot Protocol Mode 49 | //bthid.setProtocolMode(HID_RPT_PROTOCOL); // Report Protocol Mode 50 | 51 | Serial.print(F("\r\nHID Bluetooth Library Started")); 52 | } 53 | void loop() { 54 | Usb.Task(); 55 | } 56 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/KeyboardParser.h: -------------------------------------------------------------------------------- 1 | #ifndef __kbdrptparser_h_ 2 | #define __kbdrptparser_h_ 3 | 4 | class KbdRptParser : public KeyboardReportParser { 5 | protected: 6 | virtual uint8_t HandleLockingKeys(USBHID *hid, uint8_t key); 7 | virtual void OnControlKeysChanged(uint8_t before, uint8_t after); 8 | virtual void OnKeyDown(uint8_t mod, uint8_t key); 9 | virtual void OnKeyUp(uint8_t mod, uint8_t key); 10 | virtual void OnKeyPressed(uint8_t key); 11 | 12 | private: 13 | void PrintKey(uint8_t mod, uint8_t key); 14 | }; 15 | 16 | uint8_t KbdRptParser::HandleLockingKeys(USBHID *hid, uint8_t key) { 17 | uint8_t old_keys = kbdLockingKeys.bLeds; 18 | 19 | switch (key) { 20 | case UHS_HID_BOOT_KEY_NUM_LOCK: 21 | Serial.println(F("Num lock")); 22 | kbdLockingKeys.kbdLeds.bmNumLock = ~kbdLockingKeys.kbdLeds.bmNumLock; 23 | break; 24 | case UHS_HID_BOOT_KEY_CAPS_LOCK: 25 | Serial.println(F("Caps lock")); 26 | kbdLockingKeys.kbdLeds.bmCapsLock = ~kbdLockingKeys.kbdLeds.bmCapsLock; 27 | break; 28 | case UHS_HID_BOOT_KEY_SCROLL_LOCK: 29 | Serial.println(F("Scroll lock")); 30 | kbdLockingKeys.kbdLeds.bmScrollLock = ~kbdLockingKeys.kbdLeds.bmScrollLock; 31 | break; 32 | } 33 | 34 | if (old_keys != kbdLockingKeys.bLeds && hid) { 35 | BTHID *pBTHID = reinterpret_cast (hid); // A cast the other way around is done in BTHID.cpp 36 | pBTHID->setLeds(kbdLockingKeys.bLeds); // Update the LEDs on the keyboard 37 | } 38 | 39 | return 0; 40 | }; 41 | 42 | void KbdRptParser::PrintKey(uint8_t m, uint8_t key) { 43 | MODIFIERKEYS mod; 44 | *((uint8_t*)&mod) = m; 45 | Serial.print((mod.bmLeftCtrl == 1) ? F("C") : F(" ")); 46 | Serial.print((mod.bmLeftShift == 1) ? F("S") : F(" ")); 47 | Serial.print((mod.bmLeftAlt == 1) ? F("A") : F(" ")); 48 | Serial.print((mod.bmLeftGUI == 1) ? F("G") : F(" ")); 49 | 50 | Serial.print(F(" >")); 51 | PrintHex(key, 0x80); 52 | Serial.print(F("< ")); 53 | 54 | Serial.print((mod.bmRightCtrl == 1) ? F("C") : F(" ")); 55 | Serial.print((mod.bmRightShift == 1) ? F("S") : F(" ")); 56 | Serial.print((mod.bmRightAlt == 1) ? F("A") : F(" ")); 57 | Serial.println((mod.bmRightGUI == 1) ? F("G") : F(" ")); 58 | }; 59 | 60 | void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) { 61 | Serial.print(F("DN ")); 62 | PrintKey(mod, key); 63 | uint8_t c = OemToAscii(mod, key); 64 | 65 | if (c) 66 | OnKeyPressed(c); 67 | }; 68 | 69 | void KbdRptParser::OnControlKeysChanged(uint8_t before, uint8_t after) { 70 | MODIFIERKEYS beforeMod; 71 | *((uint8_t*)&beforeMod) = before; 72 | 73 | MODIFIERKEYS afterMod; 74 | *((uint8_t*)&afterMod) = after; 75 | 76 | if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) 77 | Serial.println(F("LeftCtrl changed")); 78 | if (beforeMod.bmLeftShift != afterMod.bmLeftShift) 79 | Serial.println(F("LeftShift changed")); 80 | if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) 81 | Serial.println(F("LeftAlt changed")); 82 | if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) 83 | Serial.println(F("LeftGUI changed")); 84 | 85 | if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) 86 | Serial.println(F("RightCtrl changed")); 87 | if (beforeMod.bmRightShift != afterMod.bmRightShift) 88 | Serial.println(F("RightShift changed")); 89 | if (beforeMod.bmRightAlt != afterMod.bmRightAlt) 90 | Serial.println(F("RightAlt changed")); 91 | if (beforeMod.bmRightGUI != afterMod.bmRightGUI) 92 | Serial.println(F("RightGUI changed")); 93 | }; 94 | 95 | void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key) { 96 | Serial.print(F("UP ")); 97 | PrintKey(mod, key); 98 | }; 99 | 100 | void KbdRptParser::OnKeyPressed(uint8_t key) { 101 | Serial.print(F("ASCII: ")); 102 | Serial.println((char)key); 103 | }; 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/Bluetooth/BTHID/MouseParser.h: -------------------------------------------------------------------------------- 1 | #ifndef __mouserptparser_h__ 2 | #define __mouserptparser_h__ 3 | 4 | class MouseRptParser : public MouseReportParser { 5 | protected: 6 | virtual void OnMouseMove(MOUSEINFO *mi); 7 | virtual void OnLeftButtonUp(MOUSEINFO *mi); 8 | virtual void OnLeftButtonDown(MOUSEINFO *mi); 9 | virtual void OnRightButtonUp(MOUSEINFO *mi); 10 | virtual void OnRightButtonDown(MOUSEINFO *mi); 11 | virtual void OnMiddleButtonUp(MOUSEINFO *mi); 12 | virtual void OnMiddleButtonDown(MOUSEINFO *mi); 13 | }; 14 | 15 | void MouseRptParser::OnMouseMove(MOUSEINFO *mi) { 16 | Serial.print(F("dx=")); 17 | Serial.print(mi->dX, DEC); 18 | Serial.print(F(" dy=")); 19 | Serial.println(mi->dY, DEC); 20 | }; 21 | 22 | void MouseRptParser::OnLeftButtonUp(MOUSEINFO *mi) { 23 | Serial.println(F("L Butt Up")); 24 | }; 25 | 26 | void MouseRptParser::OnLeftButtonDown(MOUSEINFO *mi) { 27 | Serial.println(F("L Butt Dn")); 28 | }; 29 | 30 | void MouseRptParser::OnRightButtonUp(MOUSEINFO *mi) { 31 | Serial.println(F("R Butt Up")); 32 | }; 33 | 34 | void MouseRptParser::OnRightButtonDown(MOUSEINFO *mi) { 35 | Serial.println(F("R Butt Dn")); 36 | }; 37 | 38 | void MouseRptParser::OnMiddleButtonUp(MOUSEINFO *mi) { 39 | Serial.println(F("M Butt Up")); 40 | }; 41 | 42 | void MouseRptParser::OnMiddleButtonDown(MOUSEINFO *mi) { 43 | Serial.println(F("M Butt Dn")); 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/Bluetooth/SPP/SPP.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example sketch for the RFCOMM/SPP Bluetooth library - developed by Kristian Lauszus 3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or 4 | send me an e-mail: kristianl@tkjelectronics.com 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | // Satisfy the IDE, which needs to see the include statment in the ino too. 11 | #ifdef dobogusinclude 12 | #include 13 | #endif 14 | #include 15 | 16 | USB Usb; 17 | //USBHub Hub1(&Usb); // Some dongles have a hub inside 18 | 19 | BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so 20 | /* You can create the instance of the class in two ways */ 21 | SPP SerialBT(&Btd); // This will set the name to the defaults: "Arduino" and the pin to "0000" 22 | //SPP SerialBT(&Btd, "Lauszus's Arduino", "1234"); // You can also set the name and pin like so 23 | 24 | bool firstMessage = true; 25 | 26 | void setup() { 27 | Serial.begin(115200); 28 | #if !defined(__MIPSEL__) 29 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 30 | #endif 31 | if (Usb.Init() == -1) { 32 | Serial.print(F("\r\nOSC did not start")); 33 | while (1); //halt 34 | } 35 | Serial.print(F("\r\nSPP Bluetooth Library Started")); 36 | } 37 | void loop() { 38 | Usb.Task(); // The SPP data is actually not send until this is called, one could call SerialBT.send() directly as well 39 | 40 | if (SerialBT.connected) { 41 | if (firstMessage) { 42 | firstMessage = false; 43 | SerialBT.println(F("Hello from Arduino")); // Send welcome message 44 | } 45 | if (Serial.available()) 46 | SerialBT.write(Serial.read()); 47 | if (SerialBT.available()) 48 | Serial.write(SerialBT.read()); 49 | } 50 | else 51 | firstMessage = true; 52 | } 53 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/Bluetooth/SPPMulti/SPPMulti.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example sketch for the RFCOMM/SPP Bluetooth library - developed by Kristian Lauszus 3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or 4 | send me an e-mail: kristianl@tkjelectronics.com 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | // Satisfy IDE, which only needs to see the include statment in the ino. 11 | #ifdef dobogusinclude 12 | #include 13 | #endif 14 | #include 15 | 16 | USB Usb; 17 | //USBHub Hub1(&Usb); // Some dongles have a hub inside 18 | 19 | BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so 20 | 21 | const uint8_t length = 2; // Set the number of instances here 22 | SPP *SerialBT[length]; // We will use this pointer to store the instances, you can easily make it larger if you like, but it will use a lot of RAM! 23 | 24 | bool firstMessage[length] = { true }; // Set all to true 25 | 26 | void setup() { 27 | for (uint8_t i = 0; i < length; i++) 28 | SerialBT[i] = new SPP(&Btd); // This will set the name to the default: "Arduino" and the pin to "0000" for all connections 29 | 30 | Serial.begin(115200); 31 | #if !defined(__MIPSEL__) 32 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 33 | #endif 34 | if (Usb.Init() == -1) { 35 | Serial.print(F("\r\nOSC did not start")); 36 | while (1); // Halt 37 | } 38 | Serial.print(F("\r\nSPP Bluetooth Library Started")); 39 | } 40 | 41 | void loop() { 42 | Usb.Task(); // The SPP data is actually not send until this is called, one could call SerialBT.send() directly as well 43 | 44 | for (uint8_t i = 0; i < length; i++) { 45 | if (SerialBT[i]->connected) { 46 | if (firstMessage[i]) { 47 | firstMessage[i] = false; 48 | SerialBT[i]->println(F("Hello from Arduino")); // Send welcome message 49 | } 50 | if (SerialBT[i]->available()) 51 | Serial.write(SerialBT[i]->read()); 52 | } 53 | else 54 | firstMessage[i] = true; 55 | } 56 | 57 | // Set the connection you want to send to using the first character 58 | // For instance "0Hello World" would send "Hello World" to connection 0 59 | if (Serial.available()) { 60 | delay(10); // Wait for the rest of the data to arrive 61 | uint8_t id = Serial.read() - '0'; // Convert from ASCII 62 | if (id < length && SerialBT[id]->connected) { // Make sure that the id is valid and make sure that a device is actually connected 63 | while (Serial.available()) // Check if data is available 64 | SerialBT[id]->write(Serial.read()); // Send the data 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/Bluetooth/Wii/Wii.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example sketch for the Wiimote Bluetooth library - developed by Kristian Lauszus 3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or 4 | send me an e-mail: kristianl@tkjelectronics.com 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | // Satisfy the IDE, which needs to see the include statment in the ino too. 11 | #ifdef dobogusinclude 12 | #include 13 | #endif 14 | #include 15 | 16 | USB Usb; 17 | //USBHub Hub1(&Usb); // Some dongles have a hub inside 18 | 19 | BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so 20 | /* You can create the instance of the class in two ways */ 21 | WII Wii(&Btd, PAIR); // This will start an inquiry and then pair with your Wiimote - you only have to do this once 22 | //WII Wii(&Btd); // After that you can simply create the instance like so and then press any button on the Wiimote 23 | 24 | bool printAngle; 25 | 26 | void setup() { 27 | Serial.begin(115200); 28 | #if !defined(__MIPSEL__) 29 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 30 | #endif 31 | if (Usb.Init() == -1) { 32 | Serial.print(F("\r\nOSC did not start")); 33 | while (1); //halt 34 | } 35 | Serial.print(F("\r\nWiimote Bluetooth Library Started")); 36 | } 37 | void loop() { 38 | Usb.Task(); 39 | if (Wii.wiimoteConnected) { 40 | if (Wii.getButtonClick(HOME)) { // You can use getButtonPress to see if the button is held down 41 | Serial.print(F("\r\nHOME")); 42 | Wii.disconnect(); 43 | } 44 | else { 45 | if (Wii.getButtonClick(LEFT)) { 46 | Wii.setLedOff(); 47 | Wii.setLedOn(LED1); 48 | Serial.print(F("\r\nLeft")); 49 | } 50 | if (Wii.getButtonClick(RIGHT)) { 51 | Wii.setLedOff(); 52 | Wii.setLedOn(LED3); 53 | Serial.print(F("\r\nRight")); 54 | } 55 | if (Wii.getButtonClick(DOWN)) { 56 | Wii.setLedOff(); 57 | Wii.setLedOn(LED4); 58 | Serial.print(F("\r\nDown")); 59 | } 60 | if (Wii.getButtonClick(UP)) { 61 | Wii.setLedOff(); 62 | Wii.setLedOn(LED2); 63 | Serial.print(F("\r\nUp")); 64 | } 65 | 66 | if (Wii.getButtonClick(PLUS)) 67 | Serial.print(F("\r\nPlus")); 68 | if (Wii.getButtonClick(MINUS)) 69 | Serial.print(F("\r\nMinus")); 70 | 71 | if (Wii.getButtonClick(ONE)) 72 | Serial.print(F("\r\nOne")); 73 | if (Wii.getButtonClick(TWO)) 74 | Serial.print(F("\r\nTwo")); 75 | 76 | if (Wii.getButtonClick(A)) { 77 | printAngle = !printAngle; 78 | Serial.print(F("\r\nA")); 79 | } 80 | if (Wii.getButtonClick(B)) { 81 | Wii.setRumbleToggle(); 82 | Serial.print(F("\r\nB")); 83 | } 84 | } 85 | #if 0 // Set this to 1 in order to see the angle of the controllers 86 | if (printAngle) { 87 | Serial.print(F("\r\nPitch: ")); 88 | Serial.print(Wii.getPitch()); 89 | Serial.print(F("\tRoll: ")); 90 | Serial.print(Wii.getRoll()); 91 | if (Wii.motionPlusConnected) { 92 | Serial.print(F("\tYaw: ")); 93 | Serial.print(Wii.getYaw()); 94 | } 95 | if (Wii.nunchuckConnected) { 96 | Serial.print(F("\tNunchuck Pitch: ")); 97 | Serial.print(Wii.getNunchuckPitch()); 98 | Serial.print(F("\tNunchuck Roll: ")); 99 | Serial.print(Wii.getNunchuckRoll()); 100 | } 101 | } 102 | #endif 103 | } 104 | #if 0 // Set this to 1 if you are using a Nunchuck controller 105 | if (Wii.nunchuckConnected) { 106 | if (Wii.getButtonClick(Z)) 107 | Serial.print(F("\r\nZ")); 108 | if (Wii.getButtonClick(C)) 109 | Serial.print(F("\r\nC")); 110 | if (Wii.getAnalogHat(HatX) > 137 || Wii.getAnalogHat(HatX) < 117 || Wii.getAnalogHat(HatY) > 137 || Wii.getAnalogHat(HatY) < 117) { 111 | Serial.print(F("\r\nHatX: ")); 112 | Serial.print(Wii.getAnalogHat(HatX)); 113 | Serial.print(F("\tHatY: ")); 114 | Serial.print(Wii.getAnalogHat(HatY)); 115 | } 116 | } 117 | #endif 118 | } 119 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/Bluetooth/WiiBalanceBoard/WiiBalanceBoard.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example sketch for the Wii Balance Board Bluetooth library - developed by Kristian Lauszus 3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or 4 | send me an e-mail: kristianl@tkjelectronics.com 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | // Satisfy the IDE, which needs to see the include statment in the ino too. 11 | #ifdef dobogusinclude 12 | #include 13 | #endif 14 | #include 15 | 16 | USB Usb; 17 | //USBHub Hub1(&Usb); // Some dongles have a hub inside 18 | 19 | BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so 20 | /* You can create the instance of the class in two ways */ 21 | WII Wii(&Btd, PAIR); // This will start an inquiry and then pair with your Wii Balance Board - you only have to do this once 22 | //WII Wii(&Btd); // After that you can simply create the instance like so and then press the power button on the Wii Balance Board 23 | 24 | void setup() { 25 | Serial.begin(115200); 26 | #if !defined(__MIPSEL__) 27 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 28 | #endif 29 | if (Usb.Init() == -1) { 30 | Serial.print(F("\r\nOSC did not start")); 31 | while (1); //halt 32 | } 33 | Serial.print(F("\r\nWii Balance Board Bluetooth Library Started")); 34 | } 35 | void loop() { 36 | Usb.Task(); 37 | if (Wii.wiiBalanceBoardConnected) { 38 | Serial.print(F("\r\nWeight: ")); 39 | for (uint8_t i = 0; i < 4; i++) { 40 | Serial.print(Wii.getWeight((BalanceBoardEnum)i)); 41 | Serial.print(F("\t")); 42 | } 43 | Serial.print(F("Total Weight: ")); 44 | Serial.print(Wii.getTotalWeight()); 45 | if (Wii.getButtonClick(A)) { 46 | Serial.print(F("\r\nA")); 47 | //Wii.setLedToggle(LED1); // The Wii Balance Board has one LED as well 48 | Wii.disconnect(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/Bluetooth/WiiUProController/WiiUProController.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example sketch for the Wiimote Bluetooth library - developed by Kristian Lauszus 3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or 4 | send me an e-mail: kristianl@tkjelectronics.com 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | // Satisfy the IDE, which needs to see the include statment in the ino too. 11 | #ifdef dobogusinclude 12 | #include 13 | #endif 14 | #include 15 | 16 | USB Usb; 17 | //USBHub Hub1(&Usb); // Some dongles have a hub inside 18 | 19 | BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so 20 | /* You can create the instance of the class in two ways */ 21 | WII Wii(&Btd, PAIR); // This will start an inquiry and then pair with your Wiimote - you only have to do this once 22 | //WII Wii(&Btd); // After that you can simply create the instance like so and then press any button on the Wiimote 23 | 24 | void setup() { 25 | Serial.begin(115200); 26 | #if !defined(__MIPSEL__) 27 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 28 | #endif 29 | if (Usb.Init() == -1) { 30 | Serial.print(F("\r\nOSC did not start")); 31 | while (1); //halt 32 | } 33 | Serial.print(F("\r\nWiimote Bluetooth Library Started")); 34 | } 35 | void loop() { 36 | Usb.Task(); 37 | if (Wii.wiiUProControllerConnected) { 38 | if (Wii.getButtonClick(HOME)) { // You can use getButtonPress to see if the button is held down 39 | Serial.print(F("\r\nHome")); 40 | Wii.disconnect(); 41 | } 42 | else { 43 | if (Wii.getButtonClick(LEFT)) { 44 | Wii.setLedOff(); 45 | Wii.setLedOn(LED1); 46 | Serial.print(F("\r\nLeft")); 47 | } 48 | if (Wii.getButtonClick(RIGHT)) { 49 | Wii.setLedOff(); 50 | Wii.setLedOn(LED3); 51 | Serial.print(F("\r\nRight")); 52 | } 53 | if (Wii.getButtonClick(DOWN)) { 54 | Wii.setLedOff(); 55 | Wii.setLedOn(LED4); 56 | Serial.print(F("\r\nDown")); 57 | } 58 | if (Wii.getButtonClick(UP)) { 59 | Wii.setLedOff(); 60 | Wii.setLedOn(LED2); 61 | Serial.print(F("\r\nUp")); 62 | } 63 | 64 | if (Wii.getButtonClick(PLUS)) 65 | Serial.print(F("\r\nPlus")); 66 | if (Wii.getButtonClick(MINUS)) 67 | Serial.print(F("\r\nMinus")); 68 | 69 | if (Wii.getButtonClick(A)) 70 | Serial.print(F("\r\nA")); 71 | if (Wii.getButtonClick(B)) { 72 | Wii.setRumbleToggle(); 73 | Serial.print(F("\r\nB")); 74 | } 75 | if (Wii.getButtonClick(X)) 76 | Serial.print(F("\r\nX")); 77 | if (Wii.getButtonClick(Y)) 78 | Serial.print(F("\r\nY")); 79 | 80 | if (Wii.getButtonClick(L)) 81 | Serial.print(F("\r\nL")); 82 | if (Wii.getButtonClick(R)) 83 | Serial.print(F("\r\nR")); 84 | if (Wii.getButtonClick(ZL)) 85 | Serial.print(F("\r\nZL")); 86 | if (Wii.getButtonClick(ZR)) 87 | Serial.print(F("\r\nZR")); 88 | if (Wii.getButtonClick(L3)) 89 | Serial.print(F("\r\nL3")); 90 | if (Wii.getButtonClick(R3)) 91 | Serial.print(F("\r\nR3")); 92 | } 93 | if (Wii.getAnalogHat(LeftHatX) > 2200 || Wii.getAnalogHat(LeftHatX) < 1800 || Wii.getAnalogHat(LeftHatY) > 2200 || Wii.getAnalogHat(LeftHatY) < 1800 || Wii.getAnalogHat(RightHatX) > 2200 || Wii.getAnalogHat(RightHatX) < 1800 || Wii.getAnalogHat(RightHatY) > 2200 || Wii.getAnalogHat(RightHatY) < 1800) { 94 | Serial.print(F("\r\nLeftHatX: ")); 95 | Serial.print(Wii.getAnalogHat(LeftHatX)); 96 | Serial.print(F("\tLeftHatY: ")); 97 | Serial.print(Wii.getAnalogHat(LeftHatY)); 98 | Serial.print(F("\tRightHatX: ")); 99 | Serial.print(Wii.getAnalogHat(RightHatX)); 100 | Serial.print(F("\tRightHatY: ")); 101 | Serial.print(Wii.getAnalogHat(RightHatY)); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/SRWS1/SRWS1.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016 Kristian Lauszus, TKJ Electronics. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Kristian Lauszus, TKJ Electronics 14 | Web : http://www.tkjelectronics.com 15 | e-mail : kristianl@tkjelectronics.com 16 | */ 17 | 18 | #include "SRWS1.h" 19 | 20 | void SRWS1::ParseHIDData(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { 21 | if (HIDUniversal::VID != STEELSERIES_VID || HIDUniversal::PID != STEELSERIES_SRWS1_PID) // Make sure the right device is actually connected 22 | return; 23 | #if 0 24 | if (len && buf) { 25 | Notify(PSTR("\r\n"), 0x80); 26 | for (uint8_t i = 0; i < len; i++) { 27 | D_PrintHex (buf[i], 0x80); 28 | Notify(PSTR(" "), 0x80); 29 | } 30 | } 31 | #endif 32 | memcpy(&srws1Data, buf, min(len, MFK_CASTUINT8T sizeof(srws1Data))); 33 | 34 | static SRWS1DataButtons oldButtonState; 35 | if (srws1Data.btn.val != oldButtonState.val) { // Check if anything has changed 36 | buttonClickState.val = srws1Data.btn.val & ~oldButtonState.val; // Update click state variable 37 | oldButtonState.val = srws1Data.btn.val; 38 | } 39 | } 40 | 41 | // See: https://github.com/torvalds/linux/blob/master/drivers/hid/hid-steelseries.c 42 | void SRWS1::setLeds(uint16_t leds) { 43 | uint8_t buf[3]; 44 | buf[0] = 0x40; // Report ID 45 | buf[1] = leds & 0xFF; 46 | buf[2] = (leds >> 8) & 0x7F; 47 | pUsb->outTransfer(bAddress, epInfo[ hidInterfaces[0].epIndex[epInterruptOutIndex] ].epAddr, sizeof(buf), buf); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/SRWS1/SRWS1.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016 Kristian Lauszus, TKJ Electronics. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Kristian Lauszus, TKJ Electronics 14 | Web : http://www.tkjelectronics.com 15 | e-mail : kristianl@tkjelectronics.com 16 | */ 17 | 18 | #ifndef __srws1_h__ 19 | #define __srws1_h__ 20 | 21 | #include 22 | 23 | #define STEELSERIES_VID 0x1038 24 | #define STEELSERIES_SRWS1_PID 0x1410 25 | 26 | enum DPADEnum { 27 | DPAD_UP = 0x0, 28 | DPAD_UP_RIGHT = 0x1, 29 | DPAD_RIGHT = 0x2, 30 | DPAD_RIGHT_DOWN = 0x3, 31 | DPAD_DOWN = 0x4, 32 | DPAD_DOWN_LEFT = 0x5, 33 | DPAD_LEFT = 0x6, 34 | DPAD_LEFT_UP = 0x7, 35 | DPAD_OFF = 0xF, 36 | }; 37 | 38 | union SRWS1DataButtons { 39 | struct { 40 | uint8_t dpad : 4; 41 | uint8_t dummy : 3; 42 | uint8_t select : 1; 43 | 44 | uint8_t back : 1; 45 | uint8_t lookLeft : 1; 46 | uint8_t lights : 1; 47 | uint8_t lookBack : 1; 48 | uint8_t rearBrakeBalance : 1; 49 | uint8_t frontBrakeBalance : 1; 50 | uint8_t requestPit : 1; 51 | uint8_t leftGear : 1; 52 | 53 | uint8_t camera : 1; 54 | uint8_t lookRight : 1; 55 | uint8_t boost : 1; 56 | uint8_t horn : 1; 57 | uint8_t hud : 1; 58 | uint8_t launchControl : 1; 59 | uint8_t speedLimiter : 1; 60 | uint8_t rightGear : 1; 61 | } __attribute__((packed)); 62 | uint32_t val : 24; 63 | } __attribute__((packed)); 64 | 65 | struct SRWS1Data { 66 | int16_t tilt; // Range [-1800:1800] 67 | uint16_t rightTrigger : 12; // Range [0:1023] i.e. only 10 bits 68 | uint16_t leftTrigger : 12; // Range [0:1023] i.e. only 10 bits 69 | SRWS1DataButtons btn; 70 | uint8_t assists : 4; 71 | uint8_t steeringSensitivity : 4; 72 | uint8_t assistValues : 4; 73 | } __attribute__((packed)); 74 | 75 | class SRWS1 : public HIDUniversal { 76 | public: 77 | SRWS1(USB *p) : HIDUniversal(p) {}; 78 | bool connected() { 79 | return HIDUniversal::isReady() && HIDUniversal::VID == STEELSERIES_VID && HIDUniversal::PID == STEELSERIES_SRWS1_PID; 80 | }; 81 | void setLeds(uint16_t leds); 82 | SRWS1Data srws1Data; 83 | SRWS1DataButtons buttonClickState; 84 | 85 | private: 86 | void ParseHIDData(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); // Called by the HIDUniversal library 87 | uint8_t OnInitSuccessful() { // Called by the HIDUniversal library on success 88 | if (HIDUniversal::VID != STEELSERIES_VID || HIDUniversal::PID != STEELSERIES_SRWS1_PID) // Make sure the right device is actually connected 89 | return 1; 90 | setLeds(0); 91 | return 0; 92 | }; 93 | }; 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Satisfy the IDE, which needs to see the include statment in the ino too. 5 | #ifdef dobogusinclude 6 | #include 7 | #endif 8 | #include 9 | 10 | class KbdRptParser : public KeyboardReportParser 11 | { 12 | void PrintKey(uint8_t mod, uint8_t key); 13 | 14 | protected: 15 | void OnControlKeysChanged(uint8_t before, uint8_t after); 16 | 17 | void OnKeyDown (uint8_t mod, uint8_t key); 18 | void OnKeyUp (uint8_t mod, uint8_t key); 19 | void OnKeyPressed(uint8_t key); 20 | }; 21 | 22 | void KbdRptParser::PrintKey(uint8_t m, uint8_t key) 23 | { 24 | MODIFIERKEYS mod; 25 | *((uint8_t*)&mod) = m; 26 | Serial.print((mod.bmLeftCtrl == 1) ? "C" : " "); 27 | Serial.print((mod.bmLeftShift == 1) ? "S" : " "); 28 | Serial.print((mod.bmLeftAlt == 1) ? "A" : " "); 29 | Serial.print((mod.bmLeftGUI == 1) ? "G" : " "); 30 | 31 | Serial.print(" >"); 32 | PrintHex(key, 0x80); 33 | Serial.print("< "); 34 | 35 | Serial.print((mod.bmRightCtrl == 1) ? "C" : " "); 36 | Serial.print((mod.bmRightShift == 1) ? "S" : " "); 37 | Serial.print((mod.bmRightAlt == 1) ? "A" : " "); 38 | Serial.println((mod.bmRightGUI == 1) ? "G" : " "); 39 | }; 40 | 41 | void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) 42 | { 43 | Serial.print("DN "); 44 | PrintKey(mod, key); 45 | uint8_t c = OemToAscii(mod, key); 46 | 47 | if (c) 48 | OnKeyPressed(c); 49 | } 50 | 51 | void KbdRptParser::OnControlKeysChanged(uint8_t before, uint8_t after) { 52 | 53 | MODIFIERKEYS beforeMod; 54 | *((uint8_t*)&beforeMod) = before; 55 | 56 | MODIFIERKEYS afterMod; 57 | *((uint8_t*)&afterMod) = after; 58 | 59 | if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) { 60 | Serial.println("LeftCtrl changed"); 61 | } 62 | if (beforeMod.bmLeftShift != afterMod.bmLeftShift) { 63 | Serial.println("LeftShift changed"); 64 | } 65 | if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) { 66 | Serial.println("LeftAlt changed"); 67 | } 68 | if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) { 69 | Serial.println("LeftGUI changed"); 70 | } 71 | 72 | if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) { 73 | Serial.println("RightCtrl changed"); 74 | } 75 | if (beforeMod.bmRightShift != afterMod.bmRightShift) { 76 | Serial.println("RightShift changed"); 77 | } 78 | if (beforeMod.bmRightAlt != afterMod.bmRightAlt) { 79 | Serial.println("RightAlt changed"); 80 | } 81 | if (beforeMod.bmRightGUI != afterMod.bmRightGUI) { 82 | Serial.println("RightGUI changed"); 83 | } 84 | 85 | } 86 | 87 | void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key) 88 | { 89 | Serial.print("UP "); 90 | PrintKey(mod, key); 91 | } 92 | 93 | void KbdRptParser::OnKeyPressed(uint8_t key) 94 | { 95 | Serial.print("ASCII: "); 96 | Serial.println((char)key); 97 | }; 98 | 99 | USB Usb; 100 | //USBHub Hub(&Usb); 101 | HIDBoot HidKeyboard(&Usb); 102 | 103 | KbdRptParser Prs; 104 | 105 | void setup() 106 | { 107 | Serial.begin( 115200 ); 108 | #if !defined(__MIPSEL__) 109 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 110 | #endif 111 | Serial.println("Start"); 112 | 113 | if (Usb.Init() == -1) 114 | Serial.println("OSC did not start."); 115 | 116 | delay( 200 ); 117 | 118 | HidKeyboard.SetReportParser(0, &Prs); 119 | } 120 | 121 | void loop() 122 | { 123 | Usb.Task(); 124 | } 125 | 126 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/USBHIDBootMouse/USBHIDBootMouse.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Satisfy the IDE, which needs to see the include statment in the ino too. 5 | #ifdef dobogusinclude 6 | #include 7 | #endif 8 | #include 9 | 10 | class MouseRptParser : public MouseReportParser 11 | { 12 | protected: 13 | void OnMouseMove (MOUSEINFO *mi); 14 | void OnLeftButtonUp (MOUSEINFO *mi); 15 | void OnLeftButtonDown (MOUSEINFO *mi); 16 | void OnRightButtonUp (MOUSEINFO *mi); 17 | void OnRightButtonDown (MOUSEINFO *mi); 18 | void OnMiddleButtonUp (MOUSEINFO *mi); 19 | void OnMiddleButtonDown (MOUSEINFO *mi); 20 | }; 21 | void MouseRptParser::OnMouseMove(MOUSEINFO *mi) 22 | { 23 | Serial.print("dx="); 24 | Serial.print(mi->dX, DEC); 25 | Serial.print(" dy="); 26 | Serial.println(mi->dY, DEC); 27 | }; 28 | void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi) 29 | { 30 | Serial.println("L Butt Up"); 31 | }; 32 | void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi) 33 | { 34 | Serial.println("L Butt Dn"); 35 | }; 36 | void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi) 37 | { 38 | Serial.println("R Butt Up"); 39 | }; 40 | void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi) 41 | { 42 | Serial.println("R Butt Dn"); 43 | }; 44 | void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi) 45 | { 46 | Serial.println("M Butt Up"); 47 | }; 48 | void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi) 49 | { 50 | Serial.println("M Butt Dn"); 51 | }; 52 | 53 | USB Usb; 54 | USBHub Hub(&Usb); 55 | HIDBoot HidMouse(&Usb); 56 | 57 | MouseRptParser Prs; 58 | 59 | void setup() 60 | { 61 | Serial.begin( 115200 ); 62 | #if !defined(__MIPSEL__) 63 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 64 | #endif 65 | Serial.println("Start"); 66 | 67 | if (Usb.Init() == -1) 68 | Serial.println("OSC did not start."); 69 | 70 | delay( 200 ); 71 | 72 | HidMouse.SetReportParser(0, &Prs); 73 | } 74 | 75 | void loop() 76 | { 77 | Usb.Task(); 78 | } 79 | 80 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/USBHIDJoystick.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // Satisfy IDE, which only needs to see the include statment in the ino. 6 | #ifdef dobogusinclude 7 | #include 8 | #endif 9 | #include 10 | 11 | #include "hidjoystickrptparser.h" 12 | 13 | USB Usb; 14 | USBHub Hub(&Usb); 15 | HIDUniversal Hid(&Usb); 16 | JoystickEvents JoyEvents; 17 | JoystickReportParser Joy(&JoyEvents); 18 | 19 | void setup() { 20 | Serial.begin(115200); 21 | #if !defined(__MIPSEL__) 22 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 23 | #endif 24 | Serial.println("Start"); 25 | 26 | if (Usb.Init() == -1) 27 | Serial.println("OSC did not start."); 28 | 29 | delay(200); 30 | 31 | if (!Hid.SetReportParser(0, &Joy)) 32 | ErrorMessage (PSTR("SetReportParser"), 1); 33 | } 34 | 35 | void loop() { 36 | Usb.Task(); 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp: -------------------------------------------------------------------------------- 1 | #include "hidjoystickrptparser.h" 2 | 3 | JoystickReportParser::JoystickReportParser(JoystickEvents *evt) : 4 | joyEvents(evt), 5 | oldHat(0xDE), 6 | oldButtons(0) { 7 | for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++) 8 | oldPad[i] = 0xD; 9 | } 10 | 11 | void JoystickReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { 12 | bool match = true; 13 | 14 | // Checking if there are changes in report since the method was last called 15 | for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++) 16 | if (buf[i] != oldPad[i]) { 17 | match = false; 18 | break; 19 | } 20 | 21 | // Calling Game Pad event handler 22 | if (!match && joyEvents) { 23 | joyEvents->OnGamePadChanged((const GamePadEventData*)buf); 24 | 25 | for (uint8_t i = 0; i < RPT_GEMEPAD_LEN; i++) oldPad[i] = buf[i]; 26 | } 27 | 28 | uint8_t hat = (buf[5] & 0xF); 29 | 30 | // Calling Hat Switch event handler 31 | if (hat != oldHat && joyEvents) { 32 | joyEvents->OnHatSwitch(hat); 33 | oldHat = hat; 34 | } 35 | 36 | uint16_t buttons = (0x0000 | buf[6]); 37 | buttons <<= 4; 38 | buttons |= (buf[5] >> 4); 39 | uint16_t changes = (buttons ^ oldButtons); 40 | 41 | // Calling Button Event Handler for every button changed 42 | if (changes) { 43 | for (uint8_t i = 0; i < 0x0C; i++) { 44 | uint16_t mask = (0x0001 << i); 45 | 46 | if (((mask & changes) > 0) && joyEvents) { 47 | if ((buttons & mask) > 0) 48 | joyEvents->OnButtonDn(i + 1); 49 | else 50 | joyEvents->OnButtonUp(i + 1); 51 | } 52 | } 53 | oldButtons = buttons; 54 | } 55 | } 56 | 57 | void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt) { 58 | Serial.print("X1: "); 59 | PrintHex (evt->X, 0x80); 60 | Serial.print("\tY1: "); 61 | PrintHex (evt->Y, 0x80); 62 | Serial.print("\tX2: "); 63 | PrintHex (evt->Z1, 0x80); 64 | Serial.print("\tY2: "); 65 | PrintHex (evt->Z2, 0x80); 66 | Serial.print("\tRz: "); 67 | PrintHex (evt->Rz, 0x80); 68 | Serial.println(""); 69 | } 70 | 71 | void JoystickEvents::OnHatSwitch(uint8_t hat) { 72 | Serial.print("Hat Switch: "); 73 | PrintHex (hat, 0x80); 74 | Serial.println(""); 75 | } 76 | 77 | void JoystickEvents::OnButtonUp(uint8_t but_id) { 78 | Serial.print("Up: "); 79 | Serial.println(but_id, DEC); 80 | } 81 | 82 | void JoystickEvents::OnButtonDn(uint8_t but_id) { 83 | Serial.print("Dn: "); 84 | Serial.println(but_id, DEC); 85 | } 86 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/USBHIDJoystick/hidjoystickrptparser.h: -------------------------------------------------------------------------------- 1 | #if !defined(__HIDJOYSTICKRPTPARSER_H__) 2 | #define __HIDJOYSTICKRPTPARSER_H__ 3 | 4 | #include 5 | 6 | struct GamePadEventData { 7 | uint8_t X, Y, Z1, Z2, Rz; 8 | }; 9 | 10 | class JoystickEvents { 11 | public: 12 | virtual void OnGamePadChanged(const GamePadEventData *evt); 13 | virtual void OnHatSwitch(uint8_t hat); 14 | virtual void OnButtonUp(uint8_t but_id); 15 | virtual void OnButtonDn(uint8_t but_id); 16 | }; 17 | 18 | #define RPT_GEMEPAD_LEN 5 19 | 20 | class JoystickReportParser : public HIDReportParser { 21 | JoystickEvents *joyEvents; 22 | 23 | uint8_t oldPad[RPT_GEMEPAD_LEN]; 24 | uint8_t oldHat; 25 | uint16_t oldButtons; 26 | 27 | public: 28 | JoystickReportParser(JoystickEvents *evt); 29 | 30 | virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); 31 | }; 32 | 33 | #endif // __HIDJOYSTICKRPTPARSER_H__ 34 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/USBHIDMultimediaKbd/USBHIDMultimediaKbd.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Satisfy the IDE, which needs to see the include statment in the ino too. 5 | #ifdef dobogusinclude 6 | #include 7 | #endif 8 | #include 9 | 10 | // Override HIDComposite to be able to select which interface we want to hook into 11 | class HIDSelector : public HIDComposite 12 | { 13 | public: 14 | HIDSelector(USB *p) : HIDComposite(p) {}; 15 | 16 | protected: 17 | void ParseHIDData(USBHID *hid, uint8_t ep, bool is_rpt_id, uint8_t len, uint8_t *buf); // Called by the HIDComposite library 18 | bool SelectInterface(uint8_t iface, uint8_t proto); 19 | }; 20 | 21 | // Return true for the interface we want to hook into 22 | bool HIDSelector::SelectInterface(uint8_t iface, uint8_t proto) 23 | { 24 | if (proto != 0) 25 | return true; 26 | 27 | return false; 28 | } 29 | 30 | // Will be called for all HID data received from the USB interface 31 | void HIDSelector::ParseHIDData(USBHID *hid, uint8_t ep, bool is_rpt_id, uint8_t len, uint8_t *buf) { 32 | #if 1 33 | if (len && buf) { 34 | Notify(PSTR("\r\n"), 0x80); 35 | for (uint8_t i = 0; i < len; i++) { 36 | D_PrintHex (buf[i], 0x80); 37 | Notify(PSTR(" "), 0x80); 38 | } 39 | } 40 | #endif 41 | } 42 | 43 | USB Usb; 44 | //USBHub Hub(&Usb); 45 | HIDSelector hidSelector(&Usb); 46 | 47 | void setup() 48 | { 49 | Serial.begin( 115200 ); 50 | #if !defined(__MIPSEL__) 51 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 52 | #endif 53 | Serial.println("Start"); 54 | 55 | if (Usb.Init() == -1) 56 | Serial.println("OSC did not start."); 57 | 58 | // Set this to higher values to enable more debug information 59 | // minimum 0x00, maximum 0xff, default 0x80 60 | UsbDEBUGlvl = 0xff; 61 | 62 | delay( 200 ); 63 | } 64 | 65 | void loop() 66 | { 67 | Usb.Task(); 68 | } 69 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/USBHID_desc/USBHID_desc.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "pgmstrings.h" 6 | 7 | // Satisfy the IDE, which needs to see the include statment in the ino too. 8 | #ifdef dobogusinclude 9 | #include 10 | #endif 11 | #include 12 | 13 | class HIDUniversal2 : public HIDUniversal 14 | { 15 | public: 16 | HIDUniversal2(USB *usb) : HIDUniversal(usb) {}; 17 | 18 | protected: 19 | uint8_t OnInitSuccessful(); 20 | }; 21 | 22 | uint8_t HIDUniversal2::OnInitSuccessful() 23 | { 24 | uint8_t rcode; 25 | 26 | HexDumper Hex; 27 | ReportDescParser Rpt; 28 | 29 | if ((rcode = GetReportDescr(0, &Hex))) 30 | goto FailGetReportDescr1; 31 | 32 | if ((rcode = GetReportDescr(0, &Rpt))) 33 | goto FailGetReportDescr2; 34 | 35 | return 0; 36 | 37 | FailGetReportDescr1: 38 | USBTRACE("GetReportDescr1:"); 39 | goto Fail; 40 | 41 | FailGetReportDescr2: 42 | USBTRACE("GetReportDescr2:"); 43 | goto Fail; 44 | 45 | Fail: 46 | Serial.println(rcode, HEX); 47 | Release(); 48 | return rcode; 49 | } 50 | 51 | USB Usb; 52 | //USBHub Hub(&Usb); 53 | HIDUniversal2 Hid(&Usb); 54 | UniversalReportParser Uni; 55 | 56 | void setup() 57 | { 58 | Serial.begin( 115200 ); 59 | #if !defined(__MIPSEL__) 60 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 61 | #endif 62 | Serial.println("Start"); 63 | 64 | if (Usb.Init() == -1) 65 | Serial.println("OSC did not start."); 66 | 67 | delay( 200 ); 68 | 69 | if (!Hid.SetReportParser(0, &Uni)) 70 | ErrorMessage(PSTR("SetReportParser"), 1 ); 71 | } 72 | 73 | void loop() 74 | { 75 | Usb.Task(); 76 | } 77 | 78 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/USBHID_desc/pgmstrings.h: -------------------------------------------------------------------------------- 1 | #if !defined(__PGMSTRINGS_H__) 2 | #define __PGMSTRINGS_H__ 3 | 4 | #define LOBYTE(x) ((char*)(&(x)))[0] 5 | #define HIBYTE(x) ((char*)(&(x)))[1] 6 | #define BUFSIZE 256 //buffer size 7 | 8 | 9 | /* Print strings in Program Memory */ 10 | const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t"; 11 | const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: "; 12 | const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t"; 13 | const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t"; 14 | const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t"; 15 | const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t"; 16 | const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t"; 17 | const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t"; 18 | const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t"; 19 | const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t"; 20 | const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t"; 21 | const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t"; 22 | const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t"; 23 | const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t"; 24 | const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t"; 25 | const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t"; 26 | const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes"; 27 | const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:"; 28 | const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t"; 29 | const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t"; 30 | const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t"; 31 | const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t"; 32 | const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; 33 | const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t"; 34 | const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:"; 35 | const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t"; 36 | const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t"; 37 | const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t"; 38 | const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t"; 39 | const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t"; 40 | const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t"; 41 | const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t"; 42 | const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:"; 43 | const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t"; 44 | const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; 45 | const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t"; 46 | const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t"; 47 | const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:"; 48 | const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t"; 49 | const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t"; 50 | const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t"; 51 | 52 | #endif // __PGMSTRINGS_H__ -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp.ino: -------------------------------------------------------------------------------- 1 | /* Simplified Logitech Extreme 3D Pro Joystick Report Parser */ 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "le3dp_rptparser.h" 8 | 9 | // Satisfy the IDE, which needs to see the include statment in the ino too. 10 | #ifdef dobogusinclude 11 | #include 12 | #endif 13 | #include 14 | 15 | USB Usb; 16 | USBHub Hub(&Usb); 17 | HIDUniversal Hid(&Usb); 18 | JoystickEvents JoyEvents; 19 | JoystickReportParser Joy(&JoyEvents); 20 | 21 | void setup() 22 | { 23 | Serial.begin( 115200 ); 24 | #if !defined(__MIPSEL__) 25 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 26 | #endif 27 | Serial.println("Start"); 28 | 29 | if (Usb.Init() == -1) 30 | Serial.println("OSC did not start."); 31 | 32 | delay( 200 ); 33 | 34 | if (!Hid.SetReportParser(0, &Joy)) 35 | ErrorMessage(PSTR("SetReportParser"), 1 ); 36 | } 37 | 38 | void loop() 39 | { 40 | Usb.Task(); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.cpp: -------------------------------------------------------------------------------- 1 | #include "le3dp_rptparser.h" 2 | 3 | JoystickReportParser::JoystickReportParser(JoystickEvents *evt) : 4 | joyEvents(evt) 5 | {} 6 | 7 | void JoystickReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) 8 | { 9 | bool match = true; 10 | 11 | // Checking if there are changes in report since the method was last called 12 | for (uint8_t i=0; iOnGamePadChanged((const GamePadEventData*)buf); 21 | 22 | for (uint8_t i=0; i(evt->x, 0x80); 30 | Serial.print(" Y: "); 31 | PrintHex(evt->y, 0x80); 32 | Serial.print(" Hat Switch: "); 33 | PrintHex(evt->hat, 0x80); 34 | Serial.print(" Twist: "); 35 | PrintHex(evt->twist, 0x80); 36 | Serial.print(" Slider: "); 37 | PrintHex(evt->slider, 0x80); 38 | Serial.print(" Buttons A: "); 39 | PrintHex(evt->buttons_a, 0x80); 40 | Serial.print(" Buttons B: "); 41 | PrintHex(evt->buttons_b, 0x80); 42 | Serial.println(""); 43 | } 44 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/le3dp/le3dp_rptparser.h: -------------------------------------------------------------------------------- 1 | #if !defined(__HIDJOYSTICKRPTPARSER_H__) 2 | #define __HIDJOYSTICKRPTPARSER_H__ 3 | 4 | #include 5 | 6 | struct GamePadEventData 7 | { 8 | union { //axes and hut switch 9 | uint32_t axes; 10 | struct { 11 | uint32_t x : 10; 12 | uint32_t y : 10; 13 | uint32_t hat : 4; 14 | uint32_t twist : 8; 15 | }; 16 | }; 17 | uint8_t buttons_a; 18 | uint8_t slider; 19 | uint8_t buttons_b; 20 | }; 21 | 22 | class JoystickEvents 23 | { 24 | public: 25 | virtual void OnGamePadChanged(const GamePadEventData *evt); 26 | }; 27 | 28 | #define RPT_GAMEPAD_LEN sizeof(GamePadEventData)/sizeof(uint8_t) 29 | 30 | class JoystickReportParser : public HIDReportParser 31 | { 32 | JoystickEvents *joyEvents; 33 | 34 | uint8_t oldPad[RPT_GAMEPAD_LEN]; 35 | 36 | public: 37 | JoystickReportParser(JoystickEvents *evt); 38 | 39 | virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); 40 | }; 41 | 42 | #endif // __HIDJOYSTICKRPTPARSER_H__ 43 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/scale/scale.ino: -------------------------------------------------------------------------------- 1 | /* Digital Scale Output. Written for Stamps.com Model 510 */ 2 | /* 5lb Digital Scale; any HID scale with Usage page 0x8d should work */ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "scale_rptparser.h" 9 | 10 | // Satisfy the IDE, which needs to see the include statment in the ino too. 11 | #ifdef dobogusinclude 12 | #include 13 | #endif 14 | #include 15 | 16 | USB Usb; 17 | USBHub Hub(&Usb); 18 | HIDUniversal Hid(&Usb); 19 | Max_LCD LCD(&Usb); 20 | ScaleEvents ScaleEvents(&LCD); 21 | ScaleReportParser Scale(&ScaleEvents); 22 | 23 | void setup() 24 | { 25 | Serial.begin( 115200 ); 26 | #if !defined(__MIPSEL__) 27 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 28 | #endif 29 | Serial.println("Start"); 30 | 31 | if (Usb.Init() == -1) 32 | Serial.println("OSC did not start."); 33 | 34 | // set up the LCD's number of rows and columns: 35 | LCD.begin(16, 2); 36 | LCD.clear(); 37 | LCD.home(); 38 | LCD.setCursor(0,0); 39 | LCD.write('R'); 40 | 41 | delay( 200 ); 42 | 43 | if (!Hid.SetReportParser(0, &Scale)) 44 | ErrorMessage(PSTR("SetReportParser"), 1 ); 45 | } 46 | 47 | void loop() 48 | { 49 | Usb.Task(); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.cpp: -------------------------------------------------------------------------------- 1 | /* Parser for standard HID scale (usage page 0x8d) data input report (ID 3) */ 2 | #ifdef ARDUINO_SAM_DUE 3 | #include 4 | #endif 5 | #include "scale_rptparser.h" 6 | 7 | const char* UNITS[13] = { 8 | "units", // unknown unit 9 | "mg", // milligram 10 | "g", // gram 11 | "kg", // kilogram 12 | "cd", // carat 13 | "taels", // lian 14 | "gr", // grain 15 | "dwt", // pennyweight 16 | "tonnes", // metric tons 17 | "tons", // avoir ton 18 | "ozt", // troy ounce 19 | "oz", // ounce 20 | "lbs" // pound 21 | }; 22 | 23 | ScaleReportParser::ScaleReportParser(ScaleEvents *evt) : 24 | scaleEvents(evt) 25 | {} 26 | 27 | void ScaleReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) 28 | { 29 | bool match = true; 30 | 31 | // Checking if there are changes in report since the method was last called 32 | for (uint8_t i=0; iOnScaleChanged((const ScaleEventData*)buf); 41 | 42 | for (uint8_t i=0; iwrite( *str++ ); 58 | 59 | } 60 | } 61 | 62 | void ScaleEvents::OnScaleChanged(const ScaleEventData *evt) 63 | { 64 | 65 | pLcd->clear(); 66 | pLcd->home(); 67 | pLcd->setCursor(0,0); 68 | 69 | if( evt->reportID != 3 ) { 70 | 71 | const char inv_report[]="Invalid report!"; 72 | 73 | Serial.println(inv_report); 74 | LcdPrint(inv_report); 75 | 76 | return; 77 | 78 | }//if( evt->reportID != 3... 79 | 80 | switch( evt->status ) { 81 | 82 | case REPORT_FAULT: 83 | Serial.println(F("Report fault")); 84 | break; 85 | 86 | case ZEROED: 87 | Serial.println(F("Scale zero set")); 88 | break; 89 | 90 | case WEIGHING: { 91 | 92 | const char progress[] = "Weighing..."; 93 | Serial.println(progress); 94 | LcdPrint(progress); 95 | break; 96 | } 97 | 98 | case WEIGHT_VALID: { 99 | 100 | char buf[10]; 101 | double weight = evt->weight * pow( 10, evt->exp ); 102 | 103 | 104 | 105 | Serial.print(F("Weight: ")); 106 | Serial.print( weight ); 107 | Serial.print(F(" ")); 108 | Serial.println( UNITS[ evt->unit ]); 109 | 110 | LcdPrint("Weight: "); 111 | dtostrf( weight, 4, 2, buf ); 112 | LcdPrint( buf ); 113 | LcdPrint( UNITS[ evt->unit ]); 114 | 115 | break; 116 | 117 | }//case WEIGHT_VALID... 118 | 119 | case WEIGHT_NEGATIVE: { 120 | 121 | const char negweight[] = "Negative weight"; 122 | Serial.println(negweight); 123 | LcdPrint(negweight); 124 | break; 125 | } 126 | 127 | case OVERWEIGHT: { 128 | 129 | const char overweight[] = "Max.weight reached"; 130 | Serial.println(overweight); 131 | LcdPrint( overweight ); 132 | break; 133 | } 134 | 135 | case CALIBRATE_ME: 136 | 137 | Serial.println(F("Scale calibration required")); 138 | break; 139 | 140 | case ZERO_ME: 141 | 142 | Serial.println(F("Scale zeroing required")); 143 | break; 144 | 145 | default: 146 | 147 | Serial.print(F("Undefined status code: ")); 148 | Serial.println( evt->status ); 149 | break; 150 | 151 | }//switch( evt->status... 152 | 153 | } 154 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/HID/scale/scale_rptparser.h: -------------------------------------------------------------------------------- 1 | #if !defined(__SCALERPTPARSER_H__) 2 | #define __SCALERPTPARSER_H__ 3 | 4 | #include 5 | #include 6 | 7 | /* Scale status constants */ 8 | #define REPORT_FAULT 0x01 9 | #define ZEROED 0x02 10 | #define WEIGHING 0x03 11 | #define WEIGHT_VALID 0x04 12 | #define WEIGHT_NEGATIVE 0x05 13 | #define OVERWEIGHT 0x06 14 | #define CALIBRATE_ME 0x07 15 | #define ZERO_ME 0x08 16 | 17 | /* input data report */ 18 | struct ScaleEventData 19 | { 20 | uint8_t reportID; //must be 3 21 | uint8_t status; 22 | uint8_t unit; 23 | int8_t exp; //scale factor for the weight 24 | uint16_t weight; // 25 | }; 26 | 27 | class ScaleEvents 28 | { 29 | 30 | Max_LCD* pLcd; 31 | 32 | void LcdPrint( const char* str ); 33 | 34 | public: 35 | 36 | ScaleEvents( Max_LCD* pLCD ); 37 | 38 | virtual void OnScaleChanged(const ScaleEventData *evt); 39 | }; 40 | 41 | #define RPT_SCALE_LEN sizeof(ScaleEventData)/sizeof(uint8_t) 42 | 43 | class ScaleReportParser : public HIDReportParser 44 | { 45 | ScaleEvents *scaleEvents; 46 | 47 | uint8_t oldScale[RPT_SCALE_LEN]; 48 | 49 | public: 50 | ScaleReportParser(ScaleEvents *evt); 51 | 52 | virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); 53 | }; 54 | 55 | #endif // __SCALERPTPARSER_H__ 56 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/PSBuzz/PSBuzz.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example sketch for the Playstation Buzz library - developed by Kristian Lauszus 3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or 4 | send me an e-mail: kristianl@tkjelectronics.com 5 | */ 6 | 7 | #include 8 | 9 | // Satisfy the IDE, which needs to see the include statment in the ino too. 10 | #ifdef dobogusinclude 11 | #include 12 | #endif 13 | #include 14 | 15 | USB Usb; 16 | PSBuzz Buzz(&Usb); 17 | 18 | void setup() { 19 | Serial.begin(115200); 20 | #if !defined(__MIPSEL__) 21 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 22 | #endif 23 | if (Usb.Init() == -1) { 24 | Serial.print(F("\r\nOSC did not start")); 25 | while (1); // Halt 26 | } 27 | Serial.println(F("\r\nPS Buzz Library Started")); 28 | } 29 | 30 | void loop() { 31 | Usb.Task(); 32 | 33 | if (Buzz.connected()) { 34 | for (uint8_t i = 0; i < 4; i++) { 35 | if (Buzz.getButtonClick(RED, i)) { 36 | Buzz.setLedToggle(i); // Toggle the LED 37 | Serial.println(F("RED")); 38 | } 39 | if (Buzz.getButtonClick(YELLOW, i)) 40 | Serial.println(F("YELLOW")); 41 | if (Buzz.getButtonClick(GREEN, i)) 42 | Serial.println(F("GREEN")); 43 | if (Buzz.getButtonClick(ORANGE, i)) 44 | Serial.println(F("ORANGE")); 45 | if (Buzz.getButtonClick(BLUE, i)) 46 | Serial.println(F("BLUE")); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/USBH_MIDI/USBH_MIDI_dump/USBH_MIDI_dump.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ******************************************************************************* 3 | * USB-MIDI dump utility 4 | * Copyright (C) 2013-2017 Yuuichi Akagawa 5 | * 6 | * for use with USB Host Shield 2.0 from Circuitsathome.com 7 | * https://github.com/felis/USB_Host_Shield_2.0 8 | * 9 | * This is sample program. Do not expect perfect behavior. 10 | ******************************************************************************* 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | // Satisfy the IDE, which needs to see the include statment in the ino too. 17 | #ifdef dobogusinclude 18 | #include 19 | #endif 20 | #include 21 | 22 | USB Usb; 23 | //USBHub Hub(&Usb); 24 | USBH_MIDI Midi(&Usb); 25 | 26 | void MIDI_poll(); 27 | 28 | uint16_t pid, vid; 29 | 30 | void setup() 31 | { 32 | vid = pid = 0; 33 | Serial.begin(115200); 34 | 35 | if (Usb.Init() == -1) { 36 | while (1); //halt 37 | }//if (Usb.Init() == -1... 38 | delay( 200 ); 39 | } 40 | 41 | void loop() 42 | { 43 | Usb.Task(); 44 | //uint32_t t1 = (uint32_t)micros(); 45 | if ( Midi ) { 46 | MIDI_poll(); 47 | } 48 | } 49 | 50 | // Poll USB MIDI Controler and send to serial MIDI 51 | void MIDI_poll() 52 | { 53 | char buf[20]; 54 | uint8_t bufMidi[64]; 55 | uint16_t rcvd; 56 | 57 | if (Midi.idVendor() != vid || Midi.idProduct() != pid) { 58 | vid = Midi.idVendor(); 59 | pid = Midi.idProduct(); 60 | sprintf(buf, "VID:%04X, PID:%04X", vid, pid); 61 | Serial.println(buf); 62 | } 63 | if (Midi.RecvData( &rcvd, bufMidi) == 0 ) { 64 | uint32_t time = (uint32_t)millis(); 65 | sprintf(buf, "%04X%04X: ", (uint16_t)(time >> 16), (uint16_t)(time & 0xFFFF)); // Split variable to prevent warnings on the ESP8266 platform 66 | Serial.print(buf); 67 | Serial.print(rcvd); 68 | Serial.print(':'); 69 | for (int i = 0; i < 64; i++) { 70 | sprintf(buf, " %02X", bufMidi[i]); 71 | Serial.print(buf); 72 | } 73 | Serial.println(""); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/USBH_MIDI/USB_MIDI_converter/USB_MIDI_converter.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ******************************************************************************* 3 | * USB-MIDI to Legacy Serial MIDI converter 4 | * Copyright (C) 2012-2017 Yuuichi Akagawa 5 | * 6 | * Idea from LPK25 USB-MIDI to Serial MIDI converter 7 | * by Collin Cunningham - makezine.com, narbotic.com 8 | * 9 | * This is sample program. Do not expect perfect behavior. 10 | ******************************************************************************* 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | // Satisfy the IDE, which needs to see the include statment in the ino too. 17 | #ifdef dobogusinclude 18 | #include 19 | #endif 20 | #include 21 | 22 | #ifdef USBCON 23 | #define _MIDI_SERIAL_PORT Serial1 24 | #else 25 | #define _MIDI_SERIAL_PORT Serial 26 | #endif 27 | ////////////////////////// 28 | // MIDI Pin assign 29 | // 2 : GND 30 | // 4 : +5V(Vcc) with 220ohm 31 | // 5 : TX 32 | ////////////////////////// 33 | 34 | USB Usb; 35 | USBH_MIDI Midi(&Usb); 36 | 37 | void MIDI_poll(); 38 | void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime); 39 | 40 | void setup() 41 | { 42 | _MIDI_SERIAL_PORT.begin(31250); 43 | 44 | if (Usb.Init() == -1) { 45 | while (1); //halt 46 | }//if (Usb.Init() == -1... 47 | delay( 200 ); 48 | } 49 | 50 | void loop() 51 | { 52 | Usb.Task(); 53 | uint32_t t1 = (uint32_t)micros(); 54 | if ( Midi ) { 55 | MIDI_poll(); 56 | } 57 | //delay(1ms) 58 | doDelay(t1, (uint32_t)micros(), 1000); 59 | } 60 | 61 | // Poll USB MIDI Controler and send to serial MIDI 62 | void MIDI_poll() 63 | { 64 | uint8_t outBuf[ 3 ]; 65 | uint8_t size; 66 | 67 | do { 68 | if ( (size = Midi.RecvData(outBuf)) > 0 ) { 69 | //MIDI Output 70 | _MIDI_SERIAL_PORT.write(outBuf, size); 71 | } 72 | } while (size > 0); 73 | } 74 | 75 | // Delay time (max 16383 us) 76 | void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime) 77 | { 78 | uint32_t t3; 79 | 80 | t3 = t2 - t1; 81 | if ( t3 < delayTime ) { 82 | delayMicroseconds(delayTime - t3); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/USBH_MIDI/USB_MIDI_converter_multi/USB_MIDI_converter_multi.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ******************************************************************************* 3 | * USB-MIDI to Legacy Serial MIDI converter 4 | * Copyright (C) 2012-2017 Yuuichi Akagawa 5 | * 6 | * Idea from LPK25 USB-MIDI to Serial MIDI converter 7 | * by Collin Cunningham - makezine.com, narbotic.com 8 | * 9 | * This is sample program. Do not expect perfect behavior. 10 | ******************************************************************************* 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | // Satisfy the IDE, which needs to see the include statment in the ino too. 17 | #ifdef dobogusinclude 18 | #include 19 | #endif 20 | #include 21 | 22 | #ifdef USBCON 23 | #define _MIDI_SERIAL_PORT Serial1 24 | #else 25 | #define _MIDI_SERIAL_PORT Serial 26 | #endif 27 | ////////////////////////// 28 | // MIDI Pin assign 29 | // 2 : GND 30 | // 4 : +5V(Vcc) with 220ohm 31 | // 5 : TX 32 | ////////////////////////// 33 | 34 | USB Usb; 35 | USBHub Hub1(&Usb); 36 | USBH_MIDI Midi1(&Usb); 37 | USBH_MIDI Midi2(&Usb); 38 | 39 | void MIDI_poll(); 40 | void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime); 41 | 42 | void setup() 43 | { 44 | _MIDI_SERIAL_PORT.begin(31250); 45 | 46 | if (Usb.Init() == -1) { 47 | while (1); //halt 48 | }//if (Usb.Init() == -1... 49 | delay( 200 ); 50 | } 51 | 52 | void loop() 53 | { 54 | Usb.Task(); 55 | uint32_t t1 = (uint32_t)micros(); 56 | if ( Midi1 ) { 57 | MIDI_poll(Midi1); 58 | } 59 | if ( Midi2 ) { 60 | MIDI_poll(Midi2); 61 | } 62 | //delay(1ms) 63 | doDelay(t1, (uint32_t)micros(), 1000); 64 | } 65 | 66 | // Poll USB MIDI Controler and send to serial MIDI 67 | void MIDI_poll(USBH_MIDI &Midi) 68 | { 69 | uint8_t outBuf[ 3 ]; 70 | uint8_t size; 71 | 72 | do { 73 | if ( (size = Midi.RecvData(outBuf)) > 0 ) { 74 | //MIDI Output 75 | _MIDI_SERIAL_PORT.write(outBuf, size); 76 | } 77 | } while (size > 0); 78 | } 79 | 80 | // Delay time (max 16383 us) 81 | void doDelay(uint32_t t1, uint32_t t2, uint32_t delayTime) 82 | { 83 | uint32_t t3; 84 | 85 | t3 = t2 - t1; 86 | if ( t3 < delayTime ) { 87 | delayMicroseconds(delayTime - t3); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/USBH_MIDI/bidirectional_converter/bidirectional_converter.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ******************************************************************************* 3 | * Legacy Serial MIDI and USB Host bidirectional converter 4 | * Copyright (C) 2013-2017 Yuuichi Akagawa 5 | * 6 | * for use with Arduino MIDI library 7 | * https://github.com/FortySevenEffects/arduino_midi_library/ 8 | * 9 | * Note: 10 | * - If you want use with Leonardo, you must choose Arduino MIDI library v4.0 or higher. 11 | * - This is sample program. Do not expect perfect behavior. 12 | ******************************************************************************* 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | // Satisfy the IDE, which needs to see the include statment in the ino too. 20 | #ifdef dobogusinclude 21 | #include 22 | #endif 23 | #include 24 | 25 | //Arduino MIDI library v4.2 compatibility 26 | #ifdef MIDI_CREATE_DEFAULT_INSTANCE 27 | MIDI_CREATE_DEFAULT_INSTANCE(); 28 | #endif 29 | #ifdef USBCON 30 | #define _MIDI_SERIAL_PORT Serial1 31 | #else 32 | #define _MIDI_SERIAL_PORT Serial 33 | #endif 34 | 35 | ////////////////////////// 36 | // MIDI Pin assign 37 | // 2 : GND 38 | // 4 : +5V(Vcc) with 220ohm 39 | // 5 : TX 40 | ////////////////////////// 41 | 42 | USB Usb; 43 | USBH_MIDI Midi(&Usb); 44 | 45 | void MIDI_poll(); 46 | 47 | //If you want handle System Exclusive message, enable this #define otherwise comment out it. 48 | #define USBH_MIDI_SYSEX_ENABLE 49 | 50 | #ifdef USBH_MIDI_SYSEX_ENABLE 51 | //SysEx: 52 | void handle_sysex( byte* sysexmsg, unsigned sizeofsysex) { 53 | Midi.SendSysEx(sysexmsg, sizeofsysex); 54 | } 55 | #endif 56 | 57 | void setup() 58 | { 59 | MIDI.begin(MIDI_CHANNEL_OMNI); 60 | MIDI.turnThruOff(); 61 | #ifdef USBH_MIDI_SYSEX_ENABLE 62 | MIDI.setHandleSystemExclusive(handle_sysex); 63 | #endif 64 | if (Usb.Init() == -1) { 65 | while (1); //halt 66 | }//if (Usb.Init() == -1... 67 | delay( 200 ); 68 | } 69 | 70 | void loop() 71 | { 72 | uint8_t msg[4]; 73 | 74 | Usb.Task(); 75 | if ( Midi ) { 76 | MIDI_poll(); 77 | if (MIDI.read()) { 78 | msg[0] = MIDI.getType(); 79 | switch (msg[0]) { 80 | case midi::ActiveSensing : 81 | break; 82 | case midi::SystemExclusive : 83 | //SysEx is handled by event. 84 | break; 85 | default : 86 | msg[1] = MIDI.getData1(); 87 | msg[2] = MIDI.getData2(); 88 | Midi.SendData(msg, 0); 89 | break; 90 | } 91 | } 92 | } 93 | } 94 | 95 | // Poll USB MIDI Controler and send to serial MIDI 96 | void MIDI_poll() 97 | { 98 | uint8_t size; 99 | #ifdef USBH_MIDI_SYSEX_ENABLE 100 | uint8_t recvBuf[MIDI_EVENT_PACKET_SIZE]; 101 | uint8_t rcode = 0; //return code 102 | uint16_t rcvd; 103 | uint8_t readPtr = 0; 104 | 105 | rcode = Midi.RecvData( &rcvd, recvBuf); 106 | 107 | //data check 108 | if (rcode != 0) return; 109 | if ( recvBuf[0] == 0 && recvBuf[1] == 0 && recvBuf[2] == 0 && recvBuf[3] == 0 ) { 110 | return ; 111 | } 112 | 113 | uint8_t *p = recvBuf; 114 | while (readPtr < MIDI_EVENT_PACKET_SIZE) { 115 | if (*p == 0 && *(p + 1) == 0) break; //data end 116 | 117 | uint8_t outbuf[3]; 118 | uint8_t rc = Midi.extractSysExData(p, outbuf); 119 | if ( rc == 0 ) { 120 | p++; 121 | size = Midi.lookupMsgSize(*p); 122 | _MIDI_SERIAL_PORT.write(p, size); 123 | p += 3; 124 | } else { 125 | _MIDI_SERIAL_PORT.write(outbuf, rc); 126 | p += 4; 127 | } 128 | readPtr += 4; 129 | } 130 | #else 131 | uint8_t outBuf[3]; 132 | do { 133 | if ( (size = Midi.RecvData(outBuf)) > 0 ) { 134 | //MIDI Output 135 | _MIDI_SERIAL_PORT.write(outBuf, size); 136 | } 137 | } while (size > 0); 138 | #endif 139 | } 140 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/USBH_MIDI/eVY1_sample/eVY1_sample.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ******************************************************************************* 3 | * eVY1 Shield sample - Say 'Konnichiwa' 4 | * Copyright (C) 2014-2016 Yuuichi Akagawa 5 | * 6 | * This is sample program. Do not expect perfect behavior. 7 | ******************************************************************************* 8 | */ 9 | #include 10 | #include 11 | 12 | // Satisfy the IDE, which needs to see the include statment in the ino too. 13 | #ifdef dobogusinclude 14 | #include 15 | #endif 16 | #include 17 | 18 | USB Usb; 19 | //USBHub Hub(&Usb); 20 | USBH_MIDI Midi(&Usb); 21 | 22 | void MIDI_poll(); 23 | void noteOn(uint8_t note); 24 | void noteOff(uint8_t note); 25 | 26 | uint16_t pid, vid; 27 | uint8_t exdata[] = { 28 | 0xf0, 0x43, 0x79, 0x09, 0x00, 0x50, 0x10, 29 | 'k', ' ', 'o', ',', //Ko 30 | 'N', '\\', ',', //N 31 | 'J', ' ', 'i', ',', //Ni 32 | 't', 'S', ' ', 'i', ',', //Chi 33 | 'w', ' ', 'a', //Wa 34 | 0x00, 0xf7 35 | }; 36 | 37 | void setup() 38 | { 39 | vid = pid = 0; 40 | Serial.begin(115200); 41 | 42 | if (Usb.Init() == -1) { 43 | while (1); //halt 44 | }//if (Usb.Init() == -1... 45 | delay( 200 ); 46 | } 47 | 48 | void loop() 49 | { 50 | Usb.Task(); 51 | if( Midi ) { 52 | MIDI_poll(); 53 | noteOn(0x3f); 54 | delay(400); 55 | noteOff(0x3f); 56 | delay(100); 57 | } 58 | } 59 | 60 | // Poll USB MIDI Controler 61 | void MIDI_poll() 62 | { 63 | uint8_t inBuf[ 3 ]; 64 | 65 | //first call? 66 | if (Midi.idVendor() != vid || Midi.idProduct() != pid) { 67 | vid = Midi.idVendor(); pid = Midi.idProduct(); 68 | Midi.SendSysEx(exdata, sizeof(exdata)); 69 | delay(500); 70 | } 71 | Midi.RecvData(inBuf); 72 | } 73 | 74 | //note On 75 | void noteOn(uint8_t note) 76 | { 77 | uint8_t buf[3]; 78 | buf[0] = 0x90; 79 | buf[1] = note; 80 | buf[2] = 0x7f; 81 | Midi.SendData(buf); 82 | } 83 | 84 | //note Off 85 | void noteOff(uint8_t note) 86 | { 87 | uint8_t buf[3]; 88 | buf[0] = 0x80; 89 | buf[1] = note; 90 | buf[2] = 0x00; 91 | Midi.SendData(buf); 92 | } 93 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/USB_desc/pgmstrings.h: -------------------------------------------------------------------------------- 1 | #if !defined(__PGMSTRINGS_H__) 2 | #define __PGMSTRINGS_H__ 3 | 4 | #define LOBYTE(x) ((char*)(&(x)))[0] 5 | #define HIBYTE(x) ((char*)(&(x)))[1] 6 | #define BUFSIZE 256 //buffer size 7 | 8 | 9 | /* Print strings in Program Memory */ 10 | const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t"; 11 | const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: "; 12 | const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t"; 13 | const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t"; 14 | const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t"; 15 | const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t"; 16 | const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t"; 17 | const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t"; 18 | const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t"; 19 | const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t"; 20 | const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t"; 21 | const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t"; 22 | const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t"; 23 | const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t"; 24 | const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t"; 25 | const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t"; 26 | const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes"; 27 | const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:"; 28 | const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t"; 29 | const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t"; 30 | const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t"; 31 | const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t"; 32 | const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; 33 | const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t"; 34 | const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:"; 35 | const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t"; 36 | const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t"; 37 | const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t"; 38 | const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t"; 39 | const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t"; 40 | const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t"; 41 | const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t"; 42 | const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:"; 43 | const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t"; 44 | const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; 45 | const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t"; 46 | const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t"; 47 | const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:"; 48 | const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t"; 49 | const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t"; 50 | const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t"; 51 | 52 | #endif // __PGMSTRINGS_H__ -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/Xbox/XBOXOLD/XBOXOLD.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example sketch for the original Xbox library - developed by Kristian Lauszus 3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or 4 | send me an e-mail: kristianl@tkjelectronics.com 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | // Satisfy the IDE, which needs to see the include statment in the ino too. 11 | #ifdef dobogusinclude 12 | #include 13 | #endif 14 | #include 15 | 16 | USB Usb; 17 | USBHub Hub1(&Usb); // The controller has a built in hub, so this instance is needed 18 | XBOXOLD Xbox(&Usb); 19 | 20 | void setup() { 21 | Serial.begin(115200); 22 | #if !defined(__MIPSEL__) 23 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 24 | #endif 25 | if (Usb.Init() == -1) { 26 | Serial.print(F("\r\nOSC did not start")); 27 | while (1); // halt 28 | } 29 | Serial.print(F("\r\nXBOX Library Started")); 30 | } 31 | void loop() { 32 | Usb.Task(); 33 | if (Xbox.XboxConnected) { 34 | if (Xbox.getButtonPress(BLACK) || Xbox.getButtonPress(WHITE)) { 35 | Serial.print("BLACK: "); 36 | Serial.print(Xbox.getButtonPress(BLACK)); 37 | Serial.print("\tWHITE: "); 38 | Serial.println(Xbox.getButtonPress(WHITE)); 39 | Xbox.setRumbleOn(Xbox.getButtonPress(BLACK), Xbox.getButtonPress(WHITE)); 40 | } else 41 | Xbox.setRumbleOn(0, 0); 42 | 43 | if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500 || Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500 || Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500 || Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) { 44 | if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500) { 45 | Serial.print(F("LeftHatX: ")); 46 | Serial.print(Xbox.getAnalogHat(LeftHatX)); 47 | Serial.print("\t"); 48 | } 49 | if (Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500) { 50 | Serial.print(F("LeftHatY: ")); 51 | Serial.print(Xbox.getAnalogHat(LeftHatY)); 52 | Serial.print("\t"); 53 | } 54 | if (Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500) { 55 | Serial.print(F("RightHatX: ")); 56 | Serial.print(Xbox.getAnalogHat(RightHatX)); 57 | Serial.print("\t"); 58 | } 59 | if (Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) { 60 | Serial.print(F("RightHatY: ")); 61 | Serial.print(Xbox.getAnalogHat(RightHatY)); 62 | } 63 | Serial.println(); 64 | } 65 | 66 | if (Xbox.getButtonClick(UP)) 67 | Serial.println(F("Up")); 68 | if (Xbox.getButtonClick(DOWN)) 69 | Serial.println(F("Down")); 70 | if (Xbox.getButtonClick(LEFT)) 71 | Serial.println(F("Left")); 72 | if (Xbox.getButtonClick(RIGHT)) 73 | Serial.println(F("Right")); 74 | 75 | if (Xbox.getButtonClick(START)) 76 | Serial.println(F("Start")); 77 | if (Xbox.getButtonClick(BACK)) 78 | Serial.println(F("Back")); 79 | if (Xbox.getButtonClick(L3)) 80 | Serial.println(F("L3")); 81 | if (Xbox.getButtonClick(R3)) 82 | Serial.println(F("R3")); 83 | 84 | if (Xbox.getButtonPress(A)) { 85 | Serial.print(F("A: ")); 86 | Serial.println(Xbox.getButtonPress(A)); 87 | } 88 | if (Xbox.getButtonPress(B)) { 89 | Serial.print(F("B: ")); 90 | Serial.println(Xbox.getButtonPress(B)); 91 | } 92 | if (Xbox.getButtonPress(X)) { 93 | Serial.print(F("X: ")); 94 | Serial.println(Xbox.getButtonPress(X)); 95 | } 96 | if (Xbox.getButtonPress(Y)) { 97 | Serial.print(F("Y: ")); 98 | Serial.println(Xbox.getButtonPress(Y)); 99 | } 100 | if (Xbox.getButtonPress(L1)) { 101 | Serial.print(F("L1: ")); 102 | Serial.println(Xbox.getButtonPress(L1)); 103 | } 104 | if (Xbox.getButtonPress(R1)) { 105 | Serial.print(F("R1: ")); 106 | Serial.println(Xbox.getButtonPress(R1)); 107 | } 108 | } 109 | delay(1); 110 | } 111 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/Xbox/XBOXUSB/XBOXUSB.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example sketch for the Xbox 360 USB library - developed by Kristian Lauszus 3 | For more information visit my blog: http://blog.tkjelectronics.dk/ or 4 | send me an e-mail: kristianl@tkjelectronics.com 5 | */ 6 | 7 | #include 8 | 9 | // Satisfy the IDE, which needs to see the include statment in the ino too. 10 | #ifdef dobogusinclude 11 | #include 12 | #endif 13 | #include 14 | 15 | USB Usb; 16 | XBOXUSB Xbox(&Usb); 17 | 18 | void setup() { 19 | Serial.begin(115200); 20 | #if !defined(__MIPSEL__) 21 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 22 | #endif 23 | if (Usb.Init() == -1) { 24 | Serial.print(F("\r\nOSC did not start")); 25 | while (1); //halt 26 | } 27 | Serial.print(F("\r\nXBOX USB Library Started")); 28 | } 29 | void loop() { 30 | Usb.Task(); 31 | if (Xbox.Xbox360Connected) { 32 | if (Xbox.getButtonPress(L2) || Xbox.getButtonPress(R2)) { 33 | Serial.print("L2: "); 34 | Serial.print(Xbox.getButtonPress(L2)); 35 | Serial.print("\tR2: "); 36 | Serial.println(Xbox.getButtonPress(R2)); 37 | Xbox.setRumbleOn(Xbox.getButtonPress(L2), Xbox.getButtonPress(R2)); 38 | } else 39 | Xbox.setRumbleOn(0, 0); 40 | 41 | if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500 || Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500 || Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500 || Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) { 42 | if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500) { 43 | Serial.print(F("LeftHatX: ")); 44 | Serial.print(Xbox.getAnalogHat(LeftHatX)); 45 | Serial.print("\t"); 46 | } 47 | if (Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500) { 48 | Serial.print(F("LeftHatY: ")); 49 | Serial.print(Xbox.getAnalogHat(LeftHatY)); 50 | Serial.print("\t"); 51 | } 52 | if (Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500) { 53 | Serial.print(F("RightHatX: ")); 54 | Serial.print(Xbox.getAnalogHat(RightHatX)); 55 | Serial.print("\t"); 56 | } 57 | if (Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) { 58 | Serial.print(F("RightHatY: ")); 59 | Serial.print(Xbox.getAnalogHat(RightHatY)); 60 | } 61 | Serial.println(); 62 | } 63 | 64 | if (Xbox.getButtonClick(UP)) { 65 | Xbox.setLedOn(LED1); 66 | Serial.println(F("Up")); 67 | } 68 | if (Xbox.getButtonClick(DOWN)) { 69 | Xbox.setLedOn(LED4); 70 | Serial.println(F("Down")); 71 | } 72 | if (Xbox.getButtonClick(LEFT)) { 73 | Xbox.setLedOn(LED3); 74 | Serial.println(F("Left")); 75 | } 76 | if (Xbox.getButtonClick(RIGHT)) { 77 | Xbox.setLedOn(LED2); 78 | Serial.println(F("Right")); 79 | } 80 | 81 | if (Xbox.getButtonClick(START)) { 82 | Xbox.setLedMode(ALTERNATING); 83 | Serial.println(F("Start")); 84 | } 85 | if (Xbox.getButtonClick(BACK)) { 86 | Xbox.setLedBlink(ALL); 87 | Serial.println(F("Back")); 88 | } 89 | if (Xbox.getButtonClick(L3)) 90 | Serial.println(F("L3")); 91 | if (Xbox.getButtonClick(R3)) 92 | Serial.println(F("R3")); 93 | 94 | if (Xbox.getButtonClick(L1)) 95 | Serial.println(F("L1")); 96 | if (Xbox.getButtonClick(R1)) 97 | Serial.println(F("R1")); 98 | if (Xbox.getButtonClick(XBOX)) { 99 | Xbox.setLedMode(ROTATING); 100 | Serial.println(F("Xbox")); 101 | } 102 | 103 | if (Xbox.getButtonClick(A)) 104 | Serial.println(F("A")); 105 | if (Xbox.getButtonClick(B)) 106 | Serial.println(F("B")); 107 | if (Xbox.getButtonClick(X)) 108 | Serial.println(F("X")); 109 | if (Xbox.getButtonClick(Y)) 110 | Serial.println(F("Y")); 111 | } 112 | delay(1); 113 | } 114 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/acm/acm_terminal/acm_terminal.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "pgmstrings.h" 5 | 6 | // Satisfy the IDE, which needs to see the include statment in the ino too. 7 | #ifdef dobogusinclude 8 | #include 9 | #endif 10 | #include 11 | 12 | class ACMAsyncOper : public CDCAsyncOper 13 | { 14 | public: 15 | uint8_t OnInit(ACM *pacm); 16 | }; 17 | 18 | uint8_t ACMAsyncOper::OnInit(ACM *pacm) 19 | { 20 | uint8_t rcode; 21 | // Set DTR = 1 RTS=1 22 | rcode = pacm->SetControlLineState(3); 23 | 24 | if (rcode) 25 | { 26 | ErrorMessage(PSTR("SetControlLineState"), rcode); 27 | return rcode; 28 | } 29 | 30 | LINE_CODING lc; 31 | lc.dwDTERate = 115200; 32 | lc.bCharFormat = 0; 33 | lc.bParityType = 0; 34 | lc.bDataBits = 8; 35 | 36 | rcode = pacm->SetLineCoding(&lc); 37 | 38 | if (rcode) 39 | ErrorMessage(PSTR("SetLineCoding"), rcode); 40 | 41 | return rcode; 42 | } 43 | 44 | USB Usb; 45 | //USBHub Hub(&Usb); 46 | ACMAsyncOper AsyncOper; 47 | ACM Acm(&Usb, &AsyncOper); 48 | 49 | void setup() 50 | { 51 | Serial.begin( 115200 ); 52 | #if !defined(__MIPSEL__) 53 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 54 | #endif 55 | Serial.println("Start"); 56 | 57 | if (Usb.Init() == -1) 58 | Serial.println("OSCOKIRQ failed to assert"); 59 | 60 | delay( 200 ); 61 | } 62 | 63 | void loop() 64 | { 65 | Usb.Task(); 66 | 67 | if( Acm.isReady()) { 68 | uint8_t rcode; 69 | 70 | /* reading the keyboard */ 71 | if(Serial.available()) { 72 | uint8_t data= Serial.read(); 73 | /* sending to the phone */ 74 | rcode = Acm.SndData(1, &data); 75 | if (rcode) 76 | ErrorMessage(PSTR("SndData"), rcode); 77 | }//if(Serial.available()... 78 | 79 | delay(50); 80 | 81 | /* reading the phone */ 82 | /* buffer size must be greater or equal to max.packet size */ 83 | /* it it set to 64 (largest possible max.packet size) here, can be tuned down 84 | for particular endpoint */ 85 | uint8_t buf[64]; 86 | uint16_t rcvd = 64; 87 | rcode = Acm.RcvData(&rcvd, buf); 88 | if (rcode && rcode != hrNAK) 89 | ErrorMessage(PSTR("Ret"), rcode); 90 | 91 | if( rcvd ) { //more than zero bytes received 92 | for(uint16_t i=0; i < rcvd; i++ ) { 93 | Serial.print((char)buf[i]); //printing on the screen 94 | } 95 | } 96 | delay(10); 97 | }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING.. 98 | } 99 | 100 | 101 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/acm/acm_terminal/pgmstrings.h: -------------------------------------------------------------------------------- 1 | #if !defined(__PGMSTRINGS_H__) 2 | #define __PGMSTRINGS_H__ 3 | 4 | #define LOBYTE(x) ((char*)(&(x)))[0] 5 | #define HIBYTE(x) ((char*)(&(x)))[1] 6 | #define BUFSIZE 256 //buffer size 7 | 8 | 9 | /* Print strings in Program Memory */ 10 | const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t"; 11 | const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: "; 12 | const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t"; 13 | const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t"; 14 | const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t"; 15 | const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t"; 16 | const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t"; 17 | const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t"; 18 | const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t"; 19 | const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t"; 20 | const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t"; 21 | const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t"; 22 | const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t"; 23 | const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t"; 24 | const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t"; 25 | const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t"; 26 | const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes"; 27 | const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:"; 28 | const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t"; 29 | const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t"; 30 | const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t"; 31 | const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t"; 32 | const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; 33 | const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t"; 34 | const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:"; 35 | const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t"; 36 | const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t"; 37 | const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t"; 38 | const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t"; 39 | const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t"; 40 | const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t"; 41 | const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t"; 42 | const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:"; 43 | const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t"; 44 | const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; 45 | const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t"; 46 | const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t"; 47 | const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:"; 48 | const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t"; 49 | const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t"; 50 | const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t"; 51 | 52 | #endif // __PGMSTRINGS_H__ -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/adk/ArduinoBlinkLED/ArduinoBlinkLED.ino: -------------------------------------------------------------------------------- 1 | // The source for the Android application can be found at the following link: https://github.com/Lauszus/ArduinoBlinkLED 2 | // The code for the Android application is heavily based on this guide: http://allaboutee.com/2011/12/31/arduino-adk-board-blink-an-led-with-your-phone-code-and-explanation/ by Miguel 3 | #include 4 | 5 | // 6 | // CAUTION! WARNING! ATTENTION! VORSICHT! ADVARSEL! ¡CUIDADO! ВНИМАНИЕ! 7 | // 8 | // Pin 13 is occupied by the SCK pin on various Arduino boards, 9 | // including Uno, Duemilanove, etc., so use a different pin for those boards. 10 | // 11 | // CAUTION! WARNING! ATTENTION! VORSICHT! ADVARSEL! ¡CUIDADO! ВНИМАНИЕ! 12 | // 13 | #if defined(LED_BUILTIN) 14 | #define LED LED_BUILTIN // Use built in LED 15 | #else 16 | #define LED 9 // Set to something here that makes sense for your board. 17 | #endif 18 | 19 | 20 | // Satisfy IDE, which only needs to see the include statment in the ino. 21 | #ifdef dobogusinclude 22 | #include 23 | #endif 24 | #include 25 | 26 | USB Usb; 27 | ADK adk(&Usb, "TKJElectronics", // Manufacturer Name 28 | "ArduinoBlinkLED", // Model Name 29 | "Example sketch for the USB Host Shield", // Description (user-visible string) 30 | "1.0", // Version 31 | "http://www.tkjelectronics.dk/uploads/ArduinoBlinkLED.apk", // URL (web page to visit if no installed apps support the accessory) 32 | "123456789"); // Serial Number (optional) 33 | 34 | uint32_t timer; 35 | bool connected; 36 | 37 | void setup() { 38 | Serial.begin(115200); 39 | #if !defined(__MIPSEL__) 40 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 41 | #endif 42 | if (Usb.Init() == -1) { 43 | Serial.print("\r\nOSCOKIRQ failed to assert"); 44 | while (1); // halt 45 | } 46 | pinMode(LED, OUTPUT); 47 | Serial.print("\r\nArduino Blink LED Started"); 48 | } 49 | 50 | void loop() { 51 | Usb.Task(); 52 | 53 | if (adk.isReady()) { 54 | if (!connected) { 55 | connected = true; 56 | Serial.print(F("\r\nConnected to accessory")); 57 | } 58 | 59 | uint8_t msg[1]; 60 | uint16_t len = sizeof(msg); 61 | uint8_t rcode = adk.RcvData(&len, msg); 62 | if (rcode && rcode != hrNAK) { 63 | Serial.print(F("\r\nData rcv: ")); 64 | Serial.print(rcode, HEX); 65 | } else if (len > 0) { 66 | Serial.print(F("\r\nData Packet: ")); 67 | Serial.print(msg[0]); 68 | digitalWrite(LED, msg[0] ? HIGH : LOW); 69 | } 70 | 71 | if ((int32_t)((uint32_t)millis() - timer) >= 1000) { // Send data every 1s 72 | timer = (uint32_t)millis(); 73 | rcode = adk.SndData(sizeof(timer), (uint8_t*)&timer); 74 | if (rcode && rcode != hrNAK) { 75 | Serial.print(F("\r\nData send: ")); 76 | Serial.print(rcode, HEX); 77 | } else if (rcode != hrNAK) { 78 | Serial.print(F("\r\nTimer: ")); 79 | Serial.print(timer); 80 | } 81 | } 82 | } else { 83 | if (connected) { 84 | connected = false; 85 | Serial.print(F("\r\nDisconnected from accessory")); 86 | digitalWrite(LED, LOW); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/adk/adk_barcode/adk_barcode.ino: -------------------------------------------------------------------------------- 1 | /**/ 2 | /* A sketch demonstrating data exchange between two USB devices - a HID barcode scanner and ADK-compatible Android phone */ 3 | /**/ 4 | #include 5 | #include 6 | #include 7 | 8 | // Satisfy IDE, which only needs to see the include statment in the ino. 9 | #ifdef dobogusinclude 10 | #include 11 | #endif 12 | #include 13 | 14 | USB Usb; 15 | USBHub Hub1(&Usb); 16 | USBHub Hub2(&Usb); 17 | HIDBoot HidKeyboard(&Usb); 18 | 19 | ADK adk(&Usb,"Circuits@Home, ltd.", 20 | "USB Host Shield", 21 | "Arduino Terminal for Android", 22 | "1.0", 23 | "http://www.circuitsathome.com", 24 | "0000000000000001"); 25 | 26 | 27 | class KbdRptParser : public KeyboardReportParser 28 | { 29 | 30 | protected: 31 | void OnKeyDown (uint8_t mod, uint8_t key); 32 | void OnKeyPressed(uint8_t key); 33 | }; 34 | 35 | void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) 36 | { 37 | uint8_t c = OemToAscii(mod, key); 38 | 39 | if (c) 40 | OnKeyPressed(c); 41 | } 42 | 43 | /* what to do when symbol arrives */ 44 | void KbdRptParser::OnKeyPressed(uint8_t key) 45 | { 46 | const char* new_line = "\n"; 47 | uint8_t rcode; 48 | uint8_t keylcl; 49 | 50 | if( adk.isReady() == false ) { 51 | return; 52 | } 53 | 54 | keylcl = key; 55 | 56 | if( keylcl == 0x13 ) { 57 | rcode = adk.SndData( strlen( new_line ), (uint8_t *)new_line ); 58 | if (rcode && rcode != hrNAK) { 59 | Serial.print(F("\r\nData send: ")); 60 | Serial.print(rcode, HEX); 61 | } 62 | } 63 | else { 64 | rcode = adk.SndData( 1, &keylcl ); 65 | if (rcode && rcode != hrNAK) { 66 | Serial.print(F("\r\nData send: ")); 67 | Serial.print(rcode, HEX); 68 | } 69 | } 70 | 71 | Serial.print((char) keylcl ); 72 | Serial.print(" : "); 73 | Serial.println( keylcl, HEX ); 74 | }; 75 | 76 | KbdRptParser Prs; 77 | 78 | void setup() 79 | { 80 | Serial.begin(115200); 81 | #if !defined(__MIPSEL__) 82 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 83 | #endif 84 | Serial.println("\r\nADK demo start"); 85 | 86 | if (Usb.Init() == -1) { 87 | Serial.println("OSCOKIRQ failed to assert"); 88 | while(1); //halt 89 | }//if (Usb.Init() == -1... 90 | 91 | HidKeyboard.SetReportParser(0, &Prs); 92 | 93 | delay( 200 ); 94 | } 95 | 96 | void loop() 97 | { 98 | Usb.Task(); 99 | } 100 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/adk/demokit_20/demokit_20.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Satisfy IDE, which only needs to see the include statment in the ino. 5 | #ifdef dobogusinclude 6 | #include 7 | #endif 8 | #include 9 | 10 | USB Usb; 11 | USBHub hub0(&Usb); 12 | USBHub hub1(&Usb); 13 | ADK adk(&Usb, "Google, Inc.", 14 | "DemoKit", 15 | "DemoKit Arduino Board", 16 | "1.0", 17 | "http://www.android.com", 18 | "0000000012345678"); 19 | uint8_t b, b1; 20 | 21 | 22 | #define LED1_RED 3 23 | #define BUTTON1 2 24 | 25 | #ifdef ESP32 26 | #define LED1_RED_CHANNEL 0 27 | #endif 28 | 29 | void init_buttons() 30 | { 31 | pinMode(BUTTON1, INPUT); 32 | 33 | // enable the internal pullups 34 | digitalWrite(BUTTON1, HIGH); 35 | } 36 | 37 | void init_leds() 38 | { 39 | digitalWrite(LED1_RED, 0); 40 | 41 | #ifdef ESP32 42 | ledcAttachPin(LED1_RED, LED1_RED_CHANNEL); // Assign LED pin to channel 0 43 | ledcSetup(LED1_RED_CHANNEL, 12000, 8); // 12 kHz PWM, 8-bit resolution 44 | #else 45 | pinMode(LED1_RED, OUTPUT); 46 | #endif 47 | } 48 | 49 | void setup() 50 | { 51 | Serial.begin(115200); 52 | #if !defined(__MIPSEL__) 53 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 54 | #endif 55 | Serial.println("\r\nADK demo start"); 56 | 57 | if (Usb.Init() == -1) { 58 | Serial.println("OSCOKIRQ failed to assert"); 59 | while (1); //halt 60 | }//if (Usb.Init() == -1... 61 | 62 | init_leds(); 63 | init_buttons(); 64 | b1 = digitalRead(BUTTON1); 65 | } 66 | 67 | void loop() 68 | { 69 | uint8_t rcode; 70 | uint8_t msg[3] = { 0x00 }; 71 | Usb.Task(); 72 | 73 | if ( adk.isReady() == false ) { 74 | #ifdef ESP32 75 | ledcWrite(LED1_RED_CHANNEL, 255); 76 | #else 77 | analogWrite(LED1_RED, 255); 78 | #endif 79 | return; 80 | } 81 | uint16_t len = sizeof(msg); 82 | 83 | rcode = adk.RcvData(&len, msg); 84 | if ( rcode ) { 85 | USBTRACE2("Data rcv. :", rcode ); 86 | } 87 | if (len > 0) { 88 | USBTRACE("\r\nData Packet."); 89 | // assumes only one command per packet 90 | if (msg[0] == 0x2) { 91 | switch ( msg[1] ) { 92 | case 0: 93 | #ifdef ESP32 94 | ledcWrite(LED1_RED_CHANNEL, 255 - msg[2]); 95 | #else 96 | analogWrite(LED1_RED, 255 - msg[2]); 97 | #endif 98 | break; 99 | }//switch( msg[1]... 100 | }//if (msg[0] == 0x2... 101 | }//if( len > 0... 102 | 103 | msg[0] = 0x1; 104 | 105 | b = digitalRead(BUTTON1); 106 | if (b != b1) { 107 | USBTRACE("\r\nButton state changed"); 108 | msg[1] = 0; 109 | msg[2] = b ? 0 : 1; 110 | rcode = adk.SndData( 3, msg ); 111 | if ( rcode ) { 112 | USBTRACE2("Button send: ", rcode ); 113 | } 114 | b1 = b; 115 | }//if (b != b1... 116 | 117 | 118 | delay( 10 ); 119 | } 120 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/adk/term_test/term_test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Satisfy IDE, which only needs to see the include statment in the ino. 5 | #ifdef dobogusinclude 6 | #include 7 | #endif 8 | #include 9 | 10 | USB Usb; 11 | //USBHub Hub(&Usb); 12 | 13 | ADK adk(&Usb, "Circuits@Home, ltd.", 14 | "USB Host Shield", 15 | "Arduino Terminal for Android", 16 | "1.0", 17 | "http://www.circuitsathome.com", 18 | "0000000000000001"); 19 | 20 | void setup() 21 | { 22 | Serial.begin(115200); 23 | #if !defined(__MIPSEL__) 24 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 25 | #endif 26 | Serial.println("\r\nADK demo start"); 27 | 28 | if (Usb.Init() == -1) { 29 | Serial.println("OSCOKIRQ failed to assert"); 30 | while (1); //halt 31 | }//if (Usb.Init() == -1... 32 | } 33 | 34 | void loop() 35 | { 36 | uint8_t rcode; 37 | uint8_t msg[64] = { 0x00 }; 38 | const char* recv = "Received: "; 39 | 40 | Usb.Task(); 41 | 42 | if ( adk.isReady() == false ) { 43 | return; 44 | } 45 | uint16_t len = 64; 46 | 47 | rcode = adk.RcvData(&len, msg); 48 | if ( rcode & ( rcode != hrNAK )) { 49 | USBTRACE2("Data rcv. :", rcode ); 50 | } 51 | if (len > 0) { 52 | USBTRACE("\r\nData Packet."); 53 | 54 | for ( uint8_t i = 0; i < len; i++ ) { 55 | Serial.print((char)msg[i]); 56 | } 57 | /* sending back what was received */ 58 | rcode = adk.SndData( strlen( recv ), (uint8_t *)recv ); 59 | if (rcode && rcode != hrNAK) { 60 | Serial.print(F("\r\nData send: ")); 61 | Serial.print(rcode, HEX); 62 | } 63 | rcode = adk.SndData( strlen(( char * )msg ), msg ); 64 | if (rcode && rcode != hrNAK) { 65 | Serial.print(F("\r\nData send: ")); 66 | Serial.print(rcode, HEX); 67 | } 68 | 69 | }//if( len > 0 )... 70 | 71 | delay( 1000 ); 72 | } 73 | 74 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/adk/term_time/term_time.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Satisfy IDE, which only needs to see the include statment in the ino. 5 | #ifdef dobogusinclude 6 | #include 7 | #endif 8 | #include 9 | 10 | USB Usb; 11 | 12 | ADK adk(&Usb, "Circuits@Home, ltd.", 13 | "USB Host Shield", 14 | "Arduino Terminal for Android", 15 | "1.0", 16 | "http://www.circuitsathome.com", 17 | "0000000000000001"); 18 | 19 | void setup() 20 | { 21 | Serial.begin(115200); 22 | #if !defined(__MIPSEL__) 23 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 24 | #endif 25 | Serial.println("\r\nADK demo start"); 26 | 27 | if (Usb.Init() == -1) { 28 | Serial.println("OSCOKIRQ failed to assert"); 29 | while (1); //halt 30 | }//if (Usb.Init() == -1... 31 | } 32 | 33 | void loop() 34 | { 35 | uint8_t buf[ 12 ] = { 0 }; //buffer to convert unsigned long to ASCII 36 | const char* sec_ela = " seconds elapsed\r"; 37 | uint8_t rcode; 38 | 39 | Usb.Task(); 40 | if ( adk.isReady() == false ) { 41 | return; 42 | } 43 | 44 | ultoa((uint32_t)millis() / 1000, (char *)buf, 10 ); 45 | 46 | rcode = adk.SndData( strlen((char *)buf), buf ); 47 | if (rcode && rcode != hrNAK) { 48 | Serial.print(F("\r\nData send: ")); 49 | Serial.print(rcode, HEX); 50 | } 51 | rcode = adk.SndData( strlen( sec_ela), (uint8_t *)sec_ela ); 52 | if (rcode && rcode != hrNAK) { 53 | Serial.print(F("\r\nData send: ")); 54 | Serial.print(rcode, HEX); 55 | } 56 | 57 | delay( 1000 ); 58 | } 59 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/cdc_XR21B1411/XR_terminal/XR_terminal.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // Satisfy IDE, which only needs to see the include statment in the ino. 4 | #ifdef dobogusinclude 5 | #include 6 | #endif 7 | #include 8 | 9 | class ACMAsyncOper : public CDCAsyncOper 10 | { 11 | public: 12 | uint8_t OnInit(ACM *pacm); 13 | }; 14 | 15 | uint8_t ACMAsyncOper::OnInit(ACM *pacm) 16 | { 17 | uint8_t rcode; 18 | // Set DTR = 1 RTS=1 19 | rcode = pacm->SetControlLineState(3); 20 | 21 | if (rcode) 22 | { 23 | ErrorMessage(PSTR("SetControlLineState"), rcode); 24 | return rcode; 25 | } 26 | 27 | LINE_CODING lc; 28 | lc.dwDTERate = 115200; 29 | lc.bCharFormat = 0; 30 | lc.bParityType = 0; 31 | lc.bDataBits = 8; 32 | 33 | rcode = pacm->SetLineCoding(&lc); 34 | 35 | if (rcode) 36 | ErrorMessage(PSTR("SetLineCoding"), rcode); 37 | 38 | return rcode; 39 | } 40 | 41 | USB Usb; 42 | ACMAsyncOper AsyncOper; 43 | XR21B1411 Acm(&Usb, &AsyncOper); 44 | 45 | void setup() { 46 | Serial.begin( 115200 ); 47 | #if !defined(__MIPSEL__) 48 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 49 | #endif 50 | Serial.println("\r\n\r\nStart"); 51 | 52 | if (Usb.Init() == -1) Serial.println("OSCOKIRQ failed to assert"); 53 | } 54 | 55 | void loop() { 56 | Usb.Task(); 57 | if( Acm.isReady()) { 58 | uint8_t rcode; 59 | uint8_t buf[1]; 60 | uint16_t rcvd = 1; 61 | 62 | /* read keyboard */ 63 | if(Serial.available()) { 64 | uint8_t data = Serial.read(); 65 | /* send */ 66 | rcode = Acm.SndData(1, &data); 67 | if (rcode) 68 | ErrorMessage(PSTR("SndData"), rcode); 69 | } 70 | 71 | /* read XR serial */ 72 | rcode = Acm.RcvData(&rcvd, buf); 73 | if (rcode && rcode != hrNAK) 74 | ErrorMessage(PSTR("Ret"), rcode); 75 | 76 | if( rcvd ) { //more than zero bytes received 77 | for(uint16_t i=0; i < rcvd; i++ ) { 78 | Serial.print((char)buf[i]); 79 | } 80 | } 81 | } 82 | } 83 | 84 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/ftdi/USBFTDILoopback/USBFTDILoopback.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "pgmstrings.h" 5 | 6 | // Satisfy the IDE, which needs to see the include statment in the ino too. 7 | #ifdef dobogusinclude 8 | #include 9 | #endif 10 | #include 11 | 12 | class FTDIAsync : public FTDIAsyncOper 13 | { 14 | public: 15 | uint8_t OnInit(FTDI *pftdi); 16 | }; 17 | 18 | uint8_t FTDIAsync::OnInit(FTDI *pftdi) 19 | { 20 | uint8_t rcode = 0; 21 | 22 | rcode = pftdi->SetBaudRate(115200); 23 | 24 | if (rcode) 25 | { 26 | ErrorMessage(PSTR("SetBaudRate"), rcode); 27 | return rcode; 28 | } 29 | rcode = pftdi->SetFlowControl(FTDI_SIO_DISABLE_FLOW_CTRL); 30 | 31 | if (rcode) 32 | ErrorMessage(PSTR("SetFlowControl"), rcode); 33 | 34 | return rcode; 35 | } 36 | 37 | USB Usb; 38 | //USBHub Hub(&Usb); 39 | FTDIAsync FtdiAsync; 40 | FTDI Ftdi(&Usb, &FtdiAsync); 41 | 42 | void setup() 43 | { 44 | Serial.begin( 115200 ); 45 | #if !defined(__MIPSEL__) 46 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 47 | #endif 48 | Serial.println("Start"); 49 | 50 | if (Usb.Init() == -1) 51 | Serial.println("OSC did not start."); 52 | 53 | delay( 200 ); 54 | } 55 | 56 | void loop() 57 | { 58 | Usb.Task(); 59 | 60 | if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) 61 | { 62 | uint8_t rcode; 63 | char strbuf[] = "DEADBEEF"; 64 | //char strbuf[] = "The quick brown fox jumps over the lazy dog"; 65 | //char strbuf[] = "This string contains 61 character to demonstrate FTDI buffers"; //add one symbol to it to see some garbage 66 | Serial.print("."); 67 | 68 | rcode = Ftdi.SndData(strlen(strbuf), (uint8_t*)strbuf); 69 | 70 | if (rcode) 71 | ErrorMessage(PSTR("SndData"), rcode); 72 | 73 | delay(50); 74 | 75 | uint8_t buf[64]; 76 | 77 | for (uint8_t i=0; i<64; i++) 78 | buf[i] = 0; 79 | 80 | uint16_t rcvd = 64; 81 | rcode = Ftdi.RcvData(&rcvd, buf); 82 | 83 | if (rcode && rcode != hrNAK) 84 | ErrorMessage(PSTR("Ret"), rcode); 85 | 86 | // The device reserves the first two bytes of data 87 | // to contain the current values of the modem and line status registers. 88 | if (rcvd > 2) 89 | Serial.print((char*)(buf+2)); 90 | 91 | delay(10); 92 | } 93 | } 94 | 95 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/ftdi/USBFTDILoopback/pgmstrings.h: -------------------------------------------------------------------------------- 1 | #if !defined(__PGMSTRINGS_H__) 2 | #define __PGMSTRINGS_H__ 3 | 4 | #define LOBYTE(x) ((char*)(&(x)))[0] 5 | #define HIBYTE(x) ((char*)(&(x)))[1] 6 | #define BUFSIZE 256 //buffer size 7 | 8 | 9 | /* Print strings in Program Memory */ 10 | const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t"; 11 | const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: "; 12 | const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t"; 13 | const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t"; 14 | const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t"; 15 | const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t"; 16 | const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t"; 17 | const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t"; 18 | const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t"; 19 | const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t"; 20 | const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t"; 21 | const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t"; 22 | const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t"; 23 | const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t"; 24 | const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t"; 25 | const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t"; 26 | const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes"; 27 | const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:"; 28 | const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t"; 29 | const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t"; 30 | const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t"; 31 | const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t"; 32 | const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; 33 | const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t"; 34 | const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:"; 35 | const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t"; 36 | const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t"; 37 | const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t"; 38 | const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t"; 39 | const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t"; 40 | const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t"; 41 | const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t"; 42 | const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:"; 43 | const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t"; 44 | const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; 45 | const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t"; 46 | const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t"; 47 | const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:"; 48 | const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t"; 49 | const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t"; 50 | const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t"; 51 | 52 | #endif // __PGMSTRINGS_H__ -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/hub_demo/pgmstrings.h: -------------------------------------------------------------------------------- 1 | #if !defined(__PGMSTRINGS_H__) 2 | #define __PGMSTRINGS_H__ 3 | 4 | #define LOBYTE(x) ((char*)(&(x)))[0] 5 | #define HIBYTE(x) ((char*)(&(x)))[1] 6 | #define BUFSIZE 256 //buffer size 7 | 8 | 9 | /* Print strings in Program Memory */ 10 | const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t"; 11 | const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: "; 12 | const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t"; 13 | const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t"; 14 | const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t"; 15 | const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t"; 16 | const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t"; 17 | const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t"; 18 | const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t"; 19 | const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t"; 20 | const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t"; 21 | const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t"; 22 | const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t"; 23 | const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t"; 24 | const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t"; 25 | const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t"; 26 | const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes"; 27 | const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:"; 28 | const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t"; 29 | const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t"; 30 | const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t"; 31 | const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t"; 32 | const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; 33 | const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t"; 34 | const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:"; 35 | const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t"; 36 | const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t"; 37 | const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t"; 38 | const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t"; 39 | const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t"; 40 | const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t"; 41 | const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t"; 42 | const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:"; 43 | const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t"; 44 | const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; 45 | const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t"; 46 | const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t"; 47 | const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:"; 48 | const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t"; 49 | const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t"; 50 | const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t"; 51 | 52 | #endif // __PGMSTRINGS_H__ -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/max_LCD/max_LCD.ino: -------------------------------------------------------------------------------- 1 | // Just a copy of the HelloWorld example bundled with the LiquidCrystal library in the Arduino IDE 2 | 3 | // HD44780 compatible LCD display via MAX3421E GPOUT support header 4 | // pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3] 5 | 6 | #include 7 | 8 | // Satisfy IDE, which only needs to see the include statment in the ino. 9 | #ifdef dobogusinclude 10 | #include 11 | #endif 12 | #include 13 | 14 | USB Usb; 15 | Max_LCD lcd(&Usb); 16 | 17 | void setup() { 18 | // Set up the LCD's number of columns and rows: 19 | lcd.begin(16, 2); 20 | // Print a message to the LCD. 21 | lcd.print("Hello, World!"); 22 | } 23 | 24 | void loop() { 25 | // Set the cursor to column 0, line 1 (note: line 1 is the second row, since counting begins with 0): 26 | lcd.setCursor(0, 1); 27 | // Print the number of seconds since reset: 28 | lcd.print((uint32_t)millis() / 1000); 29 | } 30 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/pl2303/pl2303_gprs_terminal/pl2303_gprs_terminal.ino: -------------------------------------------------------------------------------- 1 | /* Arduino terminal for PL2303 USB to serial converter and DealeXtreme GPRS modem. */ 2 | /* USB support */ 3 | #include 4 | /* CDC support */ 5 | #include 6 | #include 7 | 8 | // Satisfy the IDE, which needs to see the include statment in the ino too. 9 | #ifdef dobogusinclude 10 | #include 11 | #endif 12 | #include 13 | 14 | class PLAsyncOper : public CDCAsyncOper 15 | { 16 | public: 17 | uint8_t OnInit(ACM *pacm); 18 | }; 19 | 20 | uint8_t PLAsyncOper::OnInit(ACM *pacm) 21 | { 22 | uint8_t rcode; 23 | 24 | // Set DTR = 1 25 | rcode = pacm->SetControlLineState(1); 26 | 27 | if (rcode) 28 | { 29 | ErrorMessage(PSTR("SetControlLineState"), rcode); 30 | return rcode; 31 | } 32 | 33 | LINE_CODING lc; 34 | //lc.dwDTERate = 9600; 35 | lc.dwDTERate = 115200; 36 | lc.bCharFormat = 0; 37 | lc.bParityType = 0; 38 | lc.bDataBits = 8; 39 | 40 | rcode = pacm->SetLineCoding(&lc); 41 | 42 | if (rcode) 43 | ErrorMessage(PSTR("SetLineCoding"), rcode); 44 | 45 | return rcode; 46 | } 47 | USB Usb; 48 | //USBHub Hub(&Usb); 49 | PLAsyncOper AsyncOper; 50 | PL2303 Pl(&Usb, &AsyncOper); 51 | 52 | void setup() 53 | { 54 | Serial.begin( 115200 ); 55 | #if !defined(__MIPSEL__) 56 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 57 | #endif 58 | Serial.println("Start"); 59 | 60 | if (Usb.Init() == -1) 61 | Serial.println("OSCOKIRQ failed to assert"); 62 | 63 | delay( 200 ); 64 | } 65 | 66 | void loop() 67 | { 68 | Usb.Task(); 69 | 70 | if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) 71 | { 72 | uint8_t rcode; 73 | 74 | /* reading the keyboard */ 75 | if(Serial.available()) { 76 | uint8_t data= Serial.read(); 77 | 78 | /* sending to the phone */ 79 | rcode = Pl.SndData(1, &data); 80 | if (rcode) 81 | ErrorMessage(PSTR("SndData"), rcode); 82 | }//if(Serial.available()... 83 | 84 | /* reading the converter */ 85 | /* buffer size must be greater or equal to max.packet size */ 86 | /* it it set to 64 (largest possible max.packet size) here, can be tuned down 87 | for particular endpoint */ 88 | uint8_t buf[64]; 89 | uint16_t rcvd = 64; 90 | rcode = Pl.RcvData(&rcvd, buf); 91 | if (rcode && rcode != hrNAK) 92 | ErrorMessage(PSTR("Ret"), rcode); 93 | 94 | if( rcvd ) { //more than zero bytes received 95 | for(uint16_t i=0; i < rcvd; i++ ) { 96 | Serial.print((char)buf[i]); //printing on the screen 97 | } 98 | }//if( rcvd ... 99 | }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING.. 100 | } 101 | 102 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/pl2303/pl2303_gps/pl2303_gps.ino: -------------------------------------------------------------------------------- 1 | /* USB Host to PL2303-based USB GPS unit interface */ 2 | /* Navibee GM720 receiver - Sirf Star III */ 3 | /* USB support */ 4 | #include 5 | /* CDC support */ 6 | #include 7 | #include 8 | 9 | // Satisfy the IDE, which needs to see the include statment in the ino too. 10 | #ifdef dobogusinclude 11 | #include 12 | #endif 13 | #include 14 | 15 | class PLAsyncOper : public CDCAsyncOper { 16 | public: 17 | uint8_t OnInit(ACM *pacm); 18 | }; 19 | 20 | uint8_t PLAsyncOper::OnInit(ACM *pacm) { 21 | uint8_t rcode; 22 | 23 | // Set DTR = 1 24 | rcode = pacm->SetControlLineState(1); 25 | 26 | if(rcode) { 27 | ErrorMessage(PSTR("SetControlLineState"), rcode); 28 | return rcode; 29 | } 30 | 31 | LINE_CODING lc; 32 | lc.dwDTERate = 4800; //default serial speed of GPS unit 33 | lc.bCharFormat = 0; 34 | lc.bParityType = 0; 35 | lc.bDataBits = 8; 36 | 37 | rcode = pacm->SetLineCoding(&lc); 38 | 39 | if(rcode) 40 | ErrorMessage(PSTR("SetLineCoding"), rcode); 41 | 42 | return rcode; 43 | } 44 | 45 | USB Usb; 46 | USBHub Hub(&Usb); 47 | PLAsyncOper AsyncOper; 48 | PL2303 Pl(&Usb, &AsyncOper); 49 | uint32_t read_delay; 50 | #define READ_DELAY 100 51 | 52 | void setup() { 53 | Serial.begin(115200); 54 | #if !defined(__MIPSEL__) 55 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 56 | #endif 57 | Serial.println("Start"); 58 | 59 | if(Usb.Init() == -1) 60 | Serial.println("OSCOKIRQ failed to assert"); 61 | 62 | delay(200); 63 | } 64 | 65 | void loop() { 66 | uint8_t rcode; 67 | uint8_t buf[64]; //serial buffer equals Max.packet size of bulk-IN endpoint 68 | uint16_t rcvd = 64; 69 | 70 | Usb.Task(); 71 | 72 | if(Pl.isReady()) { 73 | /* reading the GPS */ 74 | if((int32_t)((uint32_t)millis() - read_delay) >= 0L) { 75 | read_delay += READ_DELAY; 76 | rcode = Pl.RcvData(&rcvd, buf); 77 | if(rcode && rcode != hrNAK) 78 | ErrorMessage(PSTR("Ret"), rcode); 79 | if(rcvd) { //more than zero bytes received 80 | for(uint16_t i = 0; i < rcvd; i++) { 81 | Serial.print((char)buf[i]); //printing on the screen 82 | }//for( uint16_t i=0; i < rcvd; i++... 83 | }//if( rcvd 84 | }//if( read_delay > millis()... 85 | }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING.. 86 | } 87 | 88 | 89 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/pl2303/pl2303_xbee_terminal/pl2303_xbee_terminal.ino: -------------------------------------------------------------------------------- 1 | /* Arduino terminal for PL2303 USB to serial converter and XBee radio. */ 2 | /* Inserts linefeed after carriage return in data sent to and received from Xbee */ 3 | /* USB support */ 4 | #include 5 | /* CDC support */ 6 | #include 7 | #include 8 | 9 | // Satisfy the IDE, which needs to see the include statment in the ino too. 10 | #ifdef dobogusinclude 11 | #include 12 | #endif 13 | #include 14 | 15 | class PLAsyncOper : public CDCAsyncOper 16 | { 17 | public: 18 | uint8_t OnInit(ACM *pacm); 19 | }; 20 | 21 | uint8_t PLAsyncOper::OnInit(ACM *pacm) 22 | { 23 | uint8_t rcode; 24 | 25 | // Set DTR = 1 26 | rcode = pacm->SetControlLineState(1); 27 | 28 | if (rcode) 29 | { 30 | ErrorMessage(PSTR("SetControlLineState"), rcode); 31 | return rcode; 32 | } 33 | 34 | LINE_CODING lc; 35 | lc.dwDTERate = 115200; 36 | lc.bCharFormat = 0; 37 | lc.bParityType = 0; 38 | lc.bDataBits = 8; 39 | 40 | rcode = pacm->SetLineCoding(&lc); 41 | 42 | if (rcode) 43 | ErrorMessage(PSTR("SetLineCoding"), rcode); 44 | 45 | return rcode; 46 | } 47 | USB Usb; 48 | //USBHub Hub(&Usb); 49 | PLAsyncOper AsyncOper; 50 | PL2303 Pl(&Usb, &AsyncOper); 51 | 52 | void setup() 53 | { 54 | Serial.begin( 115200 ); 55 | #if !defined(__MIPSEL__) 56 | while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 57 | #endif 58 | Serial.println("Start"); 59 | 60 | if (Usb.Init() == -1) 61 | Serial.println("OSCOKIRQ failed to assert"); 62 | 63 | delay( 200 ); 64 | } 65 | 66 | void loop() 67 | { 68 | Usb.Task(); 69 | 70 | if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) 71 | { 72 | uint8_t rcode; 73 | 74 | /* reading the keyboard */ 75 | if(Serial.available()) { 76 | uint8_t data= Serial.read(); 77 | 78 | if ( data == '\r' ) { 79 | Serial.print("\r\n"); //insert linefeed 80 | } 81 | else { 82 | Serial.print( data ); //echo back to the screen 83 | } 84 | 85 | /* sending to the phone */ 86 | rcode = Pl.SndData(1, &data); 87 | if (rcode) 88 | ErrorMessage(PSTR("SndData"), rcode); 89 | }//if(Serial.available()... 90 | 91 | delay(50); 92 | 93 | /* reading the converter */ 94 | /* buffer size must be greater or equal to max.packet size */ 95 | /* it it set to 64 (largest possible max.packet size) here, can be tuned down 96 | for particular endpoint */ 97 | uint8_t buf[64]; 98 | uint16_t rcvd = 64; 99 | rcode = Pl.RcvData(&rcvd, buf); 100 | if (rcode && rcode != hrNAK) 101 | ErrorMessage(PSTR("Ret"), rcode); 102 | 103 | if( rcvd ) { //more than zero bytes received 104 | for(uint16_t i=0; i < rcvd; i++ ) { 105 | if( buf[i] =='\r' ) { 106 | Serial.print("\r\n"); //insert linefeed 107 | } 108 | else { 109 | Serial.print((char)buf[i]); //printing on the screen 110 | } 111 | } 112 | } 113 | delay(10); 114 | }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING.. 115 | } 116 | 117 | 118 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/testusbhostFAT/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # These are set for a mega 1280 + quadram plus my serial patch. 3 | # If you lack quadram, or want to disable LFN, just change _FS_TINY=1 _USE_LFN=0 4 | # 5 | # If your board is a mega 2560 comment out the following two lines 6 | BOARD = mega 7 | 8 | BOARD_SUB = mega.menu.cpu.atmega1280 9 | PROGRAMMER = arduino 10 | 11 | # ...and then uncomment out the following two lines 12 | #BOARD_SUB = mega.menu.cpu.atmega2560 13 | #PROGRAMMER = wiring 14 | 15 | #BOARD = teensypp2 16 | #BOARD = teensy3 17 | #BOARD = teensy31 18 | 19 | # set your Arduino tty port here 20 | PORT = /dev/ttyUSB0 21 | 22 | EXTRA_FLAGS = -D _USE_LFN=3 23 | 24 | # change to 0 if you have quadram to take advantage of caching FAT 25 | EXTRA_FLAGS += -D _FS_TINY=1 26 | 27 | 28 | EXTRA_FLAGS += -D _MAX_SS=512 29 | 30 | 31 | # Don't worry if you don't have external RAM, xmem2 detects this situation. 32 | # You *WILL* be wanting to get some kind of external ram on your mega in order to 33 | # do anything that is intense. 34 | EXTRA_FLAGS += -D EXT_RAM_STACK=1 35 | EXTRA_FLAGS += -D EXT_RAM_HEAP=1 36 | 37 | 38 | # These are no longer needed for the demo to work. 39 | # In the event you need more ram, uncomment these 3 lines. 40 | #EXTRA_FLAGS += -D DISABLE_SERIAL1 41 | #EXTRA_FLAGS += -D DISABLE_SERIAL2 42 | #EXTRA_FLAGS += -D DISABLE_SERIAL3 43 | 44 | # 45 | # Advanced debug on Serial3 46 | # 47 | 48 | # uncomment the next two to enable debug on Serial3 49 | EXTRA_FLAGS += -D USB_HOST_SERIAL=Serial3 50 | #EXTRA_FLAGS += -D DEBUG_USB_HOST 51 | 52 | # The following are the libraries used. 53 | LIB_DIRS += ../../ 54 | LIB_DIRS += ../testusbhostFAT/xmem2 55 | LIB_DIRS += ../testusbhostFAT/generic_storage 56 | LIB_DIRS += ../testusbhostFAT/RTClib 57 | LIB_DIRS += $(ARD_HOME)/libraries/Wire 58 | LIB_DIRS += $(ARD_HOME)/libraries/Wire/utility 59 | LIB_DIRS += $(ARD_HOME)/hardware/arduino/$(BUILD_ARCH)/libraries/Wire 60 | LIB_DIRS += $(ARD_HOME)/hardware/arduino/$(BUILD_ARCH)/libraries/Wire/utility 61 | LIB_DIRS += $(ARD_HOME)/hardware/arduino/$(BUILD_ARCH)/libraries/SPI 62 | 63 | # And finally, the part that brings everything together for you. 64 | include Arduino_Makefile_master/_Makefile.master 65 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/examples/testusbhostFAT/README.md: -------------------------------------------------------------------------------- 1 | This small sketch tests the USB host shield mass storage library. 2 | 3 | __Note:__ This will not run a Arduino Uno due to the limited ram available in the ATmega328p. 4 | 5 | The Arduino Mega (ATmega1280) and the Arduino Mega 2560 (ATmega2560) are confirmed to work with this test code. 6 | 7 | To compile this example you will need the following libraries as well: 8 | 9 | * [xmem2](https://github.com/xxxajk/xmem2) 10 | * [generic_storage FATfs](https://github.com/xxxajk/generic_storage) 11 | * [RTClib](https://github.com/xxxajk/RTClib) 12 | 13 | The following shield is recommended for larger projects: . 14 | 15 | You may use the bundled [Makefile](Makefile) to compile the code instead of the Arduino IDE if you have problems or want a smaller binary. The master makefile is bundled as a submodule, but can also be downloaded manually at the following link: . 16 | 17 | To download the USB Host library and all the needed libraries for this test. 18 | 19 | Run the following command in a terminal application: 20 | 21 | ``` 22 | git clone --recursive https://github.com/felis/USB_Host_Shield_2.0 23 | ``` 24 | 25 | If you want to update all the submodules run: 26 | 27 | ``` 28 | git submodule foreach --recursive git pull origin master 29 | ``` 30 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/hexdump.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Circuits At Home, LTD 14 | Web : http://www.circuitsathome.com 15 | e-mail : support@circuitsathome.com 16 | */ 17 | #if !defined(_usb_h_) || defined(__HEXDUMP_H__) 18 | #error "Never include hexdump.h directly; include Usb.h instead" 19 | #else 20 | #define __HEXDUMP_H__ 21 | 22 | extern int UsbDEBUGlvl; 23 | 24 | template 25 | class HexDumper : public BASE_CLASS { 26 | uint8_t byteCount; 27 | OFFSET_TYPE byteTotal; 28 | 29 | public: 30 | 31 | HexDumper() : byteCount(0), byteTotal(0) { 32 | }; 33 | 34 | void Initialize() { 35 | byteCount = 0; 36 | byteTotal = 0; 37 | }; 38 | 39 | void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset); 40 | }; 41 | 42 | template 43 | void HexDumper::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset __attribute__((unused))) { 44 | if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug. 45 | for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) { 46 | if(!byteCount) { 47 | PrintHex (byteTotal, 0x80); 48 | E_Notify(PSTR(": "), 0x80); 49 | } 50 | PrintHex (pbuf[j], 0x80); 51 | E_Notify(PSTR(" "), 0x80); 52 | 53 | if(byteCount == 15) { 54 | E_Notify(PSTR("\r\n"), 0x80); 55 | byteCount = 0xFF; 56 | } 57 | } 58 | } 59 | } 60 | 61 | #endif // __HEXDUMP_H__ 62 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/hidcomposite.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Circuits At Home, LTD 14 | Web : http://www.circuitsathome.com 15 | e-mail : support@circuitsathome.com 16 | */ 17 | 18 | #if !defined(__HIDCOMPOSITE_H__) 19 | #define __HIDCOMPOSITE_H__ 20 | 21 | #include "usbhid.h" 22 | //#include "hidescriptorparser.h" 23 | 24 | class HIDComposite : public USBHID { 25 | 26 | struct ReportParser { 27 | uint8_t rptId; 28 | HIDReportParser *rptParser; 29 | } rptParsers[MAX_REPORT_PARSERS]; 30 | 31 | // HID class specific descriptor type and length info obtained from HID descriptor 32 | HID_CLASS_DESCRIPTOR_LEN_AND_TYPE descrInfo[HID_MAX_HID_CLASS_DESCRIPTORS]; 33 | 34 | // Returns HID class specific descriptor length by its type and order number 35 | uint16_t GetHidClassDescrLen(uint8_t type, uint8_t num); 36 | 37 | struct HIDInterface { 38 | struct { 39 | uint8_t bmInterface : 3; 40 | uint8_t bmAltSet : 3; 41 | uint8_t bmProtocol : 2; 42 | }; 43 | uint8_t epIndex[maxEpPerInterface]; 44 | }; 45 | 46 | uint8_t bConfNum; // configuration number 47 | uint8_t bNumIface; // number of interfaces in the configuration 48 | uint8_t bNumEP; // total number of EP in the configuration 49 | uint32_t qNextPollTime; // next poll time 50 | uint8_t pollInterval; 51 | bool bPollEnable; // poll enable flag 52 | 53 | static const uint16_t constBuffLen = 64; // event buffer length 54 | 55 | void Initialize(); 56 | HIDInterface* FindInterface(uint8_t iface, uint8_t alt, uint8_t proto); 57 | 58 | void ZeroMemory(uint8_t len, uint8_t *buf); 59 | 60 | protected: 61 | EpInfo epInfo[totalEndpoints]; 62 | HIDInterface hidInterfaces[maxHidInterfaces]; 63 | 64 | bool bHasReportId; 65 | 66 | uint16_t PID, VID; // PID and VID of connected device 67 | 68 | // HID implementation 69 | HIDReportParser* GetReportParser(uint8_t id); 70 | 71 | virtual uint8_t OnInitSuccessful() { 72 | return 0; 73 | }; 74 | 75 | virtual void ParseHIDData(USBHID *hid __attribute__((unused)), uint8_t ep __attribute__((unused)), bool is_rpt_id __attribute__((unused)), uint8_t len __attribute__((unused)), uint8_t *buf __attribute__((unused))) { 76 | return; 77 | }; 78 | 79 | public: 80 | HIDComposite(USB *p); 81 | 82 | // HID implementation 83 | bool SetReportParser(uint8_t id, HIDReportParser *prs); 84 | 85 | // USBDeviceConfig implementation 86 | uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); 87 | uint8_t Release(); 88 | uint8_t Poll(); 89 | 90 | virtual uint8_t GetAddress() { 91 | return bAddress; 92 | }; 93 | 94 | virtual bool isReady() { 95 | return bPollEnable; 96 | }; 97 | 98 | // UsbConfigXtracter implementation 99 | void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); 100 | 101 | // Send report - do not mix with SetReport()! 102 | uint8_t SndRpt(uint16_t nbytes, uint8_t *dataptr); 103 | 104 | // Returns true if we should listen on an interface, false if not 105 | virtual bool SelectInterface(uint8_t iface, uint8_t proto) = 0; 106 | }; 107 | 108 | #endif // __HIDCOMPOSITE_H__ 109 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/hiduniversal.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Circuits At Home, LTD 14 | Web : http://www.circuitsathome.com 15 | e-mail : support@circuitsathome.com 16 | */ 17 | 18 | #if !defined(__HIDUNIVERSAL_H__) 19 | #define __HIDUNIVERSAL_H__ 20 | 21 | #include "usbhid.h" 22 | //#include "hidescriptorparser.h" 23 | 24 | class HIDUniversal : public USBHID { 25 | 26 | struct ReportParser { 27 | uint8_t rptId; 28 | HIDReportParser *rptParser; 29 | } rptParsers[MAX_REPORT_PARSERS]; 30 | 31 | // HID class specific descriptor type and length info obtained from HID descriptor 32 | HID_CLASS_DESCRIPTOR_LEN_AND_TYPE descrInfo[HID_MAX_HID_CLASS_DESCRIPTORS]; 33 | 34 | // Returns HID class specific descriptor length by its type and order number 35 | uint16_t GetHidClassDescrLen(uint8_t type, uint8_t num); 36 | 37 | struct HIDInterface { 38 | struct { 39 | uint8_t bmInterface : 3; 40 | uint8_t bmAltSet : 3; 41 | uint8_t bmProtocol : 2; 42 | }; 43 | uint8_t epIndex[maxEpPerInterface]; 44 | }; 45 | 46 | uint8_t bConfNum; // configuration number 47 | uint8_t bNumIface; // number of interfaces in the configuration 48 | uint8_t bNumEP; // total number of EP in the configuration 49 | uint32_t qNextPollTime; // next poll time 50 | uint8_t pollInterval; 51 | bool bPollEnable; // poll enable flag 52 | 53 | static const uint16_t constBuffLen = 64; // event buffer length 54 | uint8_t prevBuf[constBuffLen]; // previous event buffer 55 | 56 | void Initialize(); 57 | HIDInterface* FindInterface(uint8_t iface, uint8_t alt, uint8_t proto); 58 | 59 | void ZeroMemory(uint8_t len, uint8_t *buf); 60 | bool BuffersIdentical(uint8_t len, uint8_t *buf1, uint8_t *buf2); 61 | void SaveBuffer(uint8_t len, uint8_t *src, uint8_t *dest); 62 | 63 | protected: 64 | EpInfo epInfo[totalEndpoints]; 65 | HIDInterface hidInterfaces[maxHidInterfaces]; 66 | 67 | bool bHasReportId; 68 | 69 | uint16_t PID, VID; // PID and VID of connected device 70 | 71 | // HID implementation 72 | HIDReportParser* GetReportParser(uint8_t id); 73 | 74 | virtual uint8_t OnInitSuccessful() { 75 | return 0; 76 | }; 77 | 78 | virtual void ParseHIDData(USBHID *hid __attribute__((unused)), bool is_rpt_id __attribute__((unused)), uint8_t len __attribute__((unused)), uint8_t *buf __attribute__((unused))) { 79 | return; 80 | }; 81 | 82 | public: 83 | HIDUniversal(USB *p); 84 | 85 | // HID implementation 86 | bool SetReportParser(uint8_t id, HIDReportParser *prs); 87 | 88 | // USBDeviceConfig implementation 89 | uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); 90 | uint8_t Release(); 91 | uint8_t Poll(); 92 | 93 | virtual uint8_t GetAddress() { 94 | return bAddress; 95 | }; 96 | 97 | virtual bool isReady() { 98 | return bPollEnable; 99 | }; 100 | 101 | // UsbConfigXtracter implementation 102 | void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); 103 | 104 | // Send report - do not mix with SetReport()! 105 | uint8_t SndRpt(uint16_t nbytes, uint8_t *dataptr); 106 | }; 107 | 108 | #endif // __HIDUNIVERSAL_H__ 109 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "USB-Host-Shield-20", 3 | "keywords": "usb, host, ftdi, adk, acm, pl2303, hid, bluetooth, spp, ps3, ps4, buzz, xbox, wii, mass storage", 4 | "description": "Revision 2.0 of MAX3421E-based USB Host Shield Library", 5 | "authors": 6 | [ 7 | { 8 | "name": "Oleg Mazurov", 9 | "email": "mazurov@circuitsathome.com", 10 | "url": "http://www.circuitsathome.com", 11 | "maintainer": true 12 | }, 13 | { 14 | "name": "Alexei Glushchenko", 15 | "email": "alex-gl@mail.ru" 16 | }, 17 | { 18 | "name": "Kristian Lauszus", 19 | "email": "kristianl@tkjelectronics.com", 20 | "url": "http://tkjelectronics.com", 21 | "maintainer": true 22 | }, 23 | { 24 | "name": "Andrew Kroll", 25 | "email": "xxxajk@gmail.com", 26 | "maintainer": true 27 | } 28 | ], 29 | "repository": 30 | { 31 | "type": "git", 32 | "url": "https://github.com/felis/USB_Host_Shield_2.0.git" 33 | }, 34 | "version": "1.3.2", 35 | "license": "GPL-2.0", 36 | "examples": 37 | [ 38 | "examples/*/*.ino", 39 | "examples/*/*/*.ino" 40 | ], 41 | "frameworks": 42 | [ 43 | "arduino", 44 | "spl" 45 | ], 46 | "platforms": 47 | [ 48 | "atmelavr", 49 | "intel_arc32", 50 | "teensy", 51 | "atmelsam", 52 | "nordicnrf51", 53 | "ststm32", 54 | "espressif8266", 55 | "espressif32" 56 | ] 57 | } 58 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/library.properties: -------------------------------------------------------------------------------- 1 | name=USB Host Shield Library 2.0 2 | version=1.3.2 3 | author=Oleg Mazurov (Circuits@Home) , Kristian Lauszus (TKJ Electronics) , Andrew Kroll , Alexei Glushchenko (Circuits@Home) 4 | maintainer=Oleg Mazurov (Circuits@Home) , Kristian Lauszus (TKJ Electronics) , Andrew Kroll 5 | sentence=Revision 2.0 of MAX3421E-based USB Host Shield Library. 6 | paragraph=Supports HID devices, FTDI, ADK, ACM, PL2303, Bluetooth HID devices, SPP communication and mass storage devices. Furthermore it supports PS3, PS4, PS Buzz, Wii and Xbox controllers. 7 | category=Other 8 | url=https://github.com/felis/USB_Host_Shield_2.0 9 | architectures=* 10 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/max_LCD.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Circuits At Home, LTD 14 | Web : http://www.circuitsathome.com 15 | e-mail : support@circuitsathome.com 16 | */ 17 | //HD44780 compatible LCD display via MAX3421E GPOUT support header 18 | //pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3] 19 | // 20 | 21 | #ifndef _Max_LCD_h_ 22 | #define _Max_LCD_h_ 23 | 24 | #include "Usb.h" 25 | #include "Print.h" 26 | 27 | // commands 28 | #define LCD_CLEARDISPLAY 0x01 29 | #define LCD_RETURNHOME 0x02 30 | #define LCD_ENTRYMODESET 0x04 31 | #define LCD_DISPLAYCONTROL 0x08 32 | #define LCD_CURSORSHIFT 0x10 33 | #define LCD_FUNCTIONSET 0x20 34 | #define LCD_SETCGRAMADDR 0x40 35 | #define LCD_SETDDRAMADDR 0x80 36 | 37 | // flags for display entry mode 38 | #define LCD_ENTRYRIGHT 0x00 39 | #define LCD_ENTRYLEFT 0x02 40 | #define LCD_ENTRYSHIFTINCREMENT 0x01 41 | #define LCD_ENTRYSHIFTDECREMENT 0x00 42 | 43 | // flags for display on/off control 44 | #define LCD_DISPLAYON 0x04 45 | #define LCD_DISPLAYOFF 0x00 46 | #define LCD_CURSORON 0x02 47 | #define LCD_CURSOROFF 0x00 48 | #define LCD_BLINKON 0x01 49 | #define LCD_BLINKOFF 0x00 50 | 51 | // flags for display/cursor shift 52 | #define LCD_DISPLAYMOVE 0x08 53 | #define LCD_CURSORMOVE 0x00 54 | #define LCD_MOVERIGHT 0x04 55 | #define LCD_MOVELEFT 0x00 56 | 57 | // flags for function set 58 | #define LCD_8BITMODE 0x10 59 | #define LCD_4BITMODE 0x00 60 | #define LCD_2LINE 0x08 61 | #define LCD_1LINE 0x00 62 | #define LCD_5x10DOTS 0x04 63 | #define LCD_5x8DOTS 0x00 64 | 65 | class Max_LCD : public Print { 66 | USB *pUsb; 67 | 68 | public: 69 | Max_LCD(USB *pusb); 70 | void init(); 71 | void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); 72 | void clear(); 73 | void home(); 74 | void noDisplay(); 75 | void display(); 76 | void noBlink(); 77 | void blink(); 78 | void noCursor(); 79 | void cursor(); 80 | void scrollDisplayLeft(); 81 | void scrollDisplayRight(); 82 | void leftToRight(); 83 | void rightToLeft(); 84 | void autoscroll(); 85 | void noAutoscroll(); 86 | void createChar(uint8_t, uint8_t[]); 87 | void setCursor(uint8_t, uint8_t); 88 | void command(uint8_t); 89 | 90 | #if defined(ARDUINO) && ARDUINO >=100 91 | size_t write(uint8_t); 92 | using Print::write; 93 | #else 94 | void write(uint8_t); 95 | #endif 96 | 97 | private: 98 | void sendbyte(uint8_t val); 99 | uint8_t _displayfunction; //tokill 100 | uint8_t _displaycontrol; 101 | uint8_t _displaymode; 102 | uint8_t _initialized; 103 | uint8_t _numlines, _currline; 104 | }; 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/message.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; either version 2 of the License, or 6 | (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | Contact information 18 | ------------------- 19 | 20 | Circuits At Home, LTD 21 | Web : http://www.circuitsathome.com 22 | e-mail : support@circuitsathome.com 23 | */ 24 | 25 | #include "Usb.h" 26 | // 0x80 is the default (i.e. trace) to turn off set this global to something lower. 27 | // this allows for 126 other debugging levels. 28 | // TO-DO: Allow assignment to a different serial port by software 29 | int UsbDEBUGlvl = 0x80; 30 | 31 | void E_Notifyc(char c, int lvl) { 32 | if(UsbDEBUGlvl < lvl) return; 33 | #if defined(ARDUINO) && ARDUINO >=100 34 | USB_HOST_SERIAL.print(c); 35 | #else 36 | USB_HOST_SERIAL.print(c, BYTE); 37 | #endif 38 | //USB_HOST_SERIAL.flush(); 39 | } 40 | 41 | void E_Notify(char const * msg, int lvl) { 42 | if(UsbDEBUGlvl < lvl) return; 43 | if(!msg) return; 44 | char c; 45 | 46 | while((c = pgm_read_byte(msg++))) E_Notifyc(c, lvl); 47 | } 48 | 49 | void E_NotifyStr(char const * msg, int lvl) { 50 | if(UsbDEBUGlvl < lvl) return; 51 | if(!msg) return; 52 | char c; 53 | 54 | while((c = *msg++)) E_Notifyc(c, lvl); 55 | } 56 | 57 | void E_Notify(uint8_t b, int lvl) { 58 | if(UsbDEBUGlvl < lvl) return; 59 | #if defined(ARDUINO) && ARDUINO >=100 60 | USB_HOST_SERIAL.print(b); 61 | #else 62 | USB_HOST_SERIAL.print(b, DEC); 63 | #endif 64 | //USB_HOST_SERIAL.flush(); 65 | } 66 | 67 | void E_Notify(double d, int lvl) { 68 | if(UsbDEBUGlvl < lvl) return; 69 | USB_HOST_SERIAL.print(d); 70 | //USB_HOST_SERIAL.flush(); 71 | } 72 | 73 | #ifdef DEBUG_USB_HOST 74 | 75 | void NotifyFailGetDevDescr(void) { 76 | Notify(PSTR("\r\ngetDevDescr "), 0x80); 77 | } 78 | 79 | void NotifyFailSetDevTblEntry(void) { 80 | Notify(PSTR("\r\nsetDevTblEn "), 0x80); 81 | } 82 | 83 | void NotifyFailGetConfDescr(void) { 84 | Notify(PSTR("\r\ngetConf "), 0x80); 85 | } 86 | 87 | void NotifyFailSetConfDescr(void) { 88 | Notify(PSTR("\r\nsetConf "), 0x80); 89 | } 90 | 91 | void NotifyFailGetDevDescr(uint8_t reason) { 92 | NotifyFailGetDevDescr(); 93 | NotifyFail(reason); 94 | } 95 | 96 | void NotifyFailSetDevTblEntry(uint8_t reason) { 97 | NotifyFailSetDevTblEntry(); 98 | NotifyFail(reason); 99 | 100 | } 101 | 102 | void NotifyFailGetConfDescr(uint8_t reason) { 103 | NotifyFailGetConfDescr(); 104 | NotifyFail(reason); 105 | } 106 | 107 | void NotifyFailSetConfDescr(uint8_t reason) { 108 | NotifyFailSetConfDescr(); 109 | NotifyFail(reason); 110 | } 111 | 112 | void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID) { 113 | Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80); 114 | D_PrintHex (VID, 0x80); 115 | Notify(PSTR(" PID: "), 0x80); 116 | D_PrintHex (PID, 0x80); 117 | } 118 | 119 | void NotifyFail(uint8_t rcode) { 120 | D_PrintHex (rcode, 0x80); 121 | Notify(PSTR("\r\n"), 0x80); 122 | } 123 | #endif 124 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/message.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; either version 2 of the License, or 6 | (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | Contact information 18 | ------------------- 19 | 20 | Circuits At Home, LTD 21 | Web : http://www.circuitsathome.com 22 | e-mail : support@circuitsathome.com 23 | */ 24 | #if !defined(_usb_h_) || defined(__MESSAGE_H__) 25 | #error "Never include message.h directly; include Usb.h instead" 26 | #else 27 | #define __MESSAGE_H__ 28 | 29 | extern int UsbDEBUGlvl; 30 | 31 | void E_Notify(char const * msg, int lvl); 32 | void E_Notify(uint8_t b, int lvl); 33 | void E_NotifyStr(char const * msg, int lvl); 34 | void E_Notifyc(char c, int lvl); 35 | 36 | #ifdef DEBUG_USB_HOST 37 | #define Notify E_Notify 38 | #define NotifyStr E_NotifyStr 39 | #define Notifyc E_Notifyc 40 | void NotifyFailGetDevDescr(uint8_t reason); 41 | void NotifyFailSetDevTblEntry(uint8_t reason); 42 | void NotifyFailGetConfDescr(uint8_t reason); 43 | void NotifyFailSetConfDescr(uint8_t reason); 44 | void NotifyFailGetDevDescr(void); 45 | void NotifyFailSetDevTblEntry(void); 46 | void NotifyFailGetConfDescr(void); 47 | void NotifyFailSetConfDescr(void); 48 | void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID); 49 | void NotifyFail(uint8_t rcode); 50 | #else 51 | #define Notify(...) ((void)0) 52 | #define NotifyStr(...) ((void)0) 53 | #define Notifyc(...) ((void)0) 54 | #define NotifyFailGetDevDescr(...) ((void)0) 55 | #define NotifyFailSetDevTblEntry(...) ((void)0) 56 | #define NotifyFailGetConfDescr(...) ((void)0) 57 | #define NotifyFailGetDevDescr(...) ((void)0) 58 | #define NotifyFailSetDevTblEntry(...) ((void)0) 59 | #define NotifyFailGetConfDescr(...) ((void)0) 60 | #define NotifyFailSetConfDescr(...) ((void)0) 61 | #define NotifyFailUnknownDevice(...) ((void)0) 62 | #define NotifyFail(...) ((void)0) 63 | #endif 64 | 65 | template 66 | void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) { 67 | #ifdef DEBUG_USB_HOST 68 | Notify(msg, level); 69 | Notify(PSTR(": "), level); 70 | D_PrintHex (rcode, level); 71 | Notify(PSTR("\r\n"), level); 72 | #endif 73 | } 74 | 75 | template 76 | void ErrorMessage(char const * msg __attribute__((unused)), ERROR_TYPE rcode __attribute__((unused)) = 0) { 77 | #ifdef DEBUG_USB_HOST 78 | Notify(msg, 0x80); 79 | Notify(PSTR(": "), 0x80); 80 | D_PrintHex (rcode, 0x80); 81 | Notify(PSTR("\r\n"), 0x80); 82 | #endif 83 | } 84 | 85 | #endif // __MESSAGE_H__ 86 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/parsetools.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; either version 2 of the License, or 6 | (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | Contact information 18 | ------------------- 19 | 20 | Circuits At Home, LTD 21 | Web : http://www.circuitsathome.com 22 | e-mail : support@circuitsathome.com 23 | */ 24 | #include "Usb.h" 25 | 26 | bool MultiByteValueParser::Parse(uint8_t **pp, uint16_t *pcntdn) { 27 | if(!pBuf) { 28 | Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80); 29 | return false; 30 | } 31 | for(; countDown && (*pcntdn); countDown--, (*pcntdn)--, (*pp)++) 32 | pBuf[valueSize - countDown] = (**pp); 33 | 34 | if(countDown) 35 | return false; 36 | 37 | countDown = valueSize; 38 | return true; 39 | } 40 | 41 | bool PTPListParser::Parse(uint8_t **pp, uint16_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) { 42 | switch(nStage) { 43 | case 0: 44 | pBuf->valueSize = lenSize; 45 | theParser.Initialize(pBuf); 46 | nStage = 1; 47 | 48 | case 1: 49 | if(!theParser.Parse(pp, pcntdn)) 50 | return false; 51 | 52 | arLen = 0; 53 | arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue)); 54 | arLenCntdn = arLen; 55 | nStage = 2; 56 | 57 | case 2: 58 | pBuf->valueSize = valSize; 59 | theParser.Initialize(pBuf); 60 | nStage = 3; 61 | 62 | case 3: 63 | for(; arLenCntdn; arLenCntdn--) { 64 | if(!theParser.Parse(pp, pcntdn)) 65 | return false; 66 | 67 | if(pf) 68 | pf(pBuf, (arLen - arLenCntdn), me); 69 | } 70 | 71 | nStage = 0; 72 | } 73 | return true; 74 | } 75 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/printhex.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; either version 2 of the License, or 6 | (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | 17 | Contact information 18 | ------------------- 19 | 20 | Circuits At Home, LTD 21 | Web : http://www.circuitsathome.com 22 | e-mail : support@circuitsathome.com 23 | */ 24 | 25 | #if !defined(_usb_h_) || defined(__PRINTHEX_H__) 26 | #error "Never include printhex.h directly; include Usb.h instead" 27 | #else 28 | #define __PRINTHEX_H__ 29 | 30 | void E_Notifyc(char c, int lvl); 31 | 32 | template 33 | void PrintHex(T val, int lvl) { 34 | int num_nibbles = sizeof (T) * 2; 35 | 36 | do { 37 | char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f); 38 | if(v > 57) v += 7; 39 | E_Notifyc(v, lvl); 40 | } while(--num_nibbles); 41 | } 42 | 43 | template 44 | void PrintBin(T val, int lvl) { 45 | for(T mask = (((T)1) << ((sizeof (T) << 3) - 1)); mask; mask >>= 1) 46 | if(val & mask) 47 | E_Notifyc('1', lvl); 48 | else 49 | E_Notifyc('0', lvl); 50 | } 51 | 52 | template 53 | void SerialPrintHex(T val) { 54 | int num_nibbles = sizeof (T) * 2; 55 | 56 | do { 57 | char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f); 58 | if(v > 57) v += 7; 59 | USB_HOST_SERIAL.print(v); 60 | } while(--num_nibbles); 61 | } 62 | 63 | template 64 | void PrintHex2(Print *prn, T val) { 65 | T mask = (((T)1) << (((sizeof (T) << 1) - 1) << 2)); 66 | 67 | while(mask > 1) { 68 | if(val < mask) 69 | prn->print("0"); 70 | 71 | mask >>= 4; 72 | } 73 | prn->print((T)val, HEX); 74 | } 75 | 76 | template void D_PrintHex(T val __attribute__((unused)), int lvl __attribute__((unused))) { 77 | #ifdef DEBUG_USB_HOST 78 | PrintHex (val, lvl); 79 | #endif 80 | } 81 | 82 | template 83 | void D_PrintBin(T val, int lvl) { 84 | #ifdef DEBUG_USB_HOST 85 | PrintBin (val, lvl); 86 | #endif 87 | } 88 | 89 | 90 | 91 | #endif // __PRINTHEX_H__ 92 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/sink_parser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Circuits At Home, LTD 14 | Web : http://www.circuitsathome.com 15 | e-mail : support@circuitsathome.com 16 | */ 17 | #if !defined(_usb_h_) || defined(__SINK_PARSER_H__) 18 | #error "Never include hexdump.h directly; include Usb.h instead" 19 | #else 20 | #define __SINK_PARSER_H__ 21 | 22 | extern int UsbDEBUGlvl; 23 | 24 | // This parser does absolutely nothing with the data, just swallows it. 25 | 26 | template 27 | class SinkParser : public BASE_CLASS { 28 | public: 29 | 30 | SinkParser() { 31 | }; 32 | 33 | void Initialize() { 34 | }; 35 | 36 | void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) { 37 | }; 38 | }; 39 | 40 | 41 | #endif // __HEXDUMP_H__ 42 | -------------------------------------------------------------------------------- /Libraries/USB_Host_Shield_2.0/xboxEnums.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Kristian Lauszus, TKJ Electronics 14 | Web : http://www.tkjelectronics.com 15 | e-mail : kristianl@tkjelectronics.com 16 | */ 17 | 18 | #ifndef _xboxenums_h 19 | #define _xboxenums_h 20 | 21 | #include "controllerEnums.h" 22 | 23 | /** Enum used to set special LED modes supported by the Xbox controller. */ 24 | enum LEDModeEnum { 25 | ROTATING = 0x0A, 26 | FASTBLINK = 0x0B, 27 | SLOWBLINK = 0x0C, 28 | ALTERNATING = 0x0D, 29 | }; 30 | 31 | /** Used to set the LEDs on the controllers */ 32 | const uint8_t XBOX_LEDS[] PROGMEM = { 33 | 0x00, // OFF 34 | 0x02, // LED1 35 | 0x03, // LED2 36 | 0x04, // LED3 37 | 0x05, // LED4 38 | 0x01, // ALL - Used to blink all LEDs 39 | }; 40 | /** Buttons on the controllers */ 41 | const uint16_t XBOX_BUTTONS[] PROGMEM = { 42 | 0x0100, // UP 43 | 0x0800, // RIGHT 44 | 0x0200, // DOWN 45 | 0x0400, // LEFT 46 | 47 | 0x2000, // BACK 48 | 0x1000, // START 49 | 0x4000, // L3 50 | 0x8000, // R3 51 | 52 | 0, 0, // Skip L2 and R2 as these are analog buttons 53 | 0x0001, // L1 54 | 0x0002, // R1 55 | 56 | 0x0020, // B 57 | 0x0010, // A 58 | 0x0040, // X 59 | 0x0080, // Y 60 | 61 | 0x0004, // XBOX 62 | 0x0008, // SYNC 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /Models/AmazonMotorBracket.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/AmazonMotorBracket.stl -------------------------------------------------------------------------------- /Models/FlatPackE100FootDrive/Scooter_drive_center_x2_v1.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/FlatPackE100FootDrive/Scooter_drive_center_x2_v1.stl -------------------------------------------------------------------------------- /Models/FlatPackE100FootDrive/Scooter_drive_center_x2_v2.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/FlatPackE100FootDrive/Scooter_drive_center_x2_v2.stl -------------------------------------------------------------------------------- /Models/FlatPackE100FootDrive/Scooter_drive_motor_mount.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/FlatPackE100FootDrive/Scooter_drive_motor_mount.stl -------------------------------------------------------------------------------- /Models/FlatPackE100FootDrive/Scooter_drive_side_inner.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/FlatPackE100FootDrive/Scooter_drive_side_inner.stl -------------------------------------------------------------------------------- /Models/FlatPackE100FootDrive/Scooter_drive_side_outer.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/FlatPackE100FootDrive/Scooter_drive_side_outer.stl -------------------------------------------------------------------------------- /Models/FlatPackE100FootDrive/Scooter_drive_spacers_frame.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/FlatPackE100FootDrive/Scooter_drive_spacers_frame.stl -------------------------------------------------------------------------------- /Models/FlatPackE100FootDrive/Scooter_drive_spacers_motor_mount.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/FlatPackE100FootDrive/Scooter_drive_spacers_motor_mount.stl -------------------------------------------------------------------------------- /Models/FlatPackE100FootDrive/Scooter_drive_spacers_rear_wheel.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/FlatPackE100FootDrive/Scooter_drive_spacers_rear_wheel.stl -------------------------------------------------------------------------------- /Models/LockingStrip1_0.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/LockingStrip1_0.stl -------------------------------------------------------------------------------- /Models/LockingStrip1_1.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/LockingStrip1_1.stl -------------------------------------------------------------------------------- /Models/LockingStrip1_2.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/LockingStrip1_2.stl -------------------------------------------------------------------------------- /Models/LockingStrip1_3.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/LockingStrip1_3.stl -------------------------------------------------------------------------------- /Models/RingGear_77_0.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/RingGear_77_0.stl -------------------------------------------------------------------------------- /Models/RingGear_77_1.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/RingGear_77_1.stl -------------------------------------------------------------------------------- /Models/RingGear_77_2.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/RingGear_77_2.stl -------------------------------------------------------------------------------- /Models/RingGear_77_3.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/RingGear_77_3.stl -------------------------------------------------------------------------------- /Models/RingGear_77_4.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/RingGear_77_4.stl -------------------------------------------------------------------------------- /Models/RingGear_77_5.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/RingGear_77_5.stl -------------------------------------------------------------------------------- /Models/RingGear_77_6.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/RingGear_77_6.stl -------------------------------------------------------------------------------- /Models/RingGear_77_7.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/RingGear_77_7.stl -------------------------------------------------------------------------------- /Models/RingGear_77_8.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/RingGear_77_8.stl -------------------------------------------------------------------------------- /Models/battery_mount.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/battery_mount.stl -------------------------------------------------------------------------------- /Models/body_electronics_mount_center.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/body_electronics_mount_center.stl -------------------------------------------------------------------------------- /Models/body_electronics_mount_left.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/body_electronics_mount_left.stl -------------------------------------------------------------------------------- /Models/body_electronics_mount_right.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/body_electronics_mount_right.stl -------------------------------------------------------------------------------- /Models/buck_converter_mount.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/buck_converter_mount.stl -------------------------------------------------------------------------------- /Models/dome_adapter_with_platform.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/dome_adapter_with_platform.stl -------------------------------------------------------------------------------- /Models/dome_electronics_holder.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/dome_electronics_holder.stl -------------------------------------------------------------------------------- /Models/eye_neo_holder .stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/eye_neo_holder .stl -------------------------------------------------------------------------------- /Models/leg_lock_v3.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/leg_lock_v3.stl -------------------------------------------------------------------------------- /Models/motor gear_77.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/motor gear_77.stl -------------------------------------------------------------------------------- /Models/new_wheel_mount.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/new_wheel_mount.stl -------------------------------------------------------------------------------- /Models/power_bar_holder.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/power_bar_holder.stl -------------------------------------------------------------------------------- /Models/speaker_body.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/speaker_body.stl -------------------------------------------------------------------------------- /Models/speaker_mount.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/speaker_mount.stl -------------------------------------------------------------------------------- /Models/strong_wheel_mount.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/strong_wheel_mount.stl -------------------------------------------------------------------------------- /Models/strong_wood_mount_back.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/strong_wood_mount_back.stl -------------------------------------------------------------------------------- /Models/strong_wood_mount_front.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/strong_wood_mount_front.stl -------------------------------------------------------------------------------- /Models/switch_housing.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/switch_housing.stl -------------------------------------------------------------------------------- /Models/voltage_holder.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Models/voltage_holder.stl -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Arduino Astromech Control System 2 | This has grown and is now full blown electronic package for dome rotation, sound, and motion based off Padawan360 (https://github.com/dankraus/padawan360) 3 | 4 | Wiring Overview: 5 | ![wiring](https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/master/body_wiring.png) 6 | 7 | I'm using the following components for Chopper: 8 | 9 | Dome Lights: 10 | * Arduino Nano: https://www.amazon.com/gp/product/B0713XK923 11 | * 3 Individual Neopixels: https://www.amazon.com/kuman-WS2812B-Addressable-Arduino-littlergb/dp/B01M5BEO1C 12 | * Two neopixel sticks: https://www.amazon.com/ACROBOTIC-8-Pixel-Addressable-24-Bit-WS2812B/dp/B07BF7TG6Z 13 | 14 | Brain: 15 | * Arduino Mega: https://www.amazon.com/gp/product/B01H4ZLZLQ 16 | * USB Shield: https://www.amazon.com/gp/product/B0777DR3T6 17 | * Xbox USB Receiver: https://www.amazon.com/gp/product/B00FAS1WDG 18 | 19 | Audio: 20 | * Adafruit Audio FX Board: https://www.amazon.com/gp/product/B00Q3U42DM 21 | * Pyle 3.5” Inch Two Way: https://www.amazon.com/gp/product/B0007L8BT4 22 | * Lepy 808 Amplifier: https://www.amazon.com/gp/product/B00OGZW54E 23 | 24 | Dome Rotation: 25 | * Lazy Susan: https://www.amazon.com/gp/product/B071FL5QR3 26 | * Cytron Motor Controller: https://www.amazon.com/gp/product/B01M6ATGO4 27 | * Uxcell dome motor: https://www.amazon.com/gp/product/B01KTZXVMO 28 | 29 | Foot Drive: 30 | * Sabertooth 32A: https://www.amazon.com/gp/product/B00O1722NG 31 | 32 | Two locally sourced Razor E100 scooters 33 | 34 | Main Power: https://hobbyking.com/en_us/multistar-high-capacity-4s-10000mah-multi-rotor-lipo-pack.html 35 | 36 | I bought two of those lipos if I need to combine them for more time. or voltage 37 | 38 | Misc Components: 39 | * 20A Switches: https://www.amazon.com/gp/product/B012MYRB4E 40 | * Fuse Box: https://www.amazon.com/gp/product/B074XS89H5 41 | * Voltage Monitors: https://www.amazon.com/gp/product/B00YALUXH0 42 | * 12A buck converter: https://www.amazon.com/gp/product/B071CWMRYD 43 | * 60A Circuit Breaker: https://www.amazon.com/gp/product/B06Y5279ZH 44 | * Wago 221: https://www.amazon.com/gp/product/B01N0LRTXZ 45 | 46 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/Q4jPT27Jjtw/0.jpg)](https://www.youtube.com/watch?v=Q4jPT27Jjtw "Arduino Dome Rotation Controller") 47 | -------------------------------------------------------------------------------- /Robotics Meeting Chopper Presentation 7-21-18.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/Robotics Meeting Chopper Presentation 7-21-18.pdf -------------------------------------------------------------------------------- /body_wiring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/body_wiring.png -------------------------------------------------------------------------------- /chopper_board_back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/chopper_board_back.jpg -------------------------------------------------------------------------------- /chopper_board_front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/chopper_board_front.jpg -------------------------------------------------------------------------------- /chopper_wiring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CountDeMonet/ArduinoAstromechControlSystem/3f8bfa6ed3412cfb42386e2f84fe7418d3ada279/chopper_wiring.png --------------------------------------------------------------------------------