I have been playing with my Raspberry Pi and Linux for a few weeks now. Most of the example code has been published on GitHub so I thought I'd give it a go and see what it's all about.
At first I tried to add a repository and then the code snippets. That didn't seem to work as I liked so had a quick look around and saw that you can add a Gist and embed that a lot better. You are also able to link to a raw piece of code. This will hopefully come in handy as I have an idea on how to use this. If it works I will cover it in another post.
All you need to do is create a GitHub account and add a new Gist. Save the Gist get the embedded link.
When you are writing your post, switch to HTML view and paste the script where you want it to appear in your post. You can then switch back to normal view to finish writing the post.
This file contains hidden or 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
@route('/flash') | |
def flash(): | |
# import flash | |
# flash.flashLed() | |
return template('templates/flash.tpl') | |
@route('/c_flash') | |
def c_flash(): | |
return template('templates/c_flash.tpl') | |
@route('/toggle', method='GET') | |
def toggle(): | |
if request.GET.get('Led1On','').strip(): | |
#turn on LED 1 | |
from quick2wire.gpio import Pin, exported | |
with exported(Pin(12, Pin.Out)) as out1: | |
out1.value = 1 | |
return template('templates/toggle.tpl') | |
elif request.GET.get('Led1Off','').strip(): | |
#turn off LED 1 | |
from quick2wire.gpio import Pin, exported | |
with exported(Pin(12, Pin.Out)) as out1: | |
out1.value = 0 | |
return template('templates/toggle.tpl') | |
elif request.GET.get('Led2On','').strip(): | |
#turn on LED 2 | |
from quick2wire.gpio import Pin, exported | |
with exported(Pin(13, Pin.Out)) as out2: | |
out2.value = 1 | |
return template('templates/toggle.tpl') | |
elif request.GET.get('Led2Off','').strip(): | |
#turn off LED 2 | |
from quick2wire.gpio import Pin, exported | |
with exported(Pin(13, Pin.Out)) as out2: | |
out2.value = 0 | |
return template('templates/toggle.tpl') | |
else: | |
return template('templates/toggle.tpl') |
Greg
No comments:
Post a Comment