Github Repo | C Header | C source | JS source |
---|---|---|---|
mongoose-os-libs/ir | mgos_ir.h | api_ir.js |
Either
#include "mgos.h"
#include "mgos_ir.h"
static void irrecv_cb(int code, void *arg)
{
LOG(LL_INFO, ("IR: %08X", code));
(void) arg;
}
enum mgos_app_init_result mgos_app_init(void)
{
// TSOP on pin 14, NEC protocol
mgos_irrecv_nec_create(14, irrecv_cb, NULL);
return MGOS_APP_INIT_SUCCESS;
}
or
load("api_ir.js");
// TSOP on pin 14, NEC protocol
let ir = IR.Receiver.NEC.create(14, function(code) {
print("IR", code);
}, null);
struct mgos_irrecv_nec_s *mgos_irrecv_nec_create(
int pin,
void (*cb)(int, void *),
void *userdata
);
Create an object instance of IR receiver for NEC protocol. Return value: an object with the methods described below.
void mgos_irrecv_nec_close(struct mgos_irrecv_nec_s *obj);
Destroy an object instance of IR receiver for NEC protocol.
void mgos_irsend_nec(int pin, int code, bool tsop);
Send IR code for NEC protocol. Params: pin: GPIO number. code: 32-bit code. tsop: mode: true - mimic TSOP signal, false - drive real IR led at 38 kHz.
IR.Receiver.NEC.create(pin, callback, userdata)
Create an object instance of IR receiver for NEC protocol. Return value: an object with the methods described below.
myIR.close()
Close receiver handle. Return value: none.
IR.Sender.NEC.pwm(pin, code)
Send NEC IR code via real IR led. Return value: none.
IR.Sender.NEC.tsop(pin, code)
Mimic TSOP receiver: drive a pin as if it would be connected to a TSOP receiver. Return value: none.
edit this doc