GroveIRDistanceInterrupter::GroveIRDistanceInterrupter(int pin)
{
    this->io = (IO_T *)malloc(sizeof(IO_T));

    suli_pin_init(io, pin, SULI_INPUT);
    
    suli_pin_attach_interrupt_handler(io, &approach_interrupt_handler, SULI_FALL, this);
}
Exemple #2
0
EVENT_T * GroveExample::attach_event_reporter_for_fire(CALLBACK_T reporter)
{
    this->event1 = (EVENT_T *)malloc(sizeof(EVENT_T));

    suli_event_init(event1, reporter, NULL);

    suli_pin_attach_interrupt_handler(pin, &pin_interrupt_handler, SULI_RISE, this);

    return this->event1;
}
bool GroveIRDistanceInterrupter::attach_event_reporter(CALLBACK_T reporter)
{
    this->event = (EVENT_T *)malloc(sizeof(EVENT_T));

    suli_event_init(event, reporter);

    suli_pin_attach_interrupt_handler(io, &approach_interrupt_handler, SULI_FALL, this);

    return true;
}
bool GroveMagneticSwitch::attach_event_reporter(CALLBACK_T reporter)
{
    this->event = (EVENT_T *)malloc(sizeof(EVENT_T));

    suli_event_init(event, reporter);

    suli_pin_attach_interrupt_handler(io, &mag_approach_interrupt_handler, SULI_RISE, this);

    return true;
}
bool GroveButton::attach_event_reporter(CALLBACK_T reporter)
{
    this->event = (EVENT_T *)malloc(sizeof(EVENT_T));

    suli_event_init(event, reporter);

    suli_pin_attach_interrupt_handler(io, &button_interrupt_handler, SULI_RISE, this);

    return true;
}
GroveExample::GroveExample(int pin)
{
    this->io = (IO_T *)malloc(sizeof(IO_T));
    this->timer = (TIMER_T *)malloc(sizeof(TIMER_T));
    this->timer1 = (TIMER_T *)malloc(sizeof(TIMER_T));
    this->debug_serial = suli_get_debug_serial();

    //suli_i2c_init(i2c, pinsda, pinscl);
    suli_pin_init(io, pin, SULI_INPUT);

    suli_timer_install(timer,  1000000, timer_handler, this, true);
    suli_timer_install(timer1, 1500000, timer1_handler, this, true);

    suli_pin_attach_interrupt_handler(io, &pin_interrupt_handler, SULI_RISE, this);

    on_power_on();

}