from stupidArtnet import StupidArtnet
import time


def init_artnet(universe=0,target_ip="10.255.255.255") :
    #GrandMA2 seems to work only with target_ip="10.255.255.255"
    # THESE ARE MOST LIKELY THE VALUES YOU WILL BE NEEDING
    packet_size = 512								# it is not necessary to send whole universe

    # CREATING A STUPID ARTNET OBJECT
    # SETUP NEEDS A FEW ELEMENTS
    # TARGET_IP   = DEFAULT 127.0.0.1
    # UNIVERSE    = DEFAULT 0
    # PACKET_SIZE = DEFAULT 512
    # FRAME_RATE  = DEFAULT 30
    # ISBROADCAST = DEFAULT FALSE
    a = StupidArtnet(target_ip, universe, packet_size, 30, True, True)
    print(a)
    return a

def send_artnet_button(artnet,channel_num) :
    a = artnet
    a.set_single_value(channel_num, 255)			# set channel 1 to 255
    a.show()
    time.sleep(0.1)
    a.set_single_value(channel_num, 0)			# set channel 1 to 255
    a.show()

