Documentation ¶
Index ¶
- Constants
- func BoolP(val bool) *bool
- func CloneAttrs(attrs map[string]*Attribute) map[string]*Attribute
- func FixJSON(attrs map[string]*Attribute)
- func Float32P(val float32) *float32
- func HSLConstruct(hue, saturation, luminence int32) string
- func HSLDeconstruct(val string) (int32, int32, int32, error)
- func HSLStringToRGB(hsl string) (byte, byte, byte, error)
- func Int32P(val int32) *int32
- func RGBToHSLString(r, g, b int) string
- func StringP(val string) *string
- type Attribute
- func NewAttribute(localID, t, dataType string, val interface{}) *Attribute
- func NewBool(localID, concrete string, val *bool) *Attribute
- func NewBrightness(localID string, val *float32) *Attribute
- func NewButtonState(localID string, val *int32) *Attribute
- func NewFloat32(localID, concrete string, val *float32) *Attribute
- func NewHSL(localID string, val *string) *Attribute
- func NewInt32(localID, concrete string, val *int32) *Attribute
- func NewOffset(localID string, val *float32) *Attribute
- func NewOnOff(localID string, val *int32) *Attribute
- func NewOpenClose(localID string, val *int32) *Attribute
- func NewString(localID, concrete string, val *string) *Attribute
- func NewTemp(localID string, val *int32) *Attribute
- func Only(attrs map[string]*Attribute) *Attribute
Constants ¶
const ( // DTString string DTString string = "string" // DTBool boolean DTBool string = "bool" // DTFloat32 float32 DTFloat32 string = "float32" // DTInt32 int32 DTInt32 string = "int32" )
const ( // UTPercentage percentage UTPercentage string = "percentage" // UTCelcius celcius UTCelcius string = "celcius" // UTFarenheit farenheit UTFarenheit string = "farenheit" // UTMillisecond millisecond UTMilliSecond string = "millisecond" )
const ( // ATOpenClose represents an OpenClose attribute ATOpenClose string = "OpenClose" // ATBrightness represents a Brightness attribute ATBrightness string = "Brightness" // ATOnOff represents an OnOff attribute ATOnOff string = "OnOff" // ATHSL represents a HSL attribute ATHSL string = "HSL" // ATOffset represents an Offset attribute ATOffset string = "Offset" // ATTemperature represents a temperature attribute ATTemperature string = "Temperature" // ATButtonState represents a button state e.g. pressed/released ATButtonState string = "BtnState" )
const ( // PermsReadOnly the attribute is a read-only value and cannot be set PermsReadOnly string = "r" // PermsReadWrite the attribute can be read and written to PermsReadWrite string = "rw" )
const ( ButtonStatePressed int32 = 1 ButtonStateReleased int32 = 2 )
const ( // OpenCloseClosed indicates the OpenClose attribute is in a closed state OpenCloseClosed int32 = 1 // OpenCloseOpen indicates the OpenClose attribute is in an open state OpenCloseOpen int32 = 2 )
const ( // OnOffOff indicates the OnOff attribute is in the off state OnOffOff int32 = 1 // OnOffOn indicates the OnOff attribute is in the on state OnOffOn int32 = 2 )
Variables ¶
This section is empty.
Functions ¶
func CloneAttrs ¶
Clone copies the map and the contained attributes, returning a new copy that can be modified without chaning the original map or attributes
func FixJSON ¶
FixJSON massages the values back from float64 which is the type given to the values when being unmarshalled, to their correct data type
func HSLConstruct ¶
HSLConstruct takes in H,S,L values and converts then to a HSL string e.g. hsl(255, 44%, 32%)
func HSLDeconstruct ¶
HSLDeconstruct takes in a HSL string e.g. hsl(255, 44%, 32%) and returns the HSL components e.g. 255,44,32
func HSLStringToRGB ¶
HSLStringToRGB converts a HSL string e.g. hsl(100, 32%, 99%) to its corresponding RGB values
func RGBToHSLString ¶
RGBToHSLString converts the R,G,B values to a HSL string
Types ¶
type Attribute ¶
type Attribute struct { // LocalID is an identifier that should be mutually exclusive between all attributes // assigned to a feature, it doesn't need to be globally unique. It can be used to // distinguish between the various atrtibutes of a feature LocalID string `json:"localId"` // Type is the concrete type of attribute such as OpenClose, Brightness, Hue etc Type string `json:"type"` // DataType is the underlying data type used in the attribute, such as int32, bool etc DataType string `json:"dataType"` // Unit is the data units used by the attribute e.g. percentage Unit string `json:"unit"` // Name is a user friendly string which can be shown in the UI Name string `json:"name"` // Description provides more details about the attribute that can be shown in the UI Description string `json:"description"` // Value is the value of the attribute Value interface{} `json:"value"` // Min is the minimum allowed value Min interface{} `json:"min"` // Max is the max allowed value Max interface{} `json:"max"` // Step is the step size Step interface{} `json:"step"` // Perms specifies if the user has read or readwrite permissions, either 'r' or 'rw' Perms string `json:"perms"` }
Attribute represents a value with a specified data type and range.
func NewAttribute ¶
NewAttribute creates and returns a new Attribute instance
func NewBrightness ¶
NewBrightness returns a new Attribute initialized as a Brightness type
func NewButtonState ¶
func NewFloat32 ¶
NewFloat32 returns a new attribute initialized as a float32 data type
func NewHSL ¶
NewHSL returns a new attribute instance initialized as a HSL attribute. For HSL attributes they are a string, expecting the format 'hsl(HUE, SAT%, LUM%) where HUE is a number between 0 and 360, and SAT/LUM are 0 to 255
func NewOpenClose ¶
NweOpenClose returns a new attribute instance, initialized as an OpenClose type