Documentation ¶
Overview ¶
Package ctlpanel provides utilities for interacting with my custom-built Control Panel over GPIO. The hardware features a potentiometer dial for adjusting light brightness, a physical pager button, a capacitive-touch button for turning the lights on and off, and an LED and speaker for confirming user input.
Index ¶
- type ControlPanel
- func (p *ControlPanel) AcknowledgePager()
- func (p *ControlPanel) BlinkLED(d time.Duration)
- func (p *ControlPanel) Chirp(tone physic.Frequency, d time.Duration)
- func (p *ControlPanel) HandlePager()
- func (p *ControlPanel) HandleTouchSwitch(oldLightSettings *lights.LightConfig) (updated bool)
- func (p *ControlPanel) ReadDimmerPct() uint16
- func (p *ControlPanel) ResetLatches()
- func (p *ControlPanel) StartLightsInterrupt(ctx context.Context, ch chan uint8, panelCode uint8)
- func (p *ControlPanel) StartPagerInterrupt(ctx context.Context, ch chan uint8, panelCode uint8)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ControlPanel ¶
type ControlPanel struct { ResetPin gpio.PinOut PagerPin gpio.PinIn LightSwitchPin gpio.PinIn LedPin gpio.PinOut Speaker gpio.PinOut DimmerChannel int DimmerAdc *mcp3w0c.MCP3w0c DimmerLastValue uint16 // contains filtered or unexported fields }
ControlPanel models the hardware interface to the panel's devices. It also tracks the reads from the dimmer to only trigger an update when the value actually changes.
func New ¶
func New(pager, light gpio.PinIn, reset, led, speaker gpio.PinOut, dimmerSelect int, dimmerAdc *mcp3w0c.MCP3w0c, logger *log.Entry) ControlPanel
New generates the ControlPanel struct with the specified pins. It will ensure that there is a valid logger attached.
func (*ControlPanel) AcknowledgePager ¶
func (p *ControlPanel) AcknowledgePager()
AcknowledgePager plays a hardcoded sequence of lights and beeps to confirm the pager request was received.
func (*ControlPanel) BlinkLED ¶
func (p *ControlPanel) BlinkLED(d time.Duration)
BlinkLED drives the panel's button's LED on for the specified duration.
func (*ControlPanel) Chirp ¶
func (p *ControlPanel) Chirp(tone physic.Frequency, d time.Duration)
Chirp plays the specified tone for the given duration on the Panel's onboard speaker.
func (*ControlPanel) HandlePager ¶
func (p *ControlPanel) HandlePager()
func (*ControlPanel) HandleTouchSwitch ¶
func (p *ControlPanel) HandleTouchSwitch(oldLightSettings *lights.LightConfig) (updated bool)
func (*ControlPanel) ReadDimmerPct ¶
func (p *ControlPanel) ReadDimmerPct() uint16
ReadDimmerPct reads the ADC supporting this control panel, and normalizes the response to an integer in the range [0, 100]
func (*ControlPanel) ResetLatches ¶
func (p *ControlPanel) ResetLatches()
func (*ControlPanel) StartLightsInterrupt ¶
func (p *ControlPanel) StartLightsInterrupt(ctx context.Context, ch chan uint8, panelCode uint8)
StartLightsInterrupt will watch for edges on the LightSwitch pin, and write into the given channel when one is detected. It runs forever until the context is cancelled
func (*ControlPanel) StartPagerInterrupt ¶
func (p *ControlPanel) StartPagerInterrupt(ctx context.Context, ch chan uint8, panelCode uint8)
StartPagerInterrupt will watch for edges on the Pager pin, and write into the given channel when one is detected. It runs forever until the context is cancelled.