-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpifacedigitalio.patch
69 lines (57 loc) · 1.89 KB
/
pifacedigitalio.patch
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
60
61
62
63
64
65
66
67
68
From 7e12d12e527d3e8cab6032caebc8a028b91451d8 Mon Sep 17 00:00:00 2001
From: Nicola Lunghi <nicola.lunghi@emutex.com>
Date: Thu, 29 Jun 2017 11:22:33 +0100
Subject: [PATCH] added support for UP2 and fix the examples
---
examples/blink.py | 5 ++++-
examples/presslights.py | 4 ++++
pifacedigitalio/core.py | 2 +-
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/examples/blink.py b/examples/blink.py
index a93cc1d..43cb568 100644
--- a/examples/blink.py
+++ b/examples/blink.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
from time import sleep
import pifacedigitalio
@@ -8,5 +9,7 @@ DELAY = 1.0 # seconds
if __name__ == "__main__":
pifacedigital = pifacedigitalio.PiFaceDigital()
while True:
- pifacedigital.leds[7].toggle()
+ for i in range(8):
+ pifacedigital.leds[i].toggle()
sleep(DELAY)
+
diff --git a/examples/presslights.py b/examples/presslights.py
index 97daf5a..86d2818 100644
--- a/examples/presslights.py
+++ b/examples/presslights.py
@@ -1,11 +1,14 @@
+#!/usr/bin/env python3
import pifacedigitalio
def switch_pressed(event):
+ print("Switch Pressed ", event.pin_num)
event.chip.output_pins[event.pin_num].turn_on()
def switch_unpressed(event):
+ print("Switch Pressed ", event.pin_num)
event.chip.output_pins[event.pin_num].turn_off()
@@ -17,3 +20,4 @@ if __name__ == "__main__":
listener.register(i, pifacedigitalio.IODIR_ON, switch_pressed)
listener.register(i, pifacedigitalio.IODIR_OFF, switch_unpressed)
listener.activate()
+
diff --git a/pifacedigitalio/core.py b/pifacedigitalio/core.py
index 1efdb40..a0b5801 100644
--- a/pifacedigitalio/core.py
+++ b/pifacedigitalio/core.py
@@ -2,7 +2,7 @@ import pifacecommon.mcp23s17
import pifacecommon.interrupts
# /dev/spidev<bus>.<chipselect>
-DEFAULT_SPI_BUS = 0
+DEFAULT_SPI_BUS = 1
DEFAULT_SPI_CHIP_SELECT = 0
MAX_BOARDS = 4
--
2.9.3