// This is for the MCP4451 I2C based digipot void digipot_i2c_set_current(int channel, float current) { current = min( (float) max( current, 0.0f ), DIGIPOT_I2C_MAX_CURRENT); // these addresses are specific to Azteeg X3 Pro, can be set to others, // In this case first digipot is at address A0=0, A1= 0, second one is at A0=0, A1= 1 byte addr = 0x2C; // channel 0-3 if (channel >= 4) { addr = 0x2E; // channel 4-7 channel -= 4; } // Initial setup i2c_send(addr, 0x40, 0xff); i2c_send(addr, 0xA0, 0xff); // Set actual wiper value byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 }; i2c_send(addr, addresses[channel], current_to_wiper(current)); }
// This is for the MCP4018 I2C based digipot void digipot_i2c_set_current(int channel, float current) { current = min(max(current, 0.0f), float(DIGIPOT_A4988_MAX_CURRENT)); i2c_send(channel, current_to_wiper(current)); }