Ejemplo n.º 1
0
    def __init__(self):
        self.CONFIG = ConfigStore(defaults=self.CONFIG_DEFAULTS)
        self.bm = ButtonManager(buttons=self.BUTTONS)
        self.tr = TempReader(system=self.TEMP_SYSTEM_MEASUREMENT)
        self.dm = DisplayManager()
        self.sm = SystemManager(self.SYSTEM_HEAT_PIN, self.SYSTEM_COOL_PIN,
                                self.SYSTEM_FAN_PIN)

        self.MENUS = {
            'TEMP': {
                'name': 'TEMP',
                'method': self.handle_temp_mode_loop
            },
            'SYSTEM': {
                'name': 'SYSTEM',
                'method': self.handle_system_mode_loop
            },
            'SYSTEM_FAN': {
                'name': 'SYSTEM_FAN',
                'method': self.handle_system_fan_mode_loop
            }
        }

        self.mm = MenuManager(self.MENUS)
        self.mm.select(self.get_menu_mode())
Ejemplo n.º 2
0
 def toggleFullscreen(self):
     if self.isFullScreen():
         self.enableMask(True)
         self.showNormal()
         if MenuManager.instance().ticker:
             MenuManager.instance().ticker.pause(False)
     else:
         self.enableMask(False)
         self.showFullScreen()
Ejemplo n.º 3
0
 def toggleFullscreen(self):
     if self.isFullScreen():
         self.enableMask(True)
         self.showNormal()
         if MenuManager.instance().ticker:
             MenuManager.instance().ticker.pause(False)
     else:
         self.enableMask(False)
         self.showFullScreen()
Ejemplo n.º 4
0
    def focusOutEvent(self, event):
        if not Colors.pause:
            return

        if MenuManager.instance().ticker:
            MenuManager.instance().ticker.pause(True)

        code = MenuManager.instance().currentMenuCode
        if code in (MenuManager.ROOT, MenuManager.MENU1):
            self.switchTimerOnOff(False)

        self.pausedLabel.setRecursiveVisible(True)
Ejemplo n.º 5
0
    def focusOutEvent(self, event):
        if not Colors.pause:
            return

        if MenuManager.instance().ticker:
            MenuManager.instance().ticker.pause(True)

        code = MenuManager.instance().currentMenuCode
        if code in (MenuManager.ROOT, MenuManager.MENU1):
            self.switchTimerOnOff(False)

        self.pausedLabel.setRecursiveVisible(True)
Ejemplo n.º 6
0
    def tick(self):
        medianChanged = self.measureFps()
        self.checkAdapt()

        if medianChanged and self.fpsLabel and Colors.showFps:
            self.fpsLabel.setText("FPS: %d" % int(self.currentFps))

        if MenuManager.instance().ticker:
            MenuManager.instance().ticker.tick()

        self.viewport().update()

        if self.useTimer:
            self.updateTimer.start(int(1000 / Colors.fps))
Ejemplo n.º 7
0
    def checkAdapt(self):
        if self.doneAdapt or Colors.noTimerUpdate or self.demoStartTime.elapsed(
        ) < 2000:
            return

        self.doneAdapt = True
        self.forceFpsMedianCalculation()
        Colors.benchmarkFps = self.fpsMedian
        Colors.debug("- benchmark: %d FPS" % int(Colors.benchmarkFps))

        if Colors.noAdapt:
            return

        if self.fpsMedian < 30:
            ticker = MenuManager.instance().ticker
            if ticker and ticker.scene():
                self.scene.removeItem(ticker)
                Colors.noTimerUpdate = True
                self.switchTimerOnOff(False)

                if self.fpsLabel:
                    self.fpsLabel.setText("FPS: (%d)" % int(self.fpsMedian))

                Colors.debug("- benchmark adaption: removed ticker (fps < 30)")

            if self.fpsMedian < 20:
                Colors.noAnimations = True
                Colors.debug(
                    "- benchmark adaption: animations switched off (fps < 20)")

            Colors.adapted = True
