Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template for new driver (support for S1D15E06 LCD) #1172

Closed
nopbit opened this issue Apr 27, 2020 · 15 comments
Closed

Template for new driver (support for S1D15E06 LCD) #1172

nopbit opened this issue Apr 27, 2020 · 15 comments
Milestone

Comments

@nopbit
Copy link

nopbit commented Apr 27, 2020

Hello,

Thanks for this wonderful library :) I would like to add support for a screen which i removed from an old telephone. It is using chip on glass S1D15E06 with 160x100dots resolution(4 gray scale). Display uses 4 pins Serial Input, Serial Clock, Command/Data and CS pin.

I created a simple test library with arduino and screen is working perfectly with it. Is there any driver template that i can change and add support for this display?

Best Regards
Mustafa

Datasheet for S1D15E06.
https://www.rockbox.org/wiki/pub/Main/DataSheets/epson_s1d15e06.pdf

@olikraus
Copy link
Owner

This device might be a good candidate:
https://github.com/olikraus/u8g2/blob/master/csrc/u8x8_d_uc1608.c#L473

@nopbit
Copy link
Author

nopbit commented Apr 28, 2020

I edited u8x8_d_uc1608_dem240064_init_seq procedure according to my lcd driver. Now i want to learn how to send data to LCD ? My sample code is like below. I am sending data with row & column. I believe i must play with msg type U8X8_MSG_DISPLAY_DRAW_TILE right?

My sample code:

uint8_t row = 0;
uint8_t col = 0;
uint8_t data=0;

_lcd_cmd2(LCD_CMD_PAGE_ADDR,1+(row<<1));
_lcd_cmd2(LCD_CMD_COL_ADDR,(6*col));
_lcd_cmd1(LCD_CMD_DATA_WRITE);
 data = 0x0F;
 shiftOut(PIN_MOSI, PIN_SCK, MSBFIRST, b);

https://github.com/olikraus/u8g2/blob/master/csrc/u8x8_d_uc1608.c#L473

@olikraus
Copy link
Owner

There is basically no nied to use your own functions.
Instead there are several low level functions which allow hardware independent transfer to the display. They also include an abstraction layer, so that a display will work with multiple busses (I2C, 8-bit 4-wire SPI, 9-bit 3-wire SPI, parallel, etc).

The functions are listed here:

u8g2/csrc/u8x8.h

Lines 597 to 603 in 9ecb87c

uint8_t u8x8_cad_SendCmd(u8x8_t *u8x8, uint8_t cmd) U8X8_NOINLINE;
uint8_t u8x8_cad_SendArg(u8x8_t *u8x8, uint8_t arg) U8X8_NOINLINE;
uint8_t u8x8_cad_SendMultipleArg(u8x8_t *u8x8, uint8_t cnt, uint8_t arg) U8X8_NOINLINE;
uint8_t u8x8_cad_SendData(u8x8_t *u8x8, uint8_t cnt, uint8_t *data) U8X8_NOINLINE;
uint8_t u8x8_cad_StartTransfer(u8x8_t *u8x8) U8X8_NOINLINE;
uint8_t u8x8_cad_EndTransfer(u8x8_t *u8x8) U8X8_NOINLINE;
void u8x8_cad_vsendf(u8x8_t * u8x8, const char *fmt, va_list va);

The first call should go to "u8x8_cad_StartTransfer".
After this use any data transmit calls (u8x8_cad_SendCmd, u8x8_cad_SendArg, ...)
Last call should be "u8x8_cad_EndTransfer".

"cad" means "command argument data".

StartTransfer/EndTransfer will clear/set the CS flag (SPI) or does similar action on I2C.

All in all, your code should look like this:

u8g2/csrc/u8x8_d_uc1608.c

Lines 78 to 101 in 9ecb87c

case U8X8_MSG_DISPLAY_DRAW_TILE:
u8x8_cad_StartTransfer(u8x8);
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
x *= 8;
u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
y += u8x8->x_offset;
u8x8_cad_SendCmd(u8x8, 0x0b0 | (y&15));
c = ((u8x8_tile_t *)arg_ptr)->cnt;
c *= 8;
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
do
{
u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
arg_int--;
} while( arg_int > 0 );
u8x8_cad_EndTransfer(u8x8);
break;

