#ifndef __CONFIGMACROS_H
#define __CONFIGMACROS_H



#include "oled.h"


#define open16			11	//开字
#define close16			12	//关字
#define resetDevAddr					((uint32_t)0x8075000)  
#define DevstatusAddr					((uint32_t)0x8075800)  


#define Sn1Addr							((uint32_t)0x8076000)  
#define Sn2Addr							((uint32_t)0x8076800)  
#define Sn3Addr							((uint32_t)0x8077700)  
#define Sn4Addr							((uint32_t)0x8077800)  

#define Sn1StatusAddr					((uint32_t)0x8078000)  
#define Sn2StatusAddr					((uint32_t)0x8078800)  
#define Sn3StatusAddr					((uint32_t)0x8079000)  
#define Sn4StatusAddr					((uint32_t)0x8079800)  


#define TIM_Start(htim) 				HAL_TIM_Base_Start_IT(htim)
#define LED_TOGGLE(pin)       			HAL_GPIO_TogglePin(GPIOC, (pin))		//运行灯
#define RXNE_UART(huart) 				__HAL_UART_ENABLE_IT(huart, UART_IT_RXNE)	


#define PRINT_MENU_STATUS(key)  		printf("--->%s pressed\t%d   %d   %x   %d\n", key, menu.current, menu.up, (menu.next&0xf), menu.enter)
#define HELLO(message) 					printf("%s\r\n", message)
#define PRINT_UUID(message) 			printf("#%s符合设置项\n",message)
#define PRINT_NUUID(message) 			printf("%s不符合\n",message)
#define PRINT_BTRESP(message) 			printf("%s错误\n",message)

/* WDI */
#define TOGGLE_WDI_PIN(htim_instance) \
do { \
    if ((htim_instance)->Instance == TIM2) { \
        HAL_GPIO_TogglePin(WDI_GPIO_Port, WDI_Pin); \
    } \
} while(0)



/* OLED显示 */
#define OLED_DISPLAY(color, display) do { \
    OLED_Init(); \
    OLED_ColorTurn(color); \
    OLED_DisplayTurn(display);  \
} while(0)


/* U1-U4 DMA */
#define IDLE_DMA_UART(huart) \
do {\
	__HAL_UART_ENABLE_IT(huart, UART_IT_IDLE); \
	HAL_UART_Receive_DMA(huart, recvBuff, 2048); \
} while(0)


/* 4G参数初始化*/	
#define INIT_4G_FRAME() \
do { \
	printf("\t###02\t4G_init%d...\r\n",resetcount_4g); \
} while (0)


#define SET_MENU_STATUS(current_value, up_value, next_value, enter_value) \
do { \
    menu.current = current_value; \
    menu.up = up_value; \
    menu.next = next_value; \
    menu.enter = enter_value; \
	refresh = true;\
} while(0)




typedef struct
{
    uint8_t current;		//当前状态索引号
    uint8_t up; 			//向下一个
    uint8_t next; 			//向下一个
    uint8_t enter; 	    	//确定
	uint32_t home;
	char* SN1;
	char* SN1F;
	char* SN1D;
	char* SN1name;
	char* SN2;
	char* SN2F;
	char* SN2D;
	char* SN2name;
	char* SN3;
	char* SN3F;
	char* SN3D;
	char* SN3name;
	char* SN4;
	char* SN4F;
	char* SN4D;
	char* SN4name;
	uint8_t PreNext;
} Menu_table;

struct keys
{
	unsigned char judge_sta;	//判断按键按键按下的动作到了第几步
	bool key_sta;				//如果按键被按下，为0
	bool key_flag;				//如果确认被按下，为1
	bool long_flag;				//如果确认被按下，为1
	uint8_t key_time;
};

typedef struct
{
    uint32_t serialNum1;	//4字节流水号
    uint32_t serialNum2;	//4字节流水号
    uint32_t serialNum3;	//4字节流水号
    uint32_t serialNum4;	//4字节流水号
	uint32_t userId;	//4字节userid
	uint32_t Ntime;		//4字节时间
	uint8_t	 Autoseal;	//1字节自动施封
	
} BtFrame;

typedef enum {
	BtStepDefault = 0,
    UUIDS = 1,
    UUIDN = 2,
    UUIDW = 3,
} BtStep;


typedef enum {
    Default = 0,
    InProgress = 1,
	Abnormal_motor = 2,
	Starting = 3 ,
	Nosnset = 4 ,
	Carfail = 5
} TipsFlag;





#endif /*__CONFIGMACROS_H*/

