ESPHome 2026.8.2
Loading...
Searching...
No Matches
pvvx_display.h
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef USE_ESP32
6
11
12#include <cinttypes>
13
14#include <esp_gattc_api.h>
15#ifdef USE_TIME
17#endif
18
20
21class PVVXDisplay;
22
34
36
38 public:
39 void set_writer(pvvx_writer_t &&writer) { this->writer_ = writer; }
40 void set_auto_clear(bool auto_clear_enabled) { this->auto_clear_enabled_ = auto_clear_enabled; }
42
43 void dump_config() override;
44
45 void update() override;
46
47 void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
48 esp_ble_gattc_cb_param_t *param) override;
49 void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override;
50
52 void set_validity_period(uint16_t validity_period) { this->validity_period_ = validity_period; }
54 void clear() {
55 this->bignum_ = 0;
56 this->smallnum_ = 0;
57 this->cfg_ = 0;
58 }
65 void print_bignum(float bignum) { this->bignum_ = static_cast<int16_t>(bignum * 10); }
71 void print_smallnum(float smallnum) { this->smallnum_ = static_cast<int16_t>(smallnum); }
90 void print_happy(bool happy = true) { this->setcfgbit_(0, happy); }
92 void print_sad(bool sad = true) { this->setcfgbit_(1, sad); }
94 void print_bracket(bool bracket = true) { this->setcfgbit_(2, bracket); }
96 void print_percent(bool percent = true) { this->setcfgbit_(3, percent); }
98 void print_battery(bool battery = true) { this->setcfgbit_(4, battery); }
100 void print_unit(UNIT unit) { this->cfg_ = (this->cfg_ & 0x1F) | ((unit & 0x7) << 5); }
101
102 void display();
103
104#ifdef USE_TIME
105 void set_time(time::RealTimeClock *time) { this->time_ = time; };
106#endif
107
108 protected:
111 uint16_t validity_period_ = 300;
112 int16_t bignum_ = 0;
113 int16_t smallnum_ = 0;
114 uint8_t cfg_ = 0;
115
116 void setcfgbit_(uint8_t bit, bool value);
117 void send_to_setup_char_(uint8_t *blk, size_t size);
118 void delayed_disconnect_();
120#ifdef USE_TIME
121 void sync_time_();
123#endif
124 uint16_t char_handle_ = 0;
126
128 ble_device_base::ESPBTUUID::from_raw("00001f10-0000-1000-8000-00805f9b34fb");
130
132};
133
134} // namespace esphome::pvvx_mithermometer
135
136#endif // USE_ESP32
This class simplifies creating components that periodically check a state.
Definition component.h:510
static ESPBTUUID from_raw(const uint8_t *data)
Construct from raw 16-byte little-endian UUID.
void send_to_setup_char_(uint8_t *blk, size_t size)
ble_device_base::ESPBTUUID char_uuid_
void print_bignum(float bignum)
Print the big number.
void print_bracket(bool bracket=true)
Print round brackets around the face.
void setcfgbit_(uint8_t bit, bool value)
void print_battery(bool battery=true)
Print battery sign.
void set_time(time::RealTimeClock *time)
void set_validity_period(uint16_t validity_period)
Set validity period of the display information in seconds (1..65535)
void set_auto_clear(bool auto_clear_enabled)
void print_smallnum(float smallnum)
Print the small number.
void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
ble_device_base::ESPBTUUID service_uuid_
void print_happy(bool happy=true)
Print a happy face.
void set_writer(pvvx_writer_t &&writer)
void print_percent(bool percent=true)
Print percent sign at small number.
void print_sad(bool sad=true)
Print a sad face.
void print_unit(UNIT unit)
Print unit of big number.
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock.
UNIT
Possible units for the big number.
@ UNIT_NONE
do not show a unit
uint16_t size
Definition helpers.cpp:25
static void uint32_t