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.
Fork of Hexi_OLED_SSD1351 by
OLED_info.h
00001 /** OLED Screen Info 00002 * This file contains OLED screen SSD1351-related defines and macros. 00003 * 00004 * Redistribution and use in source and binary forms, with or without modification, 00005 * are permitted provided that the following conditions are met: 00006 * 00007 * Redistributions of source code must retain the above copyright notice, this list 00008 * of conditions and the following disclaimer. 00009 * 00010 * Redistributions in binary form must reproduce the above copyright notice, this 00011 * list of conditions and the following disclaimer in the documentation and/or 00012 * other materials provided with the distribution. 00013 * 00014 * Neither the name of NXP, nor the names of its 00015 * contributors may be used to endorse or promote products derived from this 00016 * software without specific prior written permission. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00019 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00020 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00021 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 00022 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00023 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00024 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00025 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00026 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00027 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00028 * 00029 * visit: http://www.mikroe.com and http://www.nxp.com 00030 * 00031 * get support at: http://www.mikroe.com/forum and https://community.nxp.com 00032 * 00033 * Project HEXIWEAR, 2015 00034 */ 00035 00036 #ifndef HG_OLED_INFO 00037 #define HG_OLED_INFO 00038 00039 // command byte number 00040 #define CMD_BYTE (1) 00041 #define DATA_BYTE (0) 00042 00043 #define OLED_COLUMN_OFFSET (16) 00044 #define OLED_ROW_OFFSET (0) 00045 00046 #define OLED_SCREEN_WIDTH (96) 00047 #define OLED_SCREEN_HEIGHT (96) 00048 00049 #define OLED_SCREEN_WIDTH_END ( (OLED_SCREEN_WIDTH-1) + OLED_COLUMN_OFFSET ) 00050 #define OLED_SCREEN_HEIGHT_END ( (OLED_SCREEN_HEIGHT-1) + OLED_ROW_OFFSET ) 00051 00052 #define OLED_BYTES_PER_PIXEL ( 2 ) 00053 00054 #define OLED_TRANSITION_STEP ( 1 ) 00055 #define OLED_ACTION_DCON ( 0xFE ) 00056 #define OLED_ACTION_DCOFF ( 0xFF ) 00057 00058 #define OLED_CHAR_WIDTH_AUTO ( 0xFF ) 00059 #define OLED_CHAR_WIDTH_MAX ( 0xFE ) 00060 #define OLED_CHAR_WIDTH_NUM ( 0xFD ) 00061 #define OLED_CHAR_WIDTH_KEEP ( 0xFC ) 00062 #define OLED_CHAR_HEIGHT_AUTO ( 0xFB ) 00063 #define OLED_CHAR_HEIGHT_KEEP ( 0xFA ) 00064 00065 #define OLED_SCREEN_SIZE ( OLED_SCREEN_WIDTH * OLED_SCREEN_HEIGHT ) 00066 #define OLED_GRAM_SIZE ( OLED_SCREEN_WIDTH * OLED_SCREEN_HEIGHT * OLED_BYTES_PER_PIXEL ) 00067 00068 #define OLED_TEXT_HALIGN_SHIFT ( 0 ) 00069 #define OLED_TEXT_HALIGN_MASK ( 0x03 << OLED_TEXT_HALIGN_SHIFT ) 00070 00071 #define OLED_TEXT_VALIGN_SHIFT ( 4 ) 00072 #define OLED_TEXT_VALIGN_MASK ( 0x03 << OLED_TEXT_VALIGN_SHIFT ) 00073 00074 #define BMP_HEADER_BYTE_SIZE (6) 00075 00076 00077 00078 /** 00079 * remap settings 00080 */ 00081 00082 #define REMAP_HORIZONTAL_INCREMENT ( 0 ) 00083 #define REMAP_VERTICAL_INCREMENT ( 1 << 0 ) 00084 00085 #define REMAP_COLUMNS_LEFT_TO_RIGHT ( 0 ) 00086 #define REMAP_COLUMNS_RIGHT_TO_LEFT ( 1 << 1 ) 00087 00088 #define REMAP_ORDER_ABC ( 0 ) 00089 #define REMAP_ORDER_CBA ( 1 << 2 ) 00090 00091 #define REMAP_SCAN_UP_TO_DOWN ( 0 ) 00092 #define REMAP_SCAN_DOWN_TO_UP ( 1 << 4 ) 00093 00094 #define REMAP_COM_SPLIT_ODD_EVEN_DIS ( 0 ) 00095 #define REMAP_COM_SPLIT_ODD_EVEN_EN ( 1 << 5 ) 00096 00097 #define REMAP_COLOR_RGB565 ( 1 << 6 ) 00098 00099 #define OLED_REMAP_SETTINGS ( REMAP_ORDER_ABC | REMAP_COM_SPLIT_ODD_EVEN_EN | REMAP_COLOR_RGB565 | REMAP_COLUMNS_LEFT_TO_RIGHT | REMAP_SCAN_UP_TO_DOWN | REMAP_HORIZONTAL_INCREMENT ) 00100 00101 /** 00102 * macros 00103 */ 00104 00105 #define OLED_SwapMe(x) x = ( ( x & 0xFF00 ) >> 8 ) | ( ( x & 0x00FF ) << 8 ) 00106 #define OLED_AdjustRowOffset(y) y += OLED_ROW_OFFSET 00107 #define OLED_AdjustColumnOffset(x) x += OLED_COLUMN_OFFSET 00108 00109 #define BMP_SkipHeader( imgPtr ) ( (const uint8_t*)(imgPtr) + BMP_HEADER_BYTE_SIZE ) 00110 00111 00112 #define CheckLimits( x, y, w, h ) ( ( ( x + w - 1 ) > OLED_SCREEN_WIDTH ) || ( x < 0 ) || ( ( y + h - 1 ) > OLED_SCREEN_HEIGHT ) || ( y < 0 ) ) 00113 #define AreCoordsValid( x, y, w, h ) ( 0 == CheckLimits( x, y, w ,h ) ) 00114 #define AreCoordsNotValid( x, y, w, h ) ( 0 != CheckLimits( x, y, w, h ) ) 00115 00116 00117 /** 00118 * set start/end column/row 00119 * the 2nd and 3rd byte represent the start and the end address, respectively 00120 */ 00121 #define OLED_CMD_SET_COLUMN ( 0x15 ) 00122 #define OLED_CMD_SET_ROW ( 0x75 ) 00123 00124 /** 00125 * scanning direction 00126 */ 00127 00128 #define OLED_DIRECTION_HORIZONTAL (0) 00129 #define OLED_DIRECTION_VERTICAL (1) 00130 00131 /** 00132 * SPI-related 00133 */ 00134 00135 #define OLED_SPI_CHUNK (511) 00136 00137 /** 00138 * set display 00139 */ 00140 #define OLED_CMD_SET_DISPLAY_MODE_ALL_OFF (0xA4) 00141 #define OLED_CMD_SET_DISPLAY_MODE_ALL_ON (0xA5) 00142 #define OLED_CMD_SET_DISPLAY_MODE_NORMAL (0xA6) 00143 #define OLED_CMD_SET_DISPLAY_MODE_INVERSE (0xA7) 00144 00145 /** 00146 * set lock command 00147 * the locked OLED driver MCU interface prohibits all commands 00148 * and memory access, except the 0xFD command 00149 */ 00150 #define OLED_CMD_SET_CMD_LOCK ( 0xFD /* << 8 */ ) 00151 // unlock OLED driver MCU interface for entering command (default upon reset) 00152 #define OLED_UNLOCK (0x12) 00153 // lock OLED driver MCU interface for entering command 00154 #define OLED_LOCK (0x16) 00155 // commands 0xA2, 0xB1, 0xB3, 0xBB, 0xBE, 0xC1 are inaccessible in both lock and unlock state (default upon reset) 00156 #define OLED_ACC_TO_CMD_NO (0xB0) 00157 // commands 0xA2, 0xB1, 0xB3, 0xBB, 0xBE, 0xC1 are accessible in unlock state 00158 #define OLED_ACC_TO_CMD_YES (0xB1) 00159 00160 /** 00161 * NOP 00162 */ 00163 #define OLED_CMD_NOP (0xD1) // also, 0xE3 00164 00165 /** 00166 * set MUX ratio 00167 */ 00168 #define OLED_CMD_SET_MUX_RATIO (0xCA) 00169 00170 /** 00171 * set re-map / color depth 00172 */ 00173 #define OLED_CMD_SET_REMAP ( 0xA0 ) 00174 00175 // set horisontal or vertical increment 00176 #define OLED_ADDR_INC_HOR (0x00) 00177 #define OLED_ADDR_INC_VER (0x01) 00178 00179 // column address mapping 00180 #define OLED_COLUMN_ADDR_REMAP_0_TO_SEG0 (0x00) 00181 #define OLED_COLUMN_ADDR_REMAP_127_TO_SEG0 (0x02) 00182 00183 // color sequence order 00184 #define OLED_COLOR_SEQ_A_B_C (0x00) 00185 #define OLED_COLOR_SEQ_C_B_A (0x04) 00186 00187 // scanning order (MR == MUX ratio) 00188 #define OLED_SCAN_FROM_COM_0_TO_MR (0x00) 00189 #define OLED_SCAN_FROM_COM_MR_TO_0 (0x10) 00190 00191 // COM splitting to odd and even 00192 #define OLED_COM_SPLIT_DISABLE (0x00) 00193 #define OLED_COM_SPLIT_ENABLE (0x20) 00194 00195 // screen color depth 00196 #define OLED_COLOR_DEPTH_256 (0x00) 00197 #define OLED_COLOR_DEPTH_65K (0x40) 00198 #define OLED_COLOR_DEPTH_262K_1 (0x80) 00199 #define OLED_COLOR_DEPTH_262K_2 (0xC0) 00200 00201 /** 00202 * set reset (phase 1) / pre-charge (phase 2) period in [DCLK] 00203 * this command is locked by command 0xFD by default 00204 */ 00205 #define OLED_CMD_SET_RESET_AND_PRECHARGE_PERIOD (0xB1) 00206 00207 #define OLED_RESET_PERIOD_5 (0x02) 00208 #define OLED_RESET_PERIOD_7 (0x03) 00209 #define OLED_RESET_PERIOD_9 (0x04) 00210 #define OLED_RESET_PERIOD_11 (0x05) 00211 #define OLED_RESET_PERIOD_13 (0x06) 00212 #define OLED_RESET_PERIOD_15 (0x07) 00213 #define OLED_RESET_PERIOD_17 (0x08) 00214 #define OLED_RESET_PERIOD_19 (0x09) 00215 #define OLED_RESET_PERIOD_21 (0x0A) 00216 #define OLED_RESET_PERIOD_23 (0x0B) 00217 #define OLED_RESET_PERIOD_25 (0x0C) 00218 #define OLED_RESET_PERIOD_27 (0x0D) 00219 #define OLED_RESET_PERIOD_29 (0x0E) 00220 #define OLED_RESET_PERIOD_31 (0x0F) 00221 00222 #define OLED_PRECHARGE_PERIOD_3 (0x03) 00223 #define OLED_PRECHARGE_PERIOD_4 (0x04) 00224 #define OLED_PRECHARGE_PERIOD_5 (0x05) 00225 #define OLED_PRECHARGE_PERIOD_6 (0x06) 00226 #define OLED_PRECHARGE_PERIOD_7 (0x07) 00227 #define OLED_PRECHARGE_PERIOD_8 (0x08) 00228 #define OLED_PRECHARGE_PERIOD_9 (0x09) 00229 #define OLED_PRECHARGE_PERIOD_10 (0x0A) 00230 #define OLED_PRECHARGE_PERIOD_11 (0x0B) 00231 #define OLED_PRECHARGE_PERIOD_12 (0x0C) 00232 #define OLED_PRECHARGE_PERIOD_13 (0x0D) 00233 #define OLED_PRECHARGE_PERIOD_14 (0x0E) 00234 #define OLED_PRECHARGE_PERIOD_15 (0x0F) 00235 00236 /** 00237 * set front clock divider (divset) / oscillator frequency 00238 * this command is locked by command 0xFD by default 00239 */ 00240 #define OLED_CMD_SET_OSC_FREQ_AND_CLOCKDIV (0xB3) 00241 00242 // clock divider 00243 #define OLED_CLOCKDIV_1 (0x00) 00244 #define OLED_CLOCKDIV_2 (0x01) 00245 #define OLED_CLOCKDIV_4 (0x02) 00246 #define OLED_CLOCKDIV_8 (0x03) 00247 #define OLED_CLOCKDIV_16 (0x04) 00248 #define OLED_CLOCKDIV_32 (0x05) 00249 #define OLED_CLOCKDIV_64 (0x06) 00250 #define OLED_CLOCKDIV_128 (0x07) 00251 #define OLED_CLOCKDIV_256 (0x08) 00252 #define OLED_CLOCKDIV_512 (0x09) 00253 #define OLED_CLOCKDIV_1024 (0x0A) 00254 00255 // oscillator frequency, frequency increases as level increases 00256 #define OLED_OSC_FREQ (0xB0) 00257 00258 #define OLED_CMD_STARTLINE (0xA1) 00259 00260 #define OLED_CMD_WRITERAM (0x5C) 00261 #define OLED_CMD_READRAM (0x5D) 00262 #define OLED_CMD_DISPLAYOFFSET (0xA2) 00263 #define OLED_CMD_DISPLAYALLOFF (0xA4) 00264 #define OLED_CMD_DISPLAYALLON (0xA5) 00265 #define OLED_CMD_NORMALDISPLAY (0xA6) 00266 #define OLED_CMD_INVERTDISPLAY (0xA7) 00267 #define OLED_CMD_FUNCTIONSELECT (0xAB) 00268 #define OLED_CMD_DISPLAYOFF (0xAE) 00269 #define OLED_CMD_DISPLAYON (0xAF) 00270 #define OLED_CMD_PRECHARGE (0xB1) 00271 #define OLED_CMD_DISPLAYENHANCE (0xB2) 00272 #define OLED_CMD_SETVSL (0xB4) 00273 #define OLED_CMD_SETGPIO (0xB5) 00274 #define OLED_CMD_PRECHARGE2 (0xB6) 00275 #define OLED_CMD_SETGRAY (0xB8) 00276 #define OLED_CMD_USELUT (0xB9) 00277 #define OLED_CMD_PRECHARGELEVEL (0xBB) 00278 #define OLED_CMD_VCOMH (0xBE) 00279 #define OLED_CMD_CONTRASTABC (0xC1) 00280 #define OLED_CMD_CONTRASTMASTER (0xC7) 00281 #define OLED_CMD_MUXRATIO (0xCA) 00282 #define OLED_CMD_COMMANDLOCK (0xFD) 00283 #define OLED_CMD_HORIZSCROLL (0x96) 00284 #define OLED_CMD_STOPSCROLL (0x9E) 00285 #define OLED_CMD_STARTSCROLL (0x9F) 00286 00287 #endif 00288
Generated on Mon Jul 18 2022 21:55:23 by
1.7.2
