ev3go / ev3dev

ev3dev is a simple interface to the Lego Mindstorms ev3 robotics platform
Other
71 stars 16 forks source link

ev3dev: add high-level LED control #5

Open kortschak opened 8 years ago

kortschak commented 8 years ago

Add an ev3 package and start with high-level LED control.

Sketch:

type LED struct { ... }

func NewLED(s Side) *LED
func (l *LED) Color() (color.Color, error)
func (l *LED) SetColor(color.Color) *LED
func (l *LED) Trigger() (Trigger, error)
func (l *LED) SetTrigger(Trigger) *LED
func (l *LED) Pattern([]time.Duration) *LED
func (l *LED) Stream(<-chan time.Duration) *LEDStream
func (l *LED) Err() error

type Side byte

const (
    Left Side = 1 << iota
    Right
}

type Trigger string

const (
    None Trigger = "none"
    MMC0 ... etc
    Timer
    Heartbeat
    DefaultOn
    Transient
    BatteryChargingOrFull
    BatteryCharging
    BatteryFull
    BatteryChargingBlinkFullSolid
    RFKill0
)

type LEDStream struct { ... }

func (l *LEDStream) Waiter() <-chan error
kortschak commented 8 years ago

Now that ev3 LEDs are handled specifically in ev3, this should just be a generalised LED group and streaming event handler.