Пример #1
0
def handler(params):
    try:
        params["action"][0]
    except:
        return "Saved configuration."
    if params["action"][0] == "on":
        # Turning a fursuit part on simply calls its autorun method again.
        if config.c.cfg.fursuit.autorun:
            for j in config.c.cfg.fursuit.autorun:
                if not callable(r.fs[j].handler): continue
                try:
                    r.fs[j].handler(None)
                except:
                    r.ERR()
        return "Your fursuit {part} is now ON.".format(part=config.c.part)
    elif params["action"][0] == "off":
        # To turn off a fursuit part, kill its process groups
        for j in [*r.proc]:
            if j.find("_") > -1:
                fsts.stop(j)
        # Then call the off() method for all hardware.
        for j in [*r.hw.drv]:
            if callable(r.hw.drv[j].off):
                r.hw.drv[j].off()
        return "Your fursuit {part} is now OFF.".format(part=config.c.part)
Пример #2
0
 def findcolor(self, x):
     if isinstance(x, int):
         return x
     elif isinstance(x, str):
         if x[0] == "#":
             x = x[1:-1]
         return Color(int(x[0:2], base=16), int(x[2:4], base=16),
                      int(x[4:6], base=16))
     elif isinstance(x, list):
         return Color(x[0], x[1], x[2])
     elif isinstance(x, dict):
         return Color(x["r"], x["g"], x["b"])
     else:
         r.ERR()
         return 0
Пример #3
0
def blink():
    global conf,com
    try:
        while True:
            if conf.mode == "Custom":
                eyel = conf.eyel
                eyer = conf.eyer
            elif conf.mode == "Random":
                eyel = None
                eyer = None
            else:
                eyel = com.eyel
                eyer = com.eyer
            if conf.mode == "Random":
                randl = random.randint(0,16777216)
                randr = random.randint(0,16777216)
            if eyel is not None:
                rl = int(head.findcolor_component(eyel, "r"))
                gl = int(head.findcolor_component(eyel, "g"))
                bl = int(head.findcolor_component(eyel, "b"))
            else:
                rl = int(head.findcolor_component(randl, "r"))
                gl = int(head.findcolor_component(randl, "g"))
                bl = int(head.findcolor_component(randl, "b"))
            if eyer is not None:
                rr = int(head.findcolor_component(eyer, "r"))
                gr = int(head.findcolor_component(eyer, "g"))
                br = int(head.findcolor_component(eyer, "b"))
            else:
                rr = int(head.findcolor_component(randr, "r"))
                gr = int(head.findcolor_component(randr, "g"))
                br = int(head.findcolor_component(randr, "b"))
            head["eyel"]=dimmer(head.findcolor([rl,gl,bl]))
            head["eyer"]=dimmer(head.findcolor([rr,gr,br]))
            head.show()
            time.sleep(random.randint(conf.timel,conf.timeh)/1000)
            head["eyel"]=0
            head["eyer"]=0
            head.show()
            time.sleep(random.randint(50,250)/1000)
    except:
        r.ERR()
Пример #4
0
def solid():
    global conf,com
    try:
        if conf.mode == "Custom":
            antl = conf.antl
            antr = conf.antl
        elif conf.mode == "Random":
            antl = None
            antr = None
        else:
            antl = com.antl
            antr = com.antr
        while True:
            if conf.mode == "Random":
                randl = random.randint(0,16777216)
                randr = random.randint(0,16777216)
            if antl is not None:
                rl = int(head.findcolor_component(antl, "r"))
                gl = int(head.findcolor_component(antl, "g"))
                bl = int(head.findcolor_component(antl, "b"))
            else:
                rl = int(head.findcolor_component(randl, "r"))
                gl = int(head.findcolor_component(randl, "g"))
                bl = int(head.findcolor_component(randl, "b"))
            if antr is not None:
                rr = int(head.findcolor_component(antr, "r"))
                gr = int(head.findcolor_component(antr, "g"))
                br = int(head.findcolor_component(antr, "b"))
            else:
                rr = int(head.findcolor_component(randr, "r"))
                gr = int(head.findcolor_component(randr, "g"))
                br = int(head.findcolor_component(randr, "b"))
            head["antl"]=head.findcolor([rl,gl,bl])
            head["antr"]=head.findcolor([rr,gr,br])
            head.show()
            time.sleep(conf.time/1000)
    except:
        r.ERR()
