lcd_display.c

来自「电表解决方案概要power_meter_r8c2g_source_code」· C语言 代码 · 共 2,185 行 · 第 1/4 页

C
2,185
字号
	
  if (menu_level_buff == Menu_Level_0)
   {
	   	/* 菜单0级时,确定菜单显示页和需要显示参数的位置 */
		
	    menu_page_shift(j, menu_buff_0, Menu_Level_0);
					
		if (j > 5)
	 	 {
			 j -=6;			 
			 m = nBitmapDot0_5;				/* 确认数据表地址 */
	 	 }
	 
		else 
		m = nBitmapDot0_2;					/* 确认数据表地址 */
		
		n = m;
	
		if (j <= 2)
	 	 {
			 x = j*2 +2;
			 y = j*2 +3;
			 z = 1;
			 
			 lcd_flash(x, y, z, m, n);
	 	 }
		else if ((j > 2)&&(j <= 5))
	 	 {
			 x = (j-3)*2 +2;				//  x = j -3 +2;
			 y = (j-3)*2 +3;				//  y = j -3 +3;
			 z = 2;

			 lcd_flash(x, y, z, m, n);	
	 	 }	
   }
  if (menu_level_buff == Menu_Level_1)
   {	
	   
	   	/* 菜单1级时,确定菜单显示页和需要显示参数的位置 */
			   
		menu_page_shift(j, menu_buff_1, Menu_Level_1);	
		
		if (menu_buff_1 == Menu_Wash_Set)
		 {
			m = nBitmapDot1_DanXi_2;
			n = m;
		 }
		else if (menu_buff_1 == Menu_Rinse_Set)
		 {
			m = nBitmapDot1_PiaoXi_2;
			n = nBitmapDot1_DanXi_3;				/* 选择单洗,单漂等程序时,2级菜单选项很少,因此 CS3 菜单需要显示白屏, 下同 */
		 }
		else if (menu_buff_1 == Menu_Spin_Set)
		 {
			m = nBitmapDot1_DanTuo_2;
			n = nBitmapDot1_DanXi_3;
		 }
		else if (menu_buff_1 == Menu_Special)
		 {
			m = nBitmapDot1_TeShu_2;
			n = nBitmapDot1_DanXi_3;
		 }
		else 
		 {
			if (j > 5)
	 	 	 {
			 	j -=6;			 
			 	m = nBitmapDot1_5;
	 	 	 }
			else 
			m = nBitmapDot1_2;						//  ???????????
			n = m;
		 }
	
		if (j <= 2)
	 	 {
			 x = j*2 +2;
			 y = j*2 +3;
			 z = 1;
			 
			 lcd_flash(x, y, z, m, n);
	 	 }
		else if ((j > 2)&&(j <= 5))
	 	 {
			 x = (j-3)*2 +2;				//  x = j -3 +2;
			 y = (j-3)*2 +3;				//  y = j -3 +3;
			 z = 2;
			 			 
			 lcd_flash(x, y, z, m, n);	
	 	 }				
   } 
   	
  if (menu_level_buff == Menu_Level_2)	  /* 菜单2级时,直接切换当前显示画面 */  

  menu_page_shift(set_num, menu_buff_2, Menu_Level_2);		/* 2 级菜单只需要进行切换及显示处理即可,不需要闪烁 */
  
  if (menu_level_buff == Menu_Level_3)	
   {
	   
      /* 菜单3级时,确定菜单显示页和需要显示参数的位置 */  	   
	  
	  menu_page_shift(set_num, menu_buff_3, Menu_Level_3);
	   
	  if (j == 0)
	  z = 1;
	  else if (j == 1)
	  z = 2;
	  
	  x = 2;
	  y = 7;
	  
	  m = nBitmapDot3_QiDong_2;
	  n = m;	  
	  
	  lcd_flash(x, y, z, m, n);
	   
   }
   
  if (menu_level_buff == Menu_Level_4)	
   {
	   
        /* 菜单4级时,显示程序运行状态 */  
  	   
  		if ((status_buff == STOP)||(status_buff == RUN))			/* 当开始按键按下时,才进行对应的过程运行现实处理 */
  		process_flash(process_buff, confirm_num, set_num, program_left_time, program_buff, water_level_buff);
		else if (preset_set_flag == 1)
		process_flash(process_buff, confirm_num, set_num, program_left_time, program_buff, water_level_buff);
  		
		else 
  		return;
   }
   
  return;
  
}

