コード例 #1
0
    def __handle_key_event__(self, event):
        """
        Handles a keyboard/keypad press event.

        Arguments:
            event {pygame.event} -- The event from the keyboard.

        Returns:
            bool -- True if the loop should continue, False if it should quit.
        """

        if event.type == pygame.QUIT:
            utilities.shutdown()
            return False

        if event.type != pygame.KEYUP:
            return True

        if event.key in [pygame.K_ESCAPE]:
            utilities.shutdown(0)
            if local_debug.IS_PI:
                self.__shutdown_stratux__()

            return False

        # Quit to terminal only.
        if event.key in [pygame.K_q]:
            return False

        if event.key in [pygame.K_KP_PLUS, pygame.K_PLUS]:
            CONFIGURATION.next_view()

        if event.key in [pygame.K_KP_MINUS, pygame.K_MINUS]:
            CONFIGURATION.previous_view()

        if event.key in [pygame.K_BACKSPACE]:
            self.__level_ahrs__()

        if event.key in [pygame.K_DELETE, pygame.K_PERIOD, pygame.K_KP_PERIOD]:
            targets.TARGET_MANAGER.clear_targets()

        if event.key in [pygame.K_RETURN, pygame.K_KP_ENTER]:
            orientation = self.__aircraft__.get_orientation()
            targets.TARGET_MANAGER.add_target(
                orientation.position[0],
                orientation.position[1],
                orientation.alt)
            targets.TARGET_MANAGER.save()

        if event.key in [pygame.K_EQUALS, pygame.K_KP_EQUALS]:
            self.__should_render_perf__ = not self.__should_render_perf__

        if event.key in [pygame.K_KP0, pygame.K_0, pygame.K_INSERT]:
            self.__reset_traffic_manager__()

        return True
コード例 #2
0
    def __shutdown__(self):
        """
        Shuts down the Pi
        """
        self.__logger__.log_info_message("SHUTDOWN: Turning off relay.")
        self.__relay_controller__.turn_off()

        self.__logger__.log_info_message(
            "SHUTDOWN: Shutting down HangarBuddy.")
        utilities.shutdown()