smartknob.proto 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. syntax = "proto3";
  2. import "nanopb.proto";
  3. package PB;
  4. /*
  5. * Message FROM the SmartKnob to the host
  6. */
  7. message FromSmartKnob {
  8. uint32 protocol_version = 1 [(nanopb).int_size = IS_8];
  9. oneof payload {
  10. Ack ack = 2;
  11. Log log = 3;
  12. SmartKnobState smartknob_state = 4;
  13. }
  14. }
  15. /*
  16. * Message TO the Smartknob from the host
  17. */
  18. message ToSmartknob {
  19. uint32 protocol_version = 1 [(nanopb).int_size = IS_8];
  20. uint32 nonce = 2;
  21. oneof payload {
  22. RequestState request_state = 3;
  23. SmartKnobConfig smartknob_config = 4;
  24. }
  25. }
  26. message Ack {
  27. uint32 nonce = 1;
  28. }
  29. message Log {
  30. string msg = 1 [(nanopb).max_length = 255];
  31. }
  32. message SmartKnobState {
  33. int32 current_position = 1;
  34. float sub_position_unit = 2;
  35. SmartKnobConfig config = 3;
  36. /** Value that changes each time the knob is pressed */
  37. uint32 press_nonce = 4 [(nanopb).int_size = IS_8];
  38. }
  39. message SmartKnobConfig {
  40. int32 position = 1;
  41. float sub_position_unit = 2;
  42. /**
  43. * Position is normally only applied when it changes, but sometimes it's desirable
  44. * to reset the position to the same value, so a nonce change can be used to force
  45. * the position values to be applied as well.
  46. *
  47. * NOTE: Must be < 256
  48. */
  49. uint32 position_nonce = 3 [(nanopb).int_size = IS_8];
  50. int32 min_position = 4;
  51. int32 max_position = 5;
  52. float position_width_radians = 6;
  53. float detent_strength_unit = 7;
  54. float endstop_strength_unit = 8;
  55. float snap_point = 9;
  56. string text = 10 [(nanopb).max_length = 50];
  57. repeated int32 detent_positions = 11 [(nanopb).max_count = 5];
  58. float snap_point_bias = 12;
  59. /**
  60. * Hue (0-255) for all 8 ring LEDs, if supported. Note: this will likely be replaced
  61. * with more configurability in a future protocol version.
  62. */
  63. int32 led_hue = 13 [(nanopb).int_size = IS_16];
  64. }
  65. message RequestState {}
  66. message PersistentConfiguration {
  67. uint32 version = 1;
  68. MotorCalibration motor = 2;
  69. StrainCalibration strain = 3;
  70. }
  71. message MotorCalibration {
  72. bool calibrated = 1;
  73. float zero_electrical_offset = 2;
  74. bool direction_cw = 3;
  75. uint32 pole_pairs = 4;
  76. }
  77. message StrainCalibration {
  78. int32 idle_value = 1;
  79. int32 press_delta = 2;
  80. }