-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
37 lines (27 loc) · 864 Bytes
/
test.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
import sys
import pigpio
import lightwaverf.lwrf
# This is a simple test class for the lwrf and pigpiod programs.
# The GPIO pin on the Pi you've connected the transmitter to.
# You probably need to change this!
gpio_pin = 7
# How often to repeat the signal, 3 seems to be OK.
repeat = 3
# An ID that must be unique for each dimmer. For testing, we can just use a constant
id = 1
pi = pigpio.pi() # Connect to GPIO daemon.
tx = lightwaverf.lwrf.tx(pi, gpio_pin)
value = int(sys.argv[1])
if (value == 0):
tx_val = 64 # according to the LightwaveRF docs, when turning off, this should be 64.
c = 0 # "command" setting i.e. on/off
else:
tx_val = value + 128
c = 1
a = tx_val >> 4 # first 4 bits
b = tx_val % 16 # last 4 bits
data = [a, b, 0, c, 15, id, 0, 0, 0, 0]
tx.put(data, repeat)
print("Sent " + str(value))
tx.cancel();
pi.stop();