Exemplo n.º 1
0
        private void ProcessBatteryState(PiTopMessage message)
        {
            var newState = BatteryState.FromMessage(message);

            if (!BatteryState.BatteryStateComparer.Equals(BatteryState, newState))
            {
                BatteryState = newState;
                BatteryStateChanged?.Invoke(this, newState);
            }
        }
Exemplo n.º 2
0
 void OnBatteryStateChanged()
 {
     if (BatteryStateChanged != null)
     {
         Delegate [] handlers = BatteryStateChanged.GetInvocationList();
         foreach (Delegate d in handlers)
         {
             try {
                 d.DynamicInvoke(new object [] { this, EventArgs.Empty });
             } catch (Exception e) {
                 Log.Error("Error in BatteryStateChanged handler, {0}", e.Message);
                 Log.Debug(e.StackTrace);
             }
         }
     }
 }
Exemplo n.º 3
0
        private void ModuleDriverClientMessageReceived(object?sender, PiTopMessage message)
        {
            switch (message.Id)
            {
            case PiTopMessageId.REQ_PING:
                break;

            case PiTopMessageId.REQ_GET_DEVICE_ID:
                break;

            case PiTopMessageId.REQ_GET_BRIGHTNESS:
                break;

            case PiTopMessageId.REQ_SET_BRIGHTNESS:
                break;

            case PiTopMessageId.REQ_INCREMENT_BRIGHTNESS:
                break;

            case PiTopMessageId.REQ_DECREMENT_BRIGHTNESS:
                break;

            case PiTopMessageId.REQ_BLANK_SCREEN:
                break;

            case PiTopMessageId.REQ_UNBLANK_SCREEN:
                break;

            case PiTopMessageId.REQ_GET_BATTERY_STATE:
                break;

            case PiTopMessageId.REQ_GET_PERIPHERAL_ENABLED:
                break;

            case PiTopMessageId.REQ_GET_SCREEN_BLANKING_TIMEOUT:
                break;

            case PiTopMessageId.REQ_SET_SCREEN_BLANKING_TIMEOUT:
                break;

            case PiTopMessageId.REQ_GET_LID_OPEN_STATE:
                break;

            case PiTopMessageId.REQ_GET_SCREEN_BACKLIGHT_STATE:
                break;

            case PiTopMessageId.REQ_SET_SCREEN_BACKLIGHT_STATE:
                break;

            case PiTopMessageId.REQ_GET_OLED_CONTROL:
                break;

            case PiTopMessageId.REQ_SET_OLED_CONTROL:
                break;

            case PiTopMessageId.RSP_ERR_SERVER:
                break;

            case PiTopMessageId.RSP_ERR_MALFORMED:
                break;

            case PiTopMessageId.RSP_ERR_UNSUPPORTED:
                break;

            case PiTopMessageId.RSP_PING:
                break;

            case PiTopMessageId.RSP_GET_DEVICE_ID:
                break;

            case PiTopMessageId.RSP_GET_BRIGHTNESS:
                break;

            case PiTopMessageId.RSP_SET_BRIGHTNESS:
                break;

            case PiTopMessageId.RSP_INCREMENT_BRIGHTNESS:
                break;

            case PiTopMessageId.RSP_DECREMENT_BRIGHTNESS:
                break;

            case PiTopMessageId.RSP_GET_BATTERY_STATE:
                break;

            case PiTopMessageId.RSP_GET_PERIPHERAL_ENABLED:
                break;

            case PiTopMessageId.RSP_GET_SCREEN_BLANKING_TIMEOUT:
                break;

            case PiTopMessageId.RSP_SET_SCREEN_BLANKING_TIMEOUT:
                break;

            case PiTopMessageId.RSP_GET_LID_OPEN_STATE:
                break;

            case PiTopMessageId.RSP_GET_SCREEN_BACKLIGHT_STATE:
                break;

            case PiTopMessageId.RSP_SET_SCREEN_BACKLIGHT_STATE:
                break;

            case PiTopMessageId.RSP_GET_OLED_CONTROL:
                break;

            case PiTopMessageId.RSP_SET_OLED_CONTROL:
                break;

            case PiTopMessageId.PUB_BRIGHTNESS_CHANGED:
                break;

            case PiTopMessageId.PUB_PERIPHERAL_CONNECTED:
                break;

            case PiTopMessageId.PUB_PERIPHERAL_DISCONNECTED:
                break;

            case PiTopMessageId.PUB_SHUTDOWN_REQUESTED:
                break;

            case PiTopMessageId.PUB_REBOOT_REQUIRED:
                break;

            case PiTopMessageId.PUB_BATTERY_STATE_CHANGED:
                break;

            case PiTopMessageId.PUB_SCREEN_BLANKED:
                break;

            case PiTopMessageId.PUB_SCREEN_UNBLANKED:
                break;

            case PiTopMessageId.PUB_LOW_BATTERY_WARNING:
                BatteryStateChanged?.Invoke(this, BatteryState.Low);
                break;

            case PiTopMessageId.PUB_CRITICAL_BATTERY_WARNING:
                BatteryStateChanged?.Invoke(this, BatteryState.Critical);
                break;

            case PiTopMessageId.PUB_LID_CLOSED:
                break;

            case PiTopMessageId.PUB_LID_OPENED:
                break;

            case PiTopMessageId.PUB_UNSUPPORTED_HARDWARE:
                break;

            case PiTopMessageId.PUB_V3_BUTTON_UP_PRESSED:
                UpButton.State = PiTopButtonState.Pressed;
                break;

            case PiTopMessageId.PUB_V3_BUTTON_UP_RELEASED:
                UpButton.State = PiTopButtonState.Released;
                break;

            case PiTopMessageId.PUB_V3_BUTTON_DOWN_PRESSED:
                DownButton.State = PiTopButtonState.Pressed;
                break;

            case PiTopMessageId.PUB_V3_BUTTON_DOWN_RELEASED:
                DownButton.State = PiTopButtonState.Released;
                break;

            case PiTopMessageId.PUB_V3_BUTTON_SELECT_PRESSED:
                SelectButton.State = PiTopButtonState.Pressed;
                break;

            case PiTopMessageId.PUB_V3_BUTTON_SELECT_RELEASED:
                SelectButton.State = PiTopButtonState.Released;
                break;

            case PiTopMessageId.PUB_V3_BUTTON_CANCEL_PRESSED:
                CancelButton.State = PiTopButtonState.Pressed;
                break;

            case PiTopMessageId.PUB_V3_BUTTON_CANCEL_RELEASED:
                CancelButton.State = PiTopButtonState.Released;
                break;

            case PiTopMessageId.PUB_KEYBOARD_DOCKED:
                break;

            case PiTopMessageId.PUB_KEYBOARD_UNDOCKED:
                break;

            case PiTopMessageId.PUB_KEYBOARD_CONNECTED:
                break;

            case PiTopMessageId.PUB_FAILED_KEYBOARD_CONNECT:
                break;

            case PiTopMessageId.PUB_OLED_CONTROL_CHANGED:
                break;

            case PiTopMessageId.PUB_NATIVE_DISPLAY_CONNECTED:
                break;

            case PiTopMessageId.PUB_NATIVE_DISPLAY_DISCONNECTED:
                break;

            case PiTopMessageId.PUB_EXTERNAL_DISPLAY_CONNECTED:
                break;

            case PiTopMessageId.PUB_EXTERNAL_DISPLAY_DISCONNECTED:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }