1919
2020LOG_MODULE_REGISTER (auxdisplay_jhd1313 , CONFIG_AUXDISPLAY_LOG_LEVEL );
2121
22- #define JHD1313_BACKLIGHT_ADDR (0x62)
23-
2422/* Defines for the JHD1313_CMD_CURSOR_SHIFT */
2523#define JHD1313_CS_DISPLAY_SHIFT (1 << 3)
2624#define JHD1313_CS_RIGHT_SHIFT (1 << 2)
@@ -73,6 +71,7 @@ struct auxdisplay_jhd1313_data {
7371struct auxdisplay_jhd1313_config {
7472 struct auxdisplay_capabilities capabilities ;
7573 struct i2c_dt_spec bus ;
74+ uint8_t backlight_addr ;
7675};
7776
7877static const uint8_t colour_define [][4 ] = {
@@ -83,11 +82,13 @@ static const uint8_t colour_define[][4] = {
8382 { 0 , 0 , 255 }, /* Blue */
8483};
8584
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 )
8786{
87+ const struct auxdisplay_jhd1313_config * config = dev -> config ;
88+ const struct device * i2c = config -> bus .bus ;
8889 uint8_t command [2 ] = { addr , data };
8990
90- i2c_write (i2c , command , sizeof (command ), JHD1313_BACKLIGHT_ADDR );
91+ i2c_write (i2c , command , sizeof (command ), config -> backlight_addr );
9192}
9293
9394static 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
202203
203204static int auxdisplay_jhd1313_backlight_set (const struct device * dev , uint8_t colour )
204205{
205- const struct auxdisplay_jhd1313_config * config = dev -> config ;
206206 struct auxdisplay_jhd1313_data * data = dev -> data ;
207207
208208 if (colour >= ARRAY_SIZE (colour_define )) {
@@ -212,9 +212,9 @@ static int auxdisplay_jhd1313_backlight_set(const struct device *dev, uint8_t co
212212
213213 data -> backlight = colour ;
214214
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 ]);
218218
219219 return 0 ;
220220}
@@ -296,9 +296,9 @@ static int auxdisplay_jhd1313_initialize(const struct device *dev)
296296
297297 /* Now power on the background RGB control */
298298 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 );
302302
303303 /* Now set the background colour to black */
304304 LOG_DBG ("Background set to off" );
@@ -361,6 +361,7 @@ static DEVICE_API(auxdisplay, auxdisplay_jhd1313_auxdisplay_api) = {
361361 .custom_characters = 0, \
362362 }, \
363363 .bus = I2C_DT_SPEC_INST_GET(inst), \
364+ .backlight_addr = DT_INST_PROP(inst, backlight_addr), \
364365 }; \
365366 static struct auxdisplay_jhd1313_data auxdisplay_jhd1313_data_##inst = { \
366367 .power = true, \
0 commit comments