zaher Posted October 15, 2018 Report Share Posted October 15, 2018 I just realized that everything is being displayed like this on my LCD. This is the result of calling: gdispClear(White); gdispFlush(); These are the defines I have enabled in the _GDISP_LLD_CONFIG_H file: #define GDISP_HARDWARE_FLUSH TRUE // This controller requires flushing #define GDISP_HARDWARE_DRAWPIXEL TRUE #define GDISP_HARDWARE_PIXELREAD TRUE #define GDISP_HARDWARE_CONTROL TRUE #define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_GRAY16 And here is what I have enabled in gfxconf.h: #define GFX_USE_OS_FREERTOS TRUE #define GFX_OS_NO_INIT TRUE /////////////////////////////////////////////////////////////////////////// // GDISP // /////////////////////////////////////////////////////////////////////////// #define GFX_USE_GDISP TRUE #define GDISP_NEED_AUTOFLUSH FALSE //#define GDISP_NEED_TIMERFLUSH FALSE #define GDISP_NEED_VALIDATION TRUE #define GDISP_NEED_CLIP TRUE #define GDISP_NEED_CIRCLE TRUE #define GDISP_NEED_DUALCIRCLE TRUE #define GDISP_NEED_ELLIPSE TRUE #define GDISP_NEED_ARC TRUE #define GDISP_NEED_ARCSECTORS TRUE #define GDISP_NEED_CONVEX_POLYGON TRUE #define GDISP_NEED_SCROLL TRUE #define GDISP_NEED_PIXELREAD TRUE #define GDISP_NEED_CONTROL TRUE #define GDISP_NEED_TEXT TRUE #define GDISP_NEED_ANTIALIAS TRUE #define GDISP_NEED_UTF8 TRUE #define GDISP_INCLUDE_FONT_UI1 TRUE #define GDISP_INCLUDE_FONT_UI2 TRUE // The smallest preferred font. #define GDISP_INCLUDE_FONT_UI1 TRUE #define GDISP_INCLUDE_FONT_UI2 TRUE // The smallest preferred font. #define GDISP_NEED_STARTUP_LOGO TRUE #define GDISP_TOTAL_DISPLAYS 1 Any ideas? Link to comment Share on other sites More sharing options...
zaher Posted October 16, 2018 Author Report Share Posted October 16, 2018 This is another screenshot. Link to comment Share on other sites More sharing options...
inmarket Posted October 17, 2018 Report Share Posted October 17, 2018 What type of physical interface do you have to your display? Eg i2c, spirit, 8 bit parallel. Link to comment Share on other sites More sharing options...
zaher Posted October 17, 2018 Author Report Share Posted October 17, 2018 It is a 3-wire half-duplex SPI Link to comment Share on other sites More sharing options...
inmarket Posted October 18, 2018 Report Share Posted October 18, 2018 It looks like the column order on your display might be a bit different to the standard arrangement. Check the initialisation sequence particularly around the column order settings. The other place to look is around the spi data format eg if you are outputting 9 bit spi bit the controller expects 8 bit spi (or visa versa) you will get similar symptoms. Link to comment Share on other sites More sharing options...
zaher Posted October 19, 2018 Author Report Share Posted October 19, 2018 Here is my SPI init code: static void MX_SPI2_Init(void) { hspi2.Instance = SPI2; hspi2.Init.Mode = SPI_MODE_MASTER; hspi2.Init.Direction = SPI_DIRECTION_1LINE; hspi2.Init.DataSize = SPI_DATASIZE_8BIT; hspi2.Init.CLKPolarity = SPI_POLARITY_LOW; hspi2.Init.CLKPhase = SPI_PHASE_1EDGE; hspi2.Init.NSS = SPI_NSS_SOFT; hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi2.Init.TIMode = SPI_TIMODE_DISABLE; hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi2.Init.CRCPolynomial = 7; if (HAL_SPI_Init(&hspi2) != HAL_OK) { Error_Handler(); } } I tried with many different prescalers (4, 16, 32), datasize, clock polarity, nothing worked. And by the way, since the drawing functions from an existing SSD1322 driver work out of the box on the current SPI setup, I doubt the interface has anything to do with it. And this is the init sequence for the SSD1322: LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { // The private area is the display surface. g->priv = gfxAlloc(GDISP_SCREEN_HEIGHT * SSD1322_ROW_WIDTH); // Initialise the board interface init_board(g); post_init_board(g); // Hardware reset HAL_GPIO_WritePin(LCD_RESET_GPIO_Port, LCD_RESET_Pin, SET); HAL_Delay(50); HAL_GPIO_WritePin(LCD_RESET_GPIO_Port, LCD_RESET_Pin, RESET); HAL_Delay(100); HAL_GPIO_WritePin(LCD_RESET_GPIO_Port, LCD_RESET_Pin, SET); HAL_Delay(40); write_cmd(g,CMD_SET_COMMAND_LOCK); write_data(g,0x12); // Unlock OLED driver IC write_cmd(g,CMD_SET_DISPLAY_OFF); write_cmd(g,CMD_SET_CLOCK_DIVIDER); write_data(g,0x91); write_cmd(g,CMD_SET_MULTIPLEX_RATIO); write_data(g,0x3F); //duty = 1/64*,64 COMS are enabled write_cmd(g,CMD_SET_DISPLAY_OFFSET); write_data(g,0x00); write_cmd(g,CMD_SET_DISPLAY_START_LINE); //set start line position write_data(g,0x00); write_cmd(g,CMD_SET_REMAP); write_data(g,0x14); //Horizontal address increment,Disable Column Address Re-map,Enable Nibble Re-map,Scan from COM[N-1] to COM0,Disable COM Split Odd Even write_data(g,0x11); //Enable Dual COM mode write_cmd(g,0xB5); //GPIO write_data(g,0x00); //writeCommand(0x00); write_cmd(g,CMD_SET_FUNCTION_SELECTION); write_data(g,0x01);// selection external VDD write_cmd(g,CMD_DISPLAY_ENHANCEMENT); write_data(g,0xA0);// enables the external VSL write_data(g,0xb5);// 0xfd,Enhanced low GS display quality;default is 0xb5(normal), write_cmd(g,CMD_SET_CONTRAST_CURRENT); write_data(g,0x7f); // 0xff default is 0x7f write_cmd(g,CMD_MASTER_CURRENT_CONTROL); write_data(g,0x0f); //default is 0x0f write_cmd(g,0xB9); //GRAY TABLE,linear Gray Scale write_cmd(g,CMD_SET_PHASE_LENGTH); write_data(g,0xE2); // default is 0x74 write_cmd(g,CMD_DISPLAY_ENHANCEMENT_B); write_data(g,0xA2); // Reserved;default is 0xa2(normal) write_data(g,0x20); write_cmd(g,CMD_SET_PRECHARGE_VOLTAGE); write_data(g,0x1F); // 0.6xVcc write_cmd(g,CMD_SET_SECOND_PRECHARGE_PERIOD); write_data(g,0x08); // default write_cmd(g,CMD_SET_VCOMH_VOLTAGE ); write_data(g,0x07); // 0.86xVcc;default is 0x04 write_cmd(g,CMD_SET_DISPLAY_MODE_NORMAL); write_cmd(g,CMD_EXIT_PARTIAL_DISPLAY); write_cmd(g,CMD_SET_DISPLAY_ON); // Finish Init post_init_board(g); /* Initialise the GDISP structure */ g->g.Width = GDISP_SCREEN_WIDTH; g->g.Height = GDISP_SCREEN_HEIGHT; g->g.Orientation = GDISP_ROTATE_0; g->g.Powermode = powerOn; g->g.Backlight = GDISP_INITIAL_BACKLIGHT; g->g.Contrast = GDISP_INITIAL_CONTRAST; return TRUE; } Link to comment Share on other sites More sharing options...
zaher Posted October 19, 2018 Author Report Share Posted October 19, 2018 This is the result of drawing a line executing the following: gdispDrawLine(0, 20, 100, 20, White); Link to comment Share on other sites More sharing options...
inmarket Posted October 19, 2018 Report Share Posted October 19, 2018 Have a look at the CMD_SET_REMAP. The value 0x14 may not match your display. Link to comment Share on other sites More sharing options...
zaher Posted October 20, 2018 Author Report Share Posted October 20, 2018 Unfortunately, it is exactly the same (0x14, 0x11 ), for my existing driver. Any other proposals? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now