Ejemplo n.º 8
0
    def __init__(self, text, align=LEFT, userCode=0, parent=None, type=SIDEBAR):
        super(TextButton, self).__init__(parent)

        # Prevent a circular import.
        from menumanager import MenuManager
        self._menu_manager = MenuManager.instance()

        self.menuString = text
        self.buttonLabel = text
        self.alignment = align
        self.buttonType = type
        self.userCode = userCode
        self.scanAnim = None
        self.bgOn = None
        self.bgOff = None
        self.bgHighlight = None
        self.bgDisabled = None
        self.state = TextButton.OFF

        self.setAcceptHoverEvents(True)
        self.setCursor(Qt.PointingHandCursor)

        # Calculate the button size.
        if type in (TextButton.SIDEBAR, TextButton.PANEL):
            self.logicalSize = QSize(TextButton.BUTTON_WIDTH, TextButton.BUTTON_HEIGHT)
        else:
            self.logicalSize = QSize(int((TextButton.BUTTON_WIDTH / 2.0) - 5), int(TextButton.BUTTON_HEIGHT * 1.5))

        self._prepared = False
Ejemplo n.º 9
0
    def checkAdapt(self):
        if self.doneAdapt or Colors.noTimerUpdate or self.demoStartTime.elapsed() < 2000:
            return

        self.doneAdapt = True
        self.forceFpsMedianCalculation()
        Colors.benchmarkFps = self.fpsMedian
        Colors.debug("- benchmark: %d FPS" % int(Colors.benchmarkFps))

        if Colors.noAdapt:
            return

        if self.fpsMedian < 30:
            ticker = MenuManager.instance().ticker
            if ticker and ticker.scene():
                self.scene.removeItem(ticker)
                Colors.noTimerUpdate = True
                self.switchTimerOnOff(False)

                if self.fpsLabel:
                    self.fpsLabel.setText("FPS: (%d)" % int(self.fpsMedian))

                Colors.debug("- benchmark adaption: removed ticker (fps < 30)")

            if self.fpsMedian < 20:
                Colors.noAnimations = True
                Colors.debug("- benchmark adaption: animations switched off (fps < 20)")

            Colors.adapted = True
    def __init__(self, text, align=LEFT, userCode=0, scene=None, parent=None, type=SIDEBAR):
        super(TextButton, self).__init__(scene, parent)

        # Prevent a circular import.
        from menumanager import MenuManager
        self._menu_manager = MenuManager.instance()

        self.menuString = text
        self.buttonLabel = text
        self.alignment = align
        self.buttonType = type
        self.userCode = userCode
        self.scanAnim = None
        self.bgOn = None
        self.bgOff = None
        self.bgHighlight = None
        self.bgDisabled = None
        self.state = TextButton.OFF

        self.setAcceptsHoverEvents(True)
        self.setCursor(QtCore.Qt.PointingHandCursor)

        # Calculate the button size.
        if type in (TextButton.SIDEBAR, TextButton.PANEL):
            self.logicalSize = QtCore.QSize(TextButton.BUTTON_WIDTH, TextButton.BUTTON_HEIGHT)
        else:
            self.logicalSize = QtCore.QSize(int((TextButton.BUTTON_WIDTH / 2.0) - 5), int(TextButton.BUTTON_HEIGHT * 1.5))
	def onUpdate(self, args):

		Menu.onUpdate(self, args)

		sinceAct = (self.currTime - self.actTime) / 1000.0
		
		#print("Since=%.2f, curr=%d" % (sinceAct, self.curInd))

		if self.curInd < 0 \
		   or (sinceAct > self.Messages[self.curInd].time + self.Messages[self.curInd].dur):

			# Next message : if none left, wait a little, and then switch to next menu. 
			if self.curInd == len(self.Messages) - 1:

				if sinceAct > self.Messages[self.curInd].time + self.Messages[self.curInd].dur + 2.0:
					self.switchTo(MenuManager.get("Results"))
				else:
					self.prbProgress.hide()
					time.sleep(0.01) # Let the CPU keep cool (no hurry).

			# Next message : if at least one left ... 
			else:

				self.curInd = self.curInd + 1
				
				# Create and add the static text for the new message.
				scpItem = PyCEGUI.WindowManager.getSingleton().createWindow("CEGUIDemo/StaticText", "MenuLoading/ScpMessages/Msg%d" % self.curInd)
				scpItem.setText(self.Messages[self.curInd].txt + " ...")
				scpItem.setProperty("FrameEnabled", "false")
				scpItem.setProperty("BackgroundEnabled", "false")
				scpItem.setXPosition(PyCEGUI.UDim(0.0, 0.0))
				scpItem.setYPosition(PyCEGUI.UDim(1.0 + self.curInd * 0.10, 0.0))
				scpItem.setWidth(PyCEGUI.UDim(1.0, 0.0))
				scpItem.setHeight(PyCEGUI.UDim(0.10, 0.0))
				self.scpMessages.addChildWindow(scpItem)

				# Adjust alpha for all messages.
				nChildren = self.scpMessages.getContentPane().getChildCount()
				for chldInd in range(nChildren):
					txtChld = self.scpMessages.getContentPane().getChildAtIdx(chldInd)
					txtChld.setAlpha(0.85 ** (nChildren - 1 - chldInd))
				
				# Scroll down to show the added static text.
				self.scpMessages.setVerticalScrollPosition(1.0)

				# Hide any scrollbar (might get shown after every call to addChildWindow).
				self.scpMessages.getVertScrollbar().hide()
				self.scpMessages.getHorzScrollbar().hide()

				# Reset progress-bar.
				self.prbProgress.setProgress(0)
				self.prbProgress.show()

		else:

			# Update progress-bar.
			progress = (sinceAct - self.Messages[self.curInd].time) / self.Messages[self.curInd].dur
			self.prbProgress.setProgress(progress)
