Skip to content

Commit

Permalink
add example, removed led
Browse files Browse the repository at this point in the history
  • Loading branch information
aanban committed Oct 2, 2023
1 parent 885cced commit dd2caa9
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
29 changes: 29 additions & 0 deletions examples/esp32_beo4_app/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

;##### Serial Port Settings #####
monitor_filters = esp32_exception_decoder, time
monitor_speed = 115200
;monitor_port = COM4

;##### Upload-Port-Settings #####
upload_speed = 921600
;upload_port = COM4

;##### In-Circuit-Debug-Settings #####
debug_tool = esp-prog
debug_init_break = tbreak setup

;##### Build parameters #####
build_flags =
;-DBOARD_HAS_PSRAM
;-mfix-esp32-psram-cache-issue
;-DCORE_DEBUG_LEVEL=5

;##### additional Libs #####
lib_deps =
https://github.com/aanban/esp32_beo4
;

38 changes: 38 additions & 0 deletions examples/esp32_beo4_app/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <Arduino.h>
#include "IrBeo4.h"

#define IR_RX_PIN 34 // IR receive pin
IrBeo4 beo4(IR_RX_PIN); // instance

// solution with task and queue
//
xQueueHandle beo4_rx_queue; // queue
TaskHandle_t beo4_task_h; // task handle

void beo4_task(void *parameter) {
static uint32_t beo4Code=0;
while(1) {
if(pdTRUE==xQueueReceive(beo4_rx_queue,(void*)(&beo4Code),portMAX_DELAY)) {
Serial.printf("beo4_task: %04x %s %s\n",beo4Code,beo_src_tbl(beo4Code),beo_cmd_tbl(beo4Code));
}
}
}


// alternative solution with callback function
//
void beo_code_cb(uint32_t beo_code) {
Serial.printf("beo_code_cb: %04x %s %s \n", beo_code,beo_src_tbl(beo_code),beo_cmd_tbl(beo_code));
}

void setup() {
Serial.begin(115200);
beo4_rx_queue = xQueueCreate(50, sizeof(uint32_t));
xTaskCreatePinnedToCore(beo4_task,"beo4_task",10000,NULL,0,&beo4_task_h,0);
beo4.Begin(beo4_rx_queue);
printf("beo4 started, RX=%d\n",IR_RX_PIN);
}

void loop() {
}

3 changes: 0 additions & 3 deletions src/IrBeo4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,10 @@ void beo4_rx_task(void *param) {
// - log-message
// - set state=FSM_IDLE
// - set timeout=infinite
// - turn LED off
#define RESET_FSM(a){ \
log_i("%s: t=%lld fsm=%d pc=%d \n",a,tsNew,fsm,pCode); \
wait=WAIT_Infinite; \
fsm=FSM_IDLE; \
if(beo_led_cb) beo_led_cb(HIGH); \
continue; \
}

Expand All @@ -149,7 +147,6 @@ void beo4_rx_task(void *param) {
bitCnt=0; // reset bit counter
tsSta=tsNew; // mark start of frame
fsm=FSM_S0; // enter start sequence
if(beo_led_cb) beo_led_cb(LOW); // indicate active frame with LED
break;
}
case FSM_S0: {
Expand Down
3 changes: 0 additions & 3 deletions src/IrBeo4.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

// external call back functions
extern __attribute__((weak)) void beo_code_cb(uint32_t beo_code);
extern __attribute__((weak)) void beo_led_cb(int8_t mode);

// interupt-serice-routine
// trigger on rising edge of IR signal, get timestamp and send to q_irs_queue
Expand Down Expand Up @@ -129,7 +128,6 @@ class IrBeo4 {
int8_t m_ir_rx_pin = -1; // IR receive pin
int8_t m_ir_tx_pin = -1; // IR transmit pin
int8_t m_ir_tx_pwm = -1; // IR transmit pwm channel
int8_t m_led_pin = -1; // LED pin
QueueHandle_t m_beo4_rx_queue; // output queue for received beoCodes
QueueHandle_t m_beo4_tx_queue; // input queue for beoCodes to be send
esp_timer_handle_t m_OneShotTimer_h; // ont-shot-timer handle
Expand Down Expand Up @@ -157,7 +155,6 @@ class IrBeo4 {
// @param rx_pin = IR receiver input pin
// @param tx_pin = IR transmit output pin (default=-1, not used)
// @param tx_pwm = IR transmit pwm-channel (default=-1, not used)
// @param led_pin = LED indicator pin (default=-1, not used)
IrBeo4(int8_t rx_pin,int8_t tx_pin=-1, int8_t tx_pwm=-1);

// destructor
Expand Down

0 comments on commit dd2caa9

Please sign in to comment.