Hardware Reference
In-Depth Information
url = self.urlGen( api.auth, d, sig )
ans = “”
try:
webbrowser.open( url )
print “You need to allow this program to access ;
your Flickr site.”
print “A web browser should pop open with instructions.”
print “When you have authenticated this application ;
type Y”
print “If you failed or don't want to then type N”
ans = raw_input(“Sucess? (Y/N): “)
except:
print str(sys.exc_info())
if ( ans.lower() == “n” ):
print “Please try again”
sys.exit()
he action of the function is the same, but the user instructions are much more clear.
The Final Roto-Sketch Program
With all the pieces of infrastructure in place you now come to the inal program which brings
this all together. he Roto-Sketch program is shown in Listing 15-4.
Listing 15-4 The Roto-Sketch Program
#!/usr/bin/env python
“””
Rotary Encoder Roto-sketch
encoder 1 wired to inputs 6 & 7
encoder 2 wired to inputs 4 & 5
Tilt switch wired to input 3
“””
import colorsys
from smbus import SMBus
import os, sys, pygame
from pygame.locals import *
import piface.pfio as pfio # piface library
import subprocess
pfio.init() # initialise piface
continued
 
Search WWH ::




Custom Search