"use strict";
// https://github.com/synapticon/somanet_software/blob/32edf5ef572ea7d840aabe4a26e0f3d31f05caab/sw_applications/app_motion_drive/test/pytest/somanet_icmu_helpers.py
Object.defineProperty(exports, "__esModule", { value: true });
exports.computeCirculoEncoderCalibrationResult = exports.getCirculoEncoderCalibrationMaxValuePercentageLabel = exports.getCirculoEncoderCalibrationMaxValuePercentageColor = exports.CirculoIntegratedEncoderIcpvlCommands = exports.CirculoIntegratedEncoderIcmuCommands = exports.CirculoIntegratedEncoderEepromParameters = exports.CirculoIntegratedEncoderIcpvlParameters = exports.CirculoIntegratedEncoderIcmuParameters = exports.circuloIntegratedEncoderI2CDeviceIdOptions = exports.CirculoIntegratedEncoderI2CDeviceId = exports.circuloIntegratedEncoderKeyConfigurationRegisterAddresses = void 0;
/**
 * Mapping of key configuration register addresses for Circulo Integrated Encoders (e.g., iC-MU, iC-PVL).
 *
 * Each entry maps a configuration register's address in EEPROM to its corresponding
 * address in RAM. This mapping allows read/write access to configuration data via
 * either persistent storage (EEPROM) or volatile memory (RAM).
 */
exports.circuloIntegratedEncoderKeyConfigurationRegisterAddresses = [
    { eeprom: 0x00, ram: 0x00 },
    { eeprom: 0x01, ram: 0x01 },
    { eeprom: 0x02, ram: 0x02 },
    { eeprom: 0x03, ram: 0x03 },
    { eeprom: 0x04, ram: 0x04 },
    { eeprom: 0x05, ram: 0x05 },
    { eeprom: 0x06, ram: 0x06 },
    { eeprom: 0x07, ram: 0x07 },
    { eeprom: 0x08, ram: 0x08 },
    { eeprom: 0x09, ram: 0x09 },
    { eeprom: 0x0a, ram: 0x0a },
    { eeprom: 0x0b, ram: 0x0b },
    { eeprom: 0x0c, ram: 0x0c },
    { eeprom: 0x0d, ram: 0x0d },
    { eeprom: 0x0e, ram: 0x0e },
    { eeprom: 0x0f, ram: 0x0f },
    { eeprom: 0x10, ram: 0x10 },
    { eeprom: 0x11, ram: 0x11 },
    { eeprom: 0x12, ram: 0x12 },
    { eeprom: 0x13, ram: 0x13 },
    { eeprom: 0x14, ram: 0x14 },
    { eeprom: 0x15, ram: 0x15 },
    { eeprom: 0x16, ram: 0x16 },
    { eeprom: 0x17, ram: 0x17 },
    { eeprom: 0x18, ram: 0x18 },
    { eeprom: 0x19, ram: 0x52 },
    { eeprom: 0x1a, ram: 0x53 },
    { eeprom: 0x1b, ram: 0x54 },
    { eeprom: 0x1c, ram: 0x55 },
    { eeprom: 0x1d, ram: 0x56 },
    { eeprom: 0x1e, ram: 0x57 },
    { eeprom: 0x1f, ram: 0x58 },
    { eeprom: 0x20, ram: 0x59 },
];
/**
 * I²C device IDs (addresses) used to access specific memory areas and registers
 * of Circulo Integrated Encoders such as iC-MU and iC-PVL.
 *
 * These values are used as the 7-bit device address (plus R/W bit) in I²C transactions,
 * defining whether the access targets EEPROM or RAM, and whether full or limited access is allowed.
 *
 * EEPROM access allows for reading and writing of persistent configuration data,
 * while iC-PVL access allows interaction with runtime registers. Limited access
 * typically restricts operations to a subset of available registers.
 */
var CirculoIntegratedEncoderI2CDeviceId;
(function (CirculoIntegratedEncoderI2CDeviceId) {
    /** I²C address for writing to EEPROM memory. */
    CirculoIntegratedEncoderI2CDeviceId[CirculoIntegratedEncoderI2CDeviceId["WRITE_EEPROM"] = 160] = "WRITE_EEPROM";
    /** I²C address for reading from EEPROM memory. */
    CirculoIntegratedEncoderI2CDeviceId[CirculoIntegratedEncoderI2CDeviceId["READ_EEPROM"] = 161] = "READ_EEPROM";
    /** I²C address for limited write access to iC-PVL registers. */
    CirculoIntegratedEncoderI2CDeviceId[CirculoIntegratedEncoderI2CDeviceId["WRITE_ICPVL_LIMITED"] = 192] = "WRITE_ICPVL_LIMITED";
    /** I²C address for limited read access to iC-PVL registers. */
    CirculoIntegratedEncoderI2CDeviceId[CirculoIntegratedEncoderI2CDeviceId["READ_ICPVL_LIMITED"] = 193] = "READ_ICPVL_LIMITED";
    /** I²C address for full write access to iC-PVL registers. */
    CirculoIntegratedEncoderI2CDeviceId[CirculoIntegratedEncoderI2CDeviceId["WRITE_ICPVL"] = 194] = "WRITE_ICPVL";
    /** I²C address for full read access to iC-PVL registers. */
    CirculoIntegratedEncoderI2CDeviceId[CirculoIntegratedEncoderI2CDeviceId["READ_ICPVL"] = 195] = "READ_ICPVL";
})(CirculoIntegratedEncoderI2CDeviceId = exports.CirculoIntegratedEncoderI2CDeviceId || (exports.CirculoIntegratedEncoderI2CDeviceId = {}));
/**
 * A key-value object representing the `CirculoIntegratedEncoderI2CDeviceId` enum,
 * where each key is the string name of an I²C device ID, and each value is its
 * corresponding numeric address.
 *
 * This object is generated by filtering out the reverse mappings from the enum
 * (numeric keys), leaving only the name-to-value entries for use in things like
 * dropdowns or selection lists.
 *
 * @example
 * {
 *   READ_EEPROM: 161,
 *   READ_ICPVL: 195
 *   READ_ICPVL_LIMITED: 193,
 *   WRITE_EEPROM: 160,
 *   WRITE_ICPVL: 194,
 *   WRITE_ICPVL_LIMITED: 192,
 * }
 */