@nopbit
Copy link
Author

nopbit commented Apr 28, 2020

during the init process, i couldn't able to switch D/C pin between command to data (Low Command, High Data). DC pin is always low. I checked it with logic analyzer. Is there any special command to active D/C pins output? Thanks in advance

a part from init process:
....

U8X8_CA(0x66, 0x0), /* (15) Display Mode, Parameter 0 (4 Gray Scale) 1 (Binary) /
U8X8_CA(0x39, 0x43), /
(16) Gray Scale Pattern Set, Pattern / U8X8_C(0xBE|1), / (2) Display Off Mode (0 VSS / 1 Vcc) */

@nopbit
Copy link
Author

nopbit commented Apr 29, 2020

I forgot to mention: i tested with U8X8_UC1608_DEM240064_4W_SW_SPI and it is using u8x8_cad_001 as default. Do you have any idea what i am doing wrong?

@olikraus
Copy link
Owner

olikraus commented Apr 29, 2020

There are actually three different kind of bytes which need to be transfered:
Commands
Arguments
Data
(thats where "cad" comes from)
An argument is an extra byte send after and required for a command.
Data is really the bitmap data, which must be written to the display memory.
The DC (Data Command) or RS (Register Select) or CD (Command Data) line can carry only two information and needs to indicate what is what. Unfortunately each display controller has its one specification. Sometimes it is like this:

Commands: DC must be 0
Arguments: DC must be 1
Data: DC must be 1
In this case you have to use u8x8_cad_011 (you get the naming convention?)

However, in your case i think it is u8x8_cad_001, which means:
Commands: DC must be 0
Arguments: DC must be 0
Data: DC must be 1
This means, DC line will be set to 1 only if pure pixel data is transfered.

As mentioned above, there are basically three different functions:

  • u8x8_cad_SendCmd: Use this for command bytes
  • u8x8_cad_SendArg: Use this for arguments of command bytes
  • u8x8_cad_SendData: Use this for pixel data

These functions will automatically set the DC line according to the used CAD callback function.
So if you use u8x8_cad_001, then only u8x8_cad_SendData will set the DC line to 1. Others will clear the DC line.

The idea of all this is to write the driver code without knowing details on the DC line. Instead only the correct callback function for the DC line has to be selected.

@nopbit
Copy link
Author

nopbit commented Apr 30, 2020

Thanks for the support :), i am able to create u8x8 graphictest run on display without any problem. I will try u8g2 with it.

@nopbit
Copy link
Author

nopbit commented Apr 30, 2020

I couldn't figure out how to choose hardware spi pins. I am using STM32F103C8T6 with arduino and this chip has 2 spi. For spi1 it is using 2 different ports. How can i choose which pin to use for MOSI and SCK ? Thanks

@olikraus
Copy link
Owner

olikraus commented May 3, 2020

For many uC you can not choose MOSI and SCK. Instead those pins are hard wired in your microcontroller.

@olikraus
Copy link
Owner

take code from pull request #1190 and create a device for this. I also think the constructor needs to be renamed.

@olikraus olikraus added this to the 2.28 milestone May 17, 2020
@nopbit
Copy link
Author

nopbit commented May 27, 2020

I can rename it, do you have a suggestion for naming? Thanks

@olikraus
Copy link
Owner

olikraus commented Jun 5, 2020

Excause my delay in working on this. My current personal situation does not allow me to spend much time on u8g2.
In order to work with codebuild.c, the second keyword after u8x8 should be the controller name.

@nopbit
Copy link
Author

nopbit commented Jun 22, 2020

Sorry for delay too. I will make the changes at first chance. Can i compile it in windows with gcc? Do i need a special tool for codebuild.c

@olikraus
Copy link
Owner

codebuild.c is plain c code, so any compiler should be valid.
Difficulties will only come from the different file IO handling compared to linux (CR vs CR/LF etc).

@olikraus olikraus changed the title Template for new driver Template for new driver (support for S1D15E06 LCD) Dec 25, 2020
olikraus added a commit that referenced this issue Dec 25, 2020
olikraus added a commit that referenced this issue Dec 25, 2020
@olikraus
Copy link
Owner

added constructor U8G2_S1D15E06_160100_1_4W_HW_SPI

olikraus added a commit that referenced this issue Dec 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants