forked from fidepus/YAWP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbacklight.py
More file actions
34 lines (31 loc) · 955 Bytes
/
backlight.py
File metadata and controls
34 lines (31 loc) · 955 Bytes
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Switch the back ligth of a connected LCD on or off, depending on the time
import RPi.GPIO as GPIO
from datetime import datetime, time
def switch_light():
# get the time
now = datetime.now()
now_time = now.time()
# see if it is time to switch on the light
if now_time >= time(6,00) and now_time <= time(23,00):
with open('/home/pi/YAWP/display_light.txt', 'w') as backlight:
backlight.write('1')
light=1
# if not, switch it off
else:
with open('home/pi/YAWP/display_light.txt', 'w') as backlight:
backlight.write('0')
light=0
# Pin 11 gives out a "already in use warning".
# Don't know why, will have to test
# # Use physical pin numbers
# GPIO.setmode(GPIO.BOARD)
# # Set up header pin 11 (GPIO17) as an input
# print "Setup Pin 11"
# GPIO.setup(11, GPIO.OUT)
# # Do the actual switching
# if light==1:
# GPIO.output(11, True)
# else:
# GPIO.output(11, False)