83
83
u8g2_t u8g2 ;
84
84
static spi_device_t m_dev ;
85
85
uint8_t m_u8g2_initialized = 0 ;
86
+
87
+ #ifdef LCD_SCREEN
86
88
APP_PWM_INSTANCE (pwm1 , 1 ); // Create the instance "PWM1" using TIMER1.
87
89
88
90
static ret_code_t pwm_init (void ) {
@@ -106,12 +108,13 @@ static ret_code_t pwm_init(void) {
106
108
app_pwm_enable (& pwm1 );
107
109
while (app_pwm_channel_duty_set (& pwm1 , 0 , init_duty ) == NRF_ERROR_BUSY )
108
110
;
109
-
110
111
}
111
112
112
113
return NRF_SUCCESS ;
113
114
}
114
115
116
+ #endif
117
+
115
118
uint8_t u8x8_HW_com_spi_nrf52832 (u8x8_t * u8x8 , uint8_t msg , uint8_t arg_int , void * arg_ptr );
116
119
uint8_t u8g2_nrf_gpio_and_delay_spi_cb (u8x8_t * u8x8 , uint8_t msg , uint8_t arg_int , void * arg_ptr );
117
120
@@ -184,35 +187,41 @@ void mui_u8g2_init(u8g2_t *p_u8g2) {
184
187
185
188
nrf_gpio_cfg_output (LCD_RESET_PIN );
186
189
nrf_gpio_cfg_output (LCD_DC_PIN );
190
+
191
+ #ifdef LCD_SCREEN
187
192
nrf_gpio_cfg_output (LCD_BL_PIN );
188
193
nrf_gpio_pin_clear (LCD_BL_PIN );
189
194
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
195
201
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 );
196
204
u8g2_InitDisplay (p_u8g2 );
197
205
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 );
202
208
203
209
u8g2_SetPowerSave (p_u8g2 , 0 );
204
210
205
- pwm_init ();
211
+ #endif
206
212
}
207
213
208
214
void mui_u8g2_deinit (u8g2_t * p_u8g2 ) {
209
215
u8g2_SetPowerSave (p_u8g2 , 1 );
210
216
217
+ #ifdef LCD_SCREEN
211
218
mui_u8g2_set_backlight_level (0 );
212
219
nrf_gpio_pin_clear (LCD_BL_PIN );
213
220
nrf_gpio_cfg_default (LCD_BL_PIN );
221
+ #endif
214
222
}
215
223
224
+ #ifdef LCD_SCREEN
216
225
void mui_u8g2_set_backlight (uint8_t bl ) { nrf_gpio_pin_write (LCD_BL_PIN , bl ); }
217
226
218
227
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) {
228
237
;
229
238
}
230
239
}
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
232
243
244
+ #ifdef OLED_SCREEN
233
245
void mui_u8g2_set_oled_contrast_level (uint8_t value ) {
234
246
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