SatCat5
cfgbus_led.h
Go to the documentation of this file.
1 // Copyright 2021-2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
13 
14 #pragma once
15 
16 #include <satcat5/cfgbus_core.h>
17 #include <satcat5/list.h>
18 #include <satcat5/polling.h>
19 
20 namespace satcat5 {
21  namespace cfg {
24  class LedArray {
25  public:
28  unsigned devaddr, unsigned count);
29 
31  unsigned count() const {return m_count;}
32 
34  u8 get(unsigned idx);
36  void set(unsigned idx, u8 brt);
37 
38  protected:
40  const unsigned m_count;
41  };
42 
46  class LedActivity {
47  public:
50  unsigned devaddr, unsigned regaddr,
51  unsigned stats_idx, u8 brt = 128);
52 
57 
58  private:
60  satcat5::cfg::Register m_reg; // Base control register
61  const unsigned m_stats_idx; // NetworkStats index
62  const u8 m_brt; // Max LED brightness
63  u8 m_state; // Recent activity state
64  LedActivity* m_next; // Linked list of other LEDs
65  };
66 
69  public:
71  explicit LedActivityCtrl(
73  unsigned delay_msec = 33); // Default speed = 30 fps
74 
76  inline void add(LedActivity* led) {m_list.add(led);}
77 
78  private:
79  void timer_event() override; // Timer event handler
80 
81  satcat5::cfg::NetworkStats* const m_stats;
83  };
84 
88  class LedWave {
89  public:
92  unsigned devaddr, unsigned regaddr, u8 m_brt = 128);
93 
95  void update(u32 incr);
96 
97  private:
99  satcat5::cfg::Register m_reg; // Base control register
100  const u8 m_brt; // Max LED brightness
101  u32 m_phase; // Animation phase counter
102  LedWave* m_next; // Linked list of other LEDs
103  };
104 
107  public:
108  LedWaveCtrl();
109 
111  inline void add(LedWave* led) {m_list.add(led);}
112 
114  void start(unsigned delay=20);
115  void stop();
116 
117  private:
118  void timer_event() override; // Timer event handler
119 
121  u32 m_incr; // Animation speed
122  };
123  }
124 }
ConfigBus core definitions.
Generic ConfigBus API.
Definition: cfgbus_core.h:124
Coordinate multiple LedActivity objects.
Definition: cfgbus_led.h:68
void add(LedActivity *led)
Add an LedActivity object to this group.
Definition: cfgbus_led.h:76
LedActivityCtrl(satcat5::cfg::NetworkStats *stats, unsigned delay_msec=33)
Link this controller to an activity source.
Definition: cfgbus_led.cc:85
void timer_event() override
Child class MUST override this method.
Definition: cfgbus_led.cc:93
Single-LED controller for a network-activity light.
Definition: cfgbus_led.h:46
LedActivity(satcat5::cfg::ConfigBus *cfg, unsigned devaddr, unsigned regaddr, unsigned stats_idx, u8 brt=128)
Link to a specific LED.
Definition: cfgbus_led.cc:46
void update(satcat5::cfg::NetworkStats *stats)
Callback object for LedActivityCtrl.
Definition: cfgbus_led.cc:57
Basic LED array with direct user control of each intensity value.
Definition: cfgbus_led.h:24
const unsigned m_count
Number of LEDs.
Definition: cfgbus_led.h:40
unsigned count() const
Number of LEDs in this bank?
Definition: cfgbus_led.h:31
LedArray(satcat5::cfg::ConfigBus *cfg, unsigned devaddr, unsigned count)
Link this controller to a bank of PWM LEDs.
Definition: cfgbus_led.cc:22
u8 get(unsigned idx)
Get brightness of the Nth LED.
Definition: cfgbus_led.cc:32
satcat5::cfg::Register m_reg
Base control register.
Definition: cfgbus_led.h:39
void set(unsigned idx, u8 brt)
Set brightness of the Nth LED.
Definition: cfgbus_led.cc:40
Coordinate multiple LedWave objects.
Definition: cfgbus_led.h:106
void timer_event() override
Child class MUST override this method.
Definition: cfgbus_led.cc:154
void add(LedWave *led)
Add an LedActivity object to this group.
Definition: cfgbus_led.h:111
void stop()
Stop wave animation.
Definition: cfgbus_led.cc:149
void start(unsigned delay=20)
Animation controls.
Definition: cfgbus_led.cc:131
Single-LED controller for a "Breathing" or "Wave" pattern.
Definition: cfgbus_led.h:88
LedWave(satcat5::cfg::ConfigBus *cfg, unsigned devaddr, unsigned regaddr, u8 m_brt=128)
Link to a specific LED.
Definition: cfgbus_led.cc:106
void update(u32 incr)
Callback object for LedWaveCtrl.
Definition: cfgbus_led.cc:116
Traffic statistics polling.
Definition: cfgbus_stats.h:49
Pointer-like wrapper for one or more ConfigBus registers.
Definition: cfgbus_core.h:76
Timer objects are polled after a fixed delay or at a regular interval.
Definition: polling.h:213
Helper functions for manipulating singly-linked lists.
Definition: list.h:52
Templated linked-list class.
Definition: list.h:210
Templated functions for manipulating singly-linked lists.
Core event-processing loop for SatCat5 software.