Ejemplo n.º 12
0
    def __init__(self, name, scene=None, parent=None):
        super(ExampleContent, self).__init__(scene, parent)

        # Prevent a circular import.
        from menumanager import MenuManager
        self._menu_manager = MenuManager.instance()

        self.name = name
        self.heading = None
        self.description = None
        self.screenshot = None
    def __init__(self, name, scene=None, parent=None):
        super(ExampleContent, self).__init__(scene, parent)

        # Prevent a circular import.
        from menumanager import MenuManager
        self._menu_manager = MenuManager.instance()

        self.name = name
        self.heading = None
        self.description = None
        self.screenshot = None
Ejemplo n.º 14
0
    def switchTimerOnOff(self, on):
        ticker = MenuManager.instance().ticker
        if ticker and ticker.scene():
            ticker.tickOnPaint = not on or Colors.noTimerUpdate

        if on and not Colors.noTimerUpdate:
            self.useTimer = True
            self.fpsTime = QTime.currentTime()
            self.updateTimer.start(int(1000 / Colors.fps))
            update_mode = QGraphicsView.NoViewportUpdate
        else:
            self.useTimer = False
            self.updateTimer.stop()

            if Colors.noTicker:
                update_mode = QGraphicsView.MinimalViewportUpdate
            else:
                update_mode = QGraphicsView.SmartViewportUpdate

        self.setViewportUpdateMode(update_mode)
Ejemplo n.º 15
0
 def __init__(self, parent=None):
     """
     Constructor
     """
     super(MainWindow, self).__init__(parent)
     self.setupUi(self)
     self.menumanager = MenuManager()
     self.setFixedSize(*WINDOW_SIZE)
     self.ImageFrame.setFixedSize(*IMAGE_SIZE)
     TermStream.stdout().messageWritten.\
         connect(self.textBrowser.insertPlainText)
     TermStream.stderr().messageWritten.\
         connect(self.textBrowser.insertPlainText)
     self.alloc_attr()
     self.dict_step = {
         0: Preprocessing,
         1: Filtering,
         2: "Correction",
         3: Segmentation,
         4: "fitting"
     }
Ejemplo n.º 16
0
	def onCreditsButtonClicked(self, args):

		self.switchTo(MenuManager.get("Credits"))
Ejemplo n.º 17
0
	def onProfilesButtonClicked(self, args):

		self.switchTo(MenuManager.get("Profiles"))
