def __init__(self): self.LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!). self.LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz) self.LED_DMA = 10 # DMA channel to use for generating signal (try 10) self.LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest self.LED_INVERT = False # True to invert the signal (when using NPN transistor level shift) self.LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53 self.LED_COUNT = 0 for j in [*c.hw.led]: if c.hw.led[j].interface == "neopx": self.LED_COUNT += 1 setattr(self, j, c.hw.led[j].index) super().__init__(self.LED_COUNT, self.LED_PIN, self.LED_FREQ_HZ, self.LED_DMA, self.LED_INVERT, self.LED_BRIGHTNESS, self.LED_CHANNEL) self.leds = [0 for i in range(self.LED_COUNT)] self.shm = shm self.shm.resize(self.LED_COUNT * 4) r.say("[neopx] shared memory size is {x}".format(x=self.LED_COUNT * 4)) try: self.read() except: pass self.begin() for j in range(self.numPixels()): if self.leds[j] == 0: self.leds[j] = super().getPixelColor(j) self.write()
def ps(*args, **kw): """Print out a list of all background processes and cron jobs.""" r.say("\n{0:20} T {1:50} {2:40} | PROCESSES".format( "Name", "Process", "Function")) for j in [*r.proc]: r.say("{name:20} {t:1} {process:49} {func}".format( name=j, process=repr(r.proc[j].process), func=repr(r.proc[j].func), t=r.proc[j].type[0])) r.say("---") r.say("{0:20} T {1:3} {2:91} | CRON JORBS".format("Name", "Int", "Function")) for j in [*r.cron]: r.say("{name:20} {t:1} {interval:3} {func}".format( name=j, interval=r.cron[j].interval, func=repr(r.cron[j].func), t=r.cron[j].type[0]))
#!/usr/bin/python3 with open("/run/shm/fursuitos.log", "w+") as f: pass from http.server import BaseHTTPRequestHandler, HTTPServer from addict import Dict from collections import OrderedDict import pprint import os, sys, importlib, time import fsts as ts import ui from config import c import r 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))
"mode": "Tail color" }) cnt = 0 if not config.c.cfg.swish or config.c.cfg.swish == "None": config.c.cfg.swish = defaults config.save() conf = config.c.cfg.swish com = config.c.cfg.common tnum = [0 for i in range(tails.numPixels())] for j in [*r.hw.led]: tnum[config.c.hw.led[j].index] = tails.findcolor(com[j]) r.say(tnum) def wheel(pos): """Generate rainbow colors across 0-255 positions.""" if pos < 85: return r.hw.drv.neopx.Color(pos * 3, 255 - pos * 3, 0) elif pos < 170: pos -= 85 return r.hw.drv.neopx.Color(255 - pos * 3, 0, pos * 3) else: pos -= 170 return r.hw.drv.neopx.Color(0, pos * 3, 255 - pos * 3) def swishgen(x, pix): global cnt
def log_message(self, fmt, *args): r.say("[HTTP@{0}] {1}".format(self.client_address[0], (fmt % args)))
except: c = Dict(Camel([caramel]).load(defaults)) return False def reset(): """Reset to default configuration.""" global c c = Dict(Camel([caramel]).load(defaults)) save() def mkmutual(node): if isinstance(node, int): who_are_they = r.extget("gateway").split(".")[0:3] + [str(node)] return "http://{0}.{1}.{2}.{3}/".format(who_are_they[0], who_are_they[1], who_are_they[2], who_are_they[3]) else: return node if load(): r.say("[FSConfig] Configuration loaded.") else: save() r.say("[FSConfig] Reset Config.") r.say(Camel([caramel]).dump(c.to_dict()))