/***************************************************************************************************************

LCD 菜单切换及菜单显示处理程序:

void menu_page_shift(unsigned char num, unsigned char menu_buff, unsigned char menu_level)

num: 当前菜单下set_up按键按下的次数,数值为减去set_down按键按下的次数
menu_buff: 菜单变量,存储菜单内容, 
menu_level: 菜单级变量,存储菜单级别

***************************************************************************************************************/

void menu_page_shift(unsigned char num, unsigned char menu_buff, unsigned char menu_level)
{
	unsigned char i;
	unsigned char j;
	unsigned char a;
	unsigned char b;
	unsigned char c;
	
	menu_buff &= 0x0f;							/* 去掉菜单变量中代表菜单级别的标志位 */
	
	if (menu_level == Menu_Level_0)
	 {
		 Set_Screen(CS1, nBitmapDot0_1);		/* 0 级菜单时,显示CS1内容,CS2, CS3, 相应内容会在 lcd_flash() 程序中显示*/
/*		 
		 if (menu_0_flag == 1)
		  {
			menu_0_flag = 0;
		 	if (num <= 5)
			 {
		 		Set_Screen(CS2, nBitmapDot0_2);
				Set_Screen(CS3, nBitmapDot0_3);
			 }
		 	if (num > 5)
			 {
		 		Set_Screen(CS2, nBitmapDot0_5);
		 		Set_Screen(CS3, nBitmapDot0_6);
			 }
		  }
*/	  
	 }
	 
	if (menu_level == Menu_Level_1)
	 {
		 /* 1 级菜单时,显示CS1内容,CS2, CS3, 相应内容会在 lcd_flash() 程序中显示*/
		 menu_0_flag = 1;
		 Change_Set_Screen(CS1, 5, 6, nBitmapDot1_JiYi + menu_buff*128, nBitmapDot1_1);	
	 }
	if (menu_level == Menu_Level_2)
	 {
		if (function_set_flag != 1)				/* 2 级菜单时,功能键没有按下时正常显示 */
		 {
			 if (menu_buff == 0)				/* 当 menu_buff == Menu_Water_P 时,2 级菜单为水位选择菜单*/
			 Set_Screen(CS1, nBitmapDot2_ShuiWei_1);
			 
			 /* 当 menu_buff != Menu_Water_P 时,2 级菜单为对应功能选择菜单,如浸泡时间,洗涤时间,漂洗次数等*/
			 else
			 Change_Set_Screen(CS1, 5, 6, nBitmapDot2_JinPao_1 + (menu_buff-1)*256, nBitmapDot2_ShuiWei_1);
			 
			 if (menu_buff == 0)				/* 当 menu_buff == Menu_Water_P 时,水位初始显示值为 6 */
			  {
				  Change_Set_Screen(CS2, 4, 5, nBitmapDot2_Num_0 + water_level_buff_0 * 128, nBitmapDot2_ShuiWei_1 +512);
			  }
			 else if (menu_buff == 1)
			  {
				  Change_Set_Screen(CS2, 4, 5, nBitmapDot2_JinPao_Num_0 + soak_time_buff_0 * 128, nBitmapDot2_ShuiWei_1 +512);
			  }
			 else if (menu_buff == 2)			/* 当 menu_buff == Menu_Wash_Time 时,洗涤时间初始显示值为 12 */
			  {
				  Change_Set_Screen(CS2, 4, 5, nBitmapDot2_Num_0 + wash_time_buff_0 * 128, nBitmapDot2_ShuiWei_1 +512);
			  }
			 else if (menu_buff == 3)			/* 当 menu_buff == Menu_Rinse_Num 时,漂洗次数初始显示值为 1 */
			  {
				  Change_Set_Screen(CS2, 4, 5, nBitmapDot2_Num_0 + rinse_time_buff_0 * 128, nBitmapDot2_ShuiWei_1 +512);
			  }
			 else if (menu_buff == 4)			/* 当 menu_buff == Menu_Spin_Time 时,脱水时间初始显示值为 6 */
			  {
				  Change_Set_Screen(CS2, 4, 5, nBitmapDot2_Num_0 + spin_time_buff_0 * 128, nBitmapDot2_ShuiWei_1 +512);
			  }
			 else if (menu_buff == 5)
			  {				  
				  if ((rinse_three_time_flag == 0)&&(save_water_num_buff_0 == 2))
				   {
				  		save_water_num_buff_0 = 3;			 /* 当只有2次蓄水漂洗时,更改显示值 */  		  
				  		Change_Set_Screen(CS2, 4, 5, nBitmapDot2_LiuShui_Num_1 + save_water_num_buff_0 * 128, nBitmapDot2_ShuiWei_1 +512);
						save_water_num_buff_0 = 2; 			 /* 恢复所选留水次数 */  
				   }
				  else
				  Change_Set_Screen(CS2, 4, 5, nBitmapDot2_LiuShui_Num_1 + save_water_num_buff_0 * 128, nBitmapDot2_ShuiWei_1 +512);				   

			  }
//			 else if (menu_buff == 6)
//			  {
//				  Change_Set_Screen(CS2, 4, 5, nBitmapDot2_FengGan_Num_0_5 + winddry_time_buff_0 * 128, nBitmapDot2_ShuiWei_1 +512);
//			  }
			 else if (menu_buff == 6)			/* 当 menu_buff == Menu_Preset 时,预约时间初始显示值为 2 */
			  {			  
				  /* 当设置预约时间 = 25时,预约时间不显示内容 */
				  if (preset_time_buff_0 == 25)
				  Change_Set_Screen(CS2, 4, 5, nBitmapDot2_Num_0_0, nBitmapDot2_ShuiWei_1 +512);
				  else
				  Change_Set_Screen(CS2, 4, 5, nBitmapDot2_Num_0 + preset_time_buff_0 * 128, nBitmapDot2_ShuiWei_1 +512);
			  }
			 
			 else 
			 Change_Set_Screen(CS2, 4, 5, nBitmapDot2_Num_0 + num * 128, nBitmapDot2_ShuiWei_1 +512);
			 
			 if (menu_buff == 0)
			 Set_Screen(CS3, nBitmapDot2_ShuiWei_3);
			 else 
			 Change_Set_Screen(CS3, 4, 5, nBitmapDot2_JinPao_3 + (menu_buff-1)*256, nBitmapDot2_ShuiWei_1 +1024);	

		 }
		else if (function_set_flag == 1)		/* 当功能键按下时,显示规则按照功能菜单的方式显示 */
		 {
			 if (num == 0)
			  {
				  Set_Screen(CS1, nBitmapDot2_GongNeng_1);
				  Set_Screen(CS2, nBitmapDot2_GongNeng_2);
				  Set_Screen(CS3, nBitmapDot2_GongNeng_3);
			  }
			 else
			  {

			 	Set_Screen(CS1, nBitmapDot2_GongNeng_1);
			 
//			 	Change_Set_Screen(CS2, 2, 7, nBitmapDot2_GongNeng_4 + (num-1) * 768, nBitmapDot2_GongNeng_1 +512);
			 	Change_Set_Screen(CS2, 4, 5, nBitmapDot2_GongNeng_4 + (num-1) * 128, nBitmapDot2_GongNeng_1 +512);
			
//			 	Change_Set_Screen(CS3, 2, 7, nBitmapDot2_GongNeng_5 + (num-1) * 768, nBitmapDot2_GongNeng_1 +1024);	
			 	Change_Set_Screen(CS3, 4, 5, nBitmapDot2_GongNeng_7 + (num-1) * 128, nBitmapDot2_GongNeng_1 +1024);	

			  }
		 } 
	 }
	if (menu_level == Menu_Level_3)
	 {
		 Set_Screen(CS1, nBitmapDot3_QiDong_1); 
	 }
	 
 return;
	
}

