19
19
20
20
LOG_MODULE_REGISTER (auxdisplay_jhd1313 , CONFIG_AUXDISPLAY_LOG_LEVEL );
21
21
22
- #define JHD1313_BACKLIGHT_ADDR (0x62)
23
-
24
22
/* Defines for the JHD1313_CMD_CURSOR_SHIFT */
25
23
#define JHD1313_CS_DISPLAY_SHIFT (1 << 3)
26
24
#define JHD1313_CS_RIGHT_SHIFT (1 << 2)
@@ -73,6 +71,7 @@ struct auxdisplay_jhd1313_data {
73
71
struct auxdisplay_jhd1313_config {
74
72
struct auxdisplay_capabilities capabilities ;
75
73
struct i2c_dt_spec bus ;
74
+ uint8_t backlight_addr ;
76
75
};
77
76
78
77
static const uint8_t colour_define [][4 ] = {
@@ -83,11 +82,13 @@ static const uint8_t colour_define[][4] = {
83
82
{ 0 , 0 , 255 }, /* Blue */
84
83
};
85
84
86
- static void auxdisplay_jhd1313_reg_set (const struct device * i2c , uint8_t addr , uint8_t data )
85
+ static void auxdisplay_jhd1313_reg_set (const struct device * dev , uint8_t addr , uint8_t data )
87
86
{
87
+ const struct auxdisplay_jhd1313_config * config = dev -> config ;
88
+ const struct device * i2c = config -> bus .bus ;
88
89
uint8_t command [2 ] = { addr , data };
89
90
90
- i2c_write (i2c , command , sizeof (command ), JHD1313_BACKLIGHT_ADDR );
91
+ i2c_write (i2c , command , sizeof (command ), config -> backlight_addr );
91
92
}
92
93
93
94
static int auxdisplay_jhd1313_print (const struct device * dev , const uint8_t * data , uint16_t size )
@@ -202,7 +203,6 @@ static void auxdisplay_jhd1313_input_state_set(const struct device *dev, uint8_t
202
203
203
204
static int auxdisplay_jhd1313_backlight_set (const struct device * dev , uint8_t colour )
204
205
{
205
- const struct auxdisplay_jhd1313_config * config = dev -> config ;
206
206
struct auxdisplay_jhd1313_data * data = dev -> data ;
207
207
208
208
if (colour >= ARRAY_SIZE (colour_define )) {
@@ -212,9 +212,9 @@ static int auxdisplay_jhd1313_backlight_set(const struct device *dev, uint8_t co
212
212
213
213
data -> backlight = colour ;
214
214
215
- auxdisplay_jhd1313_reg_set (config -> bus . bus , JHD1313_LED_REG_R , colour_define [colour ][0 ]);
216
- auxdisplay_jhd1313_reg_set (config -> bus . bus , JHD1313_LED_REG_G , colour_define [colour ][1 ]);
217
- auxdisplay_jhd1313_reg_set (config -> bus . bus , JHD1313_LED_REG_B , colour_define [colour ][2 ]);
215
+ auxdisplay_jhd1313_reg_set (dev , JHD1313_LED_REG_R , colour_define [colour ][0 ]);
216
+ auxdisplay_jhd1313_reg_set (dev , JHD1313_LED_REG_G , colour_define [colour ][1 ]);
217
+ auxdisplay_jhd1313_reg_set (dev , JHD1313_LED_REG_B , colour_define [colour ][2 ]);
218
218
219
219
return 0 ;
220
220
}
@@ -296,9 +296,9 @@ static int auxdisplay_jhd1313_initialize(const struct device *dev)
296
296
297
297
/* Now power on the background RGB control */
298
298
LOG_INF ("Configuring the RGB background" );
299
- auxdisplay_jhd1313_reg_set (config -> bus . bus , 0x00 , 0x00 );
300
- auxdisplay_jhd1313_reg_set (config -> bus . bus , 0x01 , 0x05 );
301
- auxdisplay_jhd1313_reg_set (config -> bus . bus , 0x08 , 0xAA );
299
+ auxdisplay_jhd1313_reg_set (dev , 0x00 , 0x00 );
300
+ auxdisplay_jhd1313_reg_set (dev , 0x01 , 0x05 );
301
+ auxdisplay_jhd1313_reg_set (dev , 0x08 , 0xAA );
302
302
303
303
/* Now set the background colour to black */
304
304
LOG_DBG ("Background set to off" );
@@ -361,6 +361,7 @@ static DEVICE_API(auxdisplay, auxdisplay_jhd1313_auxdisplay_api) = {
361
361
.custom_characters = 0, \
362
362
}, \
363
363
.bus = I2C_DT_SPEC_INST_GET(inst), \
364
+ .backlight_addr = DT_INST_PROP(inst, backlight_addr), \
364
365
}; \
365
366
static struct auxdisplay_jhd1313_data auxdisplay_jhd1313_data_##inst = { \
366
367
.power = true, \
0 commit comments