 /* Copyright (c) 2017 pcbreflux. All Rights Reserved.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
 */

#ifndef ESP32_IR_REMOTE_H_
#define ESP32_IR_REMOTE_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include "esp32-hal.h"
#include "esp_intr.h"
#include "driver/gpio.h"
#include "driver/rmt.h"
#include "driver/periph_ctrl.h"
#include "freertos/semphr.h"
#include "soc/rmt_struct.h"
#include "stdio.h"
#include "string.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "esp_err.h"
#include "esp_log.h"
#include "driver/rmt.h"
#include "driver/periph_ctrl.h"
#include "soc/rmt_reg.h"
//#include "soc/rmt_struct.h"

#ifdef __cplusplus
}
#endif

   // void init(); // Inits the RMT periphiral
    uint8_t readIR();  // Reads the data from the recvpin



    extern int gpionum;
   extern int rmtport;
    void dumpStatus(rmt_channel_t channel); //Used for debugging It prints all the data
    bool isInRange(rmt_item32_t item, int lowDuration, int highDuration, int tolerance); //Checks wether the data is in correct range or not
    bool NEC_is0(rmt_item32_t item); // checks wether the data is o
    bool NEC_is1(rmt_item32_t item); // checks wether the data is 1
    uint8_t decodeNEC(rmt_item32_t *data, int numItems); // Decodes the NEC signal
    


#endif /* ESP32_IR_REMOTE_H_ */