/***************************************************************************************************************

LCD 程序设定时菜单闪烁处理程序:

lcd_flash(unsigned char a, unsigned char b, unsigned char cs, unsigned char * map, unsigned char * map_t)

a: 需要闪烁区域起始页, b: 需要闪烁区域结束页, cs: 需要进行闪烁处理的屏

map, map_t: 数据表地址,map_t用于显示白屏处理,具体处理逻辑可参考 menu_display()

***************************************************************************************************************/

void lcd_flash(unsigned char a, unsigned char b, unsigned char cs, unsigned char * map, unsigned char * map_t)
{
	if (Tflash == 0)
	 {
		 Tflash = 200;

		 if (flash_switch_flag ==0)
		  {
			if (cs == 1)		  
			Comp_Set_Screen(CS2, a, b, map);				/* 反白显示需要进行闪烁处理的区域 */
			else 
			Set_Screen(CS2, map);							/* 正常显示当前菜单CS2 */
			
			if(cs == 2)
			Comp_Set_Screen(CS3, a, b, map+512);			/* 512 是单屏数据表所占据的空间,用以定位另一数据表起始地址 */
			
			else if (map != map_t)
			Set_Screen(CS3, map_t);
			else 
			Set_Screen(CS3, map+512);	
			
		 	flash_flag = 1;
			flash_switch_flag =1;
		  }
		 else if (flash_switch_flag ==1) 				 /* 根据flash_switch_flag切换闪烁显示方式 */  
		  {
			if (cs == 1)
			Set_Screen(CS2, map);
//			Flash_Set_Screen(CS2, a, b, map+512);
			else
			Set_Screen(CS2, map);
			
			if(cs == 2)
			Set_Screen(CS3, map+512);
//			Flash_Set_Screen(CS3, a, b, map+1024);
			else if (map != map_t)
			Set_Screen(CS3, map_t);
			else 
	  		Set_Screen(CS3, map+512);	
 
		 	flash_flag = 0;
			flash_switch_flag =0;
		  }
	 }
}

