forked from SteveAmor/RPiMobTimer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRPiMobTimer.py
executable file
·69 lines (57 loc) · 1.97 KB
/
RPiMobTimer.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/python
#Mob programming screen blanking timer by Steve Amor
#For the Raspberry Pi - add to /etc/xdg/lxsession/LXDE-pi/autostart
import pygame, sys, time, os
from pygame.locals import *
# constants
TIMEOUT = 600 # Timer in seconds between changing Driver
WAITTIME = 20 # seconds to leave New Driver message on screen
# set up the colours
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
def message(msgText, backgroundColour):
windowSurface.fill(backgroundColour)
basicFont = pygame.font.SysFont(None, 160)
text = basicFont.render(msgText, True, WHITE, backgroundColour)
textRect = text.get_rect()
textRect.centerx = windowSurface.get_rect().centerx
textRect.centery = windowSurface.get_rect().centery
windowSurface.blit(text, textRect)
pygame.display.update()
def smallMessage(smallText, backgroundColour):
basicFont = pygame.font.SysFont(None, 30)
text = basicFont.render(smallText, True, WHITE, backgroundColour)
textRect = text.get_rect()
textRect.centerx = windowSurface.get_rect().centerx
textRect.centery = windowSurface.get_rect().centery+100
windowSurface.blit(text, textRect)
pygame.display.update()
def countdown(counter):
while counter != 0:
smallMessage(' %s '%counter, BLACK)
counter=counter-1
time.sleep(1)
def waitForSpaceKey():
pygame.event.clear()
spacePressed = False
while not spacePressed:
time.sleep(0.1)
for event in pygame.event.get():
if event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:
spacePressed = True
#main starts here
while True:
time.sleep(TIMEOUT)
os.system("xdotool mousemove 2000 2000 click 1") # fix if you are hovered over a menu option
time.sleep(1)
pygame.init()
# windowSurface = pygame.display.set_mode((800, 600), 0,32)
windowSurface = pygame.display.set_mode((800, 600), FULLSCREEN)
message('Change Driver', BLACK)
countdown(WAITTIME)
smallMessage("Press space to continue with new driver",BLACK)
waitForSpaceKey()
pygame.display.quit()