Hi,
am working on nrf52840 withst7789v custom display . I have integrated the my display code using lvgl library with PMIC code in zephyr . while doing that I have configure the backlight also but am not able to see anything on display my main.c, . overlay, & prj.conf are as follows:
main.c:
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/logging/log.h>
#include "g1193.h"
#include "nrfx_twim.h"
#include "Max20360.h"
#include <zephyr/drivers/display.h>
#include <string.h>
#include <zephyr/drivers/gpio.h>
//#define DISPLAY_WIDTH 240
//#define DISPLAY_HEIGHT 240
#include <lvgl.h>
#define TIMER_INSTANCE_ID 0
uint8_t Register_Value;
float Cell_Voltage, Soc;
uint8_t Reg_Data[1];
uint8_t Status4_Val;
uint8_t Status_Val[1];
uint32_t sample_count = 0;
uint32_t adc_sample[80] = {0};
LOG_MODULE_REGISTER(main);
extern double adc_volt[80];
const struct device *display;
// === Simple LVGL UI ===
void lvgl_ui_init(void)
{
lv_obj_t *label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "Hello LVGL!");
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
// Optional: fill screen bg color
lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0x0000FF), LV_PART_MAIN); // Blue
}
void main(void)
{
// LOG_INF("==== G11193 Sensor Demo Starting ====");//
g11193_init();
I2c_init();
PMIC_Init();
PMIC_PowerUP_Seq();
Set_LDO2_Out_Voltage();
Set_Buck1_Voltage();
Set_Buck2_Voltage();
Set_Buck3_Voltage();
Set_Boost_Voltage();
En_BuckBoost();
Config_En_Charger();
Config_PMIC_Leds();
// g_niglucose();
const struct device *gpio0 = DEVICE_DT_GET(DT_NODELABEL(gpio0));
if (!device_is_ready(gpio0)) {
printk("GPIO0 not ready\n");
return;
}
// Set P0.04 HIGH
gpio_pin_configure(gpio0, 4, GPIO_OUTPUT_ACTIVE);
printk(" P0.04 HIGH ? LCD power ON\n");
// Wait ~100ms for rail to stabilize
k_msleep(100);
// === Init display ===
display = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
if (!device_is_ready(display)) {
printk(" Display not ready\n");
return;
}
display_blanking_off(display);
printk(" Display ON & backlight should be ON\n");
// === Init LVGL ===
lv_init();
lvgl_ui_init();
// const struct device *display = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
// if (!device_is_ready(display))
// {
// printk(" Display not ready\n");
// return;
// }
// printk(" Display is ready, turning it on...\n");
// display_blanking_off(display);
//const struct display_buffer_descriptor desc = {
//.width = DISPLAY_WIDTH,
//.height = DISPLAY_HEIGHT,
//.pitch = DISPLAY_WIDTH,
// .buf_size = DISPLAY_WIDTH * DISPLAY_HEIGHT * 2, // RGB565
// };
// static uint8_t framebuffer[DISPLAY_WIDTH * DISPLAY_HEIGHT * 2];
// memset(framebuffer, 0xF8, sizeof(framebuffer)); // fill with red
// memset(framebuffer, 0x00, sizeof(framebuffer)); // clear all
// for (int i = 0; i < sizeof(framebuffer); i += 2)
// {
// framebuffer[i] = 0xF8; // MSB (Red 11111 = 0xF8)
// framebuffer[i + 1] = 0x00; // LSB (Green = 0, Blue = 0)
// }
// display_write(display, 0, 0, &desc, framebuffer);
// printk(" Framebuffer written (solid red)\n");
while (1)
{
g_niglucose();
// int16_t raw_val = 0;
// float millivolts;
// sample_count = 0;
// memset(adc_sample, 0, sizeof(adc_sample));
// while (sample_count < 80)
// {
// raw_val = g11193_read_raw();
// // if (g11193_read_raw() == 0)
// // {
// // LOG_INF("G11193 Raw ADC Value: %d", raw_val);
// // }
// // else
// // {
// // LOG_ERR("Failed to read raw ADC value");
// // }
// // the array holding the adc readings of the last 80 adc reading
// adc_sample[sample_count] = raw_val;
// sample_count++;
// float volt = g11193_read_millivolts();
// printf("G11193 Voltage: %f mV", volt);
// // if (f (g11193_read_millivolts() == 0)
// // {
// // printf("G11193 Voltage: %d mV", millivolts);
// // }() == 0)
// // {
// // printf("G11193 Voltage: %d mV", millivolts);
// // }
// // else
// // {
// // LOG_ERR("Failed to read voltage in mV");
// // }
// }
Cell_Voltage = Get_Cell_Voltage();
Soc = Get_SOC();
Register_Read(MAX20360_SLAVE_ADDR_PMIC, STATUS4, Status_Val);
Status4_Val = Status_Val[0];
if (Status4_Val == 0xC0)
{
Register_Write(MAX20360_SLAVE_ADDR_PMIC, LED2CTR, 0x20); // Green_Led_On
Register_Write(MAX20360_SLAVE_ADDR_PMIC, LED1CTR, 0x00); // Red Led_Off
}
if (Status4_Val == 0x80)
{
Register_Write(MAX20360_SLAVE_ADDR_PMIC, LED1CTR, 0x20); // Red Led_On
Register_Write(MAX20360_SLAVE_ADDR_PMIC, LED2CTR, 0x00); // Green_Led_Off
}
// k_msleep(100);
// want to increase the time between two adc reading please increase the delay
// inside K_sleep function
lv_task_handler();
k_msleep(10);
// k_sleep(K_SECONDS(1));
}
}
Board overlay
#include <zephyr/dt-bindings/mipi_dbi/mipi_dbi.h>
/ {
chosen {
zephyr,display = &st7789v;
};
};
&pinctrl {
spi2_default_alt: spi2_default_alt {
group1 {
psels = <NRF_PSEL(SPIM_MOSI,0,26)>,
<NRF_PSEL(SPIM_SCK, 1,8)>;
};
group2 {
psels = <NRF_PSEL(SPIM_MISO,1,14)>;
bias-pull-down;
};
};
spi2_sleep_alt: spi2_sleep_alt {
group1 {
psels = <NRF_PSEL(SPIM_MOSI,0,26)>,
<NRF_PSEL(SPIM_SCK, 1,8)>,
<NRF_PSEL(SPIM_MISO,1,14)>;
low-power-enable;
};
};
};
&spi2 {
compatible = "nordic,nrf-spim";
status = "okay";
clock-frequency = <16000000>;
cs-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
pinctrl-0 = <&spi2_default_alt>;
pinctrl-1 = <&spi2_sleep_alt>;
pinctrl-names = "default", "sleep";
mipi_dbi {
compatible = "zephyr,mipi-dbi-spi";
spi-dev = <&spi2>;
dc-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
reset-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
write-only;
#address-cells = <1>;
#size-cells = <0>;
st7789v: st7789v@0 {
compatible = "sitronix,st7789v";
reg = <0>;
mipi-max-frequency = <27000000>;
width = <240>;
height = <240>;
x-offset = <0>;
y-offset = <80>;
vcom = <0x19>;
gctrl = <0x35>;
vrhs = <0x10>;
vdvs = <0x20>;
mdac = <0x00>;
gamma = <0x01>;
colmod = <0x55>;
lcm = <0x2c>;
porch-param = [0c 0c 00 33 33];
cmd2en-param = [5a 69 02 01];
pwctrl1-param = [a4 a1];
pvgam-param = [d0 04 0d 11 13 2b 3f 54 4c 18 0d 0b 1f 23];
nvgam-param = [d0 04 0c 11 13 2c 3f 44 51 2f 1f 1f 20 23];
ram-param = [00 f0];
rgb-param = [cd 08 14];
mipi-mode = "MIPI_DBI_MODE_SPI_4WIRE";
};
};
};
&gpio1 {
status = "okay";
};
&gpio0 {
status = "okay";
};
&adc {
status = "okay";
};
prj.conf
# Display framework
CONFIG_DISPLAY=y
CONFIG_DISPLAY_LOG_LEVEL_DBG=y
CONFIG_NFCT_PINS_AS_GPIOS=y
CONFIG_ADC_ASYNC=y
# ST7789V driver via MIPI-DBI SPI interface
CONFIG_MIPI_DBI=y
#CONFIG_DISPLAY_CFB_LIBRARY=y
#CONFIG_CFB_FRAMEBUFFER=y
#CONFIG_CFB_LOG_LEVEL_DBG=y
CONFIG_ST7789V=y
CONFIG_ST7789V_RGB565=y
# SPI & GPIO drivers
CONFIG_SPI=y
CONFIG_SPI_NRFX=y
CONFIG_GPIO=y
CONFIG_ADC=y
CONFIG_SENSOR=y
# Enable only TWIM0 from nrfx
CONFIG_NRFX_TWIM0=y
# Disable Zephyr's I2C driver if you want pure nrfx control
CONFIG_I2C=y
# Enable TWI API in Zephyr
# CONFIG_I2C=y
# Enable TWI_NRFX (optional, but often needed)
# CONFIG_I2C_NRFX_TWIM=y
CONFIG_G11193=y
# CONFIG_G1193 = y
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_LVGL=y
CONFIG_LV_USE_LABEL=y
#CONFIG_LVGL_TICK_MS=1
# ST7789V driver via MIPI-DBI SPI interface
#CONFIG_MIPI_DBI=y
CONFIG_DISPLAY_LOG_LEVEL_INF=y
CONFIG_LV_Z_MEM_POOL_SIZE=16384
CONFIG_LV_Z_SHELL=y
Please provide the solution how i can get backlight and data on display ?