This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is there a way to update text neatly using GFX driver?

Hello

I am using sdk17 and st7735 drivers in GFX example.

Later, I will add several UI to the display, but now I am simply outputting sensor values.  

Below is the code that simply updates the sensor value.  However, whenever text is updated, 'screen_clear()" blinks throughout the screen and makes it look bad.

When updating text on a screen, what method should I use to update text parts naturally? Is this method in sdk?

//st7735
// Some ready-made 16-bit ('565') color settings:
#define GRAY            0xC618
#define RED             0xF800
#define BLUE            0x001F
#define BLACK           0x0000
#define WHITE           0xFFFF
#define GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0
#define ORANGE          0xFC00

//static const char * test_text = "nRF52 family"; //test

extern const nrf_gfx_font_desc_t orkney_8ptFontInfo; //font
extern const nrf_lcd_t nrf_lcd_st7735;

static const nrf_gfx_font_desc_t * p_font = &orkney_8ptFontInfo;
static const nrf_lcd_t * p_lcd = &nrf_lcd_st7735;


static void gfx_initialization(void)
{
    APP_ERROR_CHECK(nrf_gfx_init(p_lcd));
}

char display_sensor[20];

static void display_sensor_print(void)
{
    sprintf(display_sensor, "%d", new_adc_value);
    nrf_gfx_point_t text_start = NRF_GFX_POINT(50,70); //position
    APP_ERROR_CHECK(nrf_gfx_print(p_lcd, &text_start, 0, display_sensor, p_font, true)); //instance, position, color, string, pont, wrap
}


static void screen_clear(void)
{
    nrf_gfx_screen_fill(p_lcd, WHITE);
}


int main(void)
{
    bool erase_bonds;
    uint32_t err_code;

    // Initialize.
    uart_init();
    log_init();
    timers_init();
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();

    // Start execution.
    printf("\r\nUART started.\r\n");
    NRF_LOG_INFO("Debug logging for UART over RTT started.");
    advertising_start();

    //saadc
    saadc_all_init();

    //st7735
    gfx_initialization();
    screen_clear();

    //test
    //char app_test[100];
    //int test_value = 5;

    // Enter main loop.
    for (;;)
    {
        idle_state_handle();

        if(new_adc_value > 0)
        {
              //display
              screen_clear(); //clear display
              display_sensor_print();

              new_adc_value = 0;
        }
    }
}

Thank you.

Parents Reply Children
No Data
Related