-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathdraw.py
130 lines (110 loc) · 3.89 KB
/
draw.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
'''
A place for my main draw functions.
Just an attempt to clean up the main file.
'''
from main import *
def mileage():
'''
Text File or Odometer and Tripometer Information (pulled from ManxGauged project, just reads from text file
Need to incorporate writing to the file after I figure out how to tabulate the mileage based on GPS or CV
'''
global odo_font
odometer = 0
tripometer = 0
odofile = open("odo.txt", "r")
odo_from_file_text_line1 = odofile.readline()
response = odo_from_file_text_line1.replace('\n', "")
response2 = response.replace('\r', "")
response3 = response2.replace("odo:", "")
try:
odometer = int(response3)
except:
print("Error: ODO read from file is not an int")
error_reading_odo_from_file = 1
odometer_arduino = odometer
odo_from_file_text_line2 = odofile.readline()
response = odo_from_file_text_line2.replace('\n', "")
response2 = response.replace('\r', "")
response3 = response2.replace("trip:", "")
try:
tripometer = int(response3)
except:
print
"Error: Trip read from file is not an int"
error_reading_odo_from_file = 1
odofile.close()
# Drawing the Odometer
digital_odo = odometer
odo_text = odo_font.render(str(digital_odo), True, NEON_GREEN)
text_rect = odo_text.get_rect()
text_rect.midright = ODO_L_XY
WIN.blit(odo_text, text_rect)
def draw_clock():
'''
Drawing the clock - currently only 24hr. I'm sure its easy to adapt to 12hr.
'''
now = datetime.now()
bgclock_text = digital_font.render("00:00", True, DARK_GREY)
WIN.blit(bgclock_text, CLOCK_XY)
digital_text = now.strftime('%H:%M')
text = digital_font.render(digital_text, True, NEON_GREEN)
WIN.blit(text, CLOCK_XY)
#####
# Functions for Drawing onto the screen
#####
def draw_fuel_text():
global digital_font
digital_fuel = fuel_status
fuel_text = digital_font.render(str(int(digital_fuel)), True, NEON_GREEN)
text_rect = fuel_text.get_rect()
text_rect.midright = 1717, 667
WIN.blit(fuel_text, text_rect)
def draw_speedometer_text():
''' Speedometer Font Testing '''
global speed_status
global font_speedunits
speedtext = font_speedunits.render(str(speed_status), True, NEON_YELLOW)
text_rect = speedtext.get_rect()
text_rect.midright = SPEEDO_XY
WIN.blit(speedtext, text_rect)
def draw_mfa():
'''
Drawing the clock and interior temp - should seperate as the MFA will eventually evolve.
'''
global outside_temp_status
WIN.blit(MFA, MFABG_XY)
# Draw MFA display
text = digital_font.render(str(outside_temp_status), True, NEON_GREEN)
# Enables the text to be right center aligned
text_rect = text.get_rect()
text_rect.midright = MFA_XY
WIN.blit(text, text_rect)
def draw_indicators():
'''
The area where I blit or draw the indicators/idiot lights and turn signals/low fuel etc.
'''
if illumination_state == 1:
WIN.blit(indicator_images[0], (45, 460))
if foglight_state == 1:
WIN.blit(indicator_images[1], (185, 460))
if defog_state == 1:
WIN.blit(indicator_images[2], (325, 460))
if highbeam_state == 1:
WIN.blit(indicator_images[3], (465, 460))
if leftturn_state == 1:
WIN.blit(indicator_images[4], (605, 460))
if rightturn_state == 1:
WIN.blit(indicator_images[5], (1220, 460))
if brakewarn_state == 1:
WIN.blit(indicator_images[6], (1360, 460))
if oillight_state == 1:
WIN.blit(indicator_images[7], (1500, 460))
if alt_state == 1:
WIN.blit(indicator_images[8], (1640, 460))
if glow_state == 1:
WIN.blit(indicator_images[9], (1780, 460))
# To highlight the fuel reserve indicator (factory is at 7 litres
if fuel_status <= 7:
WIN.blit(fuelresOn, (1795, 616))
else:
WIN.blit(fuelresOff, (1795, 616))