Ejemplo n.º 1
0
 def received_gesture_event(self, event):
     if event.gesture == nuimo.Gesture.SWIPE_UP:
         self.nuimoMenue.navigateToNextApp()
     elif event.gesture == nuimo.Gesture.SWIPE_DOWN:
         self.nuimoMenue.navigateToPreviousApp()
     elif event.gesture == nuimo.Gesture.SWIPE_RIGHT:
         self.nuimoMenue.navigateToSubMenue()
     elif event.gesture == nuimo.Gesture.SWIPE_LEFT:
         self.nuimoMenue.navigateToParentMenue()
     else:
         if event.gesture == nuimo.Gesture.BUTTON_PRESS:
             self.nuimoMenue.controller.display_matrix(
                 nuimo.LedMatrix("         "
                                 "   .     "
                                 "   ..    "
                                 "   ...   "
                                 "   ....  "
                                 "   ...   "
                                 "   ..    "
                                 "   .     "
                                 "         "))
         if event.gesture == nuimo.Gesture.TOUCH_BOTTOM:
             self.nuimoMenue.controller.display_matrix(
                 nuimo.LedMatrix("         "
                                 "  .. ..  "
                                 "  .. ..  "
                                 "  .. ..  "
                                 "  .. ..  "
                                 "  .. ..  "
                                 "  .. ..  "
                                 "  .. ..  "
                                 "         "))
         if event.gesture == nuimo.Gesture.TOUCH_LEFT:
             self.nuimoMenue.controller.display_matrix(
                 nuimo.LedMatrix("         "
                                 "         "
                                 "  .  .   "
                                 "  . ..   "
                                 "  ....   "
                                 "  . ..   "
                                 "  .  .   "
                                 "         "
                                 "         "))
         if event.gesture == nuimo.Gesture.TOUCH_RIGHT:
             self.nuimoMenue.controller.display_matrix(
                 nuimo.LedMatrix("         " + "         " + "   .  .  " +
                                 "   .. .  " + "   ....  " + "   .. .  " +
                                 "   .  .  " + "         " + "         "))
         self.nuimoMenue.getCurrentApp().getListener(
         ).received_gesture_event(event)
Ejemplo n.º 2
0
 def show_command_icon(self, fqCommand: str):
     if fqCommand in config["command_icon_mapping"]:
         if config["command_icon_mapping"][fqCommand] in icons:
             icon = icons[config["command_icon_mapping"][fqCommand]]
             self.nuimoMenue.controller.display_matrix(nuimo.LedMatrix(icon))
         else: logging.warning("Icon '"+config["command_icon_mapping"][fqCommand]+"' mapped to command '"+fqCommand+"' does not exist")
     else: logging.warning("No icon mapped to'"+fqCommand+"'")
Ejemplo n.º 3
0
 def received_gesture_event(self, event):
     super().received_gesture_event(event)
     self.controller.display_matrix(
         nuimo.LedMatrix("*        "
                         " *       "
                         "  *      "
                         "   *     "
                         "    *    "
                         "     *   "
                         "      *  "
                         "       * "
                         "        *"))
Ejemplo n.º 4
0
 def received_gesture_event(self, event):
     matrix = nuimo.LedMatrix("*       *"
                              " *     * "
                              "  *   *  "
                              "   * *   "
                              "    *    "
                              "   * *   "
                              "  *   *  "
                              " *     * "
                              "*       *")
     self.controller.display_matrix(matrix, interval=10)
     print(event.gesture, event.gesture == nuimo.Gesture.ROTATION)
     if (event.gesture == nuimo.Gesture.ROTATION):
         print(event.value)
     if (event.gesture == nuimo.Gesture.BUTTON_PRESS):
         pass
Ejemplo n.º 5
0
    def showRotationStateDigits(self, percent):
        if percent == 100:
            numberLed = icons[config["rotation_icon"] + "-100"]
        else:
            digit1 = percent // 10
            digit2 = percent % 10

            if not config["rotation_icon_leading_zero"] and digit1 == 0:
                digit1Led = icons["2-digit-empty"]
            else:
                digit1Led = icons[config["rotation_icon"] + "-" + str(digit1)]

            digit2Led = icons[config["rotation_icon"] + "-" + str(digit2)]

            numberLed = self.mergeLedHalfDigits(digit1Led, digit2Led)

        matrix = nuimo.LedMatrix("".join(numberLed))
        self.nuimoMenue.controller.display_matrix(matrix=matrix, fading=True, ignore_duplicates=True)
