diff --git a/epicardium/epicardium.h b/epicardium/epicardium.h index 12acffb83a6659ed637da50f8968c8ed3c9b1c29..60f008a33f8ba4271384af19a7ae0844a856ce23 100644 --- a/epicardium/epicardium.h +++ b/epicardium/epicardium.h @@ -1337,7 +1337,7 @@ API(API_DISP_FRAMEBUFFER, int epic_disp_framebuffer(union disp_framebuffer *fb)) /** * Set the backlight brightness value * - * :param brightness: brightness from 0 - 1000 + * :param brightness: brightness from 0 - 100 * :return: ``0`` on success or negative value in case of an error: * * - ``-EBUSY``: Display was already locked from another task. diff --git a/lib/card10/display.c b/lib/card10/display.c index 6bf37a0d4f0861904ecf654487980dd7cefc8108..f5fd471579a41a0ea520f35594dd0553b089490d 100644 --- a/lib/card10/display.c +++ b/lib/card10/display.c @@ -37,7 +37,7 @@ void display_init(void) GPIO_Config(&DEV_DC_PIN); - LCD_SetBacklight(200); + LCD_SetBacklight(20); LCD_Init(); display_screen = gfx_screen(LCD_framebuffer()); diff --git a/lib/gfx/GUI_DEV/DEV_Config.c b/lib/gfx/GUI_DEV/DEV_Config.c index 543604f768e2ede2b9ec517bbfa4786b07d077b9..bd2475e49b9037f8521fc94ce34257a1acf5fdeb 100644 --- a/lib/gfx/GUI_DEV/DEV_Config.c +++ b/lib/gfx/GUI_DEV/DEV_Config.c @@ -76,39 +76,43 @@ void DEV_Set_BL(uint16_t _Value) gpio_cfg_t gpio_pwm; // to configure GPIO tmr_cfg_t tmr; // to congigure timer tmr_pwm_cfg_t tmr_pwm; // for configure PWM - unsigned int period_ticks = PeripheralClock / FREQ; - unsigned int duty_ticks = period_ticks * _Value / 1000; - - // Congfigure GPIO port and pin for PWM - gpio_pwm.func = GPIO_FUNC_ALT4; - gpio_pwm.port = PORT_PWM; - gpio_pwm.mask = PIN_PWM; - gpio_pwm.pad = GPIO_PAD_PULL_DOWN; - GPIO_Config(&gpio_pwm); + if (_Value > 100) { + _Value = 100; + } - /* - Steps for configuring a timer for PWM mode: - 1. Disable the timer - 2. Set the prescale value - 3. Configure the timer for PWM mode - 4. Set polarity, pwm parameters - 5. Enable Timer - */ + unsigned int period_ticks = PeripheralClock / FREQ; + unsigned int duty_ticks = period_ticks * _Value / 100; TMR_Disable(PWM_TIMER); - TMR_Init(PWM_TIMER, TMR_PRES_1, 0); + if (duty_ticks > 0) { + // Congfigure GPIO port and pin for PWM + gpio_pwm.func = GPIO_FUNC_ALT4; + gpio_pwm.port = PORT_PWM; + gpio_pwm.mask = PIN_PWM; + gpio_pwm.pad = GPIO_PAD_PULL_DOWN; + GPIO_Config(&gpio_pwm); + + TMR_Init(PWM_TIMER, TMR_PRES_1, 0); - tmr.mode = TMR_MODE_PWM; - tmr.cmp_cnt = period_ticks; - tmr.pol = 0; - TMR_Config(PWM_TIMER, &tmr); + tmr.mode = TMR_MODE_PWM; + tmr.cmp_cnt = period_ticks; + tmr.pol = 0; + TMR_Config(PWM_TIMER, &tmr); - tmr_pwm.pol = 1; - tmr_pwm.per_cnt = period_ticks; - tmr_pwm.duty_cnt = duty_ticks; + tmr_pwm.pol = 1; + tmr_pwm.per_cnt = period_ticks; + tmr_pwm.duty_cnt = duty_ticks; - TMR_PWMConfig(PWM_TIMER, &tmr_pwm); - TMR_Enable(PWM_TIMER); + TMR_PWMConfig(PWM_TIMER, &tmr_pwm); + TMR_Enable(PWM_TIMER); + } else { + gpio_pwm.func = GPIO_FUNC_OUT; + gpio_pwm.port = PORT_PWM; + gpio_pwm.mask = PIN_PWM; + gpio_pwm.pad = GPIO_PAD_PULL_DOWN; + GPIO_Config(&gpio_pwm); + GPIO_OutClr(&gpio_pwm); + } } diff --git a/lib/gfx/LCD/LCD_Driver.c b/lib/gfx/LCD/LCD_Driver.c index 481d6929ffdca96dc4711788621200d9faecd9b9..55c872a824ad9ef355bdb9eb4db7018c6d44eeaa 100644 --- a/lib/gfx/LCD/LCD_Driver.c +++ b/lib/gfx/LCD/LCD_Driver.c @@ -50,7 +50,7 @@ static void LCD_Reset(void) function: Setting backlight parameter : - value : Range 0~1000 Duty cycle is value/1000 + value : Range 0~100 Duty cycle is value/100 *******************************************************************************/ void LCD_SetBacklight(UWORD Value) { diff --git a/pycardium/modules/py/display.py b/pycardium/modules/py/display.py index d6b5386477f5bd08d9fe94583b7e331538cf320c..e957977d6fc3603889f3155e515d351dc8f1753b 100644 --- a/pycardium/modules/py/display.py +++ b/pycardium/modules/py/display.py @@ -95,7 +95,7 @@ class Display: """ Set display backlight brightness - :param brightness: backlight brightness 0 <= brightness <= 1000 + :param brightness: backlight brightness 0 <= brightness <= 100 """ sys_display.backlight(brightness)