Skip to content

Commit

Permalink
Some tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
GOB52 committed Oct 16, 2024
1 parent ce2aaf4 commit 926437d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/unit/unit_KmeterISO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ bool UnitKmeterISO::changeI2CAddress(const uint8_t i2c_address)
bool done{};
auto timeout_at = m5::utility::millis() + 1000;
do {
done = readRegister8(I2C_ADDRESS_REG, v, 0) && v == i2c_address;
m5::utility::delay(1);
done = readRegister8(I2C_ADDRESS_REG, v, 0) && v == i2c_address;
} while (!done && m5::utility::millis() <= timeout_at);
return done;
}
Expand Down
3 changes: 0 additions & 3 deletions test/embedded/avmeter_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
/*
UnitTest for UnitADS111x
*/

// Move to each libarry

#include <gtest/gtest.h>
#include <Wire.h>
#include <M5Unified.h>
Expand Down
8 changes: 8 additions & 0 deletions test/embedded/test_kmeterISO/kmeterISO_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ TEST_P(TestKmeterISO, I2CAddress)
EXPECT_TRUE(unit->changeI2CAddress(0x08));
EXPECT_TRUE(unit->readI2CAddress(addr));
EXPECT_EQ(addr, 0x08);
EXPECT_EQ(unit->address(), 0x08);

EXPECT_TRUE(unit->readFirmwareVersion(ver));
EXPECT_NE(ver, 0x00);
EXPECT_TRUE(unit->measureSingleshot(d));
Expand All @@ -156,6 +158,8 @@ TEST_P(TestKmeterISO, I2CAddress)
EXPECT_TRUE(unit->changeI2CAddress(0x77));
EXPECT_TRUE(unit->readI2CAddress(addr));
EXPECT_EQ(addr, 0x77);
EXPECT_EQ(unit->address(), 0x77);

EXPECT_TRUE(unit->readFirmwareVersion(ver));
EXPECT_NE(ver, 0x00);
EXPECT_TRUE(unit->measureSingleshot(d));
Expand All @@ -164,6 +168,8 @@ TEST_P(TestKmeterISO, I2CAddress)
EXPECT_TRUE(unit->changeI2CAddress(0x52));
EXPECT_TRUE(unit->readI2CAddress(addr));
EXPECT_EQ(addr, 0x52);
EXPECT_EQ(unit->address(), 0528);

EXPECT_TRUE(unit->readFirmwareVersion(ver));
EXPECT_NE(ver, 0x00);
EXPECT_TRUE(unit->measureSingleshot(d));
Expand All @@ -172,6 +178,8 @@ TEST_P(TestKmeterISO, I2CAddress)
EXPECT_TRUE(unit->changeI2CAddress(UnitKmeterISO::DEFAULT_ADDRESS));
EXPECT_TRUE(unit->readI2CAddress(addr));
EXPECT_EQ(addr, +UnitKmeterISO::DEFAULT_ADDRESS);
EXPECT_EQ(unit->address(), +UnitKmeterISO::DEFAULT_ADDRESS);

EXPECT_TRUE(unit->readFirmwareVersion(ver));
EXPECT_NE(ver, 0x00);
EXPECT_TRUE(unit->measureSingleshot(d));
Expand Down

0 comments on commit 926437d

Please sign in to comment.