Download libraries/Adafruit_Circuit_Playground/utility/CP_Firmata.h from Beifengdo/Arduino-Development: direct link, hf CLI and curl.
- Browser
- Download file 10.4 kB
-
https://huggingface.co/datasets/Beifengdo/Arduino-Development/resolve/main/libraries/Adafruit_Circuit_Playground/utility/CP_Firmata.h
- Command line
-
hf download hf://datasets/Beifengdo/Arduino-Development/libraries/Adafruit_Circuit_Playground/utility/CP_Firmata.h
-
curl -L -o CP_Firmata.h https://huggingface.co/datasets/Beifengdo/Arduino-Development/resolve/main/libraries/Adafruit_Circuit_Playground/utility/CP_Firmata.h
10.4 kB
| /* | |
| Firmata.h - Firmata library v2.5.3 - 2016-06-18 | |
| Copyright (c) 2006-2008 Hans-Christoph Steiner. All rights reserved. | |
| Copyright (C) 2009-2015 Jeff Hoefs. All rights reserved. | |
| This library is free software; you can redistribute it and/or | |
| modify it under the terms of the GNU Lesser General Public | |
| License as published by the Free Software Foundation; either | |
| version 2.1 of the License, or (at your option) any later version. | |
| See file LICENSE.txt for further informations on licensing terms. | |
| */ | |
| /* Version numbers for the protocol. The protocol is still changing, so these | |
| * version numbers are important. | |
| * Query using the REPORT_VERSION message. | |
| */ | |
| /* Version numbers for the Firmata library. | |
| * The firmware version will not always equal the protocol version going forward. | |
| * Query using the REPORT_FIRMWARE message. | |
| */ | |
| /* DEPRECATED as of Firmata v2.5.1. As of 2.5.1 there are separate version numbers for | |
| * the protocol version and the firmware version. | |
| */ | |
| // Arduino 101 also defines SET_PIN_MODE as a macro in scss_registers.h | |
| // message command bytes (128-255/0x80-0xFF) | |
| // | |
| // | |
| // | |
| // extended command set using sysex (0-127/0x00-0x7F) | |
| /* 0x00-0x0F reserved for user-defined commands */ | |
| // these are DEPRECATED to make the naming more consistent | |
| // pin modes | |
| //#define INPUT 0x00 // defined in Arduino.h | |
| //#define OUTPUT 0x01 // defined in Arduino.h | |
| // DEPRECATED as of Firmata v2.5 | |
| extern "C" { | |
| // callback function types | |
| typedef void (*callbackFunction)(byte, int); | |
| typedef void (*systemResetCallbackFunction)(void); | |
| typedef void (*stringCallbackFunction)(char *); | |
| typedef void (*sysexCallbackFunction)(byte command, byte argc, byte *argv); | |
| } | |
| // TODO make it a subclass of a generic Serial/Stream base class | |
| class FirmataClass | |
| { | |
| public: | |
| FirmataClass(); | |
| /* Arduino constructors */ | |
| void begin(); | |
| void begin(long); | |
| void begin(Stream &s); | |
| /* querying functions */ | |
| void printVersion(void); | |
| void blinkVersion(void); | |
| void printFirmwareVersion(void); | |
| //void setFirmwareVersion(byte major, byte minor); // see macro below | |
| void setFirmwareNameAndVersion(const char *name, byte major, byte minor); | |
| void disableBlinkVersion(); | |
| /* serial receive handling */ | |
| int available(void); | |
| void processInput(void); | |
| void parse(unsigned char value); | |
| boolean isParsingMessage(void); | |
| /* serial send handling */ | |
| void sendAnalog(byte pin, int value); | |
| void sendDigital(byte pin, int value); // TODO implement this | |
| void sendDigitalPort(byte portNumber, int portData); | |
| void sendString(const char *string); | |
| void sendString(byte command, const char *string); | |
| void sendSysex(byte command, byte bytec, byte *bytev); | |
| void write(byte c); | |
| /* attach & detach callback functions to messages */ | |
| void attach(byte command, callbackFunction newFunction); | |
| void attach(byte command, systemResetCallbackFunction newFunction); | |
| void attach(byte command, stringCallbackFunction newFunction); | |
| void attach(byte command, sysexCallbackFunction newFunction); | |
| void detach(byte command); | |
| /* access pin state and config */ | |
| byte getPinMode(byte pin); | |
| void setPinMode(byte pin, byte config); | |
| /* access pin state */ | |
| int getPinState(byte pin); | |
| void setPinState(byte pin, int state); | |
| /* utility methods */ | |
| void sendValueAsTwo7bitBytes(int value); | |
| void startSysex(void); | |
| void endSysex(void); | |
| private: | |
| Stream *FirmataStream; | |
| /* firmware name and version */ | |
| byte firmwareVersionCount; | |
| byte *firmwareVersionVector; | |
| /* input message handling */ | |
| byte waitForData; // this flag says the next serial input will be data | |
| byte executeMultiByteCommand; // execute this after getting multi-byte data | |
| byte multiByteChannel; // channel data for multiByteCommands | |
| byte storedInputData[MAX_DATA_BYTES]; // multi-byte data | |
| /* sysex */ | |
| boolean parsingSysex; | |
| int sysexBytesRead; | |
| /* pin configuration */ | |
| byte pinConfig[TOTAL_PINS]; | |
| int pinState[TOTAL_PINS]; | |
| /* callback functions */ | |
| callbackFunction currentAnalogCallback; | |
| callbackFunction currentDigitalCallback; | |
| callbackFunction currentReportAnalogCallback; | |
| callbackFunction currentReportDigitalCallback; | |
| callbackFunction currentPinModeCallback; | |
| callbackFunction currentPinValueCallback; | |
| systemResetCallbackFunction currentSystemResetCallback; | |
| stringCallbackFunction currentStringCallback; | |
| sysexCallbackFunction currentSysexCallback; | |
| boolean blinkVersionDisabled; | |
| /* private methods ------------------------------ */ | |
| void processSysexMessage(void); | |
| void systemReset(void); | |
| void strobeBlinkPin(byte pin, int count, int onInterval, int offInterval); | |
| }; | |
| extern FirmataClass Firmata; | |
| /*============================================================================== | |
| * MACROS | |
| *============================================================================*/ | |
| /* shortcut for setFirmwareNameAndVersion() that uses __FILE__ to set the | |
| * firmware name. It needs to be a macro so that __FILE__ is included in the | |
| * firmware source file rather than the library source file. | |
| */ | |