Skip to content
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
62 changes: 53 additions & 9 deletions src/AmbientLightingThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ class AmbientLightingThread : public concurrency::OSThread
pinMode(RGBLED_BLUE, OUTPUT);
#endif
#ifdef HAS_NEOPIXEL
pixels.begin(); // Initialise the pixel(s)
pixels.clear(); // Set all pixel colors to 'off'
pixels.setBrightness(0); //moduleConfig.ambient_lighting.current
pixels.begin(); // Initialise the pixel(s)
pixels.clear(); // Set all pixel colors to 'off'
pixels.setBrightness(0); // moduleConfig.ambient_lighting.current
#if defined(ESP32)
if (_neoPixelApbLock == nullptr) {
esp_err_t err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "neopixel", &_neoPixelApbLock);
Expand All @@ -113,7 +113,10 @@ class AmbientLightingThread : public concurrency::OSThread
#endif
}

bool isFlashlightModeActive() const { return _flashlightOverrideActive; }
bool isFlashlightModeActive() const
{
return _flashlightOverrideActive;
}

void setFlashlightMode(bool enabled)
{
Expand All @@ -127,13 +130,16 @@ class AmbientLightingThread : public concurrency::OSThread
// if (moduleConfig.ambient_lighting.led_state) {
// setLighting();
// } else {
setLightingOff(nullptr);
setLightingOff(nullptr);
// }
}
}

#if HAS_SOS
bool isSOSModeActive() const { return _sosOverrideActive; }
bool isSOSModeActive() const
{
return _sosOverrideActive;
}

void setSOSMode(bool enabled)
{
Expand Down Expand Up @@ -178,10 +184,25 @@ class AmbientLightingThread : public concurrency::OSThread
showNotificationMarquee();
return 16;
}
#if defined(GAT562)
_bootMarqueeDone = true;
_standbyBreathingActive = true;
showBreathingWhite();
#else
setLightingOff(NULL);
_bootMarqueeDone = true;
#endif
}

#if defined(GAT562)
if (_standbyBreathingActive) {
if (millis() - _lastMarqueeCall > 200) {
showBreathingWhite();
}
return 30;
}
#endif
#endif
#if defined(HAS_NCP5623) || defined(HAS_LP5562)
if ((_type == ScanI2C::NCP5623 || _type == ScanI2C::LP5562) && moduleConfig.ambient_lighting.led_state) {
#endif
Expand All @@ -203,8 +224,10 @@ class AmbientLightingThread : public concurrency::OSThread
ScanI2C::DeviceType _type = ScanI2C::DeviceType::NONE;
uint32_t _bootEffectUntil = millis() + 3200;
bool _bootMarqueeDone = false;
bool _standbyBreathingActive = false;
bool _ledOff = false;
bool _flashlightOverrideActive = false;
uint32_t _lastMarqueeCall = 0;
#if HAS_SOS
bool _sosOverrideActive = false;
uint8_t _sosPatternIndex = 0;
Expand Down Expand Up @@ -275,11 +298,14 @@ class AmbientLightingThread : public concurrency::OSThread
#endif
return 0;
}

protected:
void showNotificationMarquee()
{
#ifdef HAS_NEOPIXEL
#if defined(GAT562)
_lastMarqueeCall = millis();
#endif
static uint16_t marqueeStep = 0;
const uint16_t hue = (marqueeStep * 2048U) & 0xFFFF;
const uint8_t maxBrightness = 255;
Expand All @@ -292,7 +318,7 @@ class AmbientLightingThread : public concurrency::OSThread
pixels.setPixelColor(head, Adafruit_NeoPixel::ColorHSV(hue, 255, 255));
pixels.setPixelColor(tail, Adafruit_NeoPixel::ColorHSV(hue, 255, 96));
#else
pixels.setPixelColor(0, Adafruit_NeoPixel::ColorHSV(hue, 255, 255));
pixels.setPixelColor(0, Adafruit_NeoPixel::ColorHSV(hue, 255, 255));
#endif
acquireNeoPixelClockLock();
pixels.show();
Expand All @@ -301,6 +327,24 @@ class AmbientLightingThread : public concurrency::OSThread
#endif
}

#if defined(GAT562) && defined(HAS_NEOPIXEL)
void showBreathingWhite()
{
const uint16_t breathPeriodMs = 2000;
const uint8_t maxBrightness = 30;
const uint32_t now = millis();
const uint16_t phase = (now % breathPeriodMs) * 512UL / breathPeriodMs;
const uint16_t breathValue = phase < 256 ? phase : 511 - phase;
const uint8_t brightness = ((uint32_t)breathValue * maxBrightness) / 255;

pixels.setBrightness(brightness);
pixels.fill(pixels.Color(255, 255, 255), 0, NEOPIXEL_COUNT);
acquireNeoPixelClockLock();
pixels.show();
releaseNeoPixelClockLock();
}
#endif

#if HAS_SOS && defined(HAS_NEOPIXEL)
void handleSOSBlink()
{
Expand Down Expand Up @@ -350,7 +394,7 @@ class AmbientLightingThread : public concurrency::OSThread
200, 200, // dot
200, 200, // dot
200, 200, // dot
0, 1000, // cycle gap
0, 1000, // cycle gap
};
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ void NodeDB::initConfigIntervals()
#endif

#if defined(GAT562)
config.display.screen_on_secs = 10;
config.display.screen_on_secs = 30;
#endif
}

Expand Down
Loading