Ejemplo n.º 6
0
    def handle_gesture_event(self, event):
        mappedCommands = config.get_mapped_commands(gesture=event.gesture, mode=self.nuimoMenue.currentMode, namespace="MENUE")
        if mappedCommands:
            mappedCommand = mappedCommands[0]

            logging.debug("Current Mode: " + str(self.nuimoMenue.currentMode))
            logging.debug("Mapped Command: " + str(mappedCommand))

            if "CHANGEMODE" in mappedCommand:
                self.nuimoMenue.currentMode = mappedCommand.split("=")[1]
            elif mappedCommand == "PARENT":
                self.nuimoMenue.navigateToParentMenue()
            elif mappedCommand == "CHILD":
                self.nuimoMenue.navigateToSubMenue()
            elif mappedCommand == "NEXT":
                self.nuimoMenue.navigateToNextApp()
            elif mappedCommand == "PREVIOUS":
                self.nuimoMenue.navigateToPreviousApp()
            elif mappedCommand == "SHOWAPP":
                logging.debug("Name: "+self.nuimoMenue.getCurrentApp().getName())
                self.nuimoMenue.showIcon()
            elif mappedCommand == "SHOWBATTERYLEVEL":
                self.nuimoMenue.controller.display_matrix(nuimo.LedMatrix(icons["battery"]))
                time.sleep(1)
                self.showPercentageIcon(self.nuimoMenue.controller.battery_level)
            elif mappedCommand == "WHEELNAVIGATION":
                self.wheelNavigation(event)

            if mappedCommand != "WHEELNAVIGATION":
                self.wheelReminder = 0
        else:
            gestureResult = self.nuimoMenue.getCurrentApp().getListener().received_gesture_event(event)
            if gestureResult is not None:
                if event.gesture == nuimo.Gesture.ROTATION:
                    self.showPercentageIcon(percent=gestureResult)
                else:
                    self.show_command_icon(fqCommand=gestureResult)
Ejemplo n.º 7
0
    def showRotationStateIcon(self, percent):

        fullRotationString = icons[config.rotation_icon]
        fullRotationIsCircular = True

        ledCnt = int()
        for c in fullRotationString:
            if c == "*":
                ledCnt += 1

        if(percent != 0):
            ledsToShow = math.ceil(percent*ledCnt/100)
            currentRotationString = list()
            itCnt = 0
            for c in fullRotationString:
                column = itCnt%9
                row = itCnt // 9
                itCnt += 1
                if c == "*" and ledsToShow != 0 and (not fullRotationIsCircular or column > 4 or row == 0 and column == 4):
                    ledsToShow -= 1
                    currentRotationString.append("*")
                else:
                    currentRotationString.append(" ")

            if fullRotationIsCircular:
                itCnt = 80
                while(itCnt >= 0):
                    column = itCnt % 9
                    row = itCnt // 9
                    if fullRotationString[itCnt] == "*" and ledsToShow != 0 and column <= 4 and not (row == 0 and column == 4):
                        ledsToShow -= 1
                        currentRotationString[itCnt] = "*"
                    itCnt -= 1

            matrix = nuimo.LedMatrix("".join(currentRotationString))
            self.nuimoMenue.controller.display_matrix(matrix=matrix,fading=True, ignore_duplicates=True)
Ejemplo n.º 8
0
 def show_error_icon(self):
     self.nuimoMenue.controller.display_matrix(nuimo.LedMatrix(icons[config["error_icon"]]))
Ejemplo n.º 9
0
                                 " *     * "
                                 "*       *")
        self.controller.display_matrix(matrix, interval=10)
        print(event.gesture, event.gesture == nuimo.Gesture.ROTATION)
        if (event.gesture == nuimo.Gesture.ROTATION):
            print(event.value)
        if (event.gesture == nuimo.Gesture.BUTTON_PRESS):
            pass


if __name__ == '__main__':
    manager = nuimo.ControllerManager(adapter_name='hci0')

    controller = nuimo.Controller(mac_address=NUIMO_ADDRESS, manager=manager)
    controller.listener = ControllerPrintListener(
        controller
    )  # Use an instance of your own nuimo.ControllerListener subclass
    controller.connect()
    matrix = nuimo.LedMatrix("*       *"
                             " *     * "
                             "  *   *  "
                             "   * *   "
                             "    *    "
                             "   * *   "
                             "  *   *  "
                             " *     * "
                             "*       *")
    controller.display_matrix(matrix)

    manager.run()