Ejemplo n.º 18
0
	def onOptionsButtonClicked(self, args):

		self.switchTo(MenuManager.get("Options"))
Ejemplo n.º 19
0
if __name__ == '__main__':

    import sys

    app = QtGui.QApplication(sys.argv)
    Colors.parseArgs(sys.argv)

    if sys.platform == 'win32':
        QtGui.QMessageBox.information(
            None, "Documentation Warning",
            "If you are using the GPL version of PyQt from the binary "
            "installer then you will probably see warning messages about "
            "missing documentation.  This is because the installer does "
            "not include a copy of the Qt documentation as it is so "
            "large.")

    mainWindow = MainWindow()
    MenuManager.instance().init(mainWindow)
    mainWindow.setFocus()

    if Colors.fullscreen:
        mainWindow.showFullScreen()
    else:
        mainWindow.enableMask(True)
        mainWindow.show()

    artisticSleep(500)
    mainWindow.start()

    sys.exit(app.exec_())
Ejemplo n.º 20
0
 def start(self):
     self.switchTimerOnOff(True)
     self.demoStartTime.restart()
     MenuManager.instance().itemSelected(MenuManager.ROOT,
                                         Colors.rootMenuName)
     Colors.debug("- starting demo")
Ejemplo n.º 21
0
    def onSingleEventButtonClicked(self, args):

        self.switchTo(MenuManager.get("TrackSelect"))
Ejemplo n.º 22
0
 def start(self):
     self.switchTimerOnOff(True)
     self.demoStartTime.restart()
     MenuManager.instance().itemSelected(MenuManager.ROOT,
             Colors.rootMenuName)
     Colors.debug("- starting demo")
Ejemplo n.º 23
0
	def setupInterface(self):

		MenuManager.get("Main").activate()
Ejemplo n.º 24
0
	def onNextButtonClicked(self, args):

		self.switchTo(MenuManager.get("CarSelect"))
Ejemplo n.º 25
0
    def initialize():

        MenuManager.register("Credits", MenuCredits.instance)
        MenuManager.register("Options", MenuOptions.instance)
        MenuManager.register("Profiles", MenuProfiles.instance)

        MenuManager.register("Main", MenuMain.instance)
        MenuManager.register("TrackSelect", MenuTrackSelect.instance)
        MenuManager.register("CarSelect", MenuCarSelect.instance)
        MenuManager.register("Loading", MenuLoading.instance)
        MenuManager.register("Results", MenuResults.instance)
	def onContinueButtonClicked(self, args):

		self.switchTo(MenuManager.get("Main"))
Ejemplo n.º 27
0
	def onQuickRaceButtonClicked(self, args):

		self.switchTo(MenuManager.get("TrackSelect"))
Ejemplo n.º 28
0
	def onSingleEventButtonClicked(self, args):

		self.switchTo(MenuManager.get("TrackSelect"))
Ejemplo n.º 29
0
    def onStartButtonClicked(self, args):

        self.switchTo(MenuManager.get("Loading"))
Ejemplo n.º 30
0
    def onNextButtonClicked(self, args):

        self.switchTo(MenuManager.get("CarSelect"))
