Skip to content

Commit 203d262

Browse files
committed
disable pwm if oled screen
1 parent 7f7edee commit 203d262

File tree

5 files changed

+41
-16
lines changed

5 files changed

+41
-16
lines changed

fw/application/src/app/settings/scene/settings_scene_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
ADD_SCENE(settings, main, MAIN)
22
ADD_SCENE(settings, version, VERSION)
33
ADD_SCENE(settings, sleep_timeout, SLEEP_TIMEOUT)
4+
#ifdef LCD_SCREEN
45
ADD_SCENE(settings, lcd_backlight, LCD_BACKLIGHT)
6+
#endif
57
#ifdef OLED_SCREEN
68
ADD_SCENE(settings, oled_contrast, OLED_CONTRAST)
79
#endif

fw/application/src/app/settings/scene/settings_scene_lcd_backlight.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "mui_u8g2.h"
1111
#include "i18n/language.h"
1212

13+
#ifdef LCD_SCREEN
14+
1315
static void settings_scene_lcd_backlight_event_cb(mui_progress_bar_event_t event, mui_progress_bar_t *p_progress_bar) {
1416
app_settings_t *app = p_progress_bar->user_data;
1517
settings_data_t *p_settings = settings_get_data();
@@ -38,4 +40,6 @@ void settings_scene_lcd_backlight_on_enter(void *user_data) {
3840
void settings_scene_lcd_backlight_on_exit(void *user_data) {
3941
app_settings_t *app = user_data;
4042
mui_progress_bar_reset(app->p_progress_bar);
41-
}
43+
}
44+
45+
#endif

fw/application/src/app/settings/scene/settings_scene_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ static void settings_scene_main_list_view_on_selected(mui_list_view_event_t even
5959

6060
uint32_t selection = (uint32_t)p_item->user_data;
6161
switch (selection) {
62+
#ifdef LCD_SCREEN
6263
case SETTINGS_MAIN_MENU_BACK_LIGHT:
6364
mui_scene_dispatcher_next_scene(app->p_scene_dispatcher, SETTINGS_SCENE_LCD_BACKLIGHT);
6465
break;
66+
#endif
6567

6668
#ifdef OLED_SCREEN
6769
case SETTINGS_MAIN_MENU_OLED_CONTRAST:

fw/application/src/app/settings/scene/settings_scene_oled_contrast.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "mui_u8g2.h"
1111
#include "i18n/language.h"
1212

13+
#ifdef OLED_SCREEN
14+
1315
static void settings_scene_oled_contrast_event_cb(mui_progress_bar_event_t event, mui_progress_bar_t *p_progress_bar) {
1416
app_settings_t *app = p_progress_bar->user_data;
1517
settings_data_t *p_settings = settings_get_data();
@@ -38,4 +40,6 @@ void settings_scene_oled_contrast_on_enter(void *user_data) {
3840
void settings_scene_oled_contrast_on_exit(void *user_data) {
3941
app_settings_t *app = user_data;
4042
mui_progress_bar_reset(app->p_progress_bar);
41-
}
43+
}
44+
45+
#endif

fw/application/src/mui/mui_u8g2.c

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
u8g2_t u8g2;
8484
static spi_device_t m_dev;
8585
uint8_t m_u8g2_initialized = 0;
86+
87+
#ifdef LCD_SCREEN
8688
APP_PWM_INSTANCE(pwm1, 1); // Create the instance "PWM1" using TIMER1.
8789

8890
static ret_code_t pwm_init(void) {
@@ -106,12 +108,13 @@ static ret_code_t pwm_init(void) {
106108
app_pwm_enable(&pwm1);
107109
while (app_pwm_channel_duty_set(&pwm1, 0, init_duty) == NRF_ERROR_BUSY)
108110
;
109-
110111
}
111112

112113
return NRF_SUCCESS;
113114
}
114115

116+
#endif
117+
115118
uint8_t u8x8_HW_com_spi_nrf52832(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
116119
uint8_t u8g2_nrf_gpio_and_delay_spi_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
117120

@@ -184,35 +187,41 @@ void mui_u8g2_init(u8g2_t *p_u8g2) {
184187

185188
nrf_gpio_cfg_output(LCD_RESET_PIN);
186189
nrf_gpio_cfg_output(LCD_DC_PIN);
190+
191+
#ifdef LCD_SCREEN
187192
nrf_gpio_cfg_output(LCD_BL_PIN);
188193
nrf_gpio_pin_clear(LCD_BL_PIN);
189194

190-
#ifdef OLED_TYPE_SH1106
191-
u8g2_Setup_sh1106_128x64_noname_f(p_u8g2, U8G2_R0, u8x8_HW_com_spi_nrf52832, u8g2_nrf_gpio_and_delay_spi_cb);
192-
#else
193-
u8g2_Setup_st7567_enh_dg128064_f(p_u8g2, U8G2_R0, u8x8_HW_com_spi_nrf52832, u8g2_nrf_gpio_and_delay_spi_cb);
194-
#endif
195+
u8g2_Setup_st7567_enh_dg128064_f(p_u8g2, U8G2_R0, u8x8_HW_com_spi_nrf52832, u8g2_nrf_gpio_and_delay_spi_cb);
196+
u8g2_InitDisplay(p_u8g2);
197+
u8g2_SetPowerSave(p_u8g2, 0);
198+
199+
pwm_init();
200+
#endif
195201

202+
#ifdef OLED_SCREEN
203+
u8g2_Setup_sh1106_128x64_noname_f(p_u8g2, U8G2_R0, u8x8_HW_com_spi_nrf52832, u8g2_nrf_gpio_and_delay_spi_cb);
196204
u8g2_InitDisplay(p_u8g2);
197205

198-
#ifdef OLED_SCREEN
199-
settings_data_t *p_settings = settings_get_data();
200-
mui_u8g2_set_oled_contrast_level(p_settings->oled_contrast);
201-
#endif
206+
settings_data_t *p_settings = settings_get_data();
207+
mui_u8g2_set_oled_contrast_level(p_settings->oled_contrast);
202208

203209
u8g2_SetPowerSave(p_u8g2, 0);
204210

205-
pwm_init();
211+
#endif
206212
}
207213

208214
void mui_u8g2_deinit(u8g2_t *p_u8g2) {
209215
u8g2_SetPowerSave(p_u8g2, 1);
210216

217+
#ifdef LCD_SCREEN
211218
mui_u8g2_set_backlight_level(0);
212219
nrf_gpio_pin_clear(LCD_BL_PIN);
213220
nrf_gpio_cfg_default(LCD_BL_PIN);
221+
#endif
214222
}
215223

224+
#ifdef LCD_SCREEN
216225
void mui_u8g2_set_backlight(uint8_t bl) { nrf_gpio_pin_write(LCD_BL_PIN, bl); }
217226

218227
uint8_t mui_u8g2_get_backlight() { return nrf_gpio_pin_out_read(LCD_BL_PIN); }
@@ -228,9 +237,13 @@ void mui_u8g2_set_backlight_level(uint8_t value) {
228237
;
229238
}
230239
}
231-
int8_t mui_u8g2_get_backlight_level(void) { return (int8_t) app_pwm_channel_duty_get(&pwm1, 0); }
240+
int8_t mui_u8g2_get_backlight_level(void) { return (int8_t)app_pwm_channel_duty_get(&pwm1, 0); }
241+
242+
#endif
232243

244+
#ifdef OLED_SCREEN
233245
void mui_u8g2_set_oled_contrast_level(uint8_t value) {
234246
mui_t *p_mui = mui();
235-
u8g2_SetContrast(&p_mui->u8g2,(value - 1) * (255.0 / 99.0));
236-
}
247+
u8g2_SetContrast(&p_mui->u8g2, (value - 1) * (255.0 / 99.0));
248+
}
249+
#endif

0 commit comments

Comments
 (0)