@@ -16,6 +16,7 @@ class NavBarPlugin(octoprint.plugin.StartupPlugin,
1616
1717 def __init__ (self ):
1818 self .isRaspi = False
19+ self .debugMode = False # to simulate temp on Win/Mac
1920
2021 def on_after_startup (self ):
2122 if sys .platform == "linux2" :
@@ -38,9 +39,10 @@ def on_after_startup(self):
3839 self ._logger .debug ("Let's start RepeatedTimer!" )
3940 t = RepeatedTimer (30.0 , self .checkRaspiTemp )
4041 t .start ()
41- # else:
42- # t = RepeatedTimer(5.0, self.checkRaspiTemp)
43- # t.start()
42+ elif self .debugMode :
43+ self .isRaspi = True
44+ t = RepeatedTimer (5.0 , self .checkRaspiTemp )
45+ t .start ()
4446
4547 self ._logger .debug ("is Raspberry Pi? - %s" % self .isRaspi )
4648
@@ -49,16 +51,17 @@ def checkRaspiTemp(self):
4951
5052 self ._logger .debug ("Checking Raspberry Pi internal temperature" )
5153
52- # if sys.platform == "linux2":
53- p = run ("/opt/vc/bin/vcgencmd measure_temp" , stdout = Capture ())
54- p = p .stdout .text
55- # else:
56- # import random
57- #
58- # def randrange_float(start, stop, step):
59- # return random.randint(0, int((stop - start) / step)) * step + start
60- #
61- # p = "temp=%s'C" % randrange_float(5, 60, 0.1)
54+ if sys .platform == "linux2" :
55+ p = run ("/opt/vc/bin/vcgencmd measure_temp" , stdout = Capture ())
56+ p = p .stdout .text
57+ elif self .debugMode :
58+ import random
59+
60+ def randrange_float (start , stop , step ):
61+ return random .randint (0 , int ((stop - start ) / step )) * step + start
62+
63+ p = "temp=%s'C" % randrange_float (5 , 60 , 0.1 )
64+
6265 self ._logger .debug ("response from sarge: %s" % p )
6366
6467 match = re .search ('=(.*)\' ' , p )
0 commit comments