Skip to content

A Swift library for controlling Luxafor LED lights

Notifications You must be signed in to change notification settings

Frizlab/swift-luxafor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift Luxafor

A simple library to control the Luxafor Flag.

Examples

For rainbow radness

go get -v -u  github.com/leosunmo/goluxafor/example/rainbow
rainbow

Quick 'n dirty CLI

go get -v -u github.com/leosunmo/goluxafor/example/luxcli

$ luxcli red
$ luxcli green
$ luxcli off

Usage

package main

import (
	"github.com/leosunmo/goluxafor"
)

func main() {
	luxafor := goluxafor.NewLuxafor()
	luxafor.Pattern(goluxafor.Pattern8, 0)

	luxafor.Close()
}

Constants

LEDs

  • goluxafor.LedAll - All LEDs
  • goluxafor.LedA - Back side
  • goluxafor.LedB - Flag side
  • goluxafor.Led1 - Lower flag
  • goluxafor.Led2 - Middle flag
  • goluxafor.Led3 - Top flag
  • goluxafor.Led4 - Lower back
  • goluxafor.Led5 - Middle back
  • goluxafor.Led6 - Top back

Static colours and fade

Set whole flag to red colour and set fadeTime to a non-zero value up to 255 to control the fade speed.

luxafor.Colour(goluxafor.ledAll, 255, 0, 0, fadeTime)

Also works for individual LEDs.

Strobe

Strobe can be set on individual LEDs, sides or all.

Set strobe frequency with speed and number of repeats with repeat, 0 is forever.

luxafor.Strobe(goluxafor.LedAll, randomColour(), randomColour(), randomColour(), speed, repeat)

Wave

Wave is executed on the whole flag and has 5 different wave patterns.

Set wave change speed with speed and number of repetitions with repeat, 0 is forever.

luxafor.Wave(goluxafor.Wave2, randomColour(), randomColour(), randomColour(), speed, repeat)

Patterns

Patterns are pre-programmed patterns on the device itself that are executed on all LEDs.

You can only specify the pattern type and repeat. Again, 0 will loop the pattern forever.

luxafor.Pattern(goluxafor.Pattern5, 0) // Loop police lights forever

Patterns:

  • goluxafor.Pattern1 - Traffic lights
  • goluxafor.Pattern2 - Colour walk
  • goluxafor.Pattern3 - Random pattern
  • goluxafor.Pattern4 - Random fading pattern
  • goluxafor.Pattern5 - Police pattern
  • goluxafor.Pattern6 - Random quick fade pattern
  • goluxafor.Pattern7 - Colourful police pattern
  • goluxafor.Pattern8 - Quick rainbow pattern

About

A Swift library for controlling Luxafor LED lights

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 100.0%