Ejemplo n.º 31
0
    def onUpdate(self, args):

        Menu.onUpdate(self, args)

        sinceAct = (self.currTime - self.actTime) / 1000.0

        #print("Since=%.2f, curr=%d" % (sinceAct, self.curInd))

        if self.curInd < 0 \
           or (sinceAct > self.Messages[self.curInd].time + self.Messages[self.curInd].dur):

            # Next message : if none left, wait a little, and then switch to next menu.
            if self.curInd == len(self.Messages) - 1:

                if sinceAct > self.Messages[self.curInd].time + self.Messages[
                        self.curInd].dur + 2.0:
                    self.switchTo(MenuManager.get("Results"))
                else:
                    self.prbProgress.hide()
                    time.sleep(0.01)  # Let the CPU keep cool (no hurry).

            # Next message : if at least one left ...
            else:

                self.curInd = self.curInd + 1

                # Create and add the static text for the new message.
                scpItem = PyCEGUI.WindowManager.getSingleton().createWindow(
                    "CEGUIDemo/StaticText",
                    "MenuLoading/ScpMessages/Msg%d" % self.curInd)
                scpItem.setText(self.Messages[self.curInd].txt + " ...")
                scpItem.setProperty("FrameEnabled", "false")
                scpItem.setProperty("BackgroundEnabled", "false")
                scpItem.setXPosition(PyCEGUI.UDim(0.0, 0.0))
                scpItem.setYPosition(
                    PyCEGUI.UDim(1.0 + self.curInd * 0.10, 0.0))
                scpItem.setWidth(PyCEGUI.UDim(1.0, 0.0))
                scpItem.setHeight(PyCEGUI.UDim(0.10, 0.0))
                self.scpMessages.addChildWindow(scpItem)

                # Adjust alpha for all messages.
                nChildren = self.scpMessages.getContentPane().getChildCount()
                for chldInd in range(nChildren):
                    txtChld = self.scpMessages.getContentPane().getChildAtIdx(
                        chldInd)
                    txtChld.setAlpha(0.85**(nChildren - 1 - chldInd))

                # Scroll down to show the added static text.
                self.scpMessages.setVerticalScrollPosition(1.0)

                # Hide any scrollbar (might get shown after every call to addChildWindow).
                self.scpMessages.getVertScrollbar().hide()
                self.scpMessages.getHorzScrollbar().hide()

                # Reset progress-bar.
                self.prbProgress.setProgress(0)
                self.prbProgress.show()

        else:

            # Update progress-bar.
            progress = (sinceAct - self.Messages[self.curInd].time
                        ) / self.Messages[self.curInd].dur
            self.prbProgress.setProgress(progress)
Ejemplo n.º 32
0
    def onContinueButtonClicked(self, args):

        self.switchTo(MenuManager.get("Main"))
