firmware icon indicating copy to clipboard operation
firmware copied to clipboard

De-duplicate Ambient LED management code

Open fifieldt opened this issue 1 year ago • 1 comments
trafficstars

We currently have 3 different places where we have the logic for modifying LED state of the various types of Ambient LEDs, ExternalNotificationModule::SetExternalState AmbientLightingThread::setLighting AmbientLightingThread::setLightingOff

Instead, we should have a single place where this happens.

Use the notification system we have in the firmware for IPC, so that Ambient lighting offers a subscription service for LED changes and the External Notifications uses it (if available).

You can look at how it's done for notifying others about GPS position changes :-)

fifieldt avatar Oct 31 '24 01:10 fifieldt

You can look at how it's done for notifying others about GPS position changes :-)

https://github.com/meshtastic/firmware/blob/e866734a25fe811bdb87253da8c8e0879be512f9/src/gps/GPS.cpp#L975

Is this what you're referring to? If I understand the proposal correctly:

  1. AmbientLightingThread should own something like an Observable<LightingConfig> lightChanged.
  2. AmbientLightingThread::setLighting is invoked by an observer.
  3. LightingConfig probably looks a lot like meshtastic_ModuleConfig_AmbientLightingConfig, but also needs to identify which light is being configured. Though maybe you're expecting that the observer is just watching for ambient lighting.
  4. AmbientLightingThread::setLightingOff calls observable.notifyObservers(&offStruct)

Blake-Latchford avatar Nov 13 '24 02:11 Blake-Latchford

Hi @Blake-Latchford - I'm sorry for missing your message. A fellow contributor pointed it out to me. As I understand it, yes, basically. ExternalNotificationModule would use the Observable.

fifieldt avatar Feb 21 '25 00:02 fifieldt

Hi, Lets talk aboud LEDS Can you add instead of ambientlight - TX Indicator with possibility to enter delay - this will help to control external LNA and amplifier when used in amateur radio bands. We like to try on 2.4GHz out of wifi spectrum in Ham radio part of 2.4 GHz (not yet possible, casue crash, this will be reported as an issue in other topic) (It is important to be able to set the time at which the transmission starts after the LED lights up, this time is needed to switch the RF end switch)

SQ6RDP avatar Mar 04 '25 13:03 SQ6RDP