#ifndef __DEBUG_H__
#define __DEBUG_H__

#endif

#ifndef __BL55072A_H__
#define __BL55072A_H__

#include <stdlib.h>
#include <stdint.h>
#include "control_comm.h"

typedef enum{
	BL55072A_SET_END			=0x7F,

	BL55072A_CMD_MODESET_ON		=0xC8,
	BL55072A_CMD_MODESET_OFF	=0xC0,

	BL55072A_CMD_ADSET			=0x00,

	BL55072A_CMD_DISCTL_DEF		=0xB6,
	BL55072A_CMD_DISCTL_PSM1	=0xA4,

	BL55072A_CMD_ICSET			=0xE8,
	BL55072A_CMD_ICSET_RST		=0xEA,
	BL55072A_CMD_BLKCTL_OFF		=0x80,
	BL55072A_CMD_BLKCTL_HZ5		=0x81,
	BL55072A_CMD_BLKCTL_1HZ		=0x82,
	BL55072A_CMD_BLKCTL_2HZ		=0x83,
	BL55072A_CMD_BLKCTL_HZ3		=0x84,
	BL55072A_CMD_BLKCTL_HZ2		=0x85,

	BL55072A_CMD_APCTL_ON		=0xFE,
	BL55072A_CMD_APCTL_OFF		=0xFF,
}blCommands;

typedef enum{
	BL55072A_SEG0 = 0x00,
	BL55072A_SEG1,
	BL55072A_SEG2,
	BL55072A_SEG3,
	BL55072A_SEG4,
	BL55072A_SEG5,
	BL55072A_SEG6,
	BL55072A_SEG7,
	BL55072A_SEG8,
	BL55072A_SEG9,
	BL55072A_SEG10,
	BL55072A_SEG11,
	BL55072A_SEG12,
	BL55072A_SEG13,
	BL55072A_SEG14,
	BL55072A_SEG15,
	BL55072A_SEG16,
	BL55072A_SEG17,
	BL55072A_SEG18,
	BL55072A_SEG19,
	BL55072A_SEG20,
	BL55072A_SEG21,
	BL55072A_SEG22,
	BL55072A_SEG23,
	BL55072A_SEG24,
	BL55072A_SEG25,
	BL55072A_SEG26,
	BL55072A_SEG27,
	BL55072A_SEG28,
	BL55072A_SEG29,
	BL55072A_SEG30,
	BL55072A_SEG31,
	BL55072A_SEG32,
	BL55072A_SEG33,
	BL55072A_SEG34,
	BL55072A_SEG35,
	BL55072A_SEG36,
}blSeg;

#define  DisplayChar0 0x5F
#define  DisplayChar1 0x06
#define  DisplayChar2 0x3D
#define  DisplayChar3 0x2F
#define  DisplayChar4 0x66
#define  DisplayChar5 0x6B
#define  DisplayChar6 0x7B
#define  DisplayChar7 0x0E
#define  DisplayChar8 0x7F
#define  DisplayChar9 0x6F
#define  DisplayCharA 0x7E
#define  DisplayCharB 0x73  // ???
#define  DisplayCharE 0x79  // E
#define  DisplayCharF 0x78  // F
#define  DisplayCharr 0x30  // r
#define  DisplayCharL 0x51
#define  DisplayCharo 0x33




#define OFF       						0
#define ON       						1
#define FLASHING  						2
#define DFLASHING 						3


#define LCDDisplayInvalidParameter  	0XFFFF

#define SysLCDShowTimer 				10


typedef struct Lcd_Display_Status
{
    u8  LCD_place;             // 需要点亮部分位置,LCDDisplayInvalidParameter/0XFF为无效值         
    u16  LCD_code_data;         // 参数--当前只有温度部分需要使用此参数 范围（ NULL - ShowCharNumLitd ），超出此      范围无效,LCDDisplayInvalidParameter/0XFFFF为无效值 
    u8  LCD_state;             // 亮、灭、闪,双闪LCDDisplayInvalidParameter/0XFF为无效值，不包括数码管1、2、3、4、5、6 
    u16 LCD_display_timer;     // 闪烁间隔时间，单位10ms,LCDDisplayInvalidParameter/0XFFFF/NULL为无效值  
    u16 LCD_display_count;     // 部分液晶只需要闪烁几次，一个跳变为一次,LCDDisplayInvalidParameter                   /0xFFFF为无效值,不使用填充无效值   
	
} Lcd_Status_Info_t;


/*****************************************************************
             LCD屏位置定义
*******************************************************************/
#define   SYSTEM_MANUAL_OUTLINE_DISPLAY              		0X01    //手动模式外圈(S1)
#define   SYSTEM_MANUAL_CHAR_DISPLAY               			0X02    //手动模式内圈(S2)
#define   SYSTEM_ROLLING_OUTLINE_DISPLAY              		0X03    //循环模式外圈(S3)
#define   SYSTEM_ROLLING_CHAR_DISPLAY               		0X04    //循环模式内圈(S4)
#define   SYSTEM_AUTO_OUTLINE_DISPLAY              			0X05    //自动模式外圈(S13)
#define   SYSTEM_AUTO_CHAR_DISPLAY               			0X06    //自动模式内圈(S14)

