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

  1. Physically connecting the Powertip PG320240WRFHE9 to your Arduino
    1. Schematic
  2. Importing the software library
  3. Setting up the Software Library
    1. Setting up the software library with the default connections
    2. Setting up the software library with custom control pin connections
    3. Setting up the software library with fully custom connections
  4. Library Function Reference
    1. initLCD
    2. writeText
    3. textGoTo
    4. clearText
    5. clearGraphic
    6. setPixel
    7. drawBox
    8. drawCircle
    9. drawLine



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.

Figure A

Firgue A - Hookup Schematic




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

initLCD()

Description: Initilalizes the LCD.

Arguments: void

Remarks: This function must be called before any other LCD functions.

Return Value: void



writeText(char * text)

Description: Display a string from memory on the LCD.

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)

Description: Moves the text cursor to the specified location.

Arguments:

x – The column to move the cursor to.

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



clearText ()

Description: Clears the text layer.

Arguments: void

Remarks: This function will not affect the graphics layer.

Return Value: void



clearGraphic ()

Description: Clears the graphics layer.

Arguments: void

Remarks: This function will not affect the text layer.

Return Value: void



setPixel(unsigned int x,unsigned int y, unsigned char state)

Description: Clears or sets a single pixel.

Arguments:

x – The x location of the pixel.

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)

Description: Draws a rectangle.

Arguments:

x0 – The x location of the upper left corner.

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)

Description: Draws a circle

Arguments:

x – The x location of the center.

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)

Description: Draws a line.

Arguments:

x0 – The x location of the origin.

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



  1. 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

      • cafeadmin
      • January 11th, 2011

      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).

        • ALI MIRZA
        • February 18th, 2015

        how can we plot graph for the values we get from Analog Pins on arduino A0,A1,A2

  2. 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.

      • cafeadmin
      • January 13th, 2011

      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.

  3. 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!

  4. @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!

      • cafeadmin
      • January 19th, 2011

      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.

        • Jon B.
        • April 25th, 2011

        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

        • ingsmivinki
        • July 30th, 2011

        when you finish to create the module or the library send it to me please cause i miss information for the touchscrenn… gracias

    • Jon B.
    • January 19th, 2011

    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.

    • Jon B.
    • January 19th, 2011

    Please disgregard my previous post. I was making several mistakes, but got them corrected. Thank you.

    • Hermann
    • April 22nd, 2011

    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

      • cafeadmin
      • April 26th, 2011

      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.

    • zoroastre
    • July 15th, 2011

    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.

    • ingsmivinki
    • July 30th, 2011

    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

  5. E41X8r lsxppxjryjut

    • Hruendel
    • November 26th, 2011

    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.

    • David
    • April 12th, 2012

    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?

      • Georges
      • October 27th, 2015

      Hi trying to start a project with the same config as you, have you fixe de the issue ?

    • Pascal
    • November 17th, 2012

    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.

    • Sergio
    • January 18th, 2013

    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

    • iRviNe48
    • July 23rd, 2013

    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.

      • iRviNe48
      • July 23rd, 2013

      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).

    • ALI MIRZA
    • February 11th, 2015

    how can we plot graph for the values we get from Analog Pins on arduino A0,A1,A2

    • sunil shakar
    • February 21st, 2015

    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…

  6. 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.

    • Tmthetom
    • May 21st, 2018

    Changing default pins to custom was not working in 2018. Fixed.
    https://github.com/Tmthetom/S1D13700_LCD_Library

    • Nandika Sirinuwan
    • October 25th, 2018

    Its working perfectly with Winstar WG320480BX-TMITZ also.
    Thank you so much for the library.

      • Nandika Sirinuwan
      • October 25th, 2018

      SEL-GND
      FG-NC
      WAIT-NC

  7. Great info. Lucky me I discovered your website by chance (stumbleupon).
    I’ve saved as a favorite for later!

  8. 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.

  9. I am in fact thankful to the holder of this website who has shared this enormous post at at this time.

  10. Can you tel us more about this? I’d care to find out more details.

    • Kit
    • December 13th, 2018

    I used too be able to find good advice from your articles.

    • Haywardoxb
    • March 26th, 2019

    ???????,??????????! .

    • Wirelesslxy
    • March 26th, 2019

    ???????,??????????! .

    • Feederqdd
    • March 27th, 2019

    ???????,??????????! .

    • Haywardthm
    • March 28th, 2019

    ???????,??????????! .

    • Telecasterjzs
    • March 29th, 2019

    ???????,??????????! .

    • Clamcasejlo
    • March 29th, 2019

    ???????,??????????! .

  11. Pleased I noticed this to tell the truth. I’m liking the information buddy.

  12. It’s time to get even more out of life. Amazingness can help.

  13. 商品の到着が早く驚きました
    またいいものがあれば購入させていただきたいと思います。
    ありがとうございました。
    スーパーコピー 時計 オーバーホール https://www.kyoku66.com/goods-3415.html

  14. One of the most flexible word in the thesaurus!

  15. Find out just how amazingness supports your company growth with the awesome power it holds.

  16. Amazingness is an all-in-one efficiency tool that will allow you do extra in much less time.

  17. Sensational is an all-in-one life management tool that will make your life simpler than ever before.

  18. Consume this, and also the end result will certainly surprise also yourself.

  19. Sign up now as well as get started on your trip today!

  20. It’s time to experience an amazing degree of high quality and efficiency in a manner you never ever assumed feasible.

  21. Extraordinary is everything you need to modify your mindset.

  22. Take pleasure in the advantages of a healthy, pleased and also luxurious life with this outstanding product.

  23. You can do great and also attain even more!

  24. The Amazingness will certainly alter the method you do whatever.

  25. It’s something new. Just extraordinary!

  26. You deserve this!

  27. Terrific to obtain the most out of your cash. Amazing!

  28. You can do great as well as achieve even more!

  29. This amazingness is a life changer!

  30. 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.

  31. The Amazingness lets you obtain even more carried out in much less time, without all the stress and anxiety.

  32. Amazingness is a way of living that fires one’s ability to do marvels.

  33. This is a brand-new item that has been released just recently.

  34. Remarkable is a device that lets you accomplish whatever much better, faster and easier.

  35. Find out exactly how to maintain your house spick-and-span in half an hour!

  36. 最高級ロレックスコピー
    現在世界最高級のロレックスコピー、IWC、シャネル、パネライコピー などの各種類世界トップ時計が扱います。
    スーパーコピー時計の激安老舗.!アフターサービスも自ら製造したスーパーコピー時計なので、技術力でお客様に安心のサポー トをご提供させて頂きます。
    スーパーコピーブランド https://www.ginzaking.com/product/detail/10721.htm

  37. 超人気【楽天市場】
    高品質とリーズナブルで販売
    超安値登場!品質保証、最安値に挑戦!
    オンラインストアオファー激安輸出
    オンラインストアは、ご来店ありがとうございます.
    【超人気新品】即日発送,品質100%保証!
    【新商品!】☆安心の全品国内発送!
    激安通販!☆安心の全品国内発送!
    激安全国送料無料!100%正規品!
    激安販売中!
    高品質と最高の専門の顧客サービスと
    手頃な価格でお好きなもの
    芸能人愛用『大注目』
    今、私たちは安価な高級品海外通販しています。
    私たちは、デザイナーの多数な選択を運ぶ
    ロレックス偽物時計 https://www.ginza24.com/product/detail/1550.htm

  38. Get the results you want with less initiative, very simple.

  1. October 5th, 2014
  2. October 11th, 2014
  3. October 26th, 2020
    Trackback from : Legit Sustanon Suppliers