Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
gfx1.cpp@0:582c20f27326, 2012-03-05 (annotated)
- Committer:
- fblanc
- Date:
- Mon Mar 05 11:48:28 2012 +0000
- Revision:
- 0:582c20f27326
v1.0
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| fblanc | 0:582c20f27326 | 1 | /** |
| fblanc | 0:582c20f27326 | 2 | * @file gfx1.cpp |
| fblanc | 0:582c20f27326 | 3 | * @brief library Lascar Electronics SP 5-GFX1 DISPLAY, LCD GRAPHIC, 128 X 64 DOTS |
| fblanc | 0:582c20f27326 | 4 | * @author Frederic BLANC |
| fblanc | 0:582c20f27326 | 5 | */ |
| fblanc | 0:582c20f27326 | 6 | #include "gfx1.h" |
| fblanc | 0:582c20f27326 | 7 | SPI spi1(p5, p6, p7); //definition BUS SPI |
| fblanc | 0:582c20f27326 | 8 | unsigned char gfx1[128][7]; //emulation memoire ecran |
| fblanc | 0:582c20f27326 | 9 | unsigned int gfx1_x,gfx1_y;//emulation memoire ecran |
| fblanc | 0:582c20f27326 | 10 | DigitalOut GFX1_CS1_PIN(p23); |
| fblanc | 0:582c20f27326 | 11 | DigitalOut GFX1_RST_PIN(p22); |
| fblanc | 0:582c20f27326 | 12 | DigitalOut GFX1_AOP_PIN(p21); |
| fblanc | 0:582c20f27326 | 13 | |
| fblanc | 0:582c20f27326 | 14 | /** |
| fblanc | 0:582c20f27326 | 15 | * @brief init hard SPI |
| fblanc | 0:582c20f27326 | 16 | * @date 20/06/2011 |
| fblanc | 0:582c20f27326 | 17 | * |
| fblanc | 0:582c20f27326 | 18 | */ |
| fblanc | 0:582c20f27326 | 19 | void gfx1_init(void) { |
| fblanc | 0:582c20f27326 | 20 | spi1.format(8, 2); //spi 8bits, mode10 |
| fblanc | 0:582c20f27326 | 21 | spi1.frequency(1000000); //1mhz |
| fblanc | 0:582c20f27326 | 22 | GFX1_CS1_PIN=0; |
| fblanc | 0:582c20f27326 | 23 | GFX1_RST_PIN=0; |
| fblanc | 0:582c20f27326 | 24 | wait_us(1); //1�s |
| fblanc | 0:582c20f27326 | 25 | GFX1_RST_PIN=1; |
| fblanc | 0:582c20f27326 | 26 | } |
| fblanc | 0:582c20f27326 | 27 | |
| fblanc | 0:582c20f27326 | 28 | |
| fblanc | 0:582c20f27326 | 29 | /** |
| fblanc | 0:582c20f27326 | 30 | * @brief Write command |
| fblanc | 0:582c20f27326 | 31 | * @param [in] command |
| fblanc | 0:582c20f27326 | 32 | * @date 20/06/2011 |
| fblanc | 0:582c20f27326 | 33 | * |
| fblanc | 0:582c20f27326 | 34 | */ |
| fblanc | 0:582c20f27326 | 35 | void gfx1_command (unsigned char data ) { |
| fblanc | 0:582c20f27326 | 36 | GFX1_AOP_PIN = 0; |
| fblanc | 0:582c20f27326 | 37 | spi1.write (data); |
| fblanc | 0:582c20f27326 | 38 | |
| fblanc | 0:582c20f27326 | 39 | } |
| fblanc | 0:582c20f27326 | 40 | |
| fblanc | 0:582c20f27326 | 41 | |
| fblanc | 0:582c20f27326 | 42 | /** |
| fblanc | 0:582c20f27326 | 43 | * @brief Write display data |
| fblanc | 0:582c20f27326 | 44 | * @param [in] data |
| fblanc | 0:582c20f27326 | 45 | * @date 20/06/2011 |
| fblanc | 0:582c20f27326 | 46 | * |
| fblanc | 0:582c20f27326 | 47 | */ |
| fblanc | 0:582c20f27326 | 48 | void gfx1_data (unsigned char data ) { |
| fblanc | 0:582c20f27326 | 49 | GFX1_AOP_PIN = 1; |
| fblanc | 0:582c20f27326 | 50 | spi1.write (data); |
| fblanc | 0:582c20f27326 | 51 | gfx1[gfx1_x][gfx1_y]=data; |
| fblanc | 0:582c20f27326 | 52 | gfx1_x++; //emulation memoire ecran |
| fblanc | 0:582c20f27326 | 53 | if(gfx1_x>=128) |
| fblanc | 0:582c20f27326 | 54 | { |
| fblanc | 0:582c20f27326 | 55 | gfx1_x=0; |
| fblanc | 0:582c20f27326 | 56 | gfx1_y++; |
| fblanc | 0:582c20f27326 | 57 | } |
| fblanc | 0:582c20f27326 | 58 | if(gfx1_y>=8) |
| fblanc | 0:582c20f27326 | 59 | gfx1_y=7; |
| fblanc | 0:582c20f27326 | 60 | } |
| fblanc | 0:582c20f27326 | 61 | |
| fblanc | 0:582c20f27326 | 62 | /** |
| fblanc | 0:582c20f27326 | 63 | * @brief Read display data |
| fblanc | 0:582c20f27326 | 64 | * @return data |
| fblanc | 0:582c20f27326 | 65 | * @date 20/06/2011 |
| fblanc | 0:582c20f27326 | 66 | * |
| fblanc | 0:582c20f27326 | 67 | */ |
| fblanc | 0:582c20f27326 | 68 | unsigned char gfx1_read(void) |
| fblanc | 0:582c20f27326 | 69 | { |
| fblanc | 0:582c20f27326 | 70 | unsigned char tmp; |
| fblanc | 0:582c20f27326 | 71 | tmp=gfx1[gfx1_x][gfx1_y]; //emulation memoire ecran |
| fblanc | 0:582c20f27326 | 72 | |
| fblanc | 0:582c20f27326 | 73 | return tmp; |
| fblanc | 0:582c20f27326 | 74 | } |