diff --git a/lib/Adafruit NeoPixel/.github/ISSUE_TEMPLATE.md b/lib/Adafruit NeoPixel/.github/ISSUE_TEMPLATE.md
deleted file mode 100644
index f0e26146f..000000000
--- a/lib/Adafruit NeoPixel/.github/ISSUE_TEMPLATE.md
+++ /dev/null
@@ -1,46 +0,0 @@
-Thank you for opening an issue on an Adafruit Arduino library repository. To
-improve the speed of resolution please review the following guidelines and
-common troubleshooting steps below before creating the issue:
-
-- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
- the forums at http://forums.adafruit.com to ask questions and troubleshoot why
- something isn't working as expected. In many cases the problem is a common issue
- that you will more quickly receive help from the forum community. GitHub issues
- are meant for known defects in the code. If you don't know if there is a defect
- in the code then start with troubleshooting on the forum first.
-
-- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
- check all of the steps and commands to run have been followed. Consult the
- forum if you're unsure or have questions about steps in a guide/tutorial.
-
-- **For Arduino projects check these very common issues to ensure they don't apply**:
-
- - For uploading sketches or communicating with the board make sure you're using
- a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
- very hard to tell the difference between a data and charge cable! Try using the
- cable with other devices or swapping to another cable to confirm it is not
- the problem.
-
- - **Be sure you are supplying adequate power to the board.** Check the specs of
- your board and plug in an external power supply. In many cases just
- plugging a board into your computer is not enough to power it and other
- peripherals.
-
- - **Double check all soldering joints and connections.** Flakey connections
- 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.
-
- - **Ensure you are using an official Arduino or Adafruit board.** We can't
- guarantee a clone board will have the same functionality and work as expected
- with this code and don't support them.
-
-If you're sure this issue is a defect in the code and checked the steps above
-please fill in the following fields to provide enough troubleshooting information.
-You may delete the guideline and text above to just leave the following details:
-
-- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
-
-- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
- VERSION HERE**
-
-- List the steps to reproduce the problem below (if possible attach a sketch or
- copy the sketch code in too): **LIST REPRO STEPS BELOW**
diff --git a/lib/Adafruit NeoPixel/.github/PULL_REQUEST_TEMPLATE.md b/lib/Adafruit NeoPixel/.github/PULL_REQUEST_TEMPLATE.md
deleted file mode 100644
index 7b641eb86..000000000
--- a/lib/Adafruit NeoPixel/.github/PULL_REQUEST_TEMPLATE.md
+++ /dev/null
@@ -1,26 +0,0 @@
-Thank you for creating a pull request to contribute to Adafruit's GitHub code!
-Before you open the request please review the following guidelines and tips to
-help it be more easily integrated:
-
-- **Describe the scope of your change--i.e. what the change does and what parts
- of the code were modified.** This will help us understand any risks of integrating
- the code.
-
-- **Describe any known limitations with your change.** For example if the change
- doesn't apply to a supported platform of the library please mention it.
-
-- **Please run any tests or examples that can exercise your modified code.** We
- strive to not break users of the code and running tests/examples helps with this
- process.
-
-Thank you again for contributing! We will try to test and integrate the change
-as soon as we can, but be aware we have many GitHub repositories to manage and
-can't immediately respond to every request. There is no need to bump or check in
-on a pull request (it will clutter the discussion of the request).
-
-Also don't be worried if the request is closed or not integrated--sometimes the
-priorities of Adafruit's GitHub code (education, ease of use) might not match the
-priorities of the pull request. Don't fret, the open source community thrives on
-forks and GitHub makes it easy to keep your changes in a forked repo.
-
-After reviewing the guidelines above you can delete this text from the pull request.
diff --git a/lib/Adafruit NeoPixel/.github/workflows/githubci.yml b/lib/Adafruit NeoPixel/.github/workflows/githubci.yml
deleted file mode 100644
index 2ff3d6547..000000000
--- a/lib/Adafruit NeoPixel/.github/workflows/githubci.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-name: Arduino Library CI
-
-on: [pull_request, push, repository_dispatch]
-
-jobs:
- build:
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/setup-python@v1
- with:
- python-version: '3.x'
- - uses: actions/checkout@v2
- - uses: actions/checkout@v2
- with:
- repository: adafruit/ci-arduino
- path: ci
-
- - name: pre-install
- run: bash ci/actions_install.sh
-
- - name: test platforms
- run: python3 ci/build_platform.py main_platforms
-
- - name: doxygen
- env:
- GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
- PRETTYNAME : "Adafruit NeoPixel Library"
- run: bash ci/doxy_gen_and_deploy.sh
diff --git a/lib/Adafruit NeoPixel/.gitignore b/lib/Adafruit NeoPixel/.gitignore
deleted file mode 100644
index c2a26c038..000000000
--- a/lib/Adafruit NeoPixel/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-# Our handy .gitignore for automation ease
-Doxyfile*
-doxygen_sqlite3.db
-html
diff --git a/lib/Adafruit NeoPixel/Adafruit_NeoPixel.cpp b/lib/Adafruit NeoPixel/Adafruit_NeoPixel.cpp
deleted file mode 100644
index 62bfa621a..000000000
--- a/lib/Adafruit NeoPixel/Adafruit_NeoPixel.cpp
+++ /dev/null
@@ -1,3441 +0,0 @@
-/*!
- * @file Adafruit_NeoPixel.cpp
- *
- * @mainpage Arduino Library for driving Adafruit NeoPixel addressable LEDs,
- * FLORA RGB Smart Pixels and compatible devicess -- WS2811, WS2812, WS2812B,
- * SK6812, etc.
- *
- * @section intro_sec Introduction
- *
- * This is the documentation for Adafruit's NeoPixel library for the
- * Arduino platform, allowing a broad range of microcontroller boards
- * (most AVR boards, many ARM devices, ESP8266 and ESP32, among others)
- * to control Adafruit NeoPixels, FLORA RGB Smart Pixels and compatible
- * devices -- WS2811, WS2812, WS2812B, SK6812, etc.
- *
- * Adafruit invests time and resources providing this open source code,
- * please support Adafruit and open-source hardware by purchasing products
- * from Adafruit!
- *
- * @section author Author
- *
- * Written by Phil "Paint Your Dragon" Burgess for Adafruit Industries,
- * with contributions by PJRC, Michael Miller and other members of the
- * open source community.
- *
- * @section license License
- *
- * This file is part of the Adafruit_NeoPixel library.
- *
- * Adafruit_NeoPixel 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 3 of the
- * License, or (at your option) any later version.
- *
- * Adafruit_NeoPixel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with NeoPixel. If not, see
- * .
- *
- */
-
-#include "Adafruit_NeoPixel.h"
-
-#if defined(TARGET_LPC1768)
-#include
-#endif
-
-#if defined(NRF52) || defined(NRF52_SERIES)
-#include "nrf.h"
-
-// Interrupt is only disabled if there is no PWM device available
-// Note: Adafruit Bluefruit nrf52 does not use this option
-//#define NRF52_DISABLE_INT
-#endif
-
-#if defined(ARDUINO_ARCH_NRF52840)
-#if defined __has_include
-#if __has_include()
-#include
-#endif
-#endif
-#endif
-
-/*!
- @brief NeoPixel constructor when length, pin and pixel type are known
- at compile-time.
- @param n Number of NeoPixels in strand.
- @param p Arduino pin number which will drive the NeoPixel data in.
- @param t Pixel type -- add together NEO_* constants defined in
- Adafruit_NeoPixel.h, for example NEO_GRB+NEO_KHZ800 for
- NeoPixels expecting an 800 KHz (vs 400 KHz) data stream
- with color bytes expressed in green, red, blue order per
- pixel.
- @return Adafruit_NeoPixel object. Call the begin() function before use.
-*/
-Adafruit_NeoPixel::Adafruit_NeoPixel(uint16_t n, int16_t p, neoPixelType t)
- : begun(false), brightness(0), pixels(NULL), endTime(0) {
- updateType(t);
- updateLength(n);
- setPin(p);
-#if defined(ARDUINO_ARCH_RP2040)
- // Find a free SM on one of the PIO's
- sm = pio_claim_unused_sm(pio, false); // don't panic
- // Try pio1 if SM not found
- if (sm < 0) {
- pio = pio1;
- sm = pio_claim_unused_sm(pio, true); // panic if no SM is free
- }
- init = true;
-#endif
-}
-
-/*!
- @brief "Empty" NeoPixel constructor when length, pin and/or pixel type
- are not known at compile-time, and must be initialized later with
- updateType(), updateLength() and setPin().
- @return Adafruit_NeoPixel object. Call the begin() function before use.
- @note This function is deprecated, here only for old projects that
- may still be calling it. New projects should instead use the
- 'new' keyword with the first constructor syntax (length, pin,
- type).
-*/
-Adafruit_NeoPixel::Adafruit_NeoPixel()
- :
-#if defined(NEO_KHZ400)
- is800KHz(true),
-#endif
- begun(false), numLEDs(0), numBytes(0), pin(-1), brightness(0),
- pixels(NULL), rOffset(1), gOffset(0), bOffset(2), wOffset(1), endTime(0) {
-}
-
-/*!
- @brief Deallocate Adafruit_NeoPixel object, set data pin back to INPUT.
-*/
-Adafruit_NeoPixel::~Adafruit_NeoPixel() {
- free(pixels);
- if (pin >= 0)
- pinMode(pin, INPUT);
-}
-
-/*!
- @brief Configure NeoPixel pin for output.
-*/
-void Adafruit_NeoPixel::begin(void) {
- if (pin >= 0) {
- pinMode(pin, OUTPUT);
- digitalWrite(pin, LOW);
- }
- begun = true;
-}
-
-/*!
- @brief Change the length of a previously-declared Adafruit_NeoPixel
- strip object. Old data is deallocated and new data is cleared.
- Pin number and pixel format are unchanged.
- @param n New length of strip, in pixels.
- @note This function is deprecated, here only for old projects that
- may still be calling it. New projects should instead use the
- 'new' keyword with the first constructor syntax (length, pin,
- type).
-*/
-void Adafruit_NeoPixel::updateLength(uint16_t n) {
- free(pixels); // Free existing data (if any)
-
- // Allocate new data -- note: ALL PIXELS ARE CLEARED
- numBytes = n * ((wOffset == rOffset) ? 3 : 4);
- if ((pixels = (uint8_t *)malloc(numBytes))) {
- memset(pixels, 0, numBytes);
- numLEDs = n;
- } else {
- numLEDs = numBytes = 0;
- }
-}
-
-/*!
- @brief Change the pixel format of a previously-declared
- Adafruit_NeoPixel strip object. If format changes from one of
- the RGB variants to an RGBW variant (or RGBW to RGB), the old
- data will be deallocated and new data is cleared. Otherwise,
- the old data will remain in RAM and is not reordered to the
- new format, so it's advisable to follow up with clear().
- @param t Pixel type -- add together NEO_* constants defined in
- Adafruit_NeoPixel.h, for example NEO_GRB+NEO_KHZ800 for
- NeoPixels expecting an 800 KHz (vs 400 KHz) data stream
- with color bytes expressed in green, red, blue order per
- pixel.
- @note This function is deprecated, here only for old projects that
- may still be calling it. New projects should instead use the
- 'new' keyword with the first constructor syntax
- (length, pin, type).
-*/
-void Adafruit_NeoPixel::updateType(neoPixelType t) {
- bool oldThreeBytesPerPixel = (wOffset == rOffset); // false if RGBW
-
- wOffset = (t >> 6) & 0b11; // See notes in header file
- rOffset = (t >> 4) & 0b11; // regarding R/G/B/W offsets
- gOffset = (t >> 2) & 0b11;
- bOffset = t & 0b11;
-#if defined(NEO_KHZ400)
- is800KHz = (t < 256); // 400 KHz flag is 1<<8
-#endif
-
- // If bytes-per-pixel has changed (and pixel data was previously
- // allocated), re-allocate to new size. Will clear any data.
- if (pixels) {
- bool newThreeBytesPerPixel = (wOffset == rOffset);
- if (newThreeBytesPerPixel != oldThreeBytesPerPixel)
- updateLength(numLEDs);
- }
-}
-
-// RP2040 specific driver
-#if defined(ARDUINO_ARCH_RP2040)
-void Adafruit_NeoPixel::rp2040Init(uint8_t pin, bool is800KHz)
-{
- uint offset = pio_add_program(pio, &ws2812_program);
-
- if (is800KHz)
- {
- // 800kHz, 8 bit transfers
- ws2812_program_init(pio, sm, offset, pin, 800000, 8);
- }
- else
- {
- // 400kHz, 8 bit transfers
- ws2812_program_init(pio, sm, offset, pin, 400000, 8);
- }
-}
-// Not a user API
-void Adafruit_NeoPixel::rp2040Show(uint8_t pin, uint8_t *pixels, uint32_t numBytes, bool is800KHz)
-{
- if (this->init)
- {
- // On first pass through initialise the PIO
- rp2040Init(pin, is800KHz);
- this->init = false;
- }
-
- while(numBytes--)
- // Bits for transmission must be shifted to top 8 bits
- pio_sm_put_blocking(pio, sm, ((uint32_t)*pixels++)<< 24);
-}
-
-#endif
-
-#if defined(ESP8266)
-// ESP8266 show() is external to enforce ICACHE_RAM_ATTR execution
-extern "C" IRAM_ATTR void espShow(uint16_t pin, uint8_t *pixels,
- uint32_t numBytes, uint8_t type);
-#elif defined(ESP32)
-extern "C" void espShow(uint16_t pin, uint8_t *pixels, uint32_t numBytes,
- uint8_t type);
-#endif // ESP8266
-
-#if defined(K210)
-#define KENDRYTE_K210 1
-#endif
-
-#if defined(KENDRYTE_K210)
-extern "C" void k210Show(uint8_t pin, uint8_t *pixels, uint32_t numBytes,
- boolean is800KHz);
-#endif // KENDRYTE_K210
-/*!
- @brief Transmit pixel data in RAM to NeoPixels.
- @note On most architectures, interrupts are temporarily disabled in
- order to achieve the correct NeoPixel signal timing. This means
- that the Arduino millis() and micros() functions, which require
- interrupts, will lose small intervals of time whenever this
- function is called (about 30 microseconds per RGB pixel, 40 for
- RGBW pixels). There's no easy fix for this, but a few
- specialized alternative or companion libraries exist that use
- very device-specific peripherals to work around it.
-*/
-void Adafruit_NeoPixel::show(void) {
-
- if (!pixels)
- return;
-
- // Data latch = 300+ microsecond pause in the output stream. Rather than
- // put a delay at the end of the function, the ending time is noted and
- // the function will simply hold off (if needed) on issuing the
- // subsequent round of data until the latch time has elapsed. This
- // allows the mainline code to start generating the next frame of data
- // rather than stalling for the latch.
- while (!canShow())
- ;
- // endTime is a private member (rather than global var) so that multiple
- // instances on different pins can be quickly issued in succession (each
- // instance doesn't delay the next).
-
- // In order to make this code runtime-configurable to work with any pin,
- // SBI/CBI instructions are eschewed in favor of full PORT writes via the
- // OUT or ST instructions. It relies on two facts: that peripheral
- // functions (such as PWM) take precedence on output pins, so our PORT-
- // wide writes won't interfere, and that interrupts are globally disabled
- // while data is being issued to the LEDs, so no other code will be
- // accessing the PORT. The code takes an initial 'snapshot' of the PORT
- // state, computes 'pin high' and 'pin low' values, and writes these back
- // to the PORT register as needed.
-
- // NRF52 may use PWM + DMA (if available), may not need to disable interrupt
- // ESP32 may not disable interrupts because espShow() uses RMT which tries to acquire locks
-#if !(defined(NRF52) || defined(NRF52_SERIES) || defined(ESP32))
- noInterrupts(); // Need 100% focus on instruction timing
-#endif
-
-#if defined(__AVR__)
- // AVR MCUs -- ATmega & ATtiny (no XMEGA) ---------------------------------
-
- volatile uint16_t i = numBytes; // Loop counter
- volatile uint8_t *ptr = pixels, // Pointer to next byte
- b = *ptr++, // Current byte value
- hi, // PORT w/output bit set high
- lo; // PORT w/output bit set low
-
- // Hand-tuned assembly code issues data to the LED drivers at a specific
- // rate. There's separate code for different CPU speeds (8, 12, 16 MHz)
- // for both the WS2811 (400 KHz) and WS2812 (800 KHz) drivers. The
- // datastream timing for the LED drivers allows a little wiggle room each
- // way (listed in the datasheets), so the conditions for compiling each
- // case are set up for a range of frequencies rather than just the exact
- // 8, 12 or 16 MHz values, permitting use with some close-but-not-spot-on
- // devices (e.g. 16.5 MHz DigiSpark). The ranges were arrived at based
- // on the datasheet figures and have not been extensively tested outside
- // the canonical 8/12/16 MHz speeds; there's no guarantee these will work
- // close to the extremes (or possibly they could be pushed further).
- // Keep in mind only one CPU speed case actually gets compiled; the
- // resulting program isn't as massive as it might look from source here.
-
-// 8 MHz(ish) AVR ---------------------------------------------------------
-#if (F_CPU >= 7400000UL) && (F_CPU <= 9500000UL)
-
-#if defined(NEO_KHZ400) // 800 KHz check needed only if 400 KHz support enabled
- if (is800KHz) {
-#endif
-
- volatile uint8_t n1, n2 = 0; // First, next bits out
-
- // Squeezing an 800 KHz stream out of an 8 MHz chip requires code
- // specific to each PORT register.
-
- // 10 instruction clocks per bit: HHxxxxxLLL
- // OUT instructions: ^ ^ ^ (T=0,2,7)
-
- // PORTD OUTPUT ----------------------------------------------------
-
-#if defined(PORTD)
-#if defined(PORTB) || defined(PORTC) || defined(PORTF)
- if (port == &PORTD) {
-#endif // defined(PORTB/C/F)
-
- hi = PORTD | pinMask;
- lo = PORTD & ~pinMask;
- n1 = lo;
- if (b & 0x80)
- n1 = hi;
-
- // Dirty trick: RJMPs proceeding to the next instruction are used
- // to delay two clock cycles in one instruction word (rather than
- // using two NOPs). This was necessary in order to squeeze the
- // loop down to exactly 64 words -- the maximum possible for a
- // relative branch.
-
- asm volatile(
- "headD:"
- "\n\t" // Clk Pseudocode
- // Bit 7:
- "out %[port] , %[hi]"
- "\n\t" // 1 PORT = hi
- "mov %[n2] , %[lo]"
- "\n\t" // 1 n2 = lo
- "out %[port] , %[n1]"
- "\n\t" // 1 PORT = n1
- "rjmp .+0"
- "\n\t" // 2 nop nop
- "sbrc %[byte] , 6"
- "\n\t" // 1-2 if(b & 0x40)
- "mov %[n2] , %[hi]"
- "\n\t" // 0-1 n2 = hi
- "out %[port] , %[lo]"
- "\n\t" // 1 PORT = lo
- "rjmp .+0"
- "\n\t" // 2 nop nop
- // Bit 6:
- "out %[port] , %[hi]"
- "\n\t" // 1 PORT = hi
- "mov %[n1] , %[lo]"
- "\n\t" // 1 n1 = lo
- "out %[port] , %[n2]"
- "\n\t" // 1 PORT = n2
- "rjmp .+0"
- "\n\t" // 2 nop nop
- "sbrc %[byte] , 5"
- "\n\t" // 1-2 if(b & 0x20)
- "mov %[n1] , %[hi]"
- "\n\t" // 0-1 n1 = hi
- "out %[port] , %[lo]"
- "\n\t" // 1 PORT = lo
- "rjmp .+0"
- "\n\t" // 2 nop nop
- // Bit 5:
- "out %[port] , %[hi]"
- "\n\t" // 1 PORT = hi
- "mov %[n2] , %[lo]"
- "\n\t" // 1 n2 = lo
- "out %[port] , %[n1]"
- "\n\t" // 1 PORT = n1
- "rjmp .+0"
- "\n\t" // 2 nop nop
- "sbrc %[byte] , 4"
- "\n\t" // 1-2 if(b & 0x10)
- "mov %[n2] , %[hi]"
- "\n\t" // 0-1 n2 = hi
- "out %[port] , %[lo]"
- "\n\t" // 1 PORT = lo
- "rjmp .+0"
- "\n\t" // 2 nop nop
- // Bit 4:
- "out %[port] , %[hi]"
- "\n\t" // 1 PORT = hi
- "mov %[n1] , %[lo]"
- "\n\t" // 1 n1 = lo
- "out %[port] , %[n2]"
- "\n\t" // 1 PORT = n2
- "rjmp .+0"
- "\n\t" // 2 nop nop
- "sbrc %[byte] , 3"
- "\n\t" // 1-2 if(b & 0x08)
- "mov %[n1] , %[hi]"
- "\n\t" // 0-1 n1 = hi
- "out %[port] , %[lo]"
- "\n\t" // 1 PORT = lo
- "rjmp .+0"
- "\n\t" // 2 nop nop
- // Bit 3:
- "out %[port] , %[hi]"
- "\n\t" // 1 PORT = hi
- "mov %[n2] , %[lo]"
- "\n\t" // 1 n2 = lo
- "out %[port] , %[n1]"
- "\n\t" // 1 PORT = n1
- "rjmp .+0"
- "\n\t" // 2 nop nop
- "sbrc %[byte] , 2"
- "\n\t" // 1-2 if(b & 0x04)
- "mov %[n2] , %[hi]"
- "\n\t" // 0-1 n2 = hi
- "out %[port] , %[lo]"
- "\n\t" // 1 PORT = lo
- "rjmp .+0"
- "\n\t" // 2 nop nop
- // Bit 2:
- "out %[port] , %[hi]"
- "\n\t" // 1 PORT = hi
- "mov %[n1] , %[lo]"
- "\n\t" // 1 n1 = lo
- "out %[port] , %[n2]"
- "\n\t" // 1 PORT = n2
- "rjmp .+0"
- "\n\t" // 2 nop nop
- "sbrc %[byte] , 1"
- "\n\t" // 1-2 if(b & 0x02)
- "mov %[n1] , %[hi]"
- "\n\t" // 0-1 n1 = hi
- "out %[port] , %[lo]"
- "\n\t" // 1 PORT = lo
- "rjmp .+0"
- "\n\t" // 2 nop nop
- // Bit 1:
- "out %[port] , %[hi]"
- "\n\t" // 1 PORT = hi
- "mov %[n2] , %[lo]"
- "\n\t" // 1 n2 = lo
- "out %[port] , %[n1]"
- "\n\t" // 1 PORT = n1
- "rjmp .+0"
- "\n\t" // 2 nop nop
- "sbrc %[byte] , 0"
- "\n\t" // 1-2 if(b & 0x01)
- "mov %[n2] , %[hi]"
- "\n\t" // 0-1 n2 = hi
- "out %[port] , %[lo]"
- "\n\t" // 1 PORT = lo
- "sbiw %[count], 1"
- "\n\t" // 2 i-- (don't act on Z flag yet)
- // Bit 0:
- "out %[port] , %[hi]"
- "\n\t" // 1 PORT = hi
- "mov %[n1] , %[lo]"
- "\n\t" // 1 n1 = lo
- "out %[port] , %[n2]"
- "\n\t" // 1 PORT = n2
- "ld %[byte] , %a[ptr]+"
- "\n\t" // 2 b = *ptr++
- "sbrc %[byte] , 7"
- "\n\t" // 1-2 if(b & 0x80)
- "mov %[n1] , %[hi]"
- "\n\t" // 0-1 n1 = hi
- "out %[port] , %[lo]"
- "\n\t" // 1 PORT = lo
- "brne headD"
- "\n" // 2 while(i) (Z flag set above)
- : [byte] "+r"(b), [n1] "+r"(n1), [n2] "+r"(n2), [count] "+w"(i)
- : [port] "I"(_SFR_IO_ADDR(PORTD)), [ptr] "e"(ptr), [hi] "r"(hi),
- [lo] "r"(lo));
-
-#if defined(PORTB) || defined(PORTC) || defined(PORTF)
- } else // other PORT(s)
-#endif // defined(PORTB/C/F)
-#endif // defined(PORTD)
-
- // PORTB OUTPUT ----------------------------------------------------
-
-#if defined(PORTB)
-#if defined(PORTD) || defined(PORTC) || defined(PORTF)
- if (port == &PORTB) {
-#endif // defined(PORTD/C/F)
-
- // Same as above, just switched to PORTB and stripped of comments.
- hi = PORTB | pinMask;
- lo = PORTB & ~pinMask;
- n1 = lo;
- if (b & 0x80)
- n1 = hi;
-
- asm volatile(
- "headB:"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n2] , %[lo]"
- "\n\t"
- "out %[port] , %[n1]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 6"
- "\n\t"
- "mov %[n2] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n1] , %[lo]"
- "\n\t"
- "out %[port] , %[n2]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 5"
- "\n\t"
- "mov %[n1] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n2] , %[lo]"
- "\n\t"
- "out %[port] , %[n1]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 4"
- "\n\t"
- "mov %[n2] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n1] , %[lo]"
- "\n\t"
- "out %[port] , %[n2]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 3"
- "\n\t"
- "mov %[n1] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n2] , %[lo]"
- "\n\t"
- "out %[port] , %[n1]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 2"
- "\n\t"
- "mov %[n2] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n1] , %[lo]"
- "\n\t"
- "out %[port] , %[n2]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 1"
- "\n\t"
- "mov %[n1] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n2] , %[lo]"
- "\n\t"
- "out %[port] , %[n1]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 0"
- "\n\t"
- "mov %[n2] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "sbiw %[count], 1"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n1] , %[lo]"
- "\n\t"
- "out %[port] , %[n2]"
- "\n\t"
- "ld %[byte] , %a[ptr]+"
- "\n\t"
- "sbrc %[byte] , 7"
- "\n\t"
- "mov %[n1] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "brne headB"
- "\n"
- : [byte] "+r"(b), [n1] "+r"(n1), [n2] "+r"(n2), [count] "+w"(i)
- : [port] "I"(_SFR_IO_ADDR(PORTB)), [ptr] "e"(ptr), [hi] "r"(hi),
- [lo] "r"(lo));
-
-#if defined(PORTD) || defined(PORTC) || defined(PORTF)
- }
-#endif
-#if defined(PORTC) || defined(PORTF)
- else
-#endif // defined(PORTC/F)
-#endif // defined(PORTB)
-
- // PORTC OUTPUT ----------------------------------------------------
-
-#if defined(PORTC)
-#if defined(PORTD) || defined(PORTB) || defined(PORTF)
- if (port == &PORTC) {
-#endif // defined(PORTD/B/F)
-
- // Same as above, just switched to PORTC and stripped of comments.
- hi = PORTC | pinMask;
- lo = PORTC & ~pinMask;
- n1 = lo;
- if (b & 0x80)
- n1 = hi;
-
- asm volatile(
- "headC:"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n2] , %[lo]"
- "\n\t"
- "out %[port] , %[n1]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 6"
- "\n\t"
- "mov %[n2] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n1] , %[lo]"
- "\n\t"
- "out %[port] , %[n2]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 5"
- "\n\t"
- "mov %[n1] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n2] , %[lo]"
- "\n\t"
- "out %[port] , %[n1]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 4"
- "\n\t"
- "mov %[n2] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n1] , %[lo]"
- "\n\t"
- "out %[port] , %[n2]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 3"
- "\n\t"
- "mov %[n1] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n2] , %[lo]"
- "\n\t"
- "out %[port] , %[n1]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 2"
- "\n\t"
- "mov %[n2] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n1] , %[lo]"
- "\n\t"
- "out %[port] , %[n2]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 1"
- "\n\t"
- "mov %[n1] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n2] , %[lo]"
- "\n\t"
- "out %[port] , %[n1]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 0"
- "\n\t"
- "mov %[n2] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "sbiw %[count], 1"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n1] , %[lo]"
- "\n\t"
- "out %[port] , %[n2]"
- "\n\t"
- "ld %[byte] , %a[ptr]+"
- "\n\t"
- "sbrc %[byte] , 7"
- "\n\t"
- "mov %[n1] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "brne headC"
- "\n"
- : [byte] "+r"(b), [n1] "+r"(n1), [n2] "+r"(n2), [count] "+w"(i)
- : [port] "I"(_SFR_IO_ADDR(PORTC)), [ptr] "e"(ptr), [hi] "r"(hi),
- [lo] "r"(lo));
-
-#if defined(PORTD) || defined(PORTB) || defined(PORTF)
- }
-#endif // defined(PORTD/B/F)
-#if defined(PORTF)
- else
-#endif
-#endif // defined(PORTC)
-
- // PORTF OUTPUT ----------------------------------------------------
-
-#if defined(PORTF)
-#if defined(PORTD) || defined(PORTB) || defined(PORTC)
- if (port == &PORTF) {
-#endif // defined(PORTD/B/C)
-
- hi = PORTF | pinMask;
- lo = PORTF & ~pinMask;
- n1 = lo;
- if (b & 0x80)
- n1 = hi;
-
- asm volatile(
- "headF:"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n2] , %[lo]"
- "\n\t"
- "out %[port] , %[n1]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 6"
- "\n\t"
- "mov %[n2] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n1] , %[lo]"
- "\n\t"
- "out %[port] , %[n2]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 5"
- "\n\t"
- "mov %[n1] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n2] , %[lo]"
- "\n\t"
- "out %[port] , %[n1]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 4"
- "\n\t"
- "mov %[n2] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n1] , %[lo]"
- "\n\t"
- "out %[port] , %[n2]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 3"
- "\n\t"
- "mov %[n1] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n2] , %[lo]"
- "\n\t"
- "out %[port] , %[n1]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 2"
- "\n\t"
- "mov %[n2] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n1] , %[lo]"
- "\n\t"
- "out %[port] , %[n2]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 1"
- "\n\t"
- "mov %[n1] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n2] , %[lo]"
- "\n\t"
- "out %[port] , %[n1]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "sbrc %[byte] , 0"
- "\n\t"
- "mov %[n2] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "sbiw %[count], 1"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "mov %[n1] , %[lo]"
- "\n\t"
- "out %[port] , %[n2]"
- "\n\t"
- "ld %[byte] , %a[ptr]+"
- "\n\t"
- "sbrc %[byte] , 7"
- "\n\t"
- "mov %[n1] , %[hi]"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "brne headF"
- "\n"
- : [byte] "+r"(b), [n1] "+r"(n1), [n2] "+r"(n2), [count] "+w"(i)
- : [port] "I"(_SFR_IO_ADDR(PORTF)), [ptr] "e"(ptr), [hi] "r"(hi),
- [lo] "r"(lo));
-
-#if defined(PORTD) || defined(PORTB) || defined(PORTC)
- }
-#endif // defined(PORTD/B/C)
-#endif // defined(PORTF)
-
-#if defined(NEO_KHZ400)
- } else { // end 800 KHz, do 400 KHz
-
- // Timing is more relaxed; unrolling the inner loop for each bit is
- // not necessary. Still using the peculiar RJMPs as 2X NOPs, not out
- // of need but just to trim the code size down a little.
- // This 400-KHz-datastream-on-8-MHz-CPU code is not quite identical
- // to the 800-on-16 code later -- the hi/lo timing between WS2811 and
- // WS2812 is not simply a 2:1 scale!
-
- // 20 inst. clocks per bit: HHHHxxxxxxLLLLLLLLLL
- // ST instructions: ^ ^ ^ (T=0,4,10)
-
- volatile uint8_t next, bit;
-
- hi = *port | pinMask;
- lo = *port & ~pinMask;
- next = lo;
- bit = 8;
-
- asm volatile("head20:"
- "\n\t" // Clk Pseudocode (T = 0)
- "st %a[port], %[hi]"
- "\n\t" // 2 PORT = hi (T = 2)
- "sbrc %[byte] , 7"
- "\n\t" // 1-2 if(b & 128)
- "mov %[next], %[hi]"
- "\n\t" // 0-1 next = hi (T = 4)
- "st %a[port], %[next]"
- "\n\t" // 2 PORT = next (T = 6)
- "mov %[next] , %[lo]"
- "\n\t" // 1 next = lo (T = 7)
- "dec %[bit]"
- "\n\t" // 1 bit-- (T = 8)
- "breq nextbyte20"
- "\n\t" // 1-2 if(bit == 0)
- "rol %[byte]"
- "\n\t" // 1 b <<= 1 (T = 10)
- "st %a[port], %[lo]"
- "\n\t" // 2 PORT = lo (T = 12)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 14)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 16)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 18)
- "rjmp head20"
- "\n\t" // 2 -> head20 (next bit out)
- "nextbyte20:"
- "\n\t" // (T = 10)
- "st %a[port], %[lo]"
- "\n\t" // 2 PORT = lo (T = 12)
- "nop"
- "\n\t" // 1 nop (T = 13)
- "ldi %[bit] , 8"
- "\n\t" // 1 bit = 8 (T = 14)
- "ld %[byte] , %a[ptr]+"
- "\n\t" // 2 b = *ptr++ (T = 16)
- "sbiw %[count], 1"
- "\n\t" // 2 i-- (T = 18)
- "brne head20"
- "\n" // 2 if(i != 0) -> (next byte)
- : [port] "+e"(port), [byte] "+r"(b), [bit] "+r"(bit),
- [next] "+r"(next), [count] "+w"(i)
- : [hi] "r"(hi), [lo] "r"(lo), [ptr] "e"(ptr));
- }
-#endif // NEO_KHZ400
-
-// 12 MHz(ish) AVR --------------------------------------------------------
-#elif (F_CPU >= 11100000UL) && (F_CPU <= 14300000UL)
-
-#if defined(NEO_KHZ400) // 800 KHz check needed only if 400 KHz support enabled
- if (is800KHz) {
-#endif
-
- // In the 12 MHz case, an optimized 800 KHz datastream (no dead time
- // between bytes) requires a PORT-specific loop similar to the 8 MHz
- // code (but a little more relaxed in this case).
-
- // 15 instruction clocks per bit: HHHHxxxxxxLLLLL
- // OUT instructions: ^ ^ ^ (T=0,4,10)
-
- volatile uint8_t next;
-
- // PORTD OUTPUT ----------------------------------------------------
-
-#if defined(PORTD)
-#if defined(PORTB) || defined(PORTC) || defined(PORTF)
- if (port == &PORTD) {
-#endif // defined(PORTB/C/F)
-
- hi = PORTD | pinMask;
- lo = PORTD & ~pinMask;
- next = lo;
- if (b & 0x80)
- next = hi;
-
- // Don't "optimize" the OUT calls into the bitTime subroutine;
- // we're exploiting the RCALL and RET as 3- and 4-cycle NOPs!
- asm volatile("headD:"
- "\n\t" // (T = 0)
- "out %[port], %[hi]"
- "\n\t" // (T = 1)
- "rcall bitTimeD"
- "\n\t" // Bit 7 (T = 15)
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeD"
- "\n\t" // Bit 6
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeD"
- "\n\t" // Bit 5
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeD"
- "\n\t" // Bit 4
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeD"
- "\n\t" // Bit 3
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeD"
- "\n\t" // Bit 2
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeD"
- "\n\t" // Bit 1
- // Bit 0:
- "out %[port] , %[hi]"
- "\n\t" // 1 PORT = hi (T = 1)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 3)
- "ld %[byte] , %a[ptr]+"
- "\n\t" // 2 b = *ptr++ (T = 5)
- "out %[port] , %[next]"
- "\n\t" // 1 PORT = next (T = 6)
- "mov %[next] , %[lo]"
- "\n\t" // 1 next = lo (T = 7)
- "sbrc %[byte] , 7"
- "\n\t" // 1-2 if(b & 0x80) (T = 8)
- "mov %[next] , %[hi]"
- "\n\t" // 0-1 next = hi (T = 9)
- "nop"
- "\n\t" // 1 (T = 10)
- "out %[port] , %[lo]"
- "\n\t" // 1 PORT = lo (T = 11)
- "sbiw %[count], 1"
- "\n\t" // 2 i-- (T = 13)
- "brne headD"
- "\n\t" // 2 if(i != 0) -> (next byte)
- "rjmp doneD"
- "\n\t"
- "bitTimeD:"
- "\n\t" // nop nop nop (T = 4)
- "out %[port], %[next]"
- "\n\t" // 1 PORT = next (T = 5)
- "mov %[next], %[lo]"
- "\n\t" // 1 next = lo (T = 6)
- "rol %[byte]"
- "\n\t" // 1 b <<= 1 (T = 7)
- "sbrc %[byte], 7"
- "\n\t" // 1-2 if(b & 0x80) (T = 8)
- "mov %[next], %[hi]"
- "\n\t" // 0-1 next = hi (T = 9)
- "nop"
- "\n\t" // 1 (T = 10)
- "out %[port], %[lo]"
- "\n\t" // 1 PORT = lo (T = 11)
- "ret"
- "\n\t" // 4 nop nop nop nop (T = 15)
- "doneD:"
- "\n"
- : [byte] "+r"(b), [next] "+r"(next), [count] "+w"(i)
- : [port] "I"(_SFR_IO_ADDR(PORTD)), [ptr] "e"(ptr),
- [hi] "r"(hi), [lo] "r"(lo));
-
-#if defined(PORTB) || defined(PORTC) || defined(PORTF)
- } else // other PORT(s)
-#endif // defined(PORTB/C/F)
-#endif // defined(PORTD)
-
- // PORTB OUTPUT ----------------------------------------------------
-
-#if defined(PORTB)
-#if defined(PORTD) || defined(PORTC) || defined(PORTF)
- if (port == &PORTB) {
-#endif // defined(PORTD/C/F)
-
- hi = PORTB | pinMask;
- lo = PORTB & ~pinMask;
- next = lo;
- if (b & 0x80)
- next = hi;
-
- // Same as above, just set for PORTB & stripped of comments
- asm volatile("headB:"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeB"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeB"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeB"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeB"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeB"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeB"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeB"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "ld %[byte] , %a[ptr]+"
- "\n\t"
- "out %[port] , %[next]"
- "\n\t"
- "mov %[next] , %[lo]"
- "\n\t"
- "sbrc %[byte] , 7"
- "\n\t"
- "mov %[next] , %[hi]"
- "\n\t"
- "nop"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "sbiw %[count], 1"
- "\n\t"
- "brne headB"
- "\n\t"
- "rjmp doneB"
- "\n\t"
- "bitTimeB:"
- "\n\t"
- "out %[port], %[next]"
- "\n\t"
- "mov %[next], %[lo]"
- "\n\t"
- "rol %[byte]"
- "\n\t"
- "sbrc %[byte], 7"
- "\n\t"
- "mov %[next], %[hi]"
- "\n\t"
- "nop"
- "\n\t"
- "out %[port], %[lo]"
- "\n\t"
- "ret"
- "\n\t"
- "doneB:"
- "\n"
- : [byte] "+r"(b), [next] "+r"(next), [count] "+w"(i)
- : [port] "I"(_SFR_IO_ADDR(PORTB)), [ptr] "e"(ptr),
- [hi] "r"(hi), [lo] "r"(lo));
-
-#if defined(PORTD) || defined(PORTC) || defined(PORTF)
- }
-#endif
-#if defined(PORTC) || defined(PORTF)
- else
-#endif // defined(PORTC/F)
-#endif // defined(PORTB)
-
- // PORTC OUTPUT ----------------------------------------------------
-
-#if defined(PORTC)
-#if defined(PORTD) || defined(PORTB) || defined(PORTF)
- if (port == &PORTC) {
-#endif // defined(PORTD/B/F)
-
- hi = PORTC | pinMask;
- lo = PORTC & ~pinMask;
- next = lo;
- if (b & 0x80)
- next = hi;
-
- // Same as above, just set for PORTC & stripped of comments
- asm volatile("headC:"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "ld %[byte] , %a[ptr]+"
- "\n\t"
- "out %[port] , %[next]"
- "\n\t"
- "mov %[next] , %[lo]"
- "\n\t"
- "sbrc %[byte] , 7"
- "\n\t"
- "mov %[next] , %[hi]"
- "\n\t"
- "nop"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "sbiw %[count], 1"
- "\n\t"
- "brne headC"
- "\n\t"
- "rjmp doneC"
- "\n\t"
- "bitTimeC:"
- "\n\t"
- "out %[port], %[next]"
- "\n\t"
- "mov %[next], %[lo]"
- "\n\t"
- "rol %[byte]"
- "\n\t"
- "sbrc %[byte], 7"
- "\n\t"
- "mov %[next], %[hi]"
- "\n\t"
- "nop"
- "\n\t"
- "out %[port], %[lo]"
- "\n\t"
- "ret"
- "\n\t"
- "doneC:"
- "\n"
- : [byte] "+r"(b), [next] "+r"(next), [count] "+w"(i)
- : [port] "I"(_SFR_IO_ADDR(PORTC)), [ptr] "e"(ptr),
- [hi] "r"(hi), [lo] "r"(lo));
-
-#if defined(PORTD) || defined(PORTB) || defined(PORTF)
- }
-#endif // defined(PORTD/B/F)
-#if defined(PORTF)
- else
-#endif
-#endif // defined(PORTC)
-
- // PORTF OUTPUT ----------------------------------------------------
-
-#if defined(PORTF)
-#if defined(PORTD) || defined(PORTB) || defined(PORTC)
- if (port == &PORTF) {
-#endif // defined(PORTD/B/C)
-
- hi = PORTF | pinMask;
- lo = PORTF & ~pinMask;
- next = lo;
- if (b & 0x80)
- next = hi;
-
- // Same as above, just set for PORTF & stripped of comments
- asm volatile("headF:"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port], %[hi]"
- "\n\t"
- "rcall bitTimeC"
- "\n\t"
- "out %[port] , %[hi]"
- "\n\t"
- "rjmp .+0"
- "\n\t"
- "ld %[byte] , %a[ptr]+"
- "\n\t"
- "out %[port] , %[next]"
- "\n\t"
- "mov %[next] , %[lo]"
- "\n\t"
- "sbrc %[byte] , 7"
- "\n\t"
- "mov %[next] , %[hi]"
- "\n\t"
- "nop"
- "\n\t"
- "out %[port] , %[lo]"
- "\n\t"
- "sbiw %[count], 1"
- "\n\t"
- "brne headF"
- "\n\t"
- "rjmp doneC"
- "\n\t"
- "bitTimeC:"
- "\n\t"
- "out %[port], %[next]"
- "\n\t"
- "mov %[next], %[lo]"
- "\n\t"
- "rol %[byte]"
- "\n\t"
- "sbrc %[byte], 7"
- "\n\t"
- "mov %[next], %[hi]"
- "\n\t"
- "nop"
- "\n\t"
- "out %[port], %[lo]"
- "\n\t"
- "ret"
- "\n\t"
- "doneC:"
- "\n"
- : [byte] "+r"(b), [next] "+r"(next), [count] "+w"(i)
- : [port] "I"(_SFR_IO_ADDR(PORTF)), [ptr] "e"(ptr),
- [hi] "r"(hi), [lo] "r"(lo));
-
-#if defined(PORTD) || defined(PORTB) || defined(PORTC)
- }
-#endif // defined(PORTD/B/C)
-#endif // defined(PORTF)
-
-#if defined(NEO_KHZ400)
- } else { // 400 KHz
-
- // 30 instruction clocks per bit: HHHHHHxxxxxxxxxLLLLLLLLLLLLLLL
- // ST instructions: ^ ^ ^ (T=0,6,15)
-
- volatile uint8_t next, bit;
-
- hi = *port | pinMask;
- lo = *port & ~pinMask;
- next = lo;
- bit = 8;
-
- asm volatile("head30:"
- "\n\t" // Clk Pseudocode (T = 0)
- "st %a[port], %[hi]"
- "\n\t" // 2 PORT = hi (T = 2)
- "sbrc %[byte] , 7"
- "\n\t" // 1-2 if(b & 128)
- "mov %[next], %[hi]"
- "\n\t" // 0-1 next = hi (T = 4)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 6)
- "st %a[port], %[next]"
- "\n\t" // 2 PORT = next (T = 8)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 10)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 12)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 14)
- "nop"
- "\n\t" // 1 nop (T = 15)
- "st %a[port], %[lo]"
- "\n\t" // 2 PORT = lo (T = 17)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 19)
- "dec %[bit]"
- "\n\t" // 1 bit-- (T = 20)
- "breq nextbyte30"
- "\n\t" // 1-2 if(bit == 0)
- "rol %[byte]"
- "\n\t" // 1 b <<= 1 (T = 22)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 24)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 26)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 28)
- "rjmp head30"
- "\n\t" // 2 -> head30 (next bit out)
- "nextbyte30:"
- "\n\t" // (T = 22)
- "nop"
- "\n\t" // 1 nop (T = 23)
- "ldi %[bit] , 8"
- "\n\t" // 1 bit = 8 (T = 24)
- "ld %[byte] , %a[ptr]+"
- "\n\t" // 2 b = *ptr++ (T = 26)
- "sbiw %[count], 1"
- "\n\t" // 2 i-- (T = 28)
- "brne head30"
- "\n" // 1-2 if(i != 0) -> (next byte)
- : [port] "+e"(port), [byte] "+r"(b), [bit] "+r"(bit),
- [next] "+r"(next), [count] "+w"(i)
- : [hi] "r"(hi), [lo] "r"(lo), [ptr] "e"(ptr));
- }
-#endif // NEO_KHZ400
-
-// 16 MHz(ish) AVR --------------------------------------------------------
-#elif (F_CPU >= 15400000UL) && (F_CPU <= 19000000L)
-
-#if defined(NEO_KHZ400) // 800 KHz check needed only if 400 KHz support enabled
- if (is800KHz) {
-#endif
-
- // WS2811 and WS2812 have different hi/lo duty cycles; this is
- // similar but NOT an exact copy of the prior 400-on-8 code.
-
- // 20 inst. clocks per bit: HHHHHxxxxxxxxLLLLLLL
- // ST instructions: ^ ^ ^ (T=0,5,13)
-
- volatile uint8_t next, bit;
-
- hi = *port | pinMask;
- lo = *port & ~pinMask;
- next = lo;
- bit = 8;
-
- asm volatile("head20:"
- "\n\t" // Clk Pseudocode (T = 0)
- "st %a[port], %[hi]"
- "\n\t" // 2 PORT = hi (T = 2)
- "sbrc %[byte], 7"
- "\n\t" // 1-2 if(b & 128)
- "mov %[next], %[hi]"
- "\n\t" // 0-1 next = hi (T = 4)
- "dec %[bit]"
- "\n\t" // 1 bit-- (T = 5)
- "st %a[port], %[next]"
- "\n\t" // 2 PORT = next (T = 7)
- "mov %[next] , %[lo]"
- "\n\t" // 1 next = lo (T = 8)
- "breq nextbyte20"
- "\n\t" // 1-2 if(bit == 0) (from dec above)
- "rol %[byte]"
- "\n\t" // 1 b <<= 1 (T = 10)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 12)
- "nop"
- "\n\t" // 1 nop (T = 13)
- "st %a[port], %[lo]"
- "\n\t" // 2 PORT = lo (T = 15)
- "nop"
- "\n\t" // 1 nop (T = 16)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 18)
- "rjmp head20"
- "\n\t" // 2 -> head20 (next bit out)
- "nextbyte20:"
- "\n\t" // (T = 10)
- "ldi %[bit] , 8"
- "\n\t" // 1 bit = 8 (T = 11)
- "ld %[byte] , %a[ptr]+"
- "\n\t" // 2 b = *ptr++ (T = 13)
- "st %a[port], %[lo]"
- "\n\t" // 2 PORT = lo (T = 15)
- "nop"
- "\n\t" // 1 nop (T = 16)
- "sbiw %[count], 1"
- "\n\t" // 2 i-- (T = 18)
- "brne head20"
- "\n" // 2 if(i != 0) -> (next byte)
- : [port] "+e"(port), [byte] "+r"(b), [bit] "+r"(bit),
- [next] "+r"(next), [count] "+w"(i)
- : [ptr] "e"(ptr), [hi] "r"(hi), [lo] "r"(lo));
-
-#if defined(NEO_KHZ400)
- } else { // 400 KHz
-
- // The 400 KHz clock on 16 MHz MCU is the most 'relaxed' version.
-
- // 40 inst. clocks per bit: HHHHHHHHxxxxxxxxxxxxLLLLLLLLLLLLLLLLLLLL
- // ST instructions: ^ ^ ^ (T=0,8,20)
-
- volatile uint8_t next, bit;
-
- hi = *port | pinMask;
- lo = *port & ~pinMask;
- next = lo;
- bit = 8;
-
- asm volatile("head40:"
- "\n\t" // Clk Pseudocode (T = 0)
- "st %a[port], %[hi]"
- "\n\t" // 2 PORT = hi (T = 2)
- "sbrc %[byte] , 7"
- "\n\t" // 1-2 if(b & 128)
- "mov %[next] , %[hi]"
- "\n\t" // 0-1 next = hi (T = 4)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 6)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 8)
- "st %a[port], %[next]"
- "\n\t" // 2 PORT = next (T = 10)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 12)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 14)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 16)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 18)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 20)
- "st %a[port], %[lo]"
- "\n\t" // 2 PORT = lo (T = 22)
- "nop"
- "\n\t" // 1 nop (T = 23)
- "mov %[next] , %[lo]"
- "\n\t" // 1 next = lo (T = 24)
- "dec %[bit]"
- "\n\t" // 1 bit-- (T = 25)
- "breq nextbyte40"
- "\n\t" // 1-2 if(bit == 0)
- "rol %[byte]"
- "\n\t" // 1 b <<= 1 (T = 27)
- "nop"
- "\n\t" // 1 nop (T = 28)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 30)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 32)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 34)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 36)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 38)
- "rjmp head40"
- "\n\t" // 2 -> head40 (next bit out)
- "nextbyte40:"
- "\n\t" // (T = 27)
- "ldi %[bit] , 8"
- "\n\t" // 1 bit = 8 (T = 28)
- "ld %[byte] , %a[ptr]+"
- "\n\t" // 2 b = *ptr++ (T = 30)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 32)
- "st %a[port], %[lo]"
- "\n\t" // 2 PORT = lo (T = 34)
- "rjmp .+0"
- "\n\t" // 2 nop nop (T = 36)
- "sbiw %[count], 1"
- "\n\t" // 2 i-- (T = 38)
- "brne head40"
- "\n" // 1-2 if(i != 0) -> (next byte)
- : [port] "+e"(port), [byte] "+r"(b), [bit] "+r"(bit),
- [next] "+r"(next), [count] "+w"(i)
- : [ptr] "e"(ptr), [hi] "r"(hi), [lo] "r"(lo));
- }
-#endif // NEO_KHZ400
-
-#else
-#error "CPU SPEED NOT SUPPORTED"
-#endif // end F_CPU ifdefs on __AVR__
-
- // END AVR ----------------------------------------------------------------
-
-#elif defined(__arm__)
-
- // ARM MCUs -- Teensy 3.0, 3.1, LC, Arduino Due, RP2040 -------------------
-
-#if defined(ARDUINO_ARCH_RP2040)
- // Use PIO
- rp2040Show(pin, pixels, numBytes, is800KHz);
-
-#elif defined(TEENSYDUINO) && \
- defined(KINETISK) // Teensy 3.0, 3.1, 3.2, 3.5, 3.6
-#define CYCLES_800_T0H (F_CPU / 4000000)
-#define CYCLES_800_T1H (F_CPU / 1250000)
-#define CYCLES_800 (F_CPU / 800000)
-#define CYCLES_400_T0H (F_CPU / 2000000)
-#define CYCLES_400_T1H (F_CPU / 833333)
-#define CYCLES_400 (F_CPU / 400000)
-
- uint8_t *p = pixels, *end = p + numBytes, pix, mask;
- volatile uint8_t *set = portSetRegister(pin), *clr = portClearRegister(pin);
- uint32_t cyc;
-
- ARM_DEMCR |= ARM_DEMCR_TRCENA;
- ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
-
-#if defined(NEO_KHZ400) // 800 KHz check needed only if 400 KHz support enabled
- if (is800KHz) {
-#endif
- cyc = ARM_DWT_CYCCNT + CYCLES_800;
- while (p < end) {
- pix = *p++;
- for (mask = 0x80; mask; mask >>= 1) {
- while (ARM_DWT_CYCCNT - cyc < CYCLES_800)
- ;
- cyc = ARM_DWT_CYCCNT;
- *set = 1;
- if (pix & mask) {
- while (ARM_DWT_CYCCNT - cyc < CYCLES_800_T1H)
- ;
- } else {
- while (ARM_DWT_CYCCNT - cyc < CYCLES_800_T0H)
- ;
- }
- *clr = 1;
- }
- }
- while (ARM_DWT_CYCCNT - cyc < CYCLES_800)
- ;
-#if defined(NEO_KHZ400)
- } else { // 400 kHz bitstream
- cyc = ARM_DWT_CYCCNT + CYCLES_400;
- while (p < end) {
- pix = *p++;
- for (mask = 0x80; mask; mask >>= 1) {
- while (ARM_DWT_CYCCNT - cyc < CYCLES_400)
- ;
- cyc = ARM_DWT_CYCCNT;
- *set = 1;
- if (pix & mask) {
- while (ARM_DWT_CYCCNT - cyc < CYCLES_400_T1H)
- ;
- } else {
- while (ARM_DWT_CYCCNT - cyc < CYCLES_400_T0H)
- ;
- }
- *clr = 1;
- }
- }
- while (ARM_DWT_CYCCNT - cyc < CYCLES_400)
- ;
- }
-#endif // NEO_KHZ400
-
-#elif defined(TEENSYDUINO) && (defined(__IMXRT1052__) || defined(__IMXRT1062__))
-#define CYCLES_800_T0H (F_CPU_ACTUAL / 4000000)
-#define CYCLES_800_T1H (F_CPU_ACTUAL / 1250000)
-#define CYCLES_800 (F_CPU_ACTUAL / 800000)
-#define CYCLES_400_T0H (F_CPU_ACTUAL / 2000000)
-#define CYCLES_400_T1H (F_CPU_ACTUAL / 833333)
-#define CYCLES_400 (F_CPU_ACTUAL / 400000)
-
- uint8_t *p = pixels, *end = p + numBytes, pix, mask;
- volatile uint32_t *set = portSetRegister(pin), *clr = portClearRegister(pin);
- uint32_t cyc, msk = digitalPinToBitMask(pin);
-
- ARM_DEMCR |= ARM_DEMCR_TRCENA;
- ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA;
-
-#if defined(NEO_KHZ400) // 800 KHz check needed only if 400 KHz support enabled
- if (is800KHz) {
-#endif
- cyc = ARM_DWT_CYCCNT + CYCLES_800;
- while (p < end) {
- pix = *p++;
- for (mask = 0x80; mask; mask >>= 1) {
- while (ARM_DWT_CYCCNT - cyc < CYCLES_800)
- ;
- cyc = ARM_DWT_CYCCNT;
- *set = msk;
- if (pix & mask) {
- while (ARM_DWT_CYCCNT - cyc < CYCLES_800_T1H)
- ;
- } else {
- while (ARM_DWT_CYCCNT - cyc < CYCLES_800_T0H)
- ;
- }
- *clr = msk;
- }
- }
- while (ARM_DWT_CYCCNT - cyc < CYCLES_800)
- ;
-#if defined(NEO_KHZ400)
- } else { // 400 kHz bitstream
- cyc = ARM_DWT_CYCCNT + CYCLES_400;
- while (p < end) {
- pix = *p++;
- for (mask = 0x80; mask; mask >>= 1) {
- while (ARM_DWT_CYCCNT - cyc < CYCLES_400)
- ;
- cyc = ARM_DWT_CYCCNT;
- *set = msk;
- if (pix & mask) {
- while (ARM_DWT_CYCCNT - cyc < CYCLES_400_T1H)
- ;
- } else {
- while (ARM_DWT_CYCCNT - cyc < CYCLES_400_T0H)
- ;
- }
- *clr = msk;
- }
- }
- while (ARM_DWT_CYCCNT - cyc < CYCLES_400)
- ;
- }
-#endif // NEO_KHZ400
-
-#elif defined(TEENSYDUINO) && defined(__MKL26Z64__) // Teensy-LC
-
-#if F_CPU == 48000000
- uint8_t *p = pixels, pix, count, dly, bitmask = digitalPinToBitMask(pin);
- volatile uint8_t *reg = portSetRegister(pin);
- uint32_t num = numBytes;
- asm volatile("L%=_begin:"
- "\n\t"
- "ldrb %[pix], [%[p], #0]"
- "\n\t"
- "lsl %[pix], #24"
- "\n\t"
- "movs %[count], #7"
- "\n\t"
- "L%=_loop:"
- "\n\t"
- "lsl %[pix], #1"
- "\n\t"
- "bcs L%=_loop_one"
- "\n\t"
- "L%=_loop_zero:"
- "\n\t"
- "strb %[bitmask], [%[reg], #0]"
- "\n\t"
- "movs %[dly], #4"
- "\n\t"
- "L%=_loop_delay_T0H:"
- "\n\t"
- "sub %[dly], #1"
- "\n\t"
- "bne L%=_loop_delay_T0H"
- "\n\t"
- "strb %[bitmask], [%[reg], #4]"
- "\n\t"
- "movs %[dly], #13"
- "\n\t"
- "L%=_loop_delay_T0L:"
- "\n\t"
- "sub %[dly], #1"
- "\n\t"
- "bne L%=_loop_delay_T0L"
- "\n\t"
- "b L%=_next"
- "\n\t"
- "L%=_loop_one:"
- "\n\t"
- "strb %[bitmask], [%[reg], #0]"
- "\n\t"
- "movs %[dly], #13"
- "\n\t"
- "L%=_loop_delay_T1H:"
- "\n\t"
- "sub %[dly], #1"
- "\n\t"
- "bne L%=_loop_delay_T1H"
- "\n\t"
- "strb %[bitmask], [%[reg], #4]"
- "\n\t"
- "movs %[dly], #4"
- "\n\t"
- "L%=_loop_delay_T1L:"
- "\n\t"
- "sub %[dly], #1"
- "\n\t"
- "bne L%=_loop_delay_T1L"
- "\n\t"
- "nop"
- "\n\t"
- "L%=_next:"
- "\n\t"
- "sub %[count], #1"
- "\n\t"
- "bne L%=_loop"
- "\n\t"
- "lsl %[pix], #1"
- "\n\t"
- "bcs L%=_last_one"
- "\n\t"
- "L%=_last_zero:"
- "\n\t"
- "strb %[bitmask], [%[reg], #0]"
- "\n\t"
- "movs %[dly], #4"
- "\n\t"
- "L%=_last_delay_T0H:"
- "\n\t"
- "sub %[dly], #1"
- "\n\t"
- "bne L%=_last_delay_T0H"
- "\n\t"
- "strb %[bitmask], [%[reg], #4]"
- "\n\t"
- "movs %[dly], #10"
- "\n\t"
- "L%=_last_delay_T0L:"
- "\n\t"
- "sub %[dly], #1"
- "\n\t"
- "bne L%=_last_delay_T0L"
- "\n\t"
- "b L%=_repeat"
- "\n\t"
- "L%=_last_one:"
- "\n\t"
- "strb %[bitmask], [%[reg], #0]"
- "\n\t"
- "movs %[dly], #13"
- "\n\t"
- "L%=_last_delay_T1H:"
- "\n\t"
- "sub %[dly], #1"
- "\n\t"
- "bne L%=_last_delay_T1H"
- "\n\t"
- "strb %[bitmask], [%[reg], #4]"
- "\n\t"
- "movs %[dly], #1"
- "\n\t"
- "L%=_last_delay_T1L:"
- "\n\t"
- "sub %[dly], #1"
- "\n\t"
- "bne L%=_last_delay_T1L"
- "\n\t"
- "nop"
- "\n\t"
- "L%=_repeat:"
- "\n\t"
- "add %[p], #1"
- "\n\t"
- "sub %[num], #1"
- "\n\t"
- "bne L%=_begin"
- "\n\t"
- "L%=_done:"
- "\n\t"
- : [p] "+r"(p), [pix] "=&r"(pix), [count] "=&r"(count),
- [dly] "=&r"(dly), [num] "+r"(num)
- : [bitmask] "r"(bitmask), [reg] "r"(reg));
-#else
-#error "Sorry, only 48 MHz is supported, please set Tools > CPU Speed to 48 MHz"
-#endif // F_CPU == 48000000
-
- // Begin of support for nRF52 based boards -------------------------
-
-#elif defined(NRF52) || defined(NRF52_SERIES)
-// [[[Begin of the Neopixel NRF52 EasyDMA implementation
-// by the Hackerspace San Salvador]]]
-// This technique uses the PWM peripheral on the NRF52. The PWM uses the
-// EasyDMA feature included on the chip. This technique loads the duty
-// cycle configuration for each cycle when the PWM is enabled. For this
-// to work we need to store a 16 bit configuration for each bit of the
-// RGB(W) values in the pixel buffer.
-// Comparator values for the PWM were hand picked and are guaranteed to
-// be 100% organic to preserve freshness and high accuracy. Current
-// parameters are:
-// * PWM Clock: 16Mhz
-// * Minimum step time: 62.5ns
-// * Time for zero in high (T0H): 0.31ms
-// * Time for one in high (T1H): 0.75ms
-// * Cycle time: 1.25us
-// * Frequency: 800Khz
-// For 400Khz we just double the calculated times.
-// ---------- BEGIN Constants for the EasyDMA implementation -----------
-// The PWM starts the duty cycle in LOW. To start with HIGH we
-// need to set the 15th bit on each register.
-
-// WS2812 (rev A) timing is 0.35 and 0.7us
-//#define MAGIC_T0H 5UL | (0x8000) // 0.3125us
-//#define MAGIC_T1H 12UL | (0x8000) // 0.75us
-
-// WS2812B (rev B) timing is 0.4 and 0.8 us
-#define MAGIC_T0H 6UL | (0x8000) // 0.375us
-#define MAGIC_T1H 13UL | (0x8000) // 0.8125us
-
-// WS2811 (400 khz) timing is 0.5 and 1.2
-#define MAGIC_T0H_400KHz 8UL | (0x8000) // 0.5us
-#define MAGIC_T1H_400KHz 19UL | (0x8000) // 1.1875us
-
-// For 400Khz, we double value of CTOPVAL
-#define CTOPVAL 20UL // 1.25us
-#define CTOPVAL_400KHz 40UL // 2.5us
-
-// ---------- END Constants for the EasyDMA implementation -------------
-//
-// If there is no device available an alternative cycle-counter
-// implementation is tried.
-// The nRF52 runs with a fixed clock of 64Mhz. The alternative
-// implementation is the same as the one used for the Teensy 3.0/1/2 but
-// with the Nordic SDK HAL & registers syntax.
-// The number of cycles was hand picked and is guaranteed to be 100%
-// organic to preserve freshness and high accuracy.
-// ---------- BEGIN Constants for cycle counter implementation ---------
-#define CYCLES_800_T0H 18 // ~0.36 uS
-#define CYCLES_800_T1H 41 // ~0.76 uS
-#define CYCLES_800 71 // ~1.25 uS
-
-#define CYCLES_400_T0H 26 // ~0.50 uS
-#define CYCLES_400_T1H 70 // ~1.26 uS
-#define CYCLES_400 156 // ~2.50 uS
- // ---------- END of Constants for cycle counter implementation --------
-
- // To support both the SoftDevice + Neopixels we use the EasyDMA
- // feature from the NRF25. However this technique implies to
- // generate a pattern and store it on the memory. The actual
- // memory used in bytes corresponds to the following formula:
- // totalMem = numBytes*8*2+(2*2)
- // The two additional bytes at the end are needed to reset the
- // sequence.
- //
- // If there is not enough memory, we will fall back to cycle counter
- // using DWT
- uint32_t pattern_size =
- numBytes * 8 * sizeof(uint16_t) + 2 * sizeof(uint16_t);
- uint16_t *pixels_pattern = NULL;
-
- NRF_PWM_Type *pwm = NULL;
-
- // Try to find a free PWM device, which is not enabled
- // and has no connected pins
- NRF_PWM_Type *PWM[] = {
- NRF_PWM0,
- NRF_PWM1,
- NRF_PWM2
-#if defined(NRF_PWM3)
- ,
- NRF_PWM3
-#endif
- };
-
- for (unsigned int device = 0; device < (sizeof(PWM) / sizeof(PWM[0]));
- device++) {
- if ((PWM[device]->ENABLE == 0) &&
- (PWM[device]->PSEL.OUT[0] & PWM_PSEL_OUT_CONNECT_Msk) &&
- (PWM[device]->PSEL.OUT[1] & PWM_PSEL_OUT_CONNECT_Msk) &&
- (PWM[device]->PSEL.OUT[2] & PWM_PSEL_OUT_CONNECT_Msk) &&
- (PWM[device]->PSEL.OUT[3] & PWM_PSEL_OUT_CONNECT_Msk)) {
- pwm = PWM[device];
- break;
- }
- }
-
- // only malloc if there is PWM device available
- if (pwm != NULL) {
-#if defined(ARDUINO_NRF52_ADAFRUIT) // use thread-safe malloc
- pixels_pattern = (uint16_t *)rtos_malloc(pattern_size);
-#else
- pixels_pattern = (uint16_t *)malloc(pattern_size);
-#endif
- }
-
- // Use the identified device to choose the implementation
- // If a PWM device is available use DMA
- if ((pixels_pattern != NULL) && (pwm != NULL)) {
- uint16_t pos = 0; // bit position
-
- for (uint16_t n = 0; n < numBytes; n++) {
- uint8_t pix = pixels[n];
-
- for (uint8_t mask = 0x80; mask > 0; mask >>= 1) {
-#if defined(NEO_KHZ400)
- if (!is800KHz) {
- pixels_pattern[pos] =
- (pix & mask) ? MAGIC_T1H_400KHz : MAGIC_T0H_400KHz;
- } else
-#endif
- {
- pixels_pattern[pos] = (pix & mask) ? MAGIC_T1H : MAGIC_T0H;
- }
-
- pos++;
- }
- }
-
- // Zero padding to indicate the end of que sequence
- pixels_pattern[pos++] = 0 | (0x8000); // Seq end
- pixels_pattern[pos++] = 0 | (0x8000); // Seq end
-
- // Set the wave mode to count UP
- pwm->MODE = (PWM_MODE_UPDOWN_Up << PWM_MODE_UPDOWN_Pos);
-
- // Set the PWM to use the 16MHz clock
- pwm->PRESCALER =
- (PWM_PRESCALER_PRESCALER_DIV_1 << PWM_PRESCALER_PRESCALER_Pos);
-
- // Setting of the maximum count
- // but keeping it on 16Mhz allows for more granularity just
- // in case someone wants to do more fine-tuning of the timing.
-#if defined(NEO_KHZ400)
- if (!is800KHz) {
- pwm->COUNTERTOP = (CTOPVAL_400KHz << PWM_COUNTERTOP_COUNTERTOP_Pos);
- } else
-#endif
- {
- pwm->COUNTERTOP = (CTOPVAL << PWM_COUNTERTOP_COUNTERTOP_Pos);
- }
-
- // Disable loops, we want the sequence to repeat only once
- pwm->LOOP = (PWM_LOOP_CNT_Disabled << PWM_LOOP_CNT_Pos);
-
- // On the "Common" setting the PWM uses the same pattern for the
- // for supported sequences. The pattern is stored on half-word
- // of 16bits
- pwm->DECODER = (PWM_DECODER_LOAD_Common << PWM_DECODER_LOAD_Pos) |
- (PWM_DECODER_MODE_RefreshCount << PWM_DECODER_MODE_Pos);
-
- // Pointer to the memory storing the patter
- pwm->SEQ[0].PTR = (uint32_t)(pixels_pattern) << PWM_SEQ_PTR_PTR_Pos;
-
- // Calculation of the number of steps loaded from memory.
- pwm->SEQ[0].CNT = (pattern_size / sizeof(uint16_t)) << PWM_SEQ_CNT_CNT_Pos;
-
- // The following settings are ignored with the current config.
- pwm->SEQ[0].REFRESH = 0;
- pwm->SEQ[0].ENDDELAY = 0;
-
- // The Neopixel implementation is a blocking algorithm. DMA
- // allows for non-blocking operation. To "simulate" a blocking
- // operation we enable the interruption for the end of sequence
- // and block the execution thread until the event flag is set by
- // the peripheral.
- // pwm->INTEN |= (PWM_INTEN_SEQEND0_Enabled<PSEL.OUT[0] = g_APinDescription[pin].name;
-#else
- pwm->PSEL.OUT[0] = g_ADigitalPinMap[pin];
-#endif
-
- // Enable the PWM
- pwm->ENABLE = 1;
-
- // After all of this and many hours of reading the documentation
- // we are ready to start the sequence...
- pwm->EVENTS_SEQEND[0] = 0;
- pwm->TASKS_SEQSTART[0] = 1;
-
- // But we have to wait for the flag to be set.
- while (!pwm->EVENTS_SEQEND[0]) {
-#if defined(ARDUINO_NRF52_ADAFRUIT) || defined(ARDUINO_ARCH_NRF52840)
- yield();
-#endif
- }
-
- // Before leave we clear the flag for the event.
- pwm->EVENTS_SEQEND[0] = 0;
-
- // We need to disable the device and disconnect
- // all the outputs before leave or the device will not
- // be selected on the next call.
- // TODO: Check if disabling the device causes performance issues.
- pwm->ENABLE = 0;
-
- pwm->PSEL.OUT[0] = 0xFFFFFFFFUL;
-
-#if defined(ARDUINO_NRF52_ADAFRUIT) // use thread-safe free
- rtos_free(pixels_pattern);
-#else
- free(pixels_pattern);
-#endif
- } // End of DMA implementation
- // ---------------------------------------------------------------------
- else {
-#ifndef ARDUINO_ARCH_NRF52840
-// Fall back to DWT
-#if defined(ARDUINO_NRF52_ADAFRUIT)
- // Bluefruit Feather 52 uses freeRTOS
- // Critical Section is used since it does not block SoftDevice execution
- taskENTER_CRITICAL();
-#elif defined(NRF52_DISABLE_INT)
- // If you are using the Bluetooth SoftDevice we advise you to not disable
- // the interrupts. Disabling the interrupts even for short periods of time
- // causes the SoftDevice to stop working.
- // Disable the interrupts only in cases where you need high performance for
- // the LEDs and if you are not using the EasyDMA feature.
- __disable_irq();
-#endif
-
- NRF_GPIO_Type *nrf_port = (NRF_GPIO_Type *)digitalPinToPort(pin);
- uint32_t pinMask = digitalPinToBitMask(pin);
-
- uint32_t CYCLES_X00 = CYCLES_800;
- uint32_t CYCLES_X00_T1H = CYCLES_800_T1H;
- uint32_t CYCLES_X00_T0H = CYCLES_800_T0H;
-
-#if defined(NEO_KHZ400)
- if (!is800KHz) {
- CYCLES_X00 = CYCLES_400;
- CYCLES_X00_T1H = CYCLES_400_T1H;
- CYCLES_X00_T0H = CYCLES_400_T0H;
- }
-#endif
-
- // Enable DWT in debug core
- CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
- DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
-
- // Tries to re-send the frame if is interrupted by the SoftDevice.
- while (1) {
- uint8_t *p = pixels;
-
- uint32_t cycStart = DWT->CYCCNT;
- uint32_t cyc = 0;
-
- for (uint16_t n = 0; n < numBytes; n++) {
- uint8_t pix = *p++;
-
- for (uint8_t mask = 0x80; mask; mask >>= 1) {
- while (DWT->CYCCNT - cyc < CYCLES_X00)
- ;
- cyc = DWT->CYCCNT;
-
- nrf_port->OUTSET |= pinMask;
-
- if (pix & mask) {
- while (DWT->CYCCNT - cyc < CYCLES_X00_T1H)
- ;
- } else {
- while (DWT->CYCCNT - cyc < CYCLES_X00_T0H)
- ;
- }
-
- nrf_port->OUTCLR |= pinMask;
- }
- }
- while (DWT->CYCCNT - cyc < CYCLES_X00)
- ;
-
- // If total time longer than 25%, resend the whole data.
- // Since we are likely to be interrupted by SoftDevice
- if ((DWT->CYCCNT - cycStart) < (8 * numBytes * ((CYCLES_X00 * 5) / 4))) {
- break;
- }
-
- // re-send need 300us delay
- delayMicroseconds(300);
- }
-
-// Enable interrupts again
-#if defined(ARDUINO_NRF52_ADAFRUIT)
- taskEXIT_CRITICAL();
-#elif defined(NRF52_DISABLE_INT)
- __enable_irq();
-#endif
-#endif
- }
- // END of NRF52 implementation
-
-#elif defined(__SAMD21E17A__) || defined(__SAMD21G18A__) || \
- defined(__SAMD21E18A__) || defined(__SAMD21J18A__) || \
- defined (__SAMD11C14A__)
- // Arduino Zero, Gemma/Trinket M0, SODAQ Autonomo
- // and others
- // Tried this with a timer/counter, couldn't quite get adequate
- // resolution. So yay, you get a load of goofball NOPs...
-
- uint8_t *ptr, *end, p, bitMask, portNum;
- uint32_t pinMask;
-
- portNum = g_APinDescription[pin].ulPort;
- pinMask = 1ul << g_APinDescription[pin].ulPin;
- ptr = pixels;
- end = ptr + numBytes;
- p = *ptr++;
- bitMask = 0x80;
-
- volatile uint32_t *set = &(PORT->Group[portNum].OUTSET.reg),
- *clr = &(PORT->Group[portNum].OUTCLR.reg);
-
-#if defined(NEO_KHZ400) // 800 KHz check needed only if 400 KHz support enabled
- if (is800KHz) {
-#endif
- for (;;) {
- *set = pinMask;
- asm("nop; nop; nop; nop; nop; nop; nop; nop;");
- if (p & bitMask) {
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop;");
- *clr = pinMask;
- } else {
- *clr = pinMask;
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop;");
- }
- if (bitMask >>= 1) {
- asm("nop; nop; nop; nop; nop; nop; nop; nop; nop;");
- } else {
- if (ptr >= end)
- break;
- p = *ptr++;
- bitMask = 0x80;
- }
- }
-#if defined(NEO_KHZ400)
- } else { // 400 KHz bitstream
- for (;;) {
- *set = pinMask;
- asm("nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop;");
- if (p & bitMask) {
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop;");
- *clr = pinMask;
- } else {
- *clr = pinMask;
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop;");
- }
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;");
- if (bitMask >>= 1) {
- asm("nop; nop; nop; nop; nop; nop; nop;");
- } else {
- if (ptr >= end)
- break;
- p = *ptr++;
- bitMask = 0x80;
- }
- }
- }
-#endif
-
-//----
-#elif defined(XMC1100_XMC2GO) || defined(XMC1100_H_BRIDGE2GO) || defined(XMC1100_Boot_Kit) || defined(XMC1300_Boot_Kit)
-
- // XMC1100/1200/1300 with ARM Cortex M0 are running with 32MHz, XMC1400 runs with 48MHz so may not work
- // Tried this with a timer/counter, couldn't quite get adequate
- // resolution. So yay, you get a load of goofball NOPs...
-
- uint8_t *ptr, *end, p, bitMask, portNum;
- uint32_t pinMask;
-
- ptr = pixels;
- end = ptr + numBytes;
- p = *ptr++;
- bitMask = 0x80;
-
- XMC_GPIO_PORT_t* XMC_port = mapping_port_pin[ pin ].port;
- uint8_t XMC_pin = mapping_port_pin[ pin ].pin;
-
- uint32_t omrhigh = (uint32_t)XMC_GPIO_OUTPUT_LEVEL_HIGH << XMC_pin;
- uint32_t omrlow = (uint32_t)XMC_GPIO_OUTPUT_LEVEL_LOW << XMC_pin;
-
-#ifdef NEO_KHZ400 // 800 KHz check needed only if 400 KHz support enabled
- if(is800KHz) {
-#endif
- for(;;) {
- XMC_port->OMR = omrhigh;
- asm("nop; nop; nop; nop;");
- if(p & bitMask) {
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop;");
- XMC_port->OMR = omrlow;
- } else {
- XMC_port->OMR = omrlow;
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop;");
- }
- if(bitMask >>= 1) {
- asm("nop; nop; nop; nop; nop;");
- } else {
- if(ptr >= end) break;
- p = *ptr++;
- bitMask = 0x80;
- }
- }
-#ifdef NEO_KHZ400 // untested code
- } else { // 400 KHz bitstream
- for(;;) {
- XMC_port->OMR = omrhigh;
- asm("nop; nop; nop; nop; nop;");
- if(p & bitMask) {
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop;");
- XMC_port->OMR = omrlow;
- } else {
- XMC_port->OMR = omrlow;
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop;");
- }
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;");
- if(bitMask >>= 1) {
- asm("nop; nop; nop;");
- } else {
- if(ptr >= end) break;
- p = *ptr++;
- bitMask = 0x80;
- }
- }
- }
-
-#endif
-//----
-
-//----
-#elif defined(XMC4700_Relax_Kit) || defined(XMC4800_Relax_Kit)
-
-// XMC4700 and XMC4800 with ARM Cortex M4 are running with 144MHz
-// Tried this with a timer/counter, couldn't quite get adequate
-// resolution. So yay, you get a load of goofball NOPs...
-
-uint8_t *ptr, *end, p, bitMask, portNum;
-uint32_t pinMask;
-
-ptr = pixels;
-end = ptr + numBytes;
-p = *ptr++;
-bitMask = 0x80;
-
-XMC_GPIO_PORT_t* XMC_port = mapping_port_pin[ pin ].port;
-uint8_t XMC_pin = mapping_port_pin[ pin ].pin;
-
-uint32_t omrhigh = (uint32_t)XMC_GPIO_OUTPUT_LEVEL_HIGH << XMC_pin;
-uint32_t omrlow = (uint32_t)XMC_GPIO_OUTPUT_LEVEL_LOW << XMC_pin;
-
-#ifdef NEO_KHZ400 // 800 KHz check needed only if 400 KHz support enabled
-if(is800KHz) {
-#endif
-
- for(;;) {
- XMC_port->OMR = omrhigh;
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop;");
- if(p & bitMask) {
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;");
- XMC_port->OMR = omrlow;
- } else {
- XMC_port->OMR = omrlow;
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;");
- }
- if(bitMask >>= 1) {
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;");
- } else {
- if(ptr >= end) break;
- p = *ptr++;
- bitMask = 0x80;
- }
- }
-
-
-#ifdef NEO_KHZ400
- } else { // 400 KHz bitstream
- // ToDo!
- }
-#endif
-//----
-
-#elif defined(__SAMD51__) // M4
-
- uint8_t *ptr, *end, p, bitMask, portNum, bit;
- uint32_t pinMask;
-
- portNum = g_APinDescription[pin].ulPort;
- pinMask = 1ul << g_APinDescription[pin].ulPin;
- ptr = pixels;
- end = ptr + numBytes;
- p = *ptr++;
- bitMask = 0x80;
-
- volatile uint32_t *set = &(PORT->Group[portNum].OUTSET.reg),
- *clr = &(PORT->Group[portNum].OUTCLR.reg);
-
- // SAMD51 overclock-compatible timing is only a mild abomination.
- // It uses SysTick for a consistent clock reference regardless of
- // optimization / cache settings. That's the good news. The bad news,
- // since SysTick->VAL is a volatile type it's slow to access...and then,
- // with the SysTick interval that Arduino sets up (1 ms), this would
- // require a subtract and MOD operation for gauging elapsed time, and
- // all taken in combination that lacks adequate temporal resolution
- // for NeoPixel timing. So a kind of horrible thing is done here...
- // since interrupts are turned off anyway and it's generally accepted
- // by now that we're gonna lose track of time in the NeoPixel lib,
- // the SysTick timer is reconfigured for a period matching the NeoPixel
- // bit timing (either 800 or 400 KHz) and we watch SysTick->VAL very
- // closely (just a threshold, no subtract or MOD or anything) and that
- // seems to work just well enough. When finished, the SysTick
- // peripheral is set back to its original state.
-
- uint32_t t0, t1, top, ticks, saveLoad = SysTick->LOAD, saveVal = SysTick->VAL;
-
-#if defined(NEO_KHZ400) // 800 KHz check needed only if 400 KHz support enabled
- if (is800KHz) {
-#endif
- top = (uint32_t)(F_CPU * 0.00000125); // Bit hi + lo = 1.25 uS
- t0 = top - (uint32_t)(F_CPU * 0.00000040); // 0 = 0.4 uS hi
- t1 = top - (uint32_t)(F_CPU * 0.00000080); // 1 = 0.8 uS hi
-#if defined(NEO_KHZ400)
- } else { // 400 KHz bitstream
- top = (uint32_t)(F_CPU * 0.00000250); // Bit hi + lo = 2.5 uS
- t0 = top - (uint32_t)(F_CPU * 0.00000050); // 0 = 0.5 uS hi
- t1 = top - (uint32_t)(F_CPU * 0.00000120); // 1 = 1.2 uS hi
- }
-#endif
-
- SysTick->LOAD = top; // Config SysTick for NeoPixel bit freq
- SysTick->VAL = top; // Set to start value (counts down)
- (void)SysTick->VAL; // Dummy read helps sync up 1st bit
-
- for (;;) {
- *set = pinMask; // Set output high
- ticks = (p & bitMask) ? t1 : t0; // SysTick threshold,
- while (SysTick->VAL > ticks)
- ; // wait for it
- *clr = pinMask; // Set output low
- if (!(bitMask >>= 1)) { // Next bit for this byte...done?
- if (ptr >= end)
- break; // If last byte sent, exit loop
- p = *ptr++; // Fetch next byte
- bitMask = 0x80; // Reset bitmask
- }
- while (SysTick->VAL <= ticks)
- ; // Wait for rollover to 'top'
- }
-
- SysTick->LOAD = saveLoad; // Restore SysTick rollover to 1 ms
- SysTick->VAL = saveVal; // Restore SysTick value
-
-#elif defined(ARDUINO_STM32_FEATHER) // FEATHER WICED (120MHz)
-
- // Tried this with a timer/counter, couldn't quite get adequate
- // resolution. So yay, you get a load of goofball NOPs...
-
- uint8_t *ptr, *end, p, bitMask;
- uint32_t pinMask;
-
- pinMask = BIT(PIN_MAP[pin].gpio_bit);
- ptr = pixels;
- end = ptr + numBytes;
- p = *ptr++;
- bitMask = 0x80;
-
- volatile uint16_t *set = &(PIN_MAP[pin].gpio_device->regs->BSRRL);
- volatile uint16_t *clr = &(PIN_MAP[pin].gpio_device->regs->BSRRH);
-
-#if defined(NEO_KHZ400) // 800 KHz check needed only if 400 KHz support enabled
- if (is800KHz) {
-#endif
- for (;;) {
- if (p & bitMask) { // ONE
- // High 800ns
- *set = pinMask;
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop;");
- // Low 450ns
- *clr = pinMask;
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop;");
- } else { // ZERO
- // High 400ns
- *set = pinMask;
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop;");
- // Low 850ns
- *clr = pinMask;
- asm("nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop; nop; nop; nop; nop;"
- "nop; nop; nop; nop;");
- }
- if (bitMask >>= 1) {
- // Move on to the next pixel
- asm("nop;");
- } else {
- if (ptr >= end)
- break;
- p = *ptr++;
- bitMask = 0x80;
- }
- }
-#if defined(NEO_KHZ400)
- } else { // 400 KHz bitstream
- // ToDo!
- }
-#endif
-
-#elif defined(TARGET_LPC1768)
- uint8_t *ptr, *end, p, bitMask;
- ptr = pixels;
- end = ptr + numBytes;
- p = *ptr++;
- bitMask = 0x80;
-
-#if defined(NEO_KHZ400) // 800 KHz check needed only if 400 KHz support enabled
- if (is800KHz) {
-#endif
- for (;;) {
- if (p & bitMask) {
- // data ONE high
- // min: 550 typ: 700 max: 5,500
- gpio_set(pin);
- time::delay_ns(550);
- // min: 450 typ: 600 max: 5,000
- gpio_clear(pin);
- time::delay_ns(450);
- } else {
- // data ZERO high
- // min: 200 typ: 350 max: 500
- gpio_set(pin);
- time::delay_ns(200);
- // data low
- // min: 450 typ: 600 max: 5,000
- gpio_clear(pin);
- time::delay_ns(450);
- }
- if (bitMask >>= 1) {
- // Move on to the next pixel
- asm("nop;");
- } else {
- if (ptr >= end)
- break;
- p = *ptr++;
- bitMask = 0x80;
- }
- }
-#if defined(NEO_KHZ400)
- } else { // 400 KHz bitstream
- // ToDo!
- }
-#endif
-#elif defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_ARDUINO_CORE_STM32)
- uint8_t *p = pixels, *end = p + numBytes, pix = *p++, mask = 0x80;
- uint32_t cyc;
- uint32_t saveLoad = SysTick->LOAD, saveVal = SysTick->VAL;
-#if defined(NEO_KHZ400) // 800 KHz check needed only if 400 KHz support enabled
- if (is800KHz) {
-#endif
- uint32_t top = (F_CPU / 800000); // 1.25µs
- uint32_t t0 = top - (F_CPU / 2500000); // 0.4µs
- uint32_t t1 = top - (F_CPU / 1250000); // 0.8µs
- SysTick->LOAD = top - 1; // Config SysTick for NeoPixel bit freq
- SysTick->VAL = 0; // Set to start value
- for (;;) {
- LL_GPIO_SetOutputPin(gpioPort, gpioPin);
- cyc = (pix & mask) ? t1 : t0;
- while (SysTick->VAL > cyc)
- ;
- LL_GPIO_ResetOutputPin(gpioPort, gpioPin);
- if (!(mask >>= 1)) {
- if (p >= end)
- break;
- pix = *p++;
- mask = 0x80;
- }
- while (SysTick->VAL <= cyc)
- ;
- }
-#if defined(NEO_KHZ400)
- } else { // 400 kHz bitstream
- uint32_t top = (F_CPU / 400000); // 2.5µs
- uint32_t t0 = top - (F_CPU / 2000000); // 0.5µs
- uint32_t t1 = top - (F_CPU / 833333); // 1.2µs
- SysTick->LOAD = top - 1; // Config SysTick for NeoPixel bit freq
- SysTick->VAL = 0; // Set to start value
- for (;;) {
- LL_GPIO_SetOutputPin(gpioPort, gpioPin);
- cyc = (pix & mask) ? t1 : t0;
- while (SysTick->VAL > cyc)
- ;
- LL_GPIO_ResetOutputPin(gpioPort, gpioPin);
- if (!(mask >>= 1)) {
- if (p >= end)
- break;
- pix = *p++;
- mask = 0x80;
- }
- while (SysTick->VAL <= cyc)
- ;
- }
- }
-#endif // NEO_KHZ400
- SysTick->LOAD = saveLoad; // Restore SysTick rollover to 1 ms
- SysTick->VAL = saveVal; // Restore SysTick value
-#elif defined(NRF51)
- uint8_t *p = pixels, pix, count, mask;
- int32_t num = numBytes;
- unsigned int bitmask = (1 << g_ADigitalPinMap[pin]);
- // https://github.com/sandeepmistry/arduino-nRF5/blob/dc53980c8bac27898fca90d8ecb268e11111edc1/variants/BBCmicrobit/variant.cpp
-
- volatile unsigned int *reg = (unsigned int *)(0x50000000UL + 0x508);
-
- // https://github.com/sandeepmistry/arduino-nRF5/blob/dc53980c8bac27898fca90d8ecb268e11111edc1/cores/nRF5/SDK/components/device/nrf51.h
- // http://www.iot-programmer.com/index.php/books/27-micro-bit-iot-in-c/chapters-micro-bit-iot-in-c/47-micro-bit-iot-in-c-fast-memory-mapped-gpio?showall=1
- // https://github.com/Microsoft/pxt-neopixel/blob/master/sendbuffer.asm
-
- asm volatile(
- // "cpsid i" ; disable irq
-
- // b .start
- "b L%=_start"
- "\n\t"
- // .nextbit: ; C0
- "L%=_nextbit:"
- "\n\t" //; C0
- // str r1, [r3, #0] ; pin := hi C2
- "strb %[bitmask], [%[reg], #0]"
- "\n\t" //; pin := hi C2
- // tst r6, r0 ; C3
- "tst %[mask], %[pix]"
- "\n\t" // ; C3
- // bne .islate ; C4
- "bne L%=_islate"
- "\n\t" //; C4
- // str r1, [r2, #0] ; pin := lo C6
- "strb %[bitmask], [%[reg], #4]"
- "\n\t" //; pin := lo C6
- // .islate:
- "L%=_islate:"
- "\n\t"
- // lsrs r6, r6, #1 ; r6 >>= 1 C7
- "lsr %[mask], %[mask], #1"
- "\n\t" //; r6 >>= 1 C7
- // bne .justbit ; C8
- "bne L%=_justbit"
- "\n\t" //; C8
-
- // ; not just a bit - need new byte
- // adds r4, #1 ; r4++ C9
- "add %[p], #1"
- "\n\t" //; r4++ C9
- // subs r5, #1 ; r5-- C10
- "sub %[num], #1"
- "\n\t" //; r5-- C10
- // bcc .stop ; if (r5<0) goto .stop C11
- "bcc L%=_stop"
- "\n\t" //; if (r5<0) goto .stop C11
- // .start:
- "L%=_start:"
- // movs r6, #0x80 ; reset mask C12
- "movs %[mask], #0x80"
- "\n\t" //; reset mask C12
- // nop ; C13
- "nop"
- "\n\t" //; C13
-
- // .common: ; C13
- "L%=_common:"
- "\n\t" //; C13
- // str r1, [r2, #0] ; pin := lo C15
- "strb %[bitmask], [%[reg], #4]"
- "\n\t" //; pin := lo C15
- // ; always re-load byte - it just fits with the cycles better this way
- // ldrb r0, [r4, #0] ; r0 := *r4 C17
- "ldrb %[pix], [%[p], #0]"
- "\n\t" //; r0 := *r4 C17
- // b .nextbit ; C20
- "b L%=_nextbit"
- "\n\t" //; C20
-
- // .justbit: ; C10
- "L%=_justbit:"
- "\n\t" //; C10
- // ; no nops, branch taken is already 3 cycles
- // b .common ; C13
- "b L%=_common"
- "\n\t" //; C13
-
- // .stop:
- "L%=_stop:"
- "\n\t"
- // str r1, [r2, #0] ; pin := lo
- "strb %[bitmask], [%[reg], #4]"
- "\n\t" //; pin := lo
- // cpsie i ; enable irq
-
- : [p] "+r"(p), [pix] "=&r"(pix), [count] "=&r"(count), [mask] "=&r"(mask),
- [num] "+r"(num)
- : [bitmask] "r"(bitmask), [reg] "r"(reg));
-
-#elif defined(__SAM3X8E__) // Arduino Due
-
-#define SCALE VARIANT_MCK / 2UL / 1000000UL
-#define INST (2UL * F_CPU / VARIANT_MCK)
-#define TIME_800_0 ((int)(0.40 * SCALE + 0.5) - (5 * INST))
-#define TIME_800_1 ((int)(0.80 * SCALE + 0.5) - (5 * INST))
-#define PERIOD_800 ((int)(1.25 * SCALE + 0.5) - (5 * INST))
-#define TIME_400_0 ((int)(0.50 * SCALE + 0.5) - (5 * INST))
-#define TIME_400_1 ((int)(1.20 * SCALE + 0.5) - (5 * INST))
-#define PERIOD_400 ((int)(2.50 * SCALE + 0.5) - (5 * INST))
-
- int pinMask, time0, time1, period, t;
- Pio *port;
- volatile WoReg *portSet, *portClear, *timeValue, *timeReset;
- uint8_t *p, *end, pix, mask;
-
- pmc_set_writeprotect(false);
- pmc_enable_periph_clk((uint32_t)TC3_IRQn);
- TC_Configure(TC1, 0,
- TC_CMR_WAVE | TC_CMR_WAVSEL_UP | TC_CMR_TCCLKS_TIMER_CLOCK1);
- TC_Start(TC1, 0);
-
- pinMask = g_APinDescription[pin].ulPin; // Don't 'optimize' these into
- port = g_APinDescription[pin].pPort; // declarations above. Want to
- portSet = &(port->PIO_SODR); // burn a few cycles after
- portClear = &(port->PIO_CODR); // starting timer to minimize
- timeValue = &(TC1->TC_CHANNEL[0].TC_CV); // the initial 'while'.
- timeReset = &(TC1->TC_CHANNEL[0].TC_CCR);
- p = pixels;
- end = p + numBytes;
- pix = *p++;
- mask = 0x80;
-
-#if defined(NEO_KHZ400) // 800 KHz check needed only if 400 KHz support enabled
- if (is800KHz) {
-#endif
- time0 = TIME_800_0;
- time1 = TIME_800_1;
- period = PERIOD_800;
-#if defined(NEO_KHZ400)
- } else { // 400 KHz bitstream
- time0 = TIME_400_0;
- time1 = TIME_400_1;
- period = PERIOD_400;
- }
-#endif
-
- for (t = time0;; t = time0) {
- if (pix & mask)
- t = time1;
- while (*timeValue < (unsigned)period)
- ;
- *portSet = pinMask;
- *timeReset = TC_CCR_CLKEN | TC_CCR_SWTRG;
- while (*timeValue < (unsigned)t)
- ;
- *portClear = pinMask;
- if (!(mask >>= 1)) { // This 'inside-out' loop logic utilizes
- if (p >= end)
- break; // idle time to minimize inter-byte delays.
- pix = *p++;
- mask = 0x80;
- }
- }
- while (*timeValue < (unsigned)period)
- ; // Wait for last bit
- TC_Stop(TC1, 0);
-
-#endif // end Due
-
- // END ARM ----------------------------------------------------------------
-
-#elif defined(ESP8266) || defined(ESP32)
-
- // ESP8266 ----------------------------------------------------------------
-
- // ESP8266 show() is external to enforce ICACHE_RAM_ATTR execution
- espShow(pin, pixels, numBytes, is800KHz);
-
-#elif defined(KENDRYTE_K210)
-
- k210Show(pin, pixels, numBytes, is800KHz);
-
-#elif defined(__ARDUINO_ARC__)
-
- // Arduino 101 -----------------------------------------------------------
-
-#define NOPx7 \
- { \
- __builtin_arc_nop(); \
- __builtin_arc_nop(); \
- __builtin_arc_nop(); \
- __builtin_arc_nop(); \
- __builtin_arc_nop(); \
- __builtin_arc_nop(); \
- __builtin_arc_nop(); \
- }
-
- PinDescription *pindesc = &g_APinDescription[pin];
- register uint32_t loop =
- 8 * numBytes; // one loop to handle all bytes and all bits
- register uint8_t *p = pixels;
- register uint32_t currByte = (uint32_t)(*p);
- register uint32_t currBit = 0x80 & currByte;
- register uint32_t bitCounter = 0;
- register uint32_t first = 1;
-
- // The loop is unusual. Very first iteration puts all the way LOW to the wire
- // - constant LOW does not affect NEOPIXEL, so there is no visible effect
- // displayed. During that very first iteration CPU caches instructions in the
- // loop. Because of the caching process, "CPU slows down". NEOPIXEL pulse is
- // very time sensitive that's why we let the CPU cache first and we start
- // regular pulse from 2nd iteration
- if (pindesc->ulGPIOType == SS_GPIO) {
- register uint32_t reg = pindesc->ulGPIOBase + SS_GPIO_SWPORTA_DR;
- uint32_t reg_val = __builtin_arc_lr((volatile uint32_t)reg);
- register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
- register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
-
- loop += 1; // include first, special iteration
- while (loop--) {
- if (!first) {
- currByte <<= 1;
- bitCounter++;
- }
-
- // 1 is >550ns high and >450ns low; 0 is 200..500ns high and >450ns low
- __builtin_arc_sr(first ? reg_bit_low : reg_bit_high,
- (volatile uint32_t)reg);
- if (currBit) { // ~400ns HIGH (740ns overall)
- NOPx7 NOPx7
- }
- // ~340ns HIGH
- NOPx7 __builtin_arc_nop();
-
- // 820ns LOW; per spec, max allowed low here is 5000ns */
- __builtin_arc_sr(reg_bit_low, (volatile uint32_t)reg);
- NOPx7 NOPx7
-
- if (bitCounter >= 8) {
- bitCounter = 0;
- currByte = (uint32_t)(*++p);
- }
-
- currBit = 0x80 & currByte;
- first = 0;
- }
- } else if (pindesc->ulGPIOType == SOC_GPIO) {
- register uint32_t reg = pindesc->ulGPIOBase + SOC_GPIO_SWPORTA_DR;
- uint32_t reg_val = MMIO_REG_VAL(reg);
- register uint32_t reg_bit_high = reg_val | (1 << pindesc->ulGPIOId);
- register uint32_t reg_bit_low = reg_val & ~(1 << pindesc->ulGPIOId);
-
- loop += 1; // include first, special iteration
- while (loop--) {
- if (!first) {
- currByte <<= 1;
- bitCounter++;
- }
- MMIO_REG_VAL(reg) = first ? reg_bit_low : reg_bit_high;
- if (currBit) { // ~430ns HIGH (740ns overall)
- NOPx7 NOPx7 __builtin_arc_nop();
- }
- // ~310ns HIGH
- NOPx7
-
- // 850ns LOW; per spec, max allowed low here is 5000ns */
- MMIO_REG_VAL(reg) = reg_bit_low;
- NOPx7 NOPx7
-
- if (bitCounter >= 8) {
- bitCounter = 0;
- currByte = (uint32_t)(*++p);
- }
-
- currBit = 0x80 & currByte;
- first = 0;
- }
- }
-
-#else
-#error Architecture not supported
-#endif
-
- // END ARCHITECTURE SELECT ------------------------------------------------
-
-#if !(defined(NRF52) || defined(NRF52_SERIES) || defined(ESP32))
- interrupts();
-#endif
-
- endTime = micros(); // Save EOD time for latch on next call
-}
-
-/*!
- @brief Set/change the NeoPixel output pin number. Previous pin,
- if any, is set to INPUT and the new pin is set to OUTPUT.
- @param p Arduino pin number (-1 = no pin).
-*/
-void Adafruit_NeoPixel::setPin(int16_t p) {
- if (begun && (pin >= 0))
- pinMode(pin, INPUT); // Disable existing out pin
- pin = p;
- if (begun) {
- pinMode(p, OUTPUT);
- digitalWrite(p, LOW);
- }
-#if defined(__AVR__)
- port = portOutputRegister(digitalPinToPort(p));
- pinMask = digitalPinToBitMask(p);
-#endif
-#if defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_ARDUINO_CORE_STM32)
- gpioPort = digitalPinToPort(p);
- gpioPin = STM_LL_GPIO_PIN(digitalPinToPinName(p));
-#endif
-}
-
-/*!
- @brief Set a pixel's color using separate red, green and blue
- components. If using RGBW pixels, white will be set to 0.
- @param n Pixel index, starting from 0.
- @param r Red brightness, 0 = minimum (off), 255 = maximum.
- @param g Green brightness, 0 = minimum (off), 255 = maximum.
- @param b Blue brightness, 0 = minimum (off), 255 = maximum.
-*/
-void Adafruit_NeoPixel::setPixelColor(uint16_t n, uint8_t r, uint8_t g,
- uint8_t b) {
-
- if (n < numLEDs) {
- if (brightness) { // See notes in setBrightness()
- r = (r * brightness) >> 8;
- g = (g * brightness) >> 8;
- b = (b * brightness) >> 8;
- }
- uint8_t *p;
- if (wOffset == rOffset) { // Is an RGB-type strip
- p = &pixels[n * 3]; // 3 bytes per pixel
- } else { // Is a WRGB-type strip
- p = &pixels[n * 4]; // 4 bytes per pixel
- p[wOffset] = 0; // But only R,G,B passed -- set W to 0
- }
- p[rOffset] = r; // R,G,B always stored
- p[gOffset] = g;
- p[bOffset] = b;
- }
-}
-
-/*!
- @brief Set a pixel's color using separate red, green, blue and white
- components (for RGBW NeoPixels only).
- @param n Pixel index, starting from 0.
- @param r Red brightness, 0 = minimum (off), 255 = maximum.
- @param g Green brightness, 0 = minimum (off), 255 = maximum.
- @param b Blue brightness, 0 = minimum (off), 255 = maximum.
- @param w White brightness, 0 = minimum (off), 255 = maximum, ignored
- if using RGB pixels.
-*/
-void Adafruit_NeoPixel::setPixelColor(uint16_t n, uint8_t r, uint8_t g,
- uint8_t b, uint8_t w) {
-
- if (n < numLEDs) {
- if (brightness) { // See notes in setBrightness()
- r = (r * brightness) >> 8;
- g = (g * brightness) >> 8;
- b = (b * brightness) >> 8;
- w = (w * brightness) >> 8;
- }
- uint8_t *p;
- if (wOffset == rOffset) { // Is an RGB-type strip
- p = &pixels[n * 3]; // 3 bytes per pixel (ignore W)
- } else { // Is a WRGB-type strip
- p = &pixels[n * 4]; // 4 bytes per pixel
- p[wOffset] = w; // Store W
- }
- p[rOffset] = r; // Store R,G,B
- p[gOffset] = g;
- p[bOffset] = b;
- }
-}
-
-/*!
- @brief Set a pixel's color using a 32-bit 'packed' RGB or RGBW value.
- @param n Pixel index, starting from 0.
- @param c 32-bit color value. Most significant byte is white (for RGBW
- pixels) or ignored (for RGB pixels), next is red, then green,
- and least significant byte is blue.
-*/
-void Adafruit_NeoPixel::setPixelColor(uint16_t n, uint32_t c) {
- if (n < numLEDs) {
- uint8_t *p, r = (uint8_t)(c >> 16), g = (uint8_t)(c >> 8), b = (uint8_t)c;
- if (brightness) { // See notes in setBrightness()
- r = (r * brightness) >> 8;
- g = (g * brightness) >> 8;
- b = (b * brightness) >> 8;
- }
- if (wOffset == rOffset) {
- p = &pixels[n * 3];
- } else {
- p = &pixels[n * 4];
- uint8_t w = (uint8_t)(c >> 24);
- p[wOffset] = brightness ? ((w * brightness) >> 8) : w;
- }
- p[rOffset] = r;
- p[gOffset] = g;
- p[bOffset] = b;
- }
-}
-
-/*!
- @brief Fill all or part of the NeoPixel strip with a color.
- @param c 32-bit color value. Most significant byte is white (for
- RGBW pixels) or ignored (for RGB pixels), next is red,
- then green, and least significant byte is blue. If all
- arguments are unspecified, this will be 0 (off).
- @param first Index of first pixel to fill, starting from 0. Must be
- in-bounds, no clipping is performed. 0 if unspecified.
- @param count Number of pixels to fill, as a positive value. Passing
- 0 or leaving unspecified will fill to end of strip.
-*/
-void Adafruit_NeoPixel::fill(uint32_t c, uint16_t first, uint16_t count) {
- uint16_t i, end;
-
- if (first >= numLEDs) {
- return; // If first LED is past end of strip, nothing to do
- }
-
- // Calculate the index ONE AFTER the last pixel to fill
- if (count == 0) {
- // Fill to end of strip
- end = numLEDs;
- } else {
- // Ensure that the loop won't go past the last pixel
- end = first + count;
- if (end > numLEDs)
- end = numLEDs;
- }
-
- for (i = first; i < end; i++) {
- this->setPixelColor(i, c);
- }
-}
-
-/*!
- @brief Convert hue, saturation and value into a packed 32-bit RGB color
- that can be passed to setPixelColor() or other RGB-compatible
- functions.
- @param hue An unsigned 16-bit value, 0 to 65535, representing one full
- loop of the color wheel, which allows 16-bit hues to "roll
- over" while still doing the expected thing (and allowing
- more precision than the wheel() function that was common to
- prior NeoPixel examples).
- @param sat Saturation, 8-bit value, 0 (min or pure grayscale) to 255
- (max or pure hue). Default of 255 if unspecified.
- @param val Value (brightness), 8-bit value, 0 (min / black / off) to
- 255 (max or full brightness). Default of 255 if unspecified.
- @return Packed 32-bit RGB with the most significant byte set to 0 -- the
- white element of WRGB pixels is NOT utilized. Result is linearly
- but not perceptually correct, so you may want to pass the result
- through the gamma32() function (or your own gamma-correction
- operation) else colors may appear washed out. This is not done
- automatically by this function because coders may desire a more
- refined gamma-correction function than the simplified
- one-size-fits-all operation of gamma32(). Diffusing the LEDs also
- really seems to help when using low-saturation colors.
-*/
-uint32_t Adafruit_NeoPixel::ColorHSV(uint16_t hue, uint8_t sat, uint8_t val) {
-
- uint8_t r, g, b;
-
- // Remap 0-65535 to 0-1529. Pure red is CENTERED on the 64K rollover;
- // 0 is not the start of pure red, but the midpoint...a few values above
- // zero and a few below 65536 all yield pure red (similarly, 32768 is the
- // midpoint, not start, of pure cyan). The 8-bit RGB hexcone (256 values
- // each for red, green, blue) really only allows for 1530 distinct hues
- // (not 1536, more on that below), but the full unsigned 16-bit type was
- // chosen for hue so that one's code can easily handle a contiguous color
- // wheel by allowing hue to roll over in either direction.
- hue = (hue * 1530L + 32768) / 65536;
- // Because red is centered on the rollover point (the +32768 above,
- // essentially a fixed-point +0.5), the above actually yields 0 to 1530,
- // where 0 and 1530 would yield the same thing. Rather than apply a
- // costly modulo operator, 1530 is handled as a special case below.
-
- // So you'd think that the color "hexcone" (the thing that ramps from
- // pure red, to pure yellow, to pure green and so forth back to red,
- // yielding six slices), and with each color component having 256
- // possible values (0-255), might have 1536 possible items (6*256),
- // but in reality there's 1530. This is because the last element in
- // each 256-element slice is equal to the first element of the next
- // slice, and keeping those in there this would create small
- // discontinuities in the color wheel. So the last element of each
- // slice is dropped...we regard only elements 0-254, with item 255
- // being picked up as element 0 of the next slice. Like this:
- // Red to not-quite-pure-yellow is: 255, 0, 0 to 255, 254, 0
- // Pure yellow to not-quite-pure-green is: 255, 255, 0 to 1, 255, 0
- // Pure green to not-quite-pure-cyan is: 0, 255, 0 to 0, 255, 254
- // and so forth. Hence, 1530 distinct hues (0 to 1529), and hence why
- // the constants below are not the multiples of 256 you might expect.
-
- // Convert hue to R,G,B (nested ifs faster than divide+mod+switch):
- if (hue < 510) { // Red to Green-1
- b = 0;
- if (hue < 255) { // Red to Yellow-1
- r = 255;
- g = hue; // g = 0 to 254
- } else { // Yellow to Green-1
- r = 510 - hue; // r = 255 to 1
- g = 255;
- }
- } else if (hue < 1020) { // Green to Blue-1
- r = 0;
- if (hue < 765) { // Green to Cyan-1
- g = 255;
- b = hue - 510; // b = 0 to 254
- } else { // Cyan to Blue-1
- g = 1020 - hue; // g = 255 to 1
- b = 255;
- }
- } else if (hue < 1530) { // Blue to Red-1
- g = 0;
- if (hue < 1275) { // Blue to Magenta-1
- r = hue - 1020; // r = 0 to 254
- b = 255;
- } else { // Magenta to Red-1
- r = 255;
- b = 1530 - hue; // b = 255 to 1
- }
- } else { // Last 0.5 Red (quicker than % operator)
- r = 255;
- g = b = 0;
- }
-
- // Apply saturation and value to R,G,B, pack into 32-bit result:
- uint32_t v1 = 1 + val; // 1 to 256; allows >>8 instead of /255
- uint16_t s1 = 1 + sat; // 1 to 256; same reason
- uint8_t s2 = 255 - sat; // 255 to 0
- return ((((((r * s1) >> 8) + s2) * v1) & 0xff00) << 8) |
- (((((g * s1) >> 8) + s2) * v1) & 0xff00) |
- (((((b * s1) >> 8) + s2) * v1) >> 8);
-}
-
-/*!
- @brief Query the color of a previously-set pixel.
- @param n Index of pixel to read (0 = first).
- @return 'Packed' 32-bit RGB or WRGB value. Most significant byte is white
- (for RGBW pixels) or 0 (for RGB pixels), next is red, then green,
- and least significant byte is blue.
- @note If the strip brightness has been changed from the default value
- of 255, the color read from a pixel may not exactly match what
- was previously written with one of the setPixelColor() functions.
- This gets more pronounced at lower brightness levels.
-*/
-uint32_t Adafruit_NeoPixel::getPixelColor(uint16_t n) const {
- if (n >= numLEDs)
- return 0; // Out of bounds, return no color.
-
- uint8_t *p;
-
- if (wOffset == rOffset) { // Is RGB-type device
- p = &pixels[n * 3];
- if (brightness) {
- // Stored color was decimated by setBrightness(). Returned value
- // attempts to scale back to an approximation of the original 24-bit
- // value used when setting the pixel color, but there will always be
- // some error -- those bits are simply gone. Issue is most
- // pronounced at low brightness levels.
- return (((uint32_t)(p[rOffset] << 8) / brightness) << 16) |
- (((uint32_t)(p[gOffset] << 8) / brightness) << 8) |
- ((uint32_t)(p[bOffset] << 8) / brightness);
- } else {
- // No brightness adjustment has been made -- return 'raw' color
- return ((uint32_t)p[rOffset] << 16) | ((uint32_t)p[gOffset] << 8) |
- (uint32_t)p[bOffset];
- }
- } else { // Is RGBW-type device
- p = &pixels[n * 4];
- if (brightness) { // Return scaled color
- return (((uint32_t)(p[wOffset] << 8) / brightness) << 24) |
- (((uint32_t)(p[rOffset] << 8) / brightness) << 16) |
- (((uint32_t)(p[gOffset] << 8) / brightness) << 8) |
- ((uint32_t)(p[bOffset] << 8) / brightness);
- } else { // Return raw color
- return ((uint32_t)p[wOffset] << 24) | ((uint32_t)p[rOffset] << 16) |
- ((uint32_t)p[gOffset] << 8) | (uint32_t)p[bOffset];
- }
- }
-}
-
-/*!
- @brief Adjust output brightness. Does not immediately affect what's
- currently displayed on the LEDs. The next call to show() will
- refresh the LEDs at this level.
- @param b Brightness setting, 0=minimum (off), 255=brightest.
- @note This was intended for one-time use in one's setup() function,
- not as an animation effect in itself. Because of the way this
- library "pre-multiplies" LED colors in RAM, changing the
- brightness is often a "lossy" operation -- what you write to
- pixels isn't necessary the same as what you'll read back.
- Repeated brightness changes using this function exacerbate the
- problem. Smart programs therefore treat the strip as a
- write-only resource, maintaining their own state to render each
- frame of an animation, not relying on read-modify-write.
-*/
-void Adafruit_NeoPixel::setBrightness(uint8_t b) {
- // Stored brightness value is different than what's passed.
- // This simplifies the actual scaling math later, allowing a fast
- // 8x8-bit multiply and taking the MSB. 'brightness' is a uint8_t,
- // adding 1 here may (intentionally) roll over...so 0 = max brightness
- // (color values are interpreted literally; no scaling), 1 = min
- // brightness (off), 255 = just below max brightness.
- uint8_t newBrightness = b + 1;
- if (newBrightness != brightness) { // Compare against prior value
- // Brightness has changed -- re-scale existing data in RAM,
- // This process is potentially "lossy," especially when increasing
- // brightness. The tight timing in the WS2811/WS2812 code means there
- // aren't enough free cycles to perform this scaling on the fly as data
- // is issued. So we make a pass through the existing color data in RAM
- // and scale it (subsequent graphics commands also work at this
- // brightness level). If there's a significant step up in brightness,
- // the limited number of steps (quantization) in the old data will be
- // quite visible in the re-scaled version. For a non-destructive
- // change, you'll need to re-render the full strip data. C'est la vie.
- uint8_t c, *ptr = pixels,
- oldBrightness = brightness - 1; // De-wrap old brightness value
- uint16_t scale;
- if (oldBrightness == 0)
- scale = 0; // Avoid /0
- else if (b == 255)
- scale = 65535 / oldBrightness;
- else
- scale = (((uint16_t)newBrightness << 8) - 1) / oldBrightness;
- for (uint16_t i = 0; i < numBytes; i++) {
- c = *ptr;
- *ptr++ = (c * scale) >> 8;
- }
- brightness = newBrightness;
- }
-}
-
-/*!
- @brief Retrieve the last-set brightness value for the strip.
- @return Brightness value: 0 = minimum (off), 255 = maximum.
-*/
-uint8_t Adafruit_NeoPixel::getBrightness(void) const { return brightness - 1; }
-
-/*!
- @brief Fill the whole NeoPixel strip with 0 / black / off.
-*/
-void Adafruit_NeoPixel::clear(void) { memset(pixels, 0, numBytes); }
-
-// A 32-bit variant of gamma8() that applies the same function
-// to all components of a packed RGB or WRGB value.
-uint32_t Adafruit_NeoPixel::gamma32(uint32_t x) {
- uint8_t *y = (uint8_t *)&x;
- // All four bytes of a 32-bit value are filtered even if RGB (not WRGB),
- // to avoid a bunch of shifting and masking that would be necessary for
- // properly handling different endianisms (and each byte is a fairly
- // trivial operation, so it might not even be wasting cycles vs a check
- // and branch for the RGB case). In theory this might cause trouble *if*
- // someone's storing information in the unused most significant byte
- // of an RGB value, but this seems exceedingly rare and if it's
- // encountered in reality they can mask values going in or coming out.
- for (uint8_t i = 0; i < 4; i++)
- y[i] = gamma8(y[i]);
- return x; // Packed 32-bit return
-}
-
-/*!
- @brief Fill NeoPixel strip with one or more cycles of hues.
- Everyone loves the rainbow swirl so much, now it's canon!
- @param first_hue Hue of first pixel, 0-65535, representing one full
- cycle of the color wheel. Each subsequent pixel will
- be offset to complete one or more cycles over the
- length of the strip.
- @param reps Number of cycles of the color wheel over the length
- of the strip. Default is 1. Negative values can be
- used to reverse the hue order.
- @param saturation Saturation (optional), 0-255 = gray to pure hue,
- default = 255.
- @param brightness Brightness/value (optional), 0-255 = off to max,
- default = 255. This is distinct and in combination
- with any configured global strip brightness.
- @param gammify If true (default), apply gamma correction to colors
- for better appearance.
-*/
-void Adafruit_NeoPixel::rainbow(uint16_t first_hue, int8_t reps,
- uint8_t saturation, uint8_t brightness, bool gammify) {
- for (uint16_t i=0; i.
- *
- */
-
-#ifndef ADAFRUIT_NEOPIXEL_H
-#define ADAFRUIT_NEOPIXEL_H
-
-#ifdef ARDUINO
-#if (ARDUINO >= 100)
-#include
-#else
-#include
-#include
-#endif
-
-#ifdef USE_TINYUSB // For Serial when selecting TinyUSB
-#include
-#endif
-
-#endif
-
-#ifdef TARGET_LPC1768
-#include
-#endif
-
-#if defined(ARDUINO_ARCH_RP2040)
-#include
-#include "hardware/pio.h"
-#include "hardware/clocks.h"
-#include "rp2040_pio.h"
-#endif
-
-// The order of primary colors in the NeoPixel data stream can vary among
-// device types, manufacturers and even different revisions of the same
-// item. The third parameter to the Adafruit_NeoPixel constructor encodes
-// the per-pixel byte offsets of the red, green and blue primaries (plus
-// white, if present) in the data stream -- the following #defines provide
-// an easier-to-use named version for each permutation. e.g. NEO_GRB
-// indicates a NeoPixel-compatible device expecting three bytes per pixel,
-// with the first byte transmitted containing the green value, second
-// containing red and third containing blue. The in-memory representation
-// of a chain of NeoPixels is the same as the data-stream order; no
-// re-ordering of bytes is required when issuing data to the chain.
-// Most of these values won't exist in real-world devices, but it's done
-// this way so we're ready for it (also, if using the WS2811 driver IC,
-// one might have their pixels set up in any weird permutation).
-
-// Bits 5,4 of this value are the offset (0-3) from the first byte of a
-// pixel to the location of the red color byte. Bits 3,2 are the green
-// offset and 1,0 are the blue offset. If it is an RGBW-type device
-// (supporting a white primary in addition to R,G,B), bits 7,6 are the
-// offset to the white byte...otherwise, bits 7,6 are set to the same value
-// as 5,4 (red) to indicate an RGB (not RGBW) device.
-// i.e. binary representation:
-// 0bWWRRGGBB for RGBW devices
-// 0bRRRRGGBB for RGB
-
-// RGB NeoPixel permutations; white and red offsets are always same
-// Offset: W R G B
-#define NEO_RGB ((0 << 6) | (0 << 4) | (1 << 2) | (2)) ///< Transmit as R,G,B
-#define NEO_RBG ((0 << 6) | (0 << 4) | (2 << 2) | (1)) ///< Transmit as R,B,G
-#define NEO_GRB ((1 << 6) | (1 << 4) | (0 << 2) | (2)) ///< Transmit as G,R,B
-#define NEO_GBR ((2 << 6) | (2 << 4) | (0 << 2) | (1)) ///< Transmit as G,B,R
-#define NEO_BRG ((1 << 6) | (1 << 4) | (2 << 2) | (0)) ///< Transmit as B,R,G
-#define NEO_BGR ((2 << 6) | (2 << 4) | (1 << 2) | (0)) ///< Transmit as B,G,R
-
-// RGBW NeoPixel permutations; all 4 offsets are distinct
-// Offset: W R G B
-#define NEO_WRGB ((0 << 6) | (1 << 4) | (2 << 2) | (3)) ///< Transmit as W,R,G,B
-#define NEO_WRBG ((0 << 6) | (1 << 4) | (3 << 2) | (2)) ///< Transmit as W,R,B,G
-#define NEO_WGRB ((0 << 6) | (2 << 4) | (1 << 2) | (3)) ///< Transmit as W,G,R,B
-#define NEO_WGBR ((0 << 6) | (3 << 4) | (1 << 2) | (2)) ///< Transmit as W,G,B,R
-#define NEO_WBRG ((0 << 6) | (2 << 4) | (3 << 2) | (1)) ///< Transmit as W,B,R,G
-#define NEO_WBGR ((0 << 6) | (3 << 4) | (2 << 2) | (1)) ///< Transmit as W,B,G,R
-
-#define NEO_RWGB ((1 << 6) | (0 << 4) | (2 << 2) | (3)) ///< Transmit as R,W,G,B
-#define NEO_RWBG ((1 << 6) | (0 << 4) | (3 << 2) | (2)) ///< Transmit as R,W,B,G
-#define NEO_RGWB ((2 << 6) | (0 << 4) | (1 << 2) | (3)) ///< Transmit as R,G,W,B
-#define NEO_RGBW ((3 << 6) | (0 << 4) | (1 << 2) | (2)) ///< Transmit as R,G,B,W
-#define NEO_RBWG ((2 << 6) | (0 << 4) | (3 << 2) | (1)) ///< Transmit as R,B,W,G
-#define NEO_RBGW ((3 << 6) | (0 << 4) | (2 << 2) | (1)) ///< Transmit as R,B,G,W
-
-#define NEO_GWRB ((1 << 6) | (2 << 4) | (0 << 2) | (3)) ///< Transmit as G,W,R,B
-#define NEO_GWBR ((1 << 6) | (3 << 4) | (0 << 2) | (2)) ///< Transmit as G,W,B,R
-#define NEO_GRWB ((2 << 6) | (1 << 4) | (0 << 2) | (3)) ///< Transmit as G,R,W,B
-#define NEO_GRBW ((3 << 6) | (1 << 4) | (0 << 2) | (2)) ///< Transmit as G,R,B,W
-#define NEO_GBWR ((2 << 6) | (3 << 4) | (0 << 2) | (1)) ///< Transmit as G,B,W,R
-#define NEO_GBRW ((3 << 6) | (2 << 4) | (0 << 2) | (1)) ///< Transmit as G,B,R,W
-
-#define NEO_BWRG ((1 << 6) | (2 << 4) | (3 << 2) | (0)) ///< Transmit as B,W,R,G
-#define NEO_BWGR ((1 << 6) | (3 << 4) | (2 << 2) | (0)) ///< Transmit as B,W,G,R
-#define NEO_BRWG ((2 << 6) | (1 << 4) | (3 << 2) | (0)) ///< Transmit as B,R,W,G
-#define NEO_BRGW ((3 << 6) | (1 << 4) | (2 << 2) | (0)) ///< Transmit as B,R,G,W
-#define NEO_BGWR ((2 << 6) | (3 << 4) | (1 << 2) | (0)) ///< Transmit as B,G,W,R
-#define NEO_BGRW ((3 << 6) | (2 << 4) | (1 << 2) | (0)) ///< Transmit as B,G,R,W
-
-// Add NEO_KHZ400 to the color order value to indicate a 400 KHz device.
-// All but the earliest v1 NeoPixels expect an 800 KHz data stream, this is
-// the default if unspecified. Because flash space is very limited on ATtiny
-// devices (e.g. Trinket, Gemma), v1 NeoPixels aren't handled by default on
-// those chips, though it can be enabled by removing the ifndef/endif below,
-// but code will be bigger. Conversely, can disable the NEO_KHZ400 line on
-// other MCUs to remove v1 support and save a little space.
-
-#define NEO_KHZ800 0x0000 ///< 800 KHz data transmission
-#ifndef __AVR_ATtiny85__
-#define NEO_KHZ400 0x0100 ///< 400 KHz data transmission
-#endif
-
-// If 400 KHz support is enabled, the third parameter to the constructor
-// requires a 16-bit value (in order to select 400 vs 800 KHz speed).
-// If only 800 KHz is enabled (as is default on ATtiny), an 8-bit value
-// is sufficient to encode pixel color order, saving some space.
-
-#ifdef NEO_KHZ400
-typedef uint16_t neoPixelType; ///< 3rd arg to Adafruit_NeoPixel constructor
-#else
-typedef uint8_t neoPixelType; ///< 3rd arg to Adafruit_NeoPixel constructor
-#endif
-
-// These two tables are declared outside the Adafruit_NeoPixel class
-// because some boards may require oldschool compilers that don't
-// handle the C++11 constexpr keyword.
-
-/* A PROGMEM (flash mem) table containing 8-bit unsigned sine wave (0-255).
- Copy & paste this snippet into a Python REPL to regenerate:
-import math
-for x in range(256):
- print("{:3},".format(int((math.sin(x/128.0*math.pi)+1.0)*127.5+0.5))),
- if x&15 == 15: print
-*/
-static const uint8_t PROGMEM _NeoPixelSineTable[256] = {
- 128, 131, 134, 137, 140, 143, 146, 149, 152, 155, 158, 162, 165, 167, 170,
- 173, 176, 179, 182, 185, 188, 190, 193, 196, 198, 201, 203, 206, 208, 211,
- 213, 215, 218, 220, 222, 224, 226, 228, 230, 232, 234, 235, 237, 238, 240,
- 241, 243, 244, 245, 246, 248, 249, 250, 250, 251, 252, 253, 253, 254, 254,
- 254, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 253, 253, 252, 251,
- 250, 250, 249, 248, 246, 245, 244, 243, 241, 240, 238, 237, 235, 234, 232,
- 230, 228, 226, 224, 222, 220, 218, 215, 213, 211, 208, 206, 203, 201, 198,
- 196, 193, 190, 188, 185, 182, 179, 176, 173, 170, 167, 165, 162, 158, 155,
- 152, 149, 146, 143, 140, 137, 134, 131, 128, 124, 121, 118, 115, 112, 109,
- 106, 103, 100, 97, 93, 90, 88, 85, 82, 79, 76, 73, 70, 67, 65,
- 62, 59, 57, 54, 52, 49, 47, 44, 42, 40, 37, 35, 33, 31, 29,
- 27, 25, 23, 21, 20, 18, 17, 15, 14, 12, 11, 10, 9, 7, 6,
- 5, 5, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 9, 10, 11,
- 12, 14, 15, 17, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37,
- 40, 42, 44, 47, 49, 52, 54, 57, 59, 62, 65, 67, 70, 73, 76,
- 79, 82, 85, 88, 90, 93, 97, 100, 103, 106, 109, 112, 115, 118, 121,
- 124};
-
-/* Similar to above, but for an 8-bit gamma-correction table.
- Copy & paste this snippet into a Python REPL to regenerate:
-import math
-gamma=2.6
-for x in range(256):
- print("{:3},".format(int(math.pow((x)/255.0,gamma)*255.0+0.5))),
- if x&15 == 15: print
-*/
-static const uint8_t PROGMEM _NeoPixelGammaTable[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3,
- 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6,
- 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10,
- 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17,
- 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
- 25, 26, 27, 27, 28, 29, 29, 30, 31, 31, 32, 33, 34, 34, 35,
- 36, 37, 38, 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 80, 81,
- 82, 84, 85, 86, 88, 89, 90, 92, 93, 94, 96, 97, 99, 100, 102,
- 103, 105, 106, 108, 109, 111, 112, 114, 115, 117, 119, 120, 122, 124, 125,
- 127, 129, 130, 132, 134, 136, 137, 139, 141, 143, 145, 146, 148, 150, 152,
- 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182,
- 184, 186, 188, 191, 193, 195, 197, 199, 202, 204, 206, 209, 211, 213, 215,
- 218, 220, 223, 225, 227, 230, 232, 235, 237, 240, 242, 245, 247, 250, 252,
- 255};
-
-/*!
- @brief Class that stores state and functions for interacting with
- Adafruit NeoPixels and compatible devices.
-*/
-class Adafruit_NeoPixel {
-
-public:
- // Constructor: number of LEDs, pin number, LED type
- Adafruit_NeoPixel(uint16_t n, int16_t pin = 6,
- neoPixelType type = NEO_GRB + NEO_KHZ800);
- Adafruit_NeoPixel(void);
- ~Adafruit_NeoPixel();
-
- void begin(void);
- void show(void);
- void setPin(int16_t p);
- void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b);
- void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w);
- void setPixelColor(uint16_t n, uint32_t c);
- void fill(uint32_t c = 0, uint16_t first = 0, uint16_t count = 0);
- void setBrightness(uint8_t);
- void clear(void);
- void updateLength(uint16_t n);
- void updateType(neoPixelType t);
- /*!
- @brief Check whether a call to show() will start sending data
- immediately or will 'block' for a required interval. NeoPixels
- require a short quiet time (about 300 microseconds) after the
- last bit is received before the data 'latches' and new data can
- start being received. Usually one's sketch is implicitly using
- this time to generate a new frame of animation...but if it
- finishes very quickly, this function could be used to see if
- there's some idle time available for some low-priority
- concurrent task.
- @return 1 or true if show() will start sending immediately, 0 or false
- if show() would block (meaning some idle time is available).
- */
- bool canShow(void) {
- // It's normal and possible for endTime to exceed micros() if the
- // 32-bit clock counter has rolled over (about every 70 minutes).
- // Since both are uint32_t, a negative delta correctly maps back to
- // positive space, and it would seem like the subtraction below would
- // suffice. But a problem arises if code invokes show() very
- // infrequently...the micros() counter may roll over MULTIPLE times in
- // that interval, the delta calculation is no longer correct and the
- // next update may stall for a very long time. The check below resets
- // the latch counter if a rollover has occurred. This can cause an
- // extra delay of up to 300 microseconds in the rare case where a
- // show() call happens precisely around the rollover, but that's
- // neither likely nor especially harmful, vs. other code that might
- // stall for 30+ minutes, or having to document and frequently remind
- // and/or provide tech support explaining an unintuitive need for
- // show() calls at least once an hour.
- uint32_t now = micros();
- if (endTime > now) {
- endTime = now;
- }
- return (now - endTime) >= 300L;
- }
- /*!
- @brief Get a pointer directly to the NeoPixel data buffer in RAM.
- Pixel data is stored in a device-native format (a la the NEO_*
- constants) and is not translated here. Applications that access
- this buffer will need to be aware of the specific data format
- and handle colors appropriately.
- @return Pointer to NeoPixel buffer (uint8_t* array).
- @note This is for high-performance applications where calling
- setPixelColor() on every single pixel would be too slow (e.g.
- POV or light-painting projects). There is no bounds checking
- on the array, creating tremendous potential for mayhem if one
- writes past the ends of the buffer. Great power, great
- responsibility and all that.
- */
- uint8_t *getPixels(void) const { return pixels; };
- uint8_t getBrightness(void) const;
- /*!
- @brief Retrieve the pin number used for NeoPixel data output.
- @return Arduino pin number (-1 if not set).
- */
- int16_t getPin(void) const { return pin; };
- /*!
- @brief Return the number of pixels in an Adafruit_NeoPixel strip object.
- @return Pixel count (0 if not set).
- */
- uint16_t numPixels(void) const { return numLEDs; }
- uint32_t getPixelColor(uint16_t n) const;
- /*!
- @brief An 8-bit integer sine wave function, not directly compatible
- with standard trigonometric units like radians or degrees.
- @param x Input angle, 0-255; 256 would loop back to zero, completing
- the circle (equivalent to 360 degrees or 2 pi radians).
- One can therefore use an unsigned 8-bit variable and simply
- add or subtract, allowing it to overflow/underflow and it
- still does the expected contiguous thing.
- @return Sine result, 0 to 255, or -128 to +127 if type-converted to
- a signed int8_t, but you'll most likely want unsigned as this
- output is often used for pixel brightness in animation effects.
- */
- static uint8_t sine8(uint8_t x) {
- return pgm_read_byte(&_NeoPixelSineTable[x]); // 0-255 in, 0-255 out
- }
- /*!
- @brief An 8-bit gamma-correction function for basic pixel brightness
- adjustment. Makes color transitions appear more perceptially
- correct.
- @param x Input brightness, 0 (minimum or off/black) to 255 (maximum).
- @return Gamma-adjusted brightness, can then be passed to one of the
- setPixelColor() functions. This uses a fixed gamma correction
- exponent of 2.6, which seems reasonably okay for average
- NeoPixels in average tasks. If you need finer control you'll
- need to provide your own gamma-correction function instead.
- */
- static uint8_t gamma8(uint8_t x) {
- return pgm_read_byte(&_NeoPixelGammaTable[x]); // 0-255 in, 0-255 out
- }
- /*!
- @brief Convert separate red, green and blue values into a single
- "packed" 32-bit RGB color.
- @param r Red brightness, 0 to 255.
- @param g Green brightness, 0 to 255.
- @param b Blue brightness, 0 to 255.
- @return 32-bit packed RGB value, which can then be assigned to a
- variable for later use or passed to the setPixelColor()
- function. Packed RGB format is predictable, regardless of
- LED strand color order.
- */
- static uint32_t Color(uint8_t r, uint8_t g, uint8_t b) {
- return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
- }
- /*!
- @brief Convert separate red, green, blue and white values into a
- single "packed" 32-bit WRGB color.
- @param r Red brightness, 0 to 255.
- @param g Green brightness, 0 to 255.
- @param b Blue brightness, 0 to 255.
- @param w White brightness, 0 to 255.
- @return 32-bit packed WRGB value, which can then be assigned to a
- variable for later use or passed to the setPixelColor()
- function. Packed WRGB format is predictable, regardless of
- LED strand color order.
- */
- static uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
- return ((uint32_t)w << 24) | ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
- }
- static uint32_t ColorHSV(uint16_t hue, uint8_t sat = 255, uint8_t val = 255);
- /*!
- @brief A gamma-correction function for 32-bit packed RGB or WRGB
- colors. Makes color transitions appear more perceptially
- correct.
- @param x 32-bit packed RGB or WRGB color.
- @return Gamma-adjusted packed color, can then be passed in one of the
- setPixelColor() functions. Like gamma8(), this uses a fixed
- gamma correction exponent of 2.6, which seems reasonably okay
- for average NeoPixels in average tasks. If you need finer
- control you'll need to provide your own gamma-correction
- function instead.
- */
- static uint32_t gamma32(uint32_t x);
-
- void rainbow(uint16_t first_hue = 0, int8_t reps = 1,
- uint8_t saturation = 255, uint8_t brightness = 255,
- bool gammify = true);
-
-private:
-#if defined(ARDUINO_ARCH_RP2040)
- void rp2040Init(uint8_t pin, bool is800KHz);
- void rp2040Show(uint8_t pin, uint8_t *pixels, uint32_t numBytes, bool is800KHz);
-#endif
-
-protected:
-#ifdef NEO_KHZ400 // If 400 KHz NeoPixel support enabled...
- bool is800KHz; ///< true if 800 KHz pixels
-#endif
- bool begun; ///< true if begin() previously called
- uint16_t numLEDs; ///< Number of RGB LEDs in strip
- uint16_t numBytes; ///< Size of 'pixels' buffer below
- int16_t pin; ///< Output pin number (-1 if not yet set)
- uint8_t brightness; ///< Strip brightness 0-255 (stored as +1)
- uint8_t *pixels; ///< Holds LED color values (3 or 4 bytes each)
- uint8_t rOffset; ///< Red index within each 3- or 4-byte pixel
- uint8_t gOffset; ///< Index of green byte
- uint8_t bOffset; ///< Index of blue byte
- uint8_t wOffset; ///< Index of white (==rOffset if no white)
- uint32_t endTime; ///< Latch timing reference
-#ifdef __AVR__
- volatile uint8_t *port; ///< Output PORT register
- uint8_t pinMask; ///< Output PORT bitmask
-#endif
-#if defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_ARDUINO_CORE_STM32)
- GPIO_TypeDef *gpioPort; ///< Output GPIO PORT
- uint32_t gpioPin; ///< Output GPIO PIN
-#endif
-#if defined(ARDUINO_ARCH_RP2040)
- PIO pio = pio0;
- int sm = 0;
- bool init = true;
-#endif
-};
-
-#endif // ADAFRUIT_NEOPIXEL_H
diff --git a/lib/Adafruit NeoPixel/CONTRIBUTING.md b/lib/Adafruit NeoPixel/CONTRIBUTING.md
deleted file mode 100644
index aa753894e..000000000
--- a/lib/Adafruit NeoPixel/CONTRIBUTING.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# Contribution Guidelines
-
-This library is the culmination of the expertise of many members of the open source community who have dedicated their time and hard work. The best way to ask for help or propose a new idea is to [create a new issue](https://github.com/adafruit/Adafruit_NeoPixel/issues/new) while creating a Pull Request with your code changes allows you to share your own innovations with the rest of the community.
-
-The following are some guidelines to observe when creating issues or PRs:
-
-- Be friendly; it is important that we can all enjoy a safe space as we are all working on the same project and it is okay for people to have different ideas
-
-- [Use code blocks](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code); it helps us help you when we can read your code! On that note also refrain from pasting more than 30 lines of code in a post, instead [create a gist](https://gist.github.com/) if you need to share large snippets
-
-- Use reasonable titles; refrain from using overly long or capitalized titles as they are usually annoying and do little to encourage others to help :smile:
-
-- Be detailed; refrain from mentioning code problems without sharing your source code and always give information regarding your board and version of the library
diff --git a/lib/Adafruit NeoPixel/COPYING b/lib/Adafruit NeoPixel/COPYING
deleted file mode 100644
index 65c5ca88a..000000000
--- a/lib/Adafruit NeoPixel/COPYING
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/lib/Adafruit NeoPixel/README.md b/lib/Adafruit NeoPixel/README.md
deleted file mode 100644
index eff133711..000000000
--- a/lib/Adafruit NeoPixel/README.md
+++ /dev/null
@@ -1,157 +0,0 @@
-# Adafruit NeoPixel Library [](https://github.com/adafruit/Adafruit_NeoPixel/actions)[](http://adafruit.github.io/Adafruit_NeoPixel/html/index.html)
-
-Arduino library for controlling single-wire-based LED pixels and strip such as the [Adafruit 60 LED/meter Digital LED strip][strip], the [Adafruit FLORA RGB Smart Pixel][flora], the [Adafruit Breadboard-friendly RGB Smart Pixel][pixel], the [Adafruit NeoPixel Stick][stick], and the [Adafruit NeoPixel Shield][shield].
-
-After downloading, rename folder to 'Adafruit_NeoPixel' and install in Arduino Libraries folder. Restart Arduino IDE, then open File->Sketchbook->Library->Adafruit_NeoPixel->strandtest sketch.
-
-Compatibility notes: Port A is not supported on any AVR processors at this time
-
-[flora]: http://adafruit.com/products/1060
-[strip]: http://adafruit.com/products/1138
-[pixel]: http://adafruit.com/products/1312
-[stick]: http://adafruit.com/products/1426
-[shield]: http://adafruit.com/products/1430
-
----
-
-## Installation
-
-### First Method
-
-
-
-1. In the Arduino IDE, navigate to Sketch > Include Library > Manage Libraries
-1. Then the Library Manager will open and you will find a list of libraries that are already installed or ready for installation.
-1. Then search for Neopixel strip using the search bar.
-1. Click on the text area and then select the specific version and install it.
-
-### Second Method
-
-1. Navigate to the [Releases page](https://github.com/adafruit/Adafruit_NeoPixel/releases).
-1. Download the latest release.
-1. Extract the zip file
-1. In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library
-
-## Features
-
-- ### Simple to use
-
- Controlling NeoPixels “from scratch” is quite a challenge, so we provide a library letting you focus on the fun and interesting bits.
-
-- ### Give back
-
- The library is free; you don’t have to pay for anything. Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!
-
-- ### Supported Chipsets
-
- We have included code for the following chips - sometimes these break for exciting reasons that we can't control in which case please open an issue!
-
- - AVR ATmega and ATtiny (any 8-bit) - 8 MHz, 12 MHz and 16 MHz
- - Teensy 3.x and LC
- - Arduino Due
- - Arduino 101
- - ATSAMD21 (Arduino Zero/M0 and other SAMD21 boards) @ 48 MHz
- - ATSAMD51 @ 120 MHz
- - Adafruit STM32 Feather @ 120 MHz
- - ESP8266 any speed
- - ESP32 any speed
- - Nordic nRF52 (Adafruit Feather nRF52), nRF51 (micro:bit)
- - Infineon XMC1100 BootKit @ 32 MHz
- - Infineon XMC1100 2Go @ 32 MHz
- - Infineon XMC1300 BootKit @ 32 MHz
- - Infineon XMC4700 RelaxKit, XMC4800 RelaxKit, XMC4800 IoT Amazon FreeRTOS Kit @ 144 MHz
-
- Check forks for other architectures not listed here!
-
-- ### GNU Lesser General Public License
-
- Adafruit_NeoPixel 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 3 of the License, or (at your option) any later version.
-
-## Functions
-
-- begin()
-- updateLength()
-- updateType()
-- show()
-- delay_ns()
-- setPin()
-- setPixelColor()
-- fill()
-- ColorHSV()
-- getPixelColor()
-- setBrightness()
-- getBrightness()
-- clear()
-- gamma32()
-
-## Examples
-
-There are many examples implemented in this library. One of the examples is below. You can find other examples [here](https://github.com/adafruit/Adafruit_NeoPixel/tree/master/examples)
-
-### Simple
-
-```Cpp
-#include
-#ifdef __AVR__
- #include
-#endif
-#define PIN 6
-#define NUMPIXELS 16
-
-Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
-#define DELAYVAL 500
-
-void setup() {
-#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
- clock_prescale_set(clock_div_1);
-#endif
-
- pixels.begin();
-}
-
-void loop() {
- pixels.clear();
-
- for(int i=0; i
-#include "driver/rmt.h"
-
-#if defined(ESP_IDF_VERSION)
-#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
-#define HAS_ESP_IDF_4
-#endif
-#endif
-
-// This code is adapted from the ESP-IDF v3.4 RMT "led_strip" example, altered
-// to work with the Arduino version of the ESP-IDF (3.2)
-
-#define WS2812_T0H_NS (400)
-#define WS2812_T0L_NS (850)
-#define WS2812_T1H_NS (800)
-#define WS2812_T1L_NS (450)
-
-#define WS2811_T0H_NS (500)
-#define WS2811_T0L_NS (2000)
-#define WS2811_T1H_NS (1200)
-#define WS2811_T1L_NS (1300)
-
-static uint32_t t0h_ticks = 0;
-static uint32_t t1h_ticks = 0;
-static uint32_t t0l_ticks = 0;
-static uint32_t t1l_ticks = 0;
-
-// Limit the number of RMT channels available for the Neopixels. Defaults to all
-// channels (8 on ESP32, 4 on ESP32-S2 and S3). Redefining this value will free
-// any channels with a higher number for other uses, such as IR send-and-recieve
-// libraries. Redefine as 1 to restrict Neopixels to only a single channel.
-#define ADAFRUIT_RMT_CHANNEL_MAX RMT_CHANNEL_MAX
-
-#define RMT_LL_HW_BASE (&RMT)
-
-bool rmt_reserved_channels[ADAFRUIT_RMT_CHANNEL_MAX];
-
-static void IRAM_ATTR ws2812_rmt_adapter(const void *src, rmt_item32_t *dest, size_t src_size,
- size_t wanted_num, size_t *translated_size, size_t *item_num)
-{
- if (src == NULL || dest == NULL) {
- *translated_size = 0;
- *item_num = 0;
- return;
- }
- const rmt_item32_t bit0 = {{{ t0h_ticks, 1, t0l_ticks, 0 }}}; //Logical 0
- const rmt_item32_t bit1 = {{{ t1h_ticks, 1, t1l_ticks, 0 }}}; //Logical 1
- size_t size = 0;
- size_t num = 0;
- uint8_t *psrc = (uint8_t *)src;
- rmt_item32_t *pdest = dest;
- while (size < src_size && num < wanted_num) {
- for (int i = 0; i < 8; i++) {
- // MSB first
- if (*psrc & (1 << (7 - i))) {
- pdest->val = bit1.val;
- } else {
- pdest->val = bit0.val;
- }
- num++;
- pdest++;
- }
- size++;
- psrc++;
- }
- *translated_size = size;
- *item_num = num;
-}
-
-void espShow(uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) {
- // Reserve channel
- rmt_channel_t channel = ADAFRUIT_RMT_CHANNEL_MAX;
- for (size_t i = 0; i < ADAFRUIT_RMT_CHANNEL_MAX; i++) {
- if (!rmt_reserved_channels[i]) {
- rmt_reserved_channels[i] = true;
- channel = i;
- break;
- }
- }
- if (channel == ADAFRUIT_RMT_CHANNEL_MAX) {
- // Ran out of channels!
- return;
- }
-
-#if defined(HAS_ESP_IDF_4)
- rmt_config_t config = RMT_DEFAULT_CONFIG_TX(pin, channel);
- config.clk_div = 2;
-#else
- // Match default TX config from ESP-IDF version 3.4
- rmt_config_t config = {
- .rmt_mode = RMT_MODE_TX,
- .channel = channel,
- .gpio_num = pin,
- .clk_div = 2,
- .mem_block_num = 1,
- .tx_config = {
- .carrier_freq_hz = 38000,
- .carrier_level = RMT_CARRIER_LEVEL_HIGH,
- .idle_level = RMT_IDLE_LEVEL_LOW,
- .carrier_duty_percent = 33,
- .carrier_en = false,
- .loop_en = false,
- .idle_output_en = true,
- }
- };
-#endif
- rmt_config(&config);
- rmt_driver_install(config.channel, 0, 0);
-
- // Convert NS timings to ticks
- uint32_t counter_clk_hz = 0;
-
-#if defined(HAS_ESP_IDF_4)
- rmt_get_counter_clock(channel, &counter_clk_hz);
-#else
- // this emulates the rmt_get_counter_clock() function from ESP-IDF 3.4
- if (RMT_LL_HW_BASE->conf_ch[config.channel].conf1.ref_always_on == RMT_BASECLK_REF) {
- uint32_t div_cnt = RMT_LL_HW_BASE->conf_ch[config.channel].conf0.div_cnt;
- uint32_t div = div_cnt == 0 ? 256 : div_cnt;
- counter_clk_hz = REF_CLK_FREQ / (div);
- } else {
- uint32_t div_cnt = RMT_LL_HW_BASE->conf_ch[config.channel].conf0.div_cnt;
- uint32_t div = div_cnt == 0 ? 256 : div_cnt;
- counter_clk_hz = APB_CLK_FREQ / (div);
- }
-#endif
-
- // NS to tick converter
- float ratio = (float)counter_clk_hz / 1e9;
-
- if (is800KHz) {
- t0h_ticks = (uint32_t)(ratio * WS2812_T0H_NS);
- t0l_ticks = (uint32_t)(ratio * WS2812_T0L_NS);
- t1h_ticks = (uint32_t)(ratio * WS2812_T1H_NS);
- t1l_ticks = (uint32_t)(ratio * WS2812_T1L_NS);
- } else {
- t0h_ticks = (uint32_t)(ratio * WS2811_T0H_NS);
- t0l_ticks = (uint32_t)(ratio * WS2811_T0L_NS);
- t1h_ticks = (uint32_t)(ratio * WS2811_T1H_NS);
- t1l_ticks = (uint32_t)(ratio * WS2811_T1L_NS);
- }
-
- // Initialize automatic timing translator
- rmt_translator_init(config.channel, ws2812_rmt_adapter);
-
- // Write and wait to finish
- rmt_write_sample(config.channel, pixels, (size_t)numBytes, true);
- rmt_wait_tx_done(config.channel, pdMS_TO_TICKS(100));
-
- // Free channel again
- rmt_driver_uninstall(config.channel);
- rmt_reserved_channels[channel] = false;
-
- gpio_set_direction(pin, GPIO_MODE_OUTPUT);
-}
-
-#endif
diff --git a/lib/Adafruit NeoPixel/esp8266.c b/lib/Adafruit NeoPixel/esp8266.c
deleted file mode 100644
index 51c3f3c8a..000000000
--- a/lib/Adafruit NeoPixel/esp8266.c
+++ /dev/null
@@ -1,86 +0,0 @@
-// This is a mash-up of the Due show() code + insights from Michael Miller's
-// ESP8266 work for the NeoPixelBus library: github.com/Makuna/NeoPixelBus
-// Needs to be a separate .c file to enforce ICACHE_RAM_ATTR execution.
-
-#if defined(ESP8266)
-
-#include
-#ifdef ESP8266
-#include
-#endif
-
-static uint32_t _getCycleCount(void) __attribute__((always_inline));
-static inline uint32_t _getCycleCount(void) {
- uint32_t ccount;
- __asm__ __volatile__("rsr %0,ccount":"=a" (ccount));
- return ccount;
-}
-
-#ifdef ESP8266
-IRAM_ATTR void espShow(
- uint8_t pin, uint8_t *pixels, uint32_t numBytes, __attribute__((unused)) boolean is800KHz) {
-#else
-void espShow(
- uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) {
-#endif
-
-#define CYCLES_800_T0H (F_CPU / 2500001) // 0.4us
-#define CYCLES_800_T1H (F_CPU / 1250001) // 0.8us
-#define CYCLES_800 (F_CPU / 800001) // 1.25us per bit
-#define CYCLES_400_T0H (F_CPU / 2000000) // 0.5uS
-#define CYCLES_400_T1H (F_CPU / 833333) // 1.2us
-#define CYCLES_400 (F_CPU / 400000) // 2.5us per bit
-
- uint8_t *p, *end, pix, mask;
- uint32_t t, time0, time1, period, c, startTime;
-
-#ifdef ESP8266
- uint32_t pinMask;
- pinMask = _BV(pin);
-#endif
-
- p = pixels;
- end = p + numBytes;
- pix = *p++;
- mask = 0x80;
- startTime = 0;
-
-#ifdef NEO_KHZ400
- if(is800KHz) {
-#endif
- time0 = CYCLES_800_T0H;
- time1 = CYCLES_800_T1H;
- period = CYCLES_800;
-#ifdef NEO_KHZ400
- } else { // 400 KHz bitstream
- time0 = CYCLES_400_T0H;
- time1 = CYCLES_400_T1H;
- period = CYCLES_400;
- }
-#endif
-
- for(t = time0;; t = time0) {
- if(pix & mask) t = time1; // Bit high duration
- while(((c = _getCycleCount()) - startTime) < period); // Wait for bit start
-#ifdef ESP8266
- GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinMask); // Set high
-#else
- gpio_set_level(pin, HIGH);
-#endif
- startTime = c; // Save start time
- while(((c = _getCycleCount()) - startTime) < t); // Wait high duration
-#ifdef ESP8266
- GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinMask); // Set low
-#else
- gpio_set_level(pin, LOW);
-#endif
- if(!(mask >>= 1)) { // Next bit/byte
- if(p >= end) break;
- pix = *p++;
- mask = 0x80;
- }
- }
- while((_getCycleCount() - startTime) < period); // Wait for last bit
-}
-
-#endif // ESP8266
diff --git a/lib/Adafruit NeoPixel/examples/RGBWstrandtest/.esp8266.test.skip b/lib/Adafruit NeoPixel/examples/RGBWstrandtest/.esp8266.test.skip
deleted file mode 100644
index e69de29bb..000000000
diff --git a/lib/Adafruit NeoPixel/examples/RGBWstrandtest/.trinket.test.skip b/lib/Adafruit NeoPixel/examples/RGBWstrandtest/.trinket.test.skip
deleted file mode 100644
index e69de29bb..000000000
diff --git a/lib/Adafruit NeoPixel/examples/RGBWstrandtest/RGBWstrandtest.ino b/lib/Adafruit NeoPixel/examples/RGBWstrandtest/RGBWstrandtest.ino
deleted file mode 100644
index 95335cdfc..000000000
--- a/lib/Adafruit NeoPixel/examples/RGBWstrandtest/RGBWstrandtest.ino
+++ /dev/null
@@ -1,177 +0,0 @@
-// NeoPixel test program showing use of the WHITE channel for RGBW
-// pixels only (won't look correct on regular RGB NeoPixel strips).
-
-#include
-#ifdef __AVR__
- #include // Required for 16 MHz Adafruit Trinket
-#endif
-
-// Which pin on the Arduino is connected to the NeoPixels?
-// On a Trinket or Gemma we suggest changing this to 1:
-#define LED_PIN 6
-
-// How many NeoPixels are attached to the Arduino?
-#define LED_COUNT 60
-
-// NeoPixel brightness, 0 (min) to 255 (max)
-#define BRIGHTNESS 50 // Set BRIGHTNESS to about 1/5 (max = 255)
-
-// Declare our NeoPixel strip object:
-Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRBW + NEO_KHZ800);
-// Argument 1 = Number of pixels in NeoPixel strip
-// Argument 2 = Arduino pin number (most are valid)
-// Argument 3 = Pixel type flags, add together as needed:
-// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
-// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
-// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
-// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
-// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
-
-void setup() {
- // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
- // Any other board, you can remove this part (but no harm leaving it):
-#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
- clock_prescale_set(clock_div_1);
-#endif
- // END of Trinket-specific code.
-
- strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
- strip.show(); // Turn OFF all pixels ASAP
- strip.setBrightness(BRIGHTNESS);
-}
-
-void loop() {
- // Fill along the length of the strip in various colors...
- colorWipe(strip.Color(255, 0, 0) , 50); // Red
- colorWipe(strip.Color( 0, 255, 0) , 50); // Green
- colorWipe(strip.Color( 0, 0, 255) , 50); // Blue
- colorWipe(strip.Color( 0, 0, 0, 255), 50); // True white (not RGB white)
-
- whiteOverRainbow(75, 5);
-
- pulseWhite(5);
-
- rainbowFade2White(3, 3, 1);
-}
-
-// Fill strip pixels one after another with a color. Strip is NOT cleared
-// first; anything there will be covered pixel by pixel. Pass in color
-// (as a single 'packed' 32-bit value, which you can get by calling
-// strip.Color(red, green, blue) as shown in the loop() function above),
-// and a delay time (in milliseconds) between pixels.
-void colorWipe(uint32_t color, int wait) {
- for(int i=0; i= strip.numPixels()) whiteLength = strip.numPixels() - 1;
-
- int head = whiteLength - 1;
- int tail = 0;
- int loops = 3;
- int loopNum = 0;
- uint32_t lastTime = millis();
- uint32_t firstPixelHue = 0;
-
- for(;;) { // Repeat forever (or until a 'break' or 'return')
- for(int i=0; i= tail) && (i <= head)) || // If between head & tail...
- ((tail > head) && ((i >= tail) || (i <= head)))) {
- strip.setPixelColor(i, strip.Color(0, 0, 0, 255)); // Set white
- } else { // else set rainbow
- int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
- strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
- }
- }
-
- strip.show(); // Update strip with new contents
- // There's no delay here, it just runs full-tilt until the timer and
- // counter combination below runs out.
-
- firstPixelHue += 40; // Advance just a little along the color wheel
-
- if((millis() - lastTime) > whiteSpeed) { // Time to update head/tail?
- if(++head >= strip.numPixels()) { // Advance head, wrap around
- head = 0;
- if(++loopNum >= loops) return;
- }
- if(++tail >= strip.numPixels()) { // Advance tail, wrap around
- tail = 0;
- }
- lastTime = millis(); // Save time of last movement
- }
- }
-}
-
-void pulseWhite(uint8_t wait) {
- for(int j=0; j<256; j++) { // Ramp up from 0 to 255
- // Fill entire strip with white at gamma-corrected brightness level 'j':
- strip.fill(strip.Color(0, 0, 0, strip.gamma8(j)));
- strip.show();
- delay(wait);
- }
-
- for(int j=255; j>=0; j--) { // Ramp down from 255 to 0
- strip.fill(strip.Color(0, 0, 0, strip.gamma8(j)));
- strip.show();
- delay(wait);
- }
-}
-
-void rainbowFade2White(int wait, int rainbowLoops, int whiteLoops) {
- int fadeVal=0, fadeMax=100;
-
- // Hue of first pixel runs 'rainbowLoops' complete loops through the color
- // wheel. Color wheel has a range of 65536 but it's OK if we roll over, so
- // just count from 0 to rainbowLoops*65536, using steps of 256 so we
- // advance around the wheel at a decent clip.
- for(uint32_t firstPixelHue = 0; firstPixelHue < rainbowLoops*65536;
- firstPixelHue += 256) {
-
- for(int i=0; i= ((rainbowLoops-1) * 65536)) { // Last loop,
- if(fadeVal > 0) fadeVal--; // fade out
- } else {
- fadeVal = fadeMax; // Interim loop, make sure fade is at max
- }
- }
-
- for(int k=0; k=0; j--) { // Ramp down 255 to 0
- strip.fill(strip.Color(0, 0, 0, strip.gamma8(j)));
- strip.show();
- }
- }
-
- delay(500); // Pause 1/2 second
-}
diff --git a/lib/Adafruit NeoPixel/examples/StrandtestArduinoBLE/.none.test.only b/lib/Adafruit NeoPixel/examples/StrandtestArduinoBLE/.none.test.only
deleted file mode 100644
index e69de29bb..000000000
diff --git a/lib/Adafruit NeoPixel/examples/StrandtestArduinoBLE/StrandtestArduinoBLE.ino b/lib/Adafruit NeoPixel/examples/StrandtestArduinoBLE/StrandtestArduinoBLE.ino
deleted file mode 100644
index 80e02d21b..000000000
--- a/lib/Adafruit NeoPixel/examples/StrandtestArduinoBLE/StrandtestArduinoBLE.ino
+++ /dev/null
@@ -1,231 +0,0 @@
-/****************************************************************************
- * This example is based on StrandtestBLE example and adapts it to use
- * the new ArduinoBLE library.
- *
- * https://github.com/arduino-libraries/ArduinoBLE
- *
- * Supported boards:
- * Arduino MKR WiFi 1010, Arduino Uno WiFi Rev2 board, Arduino Nano 33 IoT,
- Arduino Nano 33 BLE, or Arduino Nano 33 BLE Sense board.
- *
- * You can use a generic BLE central app, like LightBlue (iOS and Android) or
- * nRF Connect (Android), to interact with the services and characteristics
- * created in this sketch.
- *
- * This example code is in the public domain.
- *
- */
-#include
-
-#define PIN 15 // Pin where NeoPixels are connected
-
-// Declare our NeoPixel strip object:
-Adafruit_NeoPixel strip(64, PIN, NEO_GRB + NEO_KHZ800);
-// Argument 1 = Number of pixels in NeoPixel strip
-// Argument 2 = Arduino pin number (most are valid)
-// Argument 3 = Pixel type flags, add together as needed:
-// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
-// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
-// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
-// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
-// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
-
-// NEOPIXEL BEST PRACTICES for most reliable operation:
-// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections.
-// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel.
-// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR.
-// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS
-// connect GROUND (-) first, then +, then data.
-// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip,
-// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED.
-// (Skipping these may work OK on your workbench but can fail in the field)
-
-uint8_t rgb_values[3];
-
-#include
-
-BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service
-
-// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
-BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
-
-void setup()
-{
- Serial.begin(115200);
- Serial.println("Hello World!");
-
- // custom services and characteristics can be added as well
- // begin initialization
- if (!BLE.begin())
- {
- Serial.println("starting BLE failed!");
-
- while (1)
- ;
- }
-
- Serial.print("Peripheral address: ");
- Serial.println(BLE.address());
-
- // set advertised local name and service UUID:
- BLE.setLocalName("LED");
- BLE.setAdvertisedService(ledService);
-
- // add the characteristic to the service
- ledService.addCharacteristic(switchCharacteristic);
-
- // add service
- BLE.addService(ledService);
-
- // set the initial value for the characeristic:
- switchCharacteristic.writeValue(0);
-
- // start advertising
- BLE.advertise();
-
- strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
- strip.show(); // Turn OFF all pixels ASAP
-
- pinMode(PIN, OUTPUT);
- digitalWrite(PIN, LOW);
-
-}
-
-void loop()
-{
- BLEDevice central = BLE.central();
-
- // if a central is connected to peripheral:
- if (central)
- {
- Serial.print("Connected to central: ");
- // print the central's MAC address:
- Serial.println(central.address());
-
- // while the central is still connected to peripheral:
- while (central.connected())
- {
- // if the remote device wrote to the characteristic,
- // use the value to control the LED:
- if (switchCharacteristic.written())
- {
- switch (switchCharacteristic.value())
- {
- case 'a':
- colorWipe(strip.Color(255, 0, 0), 20); // Red
- break;
- case 'b':
- colorWipe(strip.Color(0, 255, 0), 20); // Green
- break;
- case 'c':
- colorWipe(strip.Color(0, 0, 255), 20); // Blue
- break;
- case 'd':
- theaterChase(strip.Color(255, 0, 0), 20); // Red
- break;
- case 'e':
- theaterChase(strip.Color(0, 255, 0), 20); // Green
- break;
- case 'f':
- theaterChase(strip.Color(255, 0, 255), 20); // Cyan
- break;
- case 'g':
- rainbow(10);
- break;
- case 'h':
- theaterChaseRainbow(20);
- break;
- }
- }
- }
- }
-}
-
-// Fill strip pixels one after another with a color. Strip is NOT cleared
-// first; anything there will be covered pixel by pixel. Pass in color
-// (as a single 'packed' 32-bit value, which you can get by calling
-// strip.Color(red, green, blue) as shown in the loop() function above),
-// and a delay time (in milliseconds) between pixels.
-void colorWipe(uint32_t color, int wait)
-{
- for (int i = 0; i < strip.numPixels(); i++)
- { // For each pixel in strip...
- strip.setPixelColor(i, color); // Set pixel's color (in RAM)
- strip.show(); // Update strip to match
- delay(wait); // Pause for a moment
- }
-}
-
-// Theater-marquee-style chasing lights. Pass in a color (32-bit value,
-// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms)
-// between frames.
-void theaterChase(uint32_t color, int wait)
-{
- for (int a = 0; a < 10; a++)
- { // Repeat 10 times...
- for (int b = 0; b < 3; b++)
- { // 'b' counts from 0 to 2...
- strip.clear(); // Set all pixels in RAM to 0 (off)
- // 'c' counts up from 'b' to end of strip in steps of 3...
- for (int c = b; c < strip.numPixels(); c += 3)
- {
- strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
- }
- strip.show(); // Update strip with new contents
- delay(wait); // Pause for a moment
- }
- }
-}
-
-// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
-void rainbow(int wait)
-{
- // Hue of first pixel runs 5 complete loops through the color wheel.
- // Color wheel has a range of 65536 but it's OK if we roll over, so
- // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time
- // means we'll make 5*65536/256 = 1280 passes through this outer loop:
- for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256)
- {
- for (int i = 0; i < strip.numPixels(); i++)
- { // For each pixel in strip...
- // Offset pixel hue by an amount to make one full revolution of the
- // color wheel (range of 65536) along the length of the strip
- // (strip.numPixels() steps):
- int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
- // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or
- // optionally add saturation and value (brightness) (each 0 to 255).
- // Here we're using just the single-argument hue variant. The result
- // is passed through strip.gamma32() to provide 'truer' colors
- // before assigning to each pixel:
- strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
- }
- strip.show(); // Update strip with new contents
- delay(wait); // Pause for a moment
- }
-}
-
-// Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames.
-void theaterChaseRainbow(int wait)
-{
- int firstPixelHue = 0; // First pixel starts at red (hue 0)
- for (int a = 0; a < 30; a++)
- { // Repeat 30 times...
- for (int b = 0; b < 3; b++)
- { // 'b' counts from 0 to 2...
- strip.clear(); // Set all pixels in RAM to 0 (off)
- // 'c' counts up from 'b' to end of strip in increments of 3...
- for (int c = b; c < strip.numPixels(); c += 3)
- {
- // hue of pixel 'c' is offset by an amount to make one full
- // revolution of the color wheel (range 65536) along the length
- // of the strip (strip.numPixels() steps):
- int hue = firstPixelHue + c * 65536L / strip.numPixels();
- uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB
- strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
- }
- strip.show(); // Update strip with new contents
- delay(wait); // Pause for a moment
- firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames
- }
- }
-}
diff --git a/lib/Adafruit NeoPixel/examples/StrandtestArduinoBLECallback/.none.test.only b/lib/Adafruit NeoPixel/examples/StrandtestArduinoBLECallback/.none.test.only
deleted file mode 100644
index e69de29bb..000000000
diff --git a/lib/Adafruit NeoPixel/examples/StrandtestArduinoBLECallback/StrandtestArduinoBLECallback.ino b/lib/Adafruit NeoPixel/examples/StrandtestArduinoBLECallback/StrandtestArduinoBLECallback.ino
deleted file mode 100644
index b986943ae..000000000
--- a/lib/Adafruit NeoPixel/examples/StrandtestArduinoBLECallback/StrandtestArduinoBLECallback.ino
+++ /dev/null
@@ -1,239 +0,0 @@
-/****************************************************************************
- * This example is based on StrandtestArduinoBLE example to make use of
- * callbacks features of the ArduinoBLE library.
- *
- * https://github.com/arduino-libraries/ArduinoBLE
- *
- * Supported boards:
- * Arduino MKR WiFi 1010, Arduino Uno WiFi Rev2 board, Arduino Nano 33 IoT,
- Arduino Nano 33 BLE, or Arduino Nano 33 BLE Sense board.
- *
- * You can use a generic BLE central app, like LightBlue (iOS and Android) or
- * nRF Connect (Android), to interact with the services and characteristics
- * created in this sketch.
- *
- * This example code is in the public domain.
- *
- */
-#include
-
-#define PIN 15 // Pin where NeoPixels are connected
-
-// Declare our NeoPixel strip object:
-Adafruit_NeoPixel strip(64, PIN, NEO_GRB + NEO_KHZ800);
-// Argument 1 = Number of pixels in NeoPixel strip
-// Argument 2 = Arduino pin number (most are valid)
-// Argument 3 = Pixel type flags, add together as needed:
-// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
-// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
-// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
-// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
-// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
-
-// NEOPIXEL BEST PRACTICES for most reliable operation:
-// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections.
-// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel.
-// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR.
-// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS
-// connect GROUND (-) first, then +, then data.
-// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip,
-// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED.
-// (Skipping these may work OK on your workbench but can fail in the field)
-
-uint8_t rgb_values[3];
-
-#include
-
-BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service
-
-// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
-BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
-
-void setup()
-{
- Serial.begin(115200);
- Serial.println("Hello World!");
-
- // custom services and characteristics can be added as well
- // begin initialization
- if (!BLE.begin())
- {
- Serial.println("starting BLE failed!");
-
- while (1)
- ;
- }
-
- Serial.print("Peripheral address: ");
- Serial.println(BLE.address());
-
- // set advertised local name and service UUID:
- BLE.setLocalName("LEDCallback");
- BLE.setAdvertisedService(ledService);
-
- // add the characteristic to the service
- ledService.addCharacteristic(switchCharacteristic);
-
- // add service
- BLE.addService(ledService);
- // assign event handlers for connected, disconnected to peripheral
- BLE.setEventHandler(BLEConnected, blePeripheralConnectHandler);
- BLE.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);
-
- // assign event handlers for characteristic
- switchCharacteristic.setEventHandler(BLEWritten, switchCharacteristicWritten);
- // set the initial value for the characeristic:
- switchCharacteristic.writeValue(0);
-
- // start advertising
- BLE.advertise();
-
- strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
- strip.show(); // Turn OFF all pixels ASAP
-
- pinMode(PIN, OUTPUT);
- digitalWrite(PIN, LOW);
-}
-
-void loop()
-{
- // poll for BLE events
- BLE.poll();
-}
-
-void blePeripheralConnectHandler(BLEDevice central)
-{
- // central connected event handler
- Serial.print("Connected event, central: ");
- Serial.println(central.address());
-}
-
-void blePeripheralDisconnectHandler(BLEDevice central)
-{
- // central disconnected event handler
- Serial.print("Disconnected event, central: ");
- Serial.println(central.address());
-}
-
-void switchCharacteristicWritten(BLEDevice central, BLECharacteristic characteristic)
-{
- // central wrote new value to characteristic, update LED
- Serial.print("Characteristic event, written: ");
-
- switch (switchCharacteristic.value())
- {
- case 'a':
- colorWipe(strip.Color(255, 0, 0), 20); // Red
- break;
- case 'b':
- colorWipe(strip.Color(0, 255, 0), 20); // Green
- break;
- case 'c':
- colorWipe(strip.Color(0, 0, 255), 20); // Blue
- break;
- case 'd':
- theaterChase(strip.Color(255, 0, 0), 20); // Red
- break;
- case 'e':
- theaterChase(strip.Color(0, 255, 0), 20); // Green
- break;
- case 'f':
- theaterChase(strip.Color(255, 0, 255), 20); // Cyan
- break;
- case 'g':
- rainbow(10);
- break;
- case 'h':
- theaterChaseRainbow(20);
- break;
- }
-}
-
-// Fill strip pixels one after another with a color. Strip is NOT cleared
-// first; anything there will be covered pixel by pixel. Pass in color
-// (as a single 'packed' 32-bit value, which you can get by calling
-// strip.Color(red, green, blue) as shown in the loop() function above),
-// and a delay time (in milliseconds) between pixels.
-void colorWipe(uint32_t color, int wait)
-{
- for (int i = 0; i < strip.numPixels(); i++)
- { // For each pixel in strip...
- strip.setPixelColor(i, color); // Set pixel's color (in RAM)
- strip.show(); // Update strip to match
- delay(wait); // Pause for a moment
- }
-}
-
-// Theater-marquee-style chasing lights. Pass in a color (32-bit value,
-// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms)
-// between frames.
-void theaterChase(uint32_t color, int wait)
-{
- for (int a = 0; a < 10; a++)
- { // Repeat 10 times...
- for (int b = 0; b < 3; b++)
- { // 'b' counts from 0 to 2...
- strip.clear(); // Set all pixels in RAM to 0 (off)
- // 'c' counts up from 'b' to end of strip in steps of 3...
- for (int c = b; c < strip.numPixels(); c += 3)
- {
- strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
- }
- strip.show(); // Update strip with new contents
- delay(wait); // Pause for a moment
- }
- }
-}
-
-// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
-void rainbow(int wait)
-{
- // Hue of first pixel runs 5 complete loops through the color wheel.
- // Color wheel has a range of 65536 but it's OK if we roll over, so
- // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time
- // means we'll make 5*65536/256 = 1280 passes through this outer loop:
- for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256)
- {
- for (int i = 0; i < strip.numPixels(); i++)
- { // For each pixel in strip...
- // Offset pixel hue by an amount to make one full revolution of the
- // color wheel (range of 65536) along the length of the strip
- // (strip.numPixels() steps):
- int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
- // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or
- // optionally add saturation and value (brightness) (each 0 to 255).
- // Here we're using just the single-argument hue variant. The result
- // is passed through strip.gamma32() to provide 'truer' colors
- // before assigning to each pixel:
- strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
- }
- strip.show(); // Update strip with new contents
- delay(wait); // Pause for a moment
- }
-}
-
-// Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames.
-void theaterChaseRainbow(int wait)
-{
- int firstPixelHue = 0; // First pixel starts at red (hue 0)
- for (int a = 0; a < 30; a++)
- { // Repeat 30 times...
- for (int b = 0; b < 3; b++)
- { // 'b' counts from 0 to 2...
- strip.clear(); // Set all pixels in RAM to 0 (off)
- // 'c' counts up from 'b' to end of strip in increments of 3...
- for (int c = b; c < strip.numPixels(); c += 3)
- {
- // hue of pixel 'c' is offset by an amount to make one full
- // revolution of the color wheel (range 65536) along the length
- // of the strip (strip.numPixels() steps):
- int hue = firstPixelHue + c * 65536L / strip.numPixels();
- uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB
- strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
- }
- strip.show(); // Update strip with new contents
- delay(wait); // Pause for a moment
- firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames
- }
- }
-}
diff --git a/lib/Adafruit NeoPixel/examples/StrandtestBLE/.none.test.only b/lib/Adafruit NeoPixel/examples/StrandtestBLE/.none.test.only
deleted file mode 100644
index e69de29bb..000000000
diff --git a/lib/Adafruit NeoPixel/examples/StrandtestBLE/BLESerial.cpp b/lib/Adafruit NeoPixel/examples/StrandtestBLE/BLESerial.cpp
deleted file mode 100644
index d1693dec8..000000000
--- a/lib/Adafruit NeoPixel/examples/StrandtestBLE/BLESerial.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-#include "BLESerial.h"
-
-// #define BLE_SERIAL_DEBUG
-
-BLESerial* BLESerial::_instance = NULL;
-
-BLESerial::BLESerial(unsigned char req, unsigned char rdy, unsigned char rst) :
- BLEPeripheral(req, rdy, rst)
-{
- this->_txCount = 0;
- this->_rxHead = this->_rxTail = 0;
- this->_flushed = 0;
- BLESerial::_instance = this;
-
- addAttribute(this->_uartService);
- addAttribute(this->_uartNameDescriptor);
- setAdvertisedServiceUuid(this->_uartService.uuid());
- addAttribute(this->_rxCharacteristic);
- addAttribute(this->_rxNameDescriptor);
- this->_rxCharacteristic.setEventHandler(BLEWritten, BLESerial::_received);
- addAttribute(this->_txCharacteristic);
- addAttribute(this->_txNameDescriptor);
-}
-
-void BLESerial::begin(...) {
- BLEPeripheral::begin();
- #ifdef BLE_SERIAL_DEBUG
- Serial.println(F("BLESerial::begin()"));
- #endif
-}
-
-void BLESerial::poll() {
- if (millis() < this->_flushed + 100) {
- BLEPeripheral::poll();
- } else {
- flush();
- }
-}
-
-void BLESerial::end() {
- this->_rxCharacteristic.setEventHandler(BLEWritten, NULL);
- this->_rxHead = this->_rxTail = 0;
- flush();
- BLEPeripheral::disconnect();
-}
-
-int BLESerial::available(void) {
- BLEPeripheral::poll();
- int retval = (this->_rxHead - this->_rxTail + sizeof(this->_rxBuffer)) % sizeof(this->_rxBuffer);
- #ifdef BLE_SERIAL_DEBUG
- Serial.print(F("BLESerial::available() = "));
- Serial.println(retval);
- #endif
- return retval;
-}
-
-int BLESerial::peek(void) {
- BLEPeripheral::poll();
- if (this->_rxTail == this->_rxHead) return -1;
- uint8_t byte = this->_rxBuffer[this->_rxTail];
- #ifdef BLE_SERIAL_DEBUG
- Serial.print(F("BLESerial::peek() = "));
- Serial.print((char) byte);
- Serial.print(F(" 0x"));
- Serial.println(byte, HEX);
- #endif
- return byte;
-}
-
-int BLESerial::read(void) {
- BLEPeripheral::poll();
- if (this->_rxTail == this->_rxHead) return -1;
- this->_rxTail = (this->_rxTail + 1) % sizeof(this->_rxBuffer);
- uint8_t byte = this->_rxBuffer[this->_rxTail];
- #ifdef BLE_SERIAL_DEBUG
- Serial.print(F("BLESerial::read() = "));
- Serial.print((char) byte);
- Serial.print(F(" 0x"));
- Serial.println(byte, HEX);
- #endif
- return byte;
-}
-
-void BLESerial::flush(void) {
- if (this->_txCount == 0) return;
- this->_txCharacteristic.setValue(this->_txBuffer, this->_txCount);
- this->_flushed = millis();
- this->_txCount = 0;
- BLEPeripheral::poll();
- #ifdef BLE_SERIAL_DEBUG
- Serial.println(F("BLESerial::flush()"));
- #endif
-}
-
-size_t BLESerial::write(uint8_t byte) {
- BLEPeripheral::poll();
- if (this->_txCharacteristic.subscribed() == false) return 0;
- this->_txBuffer[this->_txCount++] = byte;
- if (this->_txCount == sizeof(this->_txBuffer)) flush();
- #ifdef BLE_SERIAL_DEBUG
- Serial.print(F("BLESerial::write("));
- Serial.print((char) byte);
- Serial.print(F(" 0x"));
- Serial.print(byte, HEX);
- Serial.println(F(") = 1"));
- #endif
- return 1;
-}
-
-BLESerial::operator bool() {
- bool retval = BLEPeripheral::connected();
- #ifdef BLE_SERIAL_DEBUG
- Serial.print(F("BLESerial::operator bool() = "));
- Serial.println(retval);
- #endif
- return retval;
-}
-
-void BLESerial::_received(const uint8_t* data, size_t size) {
- for (int i = 0; i < size; i++) {
- this->_rxHead = (this->_rxHead + 1) % sizeof(this->_rxBuffer);
- this->_rxBuffer[this->_rxHead] = data[i];
- }
- #ifdef BLE_SERIAL_DEBUG
- Serial.print(F("BLESerial::received("));
- for (int i = 0; i < size; i++) Serial.print((char) data[i]);
- Serial.println(F(")"));
- #endif
-}
-
-void BLESerial::_received(BLECentral& /*central*/, BLECharacteristic& rxCharacteristic) {
- BLESerial::_instance->_received(rxCharacteristic.value(), rxCharacteristic.valueLength());
-}
diff --git a/lib/Adafruit NeoPixel/examples/StrandtestBLE/BLESerial.h b/lib/Adafruit NeoPixel/examples/StrandtestBLE/BLESerial.h
deleted file mode 100644
index 01904c788..000000000
--- a/lib/Adafruit NeoPixel/examples/StrandtestBLE/BLESerial.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef _BLE_SERIAL_H_
-#define _BLE_SERIAL_H_
-
-#include
-#include
-
-class BLESerial : public BLEPeripheral, public Stream
-{
- public:
- BLESerial(unsigned char req, unsigned char rdy, unsigned char rst);
-
- void begin(...);
- void poll();
- void end();
-
- virtual int available(void);
- virtual int peek(void);
- virtual int read(void);
- virtual void flush(void);
- virtual size_t write(uint8_t byte);
- using Print::write;
- virtual operator bool();
-
- private:
- unsigned long _flushed;
- static BLESerial* _instance;
-
- size_t _rxHead;
- size_t _rxTail;
- size_t _rxCount() const;
- uint8_t _rxBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH];
- size_t _txCount;
- uint8_t _txBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH];
-
- BLEService _uartService = BLEService("6E400001-B5A3-F393-E0A9-E50E24DCCA9E");
- BLEDescriptor _uartNameDescriptor = BLEDescriptor("2901", "UART");
- BLECharacteristic _rxCharacteristic = BLECharacteristic("6E400002-B5A3-F393-E0A9-E50E24DCCA9E", BLEWriteWithoutResponse, BLE_ATTRIBUTE_MAX_VALUE_LENGTH);
- BLEDescriptor _rxNameDescriptor = BLEDescriptor("2901", "RX - Receive Data (Write)");
- BLECharacteristic _txCharacteristic = BLECharacteristic("6E400003-B5A3-F393-E0A9-E50E24DCCA9E", BLENotify, BLE_ATTRIBUTE_MAX_VALUE_LENGTH);
- BLEDescriptor _txNameDescriptor = BLEDescriptor("2901", "TX - Transfer Data (Notify)");
-
- void _received(const uint8_t* data, size_t size);
- static void _received(BLECentral& /*central*/, BLECharacteristic& rxCharacteristic);
-};
-
-#endif
diff --git a/lib/Adafruit NeoPixel/examples/StrandtestBLE/StrandtestBLE.ino b/lib/Adafruit NeoPixel/examples/StrandtestBLE/StrandtestBLE.ino
deleted file mode 100644
index 593b35b6d..000000000
--- a/lib/Adafruit NeoPixel/examples/StrandtestBLE/StrandtestBLE.ino
+++ /dev/null
@@ -1,192 +0,0 @@
-/****************************************************************************
- * This example was developed by the Hackerspace San Salvador to demonstrate
- * the simultaneous use of the NeoPixel library and the Bluetooth SoftDevice.
- * To compile this example you'll need to add support for the NRF52 based
- * following the instructions at:
- * https://github.com/sandeepmistry/arduino-nRF5
- * Or adding the following URL to the board manager URLs on Arduino preferences:
- * https://sandeepmistry.github.io/arduino-nRF5/package_nRF5_boards_index.json
- * Then you can install the BLEPeripheral library avaiable at:
- * https://github.com/sandeepmistry/arduino-BLEPeripheral
- * To test it, compile this example and use the UART module from the nRF
- * Toolbox App for Android. Edit the interface and send the characters
- * 'a' to 'i' to switch the animation.
- * There is a delay because this example blocks the thread of execution but
- * the change will be shown after the current animation ends. (This might
- * take a couple of seconds)
- * For more info write us at: info _at- teubi.co
- */
-#include
-#include
-#include "BLESerial.h"
-#include
-
-#define PIN 15 // Pin where NeoPixels are connected
-
-// Declare our NeoPixel strip object:
-Adafruit_NeoPixel strip(64, PIN, NEO_GRB + NEO_KHZ800);
-// Argument 1 = Number of pixels in NeoPixel strip
-// Argument 2 = Arduino pin number (most are valid)
-// Argument 3 = Pixel type flags, add together as needed:
-// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
-// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
-// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
-// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
-// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
-
-// NEOPIXEL BEST PRACTICES for most reliable operation:
-// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections.
-// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel.
-// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR.
-// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS
-// connect GROUND (-) first, then +, then data.
-// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip,
-// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED.
-// (Skipping these may work OK on your workbench but can fail in the field)
-
-// define pins (varies per shield/board)
-#define BLE_REQ 10
-#define BLE_RDY 2
-#define BLE_RST 9
-
-// create ble serial instance, see pinouts above
-BLESerial BLESerial(BLE_REQ, BLE_RDY, BLE_RST);
-
-uint8_t current_state = 0;
-uint8_t rgb_values[3];
-
-void setup() {
- Serial.begin(115200);
- Serial.println("Hello World!");
- // custom services and characteristics can be added as well
- BLESerial.setLocalName("UART_HS");
- BLESerial.begin();
-
- strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
- strip.show(); // Turn OFF all pixels ASAP
-
- //pinMode(PIN, OUTPUT);
- //digitalWrite(PIN, LOW);
-
- current_state = 'a';
-}
-
-void loop() {
- while(BLESerial.available()) {
- uint8_t character = BLESerial.read();
- switch(character) {
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f':
- case 'g':
- case 'h':
- current_state = character;
- break;
- };
- }
- switch(current_state) {
- case 'a':
- colorWipe(strip.Color(255, 0, 0), 20); // Red
- break;
- case 'b':
- colorWipe(strip.Color( 0, 255, 0), 20); // Green
- break;
- case 'c':
- colorWipe(strip.Color( 0, 0, 255), 20); // Blue
- break;
- case 'd':
- theaterChase(strip.Color(255, 0, 0), 20); // Red
- break;
- case 'e':
- theaterChase(strip.Color( 0, 255, 0), 20); // Green
- break;
- case 'f':
- theaterChase(strip.Color(255, 0, 255), 20); // Cyan
- break;
- case 'g':
- rainbow(10);
- break;
- case 'h':
- theaterChaseRainbow(20);
- break;
- }
-}
-
-// Fill strip pixels one after another with a color. Strip is NOT cleared
-// first; anything there will be covered pixel by pixel. Pass in color
-// (as a single 'packed' 32-bit value, which you can get by calling
-// strip.Color(red, green, blue) as shown in the loop() function above),
-// and a delay time (in milliseconds) between pixels.
-void colorWipe(uint32_t color, int wait) {
- for(int i=0; i RGB
- strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
- }
- strip.show(); // Update strip with new contents
- delay(wait); // Pause for a moment
- firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames
- }
- }
-}
diff --git a/lib/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/.none.test.only b/lib/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/.none.test.only
deleted file mode 100644
index 8b1378917..000000000
--- a/lib/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/.none.test.only
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/lib/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/BLESerial.cpp b/lib/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/BLESerial.cpp
deleted file mode 100644
index d1693dec8..000000000
--- a/lib/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/BLESerial.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-#include "BLESerial.h"
-
-// #define BLE_SERIAL_DEBUG
-
-BLESerial* BLESerial::_instance = NULL;
-
-BLESerial::BLESerial(unsigned char req, unsigned char rdy, unsigned char rst) :
- BLEPeripheral(req, rdy, rst)
-{
- this->_txCount = 0;
- this->_rxHead = this->_rxTail = 0;
- this->_flushed = 0;
- BLESerial::_instance = this;
-
- addAttribute(this->_uartService);
- addAttribute(this->_uartNameDescriptor);
- setAdvertisedServiceUuid(this->_uartService.uuid());
- addAttribute(this->_rxCharacteristic);
- addAttribute(this->_rxNameDescriptor);
- this->_rxCharacteristic.setEventHandler(BLEWritten, BLESerial::_received);
- addAttribute(this->_txCharacteristic);
- addAttribute(this->_txNameDescriptor);
-}
-
-void BLESerial::begin(...) {
- BLEPeripheral::begin();
- #ifdef BLE_SERIAL_DEBUG
- Serial.println(F("BLESerial::begin()"));
- #endif
-}
-
-void BLESerial::poll() {
- if (millis() < this->_flushed + 100) {
- BLEPeripheral::poll();
- } else {
- flush();
- }
-}
-
-void BLESerial::end() {
- this->_rxCharacteristic.setEventHandler(BLEWritten, NULL);
- this->_rxHead = this->_rxTail = 0;
- flush();
- BLEPeripheral::disconnect();
-}
-
-int BLESerial::available(void) {
- BLEPeripheral::poll();
- int retval = (this->_rxHead - this->_rxTail + sizeof(this->_rxBuffer)) % sizeof(this->_rxBuffer);
- #ifdef BLE_SERIAL_DEBUG
- Serial.print(F("BLESerial::available() = "));
- Serial.println(retval);
- #endif
- return retval;
-}
-
-int BLESerial::peek(void) {
- BLEPeripheral::poll();
- if (this->_rxTail == this->_rxHead) return -1;
- uint8_t byte = this->_rxBuffer[this->_rxTail];
- #ifdef BLE_SERIAL_DEBUG
- Serial.print(F("BLESerial::peek() = "));
- Serial.print((char) byte);
- Serial.print(F(" 0x"));
- Serial.println(byte, HEX);
- #endif
- return byte;
-}
-
-int BLESerial::read(void) {
- BLEPeripheral::poll();
- if (this->_rxTail == this->_rxHead) return -1;
- this->_rxTail = (this->_rxTail + 1) % sizeof(this->_rxBuffer);
- uint8_t byte = this->_rxBuffer[this->_rxTail];
- #ifdef BLE_SERIAL_DEBUG
- Serial.print(F("BLESerial::read() = "));
- Serial.print((char) byte);
- Serial.print(F(" 0x"));
- Serial.println(byte, HEX);
- #endif
- return byte;
-}
-
-void BLESerial::flush(void) {
- if (this->_txCount == 0) return;
- this->_txCharacteristic.setValue(this->_txBuffer, this->_txCount);
- this->_flushed = millis();
- this->_txCount = 0;
- BLEPeripheral::poll();
- #ifdef BLE_SERIAL_DEBUG
- Serial.println(F("BLESerial::flush()"));
- #endif
-}
-
-size_t BLESerial::write(uint8_t byte) {
- BLEPeripheral::poll();
- if (this->_txCharacteristic.subscribed() == false) return 0;
- this->_txBuffer[this->_txCount++] = byte;
- if (this->_txCount == sizeof(this->_txBuffer)) flush();
- #ifdef BLE_SERIAL_DEBUG
- Serial.print(F("BLESerial::write("));
- Serial.print((char) byte);
- Serial.print(F(" 0x"));
- Serial.print(byte, HEX);
- Serial.println(F(") = 1"));
- #endif
- return 1;
-}
-
-BLESerial::operator bool() {
- bool retval = BLEPeripheral::connected();
- #ifdef BLE_SERIAL_DEBUG
- Serial.print(F("BLESerial::operator bool() = "));
- Serial.println(retval);
- #endif
- return retval;
-}
-
-void BLESerial::_received(const uint8_t* data, size_t size) {
- for (int i = 0; i < size; i++) {
- this->_rxHead = (this->_rxHead + 1) % sizeof(this->_rxBuffer);
- this->_rxBuffer[this->_rxHead] = data[i];
- }
- #ifdef BLE_SERIAL_DEBUG
- Serial.print(F("BLESerial::received("));
- for (int i = 0; i < size; i++) Serial.print((char) data[i]);
- Serial.println(F(")"));
- #endif
-}
-
-void BLESerial::_received(BLECentral& /*central*/, BLECharacteristic& rxCharacteristic) {
- BLESerial::_instance->_received(rxCharacteristic.value(), rxCharacteristic.valueLength());
-}
diff --git a/lib/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/BLESerial.h b/lib/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/BLESerial.h
deleted file mode 100644
index 01904c788..000000000
--- a/lib/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/BLESerial.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef _BLE_SERIAL_H_
-#define _BLE_SERIAL_H_
-
-#include
-#include
-
-class BLESerial : public BLEPeripheral, public Stream
-{
- public:
- BLESerial(unsigned char req, unsigned char rdy, unsigned char rst);
-
- void begin(...);
- void poll();
- void end();
-
- virtual int available(void);
- virtual int peek(void);
- virtual int read(void);
- virtual void flush(void);
- virtual size_t write(uint8_t byte);
- using Print::write;
- virtual operator bool();
-
- private:
- unsigned long _flushed;
- static BLESerial* _instance;
-
- size_t _rxHead;
- size_t _rxTail;
- size_t _rxCount() const;
- uint8_t _rxBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH];
- size_t _txCount;
- uint8_t _txBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH];
-
- BLEService _uartService = BLEService("6E400001-B5A3-F393-E0A9-E50E24DCCA9E");
- BLEDescriptor _uartNameDescriptor = BLEDescriptor("2901", "UART");
- BLECharacteristic _rxCharacteristic = BLECharacteristic("6E400002-B5A3-F393-E0A9-E50E24DCCA9E", BLEWriteWithoutResponse, BLE_ATTRIBUTE_MAX_VALUE_LENGTH);
- BLEDescriptor _rxNameDescriptor = BLEDescriptor("2901", "RX - Receive Data (Write)");
- BLECharacteristic _txCharacteristic = BLECharacteristic("6E400003-B5A3-F393-E0A9-E50E24DCCA9E", BLENotify, BLE_ATTRIBUTE_MAX_VALUE_LENGTH);
- BLEDescriptor _txNameDescriptor = BLEDescriptor("2901", "TX - Transfer Data (Notify)");
-
- void _received(const uint8_t* data, size_t size);
- static void _received(BLECentral& /*central*/, BLECharacteristic& rxCharacteristic);
-};
-
-#endif
diff --git a/lib/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/StrandtestBLE_nodelay.ino b/lib/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/StrandtestBLE_nodelay.ino
deleted file mode 100644
index 20c924d01..000000000
--- a/lib/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/StrandtestBLE_nodelay.ino
+++ /dev/null
@@ -1,198 +0,0 @@
-/****************************************************************************
- * This example was developed by the Hackerspace San Salvador to demonstrate
- * the simultaneous use of the NeoPixel library and the Bluetooth SoftDevice.
- * To compile this example you'll need to add support for the NRF52 based
- * following the instructions at:
- * https://github.com/sandeepmistry/arduino-nRF5
- * Or adding the following URL to the board manager URLs on Arduino preferences:
- * https://sandeepmistry.github.io/arduino-nRF5/package_nRF5_boards_index.json
- * Then you can install the BLEPeripheral library avaiable at:
- * https://github.com/sandeepmistry/arduino-BLEPeripheral
- * To test it, compile this example and use the UART module from the nRF
- * Toolbox App for Android. Edit the interface and send the characters
- * 'a' to 'i' to switch the animation.
- * There is a no delay because this example does not block the threads execution
- * so the change will be shown immediately and will not need to wait for the current
- * animation to end.
- * For more info write us at: info _at- teubi.co
- */
-#include
-#include
-#include "BLESerial.h"
-#include
-
-#define PIN 15 // Pin where NeoPixels are connected
-
-// Declare our NeoPixel strip object:
-Adafruit_NeoPixel strip(64, PIN, NEO_GRB + NEO_KHZ800);
-// Argument 1 = Number of pixels in NeoPixel strip
-// Argument 2 = Arduino pin number (most are valid)
-// Argument 3 = Pixel type flags, add together as needed:
-// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
-// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
-// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
-// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
-// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
-
-// NEOPIXEL BEST PRACTICES for most reliable operation:
-// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections.
-// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel.
-// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR.
-// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS
-// connect GROUND (-) first, then +, then data.
-// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip,
-// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED.
-// (Skipping these may work OK on your workbench but can fail in the field)
-
-// define pins (varies per shield/board)
-#define BLE_REQ 10
-#define BLE_RDY 2
-#define BLE_RST 9
-
-// create ble serial instance, see pinouts above
-BLESerial BLESerial(BLE_REQ, BLE_RDY, BLE_RST);
-
-uint8_t current_state = 0;
-uint8_t rgb_values[3];
-
-void setup() {
- Serial.begin(115200);
- Serial.println("Hello World!");
- // custom services and characteristics can be added as well
- BLESerial.setLocalName("UART_HS");
- BLESerial.begin();
-
- strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
- strip.show(); // Turn OFF all pixels ASAP
-
- //pinMode(PIN, OUTPUT);
- //digitalWrite(PIN, LOW);
-
- current_state = 'a';
-}
-
-void loop() {
- while(BLESerial.available()) {
- uint8_t character = BLESerial.read();
- switch(character) {
- case 'a':
- case 'b':
- case 'c':
- case 'd':
- case 'e':
- case 'f':
- case 'g':
- case 'h':
- current_state = character;
- break;
- };
- }
- switch(current_state) {
- case 'a':
- colorWipe(strip.Color(255, 0, 0), 20); // Red
- break;
- case 'b':
- colorWipe(strip.Color( 0, 255, 0), 20); // Green
- break;
- case 'c':
- colorWipe(strip.Color( 0, 0, 255), 20); // Blue
- break;
- case 'd':
- theaterChase(strip.Color(255, 0, 0), 20); // Red
- break;
- case 'e':
- theaterChase(strip.Color( 0, 255, 0), 20); // Green
- break;
- case 'f':
- theaterChase(strip.Color(255, 0, 255), 20); // Cyan
- break;
- case 'g':
- rainbow(10);
- break;
- case 'h':
- theaterChaseRainbow(20);
- break;
- }
-}
-
-// Some functions of our own for creating animated effects -----------------
-
-// Fill strip pixels one after another with a color. Strip is NOT cleared
-// first; anything there will be covered pixel by pixel. Pass in color
-// (as a single 'packed' 32-bit value, which you can get by calling
-// strip.Color(red, green, blue) as shown in the loop() function above),
-// and a delay time (in milliseconds) between pixels.
-void colorWipe(uint32_t color, int wait) {
- if(pixelInterval != wait)
- pixelInterval = wait; // Update delay time
- strip.setPixelColor(pixelCurrent, color); // Set pixel's color (in RAM)
- strip.show(); // Update strip to match
- pixelCurrent++; // Advance current pixel
- if(pixelCurrent >= pixelNumber) // Loop the pattern from the first LED
- pixelCurrent = 0;
-}
-
-// Theater-marquee-style chasing lights. Pass in a color (32-bit value,
-// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms)
-// between frames.
-void theaterChase(uint32_t color, int wait) {
- if(pixelInterval != wait)
- pixelInterval = wait; // Update delay time
- for(int i = 0; i < pixelNumber; i++) {
- strip.setPixelColor(i + pixelQueue, color); // Set pixel's color (in RAM)
- }
- strip.show(); // Update strip to match
- for(int i=0; i < pixelNumber; i+3) {
- strip.setPixelColor(i + pixelQueue, strip.Color(0, 0, 0)); // Set pixel's color (in RAM)
- }
- pixelQueue++; // Advance current pixel
- if(pixelQueue >= 3)
- pixelQueue = 0; // Loop the pattern from the first LED
-}
-
-// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
-void rainbow(uint8_t wait) {
- if(pixelInterval != wait)
- pixelInterval = wait;
- for(uint16_t i=0; i < pixelNumber; i++) {
- strip.setPixelColor(i, Wheel((i + pixelCycle) & 255)); // Update delay time
- }
- strip.show(); // Update strip to match
- pixelCycle++; // Advance current cycle
- if(pixelCycle >= 256)
- pixelCycle = 0; // Loop the cycle back to the begining
-}
-
-//Theatre-style crawling lights with rainbow effect
-void theaterChaseRainbow(uint8_t wait) {
- if(pixelInterval != wait)
- pixelInterval = wait; // Update delay time
- for(int i=0; i < pixelNumber; i+3) {
- strip.setPixelColor(i + pixelQueue, Wheel((i + pixelCycle) % 255)); // Update delay time
- }
- strip.show();
- for(int i=0; i < pixelNumber; i+3) {
- strip.setPixelColor(i + pixelQueue, strip.Color(0, 0, 0)); // Update delay time
- }
- pixelQueue++; // Advance current queue
- pixelCycle++; // Advance current cycle
- if(pixelQueue >= 3)
- pixelQueue = 0; // Loop
- if(pixelCycle >= 256)
- pixelCycle = 0; // Loop
-}
-
-// Input a value 0 to 255 to get a color value.
-// The colours are a transition r - g - b - back to r.
-uint32_t Wheel(byte WheelPos) {
- WheelPos = 255 - WheelPos;
- if(WheelPos < 85) {
- return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
- }
- if(WheelPos < 170) {
- WheelPos -= 85;
- return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
- }
- WheelPos -= 170;
- return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
-}
diff --git a/lib/Adafruit NeoPixel/examples/buttoncycler/.esp8266.test.skip b/lib/Adafruit NeoPixel/examples/buttoncycler/.esp8266.test.skip
deleted file mode 100644
index e69de29bb..000000000
diff --git a/lib/Adafruit NeoPixel/examples/buttoncycler/buttoncycler.ino b/lib/Adafruit NeoPixel/examples/buttoncycler/buttoncycler.ino
deleted file mode 100644
index f6d87edcb..000000000
--- a/lib/Adafruit NeoPixel/examples/buttoncycler/buttoncycler.ino
+++ /dev/null
@@ -1,164 +0,0 @@
-// Simple demonstration on using an input device to trigger changes on your
-// NeoPixels. Wire a momentary push button to connect from ground to a
-// digital IO pin. When the button is pressed it will change to a new pixel
-// animation. Initial state has all pixels off -- press the button once to
-// start the first animation. As written, the button does not interrupt an
-// animation in-progress, it works only when idle.
-
-#include
-#ifdef __AVR__
- #include // Required for 16 MHz Adafruit Trinket
-#endif
-
-// Digital IO pin connected to the button. This will be driven with a
-// pull-up resistor so the switch pulls the pin to ground momentarily.
-// On a high -> low transition the button press logic will execute.
-#define BUTTON_PIN 2
-
-#define PIXEL_PIN 6 // Digital IO pin connected to the NeoPixels.
-
-#define PIXEL_COUNT 16 // Number of NeoPixels
-
-// Declare our NeoPixel strip object:
-Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
-// Argument 1 = Number of pixels in NeoPixel strip
-// Argument 2 = Arduino pin number (most are valid)
-// Argument 3 = Pixel type flags, add together as needed:
-// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
-// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
-// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
-// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
-// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
-
-boolean oldState = HIGH;
-int mode = 0; // Currently-active animation mode, 0-9
-
-void setup() {
- pinMode(BUTTON_PIN, INPUT_PULLUP);
- strip.begin(); // Initialize NeoPixel strip object (REQUIRED)
- strip.show(); // Initialize all pixels to 'off'
-}
-
-void loop() {
- // Get current button state.
- boolean newState = digitalRead(BUTTON_PIN);
-
- // Check if state changed from high to low (button press).
- if((newState == LOW) && (oldState == HIGH)) {
- // Short delay to debounce button.
- delay(20);
- // Check if button is still low after debounce.
- newState = digitalRead(BUTTON_PIN);
- if(newState == LOW) { // Yes, still low
- if(++mode > 8) mode = 0; // Advance to next mode, wrap around after #8
- switch(mode) { // Start the new animation...
- case 0:
- colorWipe(strip.Color( 0, 0, 0), 50); // Black/off
- break;
- case 1:
- colorWipe(strip.Color(255, 0, 0), 50); // Red
- break;
- case 2:
- colorWipe(strip.Color( 0, 255, 0), 50); // Green
- break;
- case 3:
- colorWipe(strip.Color( 0, 0, 255), 50); // Blue
- break;
- case 4:
- theaterChase(strip.Color(127, 127, 127), 50); // White
- break;
- case 5:
- theaterChase(strip.Color(127, 0, 0), 50); // Red
- break;
- case 6:
- theaterChase(strip.Color( 0, 0, 127), 50); // Blue
- break;
- case 7:
- rainbow(10);
- break;
- case 8:
- theaterChaseRainbow(50);
- break;
- }
- }
- }
-
- // Set the last-read button state to the old state.
- oldState = newState;
-}
-
-// Fill strip pixels one after another with a color. Strip is NOT cleared
-// first; anything there will be covered pixel by pixel. Pass in color
-// (as a single 'packed' 32-bit value, which you can get by calling
-// strip.Color(red, green, blue) as shown in the loop() function above),
-// and a delay time (in milliseconds) between pixels.
-void colorWipe(uint32_t color, int wait) {
- for(int i=0; i RGB
- strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
- }
- strip.show(); // Update strip with new contents
- delay(wait); // Pause for a moment
- firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames
- }
- }
-}
diff --git a/lib/Adafruit NeoPixel/examples/simple/.esp8266.test.skip b/lib/Adafruit NeoPixel/examples/simple/.esp8266.test.skip
deleted file mode 100644
index e69de29bb..000000000
diff --git a/lib/Adafruit NeoPixel/examples/simple/simple.ino b/lib/Adafruit NeoPixel/examples/simple/simple.ino
deleted file mode 100644
index 09f458ecb..000000000
--- a/lib/Adafruit NeoPixel/examples/simple/simple.ino
+++ /dev/null
@@ -1,50 +0,0 @@
-// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
-// Released under the GPLv3 license to match the rest of the
-// Adafruit NeoPixel library
-
-#include
-#ifdef __AVR__
- #include // Required for 16 MHz Adafruit Trinket
-#endif
-
-// Which pin on the Arduino is connected to the NeoPixels?
-#define PIN 6 // On Trinket or Gemma, suggest changing this to 1
-
-// How many NeoPixels are attached to the Arduino?
-#define NUMPIXELS 16 // Popular NeoPixel ring size
-
-// When setting up the NeoPixel library, we tell it how many pixels,
-// and which pin to use to send signals. Note that for older NeoPixel
-// strips you might need to change the third parameter -- see the
-// strandtest example for more information on possible values.
-Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
-
-#define DELAYVAL 500 // Time (in milliseconds) to pause between pixels
-
-void setup() {
- // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
- // Any other board, you can remove this part (but no harm leaving it):
-#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
- clock_prescale_set(clock_div_1);
-#endif
- // END of Trinket-specific code.
-
- pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
-}
-
-void loop() {
- pixels.clear(); // Set all pixel colors to 'off'
-
- // The first NeoPixel in a strand is #0, second is 1, all the way up
- // to the count of pixels minus one.
- for(int i=0; i
-#ifdef __AVR__
- #include // Required for 16 MHz Adafruit Trinket
-#endif
-
-// Which pin on the Arduino is connected to the NeoPixels?
-int pin = 6; // On Trinket or Gemma, suggest changing this to 1
-
-// How many NeoPixels are attached to the Arduino?
-int numPixels = 16; // Popular NeoPixel ring size
-
-// NeoPixel color format & data rate. See the strandtest example for
-// information on possible values.
-int pixelFormat = NEO_GRB + NEO_KHZ800;
-
-// Rather than declaring the whole NeoPixel object here, we just create
-// a pointer for one, which we'll then allocate later...
-Adafruit_NeoPixel *pixels;
-
-#define DELAYVAL 500 // Time (in milliseconds) to pause between pixels
-
-void setup() {
- // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
- // Any other board, you can remove this part (but no harm leaving it):
-#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
- clock_prescale_set(clock_div_1);
-#endif
- // END of Trinket-specific code.
-
- // Right about here is where we could read 'pin', 'numPixels' and/or
- // 'pixelFormat' from EEPROM or a file on SD or whatever. This is a simple
- // example and doesn't do that -- those variables are just set to fixed
- // values at the top of this code -- but this is where it would happen.
-
- // Then create a new NeoPixel object dynamically with these values:
- pixels = new Adafruit_NeoPixel(numPixels, pin, pixelFormat);
-
- // Going forward from here, code works almost identically to any other
- // NeoPixel example, but instead of the dot operator on function calls
- // (e.g. pixels.begin()), we instead use pointer indirection (->) like so:
- pixels->begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
- // You'll see more of this in the loop() function below.
-}
-
-void loop() {
- pixels->clear(); // Set all pixel colors to 'off'
-
- // The first NeoPixel in a strand is #0, second is 1, all the way up
- // to the count of pixels minus one.
- for(int i=0; iColor() takes RGB values, from 0,0,0 up to 255,255,255
- // Here we're using a moderately bright green color:
- pixels->setPixelColor(i, pixels->Color(0, 150, 0));
-
- pixels->show(); // Send the updated pixel colors to the hardware.
-
- delay(DELAYVAL); // Pause before next pass through loop
- }
-}
diff --git a/lib/Adafruit NeoPixel/examples/strandtest/.esp8266.test.skip b/lib/Adafruit NeoPixel/examples/strandtest/.esp8266.test.skip
deleted file mode 100644
index e69de29bb..000000000
diff --git a/lib/Adafruit NeoPixel/examples/strandtest/strandtest.ino b/lib/Adafruit NeoPixel/examples/strandtest/strandtest.ino
deleted file mode 100644
index f4554cc82..000000000
--- a/lib/Adafruit NeoPixel/examples/strandtest/strandtest.ino
+++ /dev/null
@@ -1,143 +0,0 @@
-// A basic everyday NeoPixel strip test program.
-
-// NEOPIXEL BEST PRACTICES for most reliable operation:
-// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections.
-// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel.
-// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR.
-// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS
-// connect GROUND (-) first, then +, then data.
-// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip,
-// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED.
-// (Skipping these may work OK on your workbench but can fail in the field)
-
-#include
-#ifdef __AVR__
- #include // Required for 16 MHz Adafruit Trinket
-#endif
-
-// Which pin on the Arduino is connected to the NeoPixels?
-// On a Trinket or Gemma we suggest changing this to 1:
-#define LED_PIN 6
-
-// How many NeoPixels are attached to the Arduino?
-#define LED_COUNT 60
-
-// Declare our NeoPixel strip object:
-Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
-// Argument 1 = Number of pixels in NeoPixel strip
-// Argument 2 = Arduino pin number (most are valid)
-// Argument 3 = Pixel type flags, add together as needed:
-// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
-// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
-// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
-// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
-// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
-
-
-// setup() function -- runs once at startup --------------------------------
-
-void setup() {
- // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
- // Any other board, you can remove this part (but no harm leaving it):
-#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
- clock_prescale_set(clock_div_1);
-#endif
- // END of Trinket-specific code.
-
- strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
- strip.show(); // Turn OFF all pixels ASAP
- strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
-}
-
-
-// loop() function -- runs repeatedly as long as board is on ---------------
-
-void loop() {
- // Fill along the length of the strip in various colors...
- colorWipe(strip.Color(255, 0, 0), 50); // Red
- colorWipe(strip.Color( 0, 255, 0), 50); // Green
- colorWipe(strip.Color( 0, 0, 255), 50); // Blue
-
- // Do a theater marquee effect in various colors...
- theaterChase(strip.Color(127, 127, 127), 50); // White, half brightness
- theaterChase(strip.Color(127, 0, 0), 50); // Red, half brightness
- theaterChase(strip.Color( 0, 0, 127), 50); // Blue, half brightness
-
- rainbow(10); // Flowing rainbow cycle along the whole strip
- theaterChaseRainbow(50); // Rainbow-enhanced theaterChase variant
-}
-
-
-// Some functions of our own for creating animated effects -----------------
-
-// Fill strip pixels one after another with a color. Strip is NOT cleared
-// first; anything there will be covered pixel by pixel. Pass in color
-// (as a single 'packed' 32-bit value, which you can get by calling
-// strip.Color(red, green, blue) as shown in the loop() function above),
-// and a delay time (in milliseconds) between pixels.
-void colorWipe(uint32_t color, int wait) {
- for(int i=0; i RGB
- strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
- }
- strip.show(); // Update strip with new contents
- delay(wait); // Pause for a moment
- firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames
- }
- }
-}
diff --git a/lib/Adafruit NeoPixel/examples/strandtest_nodelay/.esp8266.test.skip b/lib/Adafruit NeoPixel/examples/strandtest_nodelay/.esp8266.test.skip
deleted file mode 100644
index 8b1378917..000000000
--- a/lib/Adafruit NeoPixel/examples/strandtest_nodelay/.esp8266.test.skip
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/lib/Adafruit NeoPixel/examples/strandtest_nodelay/strandtest_nodelay.ino b/lib/Adafruit NeoPixel/examples/strandtest_nodelay/strandtest_nodelay.ino
deleted file mode 100644
index 9c392e2be..000000000
--- a/lib/Adafruit NeoPixel/examples/strandtest_nodelay/strandtest_nodelay.ino
+++ /dev/null
@@ -1,186 +0,0 @@
-// A non-blocking everyday NeoPixel strip test program.
-
-// NEOPIXEL BEST PRACTICES for most reliable operation:
-// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections.
-// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel.
-// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR.
-// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS
-// connect GROUND (-) first, then +, then data.
-// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip,
-// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED.
-// (Skipping these may work OK on your workbench but can fail in the field)
-
-#include
-#ifdef __AVR__
- #include // Required for 16 MHz Adafruit Trinket
-#endif
-
-// Which pin on the Arduino is connected to the NeoPixels?
-// On a Trinket or Gemma we suggest changing this to 1:
-#ifdef ESP32
-// Cannot use 6 as output for ESP. Pins 6-11 are connected to SPI flash. Use 16 instead.
-#define LED_PIN 16
-#else
-#define LED_PIN 6
-#endif
-
-// How many NeoPixels are attached to the Arduino?
-#define LED_COUNT 60
-
-// Declare our NeoPixel strip object:
-Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
-// Argument 1 = Number of pixels in NeoPixel strip
-// Argument 2 = Arduino pin number (most are valid)
-// Argument 3 = Pixel type flags, add together as needed:
-// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
-// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
-// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
-// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
-// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
-
-unsigned long pixelPrevious = 0; // Previous Pixel Millis
-unsigned long patternPrevious = 0; // Previous Pattern Millis
-int patternCurrent = 0; // Current Pattern Number
-int patternInterval = 5000; // Pattern Interval (ms)
-int pixelInterval = 50; // Pixel Interval (ms)
-int pixelQueue = 0; // Pattern Pixel Queue
-int pixelCycle = 0; // Pattern Pixel Cycle
-uint16_t pixelCurrent = 0; // Pattern Current Pixel Number
-uint16_t pixelNumber = LED_COUNT; // Total Number of Pixels
-
-// setup() function -- runs once at startup --------------------------------
-void setup() {
- // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
- // Any other board, you can remove this part (but no harm leaving it):
-#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
- clock_prescale_set(clock_div_1);
-#endif
- // END of Trinket-specific code.
-
- strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
- strip.show(); // Turn OFF all pixels ASAP
- strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
-}
-
-// loop() function -- runs repeatedly as long as board is on ---------------
-void loop() {
- unsigned long currentMillis = millis(); // Update current time
- if((currentMillis - patternPrevious) >= patternInterval) { // Check for expired time
- patternPrevious = currentMillis;
- patternCurrent++; // Advance to next pattern
- if(patternCurrent >= 7)
- patternCurrent = 0;
- }
-
- if(currentMillis - pixelPrevious >= pixelInterval) { // Check for expired time
- pixelPrevious = currentMillis; // Run current frame
- switch (patternCurrent) {
- case 7:
- theaterChaseRainbow(50); // Rainbow-enhanced theaterChase variant
- break;
- case 6:
- rainbow(10); // Flowing rainbow cycle along the whole strip
- break;
- case 5:
- theaterChase(strip.Color(0, 0, 127), 50); // Blue
- break;
- case 4:
- theaterChase(strip.Color(127, 0, 0), 50); // Red
- break;
- case 3:
- theaterChase(strip.Color(127, 127, 127), 50); // White
- break;
- case 2:
- colorWipe(strip.Color(0, 0, 255), 50); // Blue
- break;
- case 1:
- colorWipe(strip.Color(0, 255, 0), 50); // Green
- break;
- default:
- colorWipe(strip.Color(255, 0, 0), 50); // Red
- break;
- }
- }
-}
-
-// Some functions of our own for creating animated effects -----------------
-
-// Fill strip pixels one after another with a color. Strip is NOT cleared
-// first; anything there will be covered pixel by pixel. Pass in color
-// (as a single 'packed' 32-bit value, which you can get by calling
-// strip.Color(red, green, blue) as shown in the loop() function above),
-// and a delay time (in milliseconds) between pixels.
-void colorWipe(uint32_t color, int wait) {
- if(pixelInterval != wait)
- pixelInterval = wait; // Update delay time
- strip.setPixelColor(pixelCurrent, color); // Set pixel's color (in RAM)
- strip.show(); // Update strip to match
- pixelCurrent++; // Advance current pixel
- if(pixelCurrent >= pixelNumber) // Loop the pattern from the first LED
- pixelCurrent = 0;
-}
-
-// Theater-marquee-style chasing lights. Pass in a color (32-bit value,
-// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms)
-// between frames.
-void theaterChase(uint32_t color, int wait) {
- if(pixelInterval != wait)
- pixelInterval = wait; // Update delay time
- for(int i = 0; i < pixelNumber; i++) {
- strip.setPixelColor(i + pixelQueue, color); // Set pixel's color (in RAM)
- }
- strip.show(); // Update strip to match
- for(int i=0; i < pixelNumber; i+=3) {
- strip.setPixelColor(i + pixelQueue, strip.Color(0, 0, 0)); // Set pixel's color (in RAM)
- }
- pixelQueue++; // Advance current pixel
- if(pixelQueue >= 3)
- pixelQueue = 0; // Loop the pattern from the first LED
-}
-
-// Rainbow cycle along whole strip. Pass delay time (in ms) between frames.
-void rainbow(uint8_t wait) {
- if(pixelInterval != wait)
- pixelInterval = wait;
- for(uint16_t i=0; i < pixelNumber; i++) {
- strip.setPixelColor(i, Wheel((i + pixelCycle) & 255)); // Update delay time
- }
- strip.show(); // Update strip to match
- pixelCycle++; // Advance current cycle
- if(pixelCycle >= 256)
- pixelCycle = 0; // Loop the cycle back to the begining
-}
-
-//Theatre-style crawling lights with rainbow effect
-void theaterChaseRainbow(uint8_t wait) {
- if(pixelInterval != wait)
- pixelInterval = wait; // Update delay time
- for(int i=0; i < pixelNumber; i+=3) {
- strip.setPixelColor(i + pixelQueue, Wheel((i + pixelCycle) % 255)); // Update delay time
- }
- strip.show();
- for(int i=0; i < pixelNumber; i+=3) {
- strip.setPixelColor(i + pixelQueue, strip.Color(0, 0, 0)); // Update delay time
- }
- pixelQueue++; // Advance current queue
- pixelCycle++; // Advance current cycle
- if(pixelQueue >= 3)
- pixelQueue = 0; // Loop
- if(pixelCycle >= 256)
- pixelCycle = 0; // Loop
-}
-
-// Input a value 0 to 255 to get a color value.
-// The colours are a transition r - g - b - back to r.
-uint32_t Wheel(byte WheelPos) {
- WheelPos = 255 - WheelPos;
- if(WheelPos < 85) {
- return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
- }
- if(WheelPos < 170) {
- WheelPos -= 85;
- return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
- }
- WheelPos -= 170;
- return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
-}
diff --git a/lib/Adafruit NeoPixel/examples/strandtest_wheel/.esp8266.test.skip b/lib/Adafruit NeoPixel/examples/strandtest_wheel/.esp8266.test.skip
deleted file mode 100644
index e69de29bb..000000000
diff --git a/lib/Adafruit NeoPixel/examples/strandtest_wheel/strandtest_wheel.ino b/lib/Adafruit NeoPixel/examples/strandtest_wheel/strandtest_wheel.ino
deleted file mode 100644
index c0ca41edc..000000000
--- a/lib/Adafruit NeoPixel/examples/strandtest_wheel/strandtest_wheel.ino
+++ /dev/null
@@ -1,134 +0,0 @@
-#include
-#ifdef __AVR__
- #include
-#endif
-
-#define PIN 6
-
-// Parameter 1 = number of pixels in strip
-// Parameter 2 = Arduino pin number (most are valid)
-// Parameter 3 = pixel type flags, add together as needed:
-// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
-// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
-// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
-// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
-// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
-Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
-
-// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
-// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
-// and minimize distance between Arduino and first pixel. Avoid connecting
-// on a live circuit...if you must, connect GND first.
-
-void setup() {
- // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
- #if defined (__AVR_ATtiny85__)
- if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
- #endif
- // End of trinket special code
-
- strip.begin();
- strip.setBrightness(50);
- strip.show(); // Initialize all pixels to 'off'
-}
-
-void loop() {
- // Some example procedures showing how to display to the pixels:
- colorWipe(strip.Color(255, 0, 0), 50); // Red
- colorWipe(strip.Color(0, 255, 0), 50); // Green
- colorWipe(strip.Color(0, 0, 255), 50); // Blue
-//colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW
- // Send a theater pixel chase in...
- theaterChase(strip.Color(127, 127, 127), 50); // White
- theaterChase(strip.Color(127, 0, 0), 50); // Red
- theaterChase(strip.Color(0, 0, 127), 50); // Blue
-
- rainbow(20);
- rainbowCycle(20);
- theaterChaseRainbow(50);
-}
-
-// Fill the dots one after the other with a color
-void colorWipe(uint32_t c, uint8_t wait) {
- for(uint16_t i=0; i
-#include "sysctl.h"
-
-void k210Show(
- uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz)
-{
-
-#define CYCLES_800_T0H (sysctl_clock_get_freq(SYSCTL_CLOCK_CPU) / 2500000) // 0.4us
-#define CYCLES_800_T1H (sysctl_clock_get_freq(SYSCTL_CLOCK_CPU) / 1250000) // 0.8us
-#define CYCLES_800 (sysctl_clock_get_freq(SYSCTL_CLOCK_CPU) / 800000) // 1.25us per bit
-#define CYCLES_400_T0H (sysctl_clock_get_freq(SYSCTL_CLOCK_CPU) / 2000000) // 0.5uS
-#define CYCLES_400_T1H (sysctl_clock_get_freq(SYSCTL_CLOCK_CPU) / 833333) // 1.2us
-#define CYCLES_400 (sysctl_clock_get_freq(SYSCTL_CLOCK_CPU) / 400000) // 2.5us per bit
-
- uint8_t *p, *end, pix, mask;
- uint32_t t, time0, time1, period, c, startTime;
-
- p = pixels;
- end = p + numBytes;
- pix = *p++;
- mask = 0x80;
- startTime = 0;
-
-#ifdef NEO_KHZ400
- if (is800KHz)
- {
-#endif
- time0 = CYCLES_800_T0H;
- time1 = CYCLES_800_T1H;
- period = CYCLES_800;
-#ifdef NEO_KHZ400
- }
- else
- { // 400 KHz bitstream
- time0 = CYCLES_400_T0H;
- time1 = CYCLES_400_T1H;
- period = CYCLES_400;
- }
-#endif
-
- for (t = time0;; t = time0)
- {
- if (pix & mask)
- t = time1; // Bit high duration
- while (((c = read_cycle()) - startTime) < period)
- ; // Wait for bit start
- digitalWrite(pin, HIGH);
- startTime = c; // Save start time
- while (((c = read_cycle()) - startTime) < t)
- ; // Wait high duration
- digitalWrite(pin, LOW);
-
- if (!(mask >>= 1))
- { // Next bit/byte
- if (p >= end)
- break;
- pix = *p++;
- mask = 0x80;
- }
- }
- while ((read_cycle() - startTime) < period)
- ; // Wait for last bit
-}
-
-#endif // KENDRYTE_K210
diff --git a/lib/Adafruit NeoPixel/keywords.txt b/lib/Adafruit NeoPixel/keywords.txt
deleted file mode 100644
index 4003ede9d..000000000
--- a/lib/Adafruit NeoPixel/keywords.txt
+++ /dev/null
@@ -1,72 +0,0 @@
-#######################################
-# Syntax Coloring Map For Adafruit_NeoPixel
-#######################################
-# Class
-#######################################
-
-Adafruit_NeoPixel KEYWORD1
-
-#######################################
-# Methods and Functions
-#######################################
-
-begin KEYWORD2
-show KEYWORD2
-setPin KEYWORD2
-setPixelColor KEYWORD2
-fill KEYWORD2
-setBrightness KEYWORD2
-clear KEYWORD2
-updateLength KEYWORD2
-updateType KEYWORD2
-canShow KEYWORD2
-getPixels KEYWORD2
-getBrightness KEYWORD2
-getPin KEYWORD2
-numPixels KEYWORD2
-getPixelColor KEYWORD2
-sine8 KEYWORD2
-gamma8 KEYWORD2
-Color KEYWORD2
-ColorHSV KEYWORD2
-gamma32 KEYWORD2
-
-#######################################
-# Constants
-#######################################
-
-NEO_COLMASK LITERAL1
-NEO_SPDMASK LITERAL1
-NEO_KHZ800 LITERAL1
-NEO_KHZ400 LITERAL1
-NEO_RGB LITERAL1
-NEO_RBG LITERAL1
-NEO_GRB LITERAL1
-NEO_GBR LITERAL1
-NEO_BRG LITERAL1
-NEO_BGR LITERAL1
-NEO_WRGB LITERAL1
-NEO_WRBG LITERAL1
-NEO_WGRB LITERAL1
-NEO_WGBR LITERAL1
-NEO_WBRG LITERAL1
-NEO_WBGR LITERAL1
-NEO_RWGB LITERAL1
-NEO_RWBG LITERAL1
-NEO_RGWB LITERAL1
-NEO_RGBW LITERAL1
-NEO_RBWG LITERAL1
-NEO_RBGW LITERAL1
-NEO_GWRB LITERAL1
-NEO_GWBR LITERAL1
-NEO_GRWB LITERAL1
-NEO_GRBW LITERAL1
-NEO_GBWR LITERAL1
-NEO_GBRW LITERAL1
-NEO_BWRG LITERAL1
-NEO_BWGR LITERAL1
-NEO_BRWG LITERAL1
-NEO_BRGW LITERAL1
-NEO_BGWR LITERAL1
-NEO_BGRW LITERAL1
-
diff --git a/lib/Adafruit NeoPixel/library.properties b/lib/Adafruit NeoPixel/library.properties
deleted file mode 100644
index 7bbd4889c..000000000
--- a/lib/Adafruit NeoPixel/library.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-name=Adafruit NeoPixel
-version=1.10.6
-author=Adafruit
-maintainer=Adafruit
-sentence=Arduino library for controlling single-wire-based LED pixels and strip.
-paragraph=Arduino library for controlling single-wire-based LED pixels and strip.
-category=Display
-url=https://github.com/adafruit/Adafruit_NeoPixel
-architectures=*
-includes=Adafruit_NeoPixel.h
diff --git a/lib/Adafruit NeoPixel/rp2040_pio.h b/lib/Adafruit NeoPixel/rp2040_pio.h
deleted file mode 100644
index f7ccd46de..000000000
--- a/lib/Adafruit NeoPixel/rp2040_pio.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// -------------------------------------------------- //
-// This file is autogenerated by pioasm; do not edit! //
-// -------------------------------------------------- //
-
-// Unless you know what you are doing...
-// Lines 47 and 52 have been edited to set transmit bit count
-
-#if !PICO_NO_HARDWARE
-#include "hardware/pio.h"
-#endif
-
-// ------ //
-// ws2812 //
-// ------ //
-
-#define ws2812_wrap_target 0
-#define ws2812_wrap 3
-
-#define ws2812_T1 2
-#define ws2812_T2 5
-#define ws2812_T3 3
-
-static const uint16_t ws2812_program_instructions[] = {
- // .wrap_target
- 0x6221, // 0: out x, 1 side 0 [2]
- 0x1123, // 1: jmp !x, 3 side 1 [1]
- 0x1400, // 2: jmp 0 side 1 [4]
- 0xa442, // 3: nop side 0 [4]
- // .wrap
-};
-
-#if !PICO_NO_HARDWARE
-static const struct pio_program ws2812_program = {
- .instructions = ws2812_program_instructions,
- .length = 4,
- .origin = -1,
-};
-
-static inline pio_sm_config ws2812_program_get_default_config(uint offset) {
- pio_sm_config c = pio_get_default_sm_config();
- sm_config_set_wrap(&c, offset + ws2812_wrap_target, offset + ws2812_wrap);
- sm_config_set_sideset(&c, 1, false, false);
- return c;
-}
-
-#include "hardware/clocks.h"
-static inline void ws2812_program_init(PIO pio, uint sm, uint offset, uint pin,
- float freq, uint bits) {
- pio_gpio_init(pio, pin);
- pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
- pio_sm_config c = ws2812_program_get_default_config(offset);
- sm_config_set_sideset_pins(&c, pin);
- sm_config_set_out_shift(&c, false, true,
- bits); // <----<<< Length changed to "bits"
- sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
- int cycles_per_bit = ws2812_T1 + ws2812_T2 + ws2812_T3;
- float div = clock_get_hz(clk_sys) / (freq * cycles_per_bit);
- sm_config_set_clkdiv(&c, div);
- pio_sm_init(pio, sm, offset, &c);
- pio_sm_set_enabled(pio, sm, true);
-}
-
-#endif
diff --git a/lib/Adafruit BusIO/.github/ISSUE_TEMPLATE.md b/lib/Adafruit_BusIO/.github/ISSUE_TEMPLATE.md
similarity index 100%
rename from lib/Adafruit BusIO/.github/ISSUE_TEMPLATE.md
rename to lib/Adafruit_BusIO/.github/ISSUE_TEMPLATE.md
diff --git a/lib/Adafruit BusIO/.github/PULL_REQUEST_TEMPLATE.md b/lib/Adafruit_BusIO/.github/PULL_REQUEST_TEMPLATE.md
similarity index 100%
rename from lib/Adafruit BusIO/.github/PULL_REQUEST_TEMPLATE.md
rename to lib/Adafruit_BusIO/.github/PULL_REQUEST_TEMPLATE.md
diff --git a/lib/Adafruit BusIO/.github/workflows/githubci.yml b/lib/Adafruit_BusIO/.github/workflows/githubci.yml
similarity index 100%
rename from lib/Adafruit BusIO/.github/workflows/githubci.yml
rename to lib/Adafruit_BusIO/.github/workflows/githubci.yml
diff --git a/lib/Adafruit BusIO/Adafruit_BusIO_Register.cpp b/lib/Adafruit_BusIO/Adafruit_BusIO_Register.cpp
similarity index 100%
rename from lib/Adafruit BusIO/Adafruit_BusIO_Register.cpp
rename to lib/Adafruit_BusIO/Adafruit_BusIO_Register.cpp
diff --git a/lib/Adafruit BusIO/Adafruit_BusIO_Register.h b/lib/Adafruit_BusIO/Adafruit_BusIO_Register.h
similarity index 100%
rename from lib/Adafruit BusIO/Adafruit_BusIO_Register.h
rename to lib/Adafruit_BusIO/Adafruit_BusIO_Register.h
diff --git a/lib/Adafruit BusIO/Adafruit_I2CDevice.cpp b/lib/Adafruit_BusIO/Adafruit_I2CDevice.cpp
similarity index 100%
rename from lib/Adafruit BusIO/Adafruit_I2CDevice.cpp
rename to lib/Adafruit_BusIO/Adafruit_I2CDevice.cpp
diff --git a/lib/Adafruit BusIO/Adafruit_I2CDevice.h b/lib/Adafruit_BusIO/Adafruit_I2CDevice.h
similarity index 100%
rename from lib/Adafruit BusIO/Adafruit_I2CDevice.h
rename to lib/Adafruit_BusIO/Adafruit_I2CDevice.h
diff --git a/lib/Adafruit BusIO/Adafruit_I2CRegister.h b/lib/Adafruit_BusIO/Adafruit_I2CRegister.h
similarity index 100%
rename from lib/Adafruit BusIO/Adafruit_I2CRegister.h
rename to lib/Adafruit_BusIO/Adafruit_I2CRegister.h
diff --git a/lib/Adafruit BusIO/Adafruit_SPIDevice.cpp b/lib/Adafruit_BusIO/Adafruit_SPIDevice.cpp
similarity index 100%
rename from lib/Adafruit BusIO/Adafruit_SPIDevice.cpp
rename to lib/Adafruit_BusIO/Adafruit_SPIDevice.cpp
diff --git a/lib/Adafruit BusIO/Adafruit_SPIDevice.h b/lib/Adafruit_BusIO/Adafruit_SPIDevice.h
similarity index 100%
rename from lib/Adafruit BusIO/Adafruit_SPIDevice.h
rename to lib/Adafruit_BusIO/Adafruit_SPIDevice.h
diff --git a/lib/Adafruit BusIO/CMakeLists.txt b/lib/Adafruit_BusIO/CMakeLists.txt
similarity index 100%
rename from lib/Adafruit BusIO/CMakeLists.txt
rename to lib/Adafruit_BusIO/CMakeLists.txt
diff --git a/lib/Adafruit BusIO/LICENSE b/lib/Adafruit_BusIO/LICENSE
similarity index 100%
rename from lib/Adafruit BusIO/LICENSE
rename to lib/Adafruit_BusIO/LICENSE
diff --git a/lib/Adafruit BusIO/README.md b/lib/Adafruit_BusIO/README.md
similarity index 100%
rename from lib/Adafruit BusIO/README.md
rename to lib/Adafruit_BusIO/README.md
diff --git a/lib/Adafruit BusIO/component.mk b/lib/Adafruit_BusIO/component.mk
similarity index 100%
rename from lib/Adafruit BusIO/component.mk
rename to lib/Adafruit_BusIO/component.mk
diff --git a/lib/Adafruit BusIO/examples/i2c_address_detect/i2c_address_detect.ino b/lib/Adafruit_BusIO/examples/i2c_address_detect/i2c_address_detect.ino
similarity index 100%
rename from lib/Adafruit BusIO/examples/i2c_address_detect/i2c_address_detect.ino
rename to lib/Adafruit_BusIO/examples/i2c_address_detect/i2c_address_detect.ino
diff --git a/lib/Adafruit BusIO/examples/i2c_readwrite/i2c_readwrite.ino b/lib/Adafruit_BusIO/examples/i2c_readwrite/i2c_readwrite.ino
similarity index 100%
rename from lib/Adafruit BusIO/examples/i2c_readwrite/i2c_readwrite.ino
rename to lib/Adafruit_BusIO/examples/i2c_readwrite/i2c_readwrite.ino
diff --git a/lib/Adafruit BusIO/examples/i2c_registers/i2c_registers.ino b/lib/Adafruit_BusIO/examples/i2c_registers/i2c_registers.ino
similarity index 100%
rename from lib/Adafruit BusIO/examples/i2c_registers/i2c_registers.ino
rename to lib/Adafruit_BusIO/examples/i2c_registers/i2c_registers.ino
diff --git a/lib/Adafruit BusIO/examples/i2corspi_register/i2corspi_register.ino b/lib/Adafruit_BusIO/examples/i2corspi_register/i2corspi_register.ino
similarity index 100%
rename from lib/Adafruit BusIO/examples/i2corspi_register/i2corspi_register.ino
rename to lib/Adafruit_BusIO/examples/i2corspi_register/i2corspi_register.ino
diff --git a/lib/Adafruit BusIO/examples/spi_modetest/spi_modetest.ino b/lib/Adafruit_BusIO/examples/spi_modetest/spi_modetest.ino
similarity index 100%
rename from lib/Adafruit BusIO/examples/spi_modetest/spi_modetest.ino
rename to lib/Adafruit_BusIO/examples/spi_modetest/spi_modetest.ino
diff --git a/lib/Adafruit BusIO/examples/spi_readwrite/spi_readwrite.ino b/lib/Adafruit_BusIO/examples/spi_readwrite/spi_readwrite.ino
similarity index 100%
rename from lib/Adafruit BusIO/examples/spi_readwrite/spi_readwrite.ino
rename to lib/Adafruit_BusIO/examples/spi_readwrite/spi_readwrite.ino
diff --git a/lib/Adafruit BusIO/examples/spi_register_bits/spi_register_bits.ino b/lib/Adafruit_BusIO/examples/spi_register_bits/spi_register_bits.ino
similarity index 100%
rename from lib/Adafruit BusIO/examples/spi_register_bits/spi_register_bits.ino
rename to lib/Adafruit_BusIO/examples/spi_register_bits/spi_register_bits.ino
diff --git a/lib/Adafruit BusIO/examples/spi_registers/spi_registers.ino b/lib/Adafruit_BusIO/examples/spi_registers/spi_registers.ino
similarity index 100%
rename from lib/Adafruit BusIO/examples/spi_registers/spi_registers.ino
rename to lib/Adafruit_BusIO/examples/spi_registers/spi_registers.ino
diff --git a/lib/Adafruit BusIO/library.properties b/lib/Adafruit_BusIO/library.properties
similarity index 100%
rename from lib/Adafruit BusIO/library.properties
rename to lib/Adafruit_BusIO/library.properties
diff --git a/lib/Adafruit GFX Library/.github/ISSUE_TEMPLATE.md b/lib/Adafruit_GFX_Library/.github/ISSUE_TEMPLATE.md
similarity index 100%
rename from lib/Adafruit GFX Library/.github/ISSUE_TEMPLATE.md
rename to lib/Adafruit_GFX_Library/.github/ISSUE_TEMPLATE.md
diff --git a/lib/Adafruit GFX Library/.github/PULL_REQUEST_TEMPLATE.md b/lib/Adafruit_GFX_Library/.github/PULL_REQUEST_TEMPLATE.md
similarity index 100%
rename from lib/Adafruit GFX Library/.github/PULL_REQUEST_TEMPLATE.md
rename to lib/Adafruit_GFX_Library/.github/PULL_REQUEST_TEMPLATE.md
diff --git a/lib/Adafruit GFX Library/.github/workflows/githubci.yml b/lib/Adafruit_GFX_Library/.github/workflows/githubci.yml
similarity index 100%
rename from lib/Adafruit GFX Library/.github/workflows/githubci.yml
rename to lib/Adafruit_GFX_Library/.github/workflows/githubci.yml
diff --git a/lib/Adafruit GFX Library/.gitignore b/lib/Adafruit_GFX_Library/.gitignore
similarity index 100%
rename from lib/Adafruit GFX Library/.gitignore
rename to lib/Adafruit_GFX_Library/.gitignore
diff --git a/lib/Adafruit GFX Library/Adafruit_GFX.cpp b/lib/Adafruit_GFX_Library/Adafruit_GFX.cpp
similarity index 100%
rename from lib/Adafruit GFX Library/Adafruit_GFX.cpp
rename to lib/Adafruit_GFX_Library/Adafruit_GFX.cpp
diff --git a/lib/Adafruit GFX Library/Adafruit_GFX.h b/lib/Adafruit_GFX_Library/Adafruit_GFX.h
similarity index 100%
rename from lib/Adafruit GFX Library/Adafruit_GFX.h
rename to lib/Adafruit_GFX_Library/Adafruit_GFX.h
diff --git a/lib/Adafruit GFX Library/Adafruit_GrayOLED.cpp b/lib/Adafruit_GFX_Library/Adafruit_GrayOLED.cpp
similarity index 100%
rename from lib/Adafruit GFX Library/Adafruit_GrayOLED.cpp
rename to lib/Adafruit_GFX_Library/Adafruit_GrayOLED.cpp
diff --git a/lib/Adafruit GFX Library/Adafruit_GrayOLED.h b/lib/Adafruit_GFX_Library/Adafruit_GrayOLED.h
similarity index 100%
rename from lib/Adafruit GFX Library/Adafruit_GrayOLED.h
rename to lib/Adafruit_GFX_Library/Adafruit_GrayOLED.h
diff --git a/lib/Adafruit GFX Library/Adafruit_SPITFT.cpp b/lib/Adafruit_GFX_Library/Adafruit_SPITFT.cpp
similarity index 100%
rename from lib/Adafruit GFX Library/Adafruit_SPITFT.cpp
rename to lib/Adafruit_GFX_Library/Adafruit_SPITFT.cpp
diff --git a/lib/Adafruit GFX Library/Adafruit_SPITFT.h b/lib/Adafruit_GFX_Library/Adafruit_SPITFT.h
similarity index 100%
rename from lib/Adafruit GFX Library/Adafruit_SPITFT.h
rename to lib/Adafruit_GFX_Library/Adafruit_SPITFT.h
diff --git a/lib/Adafruit GFX Library/Adafruit_SPITFT_Macros.h b/lib/Adafruit_GFX_Library/Adafruit_SPITFT_Macros.h
similarity index 100%
rename from lib/Adafruit GFX Library/Adafruit_SPITFT_Macros.h
rename to lib/Adafruit_GFX_Library/Adafruit_SPITFT_Macros.h
diff --git a/lib/Adafruit GFX Library/CMakeLists.txt b/lib/Adafruit_GFX_Library/CMakeLists.txt
similarity index 100%
rename from lib/Adafruit GFX Library/CMakeLists.txt
rename to lib/Adafruit_GFX_Library/CMakeLists.txt
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMono12pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMono12pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMono12pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMono12pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMono18pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMono18pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMono18pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMono18pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMono24pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMono24pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMono24pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMono24pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMono9pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMono9pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMono9pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMono9pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMonoBold12pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMonoBold12pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMonoBold12pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMonoBold12pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMonoBold18pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMonoBold18pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMonoBold18pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMonoBold18pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMonoBold24pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMonoBold24pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMonoBold24pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMonoBold24pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMonoBold9pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMonoBold9pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMonoBold9pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMonoBold9pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMonoBoldOblique12pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMonoBoldOblique12pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMonoBoldOblique12pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMonoBoldOblique12pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMonoBoldOblique18pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMonoBoldOblique18pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMonoBoldOblique18pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMonoBoldOblique18pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMonoBoldOblique24pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMonoBoldOblique24pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMonoBoldOblique24pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMonoBoldOblique24pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMonoBoldOblique9pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMonoBoldOblique9pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMonoBoldOblique9pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMonoBoldOblique9pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMonoOblique12pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMonoOblique12pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMonoOblique12pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMonoOblique12pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMonoOblique18pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMonoOblique18pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMonoOblique18pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMonoOblique18pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMonoOblique24pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMonoOblique24pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMonoOblique24pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMonoOblique24pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeMonoOblique9pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeMonoOblique9pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeMonoOblique9pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeMonoOblique9pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSans12pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSans12pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSans12pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSans12pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSans18pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSans18pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSans18pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSans18pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSans24pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSans24pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSans24pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSans24pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSans9pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSans9pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSans9pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSans9pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSansBold12pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSansBold12pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSansBold12pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSansBold12pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSansBold18pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSansBold18pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSansBold18pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSansBold18pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSansBold24pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSansBold24pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSansBold24pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSansBold24pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSansBold9pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSansBold9pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSansBold9pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSansBold9pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSansBoldOblique12pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSansBoldOblique12pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSansBoldOblique12pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSansBoldOblique12pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSansBoldOblique18pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSansBoldOblique18pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSansBoldOblique18pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSansBoldOblique18pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSansBoldOblique24pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSansBoldOblique24pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSansBoldOblique24pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSansBoldOblique24pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSansBoldOblique9pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSansBoldOblique9pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSansBoldOblique9pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSansBoldOblique9pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSansOblique12pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSansOblique12pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSansOblique12pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSansOblique12pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSansOblique18pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSansOblique18pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSansOblique18pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSansOblique18pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSansOblique24pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSansOblique24pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSansOblique24pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSansOblique24pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSansOblique9pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSansOblique9pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSansOblique9pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSansOblique9pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerif12pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerif12pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerif12pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerif12pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerif18pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerif18pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerif18pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerif18pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerif24pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerif24pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerif24pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerif24pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerif9pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerif9pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerif9pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerif9pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerifBold12pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerifBold12pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerifBold12pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerifBold12pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerifBold18pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerifBold18pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerifBold18pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerifBold18pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerifBold24pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerifBold24pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerifBold24pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerifBold24pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerifBold9pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerifBold9pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerifBold9pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerifBold9pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerifBoldItalic12pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerifBoldItalic12pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerifBoldItalic12pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerifBoldItalic12pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerifBoldItalic18pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerifBoldItalic18pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerifBoldItalic18pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerifBoldItalic18pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerifBoldItalic24pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerifBoldItalic24pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerifBoldItalic24pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerifBoldItalic24pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerifBoldItalic9pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerifBoldItalic9pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerifBoldItalic9pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerifBoldItalic9pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerifItalic12pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerifItalic12pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerifItalic12pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerifItalic12pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerifItalic18pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerifItalic18pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerifItalic18pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerifItalic18pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerifItalic24pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerifItalic24pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerifItalic24pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerifItalic24pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/FreeSerifItalic9pt7b.h b/lib/Adafruit_GFX_Library/Fonts/FreeSerifItalic9pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/FreeSerifItalic9pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/FreeSerifItalic9pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/Org_01.h b/lib/Adafruit_GFX_Library/Fonts/Org_01.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/Org_01.h
rename to lib/Adafruit_GFX_Library/Fonts/Org_01.h
diff --git a/lib/Adafruit GFX Library/Fonts/Picopixel.h b/lib/Adafruit_GFX_Library/Fonts/Picopixel.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/Picopixel.h
rename to lib/Adafruit_GFX_Library/Fonts/Picopixel.h
diff --git a/lib/Adafruit GFX Library/Fonts/Tiny3x3a2pt7b.h b/lib/Adafruit_GFX_Library/Fonts/Tiny3x3a2pt7b.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/Tiny3x3a2pt7b.h
rename to lib/Adafruit_GFX_Library/Fonts/Tiny3x3a2pt7b.h
diff --git a/lib/Adafruit GFX Library/Fonts/TomThumb.h b/lib/Adafruit_GFX_Library/Fonts/TomThumb.h
similarity index 100%
rename from lib/Adafruit GFX Library/Fonts/TomThumb.h
rename to lib/Adafruit_GFX_Library/Fonts/TomThumb.h
diff --git a/lib/Adafruit GFX Library/README.md b/lib/Adafruit_GFX_Library/README.md
similarity index 100%
rename from lib/Adafruit GFX Library/README.md
rename to lib/Adafruit_GFX_Library/README.md
diff --git a/lib/Adafruit GFX Library/component.mk b/lib/Adafruit_GFX_Library/component.mk
similarity index 100%
rename from lib/Adafruit GFX Library/component.mk
rename to lib/Adafruit_GFX_Library/component.mk
diff --git a/lib/Adafruit GFX Library/examples/GFXcanvas/GFXcanvas.ino b/lib/Adafruit_GFX_Library/examples/GFXcanvas/GFXcanvas.ino
similarity index 100%
rename from lib/Adafruit GFX Library/examples/GFXcanvas/GFXcanvas.ino
rename to lib/Adafruit_GFX_Library/examples/GFXcanvas/GFXcanvas.ino
diff --git a/lib/Adafruit GFX Library/examples/GFXcanvas/GFXcanvasSerialDemo.cpp b/lib/Adafruit_GFX_Library/examples/GFXcanvas/GFXcanvasSerialDemo.cpp
similarity index 100%
rename from lib/Adafruit GFX Library/examples/GFXcanvas/GFXcanvasSerialDemo.cpp
rename to lib/Adafruit_GFX_Library/examples/GFXcanvas/GFXcanvasSerialDemo.cpp
diff --git a/lib/Adafruit GFX Library/examples/GFXcanvas/GFXcanvasSerialDemo.h b/lib/Adafruit_GFX_Library/examples/GFXcanvas/GFXcanvasSerialDemo.h
similarity index 100%
rename from lib/Adafruit GFX Library/examples/GFXcanvas/GFXcanvasSerialDemo.h
rename to lib/Adafruit_GFX_Library/examples/GFXcanvas/GFXcanvasSerialDemo.h
diff --git a/lib/Adafruit GFX Library/examples/mock_ili9341/mock_ili9341.ino b/lib/Adafruit_GFX_Library/examples/mock_ili9341/mock_ili9341.ino
similarity index 100%
rename from lib/Adafruit GFX Library/examples/mock_ili9341/mock_ili9341.ino
rename to lib/Adafruit_GFX_Library/examples/mock_ili9341/mock_ili9341.ino
diff --git a/lib/Adafruit GFX Library/fontconvert/Makefile b/lib/Adafruit_GFX_Library/fontconvert/Makefile
similarity index 100%
rename from lib/Adafruit GFX Library/fontconvert/Makefile
rename to lib/Adafruit_GFX_Library/fontconvert/Makefile
diff --git a/lib/Adafruit GFX Library/fontconvert/bdf2adafruit.py b/lib/Adafruit_GFX_Library/fontconvert/bdf2adafruit.py
similarity index 100%
rename from lib/Adafruit GFX Library/fontconvert/bdf2adafruit.py
rename to lib/Adafruit_GFX_Library/fontconvert/bdf2adafruit.py
diff --git a/lib/Adafruit GFX Library/fontconvert/fontconvert.c b/lib/Adafruit_GFX_Library/fontconvert/fontconvert.c
similarity index 100%
rename from lib/Adafruit GFX Library/fontconvert/fontconvert.c
rename to lib/Adafruit_GFX_Library/fontconvert/fontconvert.c
diff --git a/lib/Adafruit GFX Library/fontconvert/fontconvert_win.md b/lib/Adafruit_GFX_Library/fontconvert/fontconvert_win.md
similarity index 100%
rename from lib/Adafruit GFX Library/fontconvert/fontconvert_win.md
rename to lib/Adafruit_GFX_Library/fontconvert/fontconvert_win.md
diff --git a/lib/Adafruit GFX Library/fontconvert/makefonts.sh b/lib/Adafruit_GFX_Library/fontconvert/makefonts.sh
similarity index 100%
rename from lib/Adafruit GFX Library/fontconvert/makefonts.sh
rename to lib/Adafruit_GFX_Library/fontconvert/makefonts.sh
diff --git a/lib/Adafruit GFX Library/gfxfont.h b/lib/Adafruit_GFX_Library/gfxfont.h
similarity index 100%
rename from lib/Adafruit GFX Library/gfxfont.h
rename to lib/Adafruit_GFX_Library/gfxfont.h
diff --git a/lib/Adafruit GFX Library/glcdfont.c b/lib/Adafruit_GFX_Library/glcdfont.c
similarity index 100%
rename from lib/Adafruit GFX Library/glcdfont.c
rename to lib/Adafruit_GFX_Library/glcdfont.c
diff --git a/lib/Adafruit GFX Library/library.properties b/lib/Adafruit_GFX_Library/library.properties
similarity index 100%
rename from lib/Adafruit GFX Library/library.properties
rename to lib/Adafruit_GFX_Library/library.properties
diff --git a/lib/Adafruit GFX Library/license.txt b/lib/Adafruit_GFX_Library/license.txt
similarity index 100%
rename from lib/Adafruit GFX Library/license.txt
rename to lib/Adafruit_GFX_Library/license.txt
diff --git a/lib/Adafruit NeoMatrix/.github/ISSUE_TEMPLATE.md b/lib/Adafruit_NeoMatrix/.github/ISSUE_TEMPLATE.md
similarity index 100%
rename from lib/Adafruit NeoMatrix/.github/ISSUE_TEMPLATE.md
rename to lib/Adafruit_NeoMatrix/.github/ISSUE_TEMPLATE.md
diff --git a/lib/Adafruit NeoMatrix/.github/PULL_REQUEST_TEMPLATE.md b/lib/Adafruit_NeoMatrix/.github/PULL_REQUEST_TEMPLATE.md
similarity index 100%
rename from lib/Adafruit NeoMatrix/.github/PULL_REQUEST_TEMPLATE.md
rename to lib/Adafruit_NeoMatrix/.github/PULL_REQUEST_TEMPLATE.md
diff --git a/lib/Adafruit NeoMatrix/.github/workflows/githubci.yml b/lib/Adafruit_NeoMatrix/.github/workflows/githubci.yml
similarity index 100%
rename from lib/Adafruit NeoMatrix/.github/workflows/githubci.yml
rename to lib/Adafruit_NeoMatrix/.github/workflows/githubci.yml
diff --git a/lib/Adafruit NeoMatrix/.gitignore b/lib/Adafruit_NeoMatrix/.gitignore
similarity index 100%
rename from lib/Adafruit NeoMatrix/.gitignore
rename to lib/Adafruit_NeoMatrix/.gitignore
diff --git a/lib/Adafruit NeoMatrix/Adafruit_NeoMatrix.cpp b/lib/Adafruit_NeoMatrix/Adafruit_NeoMatrix.cpp
similarity index 100%
rename from lib/Adafruit NeoMatrix/Adafruit_NeoMatrix.cpp
rename to lib/Adafruit_NeoMatrix/Adafruit_NeoMatrix.cpp
diff --git a/lib/Adafruit NeoMatrix/Adafruit_NeoMatrix.h b/lib/Adafruit_NeoMatrix/Adafruit_NeoMatrix.h
similarity index 100%
rename from lib/Adafruit NeoMatrix/Adafruit_NeoMatrix.h
rename to lib/Adafruit_NeoMatrix/Adafruit_NeoMatrix.h
diff --git a/lib/Adafruit NeoMatrix/COPYING b/lib/Adafruit_NeoMatrix/COPYING
similarity index 100%
rename from lib/Adafruit NeoMatrix/COPYING
rename to lib/Adafruit_NeoMatrix/COPYING
diff --git a/lib/Adafruit NeoMatrix/README.md b/lib/Adafruit_NeoMatrix/README.md
similarity index 100%
rename from lib/Adafruit NeoMatrix/README.md
rename to lib/Adafruit_NeoMatrix/README.md
diff --git a/lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/.esp8266.test.skip b/lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/.esp8266.test.skip
similarity index 100%
rename from lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/.esp8266.test.skip
rename to lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/.esp8266.test.skip
diff --git a/lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/MatrixGFXDemo.ino b/lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/MatrixGFXDemo.ino
similarity index 100%
rename from lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/MatrixGFXDemo.ino
rename to lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/MatrixGFXDemo.ino
diff --git a/lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/bluesmiley24.h b/lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/bluesmiley24.h
similarity index 100%
rename from lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/bluesmiley24.h
rename to lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/bluesmiley24.h
diff --git a/lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/google32.h b/lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/google32.h
similarity index 100%
rename from lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/google32.h
rename to lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/google32.h
diff --git a/lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/heart24.h b/lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/heart24.h
similarity index 100%
rename from lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/heart24.h
rename to lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/heart24.h
diff --git a/lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/linux32.h b/lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/linux32.h
similarity index 100%
rename from lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/linux32.h
rename to lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/linux32.h
diff --git a/lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/smileytongue24.h b/lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/smileytongue24.h
similarity index 100%
rename from lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/smileytongue24.h
rename to lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/smileytongue24.h
diff --git a/lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/yellowsmiley24.h b/lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/yellowsmiley24.h
similarity index 100%
rename from lib/Adafruit NeoMatrix/examples/MatrixGFXDemo/yellowsmiley24.h
rename to lib/Adafruit_NeoMatrix/examples/MatrixGFXDemo/yellowsmiley24.h
diff --git a/lib/Adafruit NeoMatrix/examples/matrixtest/.esp8266.test.skip b/lib/Adafruit_NeoMatrix/examples/matrixtest/.esp8266.test.skip
similarity index 100%
rename from lib/Adafruit NeoMatrix/examples/matrixtest/.esp8266.test.skip
rename to lib/Adafruit_NeoMatrix/examples/matrixtest/.esp8266.test.skip
diff --git a/lib/Adafruit NeoMatrix/examples/matrixtest/matrixtest.ino b/lib/Adafruit_NeoMatrix/examples/matrixtest/matrixtest.ino
similarity index 100%
rename from lib/Adafruit NeoMatrix/examples/matrixtest/matrixtest.ino
rename to lib/Adafruit_NeoMatrix/examples/matrixtest/matrixtest.ino
diff --git a/lib/Adafruit NeoMatrix/examples/tiletest/.esp8266.test.skip b/lib/Adafruit_NeoMatrix/examples/tiletest/.esp8266.test.skip
similarity index 100%
rename from lib/Adafruit NeoMatrix/examples/tiletest/.esp8266.test.skip
rename to lib/Adafruit_NeoMatrix/examples/tiletest/.esp8266.test.skip
diff --git a/lib/Adafruit NeoMatrix/examples/tiletest/tiletest.ino b/lib/Adafruit_NeoMatrix/examples/tiletest/tiletest.ino
similarity index 100%
rename from lib/Adafruit NeoMatrix/examples/tiletest/tiletest.ino
rename to lib/Adafruit_NeoMatrix/examples/tiletest/tiletest.ino
diff --git a/lib/Adafruit NeoMatrix/gamma.h b/lib/Adafruit_NeoMatrix/gamma.h
similarity index 100%
rename from lib/Adafruit NeoMatrix/gamma.h
rename to lib/Adafruit_NeoMatrix/gamma.h
diff --git a/lib/Adafruit NeoMatrix/library.properties b/lib/Adafruit_NeoMatrix/library.properties
similarity index 100%
rename from lib/Adafruit NeoMatrix/library.properties
rename to lib/Adafruit_NeoMatrix/library.properties
diff --git a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/.gitattributes b/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/.gitattributes
deleted file mode 100644
index dfe077042..000000000
--- a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/.gitattributes
+++ /dev/null
@@ -1,2 +0,0 @@
-# Auto detect text files and perform LF normalization
-* text=auto
diff --git a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/LICENSE b/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/LICENSE
deleted file mode 100644
index b08933d57..000000000
--- a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2020 SparkFun Electronics
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/README.md b/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/README.md
deleted file mode 100644
index 15fb48dfe..000000000
--- a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/README.md
+++ /dev/null
@@ -1,38 +0,0 @@
-# SparkFun MAX1704x Fuel Gauge Arduino Library
-
-The MAX17043/MAX17044 are ultra-compact, low-cost,
-host-side fuel-gauge systems for lithium-ion (Li+) batteries
-in handheld and portable equipment. The MAX17043
-is configured to operate with a single lithium cell and the
-MAX17044 is configured for a dual-cell 2S pack.
-
-The MAX17048/MAX17049 ICs are tiny, micropower current
-fuel gauges for lithium-ion (Li+) batteries in handheld
-and portable equipment. The MAX17048 operates with
-a single lithium cell and the MAX17049 with two lithium
-cells in series.
-
-This Arduino library provides support for all four devices.
-
-## Thanks
-
-Parts of this library were inspired by [Daniel Porrey's max1704x library](https://github.com/porrey/max1704x). Thank you Daniel.
-
-## Repository Contents
-
-- **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE.
-- **/src** - Source files for the library (.cpp, .h).
-- **keywords.txt** - Keywords from this library that will be highlighted in the Arduino IDE.
-- **library.properties** - General library properties for the Arduino package manager.
-
-## Products That Use This Library
-
-- [SparkFun LiPo Fuel Gauge (TOL-10617)](https://www.sparkfun.com/products/10617)
-
-## Documentation
-
-- **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library.
-
-## License Information
-
-Please see [LICENSE.md](./LICENSE.md) for the license information.
diff --git a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/examples/Example1_Simple/Example1_Simple.ino b/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/examples/Example1_Simple/Example1_Simple.ino
deleted file mode 100644
index 893479fdd..000000000
--- a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/examples/Example1_Simple/Example1_Simple.ino
+++ /dev/null
@@ -1,88 +0,0 @@
-/******************************************************************************
-Example1_Simple
-By: Paul Clark
-Date: October 23rd 2020
-
-Based extensively on:
-MAX17043_Simple_Serial.cpp
-SparkFun MAX17043 Example Code
-Jim Lindblom @ SparkFun Electronics
-Original Creation Date: June 22, 2015
-
-This file demonstrates the simple API of the SparkFun MAX17043 Arduino library.
-
-This example will print the gauge's voltage and state-of-charge (SOC) readings
-to Serial (115200 baud)
-
-This code is released under the MIT license.
-
-Distributed as-is; no warranty is given.
-******************************************************************************/
-
-#include // Needed for I2C
-
-#include // Click here to get the library: http://librarymanager/All#SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library
-
-SFE_MAX1704X lipo; // Defaults to the MAX17043
-
-//SFE_MAX1704X lipo(MAX1704X_MAX17043); // Create a MAX17043
-//SFE_MAX1704X lipo(MAX1704X_MAX17044); // Create a MAX17044
-//SFE_MAX1704X lipo(MAX1704X_MAX17048); // Create a MAX17048
-//SFE_MAX1704X lipo(MAX1704X_MAX17049); // Create a MAX17049
-
-double voltage = 0; // Variable to keep track of LiPo voltage
-double soc = 0; // Variable to keep track of LiPo state-of-charge (SOC)
-bool alert; // Variable to keep track of whether alert has been triggered
-
-void setup()
-{
- Serial.begin(115200); // Start serial, to output debug data
- while (!Serial)
- ; //Wait for user to open terminal
- Serial.println(F("MAX17043 Example"));
-
- Wire.begin();
-
- lipo.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
-
- // Set up the MAX17043 LiPo fuel gauge:
- if (lipo.begin() == false) // Connect to the MAX17043 using the default wire port
- {
- Serial.println(F("MAX17043 not detected. Please check wiring. Freezing."));
- while (1)
- ;
- }
-
- // Quick start restarts the MAX17043 in hopes of getting a more accurate
- // guess for the SOC.
- lipo.quickStart();
-
- // We can set an interrupt to alert when the battery SoC gets too low.
- // We can alert at anywhere between 1% - 32%:
- lipo.setThreshold(20); // Set alert threshold to 20%.
-}
-
-void loop()
-{
- // lipo.getVoltage() returns a voltage value (e.g. 3.93)
- voltage = lipo.getVoltage();
- // lipo.getSOC() returns the estimated state of charge (e.g. 79%)
- soc = lipo.getSOC();
- // lipo.getAlert() returns a 0 or 1 (0=alert not triggered)
- alert = lipo.getAlert();
-
- // Print the variables:
- Serial.print("Voltage: ");
- Serial.print(voltage); // Print the battery voltage
- Serial.println(" V");
-
- Serial.print("Percentage: ");
- Serial.print(soc); // Print the battery state of charge
- Serial.println(" %");
-
- Serial.print("Alert: ");
- Serial.println(alert);
- Serial.println();
-
- delay(500);
-}
diff --git a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/examples/Example2_AlternatePorts/Example2_AlternatePorts.ino b/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/examples/Example2_AlternatePorts/Example2_AlternatePorts.ino
deleted file mode 100644
index 7fd651aad..000000000
--- a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/examples/Example2_AlternatePorts/Example2_AlternatePorts.ino
+++ /dev/null
@@ -1,92 +0,0 @@
-/******************************************************************************
-Example2_AlternatePorts
-By: Paul Clark
-Date: October 23rd 2020
-
-Based extensively on:
-MAX17043_Simple_Serial.cpp
-SparkFun MAX17043 Example Code
-Jim Lindblom @ SparkFun Electronics
-Original Creation Date: June 22, 2015
-
-This file demonstrates the simple API of the SparkFun MAX17043 Arduino library using non-standard Wire and Serial ports.
-
-This example will print the gauge's voltage and state-of-charge (SOC) readings
-to serial (115200 baud)
-
-This code is released under the MIT license.
-
-Distributed as-is; no warranty is given.
-******************************************************************************/
-
-#include // Needed for I2C
-
-#include // Click here to get the library: http://librarymanager/All#SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library
-
-SFE_MAX1704X lipo; // Defaults to the MAX17043
-
-//SFE_MAX1704X lipo(MAX1704X_MAX17043); // Create a MAX17043
-//SFE_MAX1704X lipo(MAX1704X_MAX17044); // Create a MAX17044
-//SFE_MAX1704X lipo(MAX1704X_MAX17048); // Create a MAX17048
-//SFE_MAX1704X lipo(MAX1704X_MAX17049); // Create a MAX17049
-
-// Define our non-standard ports:
-#define mySerial Serial1
-TwoWire myWire(0);
-
-double voltage = 0; // Variable to keep track of LiPo voltage
-double soc = 0; // Variable to keep track of LiPo state-of-charge (SOC)
-bool alert; // Variable to keep track of whether alert has been triggered
-
-void setup()
-{
- mySerial.begin(115200); // Start serial, to output debug data
- while (!mySerial)
- ; //Wait for user to open terminal
- mySerial.println(F("MAX17043 Example"));
-
- myWire.begin();
-
- lipo.enableDebugging(mySerial); // Uncomment this line to enable helpful debug messages on non-standard serial
-
- // Set up the MAX17043 LiPo fuel gauge:
- if (lipo.begin(myWire) == false) // Connect to the MAX17043 using non-standard wire port
- {
- mySerial.println(F("MAX17043 not detected. Please check wiring. Freezing."));
- while (1)
- ;
- }
-
- // Quick start restarts the MAX17043 in hopes of getting a more accurate
- // guess for the SOC.
- lipo.quickStart();
-
- // We can set an interrupt to alert when the battery SoC gets too low.
- // We can alert at anywhere between 1% - 32%:
- lipo.setThreshold(20); // Set alert threshold to 20%.
-}
-
-void loop()
-{
- // lipo.getVoltage() returns a voltage value (e.g. 3.93)
- voltage = lipo.getVoltage();
- // lipo.getSOC() returns the estimated state of charge (e.g. 79%)
- soc = lipo.getSOC();
- // lipo.getAlert() returns a 0 or 1 (0=alert not triggered)
- alert = lipo.getAlert();
-
- // Print the variables:
- mySerial.print("Voltage: ");
- mySerial.print(voltage); // Print the battery voltage
- mySerial.println(" V");
-
- mySerial.print("Percentage: ");
- mySerial.print(soc); // Print the battery state of charge
- mySerial.println(" %");
-
- mySerial.print("Alert: ");
- mySerial.println(alert);
- mySerial.println();
-
- delay(500);
-}
diff --git a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/examples/Example3_MAX17044/Example3_MAX17044.ino b/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/examples/Example3_MAX17044/Example3_MAX17044.ino
deleted file mode 100644
index 439f8566a..000000000
--- a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/examples/Example3_MAX17044/Example3_MAX17044.ino
+++ /dev/null
@@ -1,87 +0,0 @@
-/******************************************************************************
-Example3_MAX17044
-By: Paul Clark
-Date: October 23rd 2020
-
-Based extensively on:
-MAX17043_Simple_Serial.cpp
-SparkFun MAX17043 Example Code
-Jim Lindblom @ SparkFun Electronics
-Original Creation Date: June 22, 2015
-
-This file demonstrates how to talk to the MAX17044 using the SparkFun MAX17043 Arduino library.
-
-This example will print the gauge's voltage and state-of-charge (SOC) readings
-to Serial (115200 baud)
-
-This code is released under the MIT license.
-
-Distributed as-is; no warranty is given.
-******************************************************************************/
-
-#include // Needed for I2C
-
-#include // Click here to get the library: http://librarymanager/All#SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library
-
-SFE_MAX1704X lipo(MAX1704X_MAX17044); // Create a MAX17044
-
-//SFE_MAX1704X lipo(MAX1704X_MAX17043); // Create a MAX17043
-//SFE_MAX1704X lipo(MAX1704X_MAX17048); // Create a MAX17048
-//SFE_MAX1704X lipo(MAX1704X_MAX17049); // Create a MAX17049
-
-double voltage = 0; // Variable to keep track of LiPo voltage
-double soc = 0; // Variable to keep track of LiPo state-of-charge (SOC)
-bool alert; // Variable to keep track of whether alert has been triggered
-
-void setup()
-{
- Serial.begin(115200); // Start serial, to output debug data
- while (!Serial)
- ; //Wait for user to open terminal
- Serial.println(F("MAX17044 Example"));
-
- Wire.begin();
-
- lipo.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
-
- // Set up the MAX17044 LiPo fuel gauge:
- if (lipo.begin() == false) // Connect to the MAX17044 using the default wire port
- {
- Serial.println(F("MAX17044 not detected. Please check wiring. Freezing."));
- while (1)
- ;
- }
-
- // Quick start restarts the MAX17044 in hopes of getting a more accurate
- // guess for the SOC.
- lipo.quickStart();
-
- // We can set an interrupt to alert when the battery SoC gets too low.
- // We can alert at anywhere between 1% - 32%:
- lipo.setThreshold(20); // Set alert threshold to 20%.
-}
-
-void loop()
-{
- // lipo.getVoltage() returns a voltage value (e.g. 7.86)
- voltage = lipo.getVoltage();
- // lipo.getSOC() returns the estimated state of charge (e.g. 79%)
- soc = lipo.getSOC();
- // lipo.getAlert() returns a 0 or 1 (0=alert not triggered)
- alert = lipo.getAlert();
-
- // Print the variables:
- Serial.print("Voltage: ");
- Serial.print(voltage); // Print the battery voltage
- Serial.println(" V");
-
- Serial.print("Percentage: ");
- Serial.print(soc); // Print the battery state of charge
- Serial.println(" %");
-
- Serial.print("Alert: ");
- Serial.println(alert);
- Serial.println();
-
- delay(500);
-}
diff --git a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/examples/Example4_MAX17048_KitchenSink/Example4_MAX17048_KitchenSink.ino b/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/examples/Example4_MAX17048_KitchenSink/Example4_MAX17048_KitchenSink.ino
deleted file mode 100644
index d04f057ec..000000000
--- a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/examples/Example4_MAX17048_KitchenSink/Example4_MAX17048_KitchenSink.ino
+++ /dev/null
@@ -1,181 +0,0 @@
-/******************************************************************************
-Example4: test all the things on the MAX17048
-By: Paul Clark, SparkFun Electronics
-Date: October 23rd 2020
-
-This example is an everything-but-the-kitchen-sink test of the MAX17048.
-
-This code is released under the MIT license.
-
-Distributed as-is; no warranty is given.
-******************************************************************************/
-
-#include // Needed for I2C
-
-#include // Click here to get the library: http://librarymanager/All#SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library
-
-SFE_MAX1704X lipo(MAX1704X_MAX17048); // Create a MAX17048
-
-void setup()
-{
- Serial.begin(115200); // Start serial, to output debug data
- while (!Serial)
- ; //Wait for user to open terminal
- Serial.println(F("MAX17048 Example"));
-
- Wire.begin();
-
- lipo.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
-
- // Set up the MAX17048 LiPo fuel gauge:
- if (lipo.begin() == false) // Connect to the MAX17048 using the default wire port
- {
- Serial.println(F("MAX17048 not detected. Please check wiring. Freezing."));
- while (1)
- ;
- }
-
- // Just because we can, let's reset the MAX17048
- Serial.println(F("Resetting the MAX17048..."));
- delay(1000); // Give it time to get its act back together
-
- // Read and print the reset indicator
- Serial.print(F("Reset Indicator was: "));
- bool RI = lipo.isReset(true); // Read the RI flag and clear it automatically if it is set
- Serial.println(RI); // Print the RI
- // If RI was set, check it is now clear
- if (RI)
- {
- Serial.print(F("Reset Indicator is now: "));
- RI = lipo.isReset(); // Read the RI flag
- Serial.println(RI); // Print the RI
- }
-
- // To quick-start or not to quick-start? That is the question!
- // Read the following and then decide if you do want to quick-start the fuel gauge.
- // "Most systems should not use quick-start because the ICs handle most startup problems transparently,
- // such as intermittent battery-terminal connection during insertion. If battery voltage stabilizes
- // faster than 17ms then do not use quick-start. The quick-start command restarts fuel-gauge calculations
- // in the same manner as initial power-up of the IC. If the system power-up sequence is so noisy that the
- // initial estimate of SOC has unacceptable error, the system microcontroller might be able to reduce the
- // error by using quick-start."
- // If you still want to try a quick-start then uncomment the next line:
- //lipo.quickStart();
-
- // Read and print the device ID
- Serial.print(F("Device ID: 0x"));
- uint8_t id = lipo.getID(); // Read the device ID
- if (id < 0x10) Serial.print(F("0")); // Print the leading zero if required
- Serial.println(id, HEX); // Print the ID as hexadecimal
-
- // Read and print the device version
- Serial.print(F("Device version: 0x"));
- uint8_t ver = lipo.getVersion(); // Read the device version
- if (ver < 0x10) Serial.print(F("0")); // Print the leading zero if required
- Serial.println(ver, HEX); // Print the version as hexadecimal
-
- // Read and print the battery threshold
- Serial.print(F("Battery empty threshold is currently: "));
- Serial.print(lipo.getThreshold());
- Serial.println(F("%"));
-
- // We can set an interrupt to alert when the battery SoC gets too low.
- // We can alert at anywhere between 1% and 32%:
- lipo.setThreshold(20); // Set alert threshold to 20%.
-
- // Read and print the battery empty threshold
- Serial.print(F("Battery empty threshold is now: "));
- Serial.print(lipo.getThreshold());
- Serial.println(F("%"));
-
- // Read and print the high voltage threshold
- Serial.print(F("High voltage threshold is currently: "));
- float highVoltage = ((float)lipo.getVALRTMax()) * 0.02; // 1 LSb is 20mV. Convert to Volts.
- Serial.print(highVoltage, 2);
- Serial.println(F("V"));
-
- // Set the high voltage threshold
- lipo.setVALRTMax((float)4.1); // Set high voltage threshold (Volts)
-
- // Read and print the high voltage threshold
- Serial.print(F("High voltage threshold is now: "));
- highVoltage = ((float)lipo.getVALRTMax()) * 0.02; // 1 LSb is 20mV. Convert to Volts.
- Serial.print(highVoltage, 2);
- Serial.println(F("V"));
-
- // Read and print the low voltage threshold
- Serial.print(F("Low voltage threshold is currently: "));
- float lowVoltage = ((float)lipo.getVALRTMin()) * 0.02; // 1 LSb is 20mV. Convert to Volts.
- Serial.print(lowVoltage, 2);
- Serial.println(F("V"));
-
- // Set the low voltage threshold
- lipo.setVALRTMin((float)3.9); // Set low voltage threshold (Volts)
-
- // Read and print the low voltage threshold
- Serial.print(F("Low voltage threshold is now: "));
- lowVoltage = ((float)lipo.getVALRTMin()) * 0.02; // 1 LSb is 20mV. Convert to Volts.
- Serial.print(lowVoltage, 2);
- Serial.println(F("V"));
-
- // Enable the State Of Change alert
- Serial.print(F("Enabling the 1% State Of Change alert: "));
- if (lipo.enableSOCAlert())
- {
- Serial.println(F("success."));
- }
- else
- {
- Serial.println(F("FAILED!"));
- }
-
- // Read and print the HIBRT Active Threshold
- Serial.print(F("Hibernate active threshold is: "));
- float actThr = ((float)lipo.getHIBRTActThr()) * 0.00125; // 1 LSb is 1.25mV. Convert to Volts.
- Serial.print(actThr, 5);
- Serial.println(F("V"));
-
- // Read and print the HIBRT Hibernate Threshold
- Serial.print(F("Hibernate hibernate threshold is: "));
- float hibThr = ((float)lipo.getHIBRTHibThr()) * 0.208; // 1 LSb is 0.208%/hr. Convert to %/hr.
- Serial.print(hibThr, 3);
- Serial.println(F("%/h"));
-}
-
-void loop()
-{
- // Print the variables:
- Serial.print("Voltage: ");
- Serial.print(lipo.getVoltage()); // Print the battery voltage
- Serial.print("V");
-
- Serial.print(" Percentage: ");
- Serial.print(lipo.getSOC(), 2); // Print the battery state of charge with 2 decimal places
- Serial.print("%");
-
- Serial.print(" Change Rate: ");
- Serial.print(lipo.getChangeRate(), 2); // Print the battery change rate with 2 decimal places
- Serial.print("%/hr");
-
- Serial.print(" Alert: ");
- Serial.print(lipo.getAlert()); // Print the generic alert flag
-
- Serial.print(" Voltage High Alert: ");
- Serial.print(lipo.isVoltageHigh()); // Print the alert flag
-
- Serial.print(" Voltage Low Alert: ");
- Serial.print(lipo.isVoltageLow()); // Print the alert flag
-
- Serial.print(" Empty Alert: ");
- Serial.print(lipo.isLow()); // Print the alert flag
-
- Serial.print(" SOC 1% Change Alert: ");
- Serial.print(lipo.isChange()); // Print the alert flag
-
- Serial.print(" Hibernating: ");
- Serial.print(lipo.isHibernating()); // Print the alert flag
-
- Serial.println();
-
- delay(500);
-}
diff --git a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/keywords.txt b/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/keywords.txt
deleted file mode 100644
index c915999ce..000000000
--- a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/keywords.txt
+++ /dev/null
@@ -1,65 +0,0 @@
-#######################################
-# Syntax Coloring Map For MAX1704x
-#######################################
-
-#######################################
-# Datatypes (KEYWORD1)
-#######################################
-
-SFE_MAX17043 KEYWORD1
-
-#######################################
-# Methods and Functions (KEYWORD2)
-#######################################
-
-setDevice KEYWORD2
-setWirePort KEYWORD2
-begin KEYWORD2
-isConnected KEYWORD2
-enableDebugging KEYWORD2
-disableDebugging KEYWORD2
-quickStart KEYWORD2
-getVoltage KEYWORD2
-getSOC KEYWORD2
-getVersion KEYWORD2
-getThreshold KEYWORD2
-setThreshold KEYWORD2
-getAlert KEYWORD2
-clearAlert KEYWORD2
-enableSOCAlert KEYWORD2
-disableSOCAlert KEYWORD2
-sleep KEYWORD2
-wake KEYWORD2
-reset KEYWORD2
-getConfigRegister KEYWORD2
-getCompensation KEYWORD2
-setCompensation KEYWORD2
-setResetVoltage KEYWORD2
-getResetVoltage KEYWORD2
-enableComparator KEYWORD2
-disableComparator KEYWORD2
-getChangeRate KEYWORD2
-getStatus KEYWORD2
-isReset KEYWORD2
-isVoltageHigh KEYWORD2
-isVoltageLow KEYWORD2
-isVoltageReset KEYWORD2
-isLow KEYWORD2
-isChange KEYWORD2
-enableAlert KEYWORD2
-disableAlert KEYWORD2
-getVALRTMax KEYWORD2
-getVALRTMin KEYWORD2
-setVALRTMax KEYWORD2
-setVALRTMin KEYWORD2
-isHibernating KEYWORD2
-getHIBRTActThr KEYWORD2
-setHIBRTActThr KEYWORD2
-getHIBRTHibThr KEYWORD2
-setHIBRTHibThr KEYWORD2
-enableHibernate KEYWORD2
-disableHibernate KEYWORD2
-
-#######################################
-# Constants (LITERAL1)
-#######################################
diff --git a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/library.properties b/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/library.properties
deleted file mode 100644
index c47676fb9..000000000
--- a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/library.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-name=SparkFun MAX1704x Fuel Gauge Arduino Library
-version=1.0.4
-author=SparkFun Electronics
-maintainer=SparkFun Electronics
-sentence=Arduino library for the MAX17043/44/48/49 fuel gauges
-paragraph=An Arduino library to let you access all of the features of the MAX17043, MAX17044, MAX17048 and MAX17049 battery fuel gauges
-category=Sensors
-url=https://github.com/sparkfun/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library
-architectures=*
diff --git a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.cpp b/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.cpp
deleted file mode 100644
index 324677450..000000000
--- a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.cpp
+++ /dev/null
@@ -1,958 +0,0 @@
-/******************************************************************************
-SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.h
-By: Paul Clark
-October 23rd 2020
-
-Based extensively on:
-SparkFunMAX17043.cpp
-SparkFun MAX17043 Library Source File
-Jim Lindblom @ SparkFun Electronics
-Original Creation Date: June 22, 2015
-https://github.com/sparkfun/SparkFun_MAX17043_Particle_Library
-
-This file implements all functions of the MAX17043 class. Functions here range
-from higher level stuff, like reading/writing MAX17043 registers to low-level,
-hardware reads and writes.
-
-This code is released under the MIT license.
-
-Distributed as-is; no warranty is given.
-******************************************************************************/
-#include "SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.h"
-
-SFE_MAX1704X::SFE_MAX1704X(sfe_max1704x_devices_e device)
-{
- // Constructor
- setDevice(device);
-}
-
-// Change the device type if required. Do this after instantiation but before .begin
-void SFE_MAX1704X::setDevice(sfe_max1704x_devices_e device)
-{
- // Record the device type
- _device = device;
-
- // Define the full-scale voltage for VCELL based on the device
- switch (device)
- {
- case MAX1704X_MAX17044:
- _full_scale = 10.24; // MAX17044 VCELL is 12-bit, 2.50mV per LSB
- break;
- case MAX1704X_MAX17048:
- _full_scale = 5.12; // MAX17048 VCELL is 16-bit, 78.125uV/cell per LSB
- break;
- case MAX1704X_MAX17049:
- _full_scale = 10.24; // MAX17049 VCELL is 16-bit, 78.125uV/cell per LSB (i.e. 156.25uV per LSB)
- break;
- default: // Default is the MAX17043
- _full_scale = 5.12; // MAX17043 VCELL is 12-bit, 1.25mV per LSB
- break;
- }
-}
-
-bool SFE_MAX1704X::begin(TwoWire &wirePort)
-{
- setWirePort(wirePort); //Grab which port the user wants us to use
-
- if (isConnected() == false)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("begin: isConnected returned false"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (false);
- }
-
- return (true);
-}
-
-// Allow _i2CPort to be set manually, so that isConnected can be called before .begin if required
-void SFE_MAX1704X::setWirePort(TwoWire &wirePort)
-{
- _i2cPort = &wirePort; //Grab which port the user wants us to use
-}
-
-//Returns true if device is present
-bool SFE_MAX1704X::isConnected(void)
-{
- //Updated to resolve issue #4 Dec 27th 2021
- //Also avoid using the standard "if device answers on _deviceAddress" test
- //(https://github.com/sparkfun/Arduino_Apollo3/issues/400#issuecomment-992631994)
- bool success = false;
- uint8_t retries = 3;
- uint16_t version = 0;
-
- while ((success == false) && (retries > 0))
- {
- _i2cPort->beginTransmission(MAX1704x_ADDRESS);
- _i2cPort->write(MAX17043_VERSION); // Attempt to read the version register
- _i2cPort->endTransmission(false); // Don't release the bus
-
- if (_i2cPort->requestFrom(MAX1704x_ADDRESS, 2) == 2) // Attempt to read the version (2 bytes)
- {
- uint8_t msb = _i2cPort->read();
- uint8_t lsb = _i2cPort->read();
- version = ((uint16_t)msb << 8) | lsb;
- success = true;
- }
- else
- {
- retries--;
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("SFE_MAX1704X::isConnected: retrying..."));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- delay(50);
- }
- }
-
- if (!success) // Return now if the version could not be read
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("SFE_MAX1704X::isConnected: failed to detect IC!"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (success);
- }
-
- //Extra test - but only for MAX17048/9 - see issue #4
- if (_device >= MAX1704X_MAX17048)
- {
- //Get version should return 0x001_
- //Not a great test but something
- //Supported on 48/49
- if ((version & (1 << 4)) == 0)
- success = false;
- }
-
- return (success);
-}
-
-//Enable or disable the printing of debug messages
-void SFE_MAX1704X::enableDebugging(Stream &debugPort)
-{
- #if MAX1704X_ENABLE_DEBUGLOG
- _debugPort = &debugPort; //Grab which port the user wants us to use for debugging
- _printDebug = true; //Should we print the commands we send? Good for debugging
- #endif // if MAX1704X_ENABLE_DEBUGLOG
-}
-
-void SFE_MAX1704X::disableDebugging(void)
-{
- #if MAX1704X_ENABLE_DEBUGLOG
- _printDebug = false; //Turn off extra print statements
- #endif // if MAX1704X_ENABLE_DEBUGLOG
-}
-
-uint8_t SFE_MAX1704X::quickStart()
-{
- // A quick-start allows the MAX17043 to restart fuel-gauge calculations in the
- // same manner as initial power-up of the IC. If an application’s power-up
- // sequence is exceedingly noisy such that excess error is introduced into the
- // IC’s “first guess” of SOC, the host can issue a quick-start to reduce the
- // error. A quick-start is initiated by a rising edge on the QSTRT pin, or
- // through software by writing 4000h to MODE register.
-
- // Note: on the MAX17048/49 this will also clear / disable EnSleep
-
- return write16(MAX17043_MODE_QUICKSTART, MAX17043_MODE);
-}
-
-float SFE_MAX1704X::getVoltage()
-{
- uint16_t vCell;
- vCell = read16(MAX17043_VCELL);
-
- if (_device <= MAX1704X_MAX17044)
- {
- // On the MAX17043/44: vCell is a 12-bit register where each bit represents:
- // 1.25mV on the MAX17043
- // 2.5mV on the MAX17044
- vCell = (vCell) >> 4; // Align the 12 bits
-
- float divider = 4096.0 / _full_scale;
-
- return (((float)vCell) / divider);
- }
- else
- {
- // On the MAX17048/49: vCell is a 16-bit register where each bit represents 78.125uV/cell per LSB
- // i.e. 78.125uV per LSB on the MAX17048
- // i.e. 156.25uV per LSB on the MAX17049
-
- float divider = 65536.0 / _full_scale;
-
- return (((float)vCell) / divider);
- }
-}
-
-float SFE_MAX1704X::getSOC()
-{
- uint16_t soc;
- float percent;
- soc = read16(MAX17043_SOC);
- percent = (float)((soc & 0xFF00) >> 8);
- percent += ((float)(soc & 0x00FF)) / 256.0;
-
- return percent;
-}
-
-uint16_t SFE_MAX1704X::getVersion()
-{
- return read16(MAX17043_VERSION);
-}
-
-//Supported on MAX17048/49
-uint8_t SFE_MAX1704X::getID()
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("getID: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (0);
- }
-
- uint16_t vresetID = read16(MAX17048_VRESET_ID);
- return (vresetID & 0xFF);
-}
-
-//Default is 0x4B = 75 (7bit, shifted from 0x96__)
-//40mV per bit. So default is 3.0V.
-uint8_t SFE_MAX1704X::setResetVoltage(uint8_t threshold)
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("setResetVoltage: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (MAX17043_GENERIC_ERROR);
- }
-
- uint16_t vreset = read16(MAX17048_VRESET_ID);
- vreset &= 0x01FF; // Mask out bits to set
- vreset |= ((uint16_t)threshold << 9); // Add new threshold
-
- return write16(vreset, MAX17048_VRESET_ID);
-}
-uint8_t SFE_MAX1704X::setResetVoltage(float threshold)
-{
- // 7 bits. LSb = 40mV
- uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 5.08) / 0.04);
- return setResetVoltage(thresh);
-}
-
-uint8_t SFE_MAX1704X::getResetVoltage(void)
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("getResetVoltage: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (0);
- }
-
- uint16_t threshold = read16(MAX17048_VRESET_ID) >> 9;
- return ((uint8_t)threshold);
-}
-
-uint8_t SFE_MAX1704X::enableComparator(void)
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("enableComparator: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (MAX17043_GENERIC_ERROR);
- }
-
- uint16_t vresetReg = read16(MAX17048_VRESET_ID);
- vresetReg &= ~(1 << 8); //Clear bit to enable comparator
- return write16(vresetReg, MAX17048_VRESET_ID);
-}
-
-uint8_t SFE_MAX1704X::disableComparator(void)
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("disableComparator: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (MAX17043_GENERIC_ERROR);
- }
-
- uint16_t vresetReg = read16(MAX17048_VRESET_ID);
- vresetReg |= (1 << 8); //Set bit to disable comparator
- return write16(vresetReg, MAX17048_VRESET_ID);
-}
-
-float SFE_MAX1704X::getChangeRate(void)
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("getChangeRate: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (0.0);
- }
-
- int16_t changeRate = read16(MAX17048_CRATE);
- float changerate_f = changeRate * 0.208;
- return (changerate_f);
-}
-
-uint8_t SFE_MAX1704X::getStatus(void)
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("getStatus: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (0);
- }
-
- uint8_t statusReg = read16(MAX17048_STATUS) >> 8;
- return (statusReg & 0x7F); //Highest bit is don't care
-}
-
-bool SFE_MAX1704X::isReset(bool clear)
-{
- uint8_t status = getStatus();
- bool flag = (status & MAX1704x_STATUS_RI) > 0;
- if (flag && clear) // Clear the flag if requested
- {
- // Clear the aligned bit in the status register
- clearStatusRegBits(MAX1704x_STATUS_RI << 8);
- }
- return (flag);
-}
-bool SFE_MAX1704X::isVoltageHigh(bool clear)
-{
- uint8_t status = getStatus();
- bool flag = (status & MAX1704x_STATUS_VH) > 0;
- if (flag && clear) // Clear the flag if requested
- {
- // Clear the aligned bit in the status register
- clearStatusRegBits(MAX1704x_STATUS_VH << 8);
- }
- return (flag);
-}
-bool SFE_MAX1704X::isVoltageLow(bool clear)
-{
- uint8_t status = getStatus();
- bool flag = (status & MAX1704x_STATUS_VL) > 0;
- if (flag && clear) // Clear the flag if requested
- {
- // Clear the aligned bit in the status register
- clearStatusRegBits(MAX1704x_STATUS_VL << 8);
- }
- return (flag);
-}
-bool SFE_MAX1704X::isVoltageReset(bool clear)
-{
- uint8_t status = getStatus();
- bool flag = (status & MAX1704x_STATUS_VR) > 0;
- if (flag && clear) // Clear the flag if requested
- {
- // Clear the aligned bit in the status register
- clearStatusRegBits(MAX1704x_STATUS_VR << 8);
- }
- return (flag);
-}
-bool SFE_MAX1704X::isLow(bool clear)
-{
- uint8_t status = getStatus();
- bool flag = (status & MAX1704x_STATUS_HD) > 0;
- if (flag && clear) // Clear the flag if requested
- {
- // Clear the aligned bit in the status register
- clearStatusRegBits(MAX1704x_STATUS_HD << 8);
- }
- return (flag);
-}
-bool SFE_MAX1704X::isChange(bool clear)
-{
- uint8_t status = getStatus();
- bool flag = (status & MAX1704x_STATUS_SC) > 0;
- if (flag && clear) // Clear the flag if requested
- {
- // Clear the aligned bit in the status register
- clearStatusRegBits(MAX1704x_STATUS_SC << 8);
- }
- return (flag);
-}
-
-// Clear the specified bit in the MAX17048/49 status register (PRIVATE)
-// This requires the bits in mask to be correctly aligned.
-// MAX1704x_STATUS_RI etc. will need to be shifted left by 8 bits to become aligned.
-uint8_t SFE_MAX1704X::clearStatusRegBits(uint16_t mask)
-{
- uint16_t statusReg = read16(MAX17048_STATUS);
- statusReg &= ~mask; // Clear the specified bits
- return (write16(statusReg, MAX17048_STATUS)); // Write the contents back again
-}
-
-uint8_t SFE_MAX1704X::clearAlert()
-{
- // Read config reg, so we don't modify any other values:
- uint16_t configReg = read16(MAX17043_CONFIG);
- configReg &= ~MAX17043_CONFIG_ALERT; // Clear ALRT bit manually.
-
- return write16(configReg, MAX17043_CONFIG);
-}
-
-// getAlert([clear]) - Check if the MAX1704X's ALRT alert interrupt has been
-// triggered.
-// INPUT: [clear] - If [clear] is true, the alert flag will be cleared if it
-// was set.
-// OUTPUT: Returns 1 if interrupt is/was triggered, 0 if not.
-uint8_t SFE_MAX1704X::getAlert(bool clear)
-{
- // Read config reg, so we don't modify any other values:
- uint16_t configReg = read16(MAX17043_CONFIG);
- if (configReg & MAX17043_CONFIG_ALERT)
- {
- if (clear) // If the clear flag is set
- {
- configReg &= ~MAX17043_CONFIG_ALERT; // Clear ALRT bit manually.
- write16(configReg, MAX17043_CONFIG);
- }
- return 1;
- }
-
- return 0;
-}
-
-// enableSOCAlert() - (MAX17048/49) Enable the SOC change alert
-// Returns true if the SOC change alert was enabled successfully
-bool SFE_MAX1704X::enableSOCAlert()
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("enableSOCAlert: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (false);
- }
-
- // Read config reg, so we don't modify any other values:
- uint16_t configReg = read16(MAX17043_CONFIG);
- configReg |= MAX17043_CONFIG_ALSC; // Set the ALSC bit
- // Update the config register, return false if the write fails
- if (write16(configReg, MAX17043_CONFIG) > 0)
- return (false);
- // Re-Read the config reg
- configReg = read16(MAX17043_CONFIG);
- // Return true if the ALSC bit is set, otherwise return false
- return ((configReg & MAX17043_CONFIG_ALSC) > 0);
-}
-
-// disableSOCAlert() - (MAX17048/49) Disable the SOC change alert
-// Returns true if the SOC change alert was disabled successfully
-bool SFE_MAX1704X::disableSOCAlert()
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("disableSOCAlert: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (false);
- }
-
- // Read config reg, so we don't modify any other values:
- uint16_t configReg = read16(MAX17043_CONFIG);
- configReg &= ~MAX17043_CONFIG_ALSC; // Clear the ALSC bit
- // Update the config register, return false if the write fails
- if (write16(configReg, MAX17043_CONFIG) > 0)
- return (false);
- // Re-Read the config reg
- configReg = read16(MAX17043_CONFIG);
- // Return true if the ALSC bit is clear, otherwise return false
- return ((configReg & MAX17043_CONFIG_ALSC) == 0);
-}
-
-// Enable or Disable MAX17048 VRESET Alert:
-// EnVr (enable voltage reset alert) when set to 1 asserts
-// the ALRT pin when a voltage-reset event occurs under
-// the conditions described by the VRESET/ ID register.
-uint8_t SFE_MAX1704X::enableAlert(void)
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("enableAlert: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (MAX17043_GENERIC_ERROR);
- }
-
- uint16_t statusReg = read16(MAX17048_STATUS);
- statusReg |= MAX1704x_STATUS_EnVR; // Set EnVR bit
- return write16(statusReg, MAX17048_STATUS);
-}
-
-uint8_t SFE_MAX1704X::disableAlert(void)
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("disableAlert: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (MAX17043_GENERIC_ERROR);
- }
-
- uint16_t statusReg = read16(MAX17048_STATUS);
- statusReg &= ~MAX1704x_STATUS_EnVR; // Clear EnVR bit
- return write16(statusReg, MAX17048_STATUS);
-}
-
-uint8_t SFE_MAX1704X::getThreshold()
-{
- uint16_t configReg = read16(MAX17043_CONFIG);
- uint8_t threshold = (configReg & 0x001F);
-
- // It has an LSb weight of 1%, and can be programmed from 1% to 32%.
- // The value is (32 - ATHD)%, e.g.: 00000=32%, 00001=31%, 11111=1%.
- // Let's convert our percent to that first:
- threshold = 32 - threshold;
- return threshold;
-}
-
-uint8_t SFE_MAX1704X::setThreshold(uint8_t percent)
-{
- // The alert threshold is a 5-bit value that sets the state of charge level
- // where an interrupt is generated on the ALRT pin.
-
- // It has an LSb weight of 1%, and can be programmed from 1% to 32%.
- // The value is (32 - ATHD)%, e.g.: 00000=32%, 00001=31%, 11111=1%.
- // Let's convert our percent to that first:
- percent = (uint8_t)constrain((float)percent, 0.0, 32.0);
- percent = 32 - percent;
-
- // Read config reg, so we don't modify any other values:
- uint16_t configReg = read16(MAX17043_CONFIG);
- configReg &= 0xFFE0; // Mask out threshold bits
- configReg |= percent; // Add new threshold
-
- return write16(configReg, MAX17043_CONFIG);
-}
-
-// In sleep mode, the IC halts all operations, reducing current
-// consumption to below 1μA. After exiting sleep mode,
-// the IC continues normal operation. In sleep mode, the
-// IC does not detect self-discharge. If the battery changes
-// state while the IC sleeps, the IC cannot detect it, causing
-// SOC error. Wake up the IC before charging or discharging.
-uint8_t SFE_MAX1704X::sleep()
-{
- if (_device > MAX1704X_MAX17044)
- {
- // On the MAX17048, we also have to set the EnSleep bit in the MODE register
- uint8_t result = write16(MAX17048_MODE_ENSLEEP, MAX17043_MODE);
- if (result)
- return (result); // Write failed. Bail.
- }
-
- // Read config reg, so we don't modify any other values:
- uint16_t configReg = read16(MAX17043_CONFIG);
- if (configReg & MAX17043_CONFIG_SLEEP)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("sleep: MAX17043 is already sleeping!"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return MAX17043_GENERIC_ERROR; // Already sleeping, do nothing but return an error
- }
-
- configReg |= MAX17043_CONFIG_SLEEP; // Set sleep bit
-
- return write16(configReg, MAX17043_CONFIG);
-}
-
-uint8_t SFE_MAX1704X::wake()
-{
- // Read config reg, so we don't modify any other values:
- uint16_t configReg = read16(MAX17043_CONFIG);
- if (!(configReg & MAX17043_CONFIG_SLEEP))
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("wake: MAX17043 is already awake!"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return MAX17043_GENERIC_ERROR; // Already sleeping, do nothing but return an error
- }
- configReg &= ~MAX17043_CONFIG_SLEEP; // Clear sleep bit
-
- uint8_t result = write16(configReg, MAX17043_CONFIG);
-
- if (result)
- return (result); // Write failed. Bail.
-
- if (_device > MAX1704X_MAX17044)
- {
- // On the MAX17048, we should also clear the EnSleep bit in the MODE register
- // Strictly, this will clear the QuickStart bit too. Which is probably a good thing,
- // as I don't think we can do a read-modify-write?
- return write16(0x0000, MAX17043_MODE);
- }
- else
- {
- return (result);
- }
-}
-
-// Writing a value of 0x5400 to the CMD Register causes
-// the device to completely reset as if power had been
-// removed (see the Power-On Reset (POR) section). The
-// reset occurs when the last bit has been clocked in. The
-// IC does not respond with an I2C ACK after this command
-// sequence.
-// Output: Positive integer on success, 0 on fail.
-uint8_t SFE_MAX1704X::reset()
-{
- return write16(MAX17043_COMMAND_POR, MAX17043_COMMAND);
-}
-
-uint8_t SFE_MAX1704X::getCompensation()
-{
- uint16_t configReg = read16(MAX17043_CONFIG);
- uint8_t compensation = (configReg & 0xFF00) >> 8;
- return compensation;
-}
-
-uint16_t SFE_MAX1704X::getConfigRegister()
-{
- return read16(MAX17043_CONFIG);
-}
-
-uint8_t SFE_MAX1704X::setCompensation(uint8_t newCompensation)
-{
- // The CONFIG register compensates the ModelGauge algorith. The upper 8 bits
- // of the 16-bit register control the compensation.
- // Read the original configReg, so we can leave the lower 8 bits alone:
- uint16_t configReg = read16(MAX17043_CONFIG);
- configReg &= 0x00FF; // Mask out compensation bits
- configReg |= ((uint16_t)newCompensation) << 8;
- return write16(configReg, MAX17043_CONFIG);
-}
-
-// VALRT Register:
-// This register is divided into two thresholds: Voltage alert
-// maximum (VALRT.MAX) and minimum (VALRT. MIN).
-// Both registers have 1 LSb = 20mV. The IC alerts while
-// VCELL > VALRT.MAX or VCELL < VALRT.MIN
-uint8_t SFE_MAX1704X::setVALRTMax(uint8_t threshold)
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("setVALRTMax: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (MAX17043_GENERIC_ERROR);
- }
-
- uint16_t valrt = read16(MAX17048_CVALRT);
- valrt &= 0xFF00; // Mask off max bits
- valrt |= (uint16_t)threshold;
- return write16(valrt, MAX17048_CVALRT);
-}
-uint8_t SFE_MAX1704X::setVALRTMax(float threshold)
-{
- uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 5.1) / 0.02);
- return setVALRTMax(thresh);
-}
-
-uint8_t SFE_MAX1704X::getVALRTMax()
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("getVALRTMax: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (0);
- }
-
- uint16_t valrt = read16(MAX17048_CVALRT);
- valrt &= 0x00FF; // Mask off max bits
- return ((uint8_t)valrt);
-}
-
-uint8_t SFE_MAX1704X::setVALRTMin(uint8_t threshold)
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("setVALRTMin: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (MAX17043_GENERIC_ERROR);
- }
-
- uint16_t valrt = read16(MAX17048_CVALRT);
- valrt &= 0x00FF; // Mask off min bits
- valrt |= ((uint16_t)threshold) << 8;
- return write16(valrt, MAX17048_CVALRT);
-}
-uint8_t SFE_MAX1704X::setVALRTMin(float threshold)
-{
- uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 5.1) / 0.02);
- return setVALRTMin(thresh);
-}
-
-uint8_t SFE_MAX1704X::getVALRTMin()
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("getVALRTMin: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (0);
- }
-
- uint16_t valrt = read16(MAX17048_CVALRT);
- valrt >>= 8; // Shift min into LSB
- return ((uint8_t)valrt);
-}
-
-bool SFE_MAX1704X::isHibernating()
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("isHibernating: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (false);
- }
-
- uint16_t mode = read16(MAX17043_MODE);
- return ((mode & MAX17048_MODE_HIBSTAT) > 0);
-}
-
-uint8_t SFE_MAX1704X::getHIBRTActThr()
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("getHIBRTActThr: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (0);
- }
-
- uint16_t hibrt = read16(MAX17048_HIBRT);
- hibrt &= 0x00FF; // Mask off Act bits
- return ((uint8_t)hibrt);
-}
-
-uint8_t SFE_MAX1704X::setHIBRTActThr(uint8_t threshold)
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("setHIBRTActThr: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (MAX17043_GENERIC_ERROR);
- }
-
- uint16_t hibrt = read16(MAX17048_HIBRT);
- hibrt &= 0xFF00; // Mask off Act bits
- hibrt |= (uint16_t)threshold;
- return write16(hibrt, MAX17048_HIBRT);
-}
-uint8_t SFE_MAX1704X::setHIBRTActThr(float threshold)
-{
- // LSb = 1.25mV
- uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 0.31875) / 0.00125);
- return setHIBRTActThr(thresh);
-}
-
-uint8_t SFE_MAX1704X::getHIBRTHibThr()
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("getHIBRTHibThr: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (0);
- }
-
- uint16_t hibrt = read16(MAX17048_HIBRT);
- hibrt >>= 8; // Shift HibThr into LSB
- return ((uint8_t)hibrt);
-}
-
-uint8_t SFE_MAX1704X::setHIBRTHibThr(uint8_t threshold)
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("setHIBRTHibThr: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (MAX17043_GENERIC_ERROR);
- }
-
- uint16_t hibrt = read16(MAX17048_HIBRT);
- hibrt &= 0x00FF; // Mask off Hib bits
- hibrt |= ((uint16_t)threshold) << 8;
- return write16(hibrt, MAX17048_HIBRT);
-}
-uint8_t SFE_MAX1704X::setHIBRTHibThr(float threshold)
-{
- // LSb = 0.208%/hr
- uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 53.04) / 0.208);
- return setHIBRTHibThr(thresh);
-}
-
-uint8_t SFE_MAX1704X::enableHibernate()
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("enableHibernate: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (MAX17043_GENERIC_ERROR);
- }
-
- return write16(MAX17048_HIBRT_ENHIB, MAX17048_HIBRT);
-}
-
-uint8_t SFE_MAX1704X::disableHibernate()
-{
- if (_device <= MAX1704X_MAX17044)
- {
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("disableHibernate: not supported on this device"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- return (MAX17043_GENERIC_ERROR);
- }
-
- return write16(MAX17048_HIBRT_DISHIB, MAX17048_HIBRT);
-}
-
-uint8_t SFE_MAX1704X::write16(uint16_t data, uint8_t address)
-{
- uint8_t msb, lsb;
- msb = (data & 0xFF00) >> 8;
- lsb = (data & 0x00FF);
- _i2cPort->beginTransmission(MAX1704x_ADDRESS);
- _i2cPort->write(address);
- _i2cPort->write(msb);
- _i2cPort->write(lsb);
- return (_i2cPort->endTransmission());
-}
-
-uint16_t SFE_MAX1704X::read16(uint8_t address)
-{
- bool success = false;
- uint8_t retries = 3;
- uint16_t result = 0;
-
- while ((success == false) && (retries > 0))
- {
- _i2cPort->beginTransmission(MAX1704x_ADDRESS);
- _i2cPort->write(address);
- _i2cPort->endTransmission(false); // Don't release the bus
-
- if (_i2cPort->requestFrom(MAX1704x_ADDRESS, 2) == 2)
- {
- uint8_t msb = _i2cPort->read();
- uint8_t lsb = _i2cPort->read();
- result = ((uint16_t)msb << 8) | lsb;
- success = true;
- }
- else
- {
- retries--;
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- _debugPort->println(F("SFE_MAX1704X::read16: retrying..."));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
- delay(50);
- }
- }
-
- #if MAX1704X_ENABLE_DEBUGLOG
- if (_printDebug == true)
- {
- if (!success)
- _debugPort->println(F("SFE_MAX1704X::read16: failed to read data!"));
- }
- #endif // if MAX1704X_ENABLE_DEBUGLOG
-
- return (result);
-}
diff --git a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.h b/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.h
deleted file mode 100644
index 3bb63073b..000000000
--- a/lib/SparkFun MAX1704x Fuel Gauge Arduino Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.h
+++ /dev/null
@@ -1,403 +0,0 @@
-/******************************************************************************
-SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.h
-By: Paul Clark
-October 23rd 2020
-
-Based extensively on:
-SparkFunMAX17043.h
-SparkFun MAX17043 Library Header File
-Jim Lindblom @ SparkFun Electronics
-Original Creation Date: June 22, 2015
-https://github.com/sparkfun/SparkFun_MAX17043_Particle_Library
-
-This file implements all functions of the MAX17043 class. Functions here range
-from higher level stuff, like reading/writing MAX17043 registers to low-level,
-hardware reads and writes.
-
-This code is released under the MIT license.
-
-Distributed as-is; no warranty is given.
-******************************************************************************/
-#ifndef MAX1704X_ARDUINO_LIBRARY_H
-#define MAX1704X_ARDUINO_LIBRARY_H
-
-// Uncomment the next #define to EXclude any debug logging from the code, by default debug logging code will be included
-
-// #define MAX1704X_ENABLE_DEBUGLOG 0 // OFF/disabled/excluded on demand
-
-#if (ARDUINO >= 100)
-#include "Arduino.h"
-#else
-#include "WProgram.h"
-#endif
-
-#include
-
-//Enable/disable including debug log (to allow saving some space)
-#ifndef MAX1704X_ENABLE_DEBUGLOG
- #if defined(LIBRARIES_NO_LOG) && LIBRARIES_NO_LOG
- #define MAX1704X_ENABLE_DEBUGLOG 0 // OFF/disabled/excluded on demand
- #else
- #define MAX1704X_ENABLE_DEBUGLOG 1 // ON/enabled/included by default
- #endif
-#endif
-
-//#include "application.h"
-
-//////////////////////////
-// MAX1704x Device Enum //
-//////////////////////////
-
-typedef enum {
- MAX1704X_MAX17043 = 0,
- MAX1704X_MAX17044, // 2-cell version of the MAX17043 (full-scale range of 10V)
- MAX1704X_MAX17048,
- MAX1704X_MAX17049 // 2-cell version of the MAX17048
-} sfe_max1704x_devices_e;
-
-///////////////////////////////////
-// MAX1704x Register Definitions //
-///////////////////////////////////
-// All registers contain two bytes of data and span two addresses.
-// Registers which are present on the MAX17048/49 only are prefixed with MAX17048_
-#define MAX17043_VCELL 0x02 // R - 12-bit A/D measurement of battery voltage
-#define MAX17043_SOC 0x04 // R - 16-bit state of charge (SOC)
-#define MAX17043_MODE 0x06 // W - Sends special commands to IC
-#define MAX17043_VERSION 0x08 // R - Returns IC version
-#define MAX17048_HIBRT 0x0A // R/W - (MAX17048/49) Thresholds for entering hibernate
-#define MAX17043_CONFIG 0x0C // R/W - Battery compensation (default 0x971C)
-#define MAX17048_CVALRT 0x14 // R/W - (MAX17048/49) Configures vcell range to generate alerts (default 0x00FF)
-#define MAX17048_CRATE 0x16 // R - (MAX17048/49) Charge rate 0.208%/hr
-#define MAX17048_VRESET_ID 0x18 // R/W - (MAX17048/49) Reset voltage and ID (default 0x96__)
-#define MAX17048_STATUS 0x1A // R/W - (MAX17048/49) Status of ID (default 0x01__)
-#define MAX17043_COMMAND 0xFE // W - Sends special comands to IC
-
-///////////////////////////////////
-// MAX17043 Config Register Bits //
-///////////////////////////////////
-#define MAX17043_CONFIG_SLEEP (1 << 7)
-#define MAX17043_CONFIG_ALSC 0x0040 // MAX17048/49 only
-#define MAX17043_CONFIG_ALERT (1 << 5)
-#define MAX17043_CONFIG_THRESHOLD 0
-
-/////////////////////////////////////
-// MAX17043 Mode Register Commands //
-/////////////////////////////////////
-#define MAX17043_MODE_QUICKSTART 0x4000 // On the MAX17048/49 this also clears the EnSleep bit
-
-/////////////////////////////////
-// MAX17048 Mode Register Bits //
-/////////////////////////////////
-#define MAX17048_MODE_ENSLEEP 0x2000 // W - _Enables_ sleep mode (the SLEEP bit in the CONFIG reg engages sleep)
-#define MAX17048_MODE_HIBSTAT 0x1000 // R - indicates when the IC is in hibernate mode
-
-/////////////////////////////////////
-// MAX17048/9 Status Register Bits //
-/////////////////////////////////////
-#define MAX1704x_STATUS_RI (1 << 0) // Assumes the MSB has been shifted >> 8
-#define MAX1704x_STATUS_VH (1 << 1) // Assumes the MSB has been shifted >> 8
-#define MAX1704x_STATUS_VL (1 << 2) // Assumes the MSB has been shifted >> 8
-#define MAX1704x_STATUS_VR (1 << 3) // Assumes the MSB has been shifted >> 8
-#define MAX1704x_STATUS_HD (1 << 4) // Assumes the MSB has been shifted >> 8
-#define MAX1704x_STATUS_SC (1 << 5) // Assumes the MSB has been shifted >> 8
-#define MAX1704x_STATUS_EnVR (1 << 14) // ** Unshifted **
-
-////////////////////////////////////////
-// MAX17043 Command Register Commands //
-////////////////////////////////////////
-#define MAX17043_COMMAND_POR 0x5400
-
-///////////////////////////////////////
-// MAX17048 Hibernate Enable/Disable //
-///////////////////////////////////////
-#define MAX17048_HIBRT_ENHIB 0xFFFF // always use hibernate mode
-#define MAX17048_HIBRT_DISHIB 0x0000 // disable hibernate mode
-
-////////////////////////////////
-// MAX1704x 7-Bit I2C Address //
-////////////////////////////////
-#define MAX1704x_ADDRESS 0x36 // Unshifted I2C address. Becomes 0x6C for write and 0x6D for read.
-
-// Generic error:
-// Wire.endTransmission will return:
-// 0:success
-// 1:data too long to fit in transmit buffer
-// 2:received NACK on transmit of address
-// 3:received NACK on transmit of data
-// 4:other error
-// So, let's use "5" as a generic error value
-#define MAX17043_GENERIC_ERROR 5
-
-class SFE_MAX1704X
-{
-public:
- SFE_MAX1704X(sfe_max1704x_devices_e device = MAX1704X_MAX17043); // Default to the 5V MAX17043
-
- // Change the device type if required. Do this after instantiation but before .begin
- void setDevice(sfe_max1704x_devices_e device);
-
- // Allow _i2CPort to be set manually, so that isConnected can be called before .begin if required
- void setWirePort(TwoWire &wirePort);
-
- // begin() - Initializes the MAX17043.
- bool begin(TwoWire &wirePort = Wire); //Returns true if module is detected
-
- //Returns true if device is present
- bool isConnected(void);
-
- // Debug
- void enableDebugging(Stream &debugPort = Serial); // enable debug messages
- void disableDebugging(); // disable debug messages
-
- // quickStart() - Restarts the MAX17043 to allow it to re-"guess" the
- // parameters that go into its SoC algorithms. Calling this in your setup()
- // usually results in more accurate SoC readings.
- // Output: 0 on success, positive integer on fail.
- uint8_t quickStart();
-
- // getVoltage() - Get the MAX17043's voltage reading.
- // Output: floating point value between 0-5V in 1.25mV increments.
- float getVoltage();
-
- // getSOC() - Get the MAX17043's state-of-charge (SOC) reading, as calculated
- // by the IC's "ModelGauge" algorithm.
- // The first update is available approximately 1s after POR of the IC.
- // Output: floating point value between 0-100, representing a percentage of
- // full charge.
- float getSOC();
-
- // getVersion() - Get the MAX17043's production version number.
- // Output: 3 on success
- uint16_t getVersion();
-
- // getThreshold() - Get the MAX17043's current percentage threshold that will
- // trigger an alert.
- // Output: An integer value between 1 and 32, representing a % that will
- // trigger an alert interrupt.
- uint8_t getThreshold();
-
- // setThreshold([percent]) - Set the MAX17043's percentage threshold that will
- // trigger an alert.
- // Input: [percent] - Percentage value that will trigger an alert interrupt.
- // Any value between 1 and 32 is valid. Default value is 0x1C == 4%
- // Output: 0 on success, positive integer on fail.
- uint8_t setThreshold(uint8_t percent = 4);
-
- // sleep() - Set the MAX17043 into sleep mode.
- // Output: 0 on success, positive integer on fail.
- // In sleep mode, the IC halts all operations, reducing current
- // consumption to below 1μA. After exiting sleep mode,
- // the IC continues normal operation. In sleep mode, the
- // IC does not detect self-discharge. If the battery changes
- // state while the IC sleeps, the IC cannot detect it, causing
- // SOC error. Wake up the IC before charging or discharging.
- uint8_t sleep();
-
- // wake() - Wake the MAX17043 up from sleep.
- // Output: 0 on success, positive integer on fail.
- uint8_t wake();
-
- // reset() - Issue a Power-on-reset command to the MAX17043. This function
- // will reset every register in the MAX17043 to its default value.
- // Output: Positive integer on success, 0 on fail.
- uint8_t reset();
-
- // getConfigRegister() - Read the 16-bit value of the CONFIG Register.
- // Output: 16-bit integer value representing the msb and lsb bytes of the
- // CONFIG register.
- uint16_t getConfigRegister();
-
- // getCompensation() - Get the ModelGauge compensation value - an obscure
- // 8-bit value set to 0x97 by default.
- // Output: 8-bit value read from the CONFIG register's MSB.
- uint8_t getCompensation();
-
- // setCompensation([newCompensation]) - Set the 8-bit compensation value. This
- // is an obscure 8-bit value that has some effect on Maxim's ModelGauge
- // algorithm. The POR value of RCOMP is 0x97.
- // From the datasheet: "Contact Maxim for instructions for optimization."
- // For best performance, the host microcontroller must measure
- // battery temperature periodically, and compensate
- // the RCOMP ModelGauge parameter accordingly, at least
- // once per minute. Each custom model defines constants
- // RCOMP0 (default is 0x97), TempCoUp (default is -0.5),
- // and TempCoDown (default is -5.0). To calculate the new
- // value of CONFIG.RCOMP:
- // // T is battery temperature (degrees Celsius)
- // if (T > 20) {
- // RCOMP = RCOMP0 + (T - 20) x TempCoUp;
- // }
- // else {
- // RCOMP = RCOMP0 + (T - 20) x TempCoDown;
- // }
- // Input: [newCompensation] - Should be a value between 0-255.
- // Output: 0 on success, positive integer on fail.
- uint8_t setCompensation(uint8_t newCompensation = 0x97);
-
- // getID() - (MAX17048/49) Returns 8-bit OTP bits set at factory. Can be used to
- // 'to distinguish multiple cell types in production'.
- // Writes to these bits are ignored.
- uint8_t getID(void);
-
- // setResetVoltage([threshold]) - (MAX17048/49) Set the 7-bit VRESET value.
- // A 7-bit value that controls the comparator for detecting when
- // a battery is detached and re-connected. 40mV per bit. Default is 3.0V.
- // For captive batteries, set to 2.5V. For
- // removable batteries, set to at least 300mV below the
- // application’s empty voltage, according to the desired
- // reset threshold for your application.
- // Input: [threshold] - Should be a value between 0-127.
- // Output: 0 on success, positive integer on fail.
- uint8_t setResetVoltage(uint8_t threshold = (0x96 >> 1));
- uint8_t setResetVoltage(float threshold = 3.0); // Helper function: set threshold in Volts
-
- // getResetVoltage() - (MAX17048/49) Get the 7-bit VRESET value
- // Output: 7-bit value read from the VRESET/ID register's MSB.
- // Returned value is 40mV per bit.
- uint8_t getResetVoltage(void);
-
- // enableComparator() - (MAX17048/49) Set bit in VRESET/ID reg
- // Comparator is enabled by default. (Re)enable the analog comparator, uses 0.5uA.
- // Output: 0 on success, positive integer on fail.
- uint8_t enableComparator(void);
-
- // disableComparator() - (MAX17048/49) Clear bit in VRESET/ID reg
- // Disable the analog comparator, saves 0.5uA in hibernate mode.
- // Output: 0 on success, positive integer on fail.
- uint8_t disableComparator(void);
-
- // getChangeRate() - (MAX17048/49) Get rate of change per hour in %
- // Output: (signed) Float (that is the 0.208% * CRATE register value)
- // A positive rate is charging, negative is discharge.
- float getChangeRate();
-
- // getStatus() - (MAX17048/49) Get the 7 bits of status register
- // Output: 7-bits indicating various alerts
- uint8_t getStatus();
-
- //(MAX17048/49) Various helper functions to check bits in status register
- // INPUT: [clear] - If [clear] is true, the alert flag will be cleared if it
- // was set.
- bool isReset(bool clear = false); //True after POR
- bool isVoltageHigh(bool clear = false); //True when VCELL goes above VALRTMAX (see setVALRTMax)
- bool isVoltageLow(bool clear = false); //True when VCELL goes below VALRTMIN (see setVALRTMin)
- bool isVoltageReset(bool clear = false);
- bool isLow(bool clear = false); //True when SOC crosses the value in ATHD (see setThreshold)
- bool isChange(bool clear = false); //True when SOC changes by at least 1% and SOCAlert is enabled
-
- // getAlert([clear]) - Check if the MAX1704X's ALRT alert interrupt has been
- // triggered.
- // INPUT: [clear] - If [clear] is true, the alert flag will be cleared if it
- // was set.
- // OUTPUT: Returns 1 if interrupt is/was triggered, 0 if not.
- uint8_t getAlert(bool clear = false);
-
- // clearAlert() - Clear the MAX1704X's ALRT alert flag.
- // Output: 0 on success, positive integer on fail.
- uint8_t clearAlert();
-
- // enableSOCAlert() - (MAX17048/49) Enable the SOC change alert
- // Returns true if the SOC change alert was enabled successfully
- bool enableSOCAlert();
-
- // disableSOCAlert() - (MAX17048/49) Disable the SOC change alert
- // Returns true if the SOC change alert was disabled successfully
- bool disableSOCAlert();
-
- // Enable or Disable MAX17048/49 VRESET Alert:
- // EnVr (enable voltage reset alert) when set to 1 asserts
- // the ALRT pin when a voltage-reset event occurs under
- // the conditions described by the VRESET/ ID register.
- // enableAlert() - Set ENvR bit in STATUS register 0x1A
- // Output: 0 on success, positive integer on fail.
- uint8_t enableAlert();
- // disableAlert() - Clear the ENvR bit in STATUS register 0x1A
- // Output: 0 on success, positive integer on fail.
- uint8_t disableAlert();
-
- // Read and return the MAX17048/49 VALRT Maximum threshold
- // LSb = 20mV
- uint8_t getVALRTMax();
-
- // Read and return the MAX17048/49 VALRT Minimum threshold
- // LSb = 20mV
- uint8_t getVALRTMin();
-
- // Set the MAX17048/49 VALRT Maximum threshold
- // Output: 0 on success, positive integer on fail.
- // Note: this sets the threshold voltage _per cell_ (MAX17049 monitors two cells)
- uint8_t setVALRTMax(uint8_t threshold = 0xFF); // LSb = 20mV
- uint8_t setVALRTMax(float threshold = 5.1); // threshold is defined in Volts
-
- // Set the MAX17048/49 VALRT Minimum threshold
- // Output: 0 on success, positive integer on fail.
- // Note: this sets the threshold voltage _per cell_ (MAX17049 monitors two cells)
- uint8_t setVALRTMin(uint8_t threshold = 0x00); // LSb = 20mV
- uint8_t setVALRTMin(float threshold = 0.0); // threshold is defined in Volts
-
- // Read and return the MAX17048/49 Hibernate Status flag
- bool isHibernating();
-
- // Read and return the MAX17048/49 HIBRT Active Threshold
- // LSb = 1.25mV
- uint8_t getHIBRTActThr();
-
- // Set the MAX17048/49 HIBRT Active Threshold
- // Output: 0 on success, positive integer on fail.
- uint8_t setHIBRTActThr(uint8_t threshold); // LSb = 1.25mV
- uint8_t setHIBRTActThr(float threshold); // Helper function: set threshold in Volts
-
- // Read and return the MAX17048/49 HIBRT Hibernate Threshold
- // LSb = 0.208%/hr
- uint8_t getHIBRTHibThr();
-
- // Set the MAX17048/49 HIBRT Hibernate Threshold
- // Output: 0 on success, positive integer on fail.
- uint8_t setHIBRTHibThr(uint8_t threshold); // LSb = 0.208%/hr
- uint8_t setHIBRTHibThr(float threshold); // Helper function: set threshold in percent
-
- // Place the MAX17048/49 into hibernate
- // Sets the HIBRT register to 0xFFFF
- // Output: 0 on success, positive integer on fail.
- uint8_t enableHibernate();
-
- // Disable hibernate on the MAX17048/49
- // Sets the HIBRT register to 0x0000
- // Output: 0 on success, positive integer on fail.
- uint8_t disableHibernate();
-
- //Lower level functions but exposed incase user wants them
-
- // write16([data], [address]) - Write 16 bits to the requested address. After
- // writing the address to be written, two sequential 8-bit writes will occur.
- // the msb is written first, then lsb.
- // Input: [data] - A 16-bit integer to be written to the device.
- // [address] - An 8-bit address to be written to.
- // Output: 0 on success, positive integer on fail.
- uint8_t write16(uint16_t data, uint8_t address);
-
- // read16([address]) - Read 16-bits from the requested address of a device.
- // Input: [address] - An 8-bit address to be read from.
- // Output: A 16-bit value read from the device's address will be returned.
- uint16_t read16(uint8_t address);
-
-private:
- //Variables
- TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware
-
- #if MAX1704X_ENABLE_DEBUGLOG
- Stream *_debugPort; //The stream to send debug messages to if enabled. Usually Serial.
- bool _printDebug = false; //Flag to print debugging variables
- #endif // if MAX1704X_ENABLE_DEBUGLOG
-
- // Clear the specified bit(s) in the MAX17048/49 status register
- // This requires the bits in mask to be correctly aligned.
- // MAX1704x_STATUS_RI etc. will need to be shifted left by 8 bits to become aligned.
- // Output: 0 on success, positive integer on fail.
- uint8_t clearStatusRegBits(uint16_t mask);
-
- int _device = MAX1704X_MAX17043; // Default to MAX17043
- float _full_scale = 5.12; // Default: full-scale for the MAX17043
-};
-
-#endif
diff --git a/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/keywords.txt b/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/keywords.txt
index 8b9538a8d..c915999ce 100644
--- a/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/keywords.txt
+++ b/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/keywords.txt
@@ -12,6 +12,8 @@ SFE_MAX17043 KEYWORD1
# Methods and Functions (KEYWORD2)
#######################################
+setDevice KEYWORD2
+setWirePort KEYWORD2
begin KEYWORD2
isConnected KEYWORD2
enableDebugging KEYWORD2
diff --git a/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/library.properties b/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/library.properties
index 7022a9f5d..c47676fb9 100644
--- a/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/library.properties
+++ b/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/library.properties
@@ -1,5 +1,5 @@
name=SparkFun MAX1704x Fuel Gauge Arduino Library
-version=1.0.1
+version=1.0.4
author=SparkFun Electronics
maintainer=SparkFun Electronics
sentence=Arduino library for the MAX17043/44/48/49 fuel gauges
diff --git a/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.cpp b/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.cpp
index c1954333d..324677450 100644
--- a/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.cpp
+++ b/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.cpp
@@ -23,7 +23,12 @@ Distributed as-is; no warranty is given.
SFE_MAX1704X::SFE_MAX1704X(sfe_max1704x_devices_e device)
{
// Constructor
+ setDevice(device);
+}
+// Change the device type if required. Do this after instantiation but before .begin
+void SFE_MAX1704X::setDevice(sfe_max1704x_devices_e device)
+{
// Record the device type
_device = device;
@@ -45,47 +50,104 @@ SFE_MAX1704X::SFE_MAX1704X(sfe_max1704x_devices_e device)
}
}
-boolean SFE_MAX1704X::begin(TwoWire &wirePort)
+bool SFE_MAX1704X::begin(TwoWire &wirePort)
{
- _i2cPort = &wirePort; //Grab which port the user wants us to use
+ setWirePort(wirePort); //Grab which port the user wants us to use
if (isConnected() == false)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("begin: isConnected returned false"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (false);
}
return (true);
}
-//Returns true if device answers on _deviceAddress
-boolean SFE_MAX1704X::isConnected(void)
+// Allow _i2CPort to be set manually, so that isConnected can be called before .begin if required
+void SFE_MAX1704X::setWirePort(TwoWire &wirePort)
{
- _i2cPort->beginTransmission((uint8_t)MAX1704x_ADDRESS);
- if (_i2cPort->endTransmission() == 0)
+ _i2cPort = &wirePort; //Grab which port the user wants us to use
+}
+
+//Returns true if device is present
+bool SFE_MAX1704X::isConnected(void)
+{
+ //Updated to resolve issue #4 Dec 27th 2021
+ //Also avoid using the standard "if device answers on _deviceAddress" test
+ //(https://github.com/sparkfun/Arduino_Apollo3/issues/400#issuecomment-992631994)
+ bool success = false;
+ uint8_t retries = 3;
+ uint16_t version = 0;
+
+ while ((success == false) && (retries > 0))
+ {
+ _i2cPort->beginTransmission(MAX1704x_ADDRESS);
+ _i2cPort->write(MAX17043_VERSION); // Attempt to read the version register
+ _i2cPort->endTransmission(false); // Don't release the bus
+
+ if (_i2cPort->requestFrom(MAX1704x_ADDRESS, 2) == 2) // Attempt to read the version (2 bytes)
+ {
+ uint8_t msb = _i2cPort->read();
+ uint8_t lsb = _i2cPort->read();
+ version = ((uint16_t)msb << 8) | lsb;
+ success = true;
+ }
+ else
+ {
+ retries--;
+ #if MAX1704X_ENABLE_DEBUGLOG
+ if (_printDebug == true)
+ {
+ _debugPort->println(F("SFE_MAX1704X::isConnected: retrying..."));
+ }
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
+ delay(50);
+ }
+ }
+
+ if (!success) // Return now if the version could not be read
+ {
+ #if MAX1704X_ENABLE_DEBUGLOG
+ if (_printDebug == true)
+ {
+ _debugPort->println(F("SFE_MAX1704X::isConnected: failed to detect IC!"));
+ }
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
+ return (success);
+ }
+
+ //Extra test - but only for MAX17048/9 - see issue #4
+ if (_device >= MAX1704X_MAX17048)
{
//Get version should return 0x001_
//Not a great test but something
- //Supported on 43/44/48/49
- if (getVersion() & (1 << 4))
- return true;
+ //Supported on 48/49
+ if ((version & (1 << 4)) == 0)
+ success = false;
}
- return false;
+
+ return (success);
}
//Enable or disable the printing of debug messages
void SFE_MAX1704X::enableDebugging(Stream &debugPort)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
_debugPort = &debugPort; //Grab which port the user wants us to use for debugging
_printDebug = true; //Should we print the commands we send? Good for debugging
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
}
void SFE_MAX1704X::disableDebugging(void)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
_printDebug = false; //Turn off extra print statements
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
}
uint8_t SFE_MAX1704X::quickStart()
@@ -114,7 +176,7 @@ float SFE_MAX1704X::getVoltage()
// 2.5mV on the MAX17044
vCell = (vCell) >> 4; // Align the 12 bits
- float divider = 4096.0f / _full_scale;
+ float divider = 4096.0 / _full_scale;
return (((float)vCell) / divider);
}
@@ -124,7 +186,7 @@ float SFE_MAX1704X::getVoltage()
// i.e. 78.125uV per LSB on the MAX17048
// i.e. 156.25uV per LSB on the MAX17049
- float divider = 65536.0f / _full_scale;
+ float divider = 65536.0 / _full_scale;
return (((float)vCell) / divider);
}
@@ -136,7 +198,7 @@ float SFE_MAX1704X::getSOC()
float percent;
soc = read16(MAX17043_SOC);
percent = (float)((soc & 0xFF00) >> 8);
- percent += ((float)(soc & 0x00FF)) / 256.0f;
+ percent += ((float)(soc & 0x00FF)) / 256.0;
return percent;
}
@@ -151,10 +213,12 @@ uint8_t SFE_MAX1704X::getID()
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("getID: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (0);
}
@@ -168,10 +232,12 @@ uint8_t SFE_MAX1704X::setResetVoltage(uint8_t threshold)
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("setResetVoltage: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (MAX17043_GENERIC_ERROR);
}
@@ -184,7 +250,7 @@ uint8_t SFE_MAX1704X::setResetVoltage(uint8_t threshold)
uint8_t SFE_MAX1704X::setResetVoltage(float threshold)
{
// 7 bits. LSb = 40mV
- uint8_t thresh = (uint8_t)(constrain(threshold, 0.0f, 5.08f) / 0.04f);
+ uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 5.08) / 0.04);
return setResetVoltage(thresh);
}
@@ -192,10 +258,12 @@ uint8_t SFE_MAX1704X::getResetVoltage(void)
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("getResetVoltage: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (0);
}
@@ -207,10 +275,12 @@ uint8_t SFE_MAX1704X::enableComparator(void)
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("enableComparator: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (MAX17043_GENERIC_ERROR);
}
@@ -223,10 +293,12 @@ uint8_t SFE_MAX1704X::disableComparator(void)
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("disableComparator: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (MAX17043_GENERIC_ERROR);
}
@@ -239,15 +311,17 @@ float SFE_MAX1704X::getChangeRate(void)
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("getChangeRate: not supported on this device"));
}
- return (0.0f);
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
+ return (0.0);
}
int16_t changeRate = read16(MAX17048_CRATE);
- float changerate_f = changeRate * 0.208f;
+ float changerate_f = changeRate * 0.208;
return (changerate_f);
}
@@ -255,10 +329,12 @@ uint8_t SFE_MAX1704X::getStatus(void)
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("getStatus: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (0);
}
@@ -380,10 +456,12 @@ bool SFE_MAX1704X::enableSOCAlert()
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("enableSOCAlert: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (false);
}
@@ -405,10 +483,12 @@ bool SFE_MAX1704X::disableSOCAlert()
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("disableSOCAlert: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (false);
}
@@ -432,10 +512,12 @@ uint8_t SFE_MAX1704X::enableAlert(void)
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("enableAlert: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (MAX17043_GENERIC_ERROR);
}
@@ -448,10 +530,12 @@ uint8_t SFE_MAX1704X::disableAlert(void)
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("disableAlert: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (MAX17043_GENERIC_ERROR);
}
@@ -480,7 +564,7 @@ uint8_t SFE_MAX1704X::setThreshold(uint8_t percent)
// It has an LSb weight of 1%, and can be programmed from 1% to 32%.
// The value is (32 - ATHD)%, e.g.: 00000=32%, 00001=31%, 11111=1%.
// Let's convert our percent to that first:
- percent = constrain(percent, 0, 32);
+ percent = (uint8_t)constrain((float)percent, 0.0, 32.0);
percent = 32 - percent;
// Read config reg, so we don't modify any other values:
@@ -511,10 +595,12 @@ uint8_t SFE_MAX1704X::sleep()
uint16_t configReg = read16(MAX17043_CONFIG);
if (configReg & MAX17043_CONFIG_SLEEP)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("sleep: MAX17043 is already sleeping!"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return MAX17043_GENERIC_ERROR; // Already sleeping, do nothing but return an error
}
@@ -529,10 +615,12 @@ uint8_t SFE_MAX1704X::wake()
uint16_t configReg = read16(MAX17043_CONFIG);
if (!(configReg & MAX17043_CONFIG_SLEEP))
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("wake: MAX17043 is already awake!"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return MAX17043_GENERIC_ERROR; // Already sleeping, do nothing but return an error
}
configReg &= ~MAX17043_CONFIG_SLEEP; // Clear sleep bit
@@ -599,10 +687,12 @@ uint8_t SFE_MAX1704X::setVALRTMax(uint8_t threshold)
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("setVALRTMax: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (MAX17043_GENERIC_ERROR);
}
@@ -613,7 +703,7 @@ uint8_t SFE_MAX1704X::setVALRTMax(uint8_t threshold)
}
uint8_t SFE_MAX1704X::setVALRTMax(float threshold)
{
- uint8_t thresh = (uint8_t)(constrain(threshold, 0.0f, 5.1f) / 0.02f);
+ uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 5.1) / 0.02);
return setVALRTMax(thresh);
}
@@ -621,10 +711,12 @@ uint8_t SFE_MAX1704X::getVALRTMax()
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("getVALRTMax: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (0);
}
@@ -637,10 +729,12 @@ uint8_t SFE_MAX1704X::setVALRTMin(uint8_t threshold)
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("setVALRTMin: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (MAX17043_GENERIC_ERROR);
}
@@ -651,7 +745,7 @@ uint8_t SFE_MAX1704X::setVALRTMin(uint8_t threshold)
}
uint8_t SFE_MAX1704X::setVALRTMin(float threshold)
{
- uint8_t thresh = (uint8_t)(constrain(threshold, 0.0f, 5.1f) / 0.02f);
+ uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 5.1) / 0.02);
return setVALRTMin(thresh);
}
@@ -659,10 +753,12 @@ uint8_t SFE_MAX1704X::getVALRTMin()
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("getVALRTMin: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (0);
}
@@ -675,10 +771,12 @@ bool SFE_MAX1704X::isHibernating()
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("isHibernating: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (false);
}
@@ -690,10 +788,12 @@ uint8_t SFE_MAX1704X::getHIBRTActThr()
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("getHIBRTActThr: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (0);
}
@@ -706,10 +806,12 @@ uint8_t SFE_MAX1704X::setHIBRTActThr(uint8_t threshold)
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("setHIBRTActThr: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (MAX17043_GENERIC_ERROR);
}
@@ -721,7 +823,7 @@ uint8_t SFE_MAX1704X::setHIBRTActThr(uint8_t threshold)
uint8_t SFE_MAX1704X::setHIBRTActThr(float threshold)
{
// LSb = 1.25mV
- uint8_t thresh = (uint8_t)(constrain(threshold, 0.0f, 0.31875f) / 0.00125f);
+ uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 0.31875) / 0.00125);
return setHIBRTActThr(thresh);
}
@@ -729,10 +831,12 @@ uint8_t SFE_MAX1704X::getHIBRTHibThr()
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("getHIBRTHibThr: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (0);
}
@@ -745,10 +849,12 @@ uint8_t SFE_MAX1704X::setHIBRTHibThr(uint8_t threshold)
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("setHIBRTHibThr: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (MAX17043_GENERIC_ERROR);
}
@@ -760,7 +866,7 @@ uint8_t SFE_MAX1704X::setHIBRTHibThr(uint8_t threshold)
uint8_t SFE_MAX1704X::setHIBRTHibThr(float threshold)
{
// LSb = 0.208%/hr
- uint8_t thresh = (uint8_t)(constrain(threshold, 0.0f, 53.04f) / 0.208f);
+ uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 53.04) / 0.208);
return setHIBRTHibThr(thresh);
}
@@ -768,10 +874,12 @@ uint8_t SFE_MAX1704X::enableHibernate()
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("enableHibernate: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (MAX17043_GENERIC_ERROR);
}
@@ -782,10 +890,12 @@ uint8_t SFE_MAX1704X::disableHibernate()
{
if (_device <= MAX1704X_MAX17044)
{
+ #if MAX1704X_ENABLE_DEBUGLOG
if (_printDebug == true)
{
_debugPort->println(F("disableHibernate: not supported on this device"));
}
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
return (MAX17043_GENERIC_ERROR);
}
@@ -806,18 +916,43 @@ uint8_t SFE_MAX1704X::write16(uint16_t data, uint8_t address)
uint16_t SFE_MAX1704X::read16(uint8_t address)
{
- uint8_t msb, lsb;
- int16_t timeout = 1000;
+ bool success = false;
+ uint8_t retries = 3;
+ uint16_t result = 0;
- _i2cPort->beginTransmission(MAX1704x_ADDRESS);
- _i2cPort->write(address);
- _i2cPort->endTransmission(false);
+ while ((success == false) && (retries > 0))
+ {
+ _i2cPort->beginTransmission(MAX1704x_ADDRESS);
+ _i2cPort->write(address);
+ _i2cPort->endTransmission(false); // Don't release the bus
- _i2cPort->requestFrom(MAX1704x_ADDRESS, 2);
- while ((_i2cPort->available() < 2) && (timeout-- > 0))
- delay(1);
- msb = _i2cPort->read();
- lsb = _i2cPort->read();
+ if (_i2cPort->requestFrom(MAX1704x_ADDRESS, 2) == 2)
+ {
+ uint8_t msb = _i2cPort->read();
+ uint8_t lsb = _i2cPort->read();
+ result = ((uint16_t)msb << 8) | lsb;
+ success = true;
+ }
+ else
+ {
+ retries--;
+ #if MAX1704X_ENABLE_DEBUGLOG
+ if (_printDebug == true)
+ {
+ _debugPort->println(F("SFE_MAX1704X::read16: retrying..."));
+ }
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
+ delay(50);
+ }
+ }
- return ((uint16_t)msb << 8) | lsb;
+ #if MAX1704X_ENABLE_DEBUGLOG
+ if (_printDebug == true)
+ {
+ if (!success)
+ _debugPort->println(F("SFE_MAX1704X::read16: failed to read data!"));
+ }
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
+
+ return (result);
}
diff --git a/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.h b/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.h
index 7e50d1745..3bb63073b 100644
--- a/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.h
+++ b/lib/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library/src/SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library.h
@@ -21,6 +21,10 @@ Distributed as-is; no warranty is given.
#ifndef MAX1704X_ARDUINO_LIBRARY_H
#define MAX1704X_ARDUINO_LIBRARY_H
+// Uncomment the next #define to EXclude any debug logging from the code, by default debug logging code will be included
+
+// #define MAX1704X_ENABLE_DEBUGLOG 0 // OFF/disabled/excluded on demand
+
#if (ARDUINO >= 100)
#include "Arduino.h"
#else
@@ -29,6 +33,15 @@ Distributed as-is; no warranty is given.
#include
+//Enable/disable including debug log (to allow saving some space)
+#ifndef MAX1704X_ENABLE_DEBUGLOG
+ #if defined(LIBRARIES_NO_LOG) && LIBRARIES_NO_LOG
+ #define MAX1704X_ENABLE_DEBUGLOG 0 // OFF/disabled/excluded on demand
+ #else
+ #define MAX1704X_ENABLE_DEBUGLOG 1 // ON/enabled/included by default
+ #endif
+#endif
+
//#include "application.h"
//////////////////////////
@@ -120,11 +133,17 @@ class SFE_MAX1704X
public:
SFE_MAX1704X(sfe_max1704x_devices_e device = MAX1704X_MAX17043); // Default to the 5V MAX17043
- // begin() - Initializes the MAX17043.
- boolean begin(TwoWire &wirePort = Wire); //Returns true if module is detected
+ // Change the device type if required. Do this after instantiation but before .begin
+ void setDevice(sfe_max1704x_devices_e device);
- //Returns true if device answers on MAX1704x_ADDRESS
- boolean isConnected(void);
+ // Allow _i2CPort to be set manually, so that isConnected can be called before .begin if required
+ void setWirePort(TwoWire &wirePort);
+
+ // begin() - Initializes the MAX17043.
+ bool begin(TwoWire &wirePort = Wire); //Returns true if module is detected
+
+ //Returns true if device is present
+ bool isConnected(void);
// Debug
void enableDebugging(Stream &debugPort = Serial); // enable debug messages
@@ -366,8 +385,10 @@ private:
//Variables
TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware
+ #if MAX1704X_ENABLE_DEBUGLOG
Stream *_debugPort; //The stream to send debug messages to if enabled. Usually Serial.
- boolean _printDebug = false; //Flag to print debugging variables
+ bool _printDebug = false; //Flag to print debugging variables
+ #endif // if MAX1704X_ENABLE_DEBUGLOG
// Clear the specified bit(s) in the MAX17048/49 status register
// This requires the bits in mask to be correctly aligned.
diff --git a/lib/SparkFun SCD4x Arduino Library/LICENSE.md b/lib/SparkFun_SCD4x_Arduino_Library/LICENSE.md
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/LICENSE.md
rename to lib/SparkFun_SCD4x_Arduino_Library/LICENSE.md
diff --git a/lib/SparkFun SCD4x Arduino Library/README.md b/lib/SparkFun_SCD4x_Arduino_Library/README.md
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/README.md
rename to lib/SparkFun_SCD4x_Arduino_Library/README.md
diff --git a/lib/SparkFun SCD4x Arduino Library/examples/Example1_BasicReadings/Example1_BasicReadings.ino b/lib/SparkFun_SCD4x_Arduino_Library/examples/Example1_BasicReadings/Example1_BasicReadings.ino
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/examples/Example1_BasicReadings/Example1_BasicReadings.ino
rename to lib/SparkFun_SCD4x_Arduino_Library/examples/Example1_BasicReadings/Example1_BasicReadings.ino
diff --git a/lib/SparkFun SCD4x Arduino Library/examples/Example2_LowPowerReadings/Example2_LowPowerReadings.ino b/lib/SparkFun_SCD4x_Arduino_Library/examples/Example2_LowPowerReadings/Example2_LowPowerReadings.ino
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/examples/Example2_LowPowerReadings/Example2_LowPowerReadings.ino
rename to lib/SparkFun_SCD4x_Arduino_Library/examples/Example2_LowPowerReadings/Example2_LowPowerReadings.ino
diff --git a/lib/SparkFun SCD4x Arduino Library/examples/Example3_DisableAutoCalibration/Example3_DisableAutoCalibration.ino b/lib/SparkFun_SCD4x_Arduino_Library/examples/Example3_DisableAutoCalibration/Example3_DisableAutoCalibration.ino
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/examples/Example3_DisableAutoCalibration/Example3_DisableAutoCalibration.ino
rename to lib/SparkFun_SCD4x_Arduino_Library/examples/Example3_DisableAutoCalibration/Example3_DisableAutoCalibration.ino
diff --git a/lib/SparkFun SCD4x Arduino Library/examples/Example4_SkipStopPeriodicMeasurement/Example4_SkipStopPeriodicMeasurement.ino b/lib/SparkFun_SCD4x_Arduino_Library/examples/Example4_SkipStopPeriodicMeasurement/Example4_SkipStopPeriodicMeasurement.ino
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/examples/Example4_SkipStopPeriodicMeasurement/Example4_SkipStopPeriodicMeasurement.ino
rename to lib/SparkFun_SCD4x_Arduino_Library/examples/Example4_SkipStopPeriodicMeasurement/Example4_SkipStopPeriodicMeasurement.ino
diff --git a/lib/SparkFun SCD4x Arduino Library/examples/Example5_AlternateWire/Example5_AlternateWire.ino b/lib/SparkFun_SCD4x_Arduino_Library/examples/Example5_AlternateWire/Example5_AlternateWire.ino
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/examples/Example5_AlternateWire/Example5_AlternateWire.ino
rename to lib/SparkFun_SCD4x_Arduino_Library/examples/Example5_AlternateWire/Example5_AlternateWire.ino
diff --git a/lib/SparkFun SCD4x Arduino Library/examples/Example6_SignalCompensation/Example6_SignalCompensation.ino b/lib/SparkFun_SCD4x_Arduino_Library/examples/Example6_SignalCompensation/Example6_SignalCompensation.ino
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/examples/Example6_SignalCompensation/Example6_SignalCompensation.ino
rename to lib/SparkFun_SCD4x_Arduino_Library/examples/Example6_SignalCompensation/Example6_SignalCompensation.ino
diff --git a/lib/SparkFun SCD4x Arduino Library/examples/Example7_SelfTest_FactoryReset/Example7_SelfTest_FactoryReset.ino b/lib/SparkFun_SCD4x_Arduino_Library/examples/Example7_SelfTest_FactoryReset/Example7_SelfTest_FactoryReset.ino
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/examples/Example7_SelfTest_FactoryReset/Example7_SelfTest_FactoryReset.ino
rename to lib/SparkFun_SCD4x_Arduino_Library/examples/Example7_SelfTest_FactoryReset/Example7_SelfTest_FactoryReset.ino
diff --git a/lib/SparkFun SCD4x Arduino Library/examples/Example8_SCD41SingleShot/Example8_SCD41SingleShot.ino b/lib/SparkFun_SCD4x_Arduino_Library/examples/Example8_SCD41SingleShot/Example8_SCD41SingleShot.ino
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/examples/Example8_SCD41SingleShot/Example8_SCD41SingleShot.ino
rename to lib/SparkFun_SCD4x_Arduino_Library/examples/Example8_SCD41SingleShot/Example8_SCD41SingleShot.ino
diff --git a/lib/SparkFun SCD4x Arduino Library/keywords.txt b/lib/SparkFun_SCD4x_Arduino_Library/keywords.txt
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/keywords.txt
rename to lib/SparkFun_SCD4x_Arduino_Library/keywords.txt
diff --git a/lib/SparkFun SCD4x Arduino Library/library.properties b/lib/SparkFun_SCD4x_Arduino_Library/library.properties
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/library.properties
rename to lib/SparkFun_SCD4x_Arduino_Library/library.properties
diff --git a/lib/SparkFun SCD4x Arduino Library/src/SparkFun_SCD4x_Arduino_Library.cpp b/lib/SparkFun_SCD4x_Arduino_Library/src/SparkFun_SCD4x_Arduino_Library.cpp
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/src/SparkFun_SCD4x_Arduino_Library.cpp
rename to lib/SparkFun_SCD4x_Arduino_Library/src/SparkFun_SCD4x_Arduino_Library.cpp
diff --git a/lib/SparkFun SCD4x Arduino Library/src/SparkFun_SCD4x_Arduino_Library.h b/lib/SparkFun_SCD4x_Arduino_Library/src/SparkFun_SCD4x_Arduino_Library.h
similarity index 100%
rename from lib/SparkFun SCD4x Arduino Library/src/SparkFun_SCD4x_Arduino_Library.h
rename to lib/SparkFun_SCD4x_Arduino_Library/src/SparkFun_SCD4x_Arduino_Library.h