forked from Makuna/NeoPixelBus
@@ -32,7 +32,7 @@ NeoPixelAnimator animations(Animation_COUNT);
|
|||||||
void CycleAnimation(const AnimationParam& param)
|
void CycleAnimation(const AnimationParam& param)
|
||||||
{
|
{
|
||||||
// calculate which segment should be on using the animation progress
|
// calculate which segment should be on using the animation progress
|
||||||
uint8_t bitfield = 1 << ( (uint8_t)(param.progress * LedSegment_G) % LedSegment_G);
|
uint8_t bitfield = 1 << ( static_cast<uint8_t>(param.progress * LedSegment_G) % LedSegment_G);
|
||||||
// instant a digit with that segment on
|
// instant a digit with that segment on
|
||||||
SevenSegDigit digit(bitfield, brightness);
|
SevenSegDigit digit(bitfield, brightness);
|
||||||
// apply it to the strip
|
// apply it to the strip
|
||||||
|
@@ -88,7 +88,7 @@ public:
|
|||||||
// Only update if there is a change
|
// Only update if there is a change
|
||||||
if (brightness != _brightness)
|
if (brightness != _brightness)
|
||||||
{
|
{
|
||||||
uint16_t scale = (((uint16_t)brightness + 1) << 8) / ((uint16_t)_brightness + 1);
|
uint16_t scale = ((static_cast<uint16_t>(brightness) + 1) << 8) / (static_cast<uint16_t>(_brightness) + 1);
|
||||||
|
|
||||||
// scale existing pixels
|
// scale existing pixels
|
||||||
//
|
//
|
||||||
|
@@ -90,7 +90,7 @@ struct HtmlColor
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
HtmlColor(const RgbColor& color)
|
HtmlColor(const RgbColor& color)
|
||||||
{
|
{
|
||||||
Color = (uint32_t)color.R << 16 | (uint32_t)color.G << 8 | (uint32_t)color.B;
|
Color = static_cast<uint32_t>(color.R) << 16 | static_cast<uint32_t>(color.G) << 8 | static_cast<uint32_t>(color.B);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
@@ -709,9 +709,9 @@ typedef NeoArm800KbpsMethod NeoArmApa106Method;
|
|||||||
class NeoArmOtherSpeedProps800KbpsBase
|
class NeoArmOtherSpeedProps800KbpsBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const uint32_t CyclesT0h = ((uint32_t)(0.40 * ARM_OTHER_SCALE + 0.5) - (5 * ARM_OTHER_INST));
|
static const uint32_t CyclesT0h = static_cast<uint32_t>((0.40 * ARM_OTHER_SCALE + 0.5) - (5 * ARM_OTHER_INST));
|
||||||
static const uint32_t CyclesT1h = ((uint32_t)(0.80 * ARM_OTHER_SCALE + 0.5) - (5 * ARM_OTHER_INST));
|
static const uint32_t CyclesT1h = static_cast<uint32_t>((0.80 * ARM_OTHER_SCALE + 0.5) - (5 * ARM_OTHER_INST));
|
||||||
static const uint32_t Cycles = ((uint32_t)(1.25 * ARM_OTHER_SCALE + 0.5) - (5 * ARM_OTHER_INST));
|
static const uint32_t Cycles = static_cast<uint32_t>((1.25 * ARM_OTHER_SCALE + 0.5) - (5 * ARM_OTHER_INST));
|
||||||
};
|
};
|
||||||
|
|
||||||
class NeoArmOtherSpeedPropsWs2812x : public NeoArmOtherSpeedProps800KbpsBase
|
class NeoArmOtherSpeedPropsWs2812x : public NeoArmOtherSpeedProps800KbpsBase
|
||||||
@@ -747,9 +747,9 @@ public:
|
|||||||
class NeoArmOtherSpeedProps400Kbps
|
class NeoArmOtherSpeedProps400Kbps
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const uint32_t CyclesT0h = ((uint32_t)(0.50 * ARM_OTHER_SCALE + 0.5) - (5 * ARM_OTHER_INST));
|
static const uint32_t CyclesT0h = static_cast<uint32_t>((0.50 * ARM_OTHER_SCALE + 0.5) - (5 * ARM_OTHER_INST));
|
||||||
static const uint32_t CyclesT1h = ((uint32_t)(1.20 * ARM_OTHER_SCALE + 0.5) - (5 * ARM_OTHER_INST));
|
static const uint32_t CyclesT1h = static_cast<uint32_t>((1.20 * ARM_OTHER_SCALE + 0.5) - (5 * ARM_OTHER_INST));
|
||||||
static const uint32_t Cycles = ((uint32_t)(2.50 * ARM_OTHER_SCALE + 0.5) - (5 * ARM_OTHER_INST));
|
static const uint32_t Cycles = static_cast<uint32_t>((2.50 * ARM_OTHER_SCALE + 0.5) - (5 * ARM_OTHER_INST));
|
||||||
static const uint32_t ResetTimeUs = 50;
|
static const uint32_t ResetTimeUs = 50;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -773,7 +773,7 @@ public:
|
|||||||
uint8_t mask;
|
uint8_t mask;
|
||||||
|
|
||||||
pmc_set_writeprotect(false);
|
pmc_set_writeprotect(false);
|
||||||
pmc_enable_periph_clk((uint32_t)TC3_IRQn);
|
pmc_enable_periph_clk(static_cast<uint32_t>(TC3_IRQn));
|
||||||
|
|
||||||
TC_Configure(TC1, 0,
|
TC_Configure(TC1, 0,
|
||||||
TC_CMR_WAVE | TC_CMR_WAVSEL_UP | TC_CMR_TCCLKS_TIMER_CLOCK1);
|
TC_CMR_WAVE | TC_CMR_WAVSEL_UP | TC_CMR_TCCLKS_TIMER_CLOCK1);
|
||||||
|
@@ -206,7 +206,7 @@ public:
|
|||||||
{
|
{
|
||||||
for (int16_t x = 0; x < wSrc && indexPixel < destPixelCount; x++, indexPixel++)
|
for (int16_t x = 0; x < wSrc && indexPixel < destPixelCount; x++, indexPixel++)
|
||||||
{
|
{
|
||||||
if ((uint16_t)xSrc < _width)
|
if (static_cast<uint16_t>(xSrc) < _width)
|
||||||
{
|
{
|
||||||
if (readPixel(&color))
|
if (readPixel(&color))
|
||||||
{
|
{
|
||||||
@@ -255,7 +255,7 @@ public:
|
|||||||
{
|
{
|
||||||
uint16_t indexDest = layoutMap(xDest + x, yDest + y);
|
uint16_t indexDest = layoutMap(xDest + x, yDest + y);
|
||||||
|
|
||||||
if ((uint16_t)xFile < _width)
|
if (static_cast<uint16_t>(xFile) < _width)
|
||||||
{
|
{
|
||||||
if (readPixel(&color))
|
if (readPixel(&color))
|
||||||
{
|
{
|
||||||
@@ -311,7 +311,7 @@ private:
|
|||||||
{
|
{
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
else if ((uint16_t)x >= _width)
|
else if (static_cast<uint16_t>(x) >= _width)
|
||||||
{
|
{
|
||||||
x = _width - 1;
|
x = _width - 1;
|
||||||
}
|
}
|
||||||
@@ -324,7 +324,7 @@ private:
|
|||||||
{
|
{
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
else if ((uint16_t)y >= _height)
|
else if (static_cast<uint16_t>(y) >= _height)
|
||||||
{
|
{
|
||||||
y = _height - 1;
|
y = _height - 1;
|
||||||
}
|
}
|
||||||
|
@@ -162,9 +162,9 @@ private:
|
|||||||
uint16_t result = PixelIndex_OutOfBounds;
|
uint16_t result = PixelIndex_OutOfBounds;
|
||||||
|
|
||||||
if (x >= 0 &&
|
if (x >= 0 &&
|
||||||
(uint16_t)x < Width() &&
|
static_cast<uint16_t>(x) < Width() &&
|
||||||
y >= 0 &&
|
y >= 0 &&
|
||||||
(uint16_t)y < Height())
|
static_cast<uint16_t>(y) < Height())
|
||||||
{
|
{
|
||||||
result = x + y * Width();
|
result = x + y * Width();
|
||||||
}
|
}
|
||||||
|
@@ -314,9 +314,9 @@ public:
|
|||||||
_i2sBufDesc[indexDesc].sub_sof = 0;
|
_i2sBufDesc[indexDesc].sub_sof = 0;
|
||||||
_i2sBufDesc[indexDesc].datalen = blockSize;
|
_i2sBufDesc[indexDesc].datalen = blockSize;
|
||||||
_i2sBufDesc[indexDesc].blocksize = blockSize;
|
_i2sBufDesc[indexDesc].blocksize = blockSize;
|
||||||
_i2sBufDesc[indexDesc].buf_ptr = (uint32_t)is2Buffer;
|
_i2sBufDesc[indexDesc].buf_ptr = reinterpret_cast<uint32_t>(is2Buffer);
|
||||||
_i2sBufDesc[indexDesc].unused = 0;
|
_i2sBufDesc[indexDesc].unused = 0;
|
||||||
_i2sBufDesc[indexDesc].next_link_ptr = (uint32_t)&(_i2sBufDesc[indexDesc + 1]);
|
_i2sBufDesc[indexDesc].next_link_ptr = reinterpret_cast<uint32_t>(&(_i2sBufDesc[indexDesc + 1]));
|
||||||
|
|
||||||
is2Buffer += blockSize;
|
is2Buffer += blockSize;
|
||||||
is2BufferSize -= blockSize;
|
is2BufferSize -= blockSize;
|
||||||
@@ -330,15 +330,15 @@ public:
|
|||||||
_i2sBufDesc[indexDesc].sub_sof = 0;
|
_i2sBufDesc[indexDesc].sub_sof = 0;
|
||||||
_i2sBufDesc[indexDesc].datalen = sizeof(_i2sZeroes);
|
_i2sBufDesc[indexDesc].datalen = sizeof(_i2sZeroes);
|
||||||
_i2sBufDesc[indexDesc].blocksize = sizeof(_i2sZeroes);
|
_i2sBufDesc[indexDesc].blocksize = sizeof(_i2sZeroes);
|
||||||
_i2sBufDesc[indexDesc].buf_ptr = (uint32_t)_i2sZeroes;
|
_i2sBufDesc[indexDesc].buf_ptr = reinterpret_cast<uint32_t>(_i2sZeroes);
|
||||||
_i2sBufDesc[indexDesc].unused = 0;
|
_i2sBufDesc[indexDesc].unused = 0;
|
||||||
_i2sBufDesc[indexDesc].next_link_ptr = (uint32_t)&(_i2sBufDesc[indexDesc + 1]);
|
_i2sBufDesc[indexDesc].next_link_ptr = reinterpret_cast<uint32_t>(&(_i2sBufDesc[indexDesc + 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// the first state block will trigger the interrupt
|
// the first state block will trigger the interrupt
|
||||||
_i2sBufDesc[indexDesc - 2].eof = 1;
|
_i2sBufDesc[indexDesc - 2].eof = 1;
|
||||||
// the last state block will loop to the first state block by defualt
|
// the last state block will loop to the first state block by defualt
|
||||||
_i2sBufDesc[indexDesc - 1].next_link_ptr = (uint32_t)&(_i2sBufDesc[indexDesc - 2]);
|
_i2sBufDesc[indexDesc - 1].next_link_ptr = reinterpret_cast<uint32_t>(&(_i2sBufDesc[indexDesc - 2]));
|
||||||
|
|
||||||
// setup the rest of i2s DMA
|
// setup the rest of i2s DMA
|
||||||
//
|
//
|
||||||
@@ -476,7 +476,7 @@ private:
|
|||||||
|
|
||||||
// data block has pending data waiting to send, prepare it
|
// data block has pending data waiting to send, prepare it
|
||||||
// point last state block to top
|
// point last state block to top
|
||||||
(finished_item + 1)->next_link_ptr = (uint32_t)(s_this->_i2sBufDesc);
|
(finished_item + 1)->next_link_ptr = reinterpret_cast<uint32_t>(s_this->_i2sBufDesc);
|
||||||
|
|
||||||
s_this->_dmaState = NeoDmaState_Sending;
|
s_this->_dmaState = NeoDmaState_Sending;
|
||||||
}
|
}
|
||||||
@@ -489,7 +489,7 @@ private:
|
|||||||
// the data block had actual data sent
|
// the data block had actual data sent
|
||||||
// point last state block to first state block thus
|
// point last state block to first state block thus
|
||||||
// just looping and not sending the data blocks
|
// just looping and not sending the data blocks
|
||||||
(finished_item + 1)->next_link_ptr = (uint32_t)(finished_item);
|
(finished_item + 1)->next_link_ptr = reinterpret_cast<uint32_t>(finished_item);
|
||||||
|
|
||||||
s_this->_dmaState = NeoDmaState_Zeroing;
|
s_this->_dmaState = NeoDmaState_Zeroing;
|
||||||
}
|
}
|
||||||
|
@@ -152,9 +152,9 @@ private:
|
|||||||
|
|
||||||
if (indexSprite < _spriteCount &&
|
if (indexSprite < _spriteCount &&
|
||||||
x >= 0 &&
|
x >= 0 &&
|
||||||
(uint16_t)x < SpriteWidth() &&
|
static_cast<uint16_t>(x) < SpriteWidth() &&
|
||||||
y >= 0 &&
|
y >= 0 &&
|
||||||
(uint16_t)y < SpriteHeight())
|
static_cast<uint16_t>(y) < SpriteHeight())
|
||||||
{
|
{
|
||||||
result = x + y * SpriteWidth() + indexSprite * _spriteHeight * SpriteWidth();
|
result = x + y * SpriteWidth() + indexSprite * _spriteHeight * SpriteWidth();
|
||||||
}
|
}
|
||||||
|
@@ -49,9 +49,9 @@ Rgb48Color::Rgb48Color(const HslColor& color)
|
|||||||
|
|
||||||
_HslToRgb(color, &r, &g, &b);
|
_HslToRgb(color, &r, &g, &b);
|
||||||
|
|
||||||
R = (uint16_t)(r * Max);
|
R = static_cast<uint16_t>(r * Max);
|
||||||
G = (uint16_t)(g * Max);
|
G = static_cast<uint16_t>(g * Max);
|
||||||
B = (uint16_t)(b * Max);
|
B = static_cast<uint16_t>(b * Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rgb48Color::Rgb48Color(const HsbColor& color)
|
Rgb48Color::Rgb48Color(const HsbColor& color)
|
||||||
@@ -62,14 +62,14 @@ Rgb48Color::Rgb48Color(const HsbColor& color)
|
|||||||
|
|
||||||
_HsbToRgb(color, &r, &g, &b);
|
_HsbToRgb(color, &r, &g, &b);
|
||||||
|
|
||||||
R = (uint16_t)(r * Max);
|
R = static_cast<uint16_t>(r * Max);
|
||||||
G = (uint16_t)(g * Max);
|
G = static_cast<uint16_t>(g * Max);
|
||||||
B = (uint16_t)(b * Max);
|
B = static_cast<uint16_t>(b * Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Rgb48Color::CalculateBrightness() const
|
uint16_t Rgb48Color::CalculateBrightness() const
|
||||||
{
|
{
|
||||||
return (uint16_t)(((uint32_t)R + (uint32_t)G + (uint32_t)B) / 3);
|
return static_cast<uint16_t>((static_cast<uint32_t>(R) + static_cast<uint32_t>(G) + static_cast<uint32_t>(B)) / 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rgb48Color Rgb48Color::Dim(uint16_t ratio) const
|
Rgb48Color Rgb48Color::Dim(uint16_t ratio) const
|
||||||
|
@@ -65,9 +65,9 @@ RgbColor::RgbColor(const HslColor& color)
|
|||||||
|
|
||||||
_HslToRgb(color, &r, &g, &b);
|
_HslToRgb(color, &r, &g, &b);
|
||||||
|
|
||||||
R = (uint8_t)(r * Max);
|
R = static_cast<uint8_t>(r * Max);
|
||||||
G = (uint8_t)(g * Max);
|
G = static_cast<uint8_t>(g * Max);
|
||||||
B = (uint8_t)(b * Max);
|
B = static_cast<uint8_t>(b * Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
RgbColor::RgbColor(const HsbColor& color)
|
RgbColor::RgbColor(const HsbColor& color)
|
||||||
@@ -78,14 +78,14 @@ RgbColor::RgbColor(const HsbColor& color)
|
|||||||
|
|
||||||
_HsbToRgb(color, &r, &g, &b);
|
_HsbToRgb(color, &r, &g, &b);
|
||||||
|
|
||||||
R = (uint8_t)(r * Max);
|
R = static_cast<uint8_t>(r * Max);
|
||||||
G = (uint8_t)(g * Max);
|
G = static_cast<uint8_t>(g * Max);
|
||||||
B = (uint8_t)(b * Max);
|
B = static_cast<uint8_t>(b * Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t RgbColor::CalculateBrightness() const
|
uint8_t RgbColor::CalculateBrightness() const
|
||||||
{
|
{
|
||||||
return (uint8_t)(((uint16_t)R + (uint16_t)G + (uint16_t)B) / 3);
|
return static_cast<uint8_t>((static_cast<uint16_t>(R) + static_cast<uint16_t>(G) + static_cast<uint16_t>(B)) / 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
RgbColor RgbColor::Dim(uint8_t ratio) const
|
RgbColor RgbColor::Dim(uint8_t ratio) const
|
||||||
|
@@ -57,7 +57,7 @@ RgbwColor::RgbwColor(const HsbColor& color)
|
|||||||
|
|
||||||
uint8_t RgbwColor::CalculateBrightness() const
|
uint8_t RgbwColor::CalculateBrightness() const
|
||||||
{
|
{
|
||||||
uint8_t colorB = (uint8_t)(((uint16_t)R + (uint16_t)G + (uint16_t)B) / 3);
|
uint8_t colorB = static_cast<uint8_t>((static_cast<uint16_t>(R) + static_cast<uint16_t>(G) + static_cast<uint16_t>(B)) / 3);
|
||||||
if (W > colorB)
|
if (W > colorB)
|
||||||
{
|
{
|
||||||
return W;
|
return W;
|
||||||
|
@@ -116,7 +116,7 @@ uint8_t SevenSegDigit::CalculateBrightness() const
|
|||||||
sum += Segment[iSegment];
|
sum += Segment[iSegment];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uint8_t)(sum / SegmentCount);
|
return static_cast<uint8_t>(sum / SegmentCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SevenSegDigit::Darken(uint8_t delta)
|
void SevenSegDigit::Darken(uint8_t delta)
|
||||||
|
Reference in New Issue
Block a user