Buttons.proto 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. syntax = "proto3";
  2. package sys;
  3. import "GPIO.proto";
  4. import "nanopb.proto";
  5. option (nanopb_fileopt).enum_to_string = true;
  6. enum ButtonAction {
  7. ACTRLS_NONE = 0;
  8. ACTRLS_POWER = 1;
  9. ACTRLS_VOLUP = 2;
  10. ACTRLS_VOLDOWN = 3;
  11. ACTRLS_TOGGLE = 4;
  12. ACTRLS_PLAY = 5;
  13. ACTRLS_PAUSE = 6;
  14. ACTRLS_STOP = 7;
  15. ACTRLS_REW = 8;
  16. ACTRLS_FWD = 9;
  17. ACTRLS_PREV = 10;
  18. ACTRLS_NEXT = 11;
  19. BCTRLS_UP = 12;
  20. BCTRLS_DOWN = 13;
  21. BCTRLS_LEFT = 14;
  22. BCTRLS_RIGHT = 15;
  23. BCTRLS_PS1 = 16;
  24. BCTRLS_PS2 = 17;
  25. BCTRLS_PS3 = 18;
  26. BCTRLS_PS4 = 19;
  27. BCTRLS_PS5 = 20;
  28. BCTRLS_PS6 = 21;
  29. BCTRLS_PS7 = 22;
  30. BCTRLS_PS8 = 23;
  31. BCTRLS_PS9 = 24;
  32. BCTRLS_PS10 = 25;
  33. KNOB_LEFT = 26;
  34. KNOB_RIGHT = 27;
  35. KNOB_PUSH = 28;
  36. ACTRLS_SLEEP = 29;
  37. }
  38. // Message for ButtonActions
  39. message ButtonActions {
  40. option (nanopb_msgopt).msgid = 10004;
  41. ButtonAction pressed = 1 ;
  42. ButtonAction released = 2 ;
  43. }
  44. message Button {
  45. option (nanopb_msgopt).msgid = 10005;
  46. GPIO gpio = 1;
  47. bool pull = 2;
  48. int32 debounce = 3;
  49. GPIO shifter = 4;
  50. int32 longduration = 5;
  51. ButtonActions normal = 6;
  52. ButtonActions longpress = 7;
  53. ButtonActions shifted = 8;
  54. ButtonActions longshifted = 9;
  55. }
  56. message KnobOnly {
  57. option (nanopb_msgopt).msgid = 10006;
  58. // This mode attempts to offer a single knob full navigation which is a bit contorded due to LMS UI's
  59. // principles. Left, Right and Press obey to LMS's navigation rules and especially Press always goes to
  60. // lower submenu item, even when navigating in the Music Library. That causes a challenge as there is no
  61. // 'Play', 'Back' or 'Pause' button. Workaround are as of below:
  62. // - longpress is 'Play'
  63. // - double press is 'Back' (Left in LMS's terminology).
  64. // - a quick left-right movement on the encoder is 'Pause'
  65. //
  66. // The speed of double click (or left-right) can be set using the optional parameter of 'knobonly'.
  67. // This is not a perfect solution, and other ideas are welcome. Be aware that the longer you set double
  68. // click speed, the less responsive the interface will be. The reason is that I need to wait for that
  69. // delay before deciding if it's a single or double click. It can also make menu navigation "hesitations"
  70. // being easily interpreted as 'Pause'
  71. bool enable = 1; // Enable/disable
  72. int32 delay_ms = 2; // optionally set the delay
  73. }
  74. message Rotary {
  75. option (nanopb_msgopt).msgid = 10007;
  76. GPIO A = 1;
  77. GPIO B = 2;
  78. GPIO SW = 3;
  79. KnobOnly knobonly = 4;
  80. bool volume = 5;
  81. bool longpress = 6;
  82. }