forked from Makuna/NeoPixelBus
@@ -19,6 +19,7 @@ HtmlColor KEYWORD1
|
||||
NeoNoSettings KEYWORD1
|
||||
NeoTm1814Settings KEYWORD1
|
||||
NeoTm1914Settings KEYWORD1
|
||||
NeoSm168xxSettings KEYWORD1
|
||||
NeoSpiSettings KEYWORD1
|
||||
NeoGrbFeature KEYWORD1
|
||||
NeoGrbwFeature KEYWORD1
|
||||
@@ -34,6 +35,7 @@ NeoRgbwUcs8904Feature KEYWORD1
|
||||
NeoWrgbTm1814Feature KEYWORD1
|
||||
NeoRgbTm1914Feature KEYWORD1
|
||||
NeoGrbTm1914Feature KEYWORD1
|
||||
NeoRgbwSm168xxFeature KEYWORD1
|
||||
DotStarBgrFeature KEYWORD1
|
||||
DotStarLbgrFeature KEYWORD1
|
||||
Lpd6803GrbFeature KEYWORD1
|
||||
|
@@ -66,6 +66,7 @@ License along with NeoPixel. If not, see
|
||||
#include "internal/NeoColorFeatures.h"
|
||||
#include "internal/NeoTm1814ColorFeatures.h"
|
||||
#include "internal/NeoTm1914ColorFeatures.h"
|
||||
#include "internal/NeoSm168xxColorFeatures.h"
|
||||
#include "internal/DotStarColorFeatures.h"
|
||||
#include "internal/Lpd8806ColorFeatures.h"
|
||||
#include "internal/Lpd6803ColorFeatures.h"
|
||||
|
@@ -224,7 +224,7 @@ public:
|
||||
return _sizePixelData;
|
||||
};
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
_speed.applySettings(settings);
|
||||
if (_spiHandle)
|
||||
|
@@ -114,7 +114,7 @@ public:
|
||||
return _sizeData;
|
||||
};
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
_wire.applySettings(settings);
|
||||
}
|
||||
|
@@ -110,7 +110,7 @@ public:
|
||||
return _sizeData;
|
||||
};
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
_wire.applySettings(settings);
|
||||
}
|
||||
|
@@ -110,7 +110,7 @@ public:
|
||||
return _sizeData;
|
||||
};
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
_wire.applySettings(settings);
|
||||
}
|
||||
|
@@ -101,7 +101,7 @@ public:
|
||||
return _sizeData;
|
||||
};
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -197,7 +197,7 @@ public:
|
||||
return _sizeData;
|
||||
};
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -217,7 +217,7 @@ public:
|
||||
return _sizeData;
|
||||
}
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -597,7 +597,7 @@ public:
|
||||
return _sizeData;
|
||||
}
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -499,7 +499,7 @@ public:
|
||||
return _sizeData;
|
||||
}
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -406,7 +406,7 @@ public:
|
||||
return this->_sizeData;
|
||||
};
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -410,7 +410,7 @@ public:
|
||||
return _sizeData;
|
||||
};
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
|
128
src/internal/NeoSm168xxColorFeatures.h
Normal file
128
src/internal/NeoSm168xxColorFeatures.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
NeoSm168xxColorFeatures provides feature classes to describe color order and
|
||||
color depth for NeoPixelBus template class specific to the SM1680 chip
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus 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.
|
||||
|
||||
NeoPixelBus 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
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class NeoSm168xxSettings : public NeoRgbwCurrentSettings
|
||||
{
|
||||
public:
|
||||
NeoSm168xxSettings(uint16_t red, uint16_t green, uint16_t blue, uint16_t white) :
|
||||
NeoRgbwCurrentSettings(red, green, blue, white)
|
||||
{
|
||||
}
|
||||
|
||||
const static uint16_t MinCurrent = 60;
|
||||
const static uint16_t MaxCurrent = 350;
|
||||
|
||||
static uint16_t LimitCurrent(uint16_t value)
|
||||
{
|
||||
if (value < MinCurrent)
|
||||
{
|
||||
value = MinCurrent;
|
||||
}
|
||||
else if (value > MaxCurrent)
|
||||
{
|
||||
value = MaxCurrent;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
class Neo4ByteElementsSm168xxSettings : public Neo4ByteElements
|
||||
{
|
||||
private:
|
||||
const static uint16_t EncodeDivisor = 19;
|
||||
|
||||
public:
|
||||
typedef NeoSm168xxSettings SettingsObject;
|
||||
static const size_t SettingsSize = 2;
|
||||
|
||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
// settings are at the end of the data stream
|
||||
uint8_t* pSet = pData + sizeData - SettingsSize;
|
||||
|
||||
// four bits per element in RGBW order
|
||||
*pSet++ = ((SettingsObject::LimitCurrent(settings.RedTenthMilliAmpere) - SettingsObject::MinCurrent) / EncodeDivisor) << 4 |
|
||||
((SettingsObject::LimitCurrent(settings.GreenTenthMilliAmpere) - SettingsObject::MinCurrent) / EncodeDivisor);
|
||||
*pSet++ = ((SettingsObject::LimitCurrent(settings.BlueTenthMilliAmpere) - SettingsObject::MinCurrent) / EncodeDivisor) << 4 |
|
||||
((SettingsObject::LimitCurrent(settings.WhiteCurrent) - SettingsObject::MinCurrent) / EncodeDivisor);
|
||||
|
||||
}
|
||||
|
||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
|
||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class NeoRgbwSm168xxFeature : public Neo4ByteElementsSm168xxSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
{
|
||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||
|
||||
*p++ = color.R;
|
||||
*p++ = color.G;
|
||||
*p++ = color.B;
|
||||
*p = color.W;
|
||||
}
|
||||
|
||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
ColorObject color;
|
||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||
|
||||
color.R = *p++;
|
||||
color.G = *p++;
|
||||
color.B = *p++;
|
||||
color.W = *p;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||
{
|
||||
ColorObject color;
|
||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||
|
||||
color.R = pgm_read_byte(p++);
|
||||
color.G = pgm_read_byte(p++);
|
||||
color.B = pgm_read_byte(p++);
|
||||
color.W = pgm_read_byte(p);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
};
|
||||
|
@@ -53,19 +53,23 @@ public:
|
||||
|
||||
class Neo4ByteElementsTm1814Settings : public Neo4ByteElements
|
||||
{
|
||||
private:
|
||||
const static uint16_t EncodeDivisor = 5;
|
||||
|
||||
public:
|
||||
typedef NeoTm1814Settings SettingsObject;
|
||||
static const size_t SettingsSize = 8;
|
||||
|
||||
static void applySettings(uint8_t* pData, const SettingsObject& settings)
|
||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
// settings are at the front of the data stream
|
||||
uint8_t* pSet = pData;
|
||||
|
||||
// C1
|
||||
*pSet++ = (SettingsObject::LimitCurrent(settings.WhiteCurrent) - SettingsObject::MinCurrent) / 5;
|
||||
*pSet++ = (SettingsObject::LimitCurrent(settings.RedTenthMilliAmpere) - SettingsObject::MinCurrent) / 5;
|
||||
*pSet++ = (SettingsObject::LimitCurrent(settings.GreenTenthMilliAmpere) - SettingsObject::MinCurrent) / 5;
|
||||
*pSet++ = (SettingsObject::LimitCurrent(settings.BlueTenthMilliAmpere) - SettingsObject::MinCurrent) / 5;
|
||||
*pSet++ = (SettingsObject::LimitCurrent(settings.WhiteCurrent) - SettingsObject::MinCurrent) / EncodeDivisor;
|
||||
*pSet++ = (SettingsObject::LimitCurrent(settings.RedTenthMilliAmpere) - SettingsObject::MinCurrent) / EncodeDivisor;
|
||||
*pSet++ = (SettingsObject::LimitCurrent(settings.GreenTenthMilliAmpere) - SettingsObject::MinCurrent) / EncodeDivisor;
|
||||
*pSet++ = (SettingsObject::LimitCurrent(settings.BlueTenthMilliAmpere) - SettingsObject::MinCurrent) / EncodeDivisor;
|
||||
|
||||
uint8_t* pC1 = pData;
|
||||
|
||||
@@ -78,11 +82,13 @@ public:
|
||||
|
||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
// settings are at the front of the data stream
|
||||
return pData + SettingsSize;
|
||||
}
|
||||
|
||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
// settings are at the front of the data stream
|
||||
return pData + SettingsSize;
|
||||
}
|
||||
};
|
||||
|
@@ -52,6 +52,7 @@ public:
|
||||
|
||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
// settings are at the front of the data stream
|
||||
uint8_t* pSet = pData;
|
||||
uint8_t mode = 0xff;
|
||||
|
||||
@@ -86,11 +87,13 @@ public:
|
||||
|
||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
// settings are at the front of the data stream
|
||||
return pData + SettingsSize;
|
||||
}
|
||||
|
||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
// settings are at the front of the data stream
|
||||
return pData + SettingsSize;
|
||||
}
|
||||
};
|
||||
|
@@ -106,7 +106,7 @@ public:
|
||||
return _sizeData;
|
||||
};
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
_wire.applySettings(settings);
|
||||
}
|
||||
|
@@ -45,9 +45,12 @@ public:
|
||||
// Write 2 channels into 3 bytes scaling 8-bit to 12-bit per channel
|
||||
for (int indexChannel = 0; indexChannel < TLC5947_MODULE_PWM_CHANNEL_COUNT; indexChannel += 2)
|
||||
{
|
||||
*sendBufferPtr++ = *channelPtr;
|
||||
*sendBufferPtr++ = (*channelPtr-- & 0xf0) | (*channelPtr >> 4);
|
||||
*sendBufferPtr++ = ((*channelPtr << 4) & 0xf0) | (*channelPtr-- >> 4);
|
||||
uint8_t ch1 = *channelPtr--;
|
||||
uint8_t ch2 = *channelPtr--;
|
||||
|
||||
*sendBufferPtr++ = ch1;
|
||||
*sendBufferPtr++ = (ch1 & 0xf0) | (ch2 >> 4);
|
||||
*sendBufferPtr++ = ((ch2 << 4) & 0xf0) | (ch2 >> 4);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -63,9 +66,12 @@ public:
|
||||
// Write 2 channels into 3 bytes using upper 12-bit of each channel
|
||||
for (int indexChannel = 0; indexChannel < TLC5947_MODULE_PWM_CHANNEL_COUNT; indexChannel += 2)
|
||||
{
|
||||
*sendBufferPtr++ = *channelPtr >> 8;
|
||||
*sendBufferPtr++ = (*channelPtr-- & 0xf0) | (*channelPtr >> 12);
|
||||
*sendBufferPtr++ = *channelPtr-- >> 4;
|
||||
uint8_t ch1 = *channelPtr--;
|
||||
uint8_t ch2 = *channelPtr--;
|
||||
|
||||
*sendBufferPtr++ = ch1 >> 8;
|
||||
*sendBufferPtr++ = (ch1 & 0xf0) | (ch2 >> 12);
|
||||
*sendBufferPtr++ = ch2 >> 4;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -168,7 +174,7 @@ public:
|
||||
return _sizeData;
|
||||
};
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
_wire.applySettings(settings);
|
||||
}
|
||||
|
@@ -103,7 +103,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,7 @@ public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
SpiSpeed40Mhz() {};
|
||||
|
||||
static void applySettings(const SettingsObject& settings) {}
|
||||
static void applySettings([[maybe_unused]] const SettingsObject& settings) {}
|
||||
|
||||
static const uint32_t Clock = 40000000L;
|
||||
};
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
SpiSpeed30Mhz() {};
|
||||
|
||||
static void applySettings(const SettingsObject& settings) {}
|
||||
static void applySettings([[maybe_unused]] const SettingsObject& settings) {}
|
||||
|
||||
static const uint32_t Clock = 30000000L;
|
||||
};
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
SpiSpeed20Mhz() {};
|
||||
|
||||
static void applySettings(const SettingsObject& settings) {}
|
||||
static void applySettings([[maybe_unused]] const SettingsObject& settings) {}
|
||||
|
||||
static const uint32_t Clock = 20000000L;
|
||||
};
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
SpiSpeed15Mhz() {};
|
||||
|
||||
static void applySettings(const SettingsObject& settings) {}
|
||||
static void applySettings([[maybe_unused]] const SettingsObject& settings) {}
|
||||
|
||||
static const uint32_t Clock = 15000000L;
|
||||
};
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
SpiSpeed10Mhz() {};
|
||||
|
||||
static void applySettings(const SettingsObject& settings) {}
|
||||
static void applySettings([[maybe_unused]] const SettingsObject& settings) {}
|
||||
|
||||
static const uint32_t Clock = 10000000L;
|
||||
};
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
SpiSpeed5Mhz() {};
|
||||
|
||||
static void applySettings(const SettingsObject& settings) {}
|
||||
static void applySettings([[maybe_unused]] const SettingsObject& settings) {}
|
||||
|
||||
static const uint32_t Clock = 5000000L;
|
||||
};
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
SpiSpeed2Mhz() {};
|
||||
|
||||
static void applySettings(const SettingsObject& settings) {}
|
||||
static void applySettings([[maybe_unused]] const SettingsObject& settings) {}
|
||||
|
||||
static const uint32_t Clock = 2000000L;
|
||||
};
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
SpiSpeed1Mhz() {};
|
||||
|
||||
static void applySettings(const SettingsObject& settings) {}
|
||||
static void applySettings([[maybe_unused]] const SettingsObject& settings) {}
|
||||
|
||||
static const uint32_t Clock = 1000000L;
|
||||
};
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
SpiSpeed500Khz() {};
|
||||
|
||||
static void applySettings(const SettingsObject& settings) {}
|
||||
static void applySettings([[maybe_unused]] const SettingsObject& settings) {}
|
||||
|
||||
static const uint32_t Clock = 500000L;
|
||||
};
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
Clock(10000000)
|
||||
{};
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
Clock = settings.Clock;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
void applySettings(const SettingsObject& settings)
|
||||
void applySettings([[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
_speed.applySettings(settings);
|
||||
}
|
||||
|
Reference in New Issue
Block a user