Skip to content

Commit

Permalink
updated readme and code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjx committed Oct 1, 2020
1 parent 709547a commit e5f7c3d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Downloadable binaries can be found on the releases page.
yeelight.exe -ip <ip>
[-hsvHue <0-359>]
[-hsvSat <0-100>]
[-css <red, blue, aqua, violet, etc>]
[-rgb <000000-FFFFFF>]
[-effect <sudden|smooth>]
[-duration <30+>]
Expand All @@ -35,3 +36,11 @@ Multiple commands can be used. Turn on a globe, set the color to RGB value #9400
Linux example showing HSV usage

`./yeelight-linux --ip=10.250.1.117 --hsvHue=120 --hsvSat=100 --effect=sudden`

## Release Notes

`1.0`
- Initial release

`1.1`
- Added CSS Named colour flag (`-css`). See [here](https://css-tricks.com/snippets/css/named-colors-and-hex-equivalents/) for a list of valid colours.
18 changes: 8 additions & 10 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ func main() {
send_message(*ipPtr, message)
}

// manage colours
switch {
// set css colour

// set colour via css named values
case (*cssPtr != ""):
var cssInt interface{}
b := []byte(colours)
Expand All @@ -119,20 +119,18 @@ func main() {
send_message(*ipPtr, message)
}

// set hsv
case (*hsvHuePtr >= 0) && (*hsvSatPtr >= 0):
fmt.Println("Setting HSV on globe at " + *ipPtr)
message := "{\"id\":1,\"method\":\"set_hsv\",\"params\":[" + strconv.Itoa(*hsvHuePtr) + "," + strconv.Itoa(*hsvSatPtr) + ",\"" + *effectPtr + "\"," + strconv.Itoa(*durationPtr) + "]}"
send_message(*ipPtr, message)

// set rgb
// set colour via rgb
case (*rgbPtr != ""):

var rgbDecimal string = hexToDec(*rgbPtr)
fmt.Println("Setting RGB on globe at " + *ipPtr)
message := "{\"id\":1,\"method\":\"set_rgb\",\"params\":[" + rgbDecimal + ",\"" + *effectPtr + "\"," + strconv.Itoa(*durationPtr) + "]}"
send_message(*ipPtr, message)

// set colour via hsv
case (*hsvHuePtr >= 0) && (*hsvSatPtr >= 0):
fmt.Println("Setting HSV on globe at " + *ipPtr)
message := "{\"id\":1,\"method\":\"set_hsv\",\"params\":[" + strconv.Itoa(*hsvHuePtr) + "," + strconv.Itoa(*hsvSatPtr) + ",\"" + *effectPtr + "\"," + strconv.Itoa(*durationPtr) + "]}"
send_message(*ipPtr, message)
}

// set brightness
Expand Down

0 comments on commit e5f7c3d

Please sign in to comment.