// Autogenerated C header file for Power
#ifndef _JACDAC_SPEC_POWER_H
#define _JACDAC_SPEC_POWER_H 1

#define JD_SERVICE_CLASS_POWER  0x1fa4c95a

// enum PowerStatus (uint8_t)
#define JD_POWER_POWER_STATUS_DISALLOWED 0x0
#define JD_POWER_POWER_STATUS_POWERING 0x1
#define JD_POWER_POWER_STATUS_OVERLOAD 0x2
#define JD_POWER_POWER_STATUS_OVERPROVISION 0x3

/**
 * Read-write bool (uint8_t). Can be used to completely disable the service.
 * When allowed, the service may still not be providing power, see 
 * `power_status` for the actual current state.
 */
#define JD_POWER_REG_ALLOWED JD_REG_INTENSITY

/**
 * Read-write mA uint16_t. Limit the power provided by the service. The actual maximum limit will depend on hardware.
 * This field may be read-only in some implementations - you should read it back after setting.
 */
#define JD_POWER_REG_MAX_POWER JD_REG_MAX_POWER

/**
 * Read-only PowerStatus (uint8_t). Indicates whether the power provider is currently providing power (`Powering` state), and if not, why not.
 * `Overprovision` means there was another power provider, and we stopped not to overprovision the bus.
 */
#define JD_POWER_REG_POWER_STATUS 0x181

/**
 * Read-only mA uint16_t. Present current draw from the bus.
 */
#define JD_POWER_REG_CURRENT_DRAW JD_REG_READING

/**
 * Read-only mV uint16_t. Voltage on input.
 */
#define JD_POWER_REG_BATTERY_VOLTAGE 0x180

/**
 * Read-only ratio u0.16 (uint16_t). Fraction of charge in the battery.
 */
#define JD_POWER_REG_BATTERY_CHARGE 0x182

/**
 * Constant mWh uint32_t. Energy that can be delivered to the bus when battery is fully charged.
 * This excludes conversion overheads if any.
 */
#define JD_POWER_REG_BATTERY_CAPACITY 0x183

/**
 * Read-write ms uint16_t. Many USB power packs need current to be drawn from time to time to prevent shutdown.
 * This regulates how often and for how long such current is drawn.
 * Typically a 1/8W 22 ohm resistor is used as load. This limits the duty cycle to 10%.
 */
#define JD_POWER_REG_KEEP_ON_PULSE_DURATION 0x80

/**
 * Read-write ms uint16_t. Many USB power packs need current to be drawn from time to time to prevent shutdown.
 * This regulates how often and for how long such current is drawn.
 * Typically a 1/8W 22 ohm resistor is used as load. This limits the duty cycle to 10%.
 */
#define JD_POWER_REG_KEEP_ON_PULSE_PERIOD 0x81

/**
 * No args. Sent by the power service periodically, as broadcast.
 */
#define JD_POWER_CMD_SHUTDOWN 0x80

/**
 * Argument: power_status PowerStatus (uint8_t). Emitted whenever `power_status` changes.
 */
#define JD_POWER_EV_POWER_STATUS_CHANGED JD_EV_CHANGE

#endif