Ejemplo n.º 33
0
class MicroStat():

    CONFIG_DEFAULTS = {
        'temp_desired': 75.0,
        'temp_mode': 'OFF',
        'fan_mode': 'AUTO',
        'menu_mode': 'TEMP'
    }
    CONFIG = {}

    BUTTONS = [
        {
            'name': 'UP',
            'pin': 14
        },
        {
            'name': 'DOWN',
            'pin': 12
        },
        {
            'name': 'MENU_MODE',
            'pin': 13
        },
    ]

    # Temp settings
    TEMP_BUFFER = 1.0
    TEMP_COOLDOWN = 60  # Cooldown in seconds
    TEMP_HUMID_ACTIVATE = 80
    TEMP_LOWER_LIMIT = 60.0
    TEMP_UPPER_LIMIT = 80.0
    TEMP_SYSTEM_MEASUREMENT = 'fahrenheit'

    # AC pins and settings
    SYSTEM_HEAT_PIN = 16
    SYSTEM_COOL_PIN = 15
    SYSTEM_FAN_PIN = 4
    SYSTEM_MODES = ['COOL', 'HEAT', 'OFF']
    SYSTEM_FAN_MODES = ['AUTO', 'ON']

    MENUS = {}

    def __init__(self):
        self.CONFIG = ConfigStore(defaults=self.CONFIG_DEFAULTS)
        self.bm = ButtonManager(buttons=self.BUTTONS)
        self.tr = TempReader(system=self.TEMP_SYSTEM_MEASUREMENT)
        self.dm = DisplayManager()
        self.sm = SystemManager(self.SYSTEM_HEAT_PIN, self.SYSTEM_COOL_PIN,
                                self.SYSTEM_FAN_PIN)

        self.MENUS = {
            'TEMP': {
                'name': 'TEMP',
                'method': self.handle_temp_mode_loop
            },
            'SYSTEM': {
                'name': 'SYSTEM',
                'method': self.handle_system_mode_loop
            },
            'SYSTEM_FAN': {
                'name': 'SYSTEM_FAN',
                'method': self.handle_system_fan_mode_loop
            }
        }

        self.mm = MenuManager(self.MENUS)
        self.mm.select(self.get_menu_mode())
        # For debugging
        # self.CONFIG.reset()

    #
    # TEMP CODE
    #
    def increase_desired_temp(self):
        return self.set_desired_temp(self.get_desired_temp() + 1)

    def decrease_desired_temp(self):
        return self.set_desired_temp(self.get_desired_temp() - 1)

    def set_desired_temp(self, temp):
        self.CONFIG.set(
            'temp_desired',
            clamp(temp, self.TEMP_UPPER_LIMIT, self.TEMP_LOWER_LIMIT))
        return self.get_desired_temp()

    def get_desired_temp(self):
        return self.CONFIG.get('temp_desired')

    #
    # SYSTEM MODE CODE
    #
    def set_system_mode(self, mode):
        self.CONFIG.set('temp_mode', mode)
        return self.get_system_mode()

    def get_system_mode(self):
        return self.CONFIG.get('temp_mode')

    def get_system_modes(self):
        return self.SYSTEM_MODES

    def next_system_mode(self):
        next_mode = next_item(self.get_system_mode(), self.get_system_modes())
        return self.set_system_mode(next_mode)

    def prev_system_mode(self):
        prev_mode = prev_item(self.get_system_mode(), self.get_system_modes())
        return self.set_system_mode(prev_mode)

    #
    # SYSTEM FAN MODE CODE
    #
    def set_system_fan_mode(self, mode):
        self.CONFIG.set('fan_mode', mode)
        return self.get_system_fan_mode()

    def get_system_fan_mode(self):
        return self.CONFIG.get('fan_mode')

    def get_system_fan_modes(self):
        return self.SYSTEM_FAN_MODES

    def next_system_fan_mode(self):
        next_mode = next_item(self.get_system_fan_mode(),
                              self.get_system_fan_modes())
        return self.set_system_fan_mode(next_mode)

    def prev_system_fan_mode(self):
        prev_mode = prev_item(self.get_system_fan_mode(),
                              self.get_system_fan_modes())
        return self.set_system_fan_mode(prev_mode)

    #
    # MENU MODE CODE
    #
    def set_menu_mode(self, mode):
        print('Setting menu mode tp', mode)
        self.CONFIG.set('menu_mode', mode)
        return self.get_menu_mode()

    def get_menu_mode(self):
        return self.CONFIG.get('menu_mode')

    def get_menu_modes(self):
        return list(self.MENUS)

    #
    # Loop handlers
    #
    def handle_temp_mode_loop(self, menu_name, button):
        if button:
            if button == 'UP':
                cur_desired_temp = self.increase_desired_temp()
                blink_led()
                print('New desired temp: {}'.format(cur_desired_temp))
            if button == 'DOWN':
                cur_desired_temp = self.decrease_desired_temp()
                blink_led()
                print('New desired temp: {}'.format(cur_desired_temp))
        else:
            temp = self.tr.temperture()
            symbol = self.tr.current_temp.symbol()
            humid = self.tr.humidity()

            rows = [
                'Temp: {}{}'.format(round(temp),
                                    symbol), 'Humidity: {}'.format(humid),
                'Mode: {}'.format(self.get_system_mode()),
                'Desired Temp: {}{}'.format(self.get_desired_temp(), symbol)
            ]
            self.dm.display_rows(rows)

    def handle_system_mode_loop(self, menu_name, button):

        if button:
            if button == 'UP':
                cur_desired_mode = self.next_system_mode()
                blink_led()
                print('New system mode: {}'.format(cur_desired_mode))
            if button == 'DOWN':
                cur_desired_mode = self.prev_system_mode()
                blink_led()
                print('New system mode: {}'.format(cur_desired_mode))
        else:
            self.dm.display_selection(self.get_system_mode(),
                                      self.SYSTEM_MODES, 'Mode:')

    def handle_system_fan_mode_loop(self, menu_name, button):
        if button:
            if button == 'UP':
                cur_desired_fan_mode = self.next_system_fan_mode()
                blink_led()
                print('New system fan mode: {}'.format(cur_desired_fan_mode))
            if button == 'DOWN':
                cur_desired_fan_mode = self.prev_system_fan_mode()
                blink_led()
                print('New system fan mode: {}'.format(cur_desired_fan_mode))
        else:
            self.dm.display_selection(self.get_system_fan_mode(),
                                      self.SYSTEM_FAN_MODES, 'Fan:')

    def system_status(self):
        system_mode = self.get_system_mode()

        if system_mode == 'OFF':
            self.sm.cool_off()
            self.sm.heat_off()
            self.sm.fan_off()

        system_fan_mode = self.get_system_fan_mode()
        desired_temp = self.get_desired_temp()
        cur_temp = self.tr.temperture()

        # Check if its hot enough to turn the cool on
        if system_mode == 'COOL' and (cur_temp -
                                      desired_temp) >= self.TEMP_BUFFER:
            self.sm.cool_on()

        #  Check if its cool enough to turn the cool off
        if system_mode == 'COOL' and (desired_temp -
                                      cur_temp) >= self.TEMP_BUFFER:
            self.sm.cool_off()
            # If the fan is on auto lets turn it off too if it will let us
            if system_fan_mode == 'AUTO':
                self.sm.fan_off()

        # Check if its cold enough to turn the heat on
        if system_mode == 'HEAT' and (desired_temp -
                                      cur_temp) >= self.TEMP_BUFFER:
            self.sm.heat_on()

        #  Check if its hot enough to turn the heat off
        if system_mode == 'HEAT' and (cur_temp -
                                      desired_temp) >= self.TEMP_BUFFER:
            self.sm.heat_off()
            # If the fan is on auto lets turn it off too if it will let us
            if system_fan_mode == 'AUTO':
                self.sm.fan_off()

        # If the fan is set to ON then we should keep it always on
        if system_fan_mode == 'ON' or self.tr.humidity(
        ) > self.TEMP_HUMID_ACTIVATE:
            self.sm.fan_on()

    #
    # Main action handler
    #
    def action_check(self):

        button = self.bm.check_button_pressed()
        mode = self.get_menu_mode()

        if button and button == 'MENU_MODE':
            mode = self.set_menu_mode(next_item(mode, self.get_menu_modes()))
            self.mm.select(mode)
            print('Changing menu mode to ({})'.format(mode))
        else:
            self.mm.handle(button=button)

    def loop(self):
        self.CONFIG.check_save()

        # Always try to update temp
        self.tr.measure()

        # See if something needs to be changed with the system
        self.system_status()

        self.action_check()
