#ifndef TEST_AND_DEBUG_H_
#define TEST_AND_DEBUG_H_

#include "oled_control.h"

#ifdef USE_MONITOR_TASK
#define TASK_MONITOR_STACK_SIZE				(2048/sizeof(portSTACK_TYPE))
#define TASK_MONITOR_STACK_PRIORITY			(tskIDLE_PRIORITY)
#endif

#define TASK_I2C_STACK_SIZE					(512/sizeof(portSTACK_TYPE))
#define TASK_I2C_PRIORITY					(configMAX_PRIORITIES - 2) // just less than USB audio
#define TASK_TIMED_STARTUP_STACK_SIZE		(512/sizeof(portSTACK_TYPE))
#define TASK_TIMED_STARTUP_PRIORITY			(tskIDLE_PRIORITY)
#define TASK_ADC_STACK_SIZE					(512/sizeof(portSTACK_TYPE))
#define TASK_ADC_PRIORITY					(tskIDLE_PRIORITY)
#define TASK_LED_STACK_SIZE					(512/sizeof(portSTACK_TYPE))
#define TASK_LED_PRIORITY					(tskIDLE_PRIORITY)
#define TASK_FAN_STACK_SIZE					(512/sizeof(portSTACK_TYPE))
#define TASK_FAN_PRIORITY					(tskIDLE_PRIORITY)

#define LED_UPDATE_DELAY		(50) // LED runs at 50ms (20Hz)
#define	LED_TASK_CODE_LED_INIT		(0x01)
#define LED_TASK_CODE_MODE_MASK		(0x0E) // Bit 0 is init, bits 3:1 are mode
#define LED_TASK_CODE_STATIC_COLOR	(0x02)
#define LED_TASK_CODE_BREATHING		(0x04)

#define FAN_UPDATE_DELAY		(10) // Fan updates PWM at 100Hz
#define FAN_TASK_CODE_NEW_SPEED		(0x100) // Lowest byte is the new speed
#define FAN_TASK_CODE_STOP			(0x200)

#define PROX_DISTANCE_DELAY		(10) // Delay between checking the proximity sensor.
#define OLED_TEMP_DELAY			(100) // Delay between checking OLED temperature
#define PROX_CONNECT_CHECK_DELAY	(1000) // Delay between checking if prox sensor is there when it wasn't detected before
#define POWER_TIMER_GRANULARITY	(10000) // Power timer is checked repeatedly after this delay
#define TEN_MIN_IN_TEN_SEC_INTERVALS	(60u) // number of 10sec ticks to hit 10min
#define ONE_MIN_IN_TEN_SEC_INTERVALS	(6u)  // number of 10sec ticks to hit 1min

#define PANEL_INIT_TO_STARTUP_DELAY		(500) // Delay after video mode entered before initializing panels

#define OLED_ZERO_TEMP			(71) // Approximately zero degC.

typedef enum {
	I2C_CTRL_NONE,
	I2C_CTRL_OLED_FLIP,
	I2C_CTRL_OLED_UNFLIP,
	I2C_CTRL_OLED_DISPOFF,
	I2C_CTRL_OLED_DISPON,
	I2C_CTRL_OLED_BRIGHTNESS,
	I2C_CTRL_OLED_CMD,
	I2C_CTRL_RGB_COLOR,
	I2C_CTRL_SAVE_SIG,
	I2C_CTRL_PROX_SETTINGS
} I2C_Control_T;

void start_test_tasks(void);
//void queue_prox_settings(Prox_Settings* proxset);
bool send_code_to_i2c_task_fromISR(I2C_Control_T code);
TaskHandle_t get_fan_task_handle(void);
TaskHandle_t get_led_task_handle(void);

// Callback for ASF at pin change interrupt
void scl_pin_irq_handler(uint32_t port_id, uint32_t pin);

// Call this to set the direct OLED command data before sending a notification to the task
void set_oled_command_data(uint8_t datalen, OLED_Panel_T left_or_right, uint8_t* data);

#endif /* TEST_AND_DEBUG_H_ */
