From 546dc31c7c467193f82de2596ae9f143aed3b2b7 Mon Sep 17 00:00:00 2001 From: kyz Date: Wed, 22 May 2024 14:10:01 +0800 Subject: [PATCH] =?utf8?q?lcd=E8=83=8C=E5=85=89=E6=8E=A7=E5=88=B6=E4=BF=A1?= =?utf8?q?=E5=8F=B7=E5=92=8C=E8=9C=82=E9=B8=A3=E5=99=A8=E6=8E=A7=E5=88=B6?= =?utf8?q?=E4=BF=A1=E5=8F=B7=E4=BA=A4=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- user/ht1622.c | 27 ++++++++++++++++++++++-- user/user_app.c | 53 +++++++++++++++++++++++++++++++++-------------- user/user_ui.c | 4 ++-- user/user_ui_h3.c | 34 +++++++++++++++++++++++------- 4 files changed, 90 insertions(+), 28 deletions(-) diff --git a/user/ht1622.c b/user/ht1622.c index 87fa5ac..81c73cb 100644 --- a/user/ht1622.c +++ b/user/ht1622.c @@ -98,9 +98,9 @@ void ht1622_data_dir_input(void) GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitStruct.Pin = LCD_SDA_Pin; - GPIO_InitStruct.Pin = LCD_INT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(LCD_SDA_GPIO_Port, &GPIO_InitStruct); } @@ -133,7 +133,7 @@ void ht1622_read_bits( uint8_t *data, uint32_t bits ) ht1622_delay_us(10); if( ht1622_data_read() ) d |= 1< 10 ) + level = 10; + __HAL_TIM_SET_COMPARE(&htim13, TIM_CHANNEL_1, bl_compare[level] ); +} + +void lcd_bl_init( void ) { - static uint8_t bl_timer_count = 0; - HAL_GPIO_WritePin( LCM_EN_GPIO_Port, LCM_EN_Pin, ( bl_timer_count < bl_level )?GPIO_PIN_SET:GPIO_PIN_RESET ); - if( bl_timer_count>= 9 ) - bl_timer_count = 0; - else - bl_timer_count++; + bl_level = 5; + curr_bl = 5; + + HAL_TIM_PWM_Start( &htim13, TIM_CHANNEL_1 ); + __HAL_TIM_SET_COMPARE(&htim13, TIM_CHANNEL_1, 500 ); + lcd_bl( curr_bl ); } #define DEV_MODE_WORK 0 @@ -231,9 +240,17 @@ void ui_evt_handle( ui_ev_t *ev ) HAL_GPIO_WritePin( PB3_LEDG_GPIO_Port, PB3_LEDG_Pin, GPIO_PIN_RESET ); HAL_GPIO_WritePin( PB3_LEDR_GPIO_Port, PB3_LEDR_Pin, (now%1000)<500?GPIO_PIN_SET:GPIO_PIN_RESET ); } + //backlight + { + if(curr_bl != bl_level ){ //bl 0--10 + curr_bl = bl_level; + lcd_bl( curr_bl ); + } + } } } + void lcd_init( void ); void user_ui_h3_task( void* unused ) { @@ -246,6 +263,7 @@ void user_ui_h3_task( void* unused ) tick = xTaskGetTickCount(); lcd_init(); + lcd_bl_init(); while(1){ //dbg_t1 = TIM7->CNT; -- 2.34.1