Skip to content

Commit

Permalink
Optimization & fix conditional check
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed May 24, 2021
1 parent 4777a56 commit 852ea59
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
18 changes: 9 additions & 9 deletions HyperSerialEsp8266.ino
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ uint16_t stat_final_good = 0;
uint16_t stat_final_frames = 0;
bool wantShow = false;

void ShowMe()
inline void ShowMe()
{
if (wantShow = true && strip->CanShow())
if (wantShow == true && strip->CanShow())
{
stat_good++;;
wantShow = false;
Expand All @@ -95,7 +95,7 @@ void readSerialData()
// stats
if (internalIndex > 0 && curTime - stat_start > 1000)
{
if (stat_frames > 0)
if (stat_frames > 0 && stat_frames >= stat_good )
{
stat_final_good = stat_good;
stat_final_frames = stat_frames;
Expand All @@ -111,7 +111,7 @@ void readSerialData()
stat_good = 0;
stat_frames = 0;

Serial.write("Stats for the last full frame.\r\n");
Serial.write("HyperSerialEsp8266 version 4.\r\nStatistics for the last full 1 second cycle.\r\n");
Serial.write("Frames per second: ");
Serial.print(stat_final_frames);
Serial.write("\r\nGood frames: ");
Expand Down Expand Up @@ -233,15 +233,15 @@ void readSerialData()
}

#ifdef THIS_IS_RGBW
void setStripPixel(uint16_t pix, RgbwColor& inputColor)
inline void setStripPixel(uint16_t pix, RgbwColor& inputColor)
{
if (pix < pixelCount)
{
strip->SetPixelColor(pix, inputColor);
}
}
#else
void setStripPixel(uint16_t pix, RgbColor& inputColor)
inline void setStripPixel(uint16_t pix, RgbColor& inputColor)
{
if (pix < pixelCount)
{
Expand Down Expand Up @@ -275,8 +275,8 @@ void setup()

// Prepare calibration for RGBW
#ifdef THIS_IS_RGBW
// prepare
for (int i = 0; i < 256; i++)
// prepare LUT calibration table, neutral white is in fact yellow
for (uint32_t i = 0; i < 256; i++)
{
// color calibration
uint32_t rCorrection = 0xB0 * (uint32_t)i; // adjust red -> white in 0-0xFF range
Expand All @@ -293,7 +293,7 @@ void setup()
}
#endif

// Say ambilight like "Hello" to the world
// Say "Hello" to the world using first led
for (int i = 0; i < 9; i++)
{
if (i < 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ uint16_t stat_final_good = 0;
uint16_t stat_final_frames = 0;
bool wantShow = false;

void ShowMe()
inline void ShowMe()
{
if (wantShow = true && strip->CanShow())
if (wantShow == true && strip->CanShow())
{
stat_good++;;
wantShow = false;
Expand All @@ -95,7 +95,7 @@ void readSerialData()
// stats
if (internalIndex > 0 && curTime - stat_start > 1000)
{
if (stat_frames > 0)
if (stat_frames > 0 && stat_frames >= stat_good )
{
stat_final_good = stat_good;
stat_final_frames = stat_frames;
Expand All @@ -111,7 +111,7 @@ void readSerialData()
stat_good = 0;
stat_frames = 0;

Serial.write("Stats for the last full frame.\r\n");
Serial.write("HyperSerialEsp8266 version 4.\r\nStatistics for the last full 1 second cycle.\r\n");
Serial.write("Frames per second: ");
Serial.print(stat_final_frames);
Serial.write("\r\nGood frames: ");
Expand Down Expand Up @@ -233,15 +233,15 @@ void readSerialData()
}

#ifdef THIS_IS_RGBW
void setStripPixel(uint16_t pix, RgbwColor& inputColor)
inline void setStripPixel(uint16_t pix, RgbwColor& inputColor)
{
if (pix < pixelCount)
{
strip->SetPixelColor(pix, inputColor);
}
}
#else
void setStripPixel(uint16_t pix, RgbColor& inputColor)
inline void setStripPixel(uint16_t pix, RgbColor& inputColor)
{
if (pix < pixelCount)
{
Expand Down Expand Up @@ -275,8 +275,8 @@ void setup()

// Prepare calibration for RGBW
#ifdef THIS_IS_RGBW
// prepare
for (int i = 0; i < 256; i++)
// prepare LUT calibration table, cold white is much better than "neutral" white
for (uint32_t i = 0; i < 256; i++)
{
// color calibration
uint32_t rCorrection = 0xA0 * (uint32_t)i; // adjust red -> white in 0-0xFF range
Expand All @@ -293,7 +293,7 @@ void setup()
}
#endif

// Say ambilight like "Hello" to the world
// Say "Hello" to the world using first led
for (int i = 0; i < 9; i++)
{
if (i < 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ uint16_t stat_final_good = 0;
uint16_t stat_final_frames = 0;
bool wantShow = false;

void ShowMe()
inline void ShowMe()
{
if (wantShow = true && strip->CanShow())
if (wantShow == true && strip->CanShow())
{
stat_good++;;
wantShow = false;
Expand All @@ -94,7 +94,7 @@ void readSerialData()
// stats
if (internalIndex > 0 && curTime - stat_start > 1000)
{
if (stat_frames > 0)
if (stat_frames > 0 && stat_frames >= stat_good )
{
stat_final_good = stat_good;
stat_final_frames = stat_frames;
Expand All @@ -110,7 +110,7 @@ void readSerialData()
stat_good = 0;
stat_frames = 0;

Serial.write("Stats for the last full frame.\r\n");
Serial.write("HyperSerialEsp8266 version 4.\r\nStatistics for the last full 1 second cycle.\r\n");
Serial.write("Frames per second: ");
Serial.print(stat_final_frames);
Serial.write("\r\nGood frames: ");
Expand Down Expand Up @@ -232,15 +232,15 @@ void readSerialData()
}

#ifdef THIS_IS_RGBW
void setStripPixel(uint16_t pix, RgbwColor& inputColor)
inline void setStripPixel(uint16_t pix, RgbwColor& inputColor)
{
if (pix < pixelCount)
{
strip->SetPixelColor(pix, inputColor);
}
}
#else
void setStripPixel(uint16_t pix, RgbColor& inputColor)
inline void setStripPixel(uint16_t pix, RgbColor& inputColor)
{
if (pix < pixelCount)
{
Expand Down Expand Up @@ -274,8 +274,8 @@ void setup()

// Prepare calibration for RGBW
#ifdef THIS_IS_RGBW
// prepare
for (int i = 0; i < 256; i++)
// prepare LUT calibration table
for (uint32_t i = 0; i < 256; i++)
{
// color calibration
uint32_t rCorrection = 0 * (uint32_t)i; // adjust red -> white in 0-0xFF range
Expand All @@ -292,7 +292,7 @@ void setup()
}
#endif

// Say ambilight like "Hello" to the world
// Say "Hello" to the world using first led
for (int i = 0; i < 9; i++)
{
if (i < 3)
Expand Down

0 comments on commit 852ea59

Please sign in to comment.