Ejemplo n.º 34
0
    def onQuickRaceButtonClicked(self, args):

        self.switchTo(MenuManager.get("TrackSelect"))
Ejemplo n.º 35
0
if __name__ == '__main__':

    import sys

    app = QApplication(sys.argv)
    Colors.parseArgs(sys.argv)

    if sys.platform == 'win32':
        QMessageBox.information(None, "Documentation Warning",
                "If you are using the GPL version of PyQt from the binary "
                "installer then you will probably see warning messages about "
                "missing documentation.  This is because the installer does "
                "not include a copy of the Qt documentation as it is so "
                "large.")

    mainWindow = MainWindow()
    MenuManager.instance().init(mainWindow)
    mainWindow.setFocus()

    if Colors.fullscreen:
        mainWindow.showFullScreen()
    else:
        mainWindow.enableMask(True)
        mainWindow.show()

    artisticSleep(500)
    mainWindow.start()

    sys.exit(app.exec_())
Ejemplo n.º 36
0
	def setupInterface(self):

		MenuManager.get("Main").activate()
Ejemplo n.º 37
0
	def initialize():

		MenuManager.register("Credits",  MenuCredits.instance)
		MenuManager.register("Options",  MenuOptions.instance)
		MenuManager.register("Profiles", MenuProfiles.instance)

		MenuManager.register("Main",        MenuMain.instance)
		MenuManager.register("TrackSelect", MenuTrackSelect.instance)
		MenuManager.register("CarSelect",   MenuCarSelect.instance)
		MenuManager.register("Loading",     MenuLoading.instance)
		MenuManager.register("Results",     MenuResults.instance)
Ejemplo n.º 38
0
	def onStartButtonClicked(self, args):

		self.switchTo(MenuManager.get("Loading"))