SSD1963, lv_disp_drv_register, getting started.....crash

Description

Trying to get the Arduino getting started into example working

What MCU/Processor/Board and compiler are you using?

Arduino Nano 33 BLE. Using the Arduino IDE 1.8.13. Screen is a 7" SSD1963 with touch: 7"Arduino Touch Screen Shield w/SSD1963,Library for Mega/Due

The screen works well with just MCUFriend_kbv. I’m trying to use MCUFriend_kbv rather than TFT_Espi because I was never able to get that working with my boards.

What do you want to achieve?

Initially, just get the “Hello world” app and demos running. At the #ifdef point, it tells me that USE_SSD1963 is not defined.

What have you tried so far?

Started from scratch, to revert any mistakes I’d made. Searched for SSD1963 and LVGL and Nano 33 BLE. Added debug text to check how far the code had got.

Code to reproduce

Add the relevant code snippets here.

REDIRECT_STDOUT_TO(Serial)

#include <MCUFRIEND_kbv.h>

// screen globals
MCUFRIEND_kbv tft;
#define backlightPin A7
// end screen globals

// colours
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
// end of colours


#include <lvgl.h>



/*If you want to use the LVGL examples,
  make sure to install the lv_examples Arduino library
  and uncomment the following line.
  #include <lv_examples.h>
*/

//#include <lv_demo.h>

/*Change to your screen resolution*/
static const uint32_t screenWidth  = 480;
static const uint32_t screenHeight = 320;
static const int bufferSize =  screenWidth * screenHeight / 10;
static lv_disp_draw_buf_t draw_buf;
static lv_color_t buf[ bufferSize ];

#if LV_USE_LOG != 0
/* Serial debugging */
void my_print( lv_log_level_t level, const char * file, uint32_t line, const char * fn_name, const char * dsc )
{
  printf( "%s(%s)@%d->%s\r\n", file, fn_name, line, dsc );
  Serial.flush();
}

void my_print( const char* message )
{
  Serial.println(message);
  tft.print("****");tft.print(message);tft.println("***");
  Serial.flush();
}
#endif

/* Display flushing */
void my_disp_flush( lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p )
{
  uint32_t w = ( area->x2 - area->x1 + 1 );
  uint32_t h = ( area->y2 - area->y1 + 1 );

  Serial.println("into my_disp_flush");
  tft.startWrite();
  tft.setAddrWindow( area->x1, area->y1, w, h );
  tft.pushColors( ( uint16_t * )&color_p->full, w * h, true );
  tft.endWrite();

  lv_disp_flush_ready( disp );
  Serial.println("leaving my_disp_flush");
}

/*Read the touchpad*/
void my_touchpad_read( lv_indev_drv_t * indev_driver, lv_indev_data_t * data )
{
  //   uint16_t touchX, touchY;
  //
  //   bool touched = tft.getTouch( &touchX, &touchY, 600 );
  //
  //   if( !touched )
  //   {
  data->state = LV_INDEV_STATE_REL;
  //   }
  //   else
  //   {
  //      data->state = LV_INDEV_STATE_PR;
  //
  //      /*Set the coordinates*/
  //      data->point.x = touchX;
  //      data->point.y = touchY;
  //
  //      Serial.print( "Data x " );
  //      Serial.println( touchX );
  //
  //      Serial.print( "Data y " );
  //      Serial.println( touchY );
  //   }
}

void startSerial()
{
  Serial.begin( 115200 ); /* prepare for possible serial debug */
  int start = millis();
  while (!Serial && millis() - start < 5000);
  Serial.println("started...");
}

void setup()
{
  startSerial(); /* prepare for possible serial debug */
  Serial.println( "Hello Arduino! (V8.0.X)" );
  Serial.println( "I am LVGL_Arduino" );

  lv_init();

#if LV_USE_LOG != 0
  lv_log_register_print_cb( my_print ); /* register print function for debugging */
#endif

  uint16_t ID = tft.readID();
  if (ID == 0xD3D3) {
    ID = 0x1963;
  }
  tft.begin(ID);

  pinMode(backlightPin, OUTPUT);     //backlight
  digitalWrite(backlightPin, HIGH);  //on

  tft.setRotation(0);
  tft.fillScreen(BLUE);
  tft.setTextColor(GREEN);
  tft.setCursor(100,10);
  tft.setTextSize(2);
  
#ifndef USE_SSD1963
  tft.println("USE_SSD1963 not defined ***");
#else
  tft.println("USE_SSD1963 IS defined");
#endif

  /*Set the touchscreen calibration data,
    the actual data for your display can be aquired using
    the Generic -> Touch_calibrate example from the TFT_eSPI library*/
  uint16_t calData[5] = { 275, 3620, 264, 3532, 1 };
  //tft.setTouch( calData );

  tft.println("intialise buffer");
  lv_disp_draw_buf_init( &draw_buf, buf, NULL, bufferSize );
  tft.println("buffer initialised");

  /*Initialize the display*/
  static lv_disp_drv_t disp_drv;
  lv_disp_drv_init( &disp_drv );
  tft.println("driver initialised");
  
  /*Change the following line to your display resolution*/
  disp_drv.hor_res = screenWidth;
  disp_drv.ver_res = screenHeight;

  tft.println("set flush function");
  disp_drv.flush_cb = my_disp_flush;
  tft.println("flush function set");
  
  disp_drv.draw_buf = &draw_buf;
  tft.println("pointer to draw buffer set");


  tft.print("about to register driver");
  lv_disp_drv_register( &disp_drv );
  tft.println("driver registered");

  /*Initialize the (dummy) input device driver*/
  static lv_indev_drv_t indev_drv;
  lv_indev_drv_init( &indev_drv );
  indev_drv.type = LV_INDEV_TYPE_POINTER;
  indev_drv.read_cb = my_touchpad_read;
  lv_indev_drv_register( &indev_drv );
 Serial.println("touch driver registered");

#if 1
  /* Create simple label */
  lv_obj_t *label = lv_label_create( lv_scr_act() );
  lv_label_set_text( label, "Hello Arduino! (V8.0.X)" );
  lv_obj_align( label, LV_ALIGN_CENTER, 0, 0 );
  printf("label done\n");
  Serial.println("label displayed");
#else
  /* Try an example from the lv_examples Arduino library
     make sure to include it as written above.
    lv_example_btn_1();
  */

  // uncomment one of these demos
  // lv_demo_widgets();            // OK
  // lv_demo_benchmark();          // OK
  // lv_demo_keypad_encoder();     // works, but I haven't an encoder
  // lv_demo_music();              // NOK
  // lv_demo_printer();
  // lv_demo_stress();             // seems to be OK
#endif
  Serial.println( "Setup done" );
}

void loop()
{
  lv_timer_handler(); /* let the GUI do its work */
  delay( 5 );
}

Screenshot and/or video

The following text is churned out on the Serial port

started...
Hello Arduino! (V8.0.X)
I am LVGL_Arduino
into lv_disp_driv_init
into lv_disp_driv_init
started...
Hello Arduino! (V8.0.X)
I am LVGL_Arduino
into lv_disp_driv_init
[Trace]	(2.805, +1326)	 lv_mem_alloc: allocating 352 bytes 	(in lv_mem.c line #118)

The into lv_disp_driv_init is added inside void lv_disp_drv_init(lv_disp_drv_t * driver) in lvl\src\ lv_hal_disp.c.

any suggestions anyone?