-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:pvcraven/networking_down_under
- Loading branch information
Showing
12 changed files
with
314 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import time | ||
import RPi.GPIO as GPIO | ||
|
||
CLOCK_CHANNEL = 16 | ||
DATA_CHANNEL = 23 | ||
|
||
# This is a callback function that will be called whenever we have a high/low | ||
# or low/high change in the signal. | ||
def my_callback(channel): | ||
result = GPIO.input(DATA_CHANNEL); | ||
if result: | ||
print("1") | ||
else: | ||
print("0") | ||
|
||
# Set pin 12 up for input | ||
GPIO.setmode(GPIO.BCM) | ||
GPIO.setup(CLOCK_CHANNEL, GPIO.IN) | ||
GPIO.setup(DATA_CHANNEL, GPIO.IN) | ||
|
||
# Now we have to 'register' the callback function so that the GPIO library | ||
# will call the function when the change occurs on pin 12. | ||
# GPIO.BOTH means it is called on both rising and falling changes. | ||
# Use GPIO.FALLING if you want it called for high to low | ||
# Use GPIO.RISING if you want it called low to high | ||
GPIO.add_event_detect(CLOCK_CHANNEL, GPIO.FALLING, callback=my_callback) | ||
|
||
# Now just wait forever. | ||
print("Running") | ||
while True: | ||
time.sleep(10) | ||
print("Still running") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import time | ||
import RPi.GPIO as GPIO | ||
|
||
CLOCK_CHANNEL = 16 | ||
DATA_CHANNEL = 23 | ||
|
||
# This is a callback function that will be called whenever we have a high/low | ||
# or low/high change in the signal. | ||
def my_callback(channel): | ||
result = GPIO.input(DATA_CHANNEL); | ||
if result: | ||
print("1", end="") | ||
else: | ||
print("0", end="") | ||
|
||
my_callback.counter += 1 | ||
if my_callback.counter > 7: | ||
print() | ||
my_callback.counter = 0 | ||
|
||
my_callback.counter = 0 | ||
|
||
# Set pin 12 up for input | ||
GPIO.setmode(GPIO.BCM) | ||
GPIO.setup(CLOCK_CHANNEL, GPIO.IN) | ||
GPIO.setup(DATA_CHANNEL, GPIO.IN) | ||
|
||
# Now we have to 'register' the callback function so that the GPIO library | ||
# will call the function when the change occurs on pin 12. | ||
# GPIO.BOTH means it is called on both rising and falling changes. | ||
# Use GPIO.FALLING if you want it called for high to low | ||
# Use GPIO.RISING if you want it called low to high | ||
GPIO.add_event_detect(CLOCK_CHANNEL, GPIO.FALLING, callback=my_callback) | ||
|
||
# Now just wait forever. | ||
print("Running") | ||
while True: | ||
time.sleep(10) | ||
print("Still running") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import time | ||
import RPi.GPIO as GPIO | ||
|
||
CLOCK_CHANNEL = 16 | ||
DATA_CHANNEL = 23 | ||
|
||
# This is a callback function that will be called whenever we have a high/low | ||
# or low/high change in the signal. | ||
def my_callback(channel): | ||
result = GPIO.input(DATA_CHANNEL); | ||
if result: | ||
print("1", end="") | ||
my_callback.result_byte += 1 << (7 - my_callback.counter) | ||
else: | ||
print("0", end="") | ||
|
||
my_callback.counter += 1 | ||
if my_callback.counter > 7: | ||
print(" = {} = {}".format(my_callback.result_byte, chr(my_callback.result_byte))) | ||
my_callback.counter = 0 | ||
my_callback.result_byte = 0 | ||
|
||
my_callback.counter = 0 | ||
my_callback.result_byte = 0 | ||
|
||
# Set pin 12 up for input | ||
GPIO.setmode(GPIO.BCM) | ||
GPIO.setup(CLOCK_CHANNEL, GPIO.IN) | ||
GPIO.setup(DATA_CHANNEL, GPIO.IN) | ||
|
||
# Now we have to 'register' the callback function so that the GPIO library | ||
# will call the function when the change occurs on pin 12. | ||
# GPIO.BOTH means it is called on both rising and falling changes. | ||
# Use GPIO.FALLING if you want it called for high to low | ||
# Use GPIO.RISING if you want it called low to high | ||
GPIO.add_event_detect(CLOCK_CHANNEL, GPIO.FALLING, callback=my_callback) | ||
|
||
# Now just wait forever. | ||
print("Running") | ||
while True: | ||
time.sleep(60) | ||
print("Still running") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
cherrypy | ||
pillow | ||
colorama | ||
colorama | ||
lxml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.