1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-17 10:42:21 +01:00

Add get_size method to QR Code header (#6430)

This commit is contained in:
Daniel Eisterhold
2024-03-27 18:56:26 -05:00
committed by GitHub
parent 0ff543ffe5
commit 9194f7eb27
8 changed files with 56 additions and 0 deletions

View File

@@ -51,5 +51,17 @@ void QrCode::draw(display::Display *buff, uint16_t x_offset, uint16_t y_offset,
}
}
}
uint8_t QrCode::get_size() {
if (this->needs_update_) {
this->generate_qr_code();
this->needs_update_ = false;
}
uint8_t size = qrcodegen_getSize(this->qr_);
return size;
}
} // namespace qr_code
} // namespace esphome

View File

@@ -24,6 +24,8 @@ class QrCode : public Component {
void generate_qr_code();
uint8_t get_size();
protected:
std::string value_;
qrcodegen_Ecc ecc_;