7 #include <satcat5/cfgbus_stats.h>
16 static const u8 SINE_ARRAY[] = {
17 0x00, 0x02, 0x09, 0x15, 0x25, 0x38, 0x4E, 0x66,
18 0x7F, 0x98, 0xB0, 0xC6, 0xD9, 0xE9, 0xF5, 0xFC,
19 0xFF, 0xFC, 0xF5, 0xE9, 0xD9, 0xC6, 0xB0, 0x98,
20 0x7F, 0x66, 0x4E, 0x38, 0x25, 0x15, 0x09, 0x02};
23 unsigned devaddr,
unsigned count)
24 : m_reg(cfg->get_register(devaddr, 0))
28 for (
unsigned a = 0 ; a <
m_count ; ++a)
35 return (u8)
m_reg[idx];
43 m_reg[idx] = (u32)brt;
47 unsigned devaddr,
unsigned regaddr,
unsigned stats_idx, u8 brt)
48 : m_reg(cfg->get_register(devaddr, regaddr))
49 , m_stats_idx(stats_idx)
60 static const unsigned ACTIVITY_SUSTAIN = 3;
64 u32 active = port.rcvd_frames + port.sent_frames;
67 if (m_state > ACTIVITY_SUSTAIN) {
69 m_state = ACTIVITY_SUSTAIN; *m_reg = m_brt;
70 }
else if (active && m_state > 0) {
72 m_state = ACTIVITY_SUSTAIN + 1; *m_reg = 0;
75 m_state = ACTIVITY_SUSTAIN; *m_reg = m_brt;
76 }
else if (m_state > 0) {
78 --m_state; *m_reg = m_brt;
102 item = m_list.next(item);
107 unsigned devaddr,
unsigned regaddr, u8 brt)
108 : m_reg(cfg->get_register(devaddr, regaddr))
120 u8 tbl = SINE_ARRAY[m_phase >> 27];
122 *m_reg = (((u32)tbl * (u32)m_brt) >> 8);
125 LedWaveCtrl::LedWaveCtrl()
134 unsigned count = m_list.len();
135 u32 phase = 0, delta = UINT32_MAX / count;
141 item = m_list.next(item);
145 m_incr = UINT32_MAX / 100;
160 item = m_list.next(item);
ConfigBus-controlled PWM LEDs and animation functions.
Coordinate multiple LedActivity objects.
LedActivityCtrl(satcat5::cfg::NetworkStats *stats, unsigned delay_msec=33)
Link this controller to an activity source.
void timer_event() override
Child class MUST override this method.
Single-LED controller for a network-activity light.
LedActivity(satcat5::cfg::ConfigBus *cfg, unsigned devaddr, unsigned regaddr, unsigned stats_idx, u8 brt=128)
Link to a specific LED.
void update(satcat5::cfg::NetworkStats *stats)
Callback object for LedActivityCtrl.
Basic LED array with direct user control of each intensity value.
const unsigned m_count
Number of LEDs.
u8 get(unsigned idx)
Get brightness of the Nth LED.
satcat5::cfg::Register m_reg
Base control register.
void set(unsigned idx, u8 brt)
Set brightness of the Nth LED.
Coordinate multiple LedWave objects.
void timer_event() override
Child class MUST override this method.
void stop()
Stop wave animation.
void start(unsigned delay=20)
Animation controls.
Single-LED controller for a "Breathing" or "Wave" pattern.
LedWave(satcat5::cfg::ConfigBus *cfg, unsigned devaddr, unsigned regaddr, u8 m_brt=128)
Link to a specific LED.
void update(u32 incr)
Callback object for LedWaveCtrl.
Traffic statistics polling.
satcat5::cfg::TrafficStats get_port(unsigned idx)
Read most recent statistics for the Nth port.
void refresh_now()
Immediately refresh statistics for every port.
void timer_stop()
Stop all future notifications.
void timer_every(unsigned msec)
Configure a repeating notification every X milliseconds.
Data structure for reading per-port traffic statistics.