Cleaned up for RGB/BGR selection
[hackover2013-badge-firmware.git] / drivers / lcd / bitmap / ssd1306 / ssd1306.h
1 /**************************************************************************/
2 /*!
3 @file ssd1306.h
4 @author K. Townsend (microBuilder.eu)
5 @date 18 January 2012
6 @version 0.10
7
8 @section LICENSE
9
10 Software License Agreement (BSD License)
11
12 Copyright (c) 2012, microBuilder SARL
13 All rights reserved.
14
15 Redistribution and use in source and binary forms, with or without
16 modification, are permitted provided that the following conditions are met:
17 1. Redistributions of source code must retain the above copyright
18 notice, this list of conditions and the following disclaimer.
19 2. Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions and the following disclaimer in the
21 documentation and/or other materials provided with the distribution.
22 3. Neither the name of the copyright holders nor the
23 names of its contributors may be used to endorse or promote products
24 derived from this software without specific prior written permission.
25
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
27 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
30 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37 /**************************************************************************/
38 #ifndef __SSD1306_H__
39 #define __SSD1306_H__
40
41 #include "projectconfig.h"
42
43 #include "drivers/lcd/smallfonts.h"
44
45 /*=========================================================================
46 SSD1306 Displays
47 -----------------------------------------------------------------------
48 The driver is used in multiple displays (128x64, 128x32, etc.).
49 Select the appropriate display below to create an appropriately
50 sized framebuffer, etc.
51
52 SSD1306_128_64 128x64 pixel display
53
54 SSD1306_128_32 128x32 pixel display
55
56 You also need to set the LCDWIDTH and LCDHEIGHT defines to an
57 appropriate size
58
59 -----------------------------------------------------------------------*/
60 // #define SSD1306_128_64
61 #define SSD1306_128_32
62 /*=========================================================================*/
63
64 #if defined SSD1306_128_64 && defined SSD1306_128_32
65 #error "Only one SSD1306 display can be specified at once in ssd1306.h"
66 #endif
67 #if !defined SSD1306_128_64 && !defined SSD1306_128_32
68 #error "At least one SSD1306 display must be specified in ssd1306.h"
69 #endif
70
71 #if defined SSD1306_128_64
72 #define SSD1306_LCDWIDTH 128
73 #define SSD1306_LCDHEIGHT 64
74 #endif
75 #if defined SSD1306_128_32
76 #define SSD1306_LCDWIDTH 128
77 #define SSD1306_LCDHEIGHT 32
78 #endif
79
80 // Pin Definitions
81 #define SSD1306_DC_PORT (2) // Data/Command
82 #define SSD1306_DC_PIN (1)
83 #define SSD1306_RST_PORT (2) // Reset
84 #define SSD1306_RST_PIN (2)
85 #define SSD1306_CS_PORT (2) // Select
86 #define SSD1306_CS_PIN (3)
87 #define SSD1306_SCLK_PORT (2) // Serial Clock
88 #define SSD1306_SCLK_PIN (5)
89 #define SSD1306_SDAT_PORT (2) // Serial Data
90 #define SSD1306_SDAT_PIN (6)
91
92
93 // Commands
94 #define SSD1306_SETCONTRAST 0x81
95 #define SSD1306_DISPLAYALLON_RESUME 0xA4
96 #define SSD1306_DISPLAYALLON 0xA5
97 #define SSD1306_NORMALDISPLAY 0xA6
98 #define SSD1306_INVERTDISPLAY 0xA7
99 #define SSD1306_DISPLAYOFF 0xAE
100 #define SSD1306_DISPLAYON 0xAF
101 #define SSD1306_SETDISPLAYOFFSET 0xD3
102 #define SSD1306_SETCOMPINS 0xDA
103 #define SSD1306_SETVCOMDETECT 0xDB
104 #define SSD1306_SETDISPLAYCLOCKDIV 0xD5
105 #define SSD1306_SETPRECHARGE 0xD9
106 #define SSD1306_SETMULTIPLEX 0xA8
107 #define SSD1306_SETLOWCOLUMN 0x00
108 #define SSD1306_SETHIGHCOLUMN 0x10
109 #define SSD1306_SETSTARTLINE 0x40
110 #define SSD1306_MEMORYMODE 0x20
111 #define SSD1306_COMSCANINC 0xC0
112 #define SSD1306_COMSCANDEC 0xC8
113 #define SSD1306_SEGREMAP 0xA0
114 #define SSD1306_CHARGEPUMP 0x8D
115 #define SSD1306_INTERNALVCC 0x1
116 #define SSD1306_EXTERNALVCC 0x1
117 #define SSD1306_SWITCHCAPVCC 0x2
118
119 // Initialisation/Config Prototypes
120 void ssd1306Init ( uint8_t vccstate );
121 void ssd1306DrawPixel ( uint8_t x, uint8_t y );
122 void ssd1306ClearPixel ( uint8_t x, uint8_t y );
123 uint8_t ssd1306GetPixel ( uint8_t x, uint8_t y );
124 void ssd1306ClearScreen ( void );
125 void ssd1306Refresh ( void );
126 void ssd1306DrawString( uint16_t x, uint16_t y, char* text, struct FONT_DEF font );
127 void ssd1306ShiftFrameBuffer( uint8_t height );
128
129 #endif
This page took 0.055047 seconds and 5 git commands to generate.