-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_shelf.py
62 lines (45 loc) · 1.48 KB
/
client_shelf.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#! /usr/bin/python3
# -*- coding: utf-8 -*-
#
# Description : small script to test Post Tenebras Lab shelf REST node
#
#
#
#
#
#
__author__ = 'Sebastien Chassot'
__author_email__ = '[email protected]'
__version__ = "1.0.1"
__copyright__ = ""
__licence__ = "GPL"
__status__ = "Project"
import requests
import time
import random
SRV = '192.168.80.168'
PORT = '5000'
def set_led(x, y, color):
val = ":".join(('led', hex(color).__str__(), x.__str__(), y.__str__()))
requests.get('http://'+SRV+':'+PORT+'/ptl?values='+val)
def set_line(line, color):
val = ":".join(('line', hex(color).__str__(), line.__str__()) )
requests.get('http://'+SRV+':'+PORT+'/ptl?values='+val)
def set_column(col, color):
val = ":".join(('column', hex(color).__str__(), col.__str__()))
requests.get('http://'+SRV+':'+PORT+'/ptl?values='+val)
def set_all(color):
val = ":".join(('set_all', hex(color).__str__()))
requests.get('http://'+SRV+':'+PORT+'/ptl?values='+val)
def clear_all():
requests.get('http://'+SRV+':'+PORT+'/ptl?values=clear_all')
MIN = 50
MAX = 150
while(1):
color = random.randint(MIN, MAX) << 16 | random.randint(MIN, MAX) << 8 | random.randint(MIN, MAX)
set_led(random.randint(4, 7), random.randint(0, 14), color)
time.sleep(random.random())
# while(1):
# color = random.randint(MIN, MAX) << 16 | random.randint(MIN, MAX) << 8 | random.randint(MIN, MAX)
# set_line(random.randint(0, 15), color)
# time.sleep(random.random())