Skip to content

Commit 211af75

Browse files
committed
Merge branch 'master' of https://github.com/FastLED/FastLED
2 parents eb65ae0 + eabf2d8 commit 211af75

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

colorutils.h

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,23 @@ class CHSVPalette16 {
489489
return &(entries[0]);
490490
}
491491

492+
bool operator==( const CHSVPalette16 rhs)
493+
{
494+
const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
495+
const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
496+
if( p == q) return true;
497+
for( uint8_t i = 0; i < (sizeof( entries)); i++) {
498+
if( *p != *q) return false;
499+
p++;
500+
q++;
501+
}
502+
return true;
503+
}
504+
bool operator!=( const CHSVPalette16 rhs)
505+
{
506+
return !( *this == rhs);
507+
}
508+
492509
CHSVPalette16( const CHSV& c1)
493510
{
494511
fill_solid( &(entries[0]), 16, c1);
@@ -577,6 +594,23 @@ class CHSVPalette256 {
577594
return &(entries[0]);
578595
}
579596

597+
bool operator==( const CHSVPalette256 rhs)
598+
{
599+
const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
600+
const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
601+
if( p == q) return true;
602+
for( uint16_t i = 0; i < (sizeof( entries)); i++) {
603+
if( *p != *q) return false;
604+
p++;
605+
q++;
606+
}
607+
return true;
608+
}
609+
bool operator!=( const CHSVPalette256 rhs)
610+
{
611+
return !( *this == rhs);
612+
}
613+
580614
CHSVPalette256( const CHSV& c1)
581615
{
582616
fill_solid( &(entries[0]), 256, c1);
@@ -648,6 +682,23 @@ class CRGBPalette16 {
648682
return *this;
649683
}
650684

685+
bool operator==( const CRGBPalette16 rhs)
686+
{
687+
const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
688+
const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
689+
if( p == q) return true;
690+
for( uint8_t i = 0; i < (sizeof( entries)); i++) {
691+
if( *p != *q) return false;
692+
p++;
693+
q++;
694+
}
695+
return true;
696+
}
697+
bool operator!=( const CRGBPalette16 rhs)
698+
{
699+
return !( *this == rhs);
700+
}
701+
651702
inline CRGB& operator[] (uint8_t x) __attribute__((always_inline))
652703
{
653704
return entries[x];
@@ -880,6 +931,23 @@ class CRGBPalette256 {
880931
return *this;
881932
}
882933

934+
bool operator==( const CRGBPalette256 rhs)
935+
{
936+
const uint8_t* p = (const uint8_t*)(&(this->entries[0]));
937+
const uint8_t* q = (const uint8_t*)(&(rhs.entries[0]));
938+
if( p == q) return true;
939+
for( uint16_t i = 0; i < (sizeof( entries)); i++) {
940+
if( *p != *q) return false;
941+
p++;
942+
q++;
943+
}
944+
return true;
945+
}
946+
bool operator!=( const CRGBPalette256 rhs)
947+
{
948+
return !( *this == rhs);
949+
}
950+
883951
inline CRGB& operator[] (uint8_t x) __attribute__((always_inline))
884952
{
885953
return entries[x];

hsv2rgb.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@ CHSV rgb2hsv_approximate( const CRGB& rgb)
550550
// this part could probably use refinement/rethinking,
551551
// (but it doesn't overflow & wrap anymore)
552552
uint16_t s16;
553-
s16 = (s * 256) / v;
553+
s16 = (s * 256);
554+
s16 /= v;
554555
if( s16 < 256) {
555556
s = s16;
556557
} else {

0 commit comments

Comments
 (0)