Skip to content

Commit 69801c7

Browse files
committed
test implement of GPIO control via Raspberry PI
1 parent 295888f commit 69801c7

File tree

2 files changed

+36
-130
lines changed

2 files changed

+36
-130
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from gpiozero import DigitalOutputDevice
2+
from gpiozero.pins.pigpio import PiGPIOFactory
3+
BOARD_IP = '192.168.1.2'
4+
5+
6+
7+
class DigitialPiBoardDevice:
8+
"""
9+
Digital modulated devices in combination with Raspberry Pi GPIO
10+
"""
11+
12+
def __init__(self, PIN, BOARD_IP: str = None, remote: bool = False):
13+
"""
14+
:param BOARD_IP: IP adress of board connected to the Device
15+
"""
16+
if remote:
17+
self._factory = PiGPIOFactory(host = BOARD_IP)
18+
self._device = DigitalOutputDevice(PIN= PIN, pin_factory = self._factory)
19+
else:
20+
self._factory = None
21+
self._device = DigitalOutputDevice(PIN = PIN)
22+
self._running = False
23+
24+
def turn_on(self):
25+
self._device.on()
26+
self._running = True
27+
28+
def turn_off(self):
29+
self._device.off()
30+
self._running = False
31+
32+
def toggle(self):
33+
self._device.toggle()
34+
self._running = self._device.is_active
35+
36+

experiments/utils/readme.md

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)