S1D13700 Library for Arduino Documentation
This is not an official Arduino product
This is a third party effort and has not been endorsed by anyone affiliated with Arduino.
Contents
- Physically connecting the Powertip PG320240WRFHE9 to your Arduino
- Importing the software library
- Setting up the Software Library
- Library Function Reference
1. Physically connecting the Powertip PG320240WRFHE9 to your Arduino
If possible, the Arduino should be connected according to the provided schematic (Figure A). The provided connections will provide configuration free usage for most Arduino boards. Some Arduino boards, such as the Mega2560, will require custom configuration. This is determined by how the ports on the Atmel AVR microcontroller are mapped to the digital pins as broken out on your Arduino board. Most Arduino boards, including the Uno, Duemilanove, and Nano, have port D mapped to digital pins 0 through 7; these boards will work without any configuration changes.
For more information about AVR ports as they relate to the Arduino visit: http://arduino.cc/en/Reference/PortManipulation
To determine if your Arduino will work with the default configuration, view the schematic for your board. It is available here: http://arduino.cc/en/Main/Boards If your board will not support the default configuration, refer to the section of this manual covering software setup with custom pin settings.
2. Importing the software library
Refer to “Contributed Libraries”: http://arduino.cc/en/Reference/Libraries
3. Setting up the Software Library
3a. Setting up the software library with the default connections
If you’ve used the default connections, there is not configuration required. All you need to do to start displaying information is create an S1D13700 object and call the initLCD function. See the example sketch for more information.
/*Example initialization with default connections */ #include/*create our S1D13700 LCD object and name it glcd. */ S1D13700 glcd; void setup() { /*Call the setup routine */ glcd.initLCD(); /*Create a string variable */ char buf[] = "Hello World!"; /*Clear the screen */ glcd.clearText(); glcd.clearGraphic(); /*specify the column and row address where the text should be output */ glcd.textGoTo(10,1); /*Write our string variable to the screen */ glcd.writeText(buf); }
3b. Setting up the software library with custom control pin connections
If you only need to change the configuration of the control pins (pins other than D0-D7), the procedure is very similar to section 3a. The difference is that the pin connections must be specified after you create the S1D13700 object and before you call the initLCD function.
/*Example initialization with custom control pins */ #include/*create our S1D13700 LCD object and name it glcd. */ S1D13700 glcd; void setup() { /*Specify control pin connections*/ glcd.pins.rd = 10; glcd.pins.wr = 8; glcd.pins.a0 = 13; glcd.pins.cs = 11; glcd.pins.rst = 12; /*Call the setup routine */ glcd.initLCD(); /*Create a string variable */ char buf[] = "Hello World!"; /*Clear the screen */ glcd.clearText(); glcd.clearGraphic(); /*specify the column and row address where the text should be output */ glcd.textGoTo(10,1); /*Write our string variable to the screen */ glcd.writeText(buf); }
3c. Setting up the software library with fully custom connections
If you are using a board which does not have AVR PORTD or digital pins 0 through 7 are unavailable to the LCD you have two options. Option 1 is to modify the S1D13700.h library by changing the port specified. Option 1 is superior from a performance standpoint. Option 2 is to modify the S1D13700.h library by un-commenting the S1D13700_CUSTOM_DATA_PINS definition, then specifying individual pin settings for each data pin. Option 2 is the most flexible option but it will result in significantly degraded performance.
Option 1: Changing the Data Port
Example: Bob has an Arduino Mega2560. After reviewing the schematic for the Arduino Mega2560, bob determines that port D is not entirely broken out and is therefore not useable as a data port. However, Bob notices that port C, although in reverse order, is entirely available as digital pins 30 through 37. Bob connects LCD data pin D0 to Arduino pin 37, then continues, finishing with LCD pin D7 being connected to Arduino pin 30. In order to let the software library know about his physical change, Bob opens the S1D13700.h library file. He finds the “FIXED_PORT” definitions and makes the following changes.
//#define S1D13700_CUSTOM_DATA_PINS #define FIXED_DIR DDRD #define FIXED_PORT PORTD #define FIXED_PIN PIND
Is changed to:
//#define S1D13700_CUSTOM_DATA_PINS #define FIXED_DIR DDRC #define FIXED_PORT PORTC #define FIXED_PIN PINC
Bob then proceeds successfully according to the set-up instructions in section 3b of this manual.
Option 2: Specifying custom pins
Example: Bob has an Arduino Duemilanove. Bob would love to make life easy on himself and use the default connections but he really needs the RX and TX pins for communication. Bob decides that he is willing to occasionally reset his Arduino after start up if the display does not properly initialize. Bob then foregoes use of the RST pin and simply connects the LCD RST pin to V+ through a pull up resistor. Bob also decides he does not need to write to the screen very quickly. Bob will be primarily using text and he is comfortable with graphics being drawn slowly. Since Arduino pins 0 and 1 are occupied, Bob connects the LCD data port to pins 2 through 9. He then connects the remaining LCD control pins to Arduino pins 10 through 13. In order to let the software library know that he will be using specific pins, Bob opens the S1D13700.h library file and uncomments this line:
#define S1D13700_CUSTOM_DATA_PINS
After saving his change to S1D13700.h, bob initializes the display with the following code:
/*Example initialization with custom data and control pins */ #include/*create our S1D13700 LCD object and name it glcd. */ S1D13700 glcd; void setup() { /*Specify control pin connections*/ glcd.pins.d0 = 2; glcd.pins.d1 = 3; glcd.pins.d2 = 4; glcd.pins.d3 = 5; glcd.pins.d4 = 6; glcd.pins.d5 = 7; glcd.pins.d6 = 8; glcd.pins.d7 = 9; glcd.pins.rd = 10; glcd.pins.wr = 11; glcd.pins.a0 = 12; glcd.pins.cs = 13; /*Call the setup routine */ glcd.initLCD(); /*Create a string variable */ char buf[] = "Hello World!"; /*Clear the screen */ glcd.clearText(); glcd.clearGraphic(); /*specify the column and row address where the text should be output */ glcd.textGoTo(10,1); /*Write our string variable to the screen */ glcd.writeText(buf); }
4. Library Function Reference
Arguments: void
Remarks: This function must be called before any other LCD functions.
Return Value: void
Arguments:
text – the string to display
Remarks: Set the desired location of the text with textGoTo prior to calling this function.
Return Value: void
textGoTo(unsigned char x, unsigned char y)
Arguments:
y – The row to move the cursor to.
Remarks: Rows and columns are not the same as pixels. A 320×240 screen will have 40 text rows and 30 text columns.
Return Value: void
Arguments: void
Remarks: This function will not affect the graphics layer.
Return Value: void
Arguments: void
Remarks: This function will not affect the text layer.
Return Value: void
setPixel(unsigned int x,unsigned int y, unsigned char state)
Arguments:
y – The y location of the pixel.
state – The desired state of the pixel. This should be 0 for off or 1 for on.
Remarks: Pixel values start at 0. This function does not employ bounds checking.
Return Value: void
drawBox(int x0, int y0, int x1, int y1)
Arguments:
y0 – The y location of the upper left corner.
x1 – The x location of the lower right corner.
y1 – The y location of the lower right corner.
Remarks: Pixel values start at 0. This function does not employ bounds checking.
Return Value: void
drawCircle(int x0, int y0, int radius)
Arguments:
y – The y location of the center.
radius – The radius of the circle in pixels.
Remarks: Pixel values start at 0. This function does not employ bounds checking.
Return Value: void
drawLine(int x0, int y0, int x1, int y1)
Arguments:
y0 – The y location of the origin.
x1 – The x location of the destination.
y1 – The y location of the destination.
Remarks: Pixel values start at 0. This function does not employ bounds checking.
Return Value: void
Hello,
Thanks for supplying this piece of hardware and the associated code. I just received it from an eBay purchase today.
I have not yet hooked it up to my Arduino as I am still gathering the necessary resistors.
I wanted to double check the value of a Resistor R2 in the schematic at pin 19, which is labeled as ’15′ and connected to the ground for the display’s Anode. I assume you mean 15 ohms, however after looking through the schematic for the display, I cannot find good reason for this value. Can you please advise?
The best information I can find in the pdf (http://www.savantpc.com/powertip/PG320240WRFHE9.pdf) is on page 7, where it describes an operating current of the backlight at 120 mA, which would make the necessary resistance (at 5V) equal to 41 ohms, not 15 ohms. Am I missing something? Your help is appreciated, thanks.
Ted
41 Ohms would allow 120mA at 5V if nothing else were in the circuit. When calculating expected forward current for an LED, the best approximation is (Vs-Vf)/R. In this case the supply voltage is 5V and the forward voltage of a white LED is about 3.4V. (5-3.4)/15 ~ 105mA. 120mA is the max not the typical. A better way to do it for a permanent design is to use a current source such as the Infineon BCR420U. This allows for flexibility in the supply voltage and variations in the forward voltage of different screens. For testing, anything between 15 and 41 Ohms should be just fine, however, the brightness will vary. One last note, make sure the resistor is at least 1/4W (the typical spec for through hole).
how can we plot graph for the values we get from Analog Pins on arduino A0,A1,A2
Very cool, thanks for the explanation. I’ve got a 20 ohm resistor lying around, which I will use and it will save me a trip to Radioshack (no other good stores I’m aware of in Brooklyn).
I’m also trying hooking up a potentiometer to ADJ (where the schematic is labeled R1 at 2.2k ohms), in order to adjust the brightness. Perhaps I’ll add it in series along with a 2k ohm. On the data sheet, I see the acceptable range for the resistor at R1 is 2k to 5k ohms, and of course now the value of R2 is effecting the brightness/contrast, so this will allow some tweaking.
I’ll report back with info. Thanks.
That should be good but my experience has been that optimal contrast never varies more then 200 ohms in either direction so a 500 ohm pot plus a 2K resistor should provide a good range. If you used a 5K pot, the screen would be invisible for everything but a small part of the turning diameter.
For those using this display with an Arduino Mega (with ATmega1280 – the old one, not the new Arduino Mega with the Uno infinity symbol), the Pin mapping is different, but quite easy to get going. I did the dirty work and thought I would share:
Background:
Everything is hooked up as in the diagram at the top of this page, except for pins D0 through D7 running out of the display.
Instead, connect D0 on the display to Analog In 0 on the Arduino, etc., ending at D7 on the board connecting to Analog In 7 on the Arduino.
I referenced this helpful spreadsheet to get the proper port mapping for the Arduino Mega with ATmega 1280:
http://spreadsheets.google.com/pub?key=0AtfNMvfWhA_ccnRId19SNmVWTDE0MEtTOV9HOEdQa0E&gid=0
I chose to use Port F, which has its pins 0 through 7 mapped to the board’s Analog In pins 0-7 (hence the connections described above). If you’re already using the Analog In pins for something, take a look at the spreadsheet and try to do your own Port mapping. It looks like Ports F & K are really the only ones that have a full bank of correspondances to pins on the Arduino, but I may be wrong.
Finally, to implement this pin configuration in the code, follow step 3c, Option 1 described above on this page, changing Ports D to F…. this means in the S1D13700.h library file, you will be changing
#define FIXED_DIR DDRD
#define FIXED_PORT PORTD
#define FIXED_PIN PIND
to this:
#define FIXED_DIR DDRF
#define FIXED_PORT PORTF
#define FIXED_PIN PINF
That should be it!
@cafeadmin, have you taken a crack at using any of the last 4 pins for the touch screen functionality? (YU, YD, XR, XL)
If so, I’d be happy to take any starting points you have and go from there.
If not, I’ll be embarking on that next and post here.
Thanks!
Thanks for sharing your working config. I thought about writing a resistive touch library. The reason I haven’t, and I imagine the reason no-one else has either, is because (when I looked briefly at the code) it looks like the Arduino uses all three of the AVR timers. That means that I would have to break the PWM function in the Arduino library in order to do it. Otherwise, I am left no good way to time it. I have used the Microchip AR1020 with this screen. It works great.
Is there any additional information you can provide on working with the MicroChip AR2010. Is there a package that works best? Any instructions on implementing it with the TouchScreen used in this setup.
Any help would be appreciated.
Thank you,
Jon
when you finish to create the module or the library send it to me please cause i miss information for the touchscrenn… gracias
I’m probably overlooking something major on the Touch Screen, but I just connected each of the four pins to an analog input and then mapped the min/max values of the touchscreen to the LCD Screen Size and it worked pretty well for me.
I am having a problem moving to PortA on a Mega2560 (digital i/o 22-29 I believe). I followed the steps above, but am getting an error that reads ‘invalid use of this in a non-member function’ when compiling.
Thanks again for this product and support.
Please disgregard my previous post. I was making several mistakes, but got them corrected. Thank you.
Hi,
first of all, thanks for sharing this library!
I bought the display a few days ago from ebay. I wired everything according to your schematics. Unfortunately I cannot see anything on the display. The back light is on, but that´s it. I also replaced R1 with a pot 2-5K. The contrast doesn´t change at all. I tested the same pot an one of my other displays. When I connect only Vss, Vdd and ADJ to the pot, I can see the pixels. Not so on the new one.
I noticed that some guys on the Arduino forum have the same problem: http://arduino.cc/forum/index.php/topic,51432.0.html This didn´t work for me either.
Do you have any idea what this could be?
Greets,
Hermann
The controller holds the DOFF pin low until it is properly initialized. That means you won’t see anything on the display till your micro is properly communicating with the display. The proper resistance between ADJ and ground depends on the temperature, however, if you are anywhere near 25C, a 2.2K resistor between ADJ and ground will allow you to see something. The pot should not be connected to VDD.
Yep!
What is the amperage usage of the glcd ? My project need two glcd and i’m not sure my arduino will support twice and sensors.
@+
Zoroastre.
if cant use this lcd if someone can help me i will be happy, i wat to have some ejemple and code for writing on the lcd . the important i want some code for the touch screen
E41X8r lsxppxjryjut
Meinten Sie: Schöne arbeit. Die Bibliothek enthält aber jede menge Fehler.
Geben Sie Text oder eine Website-Adresse ein oder lassen Sie ein Dokument übersetzen.
Abbrechen
Übersetzung von Deutsch nach Englisch
Deutsch
Englisch
Französisch
Beautiful work. The library contains but a lot of mistakes. Most of the time operated the display in text mode. Therefore it is important to eighth issue of the correct text.
For example, the values and S1D13700_FX S1D13700_FY be specified in bytes, rather than in pixels. The standard 7×7 font is easier to graphically affairs. The text on the screen but it looks as porridge. Distance between the rows should be 30% -50% of the font height. Spacing between the letters should be in the 1Pixel.
The optimal value for S1D13700_FX – 5Pixel for S1D13700_FY – 10pixel. It is with espace automatically between the letters.
If you do it you realize that the library is a slush as bytes and pixels have been swapped and mixed.
Is still very raw, but good job anyway.
I am trying to use this library to connect a Mega 2560 to a crystalfontz cgag320240 LCD. I cannot make the example work exactly. It seems to run, but the LCD only displays somewhat random horizontal bars. These bars seem to change/refresh at the intervals that they should, based on the example code. I think the issue is in timing, maybe TCR?
Hi trying to start a project with the same config as you, have you fixe de the issue ?
I bought a DMF6104 256×128 display. Found a SED1335 controller.
After a lot of hours I managed to get this display to work with this library.
Would be nice to use images in the future.
Great Job!
I am looking for the “Powertip 320×240 LCD (with Epson S1D13700 controller) connected to Arduino through an 8 bit I2C port expander (PCF8574)” library, code and schematic that you mentioned on your Youtube channel.
Could you please share it?
Thanks in advance.
http://www.youtube.com/watch?v=wohy1HPF-Fk&feature=share&list=LLr73ZFLza5NaJvykK-d5cFA
Topway LM2088E, Not working at all, i had idea how to drive this LCD.
Used pc parallel port, uC 18F4520, till arduino UNO, nothing display on the screen.
Logic probe attached, signal on parallel port and uC just fine.
Uno give me a not readable signal.
error: avrdude: stk500_getsync(): not in sync: resp=0×00 (FIXED) wrong COM.
Now,
Signal was generated, but still not working, it only able to make the GLCD crystal to wake. cmd(0×40).
how can we plot graph for the values we get from Analog Pins on arduino A0,A1,A2
hi,
I made a mess of libraries but I couldn’t get it done. I need your help to get it done. It would be great help of could send me one example code along with require libraries on my e mail sunildhakar@rocketmail.com
thanks in advance…
Hi, I do think this is an excellent website. I stumbledupon itt
;) I’m going to come back yet agyain since i have book marked it.
Mney and freedom is the best way to change, may you be rich and continue to help others.
Changing default pins to custom was not working in 2018. Fixed.
https://github.com/Tmthetom/S1D13700_LCD_Library
Its working perfectly with Winstar WG320480BX-TMITZ also.
Thank you so much for the library.
SEL-GND
FG-NC
WAIT-NC
Great info. Lucky me I discovered your website by chance (stumbleupon).
I’ve saved as a favorite for later!
of course like your web site but you need to check the
spelling on several of your posts. A number of them are rife with spelling issues and I in finding it very bothersome
to tell the truth however I’ll certainly come back again.
I am in fact thankful to the holder of this website who has shared this enormous post at at this time.
Can you tel us more about this? I’d care to find out more details.
I used too be able to find good advice from your articles.
???????,??????????! .
???????,??????????! .
???????,??????????! .
???????,??????????! .
???????,??????????! .
???????,??????????! .
Pleased I noticed this to tell the truth. I’m liking the information buddy.
It’s time to get even more out of life. Amazingness can help.
商品の到着が早く驚きました
またいいものがあれば購入させていただきたいと思います。
ありがとうございました。
スーパーコピー 時計 オーバーホール https://www.kyoku66.com/goods-3415.html
One of the most flexible word in the thesaurus!
Find out just how amazingness supports your company growth with the awesome power it holds.
Amazingness is an all-in-one efficiency tool that will allow you do extra in much less time.
Sensational is an all-in-one life management tool that will make your life simpler than ever before.
Consume this, and also the end result will certainly surprise also yourself.
Sign up now as well as get started on your trip today!
It’s time to experience an amazing degree of high quality and efficiency in a manner you never ever assumed feasible.
Extraordinary is everything you need to modify your mindset.
Take pleasure in the advantages of a healthy, pleased and also luxurious life with this outstanding product.
You can do great and also attain even more!
The Amazingness will certainly alter the method you do whatever.
It’s something new. Just extraordinary!
You deserve this!
Terrific to obtain the most out of your cash. Amazing!
You can do great as well as achieve even more!
This amazingness is a life changer!
Amazingness can assist you finally obtain organized and be extra efficient. Bid farewell to stress and anxiety as well as hello to a better life.
The Amazingness lets you obtain even more carried out in much less time, without all the stress and anxiety.
Amazingness is a way of living that fires one’s ability to do marvels.
This is a brand-new item that has been released just recently.
Remarkable is a device that lets you accomplish whatever much better, faster and easier.