-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(flash): Setting a specific brightness
- Loading branch information
Showing
20 changed files
with
209 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package mqtt | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/partyhall/partyhall/api_errors" | ||
"github.com/partyhall/partyhall/log" | ||
"github.com/partyhall/partyhall/mercure_client" | ||
"github.com/partyhall/partyhall/state" | ||
"github.com/partyhall/partyhall/utils" | ||
) | ||
|
||
func SetFlash(powered bool, brightness int) { | ||
brightness = utils.ClampInt(brightness, 0, 100) | ||
if brightness == 0 { | ||
powered = false | ||
} | ||
|
||
state.STATE.ModulesSettings.Photobooth.FlashBrightness = brightness | ||
|
||
if !powered { | ||
brightness = 0 | ||
} | ||
|
||
state.STATE.HardwareFlashPowered = powered | ||
|
||
mercure_client.CLIENT.PublishEvent( | ||
"/flash", | ||
map[string]any{ | ||
"powered": powered, | ||
"brightness": brightness, | ||
}, | ||
) | ||
|
||
err := EasyMqtt.Send("partyhall/flash", fmt.Sprintf("%v", brightness)) | ||
if err != nil { | ||
api_errors.MQTT_PUBLISH_FAILURE.WithExtra(map[string]any{ | ||
"err": err, | ||
}) | ||
|
||
log.Error("[MQTT] Faied to publish partyhall/flash", "err", err) | ||
|
||
return | ||
} | ||
} |
Oops, something went wrong.