{
  "name": "Servo",
  "status": "stable",
  "shortId": "servo",
  "camelName": "servo",
  "shortName": "servo",
  "extends": [
    "_base"
  ],
  "notes": {
    "short": "Servo is a small motor with arm that can be pointing at a specific direction.\nTypically a servo angle is between 0° and 180° where 90° is the middle resting position.\n\nThe `min_pulse/max_pulse` may be read-only if the servo is permanently affixed to its Jacdac controller."
  },
  "classIdentifier": 318542083,
  "enums": {},
  "constants": {},
  "packets": [
    {
      "kind": "report",
      "name": "command_not_implemented",
      "identifier": 3,
      "description": "This report may be emitted by a server in response to a command (action or register operation)\nthat it does not understand.\nThe `service_command` and `packet_crc` fields are copied from the command packet that was unhandled.\nNote that it's possible to get an ACK, followed by such an error report.",
      "fields": [
        {
          "name": "service_command",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        },
        {
          "name": "packet_crc",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        }
      ],
      "identifierName": "command_not_implemented",
      "packFormat": "u16 u16",
      "derived": "_base"
    },
    {
      "kind": "const",
      "name": "instance_name",
      "identifier": 265,
      "description": "A friendly name that describes the role of this service instance in the device.\nIt often corresponds to what's printed on the device:\nfor example, `A` for button A, or `S0` for servo channel 0.\nWords like `left` should be avoided because of localization issues (unless they are printed on the device).",
      "fields": [
        {
          "name": "_",
          "type": "string",
          "storage": 0
        }
      ],
      "optional": true,
      "identifierName": "instance_name",
      "packFormat": "s",
      "derived": "_base"
    },
    {
      "kind": "ro",
      "name": "status_code",
      "identifier": 259,
      "description": "Reports the current state or error status of the device. ``code`` is a standardized value from \nthe Jacdac status/error codes. ``vendor_code`` is any vendor specific error code describing the device\nstate. This report is typically not queried, when a device has an error, it will typically\nadd this report in frame along with the announce packet. If a service implements this register,\nit should also support the ``status_code_changed`` event defined below.",
      "fields": [
        {
          "name": "code",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        },
        {
          "name": "vendor_code",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        }
      ],
      "optional": true,
      "identifierName": "status_code",
      "packFormat": "u16 u16",
      "derived": "_base"
    },
    {
      "kind": "rw",
      "name": "client_variant",
      "identifier": 9,
      "description": "An optional register in the format of a URL query string where the client can provide hints how\nthe device twin should be rendered. If the register is not implemented, the client library can simulate the register client side.",
      "fields": [
        {
          "name": "_",
          "type": "string",
          "storage": 0
        }
      ],
      "optional": true,
      "identifierName": "client_variant",
      "packFormat": "s",
      "derived": "_base"
    },
    {
      "kind": "event",
      "name": "status_code_changed",
      "identifier": 4,
      "description": "Notifies that the status code of the service changed.",
      "fields": [
        {
          "name": "code",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        },
        {
          "name": "vendor_code",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true
        }
      ],
      "optional": true,
      "identifierName": "status_code_changed",
      "packFormat": "u16 u16",
      "derived": "_base"
    },
    {
      "kind": "rw",
      "name": "angle",
      "identifier": 2,
      "description": "Specifies the angle of the arm (request).",
      "fields": [
        {
          "name": "_",
          "unit": "°",
          "shift": 16,
          "type": "i16.16",
          "storage": -4,
          "typicalMin": 0,
          "typicalMax": 180
        }
      ],
      "identifierName": "value",
      "packFormat": "i16.16"
    },
    {
      "kind": "rw",
      "name": "enabled",
      "identifier": 1,
      "description": "Turn the power to the servo on/off.",
      "fields": [
        {
          "name": "_",
          "type": "bool",
          "storage": 1
        }
      ],
      "identifierName": "intensity",
      "packFormat": "u8"
    },
    {
      "kind": "rw",
      "name": "offset",
      "identifier": 129,
      "description": "Correction applied to the angle to account for the servo arm drift.",
      "fields": [
        {
          "name": "_",
          "unit": "°",
          "shift": 16,
          "type": "i16.16",
          "storage": -4
        }
      ],
      "packFormat": "i16.16"
    },
    {
      "kind": "const",
      "name": "min_angle",
      "identifier": 272,
      "description": "Lowest angle that can be set, typically 0 °.",
      "fields": [
        {
          "name": "_",
          "unit": "°",
          "shift": 16,
          "type": "i16.16",
          "storage": -4
        }
      ],
      "identifierName": "min_value",
      "packFormat": "i16.16"
    },
    {
      "kind": "rw",
      "name": "min_pulse",
      "identifier": 131,
      "description": "The length of pulse corresponding to lowest angle.",
      "fields": [
        {
          "name": "_",
          "unit": "us",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true,
          "defaultValue": 500
        }
      ],
      "optional": true,
      "packFormat": "u16"
    },
    {
      "kind": "const",
      "name": "max_angle",
      "identifier": 273,
      "description": "Highest angle that can be set, typically 180°.",
      "fields": [
        {
          "name": "_",
          "unit": "°",
          "shift": 16,
          "type": "i16.16",
          "storage": -4
        }
      ],
      "identifierName": "max_value",
      "packFormat": "i16.16"
    },
    {
      "kind": "rw",
      "name": "max_pulse",
      "identifier": 133,
      "description": "The length of pulse corresponding to highest angle.",
      "fields": [
        {
          "name": "_",
          "unit": "us",
          "type": "u16",
          "storage": 2,
          "isSimpleType": true,
          "defaultValue": 2500
        }
      ],
      "optional": true,
      "packFormat": "u16"
    },
    {
      "kind": "const",
      "name": "stall_torque",
      "identifier": 384,
      "description": "The servo motor will stop rotating when it is trying to move a `stall_torque` weight at a radial distance of `1.0` cm.",
      "fields": [
        {
          "name": "_",
          "unit": "kg/cm",
          "shift": 16,
          "type": "u16.16",
          "storage": 4
        }
      ],
      "optional": true,
      "packFormat": "u16.16"
    },
    {
      "kind": "const",
      "name": "response_speed",
      "identifier": 385,
      "description": "Time to move 60°.",
      "fields": [
        {
          "name": "_",
          "unit": "s/60°",
          "shift": 16,
          "type": "u16.16",
          "storage": 4
        }
      ],
      "optional": true,
      "packFormat": "u16.16"
    },
    {
      "kind": "ro",
      "name": "actual_angle",
      "identifier": 257,
      "description": "The current physical position of the arm, if the device has a way to sense the position.",
      "fields": [
        {
          "name": "_",
          "unit": "°",
          "shift": 16,
          "type": "i16.16",
          "storage": -4
        }
      ],
      "volatile": true,
      "optional": true,
      "identifierName": "reading",
      "packFormat": "i16.16"
    }
  ],
  "tags": [
    "C"
  ]
}