Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screensaver color depth fix - add missing colors to screensaver, plus an 'off' state #70

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions OMX-27-firmware/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ int pots[NUM_CC_BANKS][NUM_CC_POTS] = {

int potMinVal = 0;
#if T4
int potMaxVal = 1019; // T4 = 1019 // T3.2 = 8190;
int potMaxVal = 1019; // T4 = 1019 // T3.2 = 8191;
#else
int potMaxVal = 8190; // T4 = 1019 // T3.2 = 8190;
int potMaxVal = 8191; // T4 = 1019 // T3.2 = 8191;
#endif

const int gridh = 32;
Expand Down
23 changes: 15 additions & 8 deletions OMX-27-firmware/src/modes/omx_screensaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

void OmxScreensaver::setScreenSaverColor()
{
colorConfig.screensaverColor = map(potSettings.analog[4]->getValue(), potMinVal, potMaxVal, 0, 32764);
colorConfig.screensaverColor = map(potSettings.analog[4]->getValue(), potMinVal, potMaxVal, 0, ssMaxColorDepth);
}

void OmxScreensaver::onPotChanged(int potIndex, int prevValue, int newValue, int analogDelta)
{
// colorConfig.screensaverColor = potSettings.analog[4]->getValue() * 4; // value is 0-32764 for strip.ColorHSV
setScreenSaverColor();

// set screensaver color with pot 4
if (potSettings.analog[4]->hasChanged())
{
setScreenSaverColor();
}
// reset screensaver
if (potSettings.analog[0]->hasChanged() || potSettings.analog[1]->hasChanged() || potSettings.analog[2]->hasChanged() || potSettings.analog[3]->hasChanged())
{
Expand All @@ -26,8 +28,12 @@ void OmxScreensaver::updateScreenSaverState()
{
if (screenSaverCounter > screensaverInterval)
{
screenSaverActive = true;
}
if (!screenSaverActive)
{
screenSaverActive = true;
setScreenSaverColor();
}
}
else if (screenSaverCounter < 10)
{
ssstep = 0;
Expand All @@ -45,7 +51,6 @@ void OmxScreensaver::updateScreenSaverState()

bool OmxScreensaver::shouldShowScreenSaver()
{
setScreenSaverColor();
return screenSaverActive;
}

Expand All @@ -62,10 +67,12 @@ void OmxScreensaver::onDisplayUpdate()
updateLEDs();
omxDisp.clearDisplay();
}

void OmxScreensaver::resetCounter()
{
screenSaverCounter = 0;
}

void OmxScreensaver::updateLEDs()
{
unsigned long playstepmillis = millis();
Expand All @@ -81,7 +88,7 @@ void OmxScreensaver::updateLEDs()
{
strip.setPixelColor(z, 0);
}
if (colorConfig.screensaverColor < 32639)
if (colorConfig.screensaverColor < ssMaxColorDepth)
{
if (!ssreverse)
{
Expand Down
5 changes: 2 additions & 3 deletions OMX-27-firmware/src/modes/omx_screensaver.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ class OmxScreensaver : public OmxModeInterface
private:
void setScreenSaverColor();
elapsedMillis screenSaverCounter = 0;
unsigned long screensaverInterval = 1000 * 60 * 3; // 3 minutes default? // 10000; 15000; //
unsigned long screensaverInterval = 1000 * 60 * 3; // 3 minutes default
uint32_t ssMaxColorDepth = 65528; // used by setScreenSaverColor(). Allows for full rainbow of colors, plus a little extra for 'black'

// Uncomment for 10 second screensaver for testing
// unsigned long screensaverInterval = 1000 * 10;
int ssstep = 0;
int ssloop = 0;
volatile unsigned long nextStepTimeSS = 0;
Expand Down
Loading