These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Committer:
frank26080115
Date:
Sun Mar 20 05:38:56 2011 +0000
Revision:
0:bf7b9fba3924

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frank26080115 0:bf7b9fba3924 1 /*************************************************************************
frank26080115 0:bf7b9fba3924 2 *
frank26080115 0:bf7b9fba3924 3 *
frank26080115 0:bf7b9fba3924 4 * (c) Copyright IAR Systems 2006
frank26080115 0:bf7b9fba3924 5 *
frank26080115 0:bf7b9fba3924 6 * File name : drv_glcd.c
frank26080115 0:bf7b9fba3924 7 * Description : Graphic LCD driver
frank26080115 0:bf7b9fba3924 8 *
frank26080115 0:bf7b9fba3924 9 * History :
frank26080115 0:bf7b9fba3924 10 * 1. Date : December 2, 2006
frank26080115 0:bf7b9fba3924 11 * Author : Stanimir Bonev
frank26080115 0:bf7b9fba3924 12 * Description : Create
frank26080115 0:bf7b9fba3924 13 *
frank26080115 0:bf7b9fba3924 14 * $Revision: 28532 $
frank26080115 0:bf7b9fba3924 15 **************************************************************************/
frank26080115 0:bf7b9fba3924 16 #include "drv_glcd.h"
frank26080115 0:bf7b9fba3924 17 #include "lpc_types.h"
frank26080115 0:bf7b9fba3924 18 #include "stdarg.h"
frank26080115 0:bf7b9fba3924 19 #include <assert.h>
frank26080115 0:bf7b9fba3924 20 #include "glcd_ll.h"
frank26080115 0:bf7b9fba3924 21
frank26080115 0:bf7b9fba3924 22 /* delay definition */
frank26080115 0:bf7b9fba3924 23 #define GLCD_DLY_10US 80 // 10us
frank26080115 0:bf7b9fba3924 24 #define GLCD_RESET_DLY 50 // 5ms
frank26080115 0:bf7b9fba3924 25 #define GLCD_BOOSTER_ON_DLY 1200 // 120 ms
frank26080115 0:bf7b9fba3924 26
frank26080115 0:bf7b9fba3924 27 static const GLCD_CmdCtrl_t GLCD_Cmd_Iss0[GLCD_CMD_NUMB] =
frank26080115 0:bf7b9fba3924 28 {
frank26080115 0:bf7b9fba3924 29 // (ISS=0)
frank26080115 0:bf7b9fba3924 30 // NOP - No Operation
frank26080115 0:bf7b9fba3924 31 {0x00, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 32 // SLPIN - Sleep in & booster off
frank26080115 0:bf7b9fba3924 33 {0x10, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 34 // SLPOUT - Sleep out & booster on
frank26080115 0:bf7b9fba3924 35 {0x11, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 36 // PTLOUT (NORON) - Partial off (Normal)
frank26080115 0:bf7b9fba3924 37 {0x13, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 38 // INVOFF - Display inversion off (normal)
frank26080115 0:bf7b9fba3924 39 {0x20, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 40 // INVON - Display inversion on
frank26080115 0:bf7b9fba3924 41 {0x21, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 42 // DISPOFF - Display off
frank26080115 0:bf7b9fba3924 43 {0x28, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 44 // DISPON - Display on
frank26080115 0:bf7b9fba3924 45 {0x29, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 46 // CASET - Column address set
frank26080115 0:bf7b9fba3924 47 // X_ADR start: 0h <= XS <= 83h
frank26080115 0:bf7b9fba3924 48 // X_ADR end: 0h <= XS <= 83h
frank26080115 0:bf7b9fba3924 49 {0x2A, GLCD_WRITE, 0, 2},
frank26080115 0:bf7b9fba3924 50 // RASET - Row address set
frank26080115 0:bf7b9fba3924 51 // Y_ADR start: 0h <= YS <= 83h
frank26080115 0:bf7b9fba3924 52 // Y_ADR end: 0h <= YS <= 83h
frank26080115 0:bf7b9fba3924 53 {0x2B, GLCD_WRITE, 0, 2},
frank26080115 0:bf7b9fba3924 54 // RAMWR - Memory write
frank26080115 0:bf7b9fba3924 55 {0x2C, GLCD_WRITE, 0, (uint32_t)-1},
frank26080115 0:bf7b9fba3924 56 // RGBSET - Color set for 256 color display
frank26080115 0:bf7b9fba3924 57 {0x2D, GLCD_WRITE, 0, 20},
frank26080115 0:bf7b9fba3924 58 // VSCSAD - Scroll start address of RAM
frank26080115 0:bf7b9fba3924 59 // SSA = 0, 1, 2, … , 131
frank26080115 0:bf7b9fba3924 60 {0x37, GLCD_WRITE, 0, 1},
frank26080115 0:bf7b9fba3924 61 // IDMOFF - Idle mode off
frank26080115 0:bf7b9fba3924 62 {0x38, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 63 // IDMON - Idle mode on
frank26080115 0:bf7b9fba3924 64 {0x39, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 65 // RDID1 - Interface pixel format
frank26080115 0:bf7b9fba3924 66 {0xDA, GLCD_READ, 0, 1},
frank26080115 0:bf7b9fba3924 67 // RDID2 - Interface pixel format
frank26080115 0:bf7b9fba3924 68 {0xDB, GLCD_READ, 0, 1},
frank26080115 0:bf7b9fba3924 69 // RDID3 - Interface pixel format
frank26080115 0:bf7b9fba3924 70 {0xDC, GLCD_READ, 0, 1},
frank26080115 0:bf7b9fba3924 71 // FRMSEL - External oscillator select
frank26080115 0:bf7b9fba3924 72 // Frame frequency in Temp range A
frank26080115 0:bf7b9fba3924 73 // Frame frequency in Temp range B
frank26080115 0:bf7b9fba3924 74 // Frame frequency in Temp range C
frank26080115 0:bf7b9fba3924 75 // Frame frequency in Temp range D
frank26080115 0:bf7b9fba3924 76 {0xB4, GLCD_WRITE, 0, 4},
frank26080115 0:bf7b9fba3924 77 // FRM8SEL - External oscillator select
frank26080115 0:bf7b9fba3924 78 // Frame frequency in Temp range A
frank26080115 0:bf7b9fba3924 79 // Frame frequency in Temp range B
frank26080115 0:bf7b9fba3924 80 // Frame frequency in Temp range C
frank26080115 0:bf7b9fba3924 81 // Frame frequency in Temp range D
frank26080115 0:bf7b9fba3924 82 {0xB5, GLCD_WRITE, 0, 4},
frank26080115 0:bf7b9fba3924 83 // TMPRNG - External oscillator select
frank26080115 0:bf7b9fba3924 84 // Temp range A
frank26080115 0:bf7b9fba3924 85 // Temp range B
frank26080115 0:bf7b9fba3924 86 // Temp range C
frank26080115 0:bf7b9fba3924 87 // Temp range D
frank26080115 0:bf7b9fba3924 88 {0xB6, GLCD_WRITE, 0, 4},
frank26080115 0:bf7b9fba3924 89 // TMPHIS - Temp range set
frank26080115 0:bf7b9fba3924 90 {0xB8, GLCD_WRITE, 0, 1},
frank26080115 0:bf7b9fba3924 91 // TMPREAD - Temperature read back
frank26080115 0:bf7b9fba3924 92 {0xB7, GLCD_READ, 0, 1},
frank26080115 0:bf7b9fba3924 93 // EPWRIN - EEPROM write start
frank26080115 0:bf7b9fba3924 94 {0xD1, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 95 // EPWROUT - EEPROM write end
frank26080115 0:bf7b9fba3924 96 {0xD0, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 97 // RDEV - Read internal contrast (EV_IN)
frank26080115 0:bf7b9fba3924 98 {0xD4, GLCD_WRITE, 0, 1},
frank26080115 0:bf7b9fba3924 99 // RDRR - Read internal resistor ratio (RR_IN)
frank26080115 0:bf7b9fba3924 100 {0xD5, GLCD_READ, 0, 1},
frank26080115 0:bf7b9fba3924 101 // Adapted commands
frank26080115 0:bf7b9fba3924 102 // PTIN - adapted command (PTLAR + PTIN)
frank26080115 0:bf7b9fba3924 103 {0x00, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 104 // SCRLAR - Scroll area set (2-line unit)
frank26080115 0:bf7b9fba3924 105 // TFA = 0,1,2, … , 132
frank26080115 0:bf7b9fba3924 106 // VSA = 0,1,2, … , 132
frank26080115 0:bf7b9fba3924 107 // BFA = 0,1,2, … , 132
frank26080115 0:bf7b9fba3924 108 {0x33, GLCD_WRITE, 0, 3},
frank26080115 0:bf7b9fba3924 109 // DATCTR - adapted command (MADCTR + COLMOD)
frank26080115 0:bf7b9fba3924 110 {0x00, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 111 // SETCON - Write contrast 0 - 127
frank26080115 0:bf7b9fba3924 112 {0x25, GLCD_WRITE, 0, 1},
frank26080115 0:bf7b9fba3924 113 // Commands applicable only when ISS=1
frank26080115 0:bf7b9fba3924 114 // OSCON
frank26080115 0:bf7b9fba3924 115 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 116 // OSCOFF
frank26080115 0:bf7b9fba3924 117 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 118 // RMWIN
frank26080115 0:bf7b9fba3924 119 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 120 // RMWOUT
frank26080115 0:bf7b9fba3924 121 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 122 // VOLUP
frank26080115 0:bf7b9fba3924 123 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 124 // VOLDOWN
frank26080115 0:bf7b9fba3924 125 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 126 // ASCSET
frank26080115 0:bf7b9fba3924 127 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 128 // DISCTR
frank26080115 0:bf7b9fba3924 129 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 130 // PWRCTR
frank26080115 0:bf7b9fba3924 131 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 132 // VOLCTR
frank26080115 0:bf7b9fba3924 133 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 134 // Commands applicable only when ISS=0
frank26080115 0:bf7b9fba3924 135 // CLKINT - Internal oscillator select
frank26080115 0:bf7b9fba3924 136 {0xB0, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 137 // CLKEXT - External oscillator select
frank26080115 0:bf7b9fba3924 138 {0xB1, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 139 // RDDST - Read Display Status
frank26080115 0:bf7b9fba3924 140 {0x09, GLCD_READ, 1, 4},
frank26080115 0:bf7b9fba3924 141 // SWRESET - Software reset
frank26080115 0:bf7b9fba3924 142 {0x01, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 143 // RDDID - Read Display ID
frank26080115 0:bf7b9fba3924 144 {0x04, GLCD_READ, 1, 3},
frank26080115 0:bf7b9fba3924 145 // PTLAR - Partial start/end address set
frank26080115 0:bf7b9fba3924 146 // Start address (0,1,2, …, 131)
frank26080115 0:bf7b9fba3924 147 // End address (0,1,2, …, 131)
frank26080115 0:bf7b9fba3924 148 {0x30, GLCD_WRITE, 0, 2},
frank26080115 0:bf7b9fba3924 149 // PTLON - Partial mode on
frank26080115 0:bf7b9fba3924 150 {0x12, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 151 // MADCTR - Tearing effect mode set & on
frank26080115 0:bf7b9fba3924 152 {0x36, GLCD_WRITE, 0, 1},
frank26080115 0:bf7b9fba3924 153 // COLMOD - Interface pixel format
frank26080115 0:bf7b9fba3924 154 // Interface format
frank26080115 0:bf7b9fba3924 155 {0x3A, GLCD_WRITE, 0, 1},
frank26080115 0:bf7b9fba3924 156 // APOFF - All pixel off (only for test purpose)
frank26080115 0:bf7b9fba3924 157 {0x22, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 158 // APON - All pixel on (only for test purpose)
frank26080115 0:bf7b9fba3924 159 {0x23, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 160 // BSTROFF - Booster off (only for test purpose)
frank26080115 0:bf7b9fba3924 161 {0x02, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 162 // BSTRON - Booster on (only for test purpose)
frank26080115 0:bf7b9fba3924 163 {0x03, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 164 };
frank26080115 0:bf7b9fba3924 165
frank26080115 0:bf7b9fba3924 166 static const GLCD_CmdCtrl_t GLCD_Cmd_Iss1[GLCD_CMD_NUMB] =
frank26080115 0:bf7b9fba3924 167 {
frank26080115 0:bf7b9fba3924 168 // (ISS=1)
frank26080115 0:bf7b9fba3924 169 // NOP - No Operation
frank26080115 0:bf7b9fba3924 170 {0x25, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 171 // SLPIN - Sleep in & booster off
frank26080115 0:bf7b9fba3924 172 {0x95, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 173 // SLPOUT - Sleep out & booster on
frank26080115 0:bf7b9fba3924 174 {0x94, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 175 // PTLOUT (NORON) - Partial off (Normal)
frank26080115 0:bf7b9fba3924 176 {0xA9, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 177 // INVOFF - Display inversion off (normal)
frank26080115 0:bf7b9fba3924 178 {0xA6, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 179 // INVON - Display inversion on
frank26080115 0:bf7b9fba3924 180 {0xA7, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 181 // DISPOFF - Display off
frank26080115 0:bf7b9fba3924 182 {0xAE, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 183 // DISPON - Display on
frank26080115 0:bf7b9fba3924 184 {0xAF, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 185 // CASET - Column address set
frank26080115 0:bf7b9fba3924 186 // X_ADR start: 0h <= XS <= 83h
frank26080115 0:bf7b9fba3924 187 // X_ADR end: 0h <= XS <= 83h
frank26080115 0:bf7b9fba3924 188 {0x15, GLCD_WRITE, 0, 2},
frank26080115 0:bf7b9fba3924 189 // RASET - Row address set
frank26080115 0:bf7b9fba3924 190 // Y_ADR start: 0h <= YS <= 83h
frank26080115 0:bf7b9fba3924 191 // Y_ADR end: 0h <= YS <= 83h
frank26080115 0:bf7b9fba3924 192 {0x75, GLCD_WRITE, 0, 2},
frank26080115 0:bf7b9fba3924 193 // RAMWR - Memory write
frank26080115 0:bf7b9fba3924 194 {0x5C, GLCD_WRITE, 0, (uint32_t)-1},
frank26080115 0:bf7b9fba3924 195 // RGBSET - Color set for 256 color display
frank26080115 0:bf7b9fba3924 196 {0xCE, GLCD_WRITE, 0, 20},
frank26080115 0:bf7b9fba3924 197 // VSCSAD - Scroll start address of RAM
frank26080115 0:bf7b9fba3924 198 // SSA = 0, 1, 2, … , 131
frank26080115 0:bf7b9fba3924 199 {0xAB, GLCD_WRITE, 0, 1},
frank26080115 0:bf7b9fba3924 200 // IDMOFF - Idle mode off
frank26080115 0:bf7b9fba3924 201 {0x38, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 202 // IDMON - Idle mode on
frank26080115 0:bf7b9fba3924 203 {0x39, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 204 // RDID1 - Interface pixel format
frank26080115 0:bf7b9fba3924 205 {0xDA, GLCD_READ, 0, 1},
frank26080115 0:bf7b9fba3924 206 // RDID2 - Interface pixel format
frank26080115 0:bf7b9fba3924 207 {0xDB, GLCD_READ, 0, 1},
frank26080115 0:bf7b9fba3924 208 // RDID3 - Interface pixel format
frank26080115 0:bf7b9fba3924 209 {0xDC, GLCD_READ, 0, 1},
frank26080115 0:bf7b9fba3924 210 // FRMSEL - External oscillator select
frank26080115 0:bf7b9fba3924 211 // Frame frequency in Temp range A
frank26080115 0:bf7b9fba3924 212 // Frame frequency in Temp range B
frank26080115 0:bf7b9fba3924 213 // Frame frequency in Temp range C
frank26080115 0:bf7b9fba3924 214 // Frame frequency in Temp range D
frank26080115 0:bf7b9fba3924 215 {0xB4, GLCD_WRITE, 0, 4},
frank26080115 0:bf7b9fba3924 216 // FRM8SEL - External oscillator select
frank26080115 0:bf7b9fba3924 217 // Frame frequency in Temp range A
frank26080115 0:bf7b9fba3924 218 // Frame frequency in Temp range B
frank26080115 0:bf7b9fba3924 219 // Frame frequency in Temp range C
frank26080115 0:bf7b9fba3924 220 // Frame frequency in Temp range D
frank26080115 0:bf7b9fba3924 221 {0xB5, GLCD_WRITE, 0, 4},
frank26080115 0:bf7b9fba3924 222 // TMPRNG - External oscillator select
frank26080115 0:bf7b9fba3924 223 // Temp range A
frank26080115 0:bf7b9fba3924 224 // Temp range B
frank26080115 0:bf7b9fba3924 225 // Temp range C
frank26080115 0:bf7b9fba3924 226 // Temp range D
frank26080115 0:bf7b9fba3924 227 {0xB6, GLCD_WRITE, 0, 4},
frank26080115 0:bf7b9fba3924 228 // TMPHIS - Temp hysteresis range set
frank26080115 0:bf7b9fba3924 229 {0xB8, GLCD_WRITE, 0, 1},
frank26080115 0:bf7b9fba3924 230 // TMPREAD - Temperature read back
frank26080115 0:bf7b9fba3924 231 {0xB7, GLCD_READ, 0, 1},
frank26080115 0:bf7b9fba3924 232 // EPWRIN - EEPROM write start
frank26080115 0:bf7b9fba3924 233 {0xCD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 234 // EPWROUT - EEPROM write end
frank26080115 0:bf7b9fba3924 235 {0xCC, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 236 // RDEV - Read internal contrast (EV_IN)
frank26080115 0:bf7b9fba3924 237 {0x7C, GLCD_WRITE, 0, 1},
frank26080115 0:bf7b9fba3924 238 // RDRR - Read internal resistor ratio (RR_IN)
frank26080115 0:bf7b9fba3924 239 {0x7D, GLCD_READ, 0, 1},
frank26080115 0:bf7b9fba3924 240 // Adapted commands
frank26080115 0:bf7b9fba3924 241 // PTIN - Partial area set & on
frank26080115 0:bf7b9fba3924 242 // Partial start line address
frank26080115 0:bf7b9fba3924 243 // PSL7-0 Partial start line address
frank26080115 0:bf7b9fba3924 244 // PEL7-0 Partial end line address
frank26080115 0:bf7b9fba3924 245 {0xA8, GLCD_WRITE, 0, 2},
frank26080115 0:bf7b9fba3924 246 // SCRLAR(ASCSET) - Scroll area set (2-line unit) Mode-0
frank26080115 0:bf7b9fba3924 247 // SSL7-0 - Scroll start line
frank26080115 0:bf7b9fba3924 248 // SEL7-0 - Scroll end line
frank26080115 0:bf7b9fba3924 249 // SFL7-0 - Scroll specified line
frank26080115 0:bf7b9fba3924 250 // SMD2-0 - Area scroll mode
frank26080115 0:bf7b9fba3924 251 {0xAA, GLCD_WRITE, 0, 4},
frank26080115 0:bf7b9fba3924 252 // DATCTR - adapted command (MADCTR + COLMOD)
frank26080115 0:bf7b9fba3924 253 // MV MX MY - Row/column address control
frank26080115 0:bf7b9fba3924 254 // MRGB - RGB
frank26080115 0:bf7b9fba3924 255 // GS2 GS1 GS0 - Gray-scale setup
frank26080115 0:bf7b9fba3924 256 {0xBC, GLCD_WRITE, 0, 3},
frank26080115 0:bf7b9fba3924 257 // SETCON - Write contrast 0 - 127
frank26080115 0:bf7b9fba3924 258 {0x00, GLCD_WRITE, 0, 1},
frank26080115 0:bf7b9fba3924 259 // Commands applicable only when ISS=1
frank26080115 0:bf7b9fba3924 260 // OSCON - Oscillator on
frank26080115 0:bf7b9fba3924 261 {0xD1, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 262 // OSCOFF - Oscillator off
frank26080115 0:bf7b9fba3924 263 {0xD2, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 264 // RMWIN - Read & modify write on
frank26080115 0:bf7b9fba3924 265 {0xE0, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 266 // RMWOUT - Read & modify write off
frank26080115 0:bf7b9fba3924 267 {0xEE, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 268 // VOLUP - EV increment
frank26080115 0:bf7b9fba3924 269 {0xD6, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 270 // VOLDOWN - EV decrement
frank26080115 0:bf7b9fba3924 271 {0xD7, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 272 // ASCSET - Scroll area set
frank26080115 0:bf7b9fba3924 273 // SSL7-0 - Scroll start line
frank26080115 0:bf7b9fba3924 274 // SEL7-0 - Scroll end line
frank26080115 0:bf7b9fba3924 275 // SFL7-0 - Scroll specified line
frank26080115 0:bf7b9fba3924 276 // SMD1-0 - Area scroll mode
frank26080115 0:bf7b9fba3924 277 {0xAA, GLCD_WRITE, 0, 4},
frank26080115 0:bf7b9fba3924 278 // DISCTR - Display control
frank26080115 0:bf7b9fba3924 279 // P1
frank26080115 0:bf7b9fba3924 280 // P2
frank26080115 0:bf7b9fba3924 281 // P3
frank26080115 0:bf7b9fba3924 282 {0xCA, GLCD_WRITE, 0, 3},
frank26080115 0:bf7b9fba3924 283 // PWRCTR - Power control set
frank26080115 0:bf7b9fba3924 284 // P13-P10
frank26080115 0:bf7b9fba3924 285 {0x20, GLCD_WRITE, 0, 1},
frank26080115 0:bf7b9fba3924 286 // VOLCTR
frank26080115 0:bf7b9fba3924 287 {0x81, GLCD_WRITE, 0, 2},
frank26080115 0:bf7b9fba3924 288 // Commands applicable only when ISS=0
frank26080115 0:bf7b9fba3924 289 // CLKINT - Internal oscillator select
frank26080115 0:bf7b9fba3924 290 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 291 // CLKEXT - External oscillator select
frank26080115 0:bf7b9fba3924 292 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 293 // RDDST - Read Display Status
frank26080115 0:bf7b9fba3924 294 {GLCD_INV_CMD, GLCD_READ, 0, 0},
frank26080115 0:bf7b9fba3924 295 // SWRESET - Software reset
frank26080115 0:bf7b9fba3924 296 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 297 // RDDID - Read Display ID
frank26080115 0:bf7b9fba3924 298 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 299 // PTLAR - Partial start/end address set
frank26080115 0:bf7b9fba3924 300 // Start address (0,1,2, …, 131)
frank26080115 0:bf7b9fba3924 301 // End address (0,1,2, …, 131)
frank26080115 0:bf7b9fba3924 302 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 303 // PTLON - Partial mode on
frank26080115 0:bf7b9fba3924 304 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 305 // MADCTR - Tearing effect mode set & on
frank26080115 0:bf7b9fba3924 306 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 307 // COLMOD - Interface pixel format
frank26080115 0:bf7b9fba3924 308 // Interface format
frank26080115 0:bf7b9fba3924 309 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 310 // APOFF - All pixel off (only for test purpose)
frank26080115 0:bf7b9fba3924 311 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 312 // APON - All pixel on (only for test purpose)
frank26080115 0:bf7b9fba3924 313 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 314 // BSTROFF - Booster off (only for test purpose)
frank26080115 0:bf7b9fba3924 315 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 316 // BSTRON - Booster on (only for test purpose)
frank26080115 0:bf7b9fba3924 317 {GLCD_INV_CMD, GLCD_WRITE, 0, 0},
frank26080115 0:bf7b9fba3924 318 };
frank26080115 0:bf7b9fba3924 319
frank26080115 0:bf7b9fba3924 320 static GLCD_ISS_t Glcd_Iss;
frank26080115 0:bf7b9fba3924 321 static Bool OddPixel = FALSE;
frank26080115 0:bf7b9fba3924 322 static uint32_t PixelHold = 0;
frank26080115 0:bf7b9fba3924 323
frank26080115 0:bf7b9fba3924 324
frank26080115 0:bf7b9fba3924 325 static pFontType_t pCurrFont = NULL;
frank26080115 0:bf7b9fba3924 326 static LdcPixel_t TextColour;
frank26080115 0:bf7b9fba3924 327 static LdcPixel_t TextBackgndColour;
frank26080115 0:bf7b9fba3924 328
frank26080115 0:bf7b9fba3924 329 static uint32_t TextX_Pos = 0;
frank26080115 0:bf7b9fba3924 330 static uint32_t TextY_Pos = 0;
frank26080115 0:bf7b9fba3924 331
frank26080115 0:bf7b9fba3924 332 static uint32_t XL_Win = DEF_X_LEFT;
frank26080115 0:bf7b9fba3924 333 static uint32_t YU_Win = DEF_Y_UP;
frank26080115 0:bf7b9fba3924 334 static uint32_t XR_Win = DEF_X_RIGHT;
frank26080115 0:bf7b9fba3924 335 static uint32_t YD_Win = DEF_Y_DOWN;
frank26080115 0:bf7b9fba3924 336
frank26080115 0:bf7b9fba3924 337 static uint32_t TabSize = TEXT_DEF_TAB_SIZE;
frank26080115 0:bf7b9fba3924 338
frank26080115 0:bf7b9fba3924 339 /*************************************************************************
frank26080115 0:bf7b9fba3924 340 * Function Name: GLCD_SendCmd
frank26080115 0:bf7b9fba3924 341 * Parameters: GLCD_SendCmd Cmd, unsigned char *pData, uint32_t Size
frank26080115 0:bf7b9fba3924 342 * Return: GLCD_Status_t
frank26080115 0:bf7b9fba3924 343 *
frank26080115 0:bf7b9fba3924 344 * Description: Send command to the Graphic LCD
frank26080115 0:bf7b9fba3924 345 *
frank26080115 0:bf7b9fba3924 346 *************************************************************************/
frank26080115 0:bf7b9fba3924 347 GLCD_Status_t GLCD_SendCmd (GLCD_Cmd_t Cmd, unsigned char *pData, uint32_t Size)
frank26080115 0:bf7b9fba3924 348 {
frank26080115 0:bf7b9fba3924 349 static Bool Write2_DRAM = FALSE; // write to DRAM mode
frank26080115 0:bf7b9fba3924 350 static uint32_t ResRatio; // Hold resistor ratio init by VOLCTR
frank26080115 0:bf7b9fba3924 351 // and used by SETCON adapted command
frank26080115 0:bf7b9fba3924 352 pDATCTR_Data_t pDATCTR_Data;
frank26080115 0:bf7b9fba3924 353 uint8_t ColourSch;
frank26080115 0:bf7b9fba3924 354 pASCSET_Data_t pASCSET_Data;
frank26080115 0:bf7b9fba3924 355 MADCTR_Data_t DataMode = {0};
frank26080115 0:bf7b9fba3924 356 // Pointer to current set of commands
frank26080115 0:bf7b9fba3924 357 pGLCD_CmdCtrl_t pGLCD_CmdCtrl = (pGLCD_CmdCtrl_t)(((Glcd_Iss==GLCD_ISS_0)?
frank26080115 0:bf7b9fba3924 358 GLCD_Cmd_Iss0:GLCD_Cmd_Iss1) + Cmd);
frank26080115 0:bf7b9fba3924 359
frank26080115 0:bf7b9fba3924 360 uint32_t Contrast;
frank26080115 0:bf7b9fba3924 361
frank26080115 0:bf7b9fba3924 362 if(Write2_DRAM)
frank26080115 0:bf7b9fba3924 363 {
frank26080115 0:bf7b9fba3924 364 // Select LCD
frank26080115 0:bf7b9fba3924 365 GLCD_SPI_ChipSelect(1);
frank26080115 0:bf7b9fba3924 366 if(Cmd != RAMWR)
frank26080115 0:bf7b9fba3924 367 {
frank26080115 0:bf7b9fba3924 368 Write2_DRAM = FALSE;
frank26080115 0:bf7b9fba3924 369 if(PixelHold & WAITED_PIXEL)
frank26080115 0:bf7b9fba3924 370 {
frank26080115 0:bf7b9fba3924 371 // Flush pixel
frank26080115 0:bf7b9fba3924 372 GLCD_SPI_TranserByte(PixelHold);
frank26080115 0:bf7b9fba3924 373 }
frank26080115 0:bf7b9fba3924 374 // Release CS
frank26080115 0:bf7b9fba3924 375 GLCD_SPI_ChipSelect(0);
frank26080115 0:bf7b9fba3924 376 }
frank26080115 0:bf7b9fba3924 377 else
frank26080115 0:bf7b9fba3924 378 {
frank26080115 0:bf7b9fba3924 379 // pixels collection
frank26080115 0:bf7b9fba3924 380 uint32_t Pixel;
frank26080115 0:bf7b9fba3924 381 while(Size > 1)
frank26080115 0:bf7b9fba3924 382 {
frank26080115 0:bf7b9fba3924 383 Pixel = *pData++;
frank26080115 0:bf7b9fba3924 384 Pixel |= (*pData++)<<8;
frank26080115 0:bf7b9fba3924 385 PixelHold |= WAITED_PIXEL;
frank26080115 0:bf7b9fba3924 386 if(!OddPixel)
frank26080115 0:bf7b9fba3924 387 {
frank26080115 0:bf7b9fba3924 388 // Get even pixel
frank26080115 0:bf7b9fba3924 389 PixelHold |= PIXEL_CONV(Pixel,0);
frank26080115 0:bf7b9fba3924 390 }
frank26080115 0:bf7b9fba3924 391 else
frank26080115 0:bf7b9fba3924 392 {
frank26080115 0:bf7b9fba3924 393 // Apply odd pixel
frank26080115 0:bf7b9fba3924 394 PixelHold |= PIXEL_CONV(Pixel,1);
frank26080115 0:bf7b9fba3924 395 // and send together both pixels
frank26080115 0:bf7b9fba3924 396 GLCD_SPI_SendBlock((unsigned char *)&PixelHold,3);
frank26080115 0:bf7b9fba3924 397 PixelHold = 0;
frank26080115 0:bf7b9fba3924 398 }
frank26080115 0:bf7b9fba3924 399 // update the even/odd flag
frank26080115 0:bf7b9fba3924 400 OddPixel ^= 1;
frank26080115 0:bf7b9fba3924 401 // update the counter of the remaining bytes
frank26080115 0:bf7b9fba3924 402 Size -= 2;
frank26080115 0:bf7b9fba3924 403 }
frank26080115 0:bf7b9fba3924 404 // Release CS
frank26080115 0:bf7b9fba3924 405 GLCD_SPI_ChipSelect(0);
frank26080115 0:bf7b9fba3924 406 return(GLCD_OK);
frank26080115 0:bf7b9fba3924 407 }
frank26080115 0:bf7b9fba3924 408 }
frank26080115 0:bf7b9fba3924 409
frank26080115 0:bf7b9fba3924 410 // sanitary check of command
frank26080115 0:bf7b9fba3924 411 if(pGLCD_CmdCtrl->Cmd == GLCD_INV_CMD)
frank26080115 0:bf7b9fba3924 412 {
frank26080115 0:bf7b9fba3924 413 return(GLCD_UNSUPPORTED);
frank26080115 0:bf7b9fba3924 414 }
frank26080115 0:bf7b9fba3924 415
frank26080115 0:bf7b9fba3924 416 // Implement adapted commands
frank26080115 0:bf7b9fba3924 417 if(Glcd_Iss==GLCD_ISS_0)
frank26080115 0:bf7b9fba3924 418 {
frank26080115 0:bf7b9fba3924 419 switch(Cmd)
frank26080115 0:bf7b9fba3924 420 {
frank26080115 0:bf7b9fba3924 421 case PTIN:
frank26080115 0:bf7b9fba3924 422 // PTLAR + PTIN
frank26080115 0:bf7b9fba3924 423 GLCD_SendCmd(PTLAR,pData,0);
frank26080115 0:bf7b9fba3924 424 GLCD_SendCmd(PTLON,NULL,0);
frank26080115 0:bf7b9fba3924 425 return(GLCD_OK);
frank26080115 0:bf7b9fba3924 426 case DATCTR:
frank26080115 0:bf7b9fba3924 427 pDATCTR_Data = (pDATCTR_Data_t)pData;
frank26080115 0:bf7b9fba3924 428 // MADCTR + COLMOD
frank26080115 0:bf7b9fba3924 429 // Data reconstruction
frank26080115 0:bf7b9fba3924 430 DataMode.MY = pDATCTR_Data->MY;
frank26080115 0:bf7b9fba3924 431 DataMode.MX = pDATCTR_Data->MX;
frank26080115 0:bf7b9fba3924 432 DataMode.MV = pDATCTR_Data->MV;
frank26080115 0:bf7b9fba3924 433 DataMode.ML = pDATCTR_Data->ML;
frank26080115 0:bf7b9fba3924 434 DataMode.RGB = !pDATCTR_Data->RGB;
frank26080115 0:bf7b9fba3924 435 GLCD_SendCmd(MADCTR,(unsigned char*)&DataMode,0);
frank26080115 0:bf7b9fba3924 436 // 4K colors Type A
frank26080115 0:bf7b9fba3924 437 ColourSch = 3;
frank26080115 0:bf7b9fba3924 438 return(GLCD_SendCmd(COLMOD,&ColourSch,0));
frank26080115 0:bf7b9fba3924 439 }
frank26080115 0:bf7b9fba3924 440 }
frank26080115 0:bf7b9fba3924 441 else
frank26080115 0:bf7b9fba3924 442 {
frank26080115 0:bf7b9fba3924 443 switch(Cmd)
frank26080115 0:bf7b9fba3924 444 {
frank26080115 0:bf7b9fba3924 445 case SCRLAR:
frank26080115 0:bf7b9fba3924 446 pASCSET_Data = (pASCSET_Data_t)pData;
frank26080115 0:bf7b9fba3924 447 pASCSET_Data->Smd = 0; // Center screen scroll mode
frank26080115 0:bf7b9fba3924 448 GLCD_SendCmd(ASCSET,pData,0);
frank26080115 0:bf7b9fba3924 449 return(GLCD_OK);
frank26080115 0:bf7b9fba3924 450 case DATCTR:
frank26080115 0:bf7b9fba3924 451 pDATCTR_Data = (pDATCTR_Data_t)pData;
frank26080115 0:bf7b9fba3924 452 pDATCTR_Data->ML = 0;
frank26080115 0:bf7b9fba3924 453 pDATCTR_Data->MX = !pDATCTR_Data->MX;
frank26080115 0:bf7b9fba3924 454 // 4K colors Type A
frank26080115 0:bf7b9fba3924 455 pDATCTR_Data->GS = 2;
frank26080115 0:bf7b9fba3924 456 break;
frank26080115 0:bf7b9fba3924 457 case SETCON:
frank26080115 0:bf7b9fba3924 458 Contrast = *pData | (ResRatio << 8);
frank26080115 0:bf7b9fba3924 459 return(GLCD_SendCmd(VOLCTR,(unsigned char *)&Contrast,0));
frank26080115 0:bf7b9fba3924 460 case VOLCTR:
frank26080115 0:bf7b9fba3924 461 ResRatio = *(pData+1);
frank26080115 0:bf7b9fba3924 462 break;
frank26080115 0:bf7b9fba3924 463 }
frank26080115 0:bf7b9fba3924 464 }
frank26080115 0:bf7b9fba3924 465
frank26080115 0:bf7b9fba3924 466 if(pGLCD_CmdCtrl->Param != (uint32_t)-1)
frank26080115 0:bf7b9fba3924 467 {
frank26080115 0:bf7b9fba3924 468 // Command with fixed size of parameters
frank26080115 0:bf7b9fba3924 469 Size = pGLCD_CmdCtrl->Param;
frank26080115 0:bf7b9fba3924 470 }
frank26080115 0:bf7b9fba3924 471
frank26080115 0:bf7b9fba3924 472 // Select LCD
frank26080115 0:bf7b9fba3924 473 GLCD_SPI_ChipSelect(1);
frank26080115 0:bf7b9fba3924 474
frank26080115 0:bf7b9fba3924 475 GLCD_SPI_TranserByte(pGLCD_CmdCtrl->Cmd);
frank26080115 0:bf7b9fba3924 476 if(Cmd == RAMWR)
frank26080115 0:bf7b9fba3924 477 {
frank26080115 0:bf7b9fba3924 478 // enter in write to DRAM mode
frank26080115 0:bf7b9fba3924 479 OddPixel = FALSE;
frank26080115 0:bf7b9fba3924 480 PixelHold = 0;
frank26080115 0:bf7b9fba3924 481 Write2_DRAM = TRUE;
frank26080115 0:bf7b9fba3924 482 return(GLCD_SendCmd(RAMWR,pData,Size));
frank26080115 0:bf7b9fba3924 483 }
frank26080115 0:bf7b9fba3924 484
frank26080115 0:bf7b9fba3924 485 // Send/Receive parameters
frank26080115 0:bf7b9fba3924 486 if(pGLCD_CmdCtrl->Dir == GLCD_READ)
frank26080115 0:bf7b9fba3924 487 {
frank26080115 0:bf7b9fba3924 488 if(pGLCD_CmdCtrl->Pulse)
frank26080115 0:bf7b9fba3924 489 {
frank26080115 0:bf7b9fba3924 490 if(Size)
frank26080115 0:bf7b9fba3924 491 {
frank26080115 0:bf7b9fba3924 492 *pData++ = GLCD_SPI_TranserByte(0xFFFF);
frank26080115 0:bf7b9fba3924 493 --Size;
frank26080115 0:bf7b9fba3924 494 }
frank26080115 0:bf7b9fba3924 495 }
frank26080115 0:bf7b9fba3924 496 GLCD_SPI_SetWordWidth(8);
frank26080115 0:bf7b9fba3924 497 }
frank26080115 0:bf7b9fba3924 498
frank26080115 0:bf7b9fba3924 499 if(pGLCD_CmdCtrl->Dir == GLCD_READ)
frank26080115 0:bf7b9fba3924 500 {
frank26080115 0:bf7b9fba3924 501 GLCD_SPI_ReceiveBlock(pData,Size);
frank26080115 0:bf7b9fba3924 502 }
frank26080115 0:bf7b9fba3924 503 else
frank26080115 0:bf7b9fba3924 504 {
frank26080115 0:bf7b9fba3924 505 GLCD_SPI_SendBlock(pData,Size);
frank26080115 0:bf7b9fba3924 506 }
frank26080115 0:bf7b9fba3924 507
frank26080115 0:bf7b9fba3924 508 // Release CS
frank26080115 0:bf7b9fba3924 509 GLCD_SPI_ChipSelect(0);
frank26080115 0:bf7b9fba3924 510 if(pGLCD_CmdCtrl->Dir == GLCD_READ)
frank26080115 0:bf7b9fba3924 511 {
frank26080115 0:bf7b9fba3924 512 GLCD_SPI_SetWordWidth(9);
frank26080115 0:bf7b9fba3924 513 }
frank26080115 0:bf7b9fba3924 514 return(GLCD_OK);
frank26080115 0:bf7b9fba3924 515 }
frank26080115 0:bf7b9fba3924 516
frank26080115 0:bf7b9fba3924 517 /*************************************************************************
frank26080115 0:bf7b9fba3924 518 * Function Name: GLCD_PowerUpInit
frank26080115 0:bf7b9fba3924 519 * Parameters: unsigned char *pInitData
frank26080115 0:bf7b9fba3924 520 * Return: GLCD_Status_t
frank26080115 0:bf7b9fba3924 521 * GLCD_OK - init pass
frank26080115 0:bf7b9fba3924 522 * GLCD_ID_ERROR - unsupported driver type
frank26080115 0:bf7b9fba3924 523 * Description: Power-up initialization of Graphic LCD
frank26080115 0:bf7b9fba3924 524 *
frank26080115 0:bf7b9fba3924 525 *************************************************************************/
frank26080115 0:bf7b9fba3924 526 //GLCD_Status_t GLCD_PowerUpInit (unsigned char *pInitData)
frank26080115 0:bf7b9fba3924 527 GLCD_Status_t GLCD_PowerUpInit (unsigned char *pInitData)
frank26080115 0:bf7b9fba3924 528 {
frank26080115 0:bf7b9fba3924 529 uint32_t Data;
frank26080115 0:bf7b9fba3924 530 volatile uint32_t i;
frank26080115 0:bf7b9fba3924 531 pDATCTR_Data_t pDATCTR_Data;
frank26080115 0:bf7b9fba3924 532 // Init SPI and IO
frank26080115 0:bf7b9fba3924 533 // Init low level
frank26080115 0:bf7b9fba3924 534 GLCD_SPI_Init(GLCD_DEF_CLOCK,GLCD_DEF_WIDTH);
frank26080115 0:bf7b9fba3924 535 GLCD_LLInit();
frank26080115 0:bf7b9fba3924 536
frank26080115 0:bf7b9fba3924 537 // H/W Reset
frank26080115 0:bf7b9fba3924 538 // Rest L > 10us H
frank26080115 0:bf7b9fba3924 539 GLCD_SetReset(0);
frank26080115 0:bf7b9fba3924 540 for(i = GLCD_DLY_10US; i ; --i);
frank26080115 0:bf7b9fba3924 541 GLCD_SetReset(1);
frank26080115 0:bf7b9fba3924 542
frank26080115 0:bf7b9fba3924 543 // Wait 5 ms
frank26080115 0:bf7b9fba3924 544 Dly100us((void *)GLCD_RESET_DLY);
frank26080115 0:bf7b9fba3924 545 // Identify LCD and command interpreter
frank26080115 0:bf7b9fba3924 546 Glcd_Iss = GLCD_ISS_0;
frank26080115 0:bf7b9fba3924 547 GLCD_SendCmd(RDDID,(unsigned char *)&Data,0);
frank26080115 0:bf7b9fba3924 548 if(((Data & 0xFF) != GLCD_MANF_ID) ||(((Data >> 16)& 0xFF) != GLCD_MOD_ID))
frank26080115 0:bf7b9fba3924 549 {
frank26080115 0:bf7b9fba3924 550 // Iss = 1 don't support RDDID command
frank26080115 0:bf7b9fba3924 551 Glcd_Iss = GLCD_ISS_1;
frank26080115 0:bf7b9fba3924 552 }
frank26080115 0:bf7b9fba3924 553 // Power Supply Set
frank26080115 0:bf7b9fba3924 554 if(Glcd_Iss == GLCD_ISS_1)
frank26080115 0:bf7b9fba3924 555 {
frank26080115 0:bf7b9fba3924 556 // Support only 4K colors
frank26080115 0:bf7b9fba3924 557 assert(GLCD_DEF_DPL_ML == 0);
frank26080115 0:bf7b9fba3924 558 // DISCTR (Display Control)
frank26080115 0:bf7b9fba3924 559 // - F1/F2 switching period set
frank26080115 0:bf7b9fba3924 560 // - Line inversion set
frank26080115 0:bf7b9fba3924 561 Data = 0 | (0x20UL << 8) | (0x11UL << 16);
frank26080115 0:bf7b9fba3924 562 GLCD_SendCmd(DISCTR,(unsigned char *)&Data,0);
frank26080115 0:bf7b9fba3924 563 // OSCON (Oscillator ON)
frank26080115 0:bf7b9fba3924 564 GLCD_SendCmd(OSCON,NULL,0);
frank26080115 0:bf7b9fba3924 565 // Set contrast
frank26080115 0:bf7b9fba3924 566 Data = 0x20 | (0x0UL << 8);
frank26080115 0:bf7b9fba3924 567 GLCD_SendCmd(VOLCTR,(unsigned char *)&Data,0);
frank26080115 0:bf7b9fba3924 568 }
frank26080115 0:bf7b9fba3924 569 else
frank26080115 0:bf7b9fba3924 570 {
frank26080115 0:bf7b9fba3924 571 // Set contrast
frank26080115 0:bf7b9fba3924 572 Data = 0x30;
frank26080115 0:bf7b9fba3924 573 GLCD_SendCmd(SETCON,(unsigned char *)&Data,0);
frank26080115 0:bf7b9fba3924 574 }
frank26080115 0:bf7b9fba3924 575 // SLPOUT (Sleep mode OFF & OSC/Booster On)
frank26080115 0:bf7b9fba3924 576 GLCD_SendCmd(SLPOUT,NULL,0); // Sleep out
frank26080115 0:bf7b9fba3924 577 if(Glcd_Iss == GLCD_ISS_0)
frank26080115 0:bf7b9fba3924 578 {
frank26080115 0:bf7b9fba3924 579 GLCD_SendCmd(BSTRON,NULL,0); // Booster voltage on
frank26080115 0:bf7b9fba3924 580 }
frank26080115 0:bf7b9fba3924 581 // Display Environment Set
frank26080115 0:bf7b9fba3924 582 // Display inversion setting
frank26080115 0:bf7b9fba3924 583 GLCD_SendCmd(GLCD_DEF_DPL_INV?INVON:INVOFF,NULL,0);
frank26080115 0:bf7b9fba3924 584 // Display color scheme setting
frank26080115 0:bf7b9fba3924 585 GLCD_SendCmd(GLCD_DEF_DPL_8_COLOR?IDMON:IDMOFF,NULL,0);
frank26080115 0:bf7b9fba3924 586 // Display partial setting
frank26080115 0:bf7b9fba3924 587 if(GLCD_DEF_DPL_PARTIAL_MODE)
frank26080115 0:bf7b9fba3924 588 {
frank26080115 0:bf7b9fba3924 589 GLCD_SendCmd(PTLOUT,NULL,0);
frank26080115 0:bf7b9fba3924 590 }
frank26080115 0:bf7b9fba3924 591 else
frank26080115 0:bf7b9fba3924 592 {
frank26080115 0:bf7b9fba3924 593 #if GLCD_DEF_DPL_PARTIAL_MODE > 0
frank26080115 0:bf7b9fba3924 594 #error "PARTIAL_MODE not supported yet"
frank26080115 0:bf7b9fba3924 595 #endif // GLCD_DEF_DPL_PARTIAL_MODE > 0
frank26080115 0:bf7b9fba3924 596 }
frank26080115 0:bf7b9fba3924 597 // Memory Data Access Control
frank26080115 0:bf7b9fba3924 598 Data = 0;
frank26080115 0:bf7b9fba3924 599 pDATCTR_Data = (pDATCTR_Data_t)&Data;
frank26080115 0:bf7b9fba3924 600 pDATCTR_Data->RGB = GLCD_DEF_DPL_RGB_ORD; // BGR / RGB order
frank26080115 0:bf7b9fba3924 601 /* Because NXP_logo data was generated by reverse row direction so have to set MY = 1 */
frank26080115 0:bf7b9fba3924 602 pDATCTR_Data->MY = 1; // no mirror Y
frank26080115 0:bf7b9fba3924 603 pDATCTR_Data->MX = GLCD_DEF_DPL_MX; // no mirror X
frank26080115 0:bf7b9fba3924 604 pDATCTR_Data->MV = GLCD_DEF_DPL_V; // vertical RAM write in Y/X direction
frank26080115 0:bf7b9fba3924 605 pDATCTR_Data->ML = GLCD_DEF_DPL_ML; // line address order (bottom to top) / (top to bottom)
frank26080115 0:bf7b9fba3924 606 // support only 4k type A colored scheme
frank26080115 0:bf7b9fba3924 607 GLCD_SendCmd(DATCTR,(unsigned char *)&Data,0);
frank26080115 0:bf7b9fba3924 608 // Display Data Write & Display On
frank26080115 0:bf7b9fba3924 609 // COLUMN ADDRESS SET and PAGE ADDRESS SET
frank26080115 0:bf7b9fba3924 610 Data = 0 | ((GLCD_HORIZONTAL_SIZE - 1)<<8);
frank26080115 0:bf7b9fba3924 611 GLCD_SendCmd(RASET,(unsigned char *)&Data,0);
frank26080115 0:bf7b9fba3924 612 GLCD_SendCmd(CASET,(unsigned char *)&Data,0);
frank26080115 0:bf7b9fba3924 613
frank26080115 0:bf7b9fba3924 614 // Init display memory
frank26080115 0:bf7b9fba3924 615 if(pInitData == NULL)
frank26080115 0:bf7b9fba3924 616 {
frank26080115 0:bf7b9fba3924 617 Data = DEF_BACKGND_COLOUR;
frank26080115 0:bf7b9fba3924 618 for(i = 0; i < (GLCD_HORIZONTAL_SIZE * GLCD_VERTICAL_SIZE); ++i)
frank26080115 0:bf7b9fba3924 619 {
frank26080115 0:bf7b9fba3924 620 LCD_WRITE_PIXEL(Data);
frank26080115 0:bf7b9fba3924 621 }
frank26080115 0:bf7b9fba3924 622 LCD_FLUSH_PIXELS();
frank26080115 0:bf7b9fba3924 623 }
frank26080115 0:bf7b9fba3924 624 else
frank26080115 0:bf7b9fba3924 625 {
frank26080115 0:bf7b9fba3924 626 GLCD_SendCmd(RAMWR,pInitData,GLCD_HORIZONTAL_SIZE * GLCD_VERTICAL_SIZE * 2);
frank26080115 0:bf7b9fba3924 627 }
frank26080115 0:bf7b9fba3924 628 if(Glcd_Iss == GLCD_ISS_1)
frank26080115 0:bf7b9fba3924 629 {
frank26080115 0:bf7b9fba3924 630 // PWRCTR
frank26080115 0:bf7b9fba3924 631 Data = 0x1F;
frank26080115 0:bf7b9fba3924 632 GLCD_SendCmd(PWRCTR,(unsigned char *)&Data,0);
frank26080115 0:bf7b9fba3924 633 }
frank26080115 0:bf7b9fba3924 634 // Memory Data Access Control
frank26080115 0:bf7b9fba3924 635 /* Reset default control mode after drawing */
frank26080115 0:bf7b9fba3924 636 pDATCTR_Data = (pDATCTR_Data_t)&Data;
frank26080115 0:bf7b9fba3924 637 pDATCTR_Data->RGB = GLCD_DEF_DPL_RGB_ORD; // BGR / RGB order
frank26080115 0:bf7b9fba3924 638 pDATCTR_Data->MY = GLCD_DEF_DPL_MY; // no mirror Y
frank26080115 0:bf7b9fba3924 639 pDATCTR_Data->MX = GLCD_DEF_DPL_MX; // no mirror X
frank26080115 0:bf7b9fba3924 640 pDATCTR_Data->MV = GLCD_DEF_DPL_V; // vertical RAM write in Y/X direction
frank26080115 0:bf7b9fba3924 641 pDATCTR_Data->ML = GLCD_DEF_DPL_ML; // line address order (bottom to top) / (top to bottom)
frank26080115 0:bf7b9fba3924 642 // support only 4k type A colored scheme
frank26080115 0:bf7b9fba3924 643 GLCD_SendCmd(DATCTR,(unsigned char *)&Data,0);
frank26080115 0:bf7b9fba3924 644
frank26080115 0:bf7b9fba3924 645 // Wait for more than 120ms after power control command
frank26080115 0:bf7b9fba3924 646 Dly100us((void *)GLCD_BOOSTER_ON_DLY);
frank26080115 0:bf7b9fba3924 647 GLCD_SendCmd(GLCD_DISPLAY_STATE?DISPON:DISPOFF,NULL,0);
frank26080115 0:bf7b9fba3924 648 return(GLCD_OK);
frank26080115 0:bf7b9fba3924 649 }
frank26080115 0:bf7b9fba3924 650
frank26080115 0:bf7b9fba3924 651 /*************************************************************************
frank26080115 0:bf7b9fba3924 652 * Function Name: GLCD_SetFont
frank26080115 0:bf7b9fba3924 653 * Parameters: pFontType_t pFont, LdcPixel_t Color
frank26080115 0:bf7b9fba3924 654 * LdcPixel_t BackgndColor
frank26080115 0:bf7b9fba3924 655 *
frank26080115 0:bf7b9fba3924 656 * Return: none
frank26080115 0:bf7b9fba3924 657 *
frank26080115 0:bf7b9fba3924 658 * Description: Set current font, font color and background color
frank26080115 0:bf7b9fba3924 659 *
frank26080115 0:bf7b9fba3924 660 *************************************************************************/
frank26080115 0:bf7b9fba3924 661 void GLCD_SetFont(pFontType_t pFont, LdcPixel_t Color, LdcPixel_t BackgndColor)
frank26080115 0:bf7b9fba3924 662 {
frank26080115 0:bf7b9fba3924 663 pCurrFont = pFont;
frank26080115 0:bf7b9fba3924 664 TextColour = Color;
frank26080115 0:bf7b9fba3924 665 TextBackgndColour = BackgndColor;
frank26080115 0:bf7b9fba3924 666 }
frank26080115 0:bf7b9fba3924 667
frank26080115 0:bf7b9fba3924 668 /*************************************************************************
frank26080115 0:bf7b9fba3924 669 * Function Name: GLCD_SetWindow
frank26080115 0:bf7b9fba3924 670 * Parameters: uint32_t X_Left, uint32_t Y_Up,
frank26080115 0:bf7b9fba3924 671 * uint32_t X_Right, uint32_t Y_Down
frank26080115 0:bf7b9fba3924 672 *
frank26080115 0:bf7b9fba3924 673 * Return: none
frank26080115 0:bf7b9fba3924 674 *
frank26080115 0:bf7b9fba3924 675 * Description: Set draw window XY coordinate in pixels
frank26080115 0:bf7b9fba3924 676 *
frank26080115 0:bf7b9fba3924 677 *************************************************************************/
frank26080115 0:bf7b9fba3924 678 void GLCD_SetWindow(uint32_t X_Left, uint32_t Y_Up,
frank26080115 0:bf7b9fba3924 679 uint32_t X_Right, uint32_t Y_Down)
frank26080115 0:bf7b9fba3924 680 {
frank26080115 0:bf7b9fba3924 681 assert(X_Right < GLCD_HORIZONTAL_SIZE);
frank26080115 0:bf7b9fba3924 682 assert(Y_Down < GLCD_VERTICAL_SIZE);
frank26080115 0:bf7b9fba3924 683 assert(X_Left < X_Right);
frank26080115 0:bf7b9fba3924 684 assert(Y_Up < Y_Down);
frank26080115 0:bf7b9fba3924 685 XL_Win = X_Left;
frank26080115 0:bf7b9fba3924 686 YU_Win = Y_Up;
frank26080115 0:bf7b9fba3924 687 XR_Win = X_Right;
frank26080115 0:bf7b9fba3924 688 YD_Win = Y_Down;
frank26080115 0:bf7b9fba3924 689 }
frank26080115 0:bf7b9fba3924 690
frank26080115 0:bf7b9fba3924 691 /*************************************************************************
frank26080115 0:bf7b9fba3924 692 * Function Name: GLCD_TextSetPos
frank26080115 0:bf7b9fba3924 693 * Parameters: uint32_t X_UpLeft, uint32_t Y_UpLeft,
frank26080115 0:bf7b9fba3924 694 * uint32_t X_DownLeft, uint32_t Y_DownLeft
frank26080115 0:bf7b9fba3924 695 *
frank26080115 0:bf7b9fba3924 696 * Return: none
frank26080115 0:bf7b9fba3924 697 *
frank26080115 0:bf7b9fba3924 698 * Description: Set text X,Y coordinate in characters
frank26080115 0:bf7b9fba3924 699 *
frank26080115 0:bf7b9fba3924 700 *************************************************************************/
frank26080115 0:bf7b9fba3924 701 void GLCD_TextSetPos(uint32_t X, uint32_t Y)
frank26080115 0:bf7b9fba3924 702 {
frank26080115 0:bf7b9fba3924 703 TextX_Pos = X;
frank26080115 0:bf7b9fba3924 704 TextY_Pos = Y;
frank26080115 0:bf7b9fba3924 705 }
frank26080115 0:bf7b9fba3924 706
frank26080115 0:bf7b9fba3924 707 /*************************************************************************
frank26080115 0:bf7b9fba3924 708 * Function Name: GLCD_TextSetTabSize
frank26080115 0:bf7b9fba3924 709 * Parameters: uint32_t Size
frank26080115 0:bf7b9fba3924 710 *
frank26080115 0:bf7b9fba3924 711 * Return: none
frank26080115 0:bf7b9fba3924 712 *
frank26080115 0:bf7b9fba3924 713 * Description: Set text tab size in characters
frank26080115 0:bf7b9fba3924 714 *
frank26080115 0:bf7b9fba3924 715 *************************************************************************/
frank26080115 0:bf7b9fba3924 716 void GLCD_TextSetTabSize(uint32_t Size)
frank26080115 0:bf7b9fba3924 717 {
frank26080115 0:bf7b9fba3924 718 TabSize = Size;
frank26080115 0:bf7b9fba3924 719 }
frank26080115 0:bf7b9fba3924 720
frank26080115 0:bf7b9fba3924 721 /*************************************************************************
frank26080115 0:bf7b9fba3924 722 * Function Name: GLCD_TextCalcWindow
frank26080115 0:bf7b9fba3924 723 * Parameters: pInt32U pXL, pInt32U pXR,
frank26080115 0:bf7b9fba3924 724 * pInt32U pYU, pInt32U pYD,
frank26080115 0:bf7b9fba3924 725 * pInt32U pH_Size, pInt32U pV_Size
frank26080115 0:bf7b9fba3924 726 *
frank26080115 0:bf7b9fba3924 727 * Return: Bool
frank26080115 0:bf7b9fba3924 728 * FALSE - out of window coordinate aren't valid
frank26080115 0:bf7b9fba3924 729 * TRUE - the returned coordinate are valid
frank26080115 0:bf7b9fba3924 730 *
frank26080115 0:bf7b9fba3924 731 * Description: Calculate character window
frank26080115 0:bf7b9fba3924 732 *
frank26080115 0:bf7b9fba3924 733 *************************************************************************/
frank26080115 0:bf7b9fba3924 734 static Bool GLCD_TextCalcWindow (unsigned int *pXL, unsigned int *pXR,
frank26080115 0:bf7b9fba3924 735 unsigned int *pYU, unsigned int *pYD,
frank26080115 0:bf7b9fba3924 736 unsigned int *pH_Size, unsigned int *pV_Size)
frank26080115 0:bf7b9fba3924 737 {
frank26080115 0:bf7b9fba3924 738 *pH_Size = pCurrFont->H_Size;
frank26080115 0:bf7b9fba3924 739 *pV_Size = pCurrFont->V_Size;
frank26080115 0:bf7b9fba3924 740 *pXL = XL_Win + (TextX_Pos*pCurrFont->H_Size);
frank26080115 0:bf7b9fba3924 741 if(*pXL > XR_Win)
frank26080115 0:bf7b9fba3924 742 {
frank26080115 0:bf7b9fba3924 743 return(FALSE);
frank26080115 0:bf7b9fba3924 744 }
frank26080115 0:bf7b9fba3924 745 *pYU = YU_Win + (TextY_Pos*pCurrFont->V_Size);
frank26080115 0:bf7b9fba3924 746 if(*pYU > YD_Win)
frank26080115 0:bf7b9fba3924 747 {
frank26080115 0:bf7b9fba3924 748 return(FALSE);
frank26080115 0:bf7b9fba3924 749 }
frank26080115 0:bf7b9fba3924 750
frank26080115 0:bf7b9fba3924 751 *pXR = XL_Win + ((TextX_Pos+1)*pCurrFont->H_Size) - 1;
frank26080115 0:bf7b9fba3924 752 if(*pXR > XR_Win)
frank26080115 0:bf7b9fba3924 753 {
frank26080115 0:bf7b9fba3924 754 *pH_Size -= *pXR - XR_Win;
frank26080115 0:bf7b9fba3924 755 *pXR = XR_Win;
frank26080115 0:bf7b9fba3924 756 }
frank26080115 0:bf7b9fba3924 757
frank26080115 0:bf7b9fba3924 758 *pYD = YU_Win + ((TextY_Pos+1)*pCurrFont->V_Size) - 1;
frank26080115 0:bf7b9fba3924 759 if(*pYD > YD_Win)
frank26080115 0:bf7b9fba3924 760 {
frank26080115 0:bf7b9fba3924 761 *pV_Size -= *pYD - YD_Win;
frank26080115 0:bf7b9fba3924 762 *pYD = YD_Win;
frank26080115 0:bf7b9fba3924 763 }
frank26080115 0:bf7b9fba3924 764
frank26080115 0:bf7b9fba3924 765 return(TRUE);
frank26080115 0:bf7b9fba3924 766 }
frank26080115 0:bf7b9fba3924 767
frank26080115 0:bf7b9fba3924 768 /*************************************************************************
frank26080115 0:bf7b9fba3924 769 * Function Name: GLCD_putchar
frank26080115 0:bf7b9fba3924 770 * Parameters: int c
frank26080115 0:bf7b9fba3924 771 *
frank26080115 0:bf7b9fba3924 772 * Return: none
frank26080115 0:bf7b9fba3924 773 *
frank26080115 0:bf7b9fba3924 774 * Description: Put char function
frank26080115 0:bf7b9fba3924 775 *
frank26080115 0:bf7b9fba3924 776 *************************************************************************/
frank26080115 0:bf7b9fba3924 777 int GLCD_putchar (int c)
frank26080115 0:bf7b9fba3924 778 {
frank26080115 0:bf7b9fba3924 779 unsigned char *pSrc;
frank26080115 0:bf7b9fba3924 780 uint32_t H_Line, i, j, k;
frank26080115 0:bf7b9fba3924 781 uint32_t xl,xr,yu,yd,Temp,V_Size, H_Size, SrcInc = 1;
frank26080115 0:bf7b9fba3924 782 uint32_t WhiteSpaceNumb;
frank26080115 0:bf7b9fba3924 783 if(pCurrFont == NULL)
frank26080115 0:bf7b9fba3924 784 {
frank26080115 0:bf7b9fba3924 785 return(-1);
frank26080115 0:bf7b9fba3924 786 }
frank26080115 0:bf7b9fba3924 787 H_Line = (pCurrFont->H_Size / 8) + ((pCurrFont->H_Size % 8)?1:0);
frank26080115 0:bf7b9fba3924 788 switch(c)
frank26080115 0:bf7b9fba3924 789 {
frank26080115 0:bf7b9fba3924 790 case '\n': // go to start of next line (NewLine)
frank26080115 0:bf7b9fba3924 791 ++TextY_Pos;
frank26080115 0:bf7b9fba3924 792 break;
frank26080115 0:bf7b9fba3924 793 case '\r': // go to start of this line (Carriage Return)
frank26080115 0:bf7b9fba3924 794 // clear from current position to end of line
frank26080115 0:bf7b9fba3924 795 while(GLCD_TextCalcWindow(&xl,&xr,&yu,&yd,&H_Size,&V_Size))
frank26080115 0:bf7b9fba3924 796 {
frank26080115 0:bf7b9fba3924 797 LCD_SET_WINDOW(xl,xr,yu,yd);
frank26080115 0:bf7b9fba3924 798 for(i = 0; i < V_Size; ++i)
frank26080115 0:bf7b9fba3924 799 {
frank26080115 0:bf7b9fba3924 800 for(j = 0; j < H_Size; ++j)
frank26080115 0:bf7b9fba3924 801 {
frank26080115 0:bf7b9fba3924 802 LCD_WRITE_PIXEL(TextBackgndColour);
frank26080115 0:bf7b9fba3924 803 }
frank26080115 0:bf7b9fba3924 804 }
frank26080115 0:bf7b9fba3924 805 ++TextX_Pos;
frank26080115 0:bf7b9fba3924 806 }
frank26080115 0:bf7b9fba3924 807 TextX_Pos = 0;
frank26080115 0:bf7b9fba3924 808 break;
frank26080115 0:bf7b9fba3924 809 case '\b': // go back one position (BackSpace)
frank26080115 0:bf7b9fba3924 810 if(TextX_Pos)
frank26080115 0:bf7b9fba3924 811 {
frank26080115 0:bf7b9fba3924 812 --TextX_Pos;
frank26080115 0:bf7b9fba3924 813 // del current position
frank26080115 0:bf7b9fba3924 814 if(GLCD_TextCalcWindow(&xl,&xr,&yu,&yd,&H_Size,&V_Size))
frank26080115 0:bf7b9fba3924 815 {
frank26080115 0:bf7b9fba3924 816 LCD_SET_WINDOW(xl,xr,yu,yd);
frank26080115 0:bf7b9fba3924 817 for(i = 0; i < V_Size; ++i)
frank26080115 0:bf7b9fba3924 818 {
frank26080115 0:bf7b9fba3924 819 for(j = 0; j < H_Size; ++j)
frank26080115 0:bf7b9fba3924 820 {
frank26080115 0:bf7b9fba3924 821 LCD_WRITE_PIXEL(TextBackgndColour);
frank26080115 0:bf7b9fba3924 822 }
frank26080115 0:bf7b9fba3924 823 }
frank26080115 0:bf7b9fba3924 824 }
frank26080115 0:bf7b9fba3924 825 }
frank26080115 0:bf7b9fba3924 826 break;
frank26080115 0:bf7b9fba3924 827 case '\t': // go to next Horizontal Tab stop
frank26080115 0:bf7b9fba3924 828 WhiteSpaceNumb = TabSize - (TextX_Pos%TabSize);
frank26080115 0:bf7b9fba3924 829 for(k = 0; k < WhiteSpaceNumb; ++k)
frank26080115 0:bf7b9fba3924 830 {
frank26080115 0:bf7b9fba3924 831 LCD_SET_WINDOW(xl,xr,yu,yd);
frank26080115 0:bf7b9fba3924 832 if(GLCD_TextCalcWindow(&xl,&xr,&yu,&yd,&H_Size,&V_Size))
frank26080115 0:bf7b9fba3924 833 {
frank26080115 0:bf7b9fba3924 834 for(i = 0; i < V_Size; ++i)
frank26080115 0:bf7b9fba3924 835 {
frank26080115 0:bf7b9fba3924 836 for(j = 0; j < H_Size; ++j)
frank26080115 0:bf7b9fba3924 837 {
frank26080115 0:bf7b9fba3924 838 LCD_WRITE_PIXEL(TextBackgndColour);
frank26080115 0:bf7b9fba3924 839 }
frank26080115 0:bf7b9fba3924 840 }
frank26080115 0:bf7b9fba3924 841 ++TextX_Pos;
frank26080115 0:bf7b9fba3924 842 }
frank26080115 0:bf7b9fba3924 843 else
frank26080115 0:bf7b9fba3924 844 {
frank26080115 0:bf7b9fba3924 845 break;
frank26080115 0:bf7b9fba3924 846 }
frank26080115 0:bf7b9fba3924 847 }
frank26080115 0:bf7b9fba3924 848 break;
frank26080115 0:bf7b9fba3924 849 case '\f': // go to top of page (Form Feed)
frank26080115 0:bf7b9fba3924 850 // clear entire window
frank26080115 0:bf7b9fba3924 851 H_Size = XR_Win - XL_Win;
frank26080115 0:bf7b9fba3924 852 V_Size = YD_Win - YU_Win;
frank26080115 0:bf7b9fba3924 853 // set character window X left, Y right
frank26080115 0:bf7b9fba3924 854 LCD_SET_WINDOW(XL_Win,XR_Win,YU_Win,YD_Win);
frank26080115 0:bf7b9fba3924 855 // Fill window with background font color
frank26080115 0:bf7b9fba3924 856 for(i = 0; i <= V_Size; ++i)
frank26080115 0:bf7b9fba3924 857 {
frank26080115 0:bf7b9fba3924 858 for(j = 0; j <= H_Size; ++j)
frank26080115 0:bf7b9fba3924 859 {
frank26080115 0:bf7b9fba3924 860 LCD_WRITE_PIXEL(TextBackgndColour);
frank26080115 0:bf7b9fba3924 861 }
frank26080115 0:bf7b9fba3924 862 }
frank26080115 0:bf7b9fba3924 863
frank26080115 0:bf7b9fba3924 864 TextX_Pos = TextY_Pos = 0;
frank26080115 0:bf7b9fba3924 865 break;
frank26080115 0:bf7b9fba3924 866 case '\a': // signal an alert (BELl)
frank26080115 0:bf7b9fba3924 867 TEXT_BEL1_FUNC();
frank26080115 0:bf7b9fba3924 868 break;
frank26080115 0:bf7b9fba3924 869 default:
frank26080115 0:bf7b9fba3924 870 // Calculate the current character base address from stream
frank26080115 0:bf7b9fba3924 871 // and the character position
frank26080115 0:bf7b9fba3924 872 if((c < pCurrFont->CharacterOffset) && (c >= pCurrFont->CharactersNuber))
frank26080115 0:bf7b9fba3924 873 {
frank26080115 0:bf7b9fba3924 874 c = 0;
frank26080115 0:bf7b9fba3924 875 }
frank26080115 0:bf7b9fba3924 876 else
frank26080115 0:bf7b9fba3924 877 {
frank26080115 0:bf7b9fba3924 878 c -= pCurrFont->CharacterOffset;
frank26080115 0:bf7b9fba3924 879 }
frank26080115 0:bf7b9fba3924 880 pSrc = pCurrFont->pFontStream + (H_Line * pCurrFont->V_Size * c);
frank26080115 0:bf7b9fba3924 881 // Calculate character window and fit it in the text window
frank26080115 0:bf7b9fba3924 882 if(GLCD_TextCalcWindow(&xl,&xr,&yu,&yd,&H_Size,&V_Size))
frank26080115 0:bf7b9fba3924 883 {
frank26080115 0:bf7b9fba3924 884 // set character window X left, Y right
frank26080115 0:bf7b9fba3924 885 LCD_SET_WINDOW(xl,xr,yu,yd);
frank26080115 0:bf7b9fba3924 886 // Send char data
frank26080115 0:bf7b9fba3924 887 for(i = 0; i < V_Size; ++i)
frank26080115 0:bf7b9fba3924 888 {
frank26080115 0:bf7b9fba3924 889 SrcInc = H_Line;
frank26080115 0:bf7b9fba3924 890 for(j = 0; j < H_Size; ++j)
frank26080115 0:bf7b9fba3924 891 {
frank26080115 0:bf7b9fba3924 892 Temp = (*pSrc & (1UL << (j&0x7)))?TextColour:TextBackgndColour;
frank26080115 0:bf7b9fba3924 893 LCD_WRITE_PIXEL(Temp);
frank26080115 0:bf7b9fba3924 894 if((j&0x7) == 7)
frank26080115 0:bf7b9fba3924 895 {
frank26080115 0:bf7b9fba3924 896 ++pSrc;
frank26080115 0:bf7b9fba3924 897 --SrcInc;
frank26080115 0:bf7b9fba3924 898 }
frank26080115 0:bf7b9fba3924 899 }
frank26080115 0:bf7b9fba3924 900 // next line of character
frank26080115 0:bf7b9fba3924 901 pSrc += SrcInc;
frank26080115 0:bf7b9fba3924 902 }
frank26080115 0:bf7b9fba3924 903 }
frank26080115 0:bf7b9fba3924 904 ++TextX_Pos;
frank26080115 0:bf7b9fba3924 905 }
frank26080115 0:bf7b9fba3924 906 LCD_FLUSH_PIXELS();
frank26080115 0:bf7b9fba3924 907 return(c);
frank26080115 0:bf7b9fba3924 908 }
frank26080115 0:bf7b9fba3924 909
frank26080115 0:bf7b9fba3924 910 /*************************************************************************
frank26080115 0:bf7b9fba3924 911 * Function Name: GLCD_print
frank26080115 0:bf7b9fba3924 912 * Parameters: int c
frank26080115 0:bf7b9fba3924 913 *
frank26080115 0:bf7b9fba3924 914 * Return: none
frank26080115 0:bf7b9fba3924 915 *
frank26080115 0:bf7b9fba3924 916 * Description: Put char function
frank26080115 0:bf7b9fba3924 917 *
frank26080115 0:bf7b9fba3924 918 *************************************************************************/
frank26080115 0:bf7b9fba3924 919 void GLCD_print (const char *fmt)
frank26080115 0:bf7b9fba3924 920 {
frank26080115 0:bf7b9fba3924 921 while(0 != *fmt)
frank26080115 0:bf7b9fba3924 922 {
frank26080115 0:bf7b9fba3924 923 if(-1 == GLCD_putchar(*fmt++))
frank26080115 0:bf7b9fba3924 924 {
frank26080115 0:bf7b9fba3924 925 break;
frank26080115 0:bf7b9fba3924 926 }
frank26080115 0:bf7b9fba3924 927 }
frank26080115 0:bf7b9fba3924 928 }