exports.circuloIntegratedEncoderI2CDeviceIdOptions = Object.entries(CirculoIntegratedEncoderI2CDeviceId)
    .filter(([key]) => isNaN(Number(key))) // exclude numeric keys (value-to-name)
    .reduce((acc, [key, value]) => {
    acc[key] = value;
    return acc;
}, {});
class CirculoIntegratedEncoderIcmuParameters {
}
exports.CirculoIntegratedEncoderIcmuParameters = CirculoIntegratedEncoderIcmuParameters;
CirculoIntegratedEncoderIcmuParameters.GC_M = { address: 0x00, lsb: 6, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.GF_M = { address: 0x00, lsb: 0, msb: 5 };
CirculoIntegratedEncoderIcmuParameters.GX_M = { address: 0x01, lsb: 0, msb: 6 };
CirculoIntegratedEncoderIcmuParameters.VOSS_M = { address: 0x02, lsb: 0, msb: 6 };
CirculoIntegratedEncoderIcmuParameters.VOSC_M = { address: 0x03, lsb: 0, msb: 6 };
CirculoIntegratedEncoderIcmuParameters.PH_M = { address: 0x04, lsb: 0, msb: 6 };
CirculoIntegratedEncoderIcmuParameters.ENAC = { address: 0x05, lsb: 7, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.CIBM = { address: 0x05, lsb: 0, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.GC_N = { address: 0x06, lsb: 6, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.GF_N = { address: 0x06, lsb: 0, msb: 5 };
CirculoIntegratedEncoderIcmuParameters.GX_N = { address: 0x07, lsb: 0, msb: 6 };
CirculoIntegratedEncoderIcmuParameters.VOSS_N = { address: 0x08, lsb: 0, msb: 6 };
CirculoIntegratedEncoderIcmuParameters.VOSC_N = { address: 0x09, lsb: 0, msb: 6 };
CirculoIntegratedEncoderIcmuParameters.PH_N = { address: 0x0a, lsb: 0, msb: 6 };
CirculoIntegratedEncoderIcmuParameters.MODEB = { address: 0x0b, lsb: 4, msb: 6 };
CirculoIntegratedEncoderIcmuParameters.MODEA = { address: 0x0b, lsb: 0, msb: 2 };
CirculoIntegratedEncoderIcmuParameters.CFGEW = { address: 0x0c, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.ACC_STAT = { address: 0x0d, lsb: 7, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.NCHK_CRC = { address: 0x0d, lsb: 6, msb: 6 };
CirculoIntegratedEncoderIcmuParameters.NCHK_NON = { address: 0x0d, lsb: 5, msb: 5 };
CirculoIntegratedEncoderIcmuParameters.ACRM_RES = { address: 0x0d, lsb: 4, msb: 4 };
CirculoIntegratedEncoderIcmuParameters.EMTD = { address: 0x0d, lsb: 0, msb: 2 };
CirculoIntegratedEncoderIcmuParameters.ESSI_MT = { address: 0x0e, lsb: 6, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.ROT_MT = { address: 0x0e, lsb: 5, msb: 5 };
CirculoIntegratedEncoderIcmuParameters.LIN = { address: 0x0e, lsb: 4, msb: 4 };
CirculoIntegratedEncoderIcmuParameters.FILT = { address: 0x0e, lsb: 0, msb: 2 };
CirculoIntegratedEncoderIcmuParameters.SPO_MT = { address: 0x0f, lsb: 4, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.MPC = { address: 0x0f, lsb: 0, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.GET_MT = { address: 0x10, lsb: 7, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.CHK_MT = { address: 0x10, lsb: 6, msb: 6 };
CirculoIntegratedEncoderIcmuParameters.SBL_MT = { address: 0x10, lsb: 4, msb: 5 };
CirculoIntegratedEncoderIcmuParameters.MODE_MT = { address: 0x10, lsb: 0, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.OUT_ZERO = { address: 0x11, lsb: 5, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.OUT_MSB = { address: 0x11, lsb: 0, msb: 4 };
CirculoIntegratedEncoderIcmuParameters.GSSI = { address: 0x12, lsb: 7, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.RSSI = { address: 0x12, lsb: 6, msb: 6 };
CirculoIntegratedEncoderIcmuParameters.MODE_ST = { address: 0x12, lsb: 4, msb: 5 };
CirculoIntegratedEncoderIcmuParameters.OUT_LSB = { address: 0x12, lsb: 0, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.RESABZ = { address: 0x13, lsb: 0, msb: 15 };
CirculoIntegratedEncoderIcmuParameters.ROT = { address: 0x015, lsb: 7, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.SS_AB = { address: 0x15, lsb: 4, msb: 5 };
CirculoIntegratedEncoderIcmuParameters.ENIF_AUTO = { address: 0x15, lsb: 3, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.FRQAB = { address: 0x15, lsb: 0, msb: 2 };
CirculoIntegratedEncoderIcmuParameters.LENZ = { address: 0x16, lsb: 6, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.CHYS_AB = { address: 0x16, lsb: 4, msb: 5 };
CirculoIntegratedEncoderIcmuParameters.PP60UVW = { address: 0x16, lsb: 3, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.INV_A = { address: 0x16, lsb: 2, msb: 2 };
CirculoIntegratedEncoderIcmuParameters.INV_B = { address: 0x16, lsb: 1, msb: 1 };
CirculoIntegratedEncoderIcmuParameters.INV_Z = { address: 0x16, lsb: 0, msb: 0 };
CirculoIntegratedEncoderIcmuParameters.RPL = { address: 0x17, lsb: 6, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.PPUVW = { address: 0x17, lsb: 0, msb: 5 };
CirculoIntegratedEncoderIcmuParameters.TEST = { address: 0x18, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.OFF_ABZ_1 = { address: 0x1e, lsb: 4, msb: 15 };
CirculoIntegratedEncoderIcmuParameters.OFF_POS = { address: 0x20, lsb: 0, msb: 23 };
CirculoIntegratedEncoderIcmuParameters.OFF_COM = { address: 0x23, lsb: 4, msb: 15 };
CirculoIntegratedEncoderIcmuParameters.PA0_CONF = { address: 0x25, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.ACGAIN_M = { address: 0x2b, lsb: 3, msb: 4 };
CirculoIntegratedEncoderIcmuParameters.AFGAIN_M = { address: 0x2b, lsb: 0, msb: 2 };
CirculoIntegratedEncoderIcmuParameters.ACGAIN_N = { address: 0x2f, lsb: 3, msb: 4 };
CirculoIntegratedEncoderIcmuParameters.AFGAIN_N = { address: 0x2f, lsb: 0, msb: 2 };
CirculoIntegratedEncoderIcmuParameters.BANKSEL = { address: 0x40, lsb: 0, msb: 4 };
CirculoIntegratedEncoderIcmuParameters.EDSBANK = { address: 0x41, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.PROFILE_ID = { address: 0x42, lsb: 0, msb: 15 };
CirculoIntegratedEncoderIcmuParameters.SERIAL = { address: 0x44, lsb: 0, msb: 31 };
CirculoIntegratedEncoderIcmuParameters.OFF_ABZ_2 = { address: 0x48, lsb: 0, msb: 23 };
CirculoIntegratedEncoderIcmuParameters.OFF_UVW = { address: 0x4b, lsb: 4, msb: 15 };
CirculoIntegratedEncoderIcmuParameters.PRES_POS = { address: 0x4d, lsb: 4, msb: 39 };
CirculoIntegratedEncoderIcmuParameters.SPO_0 = { address: 0x52, lsb: 4, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.SPO_BASE = { address: 0x52, lsb: 0, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.SPO_2 = { address: 0x53, lsb: 4, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.SPO_1 = { address: 0x53, lsb: 0, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.SPO_4 = { address: 0x54, lsb: 4, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.SPO_3 = { address: 0x54, lsb: 0, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.SPO_6 = { address: 0x55, lsb: 4, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.SPO_5 = { address: 0x55, lsb: 0, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.SPO_8 = { address: 0x56, lsb: 4, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.SPO_7 = { address: 0x56, lsb: 0, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.SPO_10 = { address: 0x57, lsb: 4, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.SPO_9 = { address: 0x57, lsb: 0, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.SPO_12 = { address: 0x58, lsb: 4, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.SPO_11 = { address: 0x58, lsb: 0, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.SPO_14 = { address: 0x59, lsb: 4, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.SPO_13 = { address: 0x59, lsb: 0, msb: 3 };
CirculoIntegratedEncoderIcmuParameters.RPL_RESET = { address: 0x5a, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.I2C_DEV_START = { address: 0x5b, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.I2C_RAM_START = { address: 0x5c, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.I2C_RAM_END = { address: 0x5d, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.I2C_DEVID = { address: 0x5e, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.I2C_RETRY = { address: 0x5f, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_1 = { address: 0x60, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_2 = { address: 0x61, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_3 = { address: 0x62, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_4 = { address: 0x63, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_5 = { address: 0x64, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_6 = { address: 0x65, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_7 = { address: 0x66, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_8 = { address: 0x67, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_9 = { address: 0x68, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_10 = { address: 0x69, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_11 = { address: 0x6a, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_12 = { address: 0x6b, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_13 = { address: 0x6c, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_14 = { address: 0x6d, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_15 = { address: 0x6e, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.USER_EXCHANGE_REGISTERS_16 = { address: 0x6f, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.EVENT_COUNT = { address: 0x73, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.HARD_REV = { address: 0x74, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.CMD_MU = { address: 0x75, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.STATUS0 = { address: 0x76, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.STATUS1 = { address: 0x77, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcmuParameters.DEV_ID = { address: 0x78, lsb: 0, msb: 47 };
CirculoIntegratedEncoderIcmuParameters.MFG_ID = { address: 0x7e, lsb: 0, msb: 15 };
class CirculoIntegratedEncoderIcpvlParameters {
}
exports.CirculoIntegratedEncoderIcpvlParameters = CirculoIntegratedEncoderIcpvlParameters;
CirculoIntegratedEncoderIcpvlParameters.EN_PAR = { address: 0x00, lsb: 6, msb: 7 };
CirculoIntegratedEncoderIcpvlParameters.EN_ERR = { address: 0x00, lsb: 4, msb: 5 };
CirculoIntegratedEncoderIcpvlParameters.DIR = { address: 0x00, lsb: 3, msb: 3 };
CirculoIntegratedEncoderIcpvlParameters.ST_GRAY = { address: 0x00, lsb: 2, msb: 2 };
CirculoIntegratedEncoderIcpvlParameters.MT_GRAY = { address: 0x00, lsb: 1, msb: 1 };
CirculoIntegratedEncoderIcpvlParameters.INT_MODE = { address: 0x00, lsb: 0, msb: 0 };
CirculoIntegratedEncoderIcpvlParameters.OS = { address: 0x01, lsb: 5, msb: 7 };
CirculoIntegratedEncoderIcpvlParameters.MT_BW = { address: 0x01, lsb: 0, msb: 4 };
CirculoIntegratedEncoderIcpvlParameters.PCR = { address: 0x02, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcpvlParameters.EN_WRN = { address: 0x03, lsb: 7, msb: 7 };
CirculoIntegratedEncoderIcpvlParameters.BAT_MON = { address: 0x03, lsb: 6, msb: 6 };
CirculoIntegratedEncoderIcpvlParameters.A_MAX = { address: 0x03, lsb: 3, msb: 5 };
CirculoIntegratedEncoderIcpvlParameters.IBIAS = { address: 0x03, lsb: 0, msb: 2 };
CirculoIntegratedEncoderIcpvlParameters.FIXED_ZERO_1 = { address: 0x04, lsb: 7, msb: 7 };
CirculoIntegratedEncoderIcpvlParameters.NOMAG = { address: 0x04, lsb: 5, msb: 6 };
CirculoIntegratedEncoderIcpvlParameters.ATHR = { address: 0x04, lsb: 3, msb: 4 };
CirculoIntegratedEncoderIcpvlParameters.ONAX = { address: 0x04, lsb: 2, msb: 2 };
CirculoIntegratedEncoderIcpvlParameters.POLEWID = { address: 0x04, lsb: 0, msb: 1 };
CirculoIntegratedEncoderIcpvlParameters.I2C_POS = { address: 0x05, lsb: 7, msb: 7 };
CirculoIntegratedEncoderIcpvlParameters.PCR_OUT = { address: 0x05, lsb: 6, msb: 6 };
CirculoIntegratedEncoderIcpvlParameters.SYNC_BW = { address: 0x05, lsb: 4, msb: 5 };
CirculoIntegratedEncoderIcpvlParameters.BAT_THR = { address: 0x05, lsb: 2, msb: 3 };
CirculoIntegratedEncoderIcpvlParameters.HYS = { address: 0x05, lsb: 1, msb: 1 };
CirculoIntegratedEncoderIcpvlParameters.ABQUAD = { address: 0x05, lsb: 0, msb: 0 };
CirculoIntegratedEncoderIcpvlParameters.CRC_CFG = { address: 0x06, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcpvlParameters.MT_COUNT = { address: 0x07, lsb: 0, msb: 39 };
CirculoIntegratedEncoderIcpvlParameters.CRC_CTR = { address: 0x0c, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcpvlParameters.FIXED_ZERO_2 = { address: 0x0d, lsb: 3, msb: 7 };
CirculoIntegratedEncoderIcpvlParameters.SYNC = { address: 0x0d, lsb: 0, msb: 2 };
CirculoIntegratedEncoderIcpvlParameters.CHIP_REL = { address: 0x0f, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcpvlParameters.PRESET = { address: 0x10, lsb: 7, msb: 7 };
CirculoIntegratedEncoderIcpvlParameters.PDR = { address: 0x10, lsb: 6, msb: 6 };
CirculoIntegratedEncoderIcpvlParameters.BAT_WRN = { address: 0x10, lsb: 5, msb: 5 };
CirculoIntegratedEncoderIcpvlParameters.BAT_ERR = { address: 0x10, lsb: 4, msb: 4 };
CirculoIntegratedEncoderIcpvlParameters.POS_ERR = { address: 0x10, lsb: 3, msb: 3 };
CirculoIntegratedEncoderIcpvlParameters.CTR_ERR = { address: 0x10, lsb: 2, msb: 2 };
CirculoIntegratedEncoderIcpvlParameters.CFG_ERR = { address: 0x10, lsb: 1, msb: 1 };
CirculoIntegratedEncoderIcpvlParameters.STUP_ERR = { address: 0x10, lsb: 0, msb: 0 };
CirculoIntegratedEncoderIcpvlParameters.CMD = { address: 0x11, lsb: 0, msb: 7 };
CirculoIntegratedEncoderIcpvlParameters.SLEEP_ST = { address: 0x12, lsb: 7, msb: 7 };
CirculoIntegratedEncoderIcpvlParameters.NOMAG_ST = { address: 0x12, lsb: 6, msb: 6 };
CirculoIntegratedEncoderIcpvlParameters.ACTIVE_ST = { address: 0x12, lsb: 5, msb: 5 };
CirculoIntegratedEncoderIcpvlParameters.POWON_ST = { address: 0x12, lsb: 4, msb: 4 };
CirculoIntegratedEncoderIcpvlParameters.NOMAG_L = { address: 0x12, lsb: 2, msb: 2 };
CirculoIntegratedEncoderIcpvlParameters.MAG_ERR = { address: 0x12, lsb: 1, msb: 1 };
CirculoIntegratedEncoderIcpvlParameters.AMPL_ERR = { address: 0x12, lsb: 0, msb: 0 };
class CirculoIntegratedEncoderEepromParameters {
}
exports.CirculoIntegratedEncoderEepromParameters = CirculoIntegratedEncoderEepromParameters;
// iC-MU registers
CirculoIntegratedEncoderEepromParameters.GC_M = { address: 0x00, lsb: 6, msb: 7 };
CirculoIntegratedEncoderEepromParameters.GF_M = { address: 0x00, lsb: 0, msb: 5 };
CirculoIntegratedEncoderEepromParameters.GX_M = { address: 0x01, lsb: 0, msb: 6 };
CirculoIntegratedEncoderEepromParameters.VOSS_M = { address: 0x02, lsb: 0, msb: 6 };
CirculoIntegratedEncoderEepromParameters.VOSC_M = { address: 0x03, lsb: 0, msb: 6 };
CirculoIntegratedEncoderEepromParameters.PH_M = { address: 0x04, lsb: 0, msb: 6 };
CirculoIntegratedEncoderEepromParameters.ENAC = { address: 0x05, lsb: 7, msb: 7 };
CirculoIntegratedEncoderEepromParameters.CIBM = { address: 0x05, lsb: 0, msb: 3 };
CirculoIntegratedEncoderEepromParameters.GC_N = { address: 0x06, lsb: 6, msb: 7 };
CirculoIntegratedEncoderEepromParameters.GF_N = { address: 0x06, lsb: 0, msb: 5 };
CirculoIntegratedEncoderEepromParameters.GX_N = { address: 0x07, lsb: 0, msb: 6 };
CirculoIntegratedEncoderEepromParameters.VOSS_N = { address: 0x08, lsb: 0, msb: 6 };
CirculoIntegratedEncoderEepromParameters.VOSC_N = { address: 0x09, lsb: 0, msb: 6 };
CirculoIntegratedEncoderEepromParameters.PH_N = { address: 0x0a, lsb: 0, msb: 6 };
CirculoIntegratedEncoderEepromParameters.MODEB = { address: 0x0b, lsb: 4, msb: 6 };
CirculoIntegratedEncoderEepromParameters.MODEA = { address: 0x0b, lsb: 0, msb: 2 };
CirculoIntegratedEncoderEepromParameters.CFGEW = { address: 0x0c, lsb: 0, msb: 7 };
CirculoIntegratedEncoderEepromParameters.ACC_STAT = { address: 0x0d, lsb: 7, msb: 7 };
CirculoIntegratedEncoderEepromParameters.NCHK_CRC = { address: 0x0d, lsb: 6, msb: 6 };
CirculoIntegratedEncoderEepromParameters.NCHK_NON = { address: 0x0d, lsb: 5, msb: 5 };
CirculoIntegratedEncoderEepromParameters.ACRM_RES = { address: 0x0d, lsb: 4, msb: 4 };
CirculoIntegratedEncoderEepromParameters.EMTD = { address: 0x0d, lsb: 0, msb: 2 };
CirculoIntegratedEncoderEepromParameters.ESSI_MT = { address: 0x0e, lsb: 6, msb: 7 };
CirculoIntegratedEncoderEepromParameters.ROT_MT = { address: 0x0e, lsb: 5, msb: 5 };
CirculoIntegratedEncoderEepromParameters.LIN = { address: 0x0e, lsb: 4, msb: 4 };
CirculoIntegratedEncoderEepromParameters.FILT = { address: 0x0e, lsb: 0, msb: 2 };
CirculoIntegratedEncoderEepromParameters.SPO_MT = { address: 0x0f, lsb: 4, msb: 7 };
CirculoIntegratedEncoderEepromParameters.MPC = { address: 0x0f, lsb: 0, msb: 3 };
CirculoIntegratedEncoderEepromParameters.GET_MT = { address: 0x10, lsb: 7, msb: 7 };
CirculoIntegratedEncoderEepromParameters.CHK_MT = { address: 0x10, lsb: 6, msb: 6 };
CirculoIntegratedEncoderEepromParameters.SBL_MT = { address: 0x10, lsb: 4, msb: 5 };
CirculoIntegratedEncoderEepromParameters.MODE_MT = { address: 0x10, lsb: 0, msb: 3 };
CirculoIntegratedEncoderEepromParameters.OUT_ZERO = { address: 0x11, lsb: 5, msb: 7 };
CirculoIntegratedEncoderEepromParameters.OUT_MSB = { address: 0x11, lsb: 0, msb: 4 };
CirculoIntegratedEncoderEepromParameters.GSSI = { address: 0x12, lsb: 7, msb: 7 };
CirculoIntegratedEncoderEepromParameters.RSSI = { address: 0x12, lsb: 6, msb: 6 };
CirculoIntegratedEncoderEepromParameters.MODE_ST = { address: 0x12, lsb: 4, msb: 5 };
CirculoIntegratedEncoderEepromParameters.OUT_LSB = { address: 0x12, lsb: 0, msb: 3 };
CirculoIntegratedEncoderEepromParameters.RESABZ = { address: 0x13, lsb: 0, msb: 15 };
CirculoIntegratedEncoderEepromParameters.ROT = { address: 0x015, lsb: 7, msb: 7 };
CirculoIntegratedEncoderEepromParameters.SS_AB = { address: 0x15, lsb: 4, msb: 5 };
CirculoIntegratedEncoderEepromParameters.ENIF_AUTO = { address: 0x15, lsb: 3, msb: 3 };
CirculoIntegratedEncoderEepromParameters.FRQAB = { address: 0x15, lsb: 0, msb: 2 };
CirculoIntegratedEncoderEepromParameters.LENZ = { address: 0x16, lsb: 6, msb: 7 };
CirculoIntegratedEncoderEepromParameters.CHYS_AB = { address: 0x16, lsb: 4, msb: 5 };
CirculoIntegratedEncoderEepromParameters.PP60UVW = { address: 0x16, lsb: 3, msb: 3 };
CirculoIntegratedEncoderEepromParameters.INV_A = { address: 0x16, lsb: 2, msb: 2 };
CirculoIntegratedEncoderEepromParameters.INV_B = { address: 0x16, lsb: 1, msb: 1 };
CirculoIntegratedEncoderEepromParameters.INV_Z = { address: 0x16, lsb: 0, msb: 0 };
CirculoIntegratedEncoderEepromParameters.RPL = { address: 0x17, lsb: 6, msb: 7 };
CirculoIntegratedEncoderEepromParameters.PPUVW = { address: 0x17, lsb: 0, msb: 5 };
CirculoIntegratedEncoderEepromParameters.TEST = { address: 0x18, lsb: 0, msb: 7 };
CirculoIntegratedEncoderEepromParameters.SPO_0 = { address: 0x19, lsb: 4, msb: 7 };
CirculoIntegratedEncoderEepromParameters.SPO_BASE = { address: 0x19, lsb: 0, msb: 3 };
CirculoIntegratedEncoderEepromParameters.SPO_2 = { address: 0x1a, lsb: 4, msb: 7 };
CirculoIntegratedEncoderEepromParameters.SPO_1 = { address: 0x1a, lsb: 0, msb: 3 };
CirculoIntegratedEncoderEepromParameters.SPO_4 = { address: 0x1b, lsb: 4, msb: 7 };
CirculoIntegratedEncoderEepromParameters.SPO_3 = { address: 0x1b, lsb: 0, msb: 3 };
CirculoIntegratedEncoderEepromParameters.SPO_6 = { address: 0x1c, lsb: 4, msb: 7 };
CirculoIntegratedEncoderEepromParameters.SPO_5 = { address: 0x1c, lsb: 0, msb: 3 };
CirculoIntegratedEncoderEepromParameters.SPO_8 = { address: 0x1d, lsb: 4, msb: 7 };
CirculoIntegratedEncoderEepromParameters.SPO_7 = { address: 0x1d, lsb: 0, msb: 3 };
CirculoIntegratedEncoderEepromParameters.SPO_10 = { address: 0x1e, lsb: 4, msb: 7 };
CirculoIntegratedEncoderEepromParameters.SPO_9 = { address: 0x1e, lsb: 0, msb: 3 };
CirculoIntegratedEncoderEepromParameters.SPO_12 = { address: 0x1f, lsb: 4, msb: 7 };
CirculoIntegratedEncoderEepromParameters.SPO_11 = { address: 0x1f, lsb: 0, msb: 3 };
CirculoIntegratedEncoderEepromParameters.SPO_14 = { address: 0x20, lsb: 4, msb: 7 };
CirculoIntegratedEncoderEepromParameters.SPO_13 = { address: 0x20, lsb: 0, msb: 3 };
CirculoIntegratedEncoderEepromParameters.CRC16 = { address: 0x21, lsb: 0, msb: 15 };
CirculoIntegratedEncoderEepromParameters.OFF_ABZ = { address: 0x23, lsb: 4, msb: 39 };
CirculoIntegratedEncoderEepromParameters.OFF_UVW = { address: 0x28, lsb: 4, msb: 15 };
CirculoIntegratedEncoderEepromParameters.PRES_POS = { address: 0x2a, lsb: 4, msb: 39 };
CirculoIntegratedEncoderEepromParameters.CRC8 = { address: 0x2f, lsb: 0, msb: 7 };
CirculoIntegratedEncoderEepromParameters.PA0_CONF = { address: 0x30, lsb: 0, msb: 7 };
CirculoIntegratedEncoderEepromParameters.EDSBANK = { address: 0x31, lsb: 0, msb: 7 };
CirculoIntegratedEncoderEepromParameters.PROFILE_ID = { address: 0x32, lsb: 0, msb: 15 };
CirculoIntegratedEncoderEepromParameters.SERIAL = { address: 0x34, lsb: 0, msb: 31 };
CirculoIntegratedEncoderEepromParameters.DEV_ID = { address: 0x38, lsb: 0, msb: 47 };
CirculoIntegratedEncoderEepromParameters.MFG_ID = { address: 0x3e, lsb: 0, msb: 15 };
// iC-PVL registers
CirculoIntegratedEncoderEepromParameters.EN_PAR = { address: 0x40, lsb: 6, msb: 7 };
CirculoIntegratedEncoderEepromParameters.EN_ERR = { address: 0x40, lsb: 4, msb: 5 };
CirculoIntegratedEncoderEepromParameters.DIR = { address: 0x40, lsb: 3, msb: 3 };
CirculoIntegratedEncoderEepromParameters.ST_GRAY = { address: 0x40, lsb: 2, msb: 2 };
CirculoIntegratedEncoderEepromParameters.MT_GRAY = { address: 0x40, lsb: 1, msb: 1 };
CirculoIntegratedEncoderEepromParameters.INT_MODE = { address: 0x40, lsb: 0, msb: 0 };
CirculoIntegratedEncoderEepromParameters.OS = { address: 0x41, lsb: 5, msb: 7 };
CirculoIntegratedEncoderEepromParameters.MT_BW = { address: 0x41, lsb: 0, msb: 4 };
CirculoIntegratedEncoderEepromParameters.PCR = { address: 0x42, lsb: 0, msb: 7 };
CirculoIntegratedEncoderEepromParameters.EN_WRN = { address: 0x43, lsb: 7, msb: 7 };
CirculoIntegratedEncoderEepromParameters.BAT_MON = { address: 0x43, lsb: 6, msb: 6 };
CirculoIntegratedEncoderEepromParameters.A_MAX = { address: 0x43, lsb: 3, msb: 5 };
CirculoIntegratedEncoderEepromParameters.IBIAS = { address: 0x43, lsb: 0, msb: 2 };
CirculoIntegratedEncoderEepromParameters.FIXED_ZERO_1 = { address: 0x44, lsb: 7, msb: 7 };
CirculoIntegratedEncoderEepromParameters.NOMAG = { address: 0x44, lsb: 5, msb: 6 };
CirculoIntegratedEncoderEepromParameters.ATHR = { address: 0x44, lsb: 3, msb: 4 };
CirculoIntegratedEncoderEepromParameters.ONAX = { address: 0x44, lsb: 2, msb: 2 };
CirculoIntegratedEncoderEepromParameters.POLEWID = { address: 0x44, lsb: 0, msb: 1 };
CirculoIntegratedEncoderEepromParameters.I2C_POS = { address: 0x45, lsb: 7, msb: 7 };
CirculoIntegratedEncoderEepromParameters.PCR_OUT = { address: 0x45, lsb: 6, msb: 6 };
CirculoIntegratedEncoderEepromParameters.SYNC_BW = { address: 0x45, lsb: 4, msb: 5 };
CirculoIntegratedEncoderEepromParameters.BAT_THR = { address: 0x45, lsb: 2, msb: 3 };
CirculoIntegratedEncoderEepromParameters.HYS = { address: 0x45, lsb: 1, msb: 1 };
CirculoIntegratedEncoderEepromParameters.ABQUAD = { address: 0x45, lsb: 0, msb: 0 };
CirculoIntegratedEncoderEepromParameters.CRC_CFG = { address: 0x46, lsb: 0, msb: 7 };
CirculoIntegratedEncoderEepromParameters.MT_PREL = { address: 0x47, lsb: 0, msb: 39 };
CirculoIntegratedEncoderEepromParameters.CRC_CTR = { address: 0x4c, lsb: 0, msb: 7 };
/**
 * Commands for the iC-MU encoder's `CMD_MU` register (address 0x75).
 *
 * These command codes control various internal operations of the iC-MU encoder,
 * such as memory writes, resets, communication settings, and maintenance counters.
 */
class CirculoIntegratedEncoderIcmuCommands {
}
exports.CirculoIntegratedEncoderIcmuCommands = CirculoIntegratedEncoderIcmuCommands;
/** Write all configuration settings to EEPROM. */
CirculoIntegratedEncoderIcmuCommands.WRITE_ALL = 0x01;
/** Disable EEPROM write access. */
CirculoIntegratedEncoderIcmuCommands.WRITE_OFF = 0x02;
/** Reset absolute position data. */
CirculoIntegratedEncoderIcmuCommands.ABS_RESET = 0x03;
/** Start non-volatile memory verification. */
CirculoIntegratedEncoderIcmuCommands.NON_VER = 0x04;
/** Reset multiturn counter. */
CirculoIntegratedEncoderIcmuCommands.MT_RESET = 0x05;
/** Verify multiturn counter value. */
CirculoIntegratedEncoderIcmuCommands.MT_VER = 0x06;
/** Perform a software reset of the device. */
CirculoIntegratedEncoderIcmuCommands.SOFT_RESET = 0x07;
/** Perform a software presence check. */
CirculoIntegratedEncoderIcmuCommands.SOFT_PRES = 0x08;
/** Perform a software + EEPROM presence check. */
CirculoIntegratedEncoderIcmuCommands.SOFT_E2P_PRES = 0x09;
/** Set or test I²C communication path. */
CirculoIntegratedEncoderIcmuCommands.I2C_COM = 0x0a;
/** Trigger an event counter update. */
CirculoIntegratedEncoderIcmuCommands.EVENT_COUNT = 0x0b;
/** Toggle or test switch functionality. */
CirculoIntegratedEncoderIcmuCommands.SWITCH = 0x0c;
/** Verify stored CRC against calculated CRC. */
CirculoIntegratedEncoderIcmuCommands.CRC_VER = 0x0d;
/** Trigger CRC calculation. */
CirculoIntegratedEncoderIcmuCommands.CRC_CALC = 0x0e;
/** Set multiturn counter (manual value assignment). */
CirculoIntegratedEncoderIcmuCommands.SET_MTC = 0x0f;
/** Reset multiturn counter to zero. */
CirculoIntegratedEncoderIcmuCommands.RES_MTC = 0x10;
/**
 * Commands for the iC-PVL encoder's `CMD` register (address 0x11).
 *
 * These command values are written to the `CMD` register to control
 * the behavior of the encoder, including reset, sleep mode, and clearing status.
 */
class CirculoIntegratedEncoderIcpvlCommands {
}
exports.CirculoIntegratedEncoderIcpvlCommands = CirculoIntegratedEncoderIcpvlCommands;
/** Perform a software reset of the device. */
CirculoIntegratedEncoderIcpvlCommands.RESET = 0x02;
/** Reboot the device, similar to power cycling. */
CirculoIntegratedEncoderIcpvlCommands.REBOOT = 0x03;
/** Enable sleep mode to reduce power consumption. */
CirculoIntegratedEncoderIcpvlCommands.SLEEP_ENABLE = 0x04;
/** Clear internal status flags or errors (software clear). */
CirculoIntegratedEncoderIcpvlCommands.SCLR = 0x05;
/** Disable sleep mode and resume normal operation. */
CirculoIntegratedEncoderIcpvlCommands.SLEEP_DISABLE = 0x07;
/**
 * Returns a color representing the encoder calibration quality for Circulo devices.
 *
 * The color is determined by the maximum-value percentage:
 *
 * - `50–100%`: **Green** (`#6ba853`) — robust calibration
 * - `20–50%`: **Yellow** (`#aeb303`) — acceptable, small displacements tolerated
 * - `0–20%`: **Orange** (`#e69138`) — weak, avoid mechanical displacement
 * - `≤ 0%`: **Red** (`#fb262e`) — invalid calibration, phase error too high
 *
 * @param percentage - The maximum-value percentage obtained from encoder calibration.
 * @returns A hex color string representing the calibration quality, or an empty string if out of range.
 */
function getCirculoEncoderCalibrationMaxValuePercentageColor(percentage) {
    if (percentage >= 50 && percentage <= 100) {
        return '#6ba853';
    }
    else if (percentage > 20 && percentage < 50) {
        return '#aeb303';
    }
    else if (percentage > 0 && percentage <= 20) {
        return '#e69138';
    }
    else if (percentage <= 0) {
        return '#fb262e';
    }
    return '';
}
exports.getCirculoEncoderCalibrationMaxValuePercentageColor = getCirculoEncoderCalibrationMaxValuePercentageColor;
/**
 * Returns a descriptive label explaining the quality of the encoder calibration
 * based on the maximum-value percentage for Circulo devices.
 *
 * The label communicates how robust the calibration is with respect to mechanical
 * displacement and thermal expansion:
 *
 * - `50–100%`: Robust against displacement and temperature changes
 * - `20–50%`: Robust to small mechanical or thermal variations
 * - `0–20%`: Calibration succeeded but sensitive; avoid displacement
 * - `≤ 0%`: Calibration failed; phase error too high
 *
 * @param percentage - The maximum-value percentage obtained from encoder calibration.
 * @returns A human-readable label describing calibration quality, or an empty string if out of range.
 */
function getCirculoEncoderCalibrationMaxValuePercentageLabel(percentage) {
    if (percentage >= 50 && percentage <= 100) {
        return 'Calibration was successful. Encoder system is robust to mechanical displacements and temperature expansions.';
    }
    else if (percentage > 20 && percentage < 50) {
        return 'Calibration was successful. Encoder system is robust to small mechanical displacements and temperature expansions.';
    }
    else if (percentage > 0 && percentage <= 20) {
        return 'Calibration was successful. Mechanical displacement and temperature expansions should be avoided.';
    }
    else if (percentage <= 0) {
        return "Phase error is too high. The absolute position can't be computed reliably. Adjust mechanical position and repeat calibration.";
    }
    return '';
}
exports.getCirculoEncoderCalibrationMaxValuePercentageLabel = getCirculoEncoderCalibrationMaxValuePercentageLabel;
/**
 * Computes the Circulo encoder calibration result from position and phaseError arrays.
 *
 * Handles empty or mismatched inputs gracefully by returning null.
 *
 * @param position - Array of encoder positions
 * @param phaseError - Array of corresponding phase errors
 * @returns Calibration result or null if inputs are invalid or empty
 */
function computeCirculoEncoderCalibrationResult(position, phaseError) {
    // Return null if inputs are missing or lengths don't match
    if (!position || !phaseError || position.length !== phaseError.length || position.length === 0) {
        return null;
    }
    // Pair valid [position, phaseError] points
    const data = position
        .map((p, i) => {
        const err = phaseError[i];
        return Number.isFinite(p) && Number.isFinite(err) ? [p, err] : undefined;
    })
        .filter((pt) => !!pt);
    if (data.length === 0) {
        return null;
    }
    // Find the data point with the largest absolute phase error
    const maxPoint = data.reduce((max, point) => (Math.abs(point[1]) > Math.abs(max[1]) ? point : max), data[0]);
    const yDomainLimit = 256;
    const maxValuePercentage = Math.max(100 - Math.floor((Math.abs(maxPoint[1]) / yDomainLimit) * 100), 0);
    return {
        data,
        value: maxValuePercentage,
        meaning: getCirculoEncoderCalibrationMaxValuePercentageLabel(maxValuePercentage),
    };
}
exports.computeCirculoEncoderCalibrationResult = computeCirculoEncoderCalibrationResult;
//# sourceMappingURL=circulo.js.map