-
Notifications
You must be signed in to change notification settings - Fork 38
/
main.py
2083 lines (1842 loc) · 74.6 KB
/
main.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import kivy
#kivy.require('1.0.6')
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.togglebutton import ToggleButton
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
from kivy.uix.slider import Slider
from kivy.uix.switch import Switch
from kivy.clock import Clock
from kivy.graphics import Color, Rectangle
from kivy.uix.widget import Widget
from kivy.graphics import Color, Line
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.anchorlayout import AnchorLayout
from math import cos, sin, pi
from kivy.clock import Clock
from kivy.lang import Builder
from kivy.properties import NumericProperty, StringProperty, BooleanProperty, ListProperty, ObjectProperty
from kivy.uix.label import Label
from kivy.logger import Logger
from kivy.uix.screenmanager import ScreenManager, Screen, NoTransition, SlideTransition
from kivy.animation import Animation
from kivy.core.window import Window
from kivy.uix.scatter import Scatter
from kivy.uix.relativelayout import RelativeLayout
from kivy.uix.image import AsyncImage
from kivy.app import App
from kivy.lang import Builder
from kivy.metrics import dp
from kivy.properties import ObjectProperty
from kivy.uix.image import Image
from kivymd.button import MDIconButton
from kivymd.label import MDLabel
from kivymd.list import ILeftBody, ILeftBodyTouch, IRightBodyTouch
from kivymd.theming import ThemeManager
from kivymd.dialog import MDDialog
import kivymd.snackbar as Snackbar
import os
os.environ["KIVY_IMAGE"]="pil"
#from kivy.garden.mapview import MapView
#I know global variables are the devil....but they are so easy
#set to 1 to disable all GPIO, temp probe, and obd stuff
global developermode
developermode = 1
global devtaps #used to keep track of taps on settings label - 5 will force devmode
devtaps = 0
global version
version = "V2.3.0"
#10/20/2017
#Created by Joel Zeller
# For PC dev work -----------------------
if developermode == 1:
from kivy.config import Config
Config.set('graphics', 'width', '800')
Config.set('graphics', 'height', '480')
from kivy.core.window import Window
Window.size = (800, 480)
# ---------------------------------------
if developermode == 0:
import RPi.GPIO as GPIO
import obd
import serial
global adxl345
import sys
import datetime
import time
import os
import subprocess
import glob
import math
import socket
import pickle
#IP address in System Diagnostics
cmd = "ip addr show wlan0 | grep inet | awk '{print $2}' | cut -d/ -f1"
def get_ip_address():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
return s.getsockname()[0]
global ip
try:
ip = get_ip_address()
except:
ip = "No IP address found..."
#AutoBrightness on Boot #set to 1 if you have the newer RPi display and want autobrightness
#set to 0 if you do not or do not want autobrightness
#adjust to suit your needs :)
global autobrightness
autobrightness = 0
if developermode == 0:
if autobrightness == 1: #temporary method
currenthour = int(time.strftime("%-H")) #hour as decimal (24hour)
if currenthour < 7 or currenthour > 21: #earlier than 7am and later than 9pm -> dim screen on start
print "dim"
os.system("sudo echo 15 > /sys/class/backlight/rpi_backlight/brightness") # sets screen brightness to ~ 10%
if currenthour >= 7 and currenthour <= 20: #later than 7am and before 8pm -> full bright on start
print "bright"
os.system("sudo echo 175 > /sys/class/backlight/rpi_backlight/brightness") # sets screen brightness to ~ 100%
#_____________________________________________________________
#GPIO SETUP
#name GPIO pins
seekupPin = 13
seekdownPin = 19
auxPin = 16
amfmPin = 26
garagePin = 20
radarPin = 21
ledsPin = 5
driverwindowdownPin = 17
driverwindowupPin = 15
passwindowdownPin = 27
passwindowupPin = 18
HotKey1Pin = 12
HotKey2Pin = 6
if developermode == 0:
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(seekupPin, GPIO.OUT)
GPIO.setup(seekdownPin, GPIO.OUT)
GPIO.setup(auxPin, GPIO.OUT)
GPIO.setup(amfmPin, GPIO.OUT)
GPIO.setup(garagePin, GPIO.OUT)
GPIO.setup(radarPin, GPIO.OUT)
GPIO.setup(ledsPin, GPIO.OUT)
GPIO.setup(driverwindowdownPin, GPIO.OUT)
GPIO.setup(driverwindowupPin, GPIO.OUT)
GPIO.setup(passwindowdownPin, GPIO.OUT)
GPIO.setup(passwindowupPin, GPIO.OUT)
GPIO.setup(HotKey1Pin, GPIO.IN)
GPIO.setup(HotKey2Pin, GPIO.IN)
#initial state of GPIO
GPIO.output(seekupPin, GPIO.HIGH)
GPIO.output(seekdownPin, GPIO.HIGH)
GPIO.output(auxPin, GPIO.HIGH)
GPIO.output(amfmPin, GPIO.HIGH)
GPIO.output(garagePin, GPIO.HIGH)
GPIO.output(radarPin, GPIO.HIGH)
GPIO.output(ledsPin, GPIO.LOW)
GPIO.output(driverwindowdownPin, GPIO.HIGH)
GPIO.output(driverwindowupPin, GPIO.HIGH)
GPIO.output(passwindowdownPin, GPIO.HIGH)
GPIO.output(passwindowupPin, GPIO.HIGH)
#_________________________________________________________________
#OBD STUFF
global OBDON #var for displaying obd gauges
OBDVAR = "NONE"
#0 - OFF
#1 - Digital Speed
#2 - Digital Tach
#3 - Graphic
#4 - Coolant Temp
#5 - Intake Temp
#6 - Engine Load
#7 - Throttle Pos
#8 - Intake Pressure
#_________________________________________________________________
#TEMP PROBE STUFF
global TempProbePresent #set to 1 if temp probe is connected, 0 if not
TempProbePresent = 1
global AccelPresent #set to 1 if adxl345 accelerometer is present
AccelPresent = 1
global accelxmaxpos
global accelxmaxneg
global accelymaxpos
global accelymaxneg
accelxmaxpos = 0
accelxmaxneg = 0
accelymaxpos = 0
accelymaxneg = 0
if developermode == 1:
TempProbePresent = 0
AccelPresent = 0
if AccelPresent == 1:
try:
from adxl345 import ADXL345
adxl345 = ADXL345()
except:
print "Failed to initialize accelerometer."
AccelPresent = 0
if TempProbePresent == 1:
try:
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0]
device_file = device_folder + '/w1_slave'
except:
print "Failed to initialize temperature sensor."
TempProbePresent = 0
global temp_f #make this var global for use in messages
temp_f = 0
global TEMPON #var for displaying cabin temp widget
TEMPON = 0
global ACCELON
ACCELON = 0
if developermode == 0:
os.system('pulseaudio --start') #start the pulseaudio daemon
global bluetoothdevicemac
bluetoothdevicemac = 'AC_37_43_D7_65_B4' #Enter your smartphones bluetooth mac address here so its audio can be controlled from the audio app
#iphone: F0_D1_A9_C9_86_3E
#HTCM8: 2C_8A_72_19_0F_F4
#HTC10: AC_37_43_D7_65_B4
global BLUETOOTHON
BLUETOOTHON = 1
global DISPLAYBTDATA
DISPLAYBTDATA = 0
global bluetoothdata
bluetoothdata = ['','','','','','','','','','','',''] #Default - only shown when bluetooth enabled
def read_temp_raw():
f = open(device_file, 'r')
lines = f.readlines()
f.close()
return lines
def read_temp():
global temp_f
lines = read_temp_raw()
while lines[0].strip()[-3:] != 'YES':
#time.sleep(0.2)
lines = read_temp_raw()
equals_pos = lines[1].find('t=')
if equals_pos != -1:
temp_string = lines[1][equals_pos+2:]
temp_c_raw = float(temp_string) / 1000.0
temp_f_raw = temp_c_raw * 9.0 / 5.0 + 32.0
temp_f = "{0:.0f}".format(temp_f_raw) #only whole numbers
#_________________________________________________________________
#VARIABLES
#varibles from text file:
global theme
global wallpaper
global hotkey1string
global hotkey2string
global oildatemonth
global oildateday
global oildateyear
global oilmileage
global oilnotify
global speedlimit
global rpmredline
f = open('savedata.txt', 'r+') # read from text file
theme = f.readline()
theme = theme.rstrip() #to remove \n from string
wallpaper = int(f.readline())
hotkey1string = f.readline()
hotkey1string = hotkey1string.rstrip()
hotkey2string = f.readline()
hotkey2string = hotkey2string.rstrip()
oildatemonth = int(f.readline())
oildateday = int(f.readline())
oildateyear = int(f.readline())
oilmileage = int(f.readline())
oilnotify = int(f.readline())
speedlimit = int(f.readline())
rpmredline = int(f.readline())
f.close()
global SEEKUPON
SEEKUPON = 0
global SEEKDOWNON
SEEKDOWNON = 0
global AUXON
AUXON = 0
global AMFMON
AMFMON = 0
global GARAGEON
GARAGEON = 0
global RADARON
RADARON = 0
global LEDSON
LEDSON = 0
global WINDOWSDOWNON
WINDOWSDOWNON = 0
global WINDOWSUPON
WINDOWSUPON = 0
# window debug vars
global DRIVERUPON
DRIVERUPON = 0
global DRIVERDOWNON
DRIVERDOWNON = 0
global PASSENGERUPON
PASSENGERUPON = 0
global PASSENGERDOWNON
PASSENGERDOWNON = 0
global clock
clock = 0
global analog
analog = 1
global message
message = 0
global swminute
swminute = 0
global swsecond
swsecond = 0
global swtenth
swtenth = 0
global swactive
swactive = 0
global swstring
swstring = 0
global testvar
testvar = 0
global testvar2
testvar2 = 0
global screenon
screenon = 1
global windowuptime #time it takes front windows to rise (secs)
windowuptime = 7
global windowdowntime #time it takes front windows to open (secs)
windowdowntime = 6
global clocktheme
clocktheme = 2
global launch_start_time
launch_start_time = 0
global animation_start_time
animation_start_time = 0
global time_second_mod
time_second_mod = 0
#OBD Global vars
global OBDconnection
OBDconnection = 0 #connection is off by default - will be turned on in obd page
global OBDpage
OBDpage = 0 #start obd page in gauge select
global cmd_RPM
global cmd_SPEED
global cmd_CoolantTemp
global cmd_IntakeTemp
global cmd_Load
global cmd_ThrottlePos
global cmd_IntakePressure
global maxRPM
maxRPM = 0
global devobd
devobd = 0
global incobd #amount to step in dev mode - obd pages
incobd = 1
global changeoil
changeoil = 0
if oilnotify == 1:
if int(time.strftime("%Y")) > oildateyear:
changeoil = 1
if int(time.strftime("%m")) >= oildatemonth:
if int(time.strftime("%Y")) > oildateyear:
changeoil = 1
if int(time.strftime("%d")) >= oildateday:
if int(time.strftime("%m")) >= oildatemonth:
if int(time.strftime("%Y")) >= oildateyear:
changeoil = 1
#__________________________________________________________________
#HOTKEY STUFF
def HotKey1(channel):
global hotkey1string
global screenon
global windowuptime
global windowdowntime
global WINDOWSUPON
global WINDOWSDOWNON
if hotkey1string == "Seek Up":
if BLUETOOTHON == 0:
Clock.schedule_once(seekup_callback)
Clock.schedule_once(seekup_callback,.1)
if BLUETOOTHON == 1:
try:
os.system('dbus-send --system --type=method_call --dest=org.bluez /org/bluez/hci0/dev_'+bluetoothdevicemac+'/player0 org.bluez.MediaPlayer1.Next')
except:
print "can't next"
if hotkey1string == "Seek Down":
if BLUETOOTHON == 0:
Clock.schedule_once(seekdown_callback)
Clock.schedule_once(seekdown_callback,.1)
if BLUETOOTHON == 1:
try:
os.system('dbus-send --system --type=method_call --dest=org.bluez /org/bluez/hci0/dev_'+bluetoothdevicemac+'/player0 org.bluez.MediaPlayer1.Previous')
except:
print "can't prev"
if hotkey1string == "Garage":
Clock.schedule_once(garage_callback)
Clock.schedule_once(garage_callback,.1)
if hotkey1string == "Radar":
Clock.schedule_once(radar_callback)
if hotkey1string == "Cup Lights":
Clock.schedule_once(leds_callback)
if hotkey1string == "Windows Up":
if WINDOWSDOWNON == 0: #only works when windows down isnt running
Clock.schedule_once(windowsup_callback)
Clock.schedule_once(windowsupOFF_callback, windowuptime)
return
if WINDOWSUPON == 1:
Clock.schedule_once(windowsupOFF_callback) #if windows going up while pushed, will cancel and stop windows
if hotkey1string == "Windows Down":
if WINDOWSUPON == 0: #only works when windows up isnt running
Clock.schedule_once(windowsdown_callback)
Clock.schedule_once(windowsdownOFF_callback, windowdowntime)
return
if WINDOWSDOWNON == 1:
Clock.schedule_once(windowsdownOFF_callback) #if windows going down while pushed, will cancel and stop windows
if hotkey1string == "Screen Toggle":
if screenon == 1:
os.system("sudo echo 1 > /sys/class/backlight/rpi_backlight/bl_power") #turns screen off
screenon = 0
return
if screenon == 0:
os.system("sudo echo 0 > /sys/class/backlight/rpi_backlight/bl_power") #turns screen on
screenon = 1
return
if hotkey1string == "None":
return
def HotKey2(channel):
global hotkey2string
global screenon
global windowuptime
global windowdowntime
global WINDOWSUPON
global WINDOWSDOWNON
if hotkey2string == "Seek Up":
if BLUETOOTHON == 0:
Clock.schedule_once(seekup_callback)
Clock.schedule_once(seekup_callback, .1)
if BLUETOOTHON == 1:
try:
os.system('dbus-send --system --type=method_call --dest=org.bluez /org/bluez/hci0/dev_' + bluetoothdevicemac + '/player0 org.bluez.MediaPlayer1.Next')
except:
print "can't next"
if hotkey2string == "Seek Down":
if BLUETOOTHON == 0:
Clock.schedule_once(seekdown_callback)
Clock.schedule_once(seekdown_callback, .1)
if BLUETOOTHON == 1:
try:
os.system('dbus-send --system --type=method_call --dest=org.bluez /org/bluez/hci0/dev_' + bluetoothdevicemac + '/player0 org.bluez.MediaPlayer1.Previous')
except:
print "can't prev"
if hotkey2string == "Garage":
Clock.schedule_once(garage_callback)
Clock.schedule_once(garage_callback,.1)
if hotkey2string == "Radar":
Clock.schedule_once(radar_callback)
if hotkey2string == "Cup Lights":
Clock.schedule_once(leds_callback)
if hotkey2string == "Windows Up":
if WINDOWSDOWNON == 0: #only works when windows down isnt running
Clock.schedule_once(windowsup_callback)
Clock.schedule_once(windowsupOFF_callback, windowuptime)
return
if WINDOWSUPON == 1:
Clock.schedule_once(windowsupOFF_callback) #if windows going up while pushed, will cancel and stop windows
if hotkey2string == "Windows Down":
if WINDOWSUPON == 0: #only works when windows up isnt running
Clock.schedule_once(windowsdown_callback)
Clock.schedule_once(windowsdownOFF_callback, windowdowntime)
return
if WINDOWSDOWNON == 1:
Clock.schedule_once(windowsdownOFF_callback) #if windows going down while pushed, will cancel and stop windows
if hotkey2string == "Screen Toggle":
if screenon == 1:
os.system("sudo echo 1 > /sys/class/backlight/rpi_backlight/bl_power") #turns screen off
screenon = 0
return
if screenon == 0:
os.system("sudo echo 0 > /sys/class/backlight/rpi_backlight/bl_power") #turns screen on
screenon = 1
return
if hotkey2string == "None":
return
if developermode == 0:
GPIO.add_event_detect(HotKey1Pin, GPIO.FALLING, callback=HotKey1, bouncetime=500)
GPIO.add_event_detect(HotKey2Pin, GPIO.FALLING, callback=HotKey2, bouncetime=500)
#__________________________________________________________________
#DEFINE CLASSES
#ROOT CLASSES
class ROOT(FloatLayout):
pass
class QUICKEYSLayout(FloatLayout):
pass
#MAIN SCREEN CLASSES
class MainScreen(Screen):
pass
class AudioScreen(Screen):
pass
class PerfScreen(Screen):
pass
class AppsScreen(Screen):
pass
class ControlsScreen(Screen):
pass
class SettingsScreen(Screen):
pass
class KillScreen(Screen):
pass
#APP SCREEN CLASSES
class PaintScreen(Screen):
pass
class FilesScreen(Screen):
pass
class LogoScreen(Screen):
pass
class ClockChooserScreen(Screen):
pass
class ClassicClockScreen(Screen):
pass
class SportClockScreen(Screen):
pass
class ExecutiveClockScreen(Screen):
pass
class DayGaugeClockScreen(Screen):
pass
class NightGaugeClockScreen(Screen):
pass
class WormsClockScreen(Screen):
pass
class InfoClockScreen(Screen):
pass
class PhotoClockScreen(Screen):
pass
class TestAppScreen(Screen):
pass
class MaintenanceScreen(Screen):
pass
class MaintenanceSetOilInfoScreen(Screen):
pass
class GPSScreen(Screen):
pass
class StopwatchScreen(Screen):
pass
class DiagnosticsScreen(Screen):
pass
class SystemDebugScreen(Screen):
pass
class WindowDebugScreen(Screen):
pass
class LaunchControlSetupScreen(Screen):
pass
class LaunchControlScreen(Screen):
pass
class PhotosScreen(Screen):
pass
class GaugeSelectScreen(Screen):
pass
class OBDTachsScreen(Screen):
pass
class OBDSpeedosScreen(Screen):
pass
class OBDDiagnosticsScreen(Screen):
pass
class GaugeSelectScreen(Screen):
pass
class GaugeSelectScreen(Screen):
pass
class OBDDigitalSpeedoScreen(Screen):
pass
class OBDDigitalTachScreen(Screen):
pass
class OBDGraphicTachScreen(Screen):
pass
class OBDGraphicTach2Screen(Screen):
pass
class OBDCoolantScreen(Screen):
pass
class OBDIntakeTempScreen(Screen):
pass
class OBDLoadScreen(Screen):
pass
class OBDThrottlePosScreen(Screen):
pass
class OBDIntakePressureScreen(Screen):
pass
class OBDSettingsScreen(Screen):
pass
class AccelerometerScreen(Screen):
pass
class NOSScreen(Screen):
pass
class WallpaperSelectScreen(Screen):
pass
class HotKey1ChooserScreen(Screen):
pass
class HotKey2ChooserScreen(Screen):
pass
class OffScreen(Screen):
pass
#APP CLASSES
class Painter(Widget): #Paint App
def on_touch_down(self, touch):
with self.canvas:
touch.ud["line"] = Line(points=(touch.x, touch.y))
def on_touch_move(self, touch):
touch.ud["line"].points += [touch.x, touch.y]
#_________________________________________________________________
#MAINAPP
class MainApp(App):
theme_cls = ThemeManager()
version = StringProperty()
timenow = StringProperty()
timenow_hour = NumericProperty(0)
timenow_minute = NumericProperty(0)
timenow_second = NumericProperty(0)
launch_start_time = NumericProperty(0)
time_second_mod = NumericProperty(0)
datenow = StringProperty()
daynow = StringProperty()
yearnow = StringProperty()
ampm = StringProperty()
tempnow = StringProperty()
CPUtempnow = StringProperty()
corevoltagenow = StringProperty()
stopwatchnow = StringProperty()
stopwatchsecnow = ObjectProperty()
stopwatchmilnow = ObjectProperty()
HKonenow = StringProperty()
HKtwonow = StringProperty()
radariconsource = StringProperty()
lightsiconsource = StringProperty()
wallpapernow = StringProperty()
obdspeed = StringProperty()
obdspeedval = ObjectProperty()
obdspeedlimitval = ObjectProperty(speedlimit)
obdspeedmax = StringProperty()
obdRPM = StringProperty()
obdRPMval = NumericProperty(0)
obdRPMmax = StringProperty()
maxRPMvar = ObjectProperty()
obdRPMredline = ObjectProperty(rpmredline)
obdcoolanttemp = StringProperty()
obdcoolanttempval = ObjectProperty()
obdintaketemp = StringProperty()
obdintakepressure = StringProperty()
obdengineload = StringProperty()
obdengineloadval = ObjectProperty()
obdthrottlepos = StringProperty()
obdthrottleposval = ObjectProperty()
oildatemonth = ObjectProperty()
oildateday = ObjectProperty()
oildateyear = ObjectProperty()
oilmileage = ObjectProperty()
oilnotify = ObjectProperty()
changeoil = ObjectProperty()
ip = StringProperty()
accelx = NumericProperty(0)
accely = NumericProperty(0)
accelxmaxpos = ObjectProperty()
accelxmaxneg = ObjectProperty()
accelymaxpos = ObjectProperty()
accelymaxneg = ObjectProperty()
bluetoothtitle = StringProperty()
bluetoothartist = StringProperty()
bluetoothduration = NumericProperty(0)
bluetoothprogress = NumericProperty(0)
theme_cls.theme_style = "Dark"
#theme_cls.primary_palette = "Indigo"
global theme
theme_cls.primary_palette = theme
def updatetime(self, *args):
time = datetime.datetime.now()
time_hour = time.strftime("%I") # time_hour
if time_hour[0] == "0": # one digit format
time_hour = " " + time_hour[1]
time_minute = time.strftime("%M") # time_minute
timenow = time_hour + ":" + time_minute # create sting format (hour:minute)
self.timenow = timenow
#self.timenow = "3:14" # for screenshots
self.timenow_hour = time.hour
self.timenow_minute = time.minute
self.timenow_second = time.second
global time_second_mod
time_second_mod = int(float(time_second_mod)) + 1
if time_second_mod > 10000000: # doesnt allow this var to get too big
time_second_mod = 0
self.time_second_mod = time_second_mod
global launch_start_time
self.launch_start_time = launch_start_time
def updatedate(self, *args):
day = time.strftime("%A") #current day of week
month = time.strftime("%B") #current month
date = time.strftime("%d") #current day of month
year = time.strftime("%Y") #current year
ampm = time.strftime("%p") #AM or PM
if date[0] == "0": # one digit format for day of month
date = " " + date[1]
datenow = month + " " + date
self.datenow = datenow
self.daynow = day
self.yearnow = year
self.ampm = ampm
def updatetemp(self, *args):
temp_f_string = str(temp_f)
#if int(float(animation_start_time))+5 <= int(float(time_second_mod)): #animation is delayed for better asthetics
global TEMPON
if TEMPON == 1:
if TempProbePresent == 1:
read_temp()
tempnow = " " + temp_f_string + u'\N{DEGREE SIGN}'
if TempProbePresent == 0:
tempnow = " " + "72" + u'\N{DEGREE SIGN}'
if TEMPON == 0:
if TempProbePresent == 1:
tempnow = " " + temp_f_string + u'\N{DEGREE SIGN}'
if TempProbePresent == 0:
tempnow = " " + "72" + u'\N{DEGREE SIGN}'
self.tempnow = tempnow
def updatevariables(self, *args):
global swminute
global swsecond
global swtenth
global swactive
global swstring
global swminutestring
global swsecondstring
global version
global devtaps
global OBDpage
if swactive == 1:
swtenth += 1
if swtenth == 10:
swtenth = 0
swsecond += 1
if swsecond == 60:
swsecond = 0
swminute += 1
# fortmatting for stopwatch display - outside of if statement because watch will run in background
if swsecond < 10:
swsecondstring = "0" + str(swsecond)
else:
swsecondstring = str(swsecond)
if swminute < 10:
swminutestring = "0" + str(swminute)
else:
swminutestring = str(swminute)
swstring = (swminutestring + ":" + swsecondstring + ":" + str(swtenth) + "0")
#set vars
self.stopwatchnow = swstring
self.stopwatchsecnow = swsecond + (swtenth*.1)
self.HKonenow = hotkey1string
self.HKtwonow = hotkey2string
self.version = version
self.ip = ip
self.devtaps = devtaps
self.oildatemonth = oildatemonth
self.oildateday = oildateday
self.oildateyear = oildateyear
self.oilmileage = oilmileage
self.oilnotify = oilnotify
self.changeoil = changeoil
self.OBDpage = OBDpage
global BLUETOOTHON
if BLUETOOTHON == 1:
if int(float(animation_start_time)) + 5 <= int(float(time_second_mod)):
try:
if DISPLAYBTDATA == 1:
bluetoothdataraw = os.popen('dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0/dev_' + bluetoothdevicemac + '/player0 org.freedesktop.DBus.Properties.Get string:org.bluez.MediaPlayer1 string:Track').read()
bluetoothduration = int((bluetoothdataraw.split("uint32"))[1].split('\n')[0])
bluetoothprogressraw = os.popen('dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0/dev_' + bluetoothdevicemac + '/player0 org.freedesktop.DBus.Properties.Get string:org.bluez.MediaPlayer1 string:Position').read()
bluetoothprogress = int((bluetoothprogressraw.split("uint32"))[1].split('\n')[0])
bluetoothdata = bluetoothdataraw.split('"')[1::2] # takes string and finds things in quotes
self.bluetoothtitle = bluetoothdata[1]
self.bluetoothartist = bluetoothdata[7]
self.bluetoothduration = bluetoothduration
self.bluetoothprogress = bluetoothprogress
else:
self.bluetoothtitle = ''
self.bluetoothartist = ''
self.bluetoothduration = 0
self.bluetoothprogress = 0
except:
self.bluetoothtitle = ''
self.bluetoothartist = ''
self.bluetoothduration = 0
self.bluetoothprogress = 0
if BLUETOOTHON == 0: #show nothing when bluetooth is off
self.bluetoothtitle = ''
self.bluetoothartist = ''
self.bluetoothduration = 0
self.bluetoothprogress = 0
global theme
theme = self.theme_cls.primary_palette
if RADARON == 1:
self.radariconsource = 'data/icons/radarindicator.png'
if RADARON == 0:
self.radariconsource = 'data/icons/null.png'
if LEDSON == 1:
self.lightsiconsource = 'data/icons/app_icons/lights_icon_on.png'
if LEDSON == 0:
self.lightsiconsource = 'data/icons/app_icons/lights_icon.png'
if wallpaper == 0:
self.wallpapernow = 'data/wallpapers/greenmaterial.png'
if wallpaper == 1:
self.wallpapernow = 'data/wallpapers/blackgreenmaterial.png'
if wallpaper == 2:
self.wallpapernow = 'data/wallpapers/darkgreymaterial2.png'
if wallpaper == 3:
self.wallpapernow = 'data/wallpapers/polymountain.png'
if wallpaper == 4:
self.wallpapernow = 'data/wallpapers/trianglematerial.png'
if wallpaper == 5:
self.wallpapernow = 'data/wallpapers/blackredmaterial.png'
if wallpaper == 6:
self.wallpapernow = 'data/wallpapers/greybluematerial.png'
if wallpaper == 7:
self.wallpapernow = 'data/wallpapers/lightblueblackmaterial.png'
if wallpaper == 8:
self.wallpapernow = 'data/wallpapers/greyplain.png'
if wallpaper == 9:
self.wallpapernow = 'data/wallpapers/stopwatchblue.png'
if wallpaper == 10:
self.wallpapernow = 'data/wallpapers/polycube.png'
if wallpaper == 11:
self.wallpapernow = 'data/wallpapers/polyvalley.png'
if wallpaper == 12:
self.wallpapernow = 'data/wallpapers/purplebluematerial.png'
if wallpaper == 13:
self.wallpapernow = 'data/wallpapers/bluegreymaterial.png'
if wallpaper == 14:
self.wallpapernow = 'data/wallpapers/redpurplematerial.png'
if wallpaper == 15:
self.wallpapernow = 'data/wallpapers/CoPilot_Wallpaper_2.png'
if wallpaper == 16:
self.wallpapernow = 'data/wallpapers/blackredmaterial2.png'
if wallpaper == 17:
self.wallpapernow = 'data/wallpapers/androidauto.png'
if wallpaper == 18:
self.wallpapernow = 'data/wallpapers/tealmaterialdesign.png'
if wallpaper == 19:
self.wallpapernow = 'data/wallpapers/blueblackmaterial.png'
if wallpaper == 20:
self.wallpapernow = 'data/wallpapers/greenmaterial2.png'
if wallpaper == 21:
self.wallpapernow = 'data/wallpapers/redbluematerial.png'
if wallpaper == 22:
self.wallpapernow = 'data/wallpapers/blueblackwhitematerial.png'
if wallpaper == 23:
self.wallpapernow = 'data/wallpapers/polymountain2.png'
if wallpaper == 24:
self.wallpapernow = 'data/wallpapers/blackpoly.png'
if wallpaper == 25:
self.wallpapernow = 'data/wallpapers/blackredlacematerial.png'
if wallpaper == 26:
self.wallpapernow = 'data/wallpapers/blueredpoly.png'
if wallpaper == 27:
self.wallpapernow = 'data/wallpapers/firewaterpoly.png'
if wallpaper == 28:
self.wallpapernow = 'data/wallpapers/tanbluepoly.png'
if wallpaper == 29:
self.wallpapernow = 'data/wallpapers/road.png'
if wallpaper == 30:
self.wallpapernow = 'data/wallpapers/road2.png'
if wallpaper == 31:
self.wallpapernow = 'data/wallpapers/pixel.png'
if wallpaper == 32:
self.wallpapernow = 'data/wallpapers/pixel2.png'
if wallpaper == 33:
self.wallpapernow = 'data/wallpapers/darkgreyplain.png'
if wallpaper == 34:
self.wallpapernow = 'data/wallpapers/city.png'
if wallpaper == 35:
self.wallpapernow = 'data/wallpapers/cincy.png'
if wallpaper == 36:
self.wallpapernow = 'data/wallpapers/grad1.png'
if wallpaper == 37:
self.wallpapernow = 'data/wallpapers/grad2.png'
if wallpaper == 38:
self.wallpapernow = 'data/wallpapers/smoke.png'
def updatemessage(self, *args):
# the logic for what the message says
if message == 0:
self.text = " "
if message == 1: # used for displaying the CPU temp
if developermode == 0:
temperaturestring = subprocess.check_output(["/opt/vc/bin/vcgencmd", "measure_temp"])
corevoltagestring = subprocess.check_output(["/opt/vc/bin/vcgencmd", "measure_volts core"])
temperature = (temperaturestring.split('=')[1][:-3])
corevoltage = (corevoltagestring.split('=')[1][:-3])
CPUtempnow = temperature + u'\N{DEGREE SIGN}' + "C"
corevoltagenow = corevoltage + " V"
if developermode == 1:
CPUtempnow = "40" + u'\N{DEGREE SIGN}' + "C"
corevoltagenow = "3.14" + " V"
self.CPUtempnow = CPUtempnow
self.corevoltagenow = corevoltagenow
def updateaccel(self, *args):
global ACCELON
global accelxmaxpos
global accelxmaxneg
global accelymaxpos
global accelymaxneg
if ACCELON == 1:
if AccelPresent == 1:
axes = adxl345.getAxes(True)
accelx = axes['x'] - .13 # compensation amount
self.accelx = accelx
accely = axes['y'] - .34 # compensation amount
self.accely = accely
if accelx > accelxmaxpos:
accelxmaxpos = accelx