FAR nicer logging
Some checks failed
Test compiling project / test (push) Failing after 2m14s

This commit is contained in:
2025-03-20 22:33:22 +01:00
parent 9064d3cd01
commit 2fa4b0761b
8 changed files with 98 additions and 81 deletions

View File

@@ -23,31 +23,29 @@ uint16_t get_word(uint8_t address, uint8_t reg) {
return (data[1] << 8) | data[0];
}
char* INA233::print_device_number() {
char data[6];
int16_t rawVoltage;
String INA233::print_device_number() {
char data[7]; // Array size includes space for the null terminator
// Request data from the PMBus device
Wire.beginTransmission(INA233::_address);
Wire.write(0x9A);
Wire.write(0x9A); // Command to read the manufacturer ID
Wire.endTransmission();
Wire.requestFrom(INA233::_address, 6);
Wire.requestFrom(INA233::_address, 7);
if (Wire.available() == 6) {
if (Wire.available() == 7) {
uint8_t i = Wire.read();
data[0] = Wire.read();
data[1] = Wire.read();
data[2] = Wire.read();
data[3] = Wire.read();
data[4] = Wire.read();
data[5] = Wire.read();
data[6] = '\0'; // Null-terminate the string
} else {
// return 0 on error
data[0] = '\0';
return data;
return String("");
}
// Combine the two bytes into a single 16-bit value
return data;
return String(data);
}

View File

@@ -32,7 +32,7 @@ enum ConversionTime {
class INA233{
public:
char* print_device_number();
String print_device_number();
INA233(uint8_t addr, TwoWire* wire = &Wire);
bool begin(const uint8_t sda, const uint8_t scl);