diff --git a/octoprint_navbartemp/__init__.py b/octoprint_navbartemp/__init__.py index 8096cbf..2022db5 100644 --- a/octoprint_navbartemp/__init__.py +++ b/octoprint_navbartemp/__init__.py @@ -16,6 +16,7 @@ class NavBarPlugin(octoprint.plugin.StartupPlugin, def __init__(self): self.isRaspi = False + self.debugMode = False # to simulate temp on Win/Mac def on_after_startup(self): if sys.platform == "linux2": @@ -38,9 +39,10 @@ def on_after_startup(self): self._logger.debug("Let's start RepeatedTimer!") t = RepeatedTimer(30.0, self.checkRaspiTemp) t.start() - # else: - # t = RepeatedTimer(5.0, self.checkRaspiTemp) - # t.start() + elif self.debugMode: + self.isRaspi = True + t = RepeatedTimer(5.0, self.checkRaspiTemp) + t.start() self._logger.debug("is Raspberry Pi? - %s" % self.isRaspi) @@ -49,16 +51,17 @@ def checkRaspiTemp(self): self._logger.debug("Checking Raspberry Pi internal temperature") - # if sys.platform == "linux2": - p = run("/opt/vc/bin/vcgencmd measure_temp", stdout=Capture()) - p = p.stdout.text - # else: - # import random - # - # def randrange_float(start, stop, step): - # return random.randint(0, int((stop - start) / step)) * step + start - # - # p = "temp=%s'C" % randrange_float(5, 60, 0.1) + if sys.platform == "linux2": + p = run("/opt/vc/bin/vcgencmd measure_temp", stdout=Capture()) + p = p.stdout.text + elif self.debugMode: + import random + + def randrange_float(start, stop, step): + return random.randint(0, int((stop - start) / step)) * step + start + + p = "temp=%s'C" % randrange_float(5, 60, 0.1) + self._logger.debug("response from sarge: %s" % p) match = re.search('=(.*)\'', p) diff --git a/octoprint_navbartemp/static/css/navbartemp.css b/octoprint_navbartemp/static/css/navbartemp.css index ad01049..b48cb2a 100644 --- a/octoprint_navbartemp/static/css/navbartemp.css +++ b/octoprint_navbartemp/static/css/navbartemp.css @@ -1 +1 @@ -#navbar .navbar-inner .nav>li>span>p{color:#333}#navbar .navbar-inner.orange .nav>li>span>p,#navbar .navbar-inner.red .nav>li>span>p{color:#f2f2f2}#navbar .navbar-inner.green .nav>li>span>p,#navbar .navbar-inner.yellow .nav>li>span>p{color:#333}#navbar .navbar-inner.black .nav>li>span>p,#navbar .navbar-inner.blue .nav>li>span>p,#navbar .navbar-inner.violet .nav>li>span>p{color:#f2f2f2} \ No newline at end of file +#navbar .navbar-inner .nav>li>div>p,#navbar .navbar-inner .nav>li>p{color:#333}#navbar .navbar-inner.orange .nav>li>div>p,#navbar .navbar-inner.orange .nav>li>p,#navbar .navbar-inner.red .nav>li>div>p,#navbar .navbar-inner.red .nav>li>p{color:#f2f2f2}#navbar .navbar-inner.green .nav>li>div>p,#navbar .navbar-inner.green .nav>li>p,#navbar .navbar-inner.yellow .nav>li>div>p,#navbar .navbar-inner.yellow .nav>li>p{color:#333}#navbar .navbar-inner.black .nav>li>div>p,#navbar .navbar-inner.black .nav>li>p,#navbar .navbar-inner.blue .nav>li>div>p,#navbar .navbar-inner.blue .nav>li>p,#navbar .navbar-inner.violet .nav>li>div>p,#navbar .navbar-inner.violet .nav>li>p{color:#f2f2f2} \ No newline at end of file diff --git a/octoprint_navbartemp/static/less/navbartemp.less b/octoprint_navbartemp/static/less/navbartemp.less index 8083ee5..a77048a 100644 --- a/octoprint_navbartemp/static/less/navbartemp.less +++ b/octoprint_navbartemp/static/less/navbartemp.less @@ -7,7 +7,7 @@ @text-color-dark: #333333; @text-color: contrast(@base, @text-color-dark, @text-color-light); - .nav>li>span>p { + .nav>li>p, .nav>li>div>p { .navbar-inner-text(@base); } } diff --git a/octoprint_navbartemp/templates/navbartemp_navbar.jinja2 b/octoprint_navbartemp/templates/navbartemp_navbar.jinja2 index d487eee..2cb25d9 100644 --- a/octoprint_navbartemp/templates/navbartemp_navbar.jinja2 +++ b/octoprint_navbartemp/templates/navbartemp_navbar.jinja2 @@ -1,10 +1,10 @@ - - + +