-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathimportSingleOverlay.py
145 lines (92 loc) · 3.49 KB
/
importSingleOverlay.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/python
# importSingleDial.py
#Copyright (C) 2014 Eilidh Fridlington http://eilidh.fridlington.com
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>
import os
import sys
import time
import dials as dd
import pygame
import pygame.camera
from pygame.locals import *
pygame.camera.init()
os.environ['SDL_VIDEO_WINDOW_POS'] = 'center'
size = width, height = 640, 480
cam = pygame.camera.Camera("/dev/video0",(640,480))
# start the camera
cam.start()
pygame.display.set_caption('K11Consult')
monitorX = pygame.display.Info().current_w
monitorY = pygame.display.Info().current_h
surface1FullscreenX = (monitorX / 2) - 150
surface1FullscreenY = (monitorY / 2) - 60
surface1WindowedX = (width / 2) - 150
surface1WindowedY = (height / 2) - 60
surface1X = surface1WindowedX
surface1Y = surface1WindowedY
surface2FullscreenX = (monitorX / 2) - 320
surface2FullscreenY = (monitorY / 2) - 240
surface2WindowedX = 0 #(width / 2) - 150
surface2WindowedY = 0 #(height / 2) -150
surface2X = surface2WindowedX
surface2Y = surface2WindowedY
screen = pygame.display.set_mode(size)
surface1 = pygame.Surface((300,300))
#cam = pygame.Surface((640,480))
surface1.set_colorkey(0x0000FF)
#screen.fill(0x000000)
TEMP_Value = 1
TEMP_Max_Value = 140
imageCounter = 0
while True:
pygame.time.Clock().tick(30)
image = cam.get_image().convert()
for event in pygame.event.get():
if event.type==pygame.QUIT:
sys.exit()
pygame.quit()
if event.type is KEYDOWN and event.key == K_q:
sys.exit()
pygame.quit()
if event.type is KEYDOWN and event.key == K_w:
pygame.display.set_mode(size)
#pygame.mouse.set_visible(False)
surface1X = surface1WindowedX
surface1Y = surface1WindowedY
surface2X = surface2WindowedX
surface2Y = surface2WindowedY
#screen.fill(0x000000)
if event.type is KEYDOWN and event.key == K_f:
pygame.display.set_mode((monitorX,monitorY), FULLSCREEN)
surface1X = surface1FullscreenX
surface1Y = surface1FullscreenY
surface2X = surface2FullscreenX
surface2Y = surface2FullscreenY
#screen.fill(0x000000)
#pygame.mouse.set_visible(False)
# Setting the surface fill to the surface color key fixes transparency
surface1.fill(0x0000FF)
dd.Dials().indicatorNeedle(surface1,TEMP_Value,148,150,280,dd.Dials.twenty,dd.Dials.BLACK,0,0,(TEMP_Max_Value / 10),6,3,1,True,True,"Temperature",dd.Dials.degree)
if imageCounter % 1 == 0:
screen.blit(image,(surface2X,surface2Y))
screen.blit(surface1,(surface1X,surface1Y))
#time.sleep(0.08)
if TEMP_Value < TEMP_Max_Value:
TEMP_Value = TEMP_Value + 1
else:
TEMP_Value = 1
if imageCounter <= 100:
imageCounter += 1
else:
imageCounter = 0
pygame.display.update()
#print imageCounter