IR Recieve
This commit is contained in:
parent
a9cde5ac54
commit
23a2f243c9
8 changed files with 215 additions and 3 deletions
39
ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/IRBlaster.cpp
Normal file
39
ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/IRBlaster.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include <IRBlaster.hpp>
|
||||
|
||||
void IRBlaster::send(uint16_t *data, size_t size)
|
||||
{
|
||||
rmt_item32_t *items = new rmt_item32_t[size];
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
items[i].duration0 = data[i] * 10;
|
||||
items[i].level0 = 1;
|
||||
items[i].duration1 = data[i] * 10;
|
||||
items[i].level1 = 0;
|
||||
}
|
||||
ESP_ERROR_CHECK(rmt_write_items(channel, items, size, true));
|
||||
delete[] items;
|
||||
}
|
||||
|
||||
IRBlaster::IRBlaster(uint8_t pin, rmt_channel_t channel)
|
||||
{
|
||||
this->channel = channel;
|
||||
rmt_config_t config;
|
||||
config.rmt_mode = RMT_MODE_TX;
|
||||
config.channel = channel;
|
||||
config.gpio_num = gpio_num_t(pin);
|
||||
config.mem_block_num = 1;
|
||||
config.tx_config.loop_en = false;
|
||||
config.tx_config.carrier_en = false;
|
||||
config.tx_config.idle_output_en = true;
|
||||
config.tx_config.idle_level = RMT_IDLE_LEVEL_LOW;
|
||||
config.tx_config.carrier_freq_hz = 38000;
|
||||
config.tx_config.carrier_level = RMT_CARRIER_LEVEL_HIGH;
|
||||
config.clk_div = 80;
|
||||
ESP_ERROR_CHECK(rmt_config(&config));
|
||||
ESP_ERROR_CHECK(rmt_driver_install(channel, 0, 0));
|
||||
}
|
||||
|
||||
IRBlaster::IRBlaster(uint8_t pin)
|
||||
{
|
||||
IRBlaster(pin, RMT_CHANNEL_0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue