/********************************************************************************
 * @file    LCD_Example.c
 * @author  SOC AE Team
 * @version V1.1
 * @date    2025-06-27
 * @brief   LCD显示输出示例。
 *
 *******************************************************************************/
#if defined(SC32f10xx)||defined(SC32f12xx)
#include "sc32_conf.h"
#include "Function_Init.h"

void LCD_Example_Function(void)
{
  
  uint16_t i,j;
  LCD_InitTypeDef LCD_InitStruct; //定义LCD初始化结构体变量
  
  /* 使能LCD时钟 */
  RCC_APB2Cmd(ENABLE);  //LCD外设挂载在APB2时钟上
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_LCD_LED, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_LEDPWM, ENABLE);
  /* 结构体成员初始化 */
  LCD_StructInit(&LCD_InitStruct);
  
  LCD_InitStruct.LCD_Bias = LCD_Bias_1_4;	//1/4偏置电压
#if defined(SC32f10xx)||defined(SC32f12xx)
  LCD_InitStruct.LCD_Duty = LCD_Duty_1_4_SEG4_27COM0_3;	//配置占空比为1/4，S4~S27为segment，C0~C3为common
#endif
  LCD_InitStruct.LCD_FrameFre = LCD_FrameFre_B64Hz;	//帧频为B类型64Hz
  LCD_InitStruct.LCD_ResSel = LCD_ResSel_33K;	//内部分压电阻为33K欧姆
  /* 使能COM管脚输出通道 */
  LCD_InitStruct.LCD_ComPin = LCD_Channel_0 | LCD_Channel_1 | LCD_Channel_2 | LCD_Channel_3;//C0~C3
  /* 使能Seg管脚输出通道，每个位对应一个通道 */
  LCD_InitStruct.LCD_SegPin =  0x00000F00;//使能SEG8~11
  LCD_InitStruct.LCD_VOIRSIF = LCD_VOIRSIF_Disable;	//关闭快速充电
  LCD_InitStruct.LCD_Voltage = 5;	//VLCD = VDD*(17+VLCD[3:0])/32= VDD
  LCD_Init(&LCD_InitStruct);
  
  LCD_Cmd(ENABLE);
	
  while(1)
  {
    for(i=0;i<1000;i++)//延时
    {
      for(j=0;j<2000;j++);
    }	
    
    /* COM0~3 SEG8~11点亮 */
    LCD_Write(LCD_RAMRegister_8,0x0F);//COM0~3 SEG8点亮
    LCD_Write(LCD_RAMRegister_9,0x0F);//COM0~3 SEG9点亮
    LCD_Write(LCD_RAMRegister_10,0x0F);//COM0~3 SEG10点亮
    LCD_Write(LCD_RAMRegister_11,0x0F);//COM0~3 SEG11点亮
    
    for(i=0;i<1000;i++)//延时
    {
      for(j=0;j<2000;j++);
    }	
    
    /* COM0~3 SEG4~7熄灭 */	
    LCD_Write(LCD_RAMRegister_8,0x00);//COM0~3 SEG8熄灭
    LCD_Write(LCD_RAMRegister_9,0x00);//COM0~3 SEG9熄灭
    LCD_Write(LCD_RAMRegister_10,0x00);//COM0~3 SEG10熄灭
    LCD_Write(LCD_RAMRegister_11,0x00);//COM0~3 SEG11熄灭
  }
}
#endif
