mirror of
https://github.com/esphome/esphome.git
synced 2024-12-25 06:54:52 +01:00
Fixed formating.
This commit is contained in:
parent
0bcd9bd153
commit
8da004362d
8 changed files with 22 additions and 27 deletions
|
@ -85,6 +85,7 @@ esphome/components/bmp581/* @kahrendt
|
|||
esphome/components/bp1658cj/* @Cossid
|
||||
esphome/components/bp5758d/* @Cossid
|
||||
esphome/components/button/* @esphome/core
|
||||
esphome/components/camera/* @DT-art1
|
||||
esphome/components/canbus/* @danielschramm @mvturnho
|
||||
esphome/components/cap1188/* @mreditor97
|
||||
esphome/components/captive_portal/* @OttoWinter
|
||||
|
|
|
@ -42,7 +42,8 @@ APIConnection::APIConnection(std::unique_ptr<socket::Socket> sock, APIServer *pa
|
|||
|
||||
#ifdef USE_CAMERA
|
||||
if (camera::Camera::global_camera != nullptr)
|
||||
this->image_reader_ = std::unique_ptr<camera::CameraImageReader>{camera::Camera::global_camera->create_image_reader()};
|
||||
this->image_reader_ =
|
||||
std::unique_ptr<camera::CameraImageReader>{camera::Camera::global_camera->create_image_reader()};
|
||||
#endif
|
||||
}
|
||||
void APIConnection::start() {
|
||||
|
@ -1074,8 +1075,7 @@ void APIConnection::send_camera_state(std::shared_ptr<camera::CameraImage> image
|
|||
return;
|
||||
if (this->image_reader_->available())
|
||||
return;
|
||||
if (image->was_requested_by(esphome::camera::API_REQUESTER) ||
|
||||
image->was_requested_by(esphome::camera::IDLE))
|
||||
if (image->was_requested_by(esphome::camera::API_REQUESTER) || image->was_requested_by(esphome::camera::IDLE))
|
||||
this->image_reader_->set_image(std::move(image));
|
||||
}
|
||||
bool APIConnection::send_camera_info(camera::Camera *camera) {
|
||||
|
@ -1099,9 +1099,8 @@ void APIConnection::camera_image(const CameraImageRequest &msg) {
|
|||
if (msg.stream) {
|
||||
camera::Camera::global_camera->start_stream(esphome::camera::API_REQUESTER);
|
||||
|
||||
App.scheduler.set_timeout(this->parent_, "api_esp32_camera_stop_stream", ESP32_CAMERA_STOP_STREAM, []() {
|
||||
camera::Camera::global_camera->stop_stream(esphome::camera::API_REQUESTER);
|
||||
});
|
||||
App.scheduler.set_timeout(this->parent_, "api_esp32_camera_stop_stream", ESP32_CAMERA_STOP_STREAM,
|
||||
[]() { camera::Camera::global_camera->stop_stream(esphome::camera::API_REQUESTER); });
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -82,13 +82,12 @@ void APIServer::setup() {
|
|||
|
||||
#ifdef USE_CAMERA
|
||||
if (camera::Camera::global_camera != nullptr && !camera::Camera::global_camera->is_internal()) {
|
||||
camera::Camera::global_camera->add_image_callback(
|
||||
[this](const std::shared_ptr<camera::CameraImage> &image) {
|
||||
for (auto &c : this->clients_) {
|
||||
if (!c->remove_)
|
||||
c->send_camera_state(image);
|
||||
}
|
||||
});
|
||||
camera::Camera::global_camera->add_image_callback([this](const std::shared_ptr<camera::CameraImage> &image) {
|
||||
for (auto &c : this->clients_) {
|
||||
if (!c->remove_)
|
||||
c->send_camera_state(image);
|
||||
}
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -51,9 +51,7 @@ bool ListEntitiesIterator::on_service(UserServiceDescriptor *service) {
|
|||
}
|
||||
|
||||
#ifdef USE_CAMERA
|
||||
bool ListEntitiesIterator::on_camera(camera::Camera *camera) {
|
||||
return this->client_->send_camera_info(camera);
|
||||
}
|
||||
bool ListEntitiesIterator::on_camera(camera::Camera *camera) { return this->client_->send_camera_info(camera); }
|
||||
#endif
|
||||
|
||||
#ifdef USE_CLIMATE
|
||||
|
|
|
@ -5,9 +5,7 @@ namespace camera {
|
|||
|
||||
Camera *Camera::global_camera = nullptr;
|
||||
|
||||
Camera::Camera() {
|
||||
global_camera = this;
|
||||
}
|
||||
Camera::Camera() { global_camera = this; }
|
||||
|
||||
} // namespace camera
|
||||
} // namespace esphome
|
||||
|
|
|
@ -60,7 +60,7 @@ class Camera : public EntityBase {
|
|||
// Camera implementation invokes callback to publish a new image.
|
||||
virtual void add_image_callback(std::function<void(std::shared_ptr<CameraImage>)> &&callback) = 0;
|
||||
/// Returns a new camera image reader that keeps track of the JPEG data in the camera image.
|
||||
virtual CameraImageReader* create_image_reader() = 0;
|
||||
virtual CameraImageReader *create_image_reader() = 0;
|
||||
// Connection, camera or web server requests one new JPEG image.
|
||||
virtual void request_image(CameraRequester requester) = 0;
|
||||
// Connection, camera or web server requests a stream of images.
|
||||
|
|
|
@ -34,7 +34,7 @@ void ESP32Camera::setup() {
|
|||
xTaskCreatePinnedToCore(&ESP32Camera::framebuffer_task,
|
||||
"framebuffer_task", // name
|
||||
1024, // stack size
|
||||
this, // task pv params
|
||||
this, // task pv params
|
||||
1, // priority
|
||||
nullptr, // handle
|
||||
1 // core
|
||||
|
@ -348,9 +348,7 @@ void ESP32Camera::add_stream_start_callback(std::function<void()> &&callback) {
|
|||
void ESP32Camera::add_stream_stop_callback(std::function<void()> &&callback) {
|
||||
this->stream_stop_callback_.add(std::move(callback));
|
||||
}
|
||||
camera::CameraImageReader* ESP32Camera::create_image_reader() {
|
||||
return new ESP32CameraImageReader;
|
||||
}
|
||||
camera::CameraImageReader *ESP32Camera::create_image_reader() { return new ESP32CameraImageReader; }
|
||||
void ESP32Camera::start_stream(camera::CameraRequester requester) {
|
||||
this->stream_start_callback_.call();
|
||||
this->stream_requesters_ |= (1U << requester);
|
||||
|
@ -388,7 +386,7 @@ void ESP32Camera::update_camera_parameters() {
|
|||
bool ESP32Camera::has_requested_image_() const { return this->single_requesters_ || this->stream_requesters_; }
|
||||
bool ESP32Camera::can_return_image_() const { return this->current_image_.use_count() == 1; }
|
||||
void ESP32Camera::framebuffer_task(void *pv) {
|
||||
ESP32Camera *that = (ESP32Camera *)pv;
|
||||
ESP32Camera *that = (ESP32Camera *) pv;
|
||||
while (true) {
|
||||
camera_fb_t *framebuffer = esp_camera_fb_get();
|
||||
xQueueSend(that->framebuffer_get_queue_, &framebuffer, portMAX_DELAY);
|
||||
|
@ -414,7 +412,8 @@ void ESP32CameraImageReader::consume_data(size_t consumed) { this->offset_ += co
|
|||
uint8_t *ESP32CameraImageReader::peek_data_buffer() { return this->image_->get_data_buffer() + this->offset_; }
|
||||
|
||||
/* ---------------- CameraImage class ---------------- */
|
||||
ESP32CameraImage::ESP32CameraImage(camera_fb_t *buffer, uint8_t requesters) : buffer_(buffer), requesters_(requesters) {}
|
||||
ESP32CameraImage::ESP32CameraImage(camera_fb_t *buffer, uint8_t requesters)
|
||||
: buffer_(buffer), requesters_(requesters) {}
|
||||
|
||||
camera_fb_t *ESP32CameraImage::get_raw_buffer() { return this->buffer_; }
|
||||
uint8_t *ESP32CameraImage::get_data_buffer() { return this->buffer_->buf; }
|
||||
|
|
|
@ -160,7 +160,8 @@ class ESP32Camera : public Component, public camera::Camera {
|
|||
void add_image_callback(std::function<void(std::shared_ptr<camera::CameraImage>)> &&callback);
|
||||
void add_stream_start_callback(std::function<void()> &&callback);
|
||||
void add_stream_stop_callback(std::function<void()> &&callback);
|
||||
camera::CameraImageReader* create_image_reader() override;
|
||||
camera::CameraImageReader *create_image_reader() override;
|
||||
|
||||
protected:
|
||||
/* internal methods */
|
||||
bool has_requested_image_() const;
|
||||
|
|
Loading…
Reference in a new issue