aboutsummaryrefslogtreecommitdiff
path: root/turtetris_slave/leds.py
blob: cdafca21805736b484543f80158b203040a779f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from subprocess import call


def prepare():
    "Prepare leds"
    call("rainbow all enable intensity 10 FFFFFF", shell=True)


def clear():
    "Clear previous changes"
    call("rainbow all auto", shell=True)


__MAP__ = [
    'pwr',
    'lan0',
    'lan1',
    'lan2',
    'lan3',
    'lan4',
    'wan',
    'pci1',
    'pci2',
    'pci3',
    'usr1',
    'usr2'
]


def output(data):
    "Output received data to leds"
    args = ['rainbow']
    for i in range(0, 12):
        args.append(__MAP__[i])
        args.append(str(data[i]['color']))
        args.append('intensity')
        args.append(str(data[i]['intens']))
    call(args)