frederic blanc / Mbed 2 deprecated sp5gfx1

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers gfx1.cpp Source File

gfx1.cpp

Go to the documentation of this file.
00001 /**
00002 * @file gfx1.cpp
00003 * @brief library Lascar Electronics SP 5-GFX1 DISPLAY, LCD GRAPHIC, 128 X 64 DOTS
00004 * @author Frederic BLANC
00005 */
00006 #include "gfx1.h"
00007 SPI spi1(p5, p6, p7); //definition BUS SPI
00008 unsigned char gfx1[128][7]; //emulation memoire ecran
00009 unsigned int gfx1_x,gfx1_y;//emulation memoire ecran
00010 DigitalOut GFX1_CS1_PIN(p23);
00011 DigitalOut GFX1_RST_PIN(p22);
00012 DigitalOut GFX1_AOP_PIN(p21);
00013 
00014 /**
00015  *     @brief init hard SPI
00016  *     @date 20/06/2011
00017  *
00018  */
00019 void gfx1_init(void) {
00020     spi1.format(8, 2); //spi 8bits, mode10
00021     spi1.frequency(1000000); //1mhz
00022     GFX1_CS1_PIN=0;
00023     GFX1_RST_PIN=0;
00024     wait_us(1); //1�s
00025     GFX1_RST_PIN=1;
00026 }
00027 
00028 
00029 /**
00030  *     @brief Write command
00031  *    @param  [in] command
00032  *     @date 20/06/2011
00033  *
00034  */
00035 void gfx1_command (unsigned char data ) {
00036     GFX1_AOP_PIN = 0;
00037     spi1.write (data);
00038     
00039 }
00040 
00041 
00042 /**
00043  *     @brief Write display data
00044  *    @param  [in] data
00045  *     @date 20/06/2011
00046  *
00047  */
00048 void gfx1_data (unsigned char data ) {
00049     GFX1_AOP_PIN = 1;
00050     spi1.write (data);
00051     gfx1[gfx1_x][gfx1_y]=data;
00052     gfx1_x++;  //emulation memoire ecran
00053     if(gfx1_x>=128)
00054     {
00055        gfx1_x=0;
00056        gfx1_y++; 
00057     }
00058     if(gfx1_y>=8)
00059         gfx1_y=7;
00060 }
00061 
00062 /**
00063  *     @brief Read display data
00064  *    @return   data
00065  *     @date 20/06/2011
00066  *
00067  */
00068 unsigned char gfx1_read(void)
00069 {
00070 unsigned char tmp;
00071     tmp=gfx1[gfx1_x][gfx1_y]; //emulation memoire ecran
00072 
00073 return tmp;
00074 }