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();

}
GroveGesture::GroveGesture(int pinsda, int pinscl)
{
    this->i2c = (I2C_T *)malloc(sizeof(I2C_T));
    suli_i2c_init(i2c, pinsda, pinscl);
    this->timer = (TIMER_T *)malloc(sizeof(TIMER_T));

    isWaken = false;
    new_data_available = false;
    cur_motion = last_motion = 255;

    suli_timer_install(timer, 1000000, grove_guesture_timer_interrupt_handler, this, true);
}