Exemplo n.º 1
0
    def pickTempSetting(self, readTemp, writeTemp, tempName, printAnnotation, row):

        # Handle temperatures as integers internally, with a resolution of 0.1C
        # i.e. divide by 10
        oldSetting = readTemp()
        startVal = oldSetting
        minVal = int(self.tempControl.cc.tempSettingMin * 10)
        maxVal = int(self.tempControl.cc.tempSettingMax * 10)
        if oldSetting is None:  # previous temperature was not defined, start at 20C
            startVal = 20.0

        startVal *= 10
        t = float(startVal) / 10

        startPos = self.encoder.pos  # The encoder is free-running, so establish zero point

        # rotaryEncoder.setRange(startVal, minVal, maxVal)

        blinkTimer = 0
        lastChangeTime = ticks.seconds()

        while (ticks.timeSince(lastChangeTime) < MENU_TIMEOUT):  # time out at 10 seconds
            if (self.encoder.changed):
                lastChangeTime = ticks.seconds()
                blinkTimer = 0
                # startVal = tenthsToFixed(encoder.read())
                t = startVal + (self.encoder.pos - startPos)
                t = max(minVal, min(t, maxVal))
                t = float(t) / 10

                display.printTemperatureAt(12, row, t)
                display.update()

            if (self.encoder.pushed):
                # rotaryEncoder.resetPushed()
                writeTemp(t)
                printAnnotation("%s temp set to %s in Menu." % (tempName, t))
                while self.encoder.pushed:
                    pass
                return True

            if (blinkTimer == 0):
                display.printTemperatureAt(12, row, t)
                display.update()

            elif (blinkTimer == 128):
                display.printAt(12, row, " " * 5)
                display.update()

            blinkTimer += 1
            blinkTimer &= 0xff  # Blink timer is an 8-bit value
            time.sleep(0.003)  # delay for blinking

        # Time Out. Setting is not written
        return False  # FIXME: Do something if the encoder is not pushed
Exemplo n.º 2
0
    def blinkLoop(self,
                  changed,  # function called to update the value
                  show,  # function called to show the current value
                  hide,  # function called to blank out the current value
                  pushed):  # function to handle selection

        # @return {@code true} if a value was selected. {@code false} on timeout.
        lastChangeTime = ticks.seconds()
        blinkTimer = 0

        while (ticks.timeSince(lastChangeTime) < MENU_TIMEOUT):  # time out at 10 seconds
            if (self.encoder.changed):
                lastChangeTime = ticks.seconds()
                blinkTimer = 0
                changed()
                display.update()

            if (blinkTimer == 0):
                show()
                display.update()

            elif (blinkTimer == 128):
                hide()
                display.update()

            if (self.encoder.pushed):
                # rotaryEncoder.resetPushed()
                show()
                display.update()
                while self.encoder.pushed:
                    pass
                pushed()
                return True

            blinkTimer += 1
            blinkTimer &= 0xff  # blink timer is an 8-bit value
            time.sleep(0.003)  # wait.millis(3)	# delay for blinking

        return False
Exemplo n.º 3
0
 def timeSinceIdle(self):
     return ticks.timeSince(self.lastIdleTime)
Exemplo n.º 4
0
 def timeSinceHeating(self):
     return ticks.timeSince(self.lastHeatTime)
Exemplo n.º 5
0
 def timeSinceCooling(self):
     return ticks.timeSince(self.lastCoolTime)
Exemplo n.º 6
0
 def timeSinceIdle(self):
     return ticks.timeSince(self.lastIdleTime)
Exemplo n.º 7
0
 def timeSinceHeating(self):
     return ticks.timeSince(self.lastHeatTime)
Exemplo n.º 8
0
 def timeSinceCooling(self):
     return ticks.timeSince(self.lastCoolTime)