| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package main
- import (
- intrgb "netdome.biz/paul/impact-80/internal/rgb"
- "netdome.biz/paul/impact-80/internal/via"
- )
- func selectedZones() ([]intrgb.Zone, error) {
- if targetZone == "" {
- return intrgb.AllZones(), nil
- }
- zone, err := intrgb.ParseZone(targetZone)
- if err != nil {
- return nil, err
- }
- return []intrgb.Zone{zone}, nil
- }
- func zoneChannels(zones []intrgb.Zone) []via.LEDType {
- var channels []via.LEDType
- for _, zone := range zones {
- channels = append(channels, via.LEDType(zone.Channel()))
- }
- return channels
- }
- // filterZones keeps the zones that appear in selected, preserving the order
- // of candidates. It neither adds nor removes zones on its own: a zone the
- // caller does not offer stays absent, so a profile that omits a zone is not
- // padded with defaults.
- func filterZones(candidates, selected []intrgb.Zone) []intrgb.Zone {
- keep := make(map[intrgb.Zone]bool, len(selected))
- for _, zone := range selected {
- keep[zone] = true
- }
- filtered := make([]intrgb.Zone, 0, len(candidates))
- for _, zone := range candidates {
- if keep[zone] {
- filtered = append(filtered, zone)
- }
- }
- return filtered
- }
|