Пример #5
0
def throb():
    global conf, com
    throb = -255.0
    randl = random.randint(0, 16777216)
    randr = random.randint(0, 16777216)
    try:
        if conf.mode == "Custom":
            eyel = conf.eyel
            eyer = conf.eyer
        elif conf.mode == "Random":
            eyel = None
            eyer = None
        else:
            eyel = com.eyel
            eyer = com.eyer
        while True:
            # eyes throb section
            if throb > 255.0: throb = -255.0
            throb = throb + 1.0
            if throb == 0.0:
                randl = random.randint(0, 16777216)
                randr = random.randint(0, 16777216)
            if eyel is not None:
                rl = int(
                    head.findcolor_component(eyel, "r") * (abs(throb) / 256.0))
                gl = int(
                    head.findcolor_component(eyel, "g") * (abs(throb) / 256.0))
                bl = int(
                    head.findcolor_component(eyel, "b") * (abs(throb) / 256.0))
            else:
                rl = int(
                    head.findcolor_component(randl, "r") *
                    (abs(throb) / 256.0))
                gl = int(
                    head.findcolor_component(randl, "g") *
                    (abs(throb) / 256.0))
                bl = int(
                    head.findcolor_component(randl, "b") *
                    (abs(throb) / 256.0))
            if eyer is not None:
                rr = int(
                    head.findcolor_component(eyer, "r") * (abs(throb) / 256.0))
                gr = int(
                    head.findcolor_component(eyer, "g") * (abs(throb) / 256.0))
                br = int(
                    head.findcolor_component(eyer, "b") * (abs(throb) / 256.0))
            else:
                rr = int(
                    head.findcolor_component(randr, "r") *
                    (abs(throb) / 256.0))
                gr = int(
                    head.findcolor_component(randr, "g") *
                    (abs(throb) / 256.0))
                br = int(
                    head.findcolor_component(randr, "b") *
                    (abs(throb) / 256.0))
            head["eyel"] = dimmer(head.findcolor([rl, gl, bl]))
            head["eyer"] = dimmer(head.findcolor([rr, gr, br]))
            head.show()
            time.sleep(1 * (1 / (conf.speed if conf.speed > 0 else 1)))
    except:
        r.ERR()
Пример #6
0
def throb():
    global conf, com
    throb = -255.0
    randl = random.randint(0, 16777216)
    randr = random.randint(0, 16777216)
    try:
        if conf.mode == "Custom":
            antl = conf.antl
            antr = conf.antr
        elif conf.mode == "Random":
            antl = None
            antr = None
        else:
            antl = com.antl
            antr = com.antr
        while True:
            # Antennae throb section
            if throb > 255.0: throb = -255.0
            throb = throb + 1.0
            if throb == 0.0:
                randl = random.randint(0, 16777216)
                randr = random.randint(0, 16777216)
            if antl is not None:
                rl = int(
                    head.findcolor_component(antl, "r") * (abs(throb) / 256.0))
                gl = int(
                    head.findcolor_component(antl, "g") * (abs(throb) / 256.0))
                bl = int(
                    head.findcolor_component(antl, "b") * (abs(throb) / 256.0))
            else:
                rl = int(
                    head.findcolor_component(randl, "r") *
                    (abs(throb) / 256.0))
                gl = int(
                    head.findcolor_component(randl, "g") *
                    (abs(throb) / 256.0))
                bl = int(
                    head.findcolor_component(randl, "b") *
                    (abs(throb) / 256.0))
            if antr is not None:
                rr = int(
                    head.findcolor_component(antr, "r") * (abs(throb) / 256.0))
                gr = int(
                    head.findcolor_component(antr, "g") * (abs(throb) / 256.0))
                br = int(
                    head.findcolor_component(antr, "b") * (abs(throb) / 256.0))
            else:
                rr = int(
                    head.findcolor_component(randr, "r") *
                    (abs(throb) / 256.0))
                gr = int(
                    head.findcolor_component(randr, "g") *
                    (abs(throb) / 256.0))
                br = int(
                    head.findcolor_component(randr, "b") *
                    (abs(throb) / 256.0))
            head["antl"] = head.findcolor([rl, gl, bl])
            head["antr"] = head.findcolor([rr, gr, br])
            head.show()
            time.sleep(1 * (1 / (conf.speed if conf.speed > 0 else 1)))
    except:
        r.ERR()
Пример #7
0
r.say("FursuitOS v{0} (C) 2018 Alynna Trypnotk, GPL3".format(r.version))

r.say(pprint.pformat(c))
# Start up the hardware handlers.  Expected to be common between fursuits.
# Config file specifies what is handled
for hwtype in c.hw:
    for hwunit in c.hw[hwtype]:
        try:
            r.hw[hwtype][hwunit].driver = importlib.import_module(
                "hw.{0}".format(c.hw[hwtype][hwunit].interface))
            r.hw[hwtype][hwunit].unit = c.hw[hwtype][hwunit].index
            r.hw.drv[c.hw[hwtype][hwunit].interface] = importlib.import_module(
                "hw.{0}".format(c.hw[hwtype][hwunit].interface))
        except Exception as e:
            r.ERR()
            r.say(
                "[HW] Failed to load {0} due to error {1}.  Skipping module.".
                format(j[0:-3], e))

r.say("\nDevice tree: \n" + pprint.pformat(r.hw))

# Search for mods and sort them by loading order.
known_mods = c.mod
found_mods = []

# Look for any module that starts with "common" and load it first.
try:
    found_mods += [
        x[0:-3] for x in os.listdir("./fs/")
        if x.startswith("common") and x.endswith(".py")
Пример #8
0
 def __setitem__(self, x, c):
     try:
         self.setPixelColor(self.findled(x), self.findcolor(c))
     except:
         r.ERR()
Пример #9
0
 def __getitem__(self, x):
     try:
         self.getPixelColor(self.findled(x))
     except:
         r.ERR()
         return -1