zump Posted December 7, 2013 Report Share Posted December 7, 2013 I am trying to get the Sharp LCD LS010B7DH01 working with uGFX, ChibiOS 2.6.1 and STM32L151CB. It is quite a basic display. There are no special features, and one can write lines to the memory with the following SPI bytestream.Write command byte, line address, 16 bytes of pixel data, 2 dummy bytes. http://www.avnet-embedded.eu/fileadmin/user_upload/Files/Displays/Mono/Sharp_LS010B7DH01.pdf (Datasheet)Here are relevant excerpts from gdisp_lld_*.c /*===========================================================================*//* Driver local definitions. *//*===========================================================================*/#ifndef GDISP_SCREEN_HEIGHT #define GDISP_SCREEN_HEIGHT 128 // This controller should support 32 (untested) or 64#endif#ifndef GDISP_SCREEN_WIDTH #define GDISP_SCREEN_WIDTH 128#endif#define LS010_LINE_WIDTH GDISP_SCREEN_WIDTH/8#define GDISP_FLG_NEEDFLUSH (GDISP_FLG_DRIVER<<0)#include "LS010.h"/*===========================================================================*//* Driver local functions. *//*===========================================================================*/// Some common routines and macros#define RAM(g) ((uint8_t *)g->priv)// Some common routines and macros#define delay(us) gfxSleepMicroseconds(us)#define delayms(ms) gfxSleepMilliseconds(ms)#define xyaddr(x, y) (x + y * GDISP_SCREEN_WIDTH) / 8#define xybit(x, y) (1 << ((x + y * GDISP_SCREEN_WIDTH) % 8))/*===========================================================================*//* Driver exported functions. *//*===========================================================================*/LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { // The private area is the display surface. g->priv = gfxAlloc(2048); lcd_init(&handle_lcd); // <--- My initialisation function which successfully turns LCD on acquire_bus(g); // Finish Init post_init_board(g); // Release the bus release_bus(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;}#if GDISP_HARDWARE_FLUSH LLDSPEC void gdisp_lld_flush(GDisplay *g) { unsigned i; uint8_t j = 128; //Address // Don't flush if we don't need it. if (!(g->flags & GDISP_FLG_NEEDFLUSH)) return; for(i=0; i < 2048; i += LS010_LINE_WIDTH) { write_data(g, RAM(g)+i, LS010_LINE_WIDTH, j); j--; } }#endif#if GDISP_HARDWARE_DRAWPIXEL LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) { coord_t x, y; int tmpx = xyaddr(g->p.x, g->p.y); int bit = xybit(g->p.x,g->p.y); switch(g->g.Orientation) { default: case GDISP_ROTATE_0: x = g->p.x; y = g->p.y; break; case GDISP_ROTATE_90: x = g->p.y; y = GDISP_SCREEN_HEIGHT-1 - g->p.x; break; case GDISP_ROTATE_180: x = GDISP_SCREEN_WIDTH-1 - g->p.x; y = GDISP_SCREEN_HEIGHT-1 - g->p.y; break; case GDISP_ROTATE_270: x = GDISP_SCREEN_HEIGHT-1 - g->p.y; x = g->p.x; break; } if (gdispColor2Native(g->p.color) != Black) { RAM(g)[xyaddr(x, y)] &= xybit(x,y); }else { RAM(g)[xyaddr(x, y)] |= ~xybit(x,y); g->flags |= GDISP_FLG_NEEDFLUSH; } }#endifand and board_*.hstatic uint8_t reverse(uint8_t b) { b = (b & 0xF0) >> 4 | (b & 0x0F) << 4; b = (b & 0xCC) >> 2 | (b & 0x33) << 2; b = (b & 0xAA) >> 1 | (b & 0x55) << 1; return b;}static inline void write_data(GDisplay *g, uint8_t* data, uint16_t length, uint8_t addr) { (void) g; uint8_t tmp[20] = {0}; // Command to write + address + 16 byte pixel data + 2 dummy bytes tmp[0] = 0b10000000; // Command to write tmp[1] = reverse(addr); // LSB first memmove(tmp+2, data, 16); spiUnselect(&SPID1); chThdSleepMicroseconds(SCS_HIGH_DELAY); spiSend(&SPID1, 20, tmp); chThdSleepMicroseconds(SCS_LOW_DELAY); spiSelect(&SPID1); chThdSleepMicroseconds(INTERFRAME_DELAY);}However, I am not able to get correct output. For example, here is the output when running the 'basics' example.Can anyone see something wrong here? Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted December 7, 2013 Report Share Posted December 7, 2013 I'm seeing several things there that are not the way they are supposed to be (not in any order of importance): What is handle_lcd? Refering to your lcd_init(&handle_lcd); You never call the board_init(). This is the place where you are supposed to set up your pin configuration and other peripherals. You do not reset your display after you called your board_init() (which you currently don't). Even if your LCD does require a non-value based initialisation, it's supposed to be inside gdisp_lld_init(). If you need to set different pins like the enable one, just add those calls to the board file. The driver must be as generic as possible. The command byte to draw a line is supposed to be send through the write_cmd() call in your board file. Please refer to the SSD1306 driver to see how it's supposed to be done properly. In your write_data() routine, you unselect the SPI slave, write to it and then select it. It's supposed to be the other way around. Please refer to the ChibiOS/RT HAL documentation for further information.All of the points above are without looking at your actual algorithms or the datasheet. Please check those points first (most likely they won't solve your issue, but it's hard to debug your code in this "messy" state).I suggest you to take a close look the the existing SSD1306 driver as that one is VERY similar to yours. You shouldn't have to change a lot from there.~ Tectu Link to comment Share on other sites More sharing options...
inmarket Posted December 15, 2013 Report Share Posted December 15, 2013 It looks like the bit order is reversed relative to the display. In other words:Bit 0 is where Bit 7 should beBit 1 is where Bit 6 should beetcHope that helps. Link to comment Share on other sites More sharing options...
addi Posted April 16, 2014 Report Share Posted April 16, 2014 to zumpDear zumpI have some asking to you about Sharp LS010B7DH01 I saw your picture on this forum and it seems that your display have got more quality white colore then mineCan I ask you to do fotos when its works and not under normal light? Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted April 16, 2014 Report Share Posted April 16, 2014 Dear zumpI have some asking to you about Sharp LS010B7DH01 I saw your picture on this forum and it seems that your display have got more quality white colore then mineCan I ask you to do fotos when its works and not under normal light?I recommend you to send a private message to zump so he gets an e-mail notification. You can do that by clicking on the username.~ Tectu Link to comment Share on other sites More sharing options...
addi Posted April 16, 2014 Report Share Posted April 16, 2014 Unfortunately I cant do that( Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted April 16, 2014 Report Share Posted April 16, 2014 What's exactly the problem?~ Tectu Link to comment Share on other sites More sharing options...
addi Posted April 17, 2014 Report Share Posted April 17, 2014 I cant write message yet on this forum , maybe because of too low quantity of messages that I have got on this forum Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted April 17, 2014 Report Share Posted April 17, 2014 I checked your permission and I don't see any problem there. I even tried it out myself (with your permission and it seems to work).Don't you find the necessary button/link or do you get any error message?~ Tectu Link to comment Share on other sites More sharing options...
addi Posted April 18, 2014 Report Share Posted April 18, 2014 Thanks to Tectu!I have just wrote the private message to zimp Link to comment Share on other sites More sharing options...
umitgun Posted May 13, 2017 Report Share Posted May 13, 2017 Hello everyone i know this post is too old but i have the same problem .Do you know anyone how can i solve this problem Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted May 13, 2017 Report Share Posted May 13, 2017 Hello @umitgun and welcome to the µGFX community! Could you do me a favor and simply creating a new topic that contains all the information about what exactly you're working with (exact display controller/driver type, what microcontroller, what underlying system (eg. baremetal or which RTOS), your driver and everything else that would help us resolving your problem. Don't forget a detailed description of what the problem actually is Looking forward helping you resolving your problem. 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