[dfrobot_sen0395][sx1509] Fix structural bugs (#14494)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jonathan Swoboda
2026-03-05 13:16:06 -05:00
committed by GitHub
parent 2777d35990
commit a061397469
2 changed files with 9 additions and 11 deletions
@@ -30,11 +30,9 @@ class Command {
class ReadStateCommand : public Command {
public:
ReadStateCommand() { timeout_ms_ = 500; }
uint8_t execute(DfrobotSen0395Component *parent) override;
uint8_t on_message(std::string &message) override;
protected:
uint32_t timeout_ms_{500};
};
class PowerCommand : public Command {
@@ -99,12 +97,12 @@ class ResetSystemCommand : public Command {
class SaveCfgCommand : public Command {
public:
SaveCfgCommand() { cmd_ = "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"; }
SaveCfgCommand() {
cmd_ = "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89";
cmd_duration_ms_ = 3000;
timeout_ms_ = 3500;
}
uint8_t on_message(std::string &message) override;
protected:
uint32_t cmd_duration_ms_{3000};
uint32_t timeout_ms_{3500};
};
class LedModeCommand : public Command {
+3 -3
View File
@@ -56,11 +56,11 @@ void SX1509Component::loop() {
return;
}
int row, col;
for (row = 0; row < 7; row++) {
for (row = 0; row < 8; row++) {
if (key_data & (1 << row))
break;
}
for (col = 8; col < 15; col++) {
for (col = 8; col < 16; col++) {
if (key_data & (1 << col))
break;
}
@@ -229,7 +229,7 @@ void SX1509Component::setup_keypad_() {
this->read_byte_16(REG_DIR_B, &this->ddr_mask_);
for (int i = 0; i < this->rows_; i++)
this->ddr_mask_ &= ~(1 << i);
for (int i = 8; i < (this->cols_ * 2); i++)
for (int i = 8; i < (8 + this->cols_); i++)
this->ddr_mask_ |= (1 << i);
this->write_byte_16(REG_DIR_B, this->ddr_mask_);