mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 11:44:13 +01:00
a718ac7ee0
Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>
34 lines
731 B
C++
34 lines
731 B
C++
#pragma once
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/core/color.h"
|
|
|
|
#include <cstdint>
|
|
|
|
#include "qrcodegen.h"
|
|
|
|
namespace esphome {
|
|
// forward declare DisplayBuffer
|
|
namespace display {
|
|
class DisplayBuffer;
|
|
} // namespace display
|
|
|
|
namespace qr_code {
|
|
class QrCode : public Component {
|
|
public:
|
|
void draw(display::DisplayBuffer *buff, uint16_t x_offset, uint16_t y_offset, Color color, int scale);
|
|
|
|
void dump_config() override;
|
|
|
|
void set_value(const std::string &value);
|
|
void set_ecc(qrcodegen_Ecc ecc);
|
|
|
|
void generate_qr_code();
|
|
|
|
protected:
|
|
std::string value_;
|
|
qrcodegen_Ecc ecc_;
|
|
bool needs_update_ = true;
|
|
uint8_t qr_[qrcodegen_BUFFER_LEN_MAX];
|
|
};
|
|
} // namespace qr_code
|
|
} // namespace esphome
|