#define   DEVICE_TYPE_HEATING_OUTLINE_DISPLAY              	0X07    //地暖模式外圈(S5)
#define   DEVICE_TYPE_HEATING_CHAR_DISPLAY               	0X08    //地暖模式内圈(S6)
#define   DEVICE_TYPE_AIRCONDITION_OUTLINE_DISPLAY          0X09    //空调模式外圈(S7)
#define   DEVICE_TYPE_AIRCONDITION_CHAR_DISPLAY             0X0A    //空调模式内圈(S8)
#define   DEVICE_TYPE_FAN_OUTLINE_DISPLAY              		0X0B    //新风模式外圈(S9)
#define   DEVICE_TYPE_FAN_CHAR_DISPLAY               		0X0C    //新风模式内圈(S10)

#define   SETTING_TIMER_DISPLAY               				0X0D    //定时图标(S12)
#define   CURRENT_TEMPER_CHAR_DISPLAY               		0X0E    //当前温度字符(S15)
#define   SETTING_TIMER_CHAR_DISPLAY               			0X0F    //设定时长字符(S16)
#define   H_CHAR_DISPLAY               						0X10    //小时“H”字符(S17)
#define   UPPER_TEMPER_UNIT_DISPLAY               			0X11    //上方摄氏度℃(S18)
#define   ZIGBEE_NET_CAHR_DISPLAY               			0X12    //zigbee网络灯(S19)
#define   CHILD_LOCK_DISPLAY               					0X13    //童锁图标(S20)
#define   MIDDLE_TEMPER_UNIT_DISPLAY               			0X14    //中间摄氏度℃(S21)

#define   SYSTEM_HEATING_OUTLINE_DISPLAY              		0X15    //制热模式外圈(S22)
#define   SYSTEM_HEATING_CHAR_DISPLAY               		0X16    //制热模式内圈(S23)
#define   SYSTEM_DRY_OUTLINE_DISPLAY              			0X17    //除湿模式外圈(S24)
#define   SYSTEM_DRY_CHAR_DISPLAY               			0X18    //除湿模式内圈(S25)
#define   SYSTEM_COOL_OUTLINE_DISPLAY              			0X19    //制冷模式外圈(S26)
#define   SYSTEM_COOL_CHAR_DISPLAY               			0X1A    //制冷模式内圈(S27)
#define   SYSTEM_FAN_OUTLINE_DISPLAY              			0X1B    //通风模式外圈(S28)
#define   SYSTEM_FAN_CHAR_DISPLAY               			0X1C    //通风模式内圈(S29)
#define   SYSTEM_SLEEP_OUTLINE_DISPLAY              		0X1D    //睡眠模式外圈(S30)
#define   SYSTEM_SLEEP_CHAR_DISPLAY               			0X1E    //睡眠模式内圈(S31)

#define   WIND_DIRECTION_UP_DISPLAY               			0X1F    //风向上图标(S32)
#define   WIND_DIRECTION_MIDDLE_DISPLAY              		0X20    //风向中图标(S33)
#define   WIND_DIRECTION_DOWN_DISPLAY               		0X21    //风向下图标(S34)

#define   WIND_DIRECT_CHAR_DISPLAY               			0X22    //风向字符图标(S35)
#define   WIND_SPEED_CHAR_DISPLAY               			0X23    //风速字符图标(S36)
#define   MIDDLE_POINT_DISPLAY              				0X24    //中间小数点(P0)
#define   UPPER_POINT_DISPLAY               				0X25    //上方小数点(P1)


#define   SET_MIDDLE_DIGITRON_DISPLAY_01           			0X26   //中间第一个段码(1)
#define   SET_MIDDLE_DIGITRON_DISPLAY_02           			0X27   //中间第二个段码(2)
#define   SET_MIDDLE_DIGITRON_DISPLAY_03           			0X28   //中间第三个段码(3)

#define   SET_UPPER_DIGITRON_DISPLAY_01         			0X29   //上方第一个段码(4)
#define   SET_UPPER_DIGITRON_DISPLAY_02          			0X2A   //上方第二个段码(5)
#define   SET_UPPER_DIGITRON_DISPLAY_03          			0X2B   //上方第三个段码(6)

#define   FAN_SPEED_DIGITRON_DISPLAY_01          			0X2C   //当前风速第1个段码(7)

#define   DELAY_OFF_TIME_DISPLAY          					0X2D   //延时关机时间显示
#define   CALIBRATE_TEMPER_DISPLAY          				0X2E   //校准温度显示
#define	  LCD_CONTROL(X)   									((X>0)?  (P52 = 1):(P52 = 0) );





void PWM_init(void);
void LcdShowCTR( Lcd_Status_Info_t LCDShowTemp_t );

void BL55072A_DisplayON(void);
void BL55072A_Clear(void);
void BL55072A_DisplayALL(void);
void BL55072A_Init(uint8_t slaver_addr,u32 freq);
void BL55072A_DisplayGeneral(u8 addr,u8 control_bits,u8 display_bits);
void LcdShowRunningAll( void );
u16  GetLCDShowTime( void );
void SetLCDShowTime(u16 uSetLCDShowTime);
u8 IsPowerOffFlashing(void);
void Test(void);
#endif 


