#ifndef IO_H
#define IO_H

#include <pico/types.h>
#include "ssd1306.h"
#include "gyro.h"

#define I2C_MASTER_SDA_PIN 21
#define I2C_MASTER_SCL_PIN 20
#define I2C_MASTER_INSTANCE i2c0

#define PIN_TIRETTE 5
#define PIN_BUTTON_COLOR 6
#define PIN_MOTOR1 1
#define PIN_MOTOR2 2
#define PIN_SERVO 7

#define DANCING_ACTION_DELTA_ANGLE 2

#define GAIN_KD 50
#define ANGULAR_SPEED 120

typedef struct io_t {
    double delta_time_ms;

    bool motion_control_activated;
    bool is_tirette_pulled;
    bool is_color_blue;
    bool is_dancing;

    ssd1306_t *screen;

    gyro_data_t gyro_data;

    float target_dir;
    float target_speed;

    double time_ms;
} io_t;

extern io_t io;

void motor_control_activated(bool activated);

void init_io(void);

void update_io(void);

void set_dir_with_angular_speed(float dir);

void io_deinit(void);

#endif // IO_H