Revised Fluffy support
This commit is contained in:
parent
6d88ca4fa1
commit
b63d763cc9
1 changed files with 15 additions and 8 deletions
23
c4ctrl.py
23
c4ctrl.py
|
@ -242,9 +242,8 @@ class C4Room:
|
||||||
cmd = []
|
cmd = []
|
||||||
for light in self.lights:
|
for light in self.lights:
|
||||||
if colorscheme.color_for(light.topic):
|
if colorscheme.color_for(light.topic):
|
||||||
if magic != "none" and magic != '0': # Send color to ghost, but skip masters
|
if magic != "none" and magic != '0':
|
||||||
#if light.is_master: continue
|
# Send color to ghost instead of the "real" light
|
||||||
|
|
||||||
mode_id, error = Fluffy().mode_id(magic)
|
mode_id, error = Fluffy().mode_id(magic)
|
||||||
if error:
|
if error:
|
||||||
print("Warning: unknown mode \"{}\". Using default.".format(
|
print("Warning: unknown mode \"{}\". Using default.".format(
|
||||||
|
@ -252,8 +251,8 @@ class C4Room:
|
||||||
|
|
||||||
light.set_color(colorscheme.color_for(light.topic))
|
light.set_color(colorscheme.color_for(light.topic))
|
||||||
cmd.append({
|
cmd.append({
|
||||||
"topic" : "ghosts" + light.topic[light.topic.find('/'):],
|
"topic" : Fluffy().ghost_of(light.topic),
|
||||||
"payload" : light.payload + int(mode_id).to_bytes(1, "little")
|
"payload" : Fluffy().ghostly_payload(light.payload, mode_id)
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
light.set_color(colorscheme.color_for(light.topic))
|
light.set_color(colorscheme.color_for(light.topic))
|
||||||
|
@ -816,10 +815,18 @@ class Fluffy:
|
||||||
modes = {
|
modes = {
|
||||||
"fade" : 1,
|
"fade" : 1,
|
||||||
"wave" : 4,
|
"wave" : 4,
|
||||||
"emp" : 8,
|
"pulse" : 8,
|
||||||
"empulse" : 9
|
"emp" : 9,
|
||||||
|
"flash" : 12
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def ghost_of(self, topic):
|
||||||
|
# Return the ghost topic of topic
|
||||||
|
return "ghosts" + topic[topic.find('/'):]
|
||||||
|
|
||||||
|
def ghostly_payload(self, payload, mode_id):
|
||||||
|
return payload + int(mode_id).to_bytes(1, "little")
|
||||||
|
|
||||||
def mode_id(self, name):
|
def mode_id(self, name):
|
||||||
if name.isdecimal():
|
if name.isdecimal():
|
||||||
if int(name) in self.modes.values():
|
if int(name) in self.modes.values():
|
||||||
|
@ -1040,7 +1047,7 @@ if __name__ == "__main__":
|
||||||
help="apply local colorscheme PRESET to Fnordcenter")
|
help="apply local colorscheme PRESET to Fnordcenter")
|
||||||
group_cl.add_argument(
|
group_cl.add_argument(
|
||||||
"-m", "--magic", type=str, default="fade", metavar="MODE",
|
"-m", "--magic", type=str, default="fade", metavar="MODE",
|
||||||
help="EXPERIMENTAL: blend into preset (needs a running instance of fluffyd on the network). MODE is either \"fade\", \"wave\", \"emp\" or \"none\".")
|
help="EXPERIMENTAL: blend into preset (needs a running instance of fluffyd on the network). MODE is either \"fade\", \"wave\", \"emp[1]\", \"flash\" or \"none\".")
|
||||||
group_cl.add_argument(
|
group_cl.add_argument(
|
||||||
"-l", "--list-presets", action="store_true",
|
"-l", "--list-presets", action="store_true",
|
||||||
help="list locally available presets")
|
help="list locally available presets")
|
||||||
|
|
Loading…
Reference in a new issue