Comparing the guts of loops between C style loops and C++ ranged loops:
Right now - the runtime of this:
CRGBArray<100> leds;
...
for(CRGB & pixel : leds) { pixel = CRGB::Black; }
#include <FastLED.h> | |
#define NUM_LEDS 60 | |
// how many frames per second you want your animation to be. Your total | |
// update rate will be ANIM_FPS * STEPS | |
#define ANIM_FPS 30 | |
// the number of steps you want between each frame - should be a power | |
// of 2 to keep things sane - e.g. 2,4,8,16,32,64 |
#include "FastLED.h" | |
#include <SPI.h> | |
#define NumPixels 1500 // number of LEDs in strip - count starts at 0, not 1 | |
#define Datapin 11 // datapin - green on apa102 | |
#define Clockpin 13 // clockpin - blue on apa102 | |
#define DataRate_Mhz 15 | |
CRGB leds[NumPixels]; | |
int g, r, b, z; | |
int head=-1, tail=(head-6); |
#include "FastLED.h" | |
template <EOrder RGB_ORDER=RGB> | |
class NetworkWriteController : public CPixelLEDController<RGB_ORDER> { | |
public: | |
public NetworkWriteController() { | |
// TODO: Modify the constructor to take other options that you might want/need (esp8266 ip | |
// address? etc...) | |
} | |
Comparing the guts of loops between C style loops and C++ ranged loops:
Right now - the runtime of this:
CRGBArray<100> leds;
...
for(CRGB & pixel : leds) { pixel = CRGB::Black; }
#ifndef FASTDELEGATE_H | |
#define FASTDELEGATE_H | |
#include <cstring> | |
#include <type_traits> | |
#include <cassert> | |
#include <cstddef> | |
#include <memory> | |
#include <new> | |
#include <utility> |
<?xml version="1.0"?> | |
<!-- private.xml definition for Karabiner - https://pqrs.org/osx/karabiner/index.html.en --> | |
<root> | |
<inputsourcedef> | |
<name>MY_RUSSIAN</name> | |
<inputsourceid_prefix>com.apple.keylayout.Russian</inputsourceid_prefix> | |
</inputsourcedef> | |
<inputsourcedef> | |
<name>MY_ENGLISH</name> |
I hereby claim:
To claim this, I am signing this object:
FastLED is about more than just pushing data out to leds as quickly as possible. It is also about providing the fastest supporting function (math, color maniuplation, etc...) while still remaining accurate. Mark has done an amazing job with many of the math functions, including fast trig functions that are ~98% accurate, and the core of the scaling functions. These scaling functions are what allow us to do things like the non-destructive, 0 overhead scaling and color adjustments in the library.
The basic scaling function in FastLED is scale8. It lets you scale an 8-bit value by another 8-bit value. It's a percentage of sorts, but from 0-255 instead of 0-100. So, for example, scale8(64,128) will give you 32. Scaling is something that gets used a lot in led work, so it is important that it be fast. The C version of scale8 takes advantage of some properties of binary math to do it's magic (while avoiding division), let's take a look:
uint8_t scale8(uint8_t i, fract8 s
A quick lesson in performance tuning. In the arduino code base, people will often use Serial.parseInt to read integer data from a Serial stream, and someone was asking me about the overhead involved. So, I decided to take a look for them. First, I looked at the implementation of parseInt:
long Stream::parseInt()
{
return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout)
}
Ok, so it calls through to another function, adding a skip character that means "no skip character". Here's a first red flag. So, let's look at that function:
template <uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER = BGR, uint8_t SPI_SPEED = DATA_RATE_MHZ(24)> | |
class APA102VController : public CLEDController { | |
typedef SPIOutput<DATA_PIN, CLOCK_PIN, SPI_SPEED> SPI; | |
SPI mSPI; | |
void startBoundary() { mSPI.writeWord(0); mSPI.writeWord(0); } | |
void endBoundary(int nLeds) { int nBytes = (nLeds/64); do { mSPI.writeByte(0xFF); mSPI.writeByte(0x00); mSPI.writeByte(0x00); mSPI.writeByte(0x00); } while(nBytes--); } | |
inline void writeLed(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t v) __attribute__((always_inline)) { | |
mSPI.writeByte(0xE0 | (v&0x1F)); mSPI.writeByte(b0); mSPI.writeByte(b1); mSPI.writeByte(b2); |