spacemanspiff2007 / PyArtNet

"Python wrappers for the Art-Net protocol to send DMX over Ethernet"
GNU General Public License v3.0
70 stars 14 forks source link

Using set_values #47

Open tmolberg opened 4 months ago

tmolberg commented 4 months ago

Hi,

Probably not an issue with the project but just wanted to check if im doing something wrong trying to set an explicite value and not a fade.

For reference, I have a PKnight Artnet4 - Cr041 (probably one of cheapest artnet controllers avaliable :D)

the fade function works as intended as shown in your example. If I on the other hand try to use the set_values function towards a device, nothing seems to happen. Changing the fade time to 0, seems to do something along the lines of what I want, it just feels wrong when there is a specific function to set the value directly.

I had a look in the issues list and found another reference of a person having issues using the set_values function. The example below does not seem to do anything.

import asyncio, time
from pyartnet import ArtNetNode

async def main():
    node = ArtNetNode('192.168.100.22', 6454, start_refresh_task=True)
    universe = node.add_universe(0)
    channel = universe.add_channel(start=1, width=6)
    channel.set_values([255,255,255,255,255,0]) #on this specific device, the last channel is used for special effects (strobes)
    await channel
    asyncio.sleep(1)
    channel.set_values([0,0,0,0,0,0])

asyncio.run(main())

Have I misunderstood how the set_values function should work?

tmolberg commented 4 months ago

Found another reference where set_values seems to be working.


    channel.set_values([255,255,255,0,255,0])
    await channel
    await asyncio.sleep(1)

    channel.set_values([0,0,0,0,0,0])
    await channel
    await asyncio.sleep(1)

Im wondering, whats the best way of handling that the light actually recieves the command to shut off? await channel doesnt seem to do anything when using set_values, but if I use await asyncio.sleep(1), then the light hits the target values which were requested.

I was more or less hoping everything needed would be to use channel.set_values([255,255,255,0,255,0]) and channel.set_values([0,0,0,0,0,0]) and it would do it, but then again, im not a developer

spacemanspiff2007 commented 4 months ago

When you create a node you specify with max_fps the interval at which the data will be sent to the device. Calling set_values will sent out the data with the next "tick", e.g. if you have max_fps=25 then you have to wait at least 40ms so the data can be sent because it could be that you just missed the send interval.

Awaiting an object waits for all Fades to complete. So the most easy solution would be to set a fade with maybe 0ms duration. and just call await channel or await node. Does that make it more clear?