/***************************************************************************************************************

LCD 程序运行时菜单闪烁处理程序:(程序结构保留了动画处理部分,只需要依次修改CS1数据起始地址就行)

process_flash(unsigned char process, unsigned char left_time, unsigned char program, unsigned char water_level)

process: 程序当前运行过程, left_time: 运行结束剩余时间, program: 所选择程序
water_level: 所选择水位

***************************************************************************************************************/

void process_flash(unsigned char process, signed char cfm_num, signed char num, unsigned char left_time, unsigned char program, unsigned char water_level)
{
	if (Pflash == 0)
	 {
		 Pflash = 200; 					 /* 重值动画更新时间 */  
		 
		 if (preset_set_flag == 1)
		 process = 5;
		 
		 if (Pflash_switch_flag ==0x00)
		  { 
			if (run_save_water_flag == 1) 				 /* 留水运行时,第一屏显示留水画面 */  
			Set_Screen(CS1, nBitmapDot4_LS_1);
			else if(run_err_flag == 1)		 			 /* 错误处理运行时,第一屏显示错误处理画面 */ 
			Set_Screen(CS1, nBitmapDot4_CW_1);
			
			else if (preset_set_flag == 1)				 /* 预约运行时,第一屏显示预约画面 */ 
			Set_Screen(CS1, nBitmapDot4_JinShui_1 + process * 2048);			 
			else 
			Set_Screen(CS1, nBitmapDot4_JinShui_1 + process * 2048);		/* 程序正常运行时,显示当前运行过程动画 */			  

			if (program_start_flag == 1)	 /* 切换CS2 第0,1页内容*/		
			 {	
				Change_Set_Screen(CS2, 0, 1, nBitmapDot4_JinShui_1_2 + process * 128, nBitmapDot4_Process_2);
				FSH_Set_Two_Page(CS2, 2, nBitmapDot4_SY_2_1 + cfm_num * 128);			
			 }
			else if (program_pause_flag == 1) /* 切换CS2 第0,1页内容*/
			 {
				Change_Set_Screen(CS2, 0, 1, nBitmapDot4_JinShui_ZT_1 + process * 128, nBitmapDot4_Process_2);
				if (run_save_water_flag == 1)
				FSH_Set_Two_Page(CS2, 2, nBitmapDot4_LS_2);
				else if(run_err_flag == 1)
				FSH_Set_Two_Page(CS2, 2, nBitmapDot4_CW_2);
			 }
			
			if (program_start_flag == 1)/* 正常显示CS3的对应菜单内容 */
			 {
				if (run_page3_flag == 0)
				 {
					run_page3_flag = 1;
					Set_Screen(CS3, nBitmapDot4_Process_3);
				 }
				 
				if ((run_page3_flag == 1)&&(recover_flag == 1))
				 {
					recover_flag = 0;
//					run_page3_flag = 1;
					Set_Screen(CS3, nBitmapDot4_Process_3);
				 }				 
			 }
			
			else if (program_pause_flag == 1)/* 正常显示CS3的对应菜单内容 */
			 {			 
				if (run_page3_flag == 0)
				 {
					run_page3_flag = 1;
					Change_Set_Screen(CS3, 0, 1, nBitmapDot4_JinShui_ZT_2, nBitmapDot4_Process_3);
				 }
				 
				if ((run_page3_flag == 1)&&(recover_flag == 1))
				 {
					recover_flag = 0;
//					run_page3_flag = 1;
					Change_Set_Screen(CS3, 0, 1, nBitmapDot4_JinShui_ZT_2, nBitmapDot4_Process_3);
				 }	
				 			 			 
				FSH_Set_Two_Page(CS3, 0, nBitmapDot4_JinShui_ZT_2);	
				
			 }		

			/* 显示剩余时间 */

			if (confirm_num == 0)		 /* 默认运行画面时,状态浏览栏根据不同状态显示剩余时间,错误代码或留水剩余次数 */ 
			 {				
				if (run_save_water_flag == 1)
				 {
			 		FSH_Set_Two_Page(CS3, 2, nBitmapDot4_CI_3);
			 		Set_Char(CS3, 2, 8, nBitmapDot_num_0 + (save_water_number/10) *16);
			 		Set_Char(CS3, 2, 16, nBitmapDot_num_0 + (save_water_number%10) *16);	
				 }		
				else if (run_err_flag == 1)
				FSH_Set_Two_Page(CS3, 2, nBitmapDot4_CW_3_1 + (err_buff-1) * 128);
				
				else if (preset_set_flag == 1)
				 {
			 		FSH_Set_Two_Page(CS3, 2, nBitmapDot4_XS_3);
			 		Set_Char(CS3, 2, 8, nBitmapDot_num_0 + (preset_time_buff/10) *16);
			 		Set_Char(CS3, 2, 16, nBitmapDot_num_0 + (preset_time_buff%10) *16);	
				 }						
				else
				 {
			 		FSH_Set_Two_Page(CS3, 2, nBitmapDot4_FZ_3);
			 		Set_Char(CS3, 2, 8, nBitmapDot_num_0 + (left_time/10) *16);
			 		Set_Char(CS3, 2, 16, nBitmapDot_num_0 + (left_time%10) *16);	
				 }					
			 }								
			else if (confirm_num == 1)		 /* 程序运行时,“+”键按下1次时,浏览状态栏显示浸泡时间 */
			 {
			 	FSH_Set_Two_Page(CS3, 2, nBitmapDot4_FZ_3);
			 	Set_Char(CS3, 2, 8, nBitmapDot_num_0 + (soak_time_buff*10/10) *16);
			 	Set_Char(CS3, 2, 16, nBitmapDot_num_0 + (soak_time_buff*10%10) *16);	
			 }		 
			else if (confirm_num == 2)		 /* 程序运行时,“+”键按下2次时,浏览状态栏显示洗涤时间 */
			 {			
			 	FSH_Set_Two_Page(CS3, 2, nBitmapDot4_FZ_3);
			 	Set_Char(CS3, 2, 8, nBitmapDot_num_0 + (wash_time_buff/10) *16);
			 	Set_Char(CS3, 2, 16, nBitmapDot_num_0 + (wash_time_buff%10) *16);		
			 }			 	 
			else if (confirm_num == 3)		 /* 程序运行时,“+”键按下3次时,浏览状态栏显示漂洗时间 */
			 {			
			 	FSH_Set_Two_Page(CS3, 2, nBitmapDot4_CI_3);
			 	Set_Char(CS3, 2, 8, nBitmapDot_num_0 + (rinse_time_buff/10) *16);
			 	Set_Char(CS3, 2, 16, nBitmapDot_num_0 + (rinse_time_buff%10) *16);		
			 }	
			else if (confirm_num == 4)		 /* 程序运行时,“+”键按下4次时,浏览状态栏显示脱水时间 */
			 {			
			 	FSH_Set_Two_Page(CS3, 2, nBitmapDot4_FZ_3);
			 	Set_Char(CS3, 2, 8, nBitmapDot_num_0 + (spin_time_buff/10) *16);
			 	Set_Char(CS3, 2, 16, nBitmapDot_num_0 + (spin_time_buff%10) *16);		
			 }		
			else if (confirm_num == 5)		 /* 程序运行时,“+”键按下5次时,浏览状态栏显示所选功能 */
			 {			
			 	FSH_Set_Two_Page(CS3, 2, nBitmapDot4_GN_3_1 + function_set_buff * 128);	
			 }						 

			/* 状态栏2显示所选择程序 */
			Set_Two_Page(CS3, 4, nBitmapDot1_JiYi + program * 128);
			
			/* 状态栏3显示所选择水位 */
			if (water_level >= 10)
			 {
				Set_Char(CS3, 6, 8, nBitmapDot_num_0 + (water_level/10) *16);
				Set_Char(CS3, 6, 16, nBitmapDot_num_0 + (water_level%10) *16);
			 }
			else if(water_level < 10)
			Set_Char(CS3, 6, 8, nBitmapDot_num_0 + water_level *16);
						  
		 	flash_flag = 1;
			Pflash_switch_flag =0x01;
		  }
		  
		 else if (Pflash_switch_flag ==0x01)			
		  {
			if ((program_start_flag == 1)&&(check_2s_buff == 0))
			Set_Screen(CS1, nBitmapDot4_JinShui_1 + process * 2048 + 512);			/* 显示动画第二幅画面 */

			else if (program_pause_flag == 1)
			 {
				FSH_Set_Two_Page(CS2, 0, nBitmapDot4_ZT_FS1);						/* 如果程序暂停,状态栏显示暂停信息 */
				FSH_Set_Two_Page(CS3, 0, nBitmapDot4_ZT_FS2);
			 }
			 
		 	flash_flag = 0;
			Pflash_switch_flag =0x02;
		  }
		 else if (Pflash_switch_flag ==0x02)
		  {
			if ((program_start_flag == 1)&&(check_2s_buff == 0))
			Set_Screen(CS1, nBitmapDot4_JinShui_1 + process * 2048 + 2 * 512);			/* 显示动画第三幅画面 */

			else if (program_pause_flag == 1)
			 {
				FSH_Set_Two_Page(CS2, 0, nBitmapDot4_JinShui_ZT_1 + process * 128);
				FSH_Set_Two_Page(CS3, 0, nBitmapDot4_JinShui_ZT_2);					/* 如果程序暂停,状态栏显示暂停信息 */
			 }
			  
		 	flash_flag = 0;
			Pflash_switch_flag =0x03;
		  }
		 else if (Pflash_switch_flag ==0x03)
		  {
			if ((program_start_flag == 1)&&(check_2s_buff == 0))
			Set_Screen(CS1, nBitmapDot4_JinShui_1 + process * 2048 + 3 * 512);			/* 显示动画第四幅画面 */

			else if (program_pause_flag == 1)
			 {
				FSH_Set_Two_Page(CS2, 0, nBitmapDot4_ZT_FS1);						/* 如果程序暂停,状态栏显示暂停信息 */
				FSH_Set_Two_Page(CS3, 0, nBitmapDot4_ZT_FS2);
			 }
			  
		 	flash_flag = 0;
			Pflash_switch_flag =0x00;
		  }
	 }
	else return;
}

//-----------------------------------------------------------------------------------------
void display_status_judge (void)
{
	;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?