NEW DATABASE - 350 MILLION DATASHEETS FROM 8500 MANUFACTURERS
AN2356 AN2348 CY8C29666 8C29666 SM6T15A BAV99 IRLM2502 SSD0323 - Datasheet Archive
Displays AN2356 Author: Valeriy Kyrynyuk Associated Project: Yes Associated Part Family: All GET FREE SAMPLES HERE Software
User Interface - Graphics Library for OLED Displays AN2356 AN2356 Author: Valeriy Kyrynyuk Associated Project: Yes Associated Part Family: All GET FREE SAMPLES HERE Software Version: PSoC® DesignerTM 4.2 Associated Application Notes: AN2348 AN2348 Application Notes Abstract This Application Note describes a graphics library for OLED display operation. Library functions include drawing, text, and bitmap operations. Introduction Modern designs often require a low-cost and high quality graphical display. OLED (organic light emitting diode) displays by OSRAM Opto Semiconductors (http://www.pictiva.com) meet these requirements and are the preferred displays for users and designers. This Application Note describes a library of functions to interface with a display that has a resolution of 96 x 48 pixels. Consider the display process in detail. An OLED display is a memory-mapped device. Four bits are necessary to display one pixel, because an OLED display has 16 brightness levels of one basic color; a single byte can hold information for two pixels. The columns and rows of the display can serve as the X and Y axes, respectively. One byte in video memory represents two pixels in the X direction. Therefore, to simplify algorithms for the display of images, the X coordinates of function arguments are assigned as one half of the real pixel position in its row. The pixel representation in a video memory byte is shown in Figure 1. OLED Review Figure 1. Video Memory Byte Format OSRAM OLED displays have the following characteristics: They are monochrome and have 16 brightness levels. X X +1 The interface supply voltage is 2.4-3.5V. The OLED supply voltage is 12-13V. The operating temperature range is between -30°C and 70°C. They have low power consumption at 220 mW maximum (OLED supply). No additional lighting elements are required. Lifetime at standard brightness is between 10 000 40 000 hours. Parallel or serial (SPI) are the standard interface options. March 16, 2006 4.7 bits 0.3 bits Interfacing with PSoC The demonstration board is implemented using a CY8C29666 CY8C29666 PSoC device. The interconnection circuit is shown in Figure 2. The connection is done by parallel interface. For a detailed description of this interface, refer to reference [1] from Solomon Systech Company at the end of this document. The maximum logic supply voltage of the display is 3.5V. Document No. 001-25479 Rev. * 1 [+] Feedback AN2356 AN2356 Figure 2. PSoC-OLED Interconnection Circuit, Vcc = 3.3V 3.3V U1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 PWM_FB PWM D7 D5 D3 D1 P0[7] P0[5] P0[3] P0[1] P2[7] P2[5] P2[3] P2[1] P4[7] P4[5] P4[3] P4[1] SMP P3[7] P3[5] P3[3] P3[1] P5[3] P5[1] P1[7] P1[5] P1[3] P1[1] Vss Vcc P0[6] P0[4] P0[2] P0[0] P2[6] P2[4] P2[2] P2[0] P4[6] P4[4] P4[2] P4[0] Xres P3[6] P3[4] P3[2] P3[0] P5[2] P5[0] P1[6] P1[4] P1[2] P1[0] 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 C1 0.1uF XRes CS# RST# D/C# R/W E E R/W D/C# RST# CS# D6 D4 D2 D0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 D0 D1 D2 D3 D4 D5 D6 D7 CY 8C29666 8C29666 J1 J2 3.3V 1 2 3 4 5 XRes CS# RES# BS1 D/C# R/W E D0 D1 D2 D3 D4 D5 D6 D7 NC Vdd OLED GND OLED ISSP 3.3V L2 10uH D7 C58 100uF PWM_FB C55 0,1uF R51 100k R30 3.3k SM6T15A SM6T15A When working with dynamic graphics, the device does not have enough of its own memory to buffer the contents of video memory. This requires about 3 Kbytes (96x64/2) of RAM. The data must be read from the video memory of the display. Therefore, the D0.D7 lines should be bidirectional. The user can choose other pins for OLED support. In this case, within the Device Editor of PSoC Designer, the PSoC-OLED signal should be configured to other pins. After that, in the oled.inc file the port numbers and bit template for the interface signals must be assigned. It is important that wires D0.D7 be located on the same port without changing the order in which the pins are numbered. March 16, 2006 R29 15k D6 BAV99 BAV99 Q5 IRLM2502 IRLM2502 PWM 12V OLED Driver Library Description The library functions can be symbolically grouped into two levels: low and high. The low-level APIs implement simple functions for display operation, which include transmitting commands, writing and reading data, and transmitting data arrays from the PSoC memory to display memory. Table 1 lists these functions. For image drawing, a special structure of image data was implemented. The argument Buf of the oledWriteROMSprite function points to the structure outlined in Code 1. Document No. 001-25479 Rev. * 2 [+] Feedback AN2356 AN2356 Code 1. Code Structure for Image Drawing Ystart and Yend start and end row position of the image. struct Sprite{ WORD Xpos=0x03; DataCount is the image size, 1.7FFFh bytes. The BYTE Xcmd=0x15; 0x8000 bit mask is set in this parameter. BYTE Xstart; abData is the image bitmap data array. BYTE Xend; WORD Ypos=0x03; BYTE Ycmd=0x75; BYTE Ystart; BYTE Yend; WORD DataCount; An example of such a record can be found in the icon.asm file. All low-level functions are written in assembly and located in oled.asm. To incorporate the low-level functions into the project, three files must be added: oled.asm, oled.inc and oled.h. BYTE abDATA [DataCount&0x7FFF]; } As we can see, the structure consists of 12-header bytes and the data array. Xstart and Xend start and end column position of the image. The position is divided by 2. Table 1. Low-Level Functions Function Description oledStart(void) Display initialization. oledWriteMode(void) Turn data direction from PSoC to OLED. oledReadMode(void) Turn data direction from OLED to PSoC. oledSendByte(BYTE bX) Write one byte to OLED (PSoC and OLED into write mode). BYTE oledReadByte(void) Read one byte from OLED (PSoC and OLED into read mode). oledWriteCmd(BYTE bX) Write one command byte to OLED. oledWriteData(BYTE bX) Write one data byte to OLED. oledWriteROMBuf(const BYTE * Buf) Write several bytes from the PSoC ROM (Flash) buffer to OLED. Buf points to an array of bytes located in ROM. The first two bytes in the buffer specify the length of data in bytes and the remaining are data bytes. If the 80h bit in the first byte is set, then data bytes will be written to the OLED's video memory (bitmap image), otherwise command bytes will be written. oledWriteROMSprite(const BYTE Buf) Place a rectangle image located in the PSoC ROM (Flash) buffer onto the OLED. Buf points to the array of bytes located in ROM. These bytes hold information about the position of the image on the display, image size, and a bitmap of the image. March 16, 2006 * Document No. 001-25479 Rev. * 3 [+] Feedback AN2356 AN2356 The high-level API functions include service routines for displaying text information, setting up a graphical data window, and clearing the selected area on display. These functions are realized in `C' and located in the main.c file, and can easily be modified by the user. Table 2 lists these functions. Table 2. High-Level Functions Function Description SetWindow(BYTE xs, BYTE ys, BYTE xe, BYTE ye) oledCLSWindow(BYTE x, BYTE y, BYTE dx, BYTE dy, BYTE color) oledString(BYTE xs, BYTE ys, BYTE color, char* text) Specify the current window for display. The display of all graphical data will be confined to this window. The xs, ys parameters specify the lower-left corner coordinates, and the xe, ye parameters the upper-right corner of the window. oledConstString(BYTE xs, BYTE ys, BYTE color, const char* text) Display a text string. The string is located in ROM (Flash) and terminated with a symbol of code 0x00. The starting coordinate (lower-left corner of the record), color, and address of the string are assigned as arguments. The 0x80 bit in the xs parameter defines the type/size of font. If the bit is set, the font is large. Otherwise, it is small. Fill the rectangular area with the selected color. The x, y parameters specify the lower-left corner coordinates of the window and the dx, dy parameters specify window size. Display a text string. The string is located in the PSoC RAM (SRAM) and terminated with a symbol of code 0x00. The starting coordinate (lower-left corner of the record), color, and address of the string are assigned as arguments. The 0x80 bit in the xs parameter defines the type/size of font. If the bit is set, the font is large. Otherwise, it is small. Image Processing and Depiction During the design of projects that use an OLED, it is often necessary to transfer graphical .bmp files from PC to PSoC. This Application Note includes a tool to convert bitmap images into .asm contents (bmp.exe). Follow these steps to incorporate a .bmp file into a PSoC project: 1. Copy image file into any graphic editor (Microsoft® Paint, for example). 2. Save image as a 16-level grayscale bitmap file (image.bmp, for example). 4. Run bmp.exe program with the following command line: bmp.exe filename.bmp filename.asm constname. For example: bmp.exe image.bmp logo.asm icon. 5. Copy .asm file to PsoC project folder. 6. Open PSoC Designer and add file to project (Project >> Add to Project >> Files.). 7. Figure 3 shows an image that was created on a PC, then converted to assembly format for the PSoC project and displayed on the OLED. Resize image to the appropriate size. 3. It is now possible to "draw" the image on the screen by calling the function oledWriteROMSprite(constname) in your project. For example: oledWriteROMSprite(icon). Define the image constant into the program by including the following line: extern const BYTE constname[];. For example: extern const BYTE icon[];. March 16, 2006 Figure 3. Example of Images on an OLED Document No. 001-25479 Rev. * 4 [+] Feedback AN2356 AN2356 The most important task for the display driver is to display text information. Two font types/sizes are implemented in the library. The range of their symbols is from 0x20 to 0x7F of the ASCII table. The size of the small font is 5x8 pixels and the large font is 8x16 (see Figure 4 (B). The font symbol is represented as an array of bytes that hold the monochrome image of each symbol (see Figure 5). Figure 5. Format of Symbol Bitmap Image Large Font Small Font Bit 01h 02h 04h 08h 10h 20h 40h 80h The bit images for each symbol of the small font are located in the small_font.h file. The bit images for the large font are located in the big_font.h file. Figure 4. Large and Small Fonts: (A) "Negative" Mode High Byte Implementation of Fonts 0 1 2 3 4 Low Byte (B) "Positive" Mode Bit 01h 02h 04h 08h 10h 20h 40h 80h 01h 02h 04h 08h 10h 20h 40h 80h 0 1 2 3 4 5 6 7 As we can see, a symbol in the small font needs 5 bytes for implementation, and a symbol in the large font needs 14 bytes. Both the high-level functions for working with fonts were previously described. The program Fontbuilder.exe allows custom fonts to be built and is included with the project. OLED Recommendations (A) Reducing pixel emission time and brightness are particularly useful ways to extend the lifetime of OLED displays. Users should also avoid using "Positive" (B) Screen Mode (Figure 4). For detailed information about optimizing the display operation, see reference [4] "Effective Use of PictivaTM OLED Displays: Power, Image and Lifetime Optimization." To include screen savers in OLED projects, refer to reference [5] "OLED Display Module Screen Saver." An OLED display requires a regulated power supply of +12V. There are many ways to generate this voltage supply. The demonstration project discussed in this Application Note uses a step-up converter to transform +3.3V to +12V. This converter only uses hardware resources of the PSoC: one switched capacitor block (analog comparator), two digital blocks (PWM and DigBuf), and one row LUT. The operation principle is the same as with the switch mode pump. The step-up converter is controlled by enabling\disabling the PWM output. The PWM duty cycle is set to (1 - 3.3V ) × 100% = 72.5% 12V to provide optimal converter operation. (B) March 16, 2006 Document No. 001-25479 Rev. * 5 [+] Feedback AN2356 AN2356 Summary References The library we have described can be used for an OLED with different resolutions. It can also be adapted for an OLED with a serial interface by using the PSoC SPIM User Module. The combination of PSoC and OLED displays can be applied to low-price devices, cell phones, hand-held terminals, vehicle displays, self-contained instruments, and similar applications. This library has been successfully tested in the compass design from Application Note AN2348 AN2348 "Tilt-Compensated Magnetic Compass with Built-In Temperature Sensor and OLED Display." 1. Advance Information.128 x 80, 16 Gray Scale Dot Matrix OLED/PLED Segment/Common Driver with Controller (http://www.solomon-systech.com) 2. To obtain the SSD0323 SSD0323 data (http://www.solomonsystech.com/pop_datasheet.htm.) 3. Bitmap File Format and Manipulation ( ) 4. Software Reference Manual: Text and Graphics Generation ( ) 5. Effective Use of PictivaTM OLED Displays: Power, Image and Lifetime Optimization ( ) 6. OLED Display Module Screen ) sheet, go to: Saver Appendix A. Tools List Tool bmp.exe (ARG1, ARG2, ARG3) Description Converts an image from a .bmp file to an .asm file for "drawing" on an OLED display by using the function oledWriteROMSprite (ARG3). ARG1 is the source .bmp file. ARG2 is the destination .asm file. ARG3 is the name of resulting array constant. Fontbuilder.exe March 16, 2006 Builds font symbols. Converts the symbol image to a `C'-format BYTE array (and from a `C'-format BYTE array to a symbol image). The generated array can be directly inserted into a font definition file. Document No. 001-25479 Rev. * 6 [+] Feedback AN2356 AN2356 About the Author Name: Title: Background: Contact: Valeriy Kyrynyuk Engineer Seven years experience on fieldbus and communications device design. lopik@lviv.farlep.net In March of 2007, Cypress recataloged all of its Application Notes using a new documentation number and revision code. This new documentation number and revision code (001-xxxxx, beginning with rev. *), located in the footer of the document, will be used in all subsequent revisions. PSoC is a registered trademark of Cypress Semiconductor Corp. "Programmable System-on-Chip," PSoC Designer, and PSoC Express are trademarks of Cypress Semiconductor Corp. All other trademarks or registered trademarks referenced herein are the property of their respective owners. Cypress Semiconductor 198 Champion Court San Jose, CA 95134-1709 Phone: 408-943-2600 Fax: 408-943-4730 http://www.cypress.com/ © Cypress Semiconductor Corporation, 2006-2007. The information contained herein is subject to change without notice. Cypress Semiconductor Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges. This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide patent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivative works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source Code except as specified above is prohibited without the express written permission of Cypress. Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the right to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application or use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress' product in a life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges. Use may be limited by and subject to the applicable Cypress software license agreement. March 16, 2006 Document No. 001-25479 Rev. * 7 [+] Feedback