mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-25 07:08:30 +02:00
2c995cf145
* Change ESP32 default power_save_mode to light * Update
27 lines
633 B
C++
27 lines
633 B
C++
#pragma once
|
|
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/components/time/real_time_clock.h"
|
|
#include "esphome/components/gps/gps.h"
|
|
|
|
namespace esphome {
|
|
namespace gps {
|
|
|
|
class GPSTime : public time::RealTimeClock, public GPSListener {
|
|
public:
|
|
void on_update(TinyGPSPlus &tiny_gps) override {
|
|
if (!this->has_time_)
|
|
this->from_tiny_gps_(tiny_gps);
|
|
}
|
|
void setup() override {
|
|
this->set_interval(5 * 60 * 1000, [this]() { this->from_tiny_gps_(this->get_tiny_gps()); });
|
|
}
|
|
|
|
protected:
|
|
void from_tiny_gps_(TinyGPSPlus &tiny_gps);
|
|
bool has_time_{false};
|
|
};
|
|
|
|
} // namespace gps
|
|
} // namespace esphome
|