added new dac command to set value manually

master
edwin 4 years ago
parent 8fd0bb88cb
commit 7810fb817f

@ -91,7 +91,7 @@ void MCP4725::operator=(uint16_t dac_value)
//i2c_write(address, temp, 3); //i2c_write(address, temp, 3);
} }
#if 0
void MCP4725::operator==(uint16_t dac_and_eeprom_value) void MCP4725::operator==(uint16_t dac_and_eeprom_value)
{ {
@ -106,10 +106,11 @@ void MCP4725::operator==(uint16_t dac_and_eeprom_value)
temp[4] = temp[1]; temp[4] = temp[1];
temp[5] = temp[2]; temp[5] = temp[2];
//i2c_write(address, temp, 6); i2c->writeBuffer(address, temp, 6);
} }
#if 0
void MCP4725::write_dac(uint16_t dac_value) void MCP4725::write_dac(uint16_t dac_value)
{ {
&this = dac_value; &this = dac_value;

@ -18,14 +18,14 @@ class MCP4725
// address list // address list
enum i2c_addr enum i2c_addr
{ {
addr_0x0 = 0b01100000, addr_0x60 = 0b01100000,
addr_0x1 = addr_0x0 + 1, addr_0x61 = addr_0x60 + 1,
addr_0x2 = addr_0x0 + 1, addr_0x62 = addr_0x60 + 2,
addr_0x3 = addr_0x0 + 1, addr_0x63 = addr_0x60 + 3,
addr_0x4 = addr_0x0 + 1, addr_0x64 = addr_0x60 + 4,
addr_0x5 = addr_0x0 + 1, addr_0x65 = addr_0x60 + 5,
addr_0x60 = 0x60,//addr_0x0 + 1, addr_0x66 = addr_0x60 + 6,
addr_0x7 = addr_0x0 + 1 addr_0x67 = addr_0x60 + 7
}; };
// power down impedance modes // power down impedance modes
@ -65,9 +65,10 @@ class MCP4725
void operator=(uint16_t dac_value); void operator=(uint16_t dac_value);
#if 0
void operator==(uint16_t dac_and_eeprom_value); void operator==(uint16_t dac_and_eeprom_value);
#if 0
void write_dac_and_eeprom(uint16_t value); void write_dac_and_eeprom(uint16_t value);
void set_powerdown_impedance(pwrd_md mode); void set_powerdown_impedance(pwrd_md mode);

@ -136,7 +136,7 @@ void mcp4725_test()
MCP4725 dac(&i2c); MCP4725 dac(&i2c);
dac = 0x0000; dac == 0x0000;
for(i = 20 ; i > 0; i--) for(i = 20 ; i > 0; i--)
{ {
@ -167,6 +167,22 @@ void mcp4725_test()
std::placeholders::_3)); std::placeholders::_3));
*/ */
}
void dac_test_1()
{
uint16_t value = 0;
MCP4725 dac(&i2c);
std::cout << "set dac value: ";
std::cin >> value;
dac = value;
} }
void dummy() void dummy()
@ -197,6 +213,7 @@ int main(int argc, char *argv[])
commander.addNewCommand("pca9685", "The test command for testing the pca8695", pca9685_test); commander.addNewCommand("pca9685", "The test command for testing the pca8695", pca9685_test);
commander.addNewCommand("motor", "The test command for testing the pca8695", pca9685_motor); commander.addNewCommand("motor", "The test command for testing the pca8695", pca9685_motor);
commander.addNewCommand("dac", "The test command for testing the mcp4725", mcp4725_test); commander.addNewCommand("dac", "The test command for testing the mcp4725", mcp4725_test);
commander.addNewCommand("set_dac_val", "The test command for setting the mcp4725 manually", dac_test_1);
commander(argv[1]); commander(argv[1]);
std::cout << "Main End" << std::endl; std::cout << "Main End" << std::endl;

Binary file not shown.
Loading…
Cancel
Save