/** 
 * @file    event.h
 * @brief   Event module
 * @author  Kenny Tran
 * @date    Nov 19 2024
 * @version 0.0.1
 *
 * @section LICENSES
 * Copyright (C) Morgan Advanced Programmable Systems, Inc.
 */


#ifndef EVENT_H_
#define EVENT_H_


/*--------------------------------------------------------------------------------------------------
 * INCLUDE FILES
 *------------------------------------------------------------------------------------------------*/
#include <stdint.h>
#include <stdbool.h>


/*--------------------------------------------------------------------------------------------------
 * MACROS & CONSTANTS
 *------------------------------------------------------------------------------------------------*/
#define EVENT_TASK_PERIOD_MS            (100)
#define EVENT_STACK_SIZE                (1024)
#define EVENT_THREAD_PRIORITY           (7)

#define EVENT_SHORT_HOLD_PERIOD_MS      (750)
#define EVENT_LONG_HOLD_PERIOD_MS       (3000)
#define EVENT_FACTORY_RESET_PERIOD_MS   (10000)

#define EVENT_CALIBRATION_PERIOD_MS     (10000)


/*--------------------------------------------------------------------------------------------------
 * TYPE DEFINITIONS & ENUMERATIONS
 *------------------------------------------------------------------------------------------------*/
typedef enum EVENT
{
    EVENT_NONE = 0,
    EVENT_CHARGER_CONNECTED,
    EVENT_CHARGER_DISCONNECTED,
    EVENT_BATTERY_FULL,
    EVENT_ACCEL_MOTION,
    EVENT_GYRO_MOTION,
    EVENT_POWER,
    EVENT_DECREASE_PIN_BRIGHTNESS,
    EVENT_INCREASE_PIN_BRIGHTNESS,
    EVENT_DECREASE_RING_BRIGHTNESS,
    EVENT_INCREASE_RING_BRIGHTNESS,
    EVENT_CONFIG_ENTER,
    EVENT_SUBCONFIG_PREV,
    EVENT_SUBCONFIG_MODE_CHANGE,
    EVENT_SUBCONFIG_NEXT,
    EVENT_CONFIG_EXIT,
    EVENT_AUTO_BRIGHTNESS,
    EVENT_BLE_ENABLE,
    EVENT_BLE_DISABLE,
    EVENT_BLE_CONNECTED,
    EVENT_BLE_DISCONNECTED,
    EVENT_FACTORY_RESET,
    EVENT_SUBCAL_START,
    EVENT_SUBCAL_NEXT,
    EVENT_SHOT_DETECTED,
} EVENT_e;


/*--------------------------------------------------------------------------------------------------
 * PUBLIC FUNCTION PROTOTYPES
 *------------------------------------------------------------------------------------------------*/
void EVENT_init (void);

void EVENT_reset (void);

bool EVENT_in_process (void);

EVENT_e EVENT_last_get (void);

void EVENT_force (EVENT_e event);

void EVENT_task_suspend (void);

void EVENT_task_resume (void);

void EVENT_task_install (void);

void EVENT_cli_cmd (int32_t argc, char **argv);

#endif /* EVENT_H_ */
