Fixing up the Pi Project

The code to do this was easy, too:

 

def initRoutine(self):

.....

 

RPi.GPIO.setmode(RPi.GPIO.BCM)

RPi.GPIO.setup(16, RPi.GPIO.IN)

 

self.lastInput = None

self.screenTimer = QTimer(self)

self.screenTimer.timeout.connect(self.checkScreenButton)

self.screenTimer.setInterval(100)

self.screenTimer.start()

 

def checkScreenButton(self):

input = RPi.GPIO.input(16)

if input != self.lastInput:

self.lastInput = input;

if input == 0:

os.system('sudo sh -c \'echo "0" > /sys/class/graphics/fb1/blank\'')

else:

os.system('sudo sh -c \'echo "1" > /sys/class/graphics/fb1/blank\'')

 

133 views
0 faves
0 comments
Uploaded on May 20, 2017