ESPHome
2024.4.1
esphome
esphome
components
microphone
microphone.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/entity_base.h
"
4
#include "
esphome/core/helpers.h
"
5
6
namespace
esphome
{
7
namespace
microphone {
8
9
enum
State
: uint8_t {
10
STATE_STOPPED
= 0,
11
STATE_STARTING
,
12
STATE_RUNNING
,
13
STATE_STOPPING
,
14
};
15
16
class
Microphone
{
17
public
:
18
virtual
void
start
() = 0;
19
virtual
void
stop
() = 0;
20
void
add_data_callback
(std::function<
void
(
const
std::vector<int16_t> &)> &&data_callback) {
21
this->
data_callbacks_
.add(std::move(data_callback));
22
}
23
virtual
size_t
read
(int16_t *buf,
size_t
len
) = 0;
24
25
bool
is_running
()
const
{
return
this->
state_
==
STATE_RUNNING
; }
26
bool
is_stopped
()
const
{
return
this->
state_
==
STATE_STOPPED
; }
27
28
protected
:
29
State
state_
{
STATE_STOPPED
};
30
31
CallbackManager<void(const std::vector<int16_t>
&)>
data_callbacks_
{};
32
};
33
34
}
// namespace microphone
35
}
// namespace esphome
esphome::microphone::Microphone::add_data_callback
void add_data_callback(std::function< void(const std::vector< int16_t > &)> &&data_callback)
Definition:
microphone.h:20
esphome::microphone::STATE_STOPPING
Definition:
microphone.h:13
entity_base.h
esphome::microphone::Microphone::is_running
bool is_running() const
Definition:
microphone.h:25
esphome::microphone::Microphone::state_
State state_
Definition:
microphone.h:29
esphome::microphone::Microphone
Definition:
microphone.h:16
esphome::microphone::Microphone::data_callbacks_
CallbackManager< void(const std::vector< int16_t > &)> data_callbacks_
Definition:
microphone.h:31
esphome::microphone::State
State
Definition:
microphone.h:9
esphome::microphone::STATE_STOPPED
Definition:
microphone.h:10
esphome::microphone::STATE_RUNNING
Definition:
microphone.h:12
esphome::microphone::Microphone::start
virtual void start()=0
esphome::microphone::STATE_STARTING
Definition:
microphone.h:11
esphome::CallbackManager
Definition:
helpers.h:468
esphome::microphone::Microphone::stop
virtual void stop()=0
esphome::microphone::Microphone::is_stopped
bool is_stopped() const
Definition:
microphone.h:26
esphome::microphone::Microphone::read
virtual size_t read(int16_t *buf, size_t len)=0
esphome::len
std::string size_t len
Definition:
helpers.h:292
esphome
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition:
a01nyub.cpp:7
helpers.h
Generated by
1.8.13