Skip to content

Commit

Permalink
Rename register
Browse files Browse the repository at this point in the history
  • Loading branch information
sebromero committed Jun 12, 2024
1 parent 239a522 commit 0b2d8aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/OrangeLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ OrangeLED::OrangeLED(uint8_t deviceAddress) : I2CDevice(deviceAddress) {}

uint8_t OrangeLED::brightness() {
// Read bits 0 - 5 from orange_led register
uint8_t data = readFromRegister<uint8_t>(WHITE_LED_REGISTER_INFO);
uint8_t data = readFromRegister<uint8_t>(ORANGE_LED_REGISTER_INFO);
return data & 63;
}

Expand All @@ -15,19 +15,19 @@ void OrangeLED::setBrightness(uint8_t brightness) {
return; // Invalid brightness value
}

uint8_t currentRegisterData = readFromRegister<uint8_t>(WHITE_LED_REGISTER_INFO);
uint8_t currentRegisterData = readFromRegister<uint8_t>(ORANGE_LED_REGISTER_INFO);
// Overwrite bits 0 - 5 with the new value
writeToRegister<uint8_t>(WHITE_LED_REGISTER_INFO, (currentRegisterData & ~63) | brightness);
writeToRegister<uint8_t>(ORANGE_LED_REGISTER_INFO, (currentRegisterData & ~63) | brightness);
}

bool OrangeLED::errorStatusEnabled() {
// Read bit 7 from orange_led register
uint8_t data = readFromRegister<uint8_t>(WHITE_LED_REGISTER_INFO);
uint8_t data = readFromRegister<uint8_t>(ORANGE_LED_REGISTER_INFO);
return data & (1 << 7);
}

void OrangeLED::setErrorStatusEnabled(bool enabled) {
uint8_t currentRegisterData = readFromRegister<uint8_t>(WHITE_LED_REGISTER_INFO);
uint8_t currentRegisterData = readFromRegister<uint8_t>(ORANGE_LED_REGISTER_INFO);
// Set bit 7 to 1 if enabled or 0 if disabled while keeping the other bits unchanged
writeToRegister<uint8_t>(WHITE_LED_REGISTER_INFO, (currentRegisterData & ~(1 << 7)) | (enabled << 7));
writeToRegister<uint8_t>(ORANGE_LED_REGISTER_INFO, (currentRegisterData & ~(1 << 7)) | (enabled << 7));
}
2 changes: 1 addition & 1 deletion src/registers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct RegisterInfo {
constexpr RegisterInfo STATUS_REGISTER_INFO{0x00, "uint8", 1};
constexpr RegisterInfo SLAVE_ADDRESS_REGISTER_INFO{0x01, "uint8", 1};
constexpr RegisterInfo CONTROL_REGISTER_INFO{0x02, "uint8", 1};
constexpr RegisterInfo WHITE_LED_REGISTER_INFO{0x03, "uint8", 1};
constexpr RegisterInfo ORANGE_LED_REGISTER_INFO{0x03, "uint8", 1};
constexpr RegisterInfo RGB_LED_RED_REGISTER_INFO{0x04, "uint8", 1};
constexpr RegisterInfo GREEN_REGISTER_INFO{0x05, "uint8", 1};
constexpr RegisterInfo BLUE_REGISTER_INFO{0x06, "uint8", 1};
Expand Down

0 comments on commit 0b2d8aa

Please sign in to comment.