Committer:
apm_litoral
Date:
Tue Apr 10 03:33:49 2012 +0000
Revision:
0:ea1b1135bb4e

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
apm_litoral 0:ea1b1135bb4e 1 #include "SPI_TFT.h"
apm_litoral 0:ea1b1135bb4e 2 #include "mbed.h"
apm_litoral 0:ea1b1135bb4e 3
apm_litoral 0:ea1b1135bb4e 4
apm_litoral 0:ea1b1135bb4e 5 #define BPP 16 // Bits per pixel
apm_litoral 0:ea1b1135bb4e 6
apm_litoral 0:ea1b1135bb4e 7 SPI_TFT::SPI_TFT(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset, PinName bk, const char *name)
apm_litoral 0:ea1b1135bb4e 8 :_spi(mosi, miso, sclk), _cs(cs), _reset(reset), _bk(bk), GraphicsDisplay(name) { //Constructor
apm_litoral 0:ea1b1135bb4e 9 //tft_rst_hw();
apm_litoral 0:ea1b1135bb4e 10 tft_init();
apm_litoral 0:ea1b1135bb4e 11 backlight(0);
apm_litoral 0:ea1b1135bb4e 12 orientation = 3;
apm_litoral 0:ea1b1135bb4e 13 char_x = 0;
apm_litoral 0:ea1b1135bb4e 14 backlight(0); //0.0001
apm_litoral 0:ea1b1135bb4e 15 foreground(Black);
apm_litoral 0:ea1b1135bb4e 16 background(Black);
apm_litoral 0:ea1b1135bb4e 17
apm_litoral 0:ea1b1135bb4e 18 }
apm_litoral 0:ea1b1135bb4e 19
apm_litoral 0:ea1b1135bb4e 20 int SPI_TFT::width() {
apm_litoral 0:ea1b1135bb4e 21 if (orientation == 0 || orientation == 2) return 240;
apm_litoral 0:ea1b1135bb4e 22 else return 320;
apm_litoral 0:ea1b1135bb4e 23 }
apm_litoral 0:ea1b1135bb4e 24
apm_litoral 0:ea1b1135bb4e 25
apm_litoral 0:ea1b1135bb4e 26 int SPI_TFT::height() {
apm_litoral 0:ea1b1135bb4e 27 if (orientation == 0 || orientation == 2) return 320;
apm_litoral 0:ea1b1135bb4e 28 else return 240;
apm_litoral 0:ea1b1135bb4e 29 }
apm_litoral 0:ea1b1135bb4e 30
apm_litoral 0:ea1b1135bb4e 31
apm_litoral 0:ea1b1135bb4e 32
apm_litoral 0:ea1b1135bb4e 33 void SPI_TFT::set_orientation(unsigned int x) {
apm_litoral 0:ea1b1135bb4e 34 orientation = x;
apm_litoral 0:ea1b1135bb4e 35 switch (orientation) {
apm_litoral 0:ea1b1135bb4e 36 case 0:
apm_litoral 0:ea1b1135bb4e 37 wr_reg(0x16, 0x0008);//240x320
apm_litoral 0:ea1b1135bb4e 38 break;
apm_litoral 0:ea1b1135bb4e 39 case 1:
apm_litoral 0:ea1b1135bb4e 40 wr_reg(0x16, 0x0068);//320x240
apm_litoral 0:ea1b1135bb4e 41 break;
apm_litoral 0:ea1b1135bb4e 42 case 2:
apm_litoral 0:ea1b1135bb4e 43 wr_reg(0x16, 0x00C8);//240x320
apm_litoral 0:ea1b1135bb4e 44 break;
apm_litoral 0:ea1b1135bb4e 45 case 3:
apm_litoral 0:ea1b1135bb4e 46 wr_reg(0x16, 0x00A8);//320x240
apm_litoral 0:ea1b1135bb4e 47 break;
apm_litoral 0:ea1b1135bb4e 48 }
apm_litoral 0:ea1b1135bb4e 49 }
apm_litoral 0:ea1b1135bb4e 50
apm_litoral 0:ea1b1135bb4e 51
apm_litoral 0:ea1b1135bb4e 52 //configura el registro index enviando para ello: (01110000+00000000+00000000)=01110000
apm_litoral 0:ea1b1135bb4e 53 void SPI_TFT::wr_cmd(int cmd) {
apm_litoral 0:ea1b1135bb4e 54 _cs = 0;
apm_litoral 0:ea1b1135bb4e 55 _spi.write(SPI_START | SPI_WR | SPI_INDEX); /* Write : RS = 0, RW = 0 */
apm_litoral 0:ea1b1135bb4e 56 _spi.write(cmd);
apm_litoral 0:ea1b1135bb4e 57 _cs = 1;
apm_litoral 0:ea1b1135bb4e 58 }
apm_litoral 0:ea1b1135bb4e 59
apm_litoral 0:ea1b1135bb4e 60
apm_litoral 0:ea1b1135bb4e 61 //escribe instrucciones o datos en GRAM enviando para ello: (01110000+00000000+00000010)=01110010
apm_litoral 0:ea1b1135bb4e 62 void SPI_TFT::wr_dat(int dat) {
apm_litoral 0:ea1b1135bb4e 63 _cs = 0;
apm_litoral 0:ea1b1135bb4e 64 _spi.write(SPI_START | SPI_WR | SPI_DATA); // Write : RS = 1, RW = 0
apm_litoral 0:ea1b1135bb4e 65 _spi.format(16,3); // switch to 16 bit Mode 3
apm_litoral 0:ea1b1135bb4e 66 _spi.write(dat); // Write D0..D15
apm_litoral 0:ea1b1135bb4e 67 _spi.format(16,3); // 8 bit Mode 3
apm_litoral 0:ea1b1135bb4e 68 _cs = 1;
apm_litoral 0:ea1b1135bb4e 69 }
apm_litoral 0:ea1b1135bb4e 70
apm_litoral 0:ea1b1135bb4e 71
apm_litoral 0:ea1b1135bb4e 72 //escribe instrucciones o datos en GRAM enviando para ello: (01110000+00000000+00000010)=01110010
apm_litoral 0:ea1b1135bb4e 73 void SPI_TFT::wr_dat_start(void) {
apm_litoral 0:ea1b1135bb4e 74 _cs = 0;
apm_litoral 0:ea1b1135bb4e 75 _spi.write(SPI_START | SPI_WR | SPI_DATA); /* Write : RS = 1, RW = 0 */ //70-00-02
apm_litoral 0:ea1b1135bb4e 76 }
apm_litoral 0:ea1b1135bb4e 77
apm_litoral 0:ea1b1135bb4e 78
apm_litoral 0:ea1b1135bb4e 79 //detiene la secuencia de envio y la comunicacion con el TFT
apm_litoral 0:ea1b1135bb4e 80 void SPI_TFT::wr_dat_stop (void) {
apm_litoral 0:ea1b1135bb4e 81 _cs = 1;
apm_litoral 0:ea1b1135bb4e 82 }
apm_litoral 0:ea1b1135bb4e 83
apm_litoral 0:ea1b1135bb4e 84
apm_litoral 0:ea1b1135bb4e 85 //envia un dato simple
apm_litoral 0:ea1b1135bb4e 86 void SPI_TFT::wr_dat_only (unsigned short dat) {
apm_litoral 0:ea1b1135bb4e 87
apm_litoral 0:ea1b1135bb4e 88 _spi.format(16,3); // switch to 16 bit Mode 3
apm_litoral 0:ea1b1135bb4e 89 _spi.write(dat); // Write D0..D15
apm_litoral 0:ea1b1135bb4e 90 _spi.format(16,3); // 8 bit Mode 3
apm_litoral 0:ea1b1135bb4e 91 }
apm_litoral 0:ea1b1135bb4e 92
apm_litoral 0:ea1b1135bb4e 93
apm_litoral 0:ea1b1135bb4e 94 //lee comandos (16bits en total) pero no soporta lectura de GRAM enviando para ello: (01110000+00000001+00000010)=01110011
apm_litoral 0:ea1b1135bb4e 95 unsigned short SPI_TFT::rd_dat (void) {
apm_litoral 0:ea1b1135bb4e 96 unsigned short val = 0;
apm_litoral 0:ea1b1135bb4e 97
apm_litoral 0:ea1b1135bb4e 98 _cs = 0;
apm_litoral 0:ea1b1135bb4e 99 _spi.write(SPI_START | SPI_RD | SPI_DATA); /* Read: RS = 1, RW = 1 */
apm_litoral 0:ea1b1135bb4e 100 _spi.write(0); /* Dummy read 1 */ //lectura ficticia
apm_litoral 0:ea1b1135bb4e 101 val = _spi.write(0); /* Read D8..D15 */ //lee los altos y luego los bajos
apm_litoral 0:ea1b1135bb4e 102 val <<= 8;
apm_litoral 0:ea1b1135bb4e 103 val |= _spi.write(0); /* Read D0..D7 */
apm_litoral 0:ea1b1135bb4e 104 _cs = 1;
apm_litoral 0:ea1b1135bb4e 105 return (val);//devuelve la concatenacion completa de 16bits
apm_litoral 0:ea1b1135bb4e 106 }
apm_litoral 0:ea1b1135bb4e 107
apm_litoral 0:ea1b1135bb4e 108
apm_litoral 0:ea1b1135bb4e 109
apm_litoral 0:ea1b1135bb4e 110 void SPI_TFT::wr_reg (unsigned char reg, unsigned short val) {
apm_litoral 0:ea1b1135bb4e 111
apm_litoral 0:ea1b1135bb4e 112 wr_cmd(reg);
apm_litoral 0:ea1b1135bb4e 113 wr_dat(val);
apm_litoral 0:ea1b1135bb4e 114 }
apm_litoral 0:ea1b1135bb4e 115
apm_litoral 0:ea1b1135bb4e 116
apm_litoral 0:ea1b1135bb4e 117
apm_litoral 0:ea1b1135bb4e 118 unsigned short SPI_TFT::rd_reg (unsigned char reg) {
apm_litoral 0:ea1b1135bb4e 119
apm_litoral 0:ea1b1135bb4e 120 wr_cmd(reg);
apm_litoral 0:ea1b1135bb4e 121 return(rd_dat());
apm_litoral 0:ea1b1135bb4e 122 }
apm_litoral 0:ea1b1135bb4e 123
apm_litoral 0:ea1b1135bb4e 124 int SPI_TFT::ID() {
apm_litoral 0:ea1b1135bb4e 125 static unsigned short driverCode;
apm_litoral 0:ea1b1135bb4e 126 driverCode = rd_reg(0x01); // read controller ID
apm_litoral 0:ea1b1135bb4e 127 //printf("Disp_ID = %x debe ser 47h",driverCode);
apm_litoral 0:ea1b1135bb4e 128 //pc.printf("Disp_ID = %x debe ser 47h",tt.ID());
apm_litoral 0:ea1b1135bb4e 129 return driverCode;
apm_litoral 0:ea1b1135bb4e 130 }
apm_litoral 0:ea1b1135bb4e 131
apm_litoral 0:ea1b1135bb4e 132 void SPI_TFT::tft_init() {
apm_litoral 0:ea1b1135bb4e 133 //static unsigned short driverCode;
apm_litoral 0:ea1b1135bb4e 134 _spi.format(16,3); // 8 bit spi mode 3
apm_litoral 0:ea1b1135bb4e 135 _spi.frequency(100000000); // 48Mhz SPI clock
apm_litoral 0:ea1b1135bb4e 136 _reset = 0; // reset
apm_litoral 0:ea1b1135bb4e 137 _cs = 1;
apm_litoral 0:ea1b1135bb4e 138 wait_us(50);
apm_litoral 0:ea1b1135bb4e 139 _reset = 1; // end reset
apm_litoral 0:ea1b1135bb4e 140 wait_ms(6);//5
apm_litoral 0:ea1b1135bb4e 141 /*
apm_litoral 0:ea1b1135bb4e 142 driverCode = rd_reg(0x00); // read controller ID
apm_litoral 0:ea1b1135bb4e 143 printf("Disp_ID = %x debe ser 47h",driverCode);
apm_litoral 0:ea1b1135bb4e 144 wait_ms(50);
apm_litoral 0:ea1b1135bb4e 145 */
apm_litoral 0:ea1b1135bb4e 146
apm_litoral 0:ea1b1135bb4e 147 // SECUENCIA DE INICIO Y DEFINICION DE CONFIGURACIONES GENERALES //
apm_litoral 0:ea1b1135bb4e 148
apm_litoral 0:ea1b1135bb4e 149 /* Start Initial Sequence ----------------------------------------------------*/
apm_litoral 0:ea1b1135bb4e 150 wr_reg(0xEA, 0x0000); /* Reset Power Control 1 */
apm_litoral 0:ea1b1135bb4e 151 wr_reg(0xEB, 0x0020); /* Power Control 2 */
apm_litoral 0:ea1b1135bb4e 152 wr_reg(0xEC, 0x000C); /* Power Control 3 */
apm_litoral 0:ea1b1135bb4e 153 wr_reg(0xED, 0x00C4); /* Power Control 4 */
apm_litoral 0:ea1b1135bb4e 154 wr_reg(0xE8, 0x0040); /* Source OPON_N */
apm_litoral 0:ea1b1135bb4e 155 wr_reg(0xE9, 0x0038); /* Source OPON_I */
apm_litoral 0:ea1b1135bb4e 156 wr_reg(0xF1, 0x0001); /* */
apm_litoral 0:ea1b1135bb4e 157 wr_reg(0xF2, 0x0010); /* */
apm_litoral 0:ea1b1135bb4e 158 wr_reg(0x27, 0x00A3); /* Display Control 2 */
apm_litoral 0:ea1b1135bb4e 159
apm_litoral 0:ea1b1135bb4e 160
apm_litoral 0:ea1b1135bb4e 161 /* Gamma settings -----------------------------------------------------------*/
apm_litoral 0:ea1b1135bb4e 162 wr_reg(0x40,0x00); //
apm_litoral 0:ea1b1135bb4e 163 wr_reg(0x41,0x00); //
apm_litoral 0:ea1b1135bb4e 164 wr_reg(0x42,0x01); //
apm_litoral 0:ea1b1135bb4e 165 wr_reg(0x43,0x12); //t12
apm_litoral 0:ea1b1135bb4e 166 wr_reg(0x44,0x10); //
apm_litoral 0:ea1b1135bb4e 167 wr_reg(0x45,0x26); //
apm_litoral 0:ea1b1135bb4e 168 wr_reg(0x46,0x08); //
apm_litoral 0:ea1b1135bb4e 169 wr_reg(0x47,0x53); //t53
apm_litoral 0:ea1b1135bb4e 170 wr_reg(0x48,0x02); //
apm_litoral 0:ea1b1135bb4e 171 wr_reg(0x49,0x15); //t15
apm_litoral 0:ea1b1135bb4e 172 wr_reg(0x4A,0x19); //t19
apm_litoral 0:ea1b1135bb4e 173 wr_reg(0x4B,0x19); //
apm_litoral 0:ea1b1135bb4e 174 wr_reg(0x4C,0x16); //t16
apm_litoral 0:ea1b1135bb4e 175 wr_reg(0x50,0x19); //
apm_litoral 0:ea1b1135bb4e 176 wr_reg(0x51,0x2F); //
apm_litoral 0:ea1b1135bb4e 177 wr_reg(0x52,0x2D); //t2D
apm_litoral 0:ea1b1135bb4e 178 wr_reg(0x53,0x3E); //
apm_litoral 0:ea1b1135bb4e 179 wr_reg(0x54,0x3F); //
apm_litoral 0:ea1b1135bb4e 180 wr_reg(0x55,0x3F); //
apm_litoral 0:ea1b1135bb4e 181 wr_reg(0x56,0x2C); //t2C
apm_litoral 0:ea1b1135bb4e 182 wr_reg(0x57,0x77); //
apm_litoral 0:ea1b1135bb4e 183 wr_reg(0x58,0x09); //t09
apm_litoral 0:ea1b1135bb4e 184 wr_reg(0x59,0x06); //
apm_litoral 0:ea1b1135bb4e 185 wr_reg(0x5A,0x06); //t06
apm_litoral 0:ea1b1135bb4e 186 wr_reg(0x5B,0x0A); //t0A
apm_litoral 0:ea1b1135bb4e 187 wr_reg(0x5C,0x1D); //
apm_litoral 0:ea1b1135bb4e 188 wr_reg(0x5D,0xCC); //
apm_litoral 0:ea1b1135bb4e 189
apm_litoral 0:ea1b1135bb4e 190 /* Power On sequence ---------------------------------------------------------*/
apm_litoral 0:ea1b1135bb4e 191 wr_reg(0x1B, 0x001B); /* Power Control 2 *///VRH=4.65V
apm_litoral 0:ea1b1135bb4e 192 wr_reg(0x1A, 0x0001); /* Power Control 1 *///BT (VGH~15V,VGL~-10V,DDVDH~5V)
apm_litoral 0:ea1b1135bb4e 193 wr_reg(0x24, 0x002F); /* Vcom Control 2 *///VMH(VCOM High voltage ~3.2V)
apm_litoral 0:ea1b1135bb4e 194 wr_reg(0x25, 0x0057); /* Vcom Control 3 *///VML(VCOM Low voltage -1.2V)
apm_litoral 0:ea1b1135bb4e 195
apm_litoral 0:ea1b1135bb4e 196 //****VCOM offset**///
apm_litoral 0:ea1b1135bb4e 197 wr_reg(0x23, 0x0097);//8D); /* Vcom Control 1 *///for Flicker adjust //can reload from OTP
apm_litoral 0:ea1b1135bb4e 198
apm_litoral 0:ea1b1135bb4e 199
apm_litoral 0:ea1b1135bb4e 200 /* Power + Osc ---------------------------------------------------------------*/
apm_litoral 0:ea1b1135bb4e 201 wr_reg(0x18, 0x003f); /* OSC Control 1 */ //I/P_RADJ,N/P_RADJ, Normal mode 75Hz
apm_litoral 0:ea1b1135bb4e 202 wr_reg(0x19, 0x0001); /* OSC Control 2 */ //OSC_EN='1', start Osc
apm_litoral 0:ea1b1135bb4e 203 wr_reg(0x01, 0x0009);//scroll activado /* Display Mode Control */ //DP_STB='0', out deep sleep
apm_litoral 0:ea1b1135bb4e 204 wr_reg(0x1F, 0x0088); /* Power Control 6 */ // GAS=1, VOMG=00, PON=0, DK=1, XDK=0, DVDH_TRI=0, STB=0
apm_litoral 0:ea1b1135bb4e 205 wait_ms(5); /* Delay 5 ms */
apm_litoral 0:ea1b1135bb4e 206 wr_reg(0x1F, 0x0080); /* Power Control 6 */ // GAS=1, VOMG=00, PON=0, DK=0, XDK=0, DVDH_TRI=0, STB=0
apm_litoral 0:ea1b1135bb4e 207 wait_ms(5); /* Delay 5 ms */
apm_litoral 0:ea1b1135bb4e 208 wr_reg(0x1F, 0x0090); /* Power Control 6 */ // GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0
apm_litoral 0:ea1b1135bb4e 209 wait_ms(5); /* Delay 5 ms */
apm_litoral 0:ea1b1135bb4e 210 wr_reg(0x1F, 0x00D0); /* Power Control 6 */ // GAS=1, VOMG=10, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0
apm_litoral 0:ea1b1135bb4e 211 wait_ms(5); /* Delay 5 ms */
apm_litoral 0:ea1b1135bb4e 212
apm_litoral 0:ea1b1135bb4e 213 wr_reg(0x17, 0x0005);//5 /* Colmod 16Bit/Pixel */ //default 0x0006 262k color // 0x0005 65k color
apm_litoral 0:ea1b1135bb4e 214
apm_litoral 0:ea1b1135bb4e 215 wr_reg(0x36, 0x0000); /* Panel Characteristic */ //SS_P, GS_P,REV_P,BGR_P
apm_litoral 0:ea1b1135bb4e 216 wr_reg(0x28, 0x0038); /* Display Control 3 */ //GON=1, DTE=1, D=1000
apm_litoral 0:ea1b1135bb4e 217 wait_ms(40);
apm_litoral 0:ea1b1135bb4e 218 wr_reg(0x28, 0x003C); /* Display Control 3 */ //GON=1, DTE=1, D=1100
apm_litoral 0:ea1b1135bb4e 219
apm_litoral 0:ea1b1135bb4e 220
apm_litoral 0:ea1b1135bb4e 221
apm_litoral 0:ea1b1135bb4e 222 switch (orientation) {
apm_litoral 0:ea1b1135bb4e 223 case 0:
apm_litoral 0:ea1b1135bb4e 224 wr_reg(0x16, 0x0008);
apm_litoral 0:ea1b1135bb4e 225 break;
apm_litoral 0:ea1b1135bb4e 226 case 1:
apm_litoral 0:ea1b1135bb4e 227 wr_reg(0x16, 0x0068);
apm_litoral 0:ea1b1135bb4e 228 break;
apm_litoral 0:ea1b1135bb4e 229 case 2:
apm_litoral 0:ea1b1135bb4e 230 wr_reg(0x16, 0x00C8);
apm_litoral 0:ea1b1135bb4e 231 break;
apm_litoral 0:ea1b1135bb4e 232 case 3:
apm_litoral 0:ea1b1135bb4e 233 wr_reg(0x16, 0x00A8);
apm_litoral 0:ea1b1135bb4e 234 break;
apm_litoral 0:ea1b1135bb4e 235 }
apm_litoral 0:ea1b1135bb4e 236
apm_litoral 0:ea1b1135bb4e 237 WindowMax ();
apm_litoral 0:ea1b1135bb4e 238 }
apm_litoral 0:ea1b1135bb4e 239
apm_litoral 0:ea1b1135bb4e 240
apm_litoral 0:ea1b1135bb4e 241
apm_litoral 0:ea1b1135bb4e 242
apm_litoral 0:ea1b1135bb4e 243 void SPI_TFT::pixel(int x, int y, int color) {
apm_litoral 0:ea1b1135bb4e 244 wr_reg(0x03, (x >> 0));
apm_litoral 0:ea1b1135bb4e 245 wr_reg(0x02, (x >> 8));
apm_litoral 0:ea1b1135bb4e 246 wr_reg(0x07, (y >> 0));
apm_litoral 0:ea1b1135bb4e 247 wr_reg(0x06, (y >> 8));
apm_litoral 0:ea1b1135bb4e 248 //wr_reg(0x05, (x+1 >> 0));
apm_litoral 0:ea1b1135bb4e 249 //wr_reg(0x04, (x+1 >> 8));
apm_litoral 0:ea1b1135bb4e 250 //wr_reg(0x09, (y+1 >> 0));
apm_litoral 0:ea1b1135bb4e 251 //wr_reg(0x08, (y+1 >> 8));
apm_litoral 0:ea1b1135bb4e 252 wr_cmd(0x22);
apm_litoral 0:ea1b1135bb4e 253 wr_dat(color);
apm_litoral 0:ea1b1135bb4e 254 }
apm_litoral 0:ea1b1135bb4e 255
apm_litoral 0:ea1b1135bb4e 256
apm_litoral 0:ea1b1135bb4e 257
apm_litoral 0:ea1b1135bb4e 258
apm_litoral 0:ea1b1135bb4e 259 void SPI_TFT::windows (unsigned int x, unsigned int y, unsigned int w, unsigned int h) {
apm_litoral 0:ea1b1135bb4e 260 wr_reg(0x03, (x >> 0));
apm_litoral 0:ea1b1135bb4e 261 wr_reg(0x02, (x >> 8));
apm_litoral 0:ea1b1135bb4e 262 wr_reg(0x05, (x+w-1 >> 0));
apm_litoral 0:ea1b1135bb4e 263 wr_reg(0x04, (x+w-1 >> 8));
apm_litoral 0:ea1b1135bb4e 264 wr_reg(0x07, ( y >> 0));
apm_litoral 0:ea1b1135bb4e 265 wr_reg(0x06, ( y >> 8));
apm_litoral 0:ea1b1135bb4e 266 wr_reg(0x09, ( y+h-1 >> 0));
apm_litoral 0:ea1b1135bb4e 267 wr_reg(0x08, ( y+h-1 >> 8));
apm_litoral 0:ea1b1135bb4e 268 //wr_cmd(0x22);
apm_litoral 0:ea1b1135bb4e 269 }
apm_litoral 0:ea1b1135bb4e 270
apm_litoral 0:ea1b1135bb4e 271
apm_litoral 0:ea1b1135bb4e 272 void SPI_TFT::WindowMax (void) {
apm_litoral 0:ea1b1135bb4e 273 windows (0, 0, width(), height());
apm_litoral 0:ea1b1135bb4e 274 }
apm_litoral 0:ea1b1135bb4e 275
apm_litoral 0:ea1b1135bb4e 276
apm_litoral 0:ea1b1135bb4e 277 void SPI_TFT::cls (void) {
apm_litoral 0:ea1b1135bb4e 278 unsigned int i;
apm_litoral 0:ea1b1135bb4e 279 WindowMax();
apm_litoral 0:ea1b1135bb4e 280 wr_cmd(0x22);
apm_litoral 0:ea1b1135bb4e 281 wr_dat_start();
apm_litoral 0:ea1b1135bb4e 282 _spi.format(16,3); // 16 bit Mode 3
apm_litoral 0:ea1b1135bb4e 283 for (i = 0; i < ( width() * height()); i++)
apm_litoral 0:ea1b1135bb4e 284 _spi.write(_background);
apm_litoral 0:ea1b1135bb4e 285 _spi.format(16,3); // 8 bit Mode 3
apm_litoral 0:ea1b1135bb4e 286 wr_dat_stop();
apm_litoral 0:ea1b1135bb4e 287 }
apm_litoral 0:ea1b1135bb4e 288
apm_litoral 0:ea1b1135bb4e 289
apm_litoral 0:ea1b1135bb4e 290 void SPI_TFT::circle(int x0, int y0, int r, int color) {
apm_litoral 0:ea1b1135bb4e 291
apm_litoral 0:ea1b1135bb4e 292 int draw_x0, draw_y0;
apm_litoral 0:ea1b1135bb4e 293 int draw_x1, draw_y1;
apm_litoral 0:ea1b1135bb4e 294 int draw_x2, draw_y2;
apm_litoral 0:ea1b1135bb4e 295 int draw_x3, draw_y3;
apm_litoral 0:ea1b1135bb4e 296 int draw_x4, draw_y4;
apm_litoral 0:ea1b1135bb4e 297 int draw_x5, draw_y5;
apm_litoral 0:ea1b1135bb4e 298 int draw_x6, draw_y6;
apm_litoral 0:ea1b1135bb4e 299 int draw_x7, draw_y7;
apm_litoral 0:ea1b1135bb4e 300 int xx, yy;
apm_litoral 0:ea1b1135bb4e 301 int di;
apm_litoral 0:ea1b1135bb4e 302 //WindowMax();
apm_litoral 0:ea1b1135bb4e 303 if (r == 0) { /* no radius */
apm_litoral 0:ea1b1135bb4e 304 return;
apm_litoral 0:ea1b1135bb4e 305 }
apm_litoral 0:ea1b1135bb4e 306
apm_litoral 0:ea1b1135bb4e 307 draw_x0 = draw_x1 = x0;
apm_litoral 0:ea1b1135bb4e 308 draw_y0 = draw_y1 = y0 + r;
apm_litoral 0:ea1b1135bb4e 309 if (draw_y0 < height()) {
apm_litoral 0:ea1b1135bb4e 310 pixel(draw_x0, draw_y0, color); /* 90 degree */
apm_litoral 0:ea1b1135bb4e 311 }
apm_litoral 0:ea1b1135bb4e 312
apm_litoral 0:ea1b1135bb4e 313 draw_x2 = draw_x3 = x0;
apm_litoral 0:ea1b1135bb4e 314 draw_y2 = draw_y3 = y0 - r;
apm_litoral 0:ea1b1135bb4e 315 if (draw_y2 >= 0) {
apm_litoral 0:ea1b1135bb4e 316 pixel(draw_x2, draw_y2, color); /* 270 degree */
apm_litoral 0:ea1b1135bb4e 317 }
apm_litoral 0:ea1b1135bb4e 318
apm_litoral 0:ea1b1135bb4e 319 draw_x4 = draw_x6 = x0 + r;
apm_litoral 0:ea1b1135bb4e 320 draw_y4 = draw_y6 = y0;
apm_litoral 0:ea1b1135bb4e 321 if (draw_x4 < width()) {
apm_litoral 0:ea1b1135bb4e 322 pixel(draw_x4, draw_y4, color); /* 0 degree */
apm_litoral 0:ea1b1135bb4e 323 }
apm_litoral 0:ea1b1135bb4e 324
apm_litoral 0:ea1b1135bb4e 325 draw_x5 = draw_x7 = x0 - r;
apm_litoral 0:ea1b1135bb4e 326 draw_y5 = draw_y7 = y0;
apm_litoral 0:ea1b1135bb4e 327 if (draw_x5>=0) {
apm_litoral 0:ea1b1135bb4e 328 pixel(draw_x5, draw_y5, color); /* 180 degree */
apm_litoral 0:ea1b1135bb4e 329 }
apm_litoral 0:ea1b1135bb4e 330
apm_litoral 0:ea1b1135bb4e 331 if (r == 1) {
apm_litoral 0:ea1b1135bb4e 332 return;
apm_litoral 0:ea1b1135bb4e 333 }
apm_litoral 0:ea1b1135bb4e 334
apm_litoral 0:ea1b1135bb4e 335 di = 3 - 2*r;
apm_litoral 0:ea1b1135bb4e 336 xx = 0;
apm_litoral 0:ea1b1135bb4e 337 yy = r;
apm_litoral 0:ea1b1135bb4e 338 while (xx < yy) {
apm_litoral 0:ea1b1135bb4e 339
apm_litoral 0:ea1b1135bb4e 340 if (di < 0) {
apm_litoral 0:ea1b1135bb4e 341 di += 4*xx + 6;
apm_litoral 0:ea1b1135bb4e 342 } else {
apm_litoral 0:ea1b1135bb4e 343 di += 4*(xx - yy) + 10;
apm_litoral 0:ea1b1135bb4e 344 yy--;
apm_litoral 0:ea1b1135bb4e 345 draw_y0--;
apm_litoral 0:ea1b1135bb4e 346 draw_y1--;
apm_litoral 0:ea1b1135bb4e 347 draw_y2++;
apm_litoral 0:ea1b1135bb4e 348 draw_y3++;
apm_litoral 0:ea1b1135bb4e 349 draw_x4--;
apm_litoral 0:ea1b1135bb4e 350 draw_x5++;
apm_litoral 0:ea1b1135bb4e 351 draw_x6--;
apm_litoral 0:ea1b1135bb4e 352 draw_x7++;
apm_litoral 0:ea1b1135bb4e 353 }
apm_litoral 0:ea1b1135bb4e 354 xx++;
apm_litoral 0:ea1b1135bb4e 355 draw_x0++;
apm_litoral 0:ea1b1135bb4e 356 draw_x1--;
apm_litoral 0:ea1b1135bb4e 357 draw_x2++;
apm_litoral 0:ea1b1135bb4e 358 draw_x3--;
apm_litoral 0:ea1b1135bb4e 359 draw_y4++;
apm_litoral 0:ea1b1135bb4e 360 draw_y5++;
apm_litoral 0:ea1b1135bb4e 361 draw_y6--;
apm_litoral 0:ea1b1135bb4e 362 draw_y7--;
apm_litoral 0:ea1b1135bb4e 363
apm_litoral 0:ea1b1135bb4e 364 if ( (draw_x0 <= width()) && (draw_y0>=0) ) {
apm_litoral 0:ea1b1135bb4e 365 pixel(draw_x0, draw_y0, color);
apm_litoral 0:ea1b1135bb4e 366 }
apm_litoral 0:ea1b1135bb4e 367
apm_litoral 0:ea1b1135bb4e 368 if ( (draw_x1 >= 0) && (draw_y1 >= 0) ) {
apm_litoral 0:ea1b1135bb4e 369 pixel(draw_x1, draw_y1, color);
apm_litoral 0:ea1b1135bb4e 370 }
apm_litoral 0:ea1b1135bb4e 371
apm_litoral 0:ea1b1135bb4e 372 if ( (draw_x2 <= width()) && (draw_y2 <= height()) ) {
apm_litoral 0:ea1b1135bb4e 373 pixel(draw_x2, draw_y2, color);
apm_litoral 0:ea1b1135bb4e 374 }
apm_litoral 0:ea1b1135bb4e 375
apm_litoral 0:ea1b1135bb4e 376 if ( (draw_x3 >=0 ) && (draw_y3 <= height()) ) {
apm_litoral 0:ea1b1135bb4e 377 pixel(draw_x3, draw_y3, color);
apm_litoral 0:ea1b1135bb4e 378 }
apm_litoral 0:ea1b1135bb4e 379
apm_litoral 0:ea1b1135bb4e 380 if ( (draw_x4 <= width()) && (draw_y4 >= 0) ) {
apm_litoral 0:ea1b1135bb4e 381 pixel(draw_x4, draw_y4, color);
apm_litoral 0:ea1b1135bb4e 382 }
apm_litoral 0:ea1b1135bb4e 383
apm_litoral 0:ea1b1135bb4e 384 if ( (draw_x5 >= 0) && (draw_y5 >= 0) ) {
apm_litoral 0:ea1b1135bb4e 385 pixel(draw_x5, draw_y5, color);
apm_litoral 0:ea1b1135bb4e 386 }
apm_litoral 0:ea1b1135bb4e 387 if ( (draw_x6 <=width()) && (draw_y6 <= height()) ) {
apm_litoral 0:ea1b1135bb4e 388 pixel(draw_x6, draw_y6, color);
apm_litoral 0:ea1b1135bb4e 389 }
apm_litoral 0:ea1b1135bb4e 390 if ( (draw_x7 >= 0) && (draw_y7 <= height()) ) {
apm_litoral 0:ea1b1135bb4e 391 pixel(draw_x7, draw_y7, color);
apm_litoral 0:ea1b1135bb4e 392 }
apm_litoral 0:ea1b1135bb4e 393 }
apm_litoral 0:ea1b1135bb4e 394 return;
apm_litoral 0:ea1b1135bb4e 395 }
apm_litoral 0:ea1b1135bb4e 396
apm_litoral 0:ea1b1135bb4e 397 void SPI_TFT::fillcircle(int x, int y, int r, int color) {
apm_litoral 0:ea1b1135bb4e 398 int i;
apm_litoral 0:ea1b1135bb4e 399 for (i = 0; i <= r; i++)
apm_litoral 0:ea1b1135bb4e 400 circle(x,y,i,color);
apm_litoral 0:ea1b1135bb4e 401 }
apm_litoral 0:ea1b1135bb4e 402
apm_litoral 0:ea1b1135bb4e 403
apm_litoral 0:ea1b1135bb4e 404
apm_litoral 0:ea1b1135bb4e 405 void SPI_TFT::hline(int x0, int x1, int y, int color) {
apm_litoral 0:ea1b1135bb4e 406 int w;
apm_litoral 0:ea1b1135bb4e 407 w = x1 - x0 + 1;
apm_litoral 0:ea1b1135bb4e 408 windows(x0,y,w,1);
apm_litoral 0:ea1b1135bb4e 409 wr_cmd(0x22);
apm_litoral 0:ea1b1135bb4e 410 wr_dat_start();
apm_litoral 0:ea1b1135bb4e 411 _spi.format(16,3); // pixel are send in 16 bit mode to speed up
apm_litoral 0:ea1b1135bb4e 412 for (int x=0; x<w; x++) {
apm_litoral 0:ea1b1135bb4e 413 _spi.write(color);
apm_litoral 0:ea1b1135bb4e 414 }
apm_litoral 0:ea1b1135bb4e 415 _spi.format(16,3);
apm_litoral 0:ea1b1135bb4e 416 wr_dat_stop();
apm_litoral 0:ea1b1135bb4e 417 WindowMax();
apm_litoral 0:ea1b1135bb4e 418 return;
apm_litoral 0:ea1b1135bb4e 419 }
apm_litoral 0:ea1b1135bb4e 420
apm_litoral 0:ea1b1135bb4e 421
apm_litoral 0:ea1b1135bb4e 422
apm_litoral 0:ea1b1135bb4e 423 void SPI_TFT::vline(int x, int y0, int y1, int color) {
apm_litoral 0:ea1b1135bb4e 424 int h;
apm_litoral 0:ea1b1135bb4e 425 h = y1 - y0 + 1;
apm_litoral 0:ea1b1135bb4e 426 windows(x,y0,1,h);
apm_litoral 0:ea1b1135bb4e 427 wr_cmd(0x22);
apm_litoral 0:ea1b1135bb4e 428 wr_dat_start();
apm_litoral 0:ea1b1135bb4e 429 _spi.format(16,3); // pixel are send in 16 bit mode to speed up
apm_litoral 0:ea1b1135bb4e 430 for (int y=0; y<h; y++) {
apm_litoral 0:ea1b1135bb4e 431 _spi.write(color);
apm_litoral 0:ea1b1135bb4e 432 }
apm_litoral 0:ea1b1135bb4e 433 _spi.format(16,3);
apm_litoral 0:ea1b1135bb4e 434 wr_dat_stop();
apm_litoral 0:ea1b1135bb4e 435 WindowMax();
apm_litoral 0:ea1b1135bb4e 436 return;
apm_litoral 0:ea1b1135bb4e 437 }
apm_litoral 0:ea1b1135bb4e 438
apm_litoral 0:ea1b1135bb4e 439
apm_litoral 0:ea1b1135bb4e 440
apm_litoral 0:ea1b1135bb4e 441 void SPI_TFT::line(int x0, int y0, int x1, int y1, int color) {
apm_litoral 0:ea1b1135bb4e 442 //WindowMax();
apm_litoral 0:ea1b1135bb4e 443 int dx = 0, dy = 0;
apm_litoral 0:ea1b1135bb4e 444 int dx_sym = 0, dy_sym = 0;
apm_litoral 0:ea1b1135bb4e 445 int dx_x2 = 0, dy_x2 = 0;
apm_litoral 0:ea1b1135bb4e 446 int di = 0;
apm_litoral 0:ea1b1135bb4e 447
apm_litoral 0:ea1b1135bb4e 448 dx = x1-x0;
apm_litoral 0:ea1b1135bb4e 449 dy = y1-y0;
apm_litoral 0:ea1b1135bb4e 450
apm_litoral 0:ea1b1135bb4e 451 if (dx == 0) { /* vertical line */
apm_litoral 0:ea1b1135bb4e 452 if (y1 > y0) vline(x0,y0,y1,color);
apm_litoral 0:ea1b1135bb4e 453 else vline(x0,y1,y0,color);
apm_litoral 0:ea1b1135bb4e 454 return;
apm_litoral 0:ea1b1135bb4e 455 }
apm_litoral 0:ea1b1135bb4e 456
apm_litoral 0:ea1b1135bb4e 457 if (dx > 0) {
apm_litoral 0:ea1b1135bb4e 458 dx_sym = 1;
apm_litoral 0:ea1b1135bb4e 459 } else {
apm_litoral 0:ea1b1135bb4e 460 dx_sym = -1;
apm_litoral 0:ea1b1135bb4e 461 }
apm_litoral 0:ea1b1135bb4e 462 if (dy == 0) { /* horizontal line */
apm_litoral 0:ea1b1135bb4e 463 if (x1 > x0) hline(x0,x1,y0,color);
apm_litoral 0:ea1b1135bb4e 464 else hline(x1,x0,y0,color);
apm_litoral 0:ea1b1135bb4e 465 return;
apm_litoral 0:ea1b1135bb4e 466 }
apm_litoral 0:ea1b1135bb4e 467
apm_litoral 0:ea1b1135bb4e 468 if (dy > 0) {
apm_litoral 0:ea1b1135bb4e 469 dy_sym = 1;
apm_litoral 0:ea1b1135bb4e 470 } else {
apm_litoral 0:ea1b1135bb4e 471 dy_sym = -1;
apm_litoral 0:ea1b1135bb4e 472 }
apm_litoral 0:ea1b1135bb4e 473
apm_litoral 0:ea1b1135bb4e 474 dx = dx_sym*dx;
apm_litoral 0:ea1b1135bb4e 475 dy = dy_sym*dy;
apm_litoral 0:ea1b1135bb4e 476
apm_litoral 0:ea1b1135bb4e 477 dx_x2 = dx*2;
apm_litoral 0:ea1b1135bb4e 478 dy_x2 = dy*2;
apm_litoral 0:ea1b1135bb4e 479
apm_litoral 0:ea1b1135bb4e 480 if (dx >= dy) {
apm_litoral 0:ea1b1135bb4e 481 di = dy_x2 - dx;
apm_litoral 0:ea1b1135bb4e 482 while (x0 != x1) {
apm_litoral 0:ea1b1135bb4e 483
apm_litoral 0:ea1b1135bb4e 484 pixel(x0, y0, color);
apm_litoral 0:ea1b1135bb4e 485 x0 += dx_sym;
apm_litoral 0:ea1b1135bb4e 486 if (di<0) {
apm_litoral 0:ea1b1135bb4e 487 di += dy_x2;
apm_litoral 0:ea1b1135bb4e 488 } else {
apm_litoral 0:ea1b1135bb4e 489 di += dy_x2 - dx_x2;
apm_litoral 0:ea1b1135bb4e 490 y0 += dy_sym;
apm_litoral 0:ea1b1135bb4e 491 }
apm_litoral 0:ea1b1135bb4e 492 }
apm_litoral 0:ea1b1135bb4e 493 pixel(x0, y0, color);
apm_litoral 0:ea1b1135bb4e 494 } else {
apm_litoral 0:ea1b1135bb4e 495 di = dx_x2 - dy;
apm_litoral 0:ea1b1135bb4e 496 while (y0 != y1) {
apm_litoral 0:ea1b1135bb4e 497 pixel(x0, y0, color);
apm_litoral 0:ea1b1135bb4e 498 y0 += dy_sym;
apm_litoral 0:ea1b1135bb4e 499 if (di < 0) {
apm_litoral 0:ea1b1135bb4e 500 di += dx_x2;
apm_litoral 0:ea1b1135bb4e 501 } else {
apm_litoral 0:ea1b1135bb4e 502 di += dx_x2 - dy_x2;
apm_litoral 0:ea1b1135bb4e 503 x0 += dx_sym;
apm_litoral 0:ea1b1135bb4e 504 }
apm_litoral 0:ea1b1135bb4e 505 }
apm_litoral 0:ea1b1135bb4e 506 pixel(x0, y0, color);
apm_litoral 0:ea1b1135bb4e 507 }
apm_litoral 0:ea1b1135bb4e 508 return;
apm_litoral 0:ea1b1135bb4e 509 }
apm_litoral 0:ea1b1135bb4e 510
apm_litoral 0:ea1b1135bb4e 511
apm_litoral 0:ea1b1135bb4e 512
apm_litoral 0:ea1b1135bb4e 513
apm_litoral 0:ea1b1135bb4e 514 void SPI_TFT::rect(int x0, int y0, int x1, int y1, int color) {
apm_litoral 0:ea1b1135bb4e 515
apm_litoral 0:ea1b1135bb4e 516 if (x1 > x0) hline(x0,x1,y0,color);
apm_litoral 0:ea1b1135bb4e 517 else hline(x1,x0,y0,color);
apm_litoral 0:ea1b1135bb4e 518
apm_litoral 0:ea1b1135bb4e 519 if (y1 > y0) vline(x0,y0,y1,color);
apm_litoral 0:ea1b1135bb4e 520 else vline(x0,y1,y0,color);
apm_litoral 0:ea1b1135bb4e 521
apm_litoral 0:ea1b1135bb4e 522 if (x1 > x0) hline(x0,x1,y1,color);
apm_litoral 0:ea1b1135bb4e 523 else hline(x1,x0,y1,color);
apm_litoral 0:ea1b1135bb4e 524
apm_litoral 0:ea1b1135bb4e 525 if (y1 > y0) vline(x1,y0,y1,color);
apm_litoral 0:ea1b1135bb4e 526 else vline(x1,y1,y0,color);
apm_litoral 0:ea1b1135bb4e 527
apm_litoral 0:ea1b1135bb4e 528 return;
apm_litoral 0:ea1b1135bb4e 529 }
apm_litoral 0:ea1b1135bb4e 530
apm_litoral 0:ea1b1135bb4e 531
apm_litoral 0:ea1b1135bb4e 532
apm_litoral 0:ea1b1135bb4e 533 void SPI_TFT::fillrect(int x0, int y0, int x1, int y1, int color) {
apm_litoral 0:ea1b1135bb4e 534
apm_litoral 0:ea1b1135bb4e 535 int h = y1 - y0 + 1;
apm_litoral 0:ea1b1135bb4e 536 int w = x1 - x0 + 1;
apm_litoral 0:ea1b1135bb4e 537 int pixel = h * w;
apm_litoral 0:ea1b1135bb4e 538 windows(x0,y0,w,h);
apm_litoral 0:ea1b1135bb4e 539 wr_cmd(0x22);
apm_litoral 0:ea1b1135bb4e 540 wr_dat_start();
apm_litoral 0:ea1b1135bb4e 541 _spi.format(16,3); // pixel are send in 16 bit mode to speed up
apm_litoral 0:ea1b1135bb4e 542 for (int p=0; p<pixel; p++) {
apm_litoral 0:ea1b1135bb4e 543 _spi.write(color);
apm_litoral 0:ea1b1135bb4e 544 }
apm_litoral 0:ea1b1135bb4e 545 _spi.format(16,3);
apm_litoral 0:ea1b1135bb4e 546 wr_dat_stop();
apm_litoral 0:ea1b1135bb4e 547 WindowMax();
apm_litoral 0:ea1b1135bb4e 548 return;
apm_litoral 0:ea1b1135bb4e 549 }
apm_litoral 0:ea1b1135bb4e 550
apm_litoral 0:ea1b1135bb4e 551
apm_litoral 0:ea1b1135bb4e 552
apm_litoral 0:ea1b1135bb4e 553 void SPI_TFT::locate(int x, int y) {
apm_litoral 0:ea1b1135bb4e 554 char_x = x;
apm_litoral 0:ea1b1135bb4e 555 char_y = y;
apm_litoral 0:ea1b1135bb4e 556 }
apm_litoral 0:ea1b1135bb4e 557
apm_litoral 0:ea1b1135bb4e 558
apm_litoral 0:ea1b1135bb4e 559
apm_litoral 0:ea1b1135bb4e 560 int SPI_TFT::columns() {
apm_litoral 0:ea1b1135bb4e 561 return width() / font[1];
apm_litoral 0:ea1b1135bb4e 562 }
apm_litoral 0:ea1b1135bb4e 563
apm_litoral 0:ea1b1135bb4e 564
apm_litoral 0:ea1b1135bb4e 565
apm_litoral 0:ea1b1135bb4e 566 int SPI_TFT::rows() {
apm_litoral 0:ea1b1135bb4e 567 return height() / font[2];
apm_litoral 0:ea1b1135bb4e 568 }
apm_litoral 0:ea1b1135bb4e 569
apm_litoral 0:ea1b1135bb4e 570
apm_litoral 0:ea1b1135bb4e 571
apm_litoral 0:ea1b1135bb4e 572 int SPI_TFT::_putc(int value) {
apm_litoral 0:ea1b1135bb4e 573 if (value == '\n') { // new line
apm_litoral 0:ea1b1135bb4e 574 char_x = 0;
apm_litoral 0:ea1b1135bb4e 575 char_y = char_y + font[2];
apm_litoral 0:ea1b1135bb4e 576 if (char_y >= height() - font[2]) {
apm_litoral 0:ea1b1135bb4e 577 char_y = 0;
apm_litoral 0:ea1b1135bb4e 578 }
apm_litoral 0:ea1b1135bb4e 579 } else {
apm_litoral 0:ea1b1135bb4e 580 character(char_x, char_y, value);
apm_litoral 0:ea1b1135bb4e 581 }
apm_litoral 0:ea1b1135bb4e 582 return value;
apm_litoral 0:ea1b1135bb4e 583 }
apm_litoral 0:ea1b1135bb4e 584
apm_litoral 0:ea1b1135bb4e 585
apm_litoral 0:ea1b1135bb4e 586
apm_litoral 0:ea1b1135bb4e 587
apm_litoral 0:ea1b1135bb4e 588 void SPI_TFT::character(int x, int y, int c) {
apm_litoral 0:ea1b1135bb4e 589 unsigned int hor,vert,offset,bpl,j,i,b;
apm_litoral 0:ea1b1135bb4e 590 unsigned char* zeichen;
apm_litoral 0:ea1b1135bb4e 591 unsigned char z,w;
apm_litoral 0:ea1b1135bb4e 592
apm_litoral 0:ea1b1135bb4e 593 if ((c < 31) || (c > 127)) return; // test char range
apm_litoral 0:ea1b1135bb4e 594
apm_litoral 0:ea1b1135bb4e 595 // read font parameter from start of array
apm_litoral 0:ea1b1135bb4e 596 offset = font[0]; // bytes / char
apm_litoral 0:ea1b1135bb4e 597 hor = font[1]; // get hor size of font
apm_litoral 0:ea1b1135bb4e 598 vert = font[2]; // get vert size of font
apm_litoral 0:ea1b1135bb4e 599 bpl = font[3]; // bytes per line
apm_litoral 0:ea1b1135bb4e 600
apm_litoral 0:ea1b1135bb4e 601 if (char_x + hor > width()) {
apm_litoral 0:ea1b1135bb4e 602 char_x = 0;
apm_litoral 0:ea1b1135bb4e 603 char_y = char_y + vert; //
apm_litoral 0:ea1b1135bb4e 604 if (char_y >= height() - font[2]) {
apm_litoral 0:ea1b1135bb4e 605 char_y = 0;
apm_litoral 0:ea1b1135bb4e 606 }
apm_litoral 0:ea1b1135bb4e 607 }
apm_litoral 0:ea1b1135bb4e 608
apm_litoral 0:ea1b1135bb4e 609 windows(char_x, char_y,hor,vert); // char box
apm_litoral 0:ea1b1135bb4e 610 wr_cmd(0x22);
apm_litoral 0:ea1b1135bb4e 611 wr_dat_start();
apm_litoral 0:ea1b1135bb4e 612 zeichen = &font[((c -32) * offset) + 4]; // start of char bitmap
apm_litoral 0:ea1b1135bb4e 613 w = zeichen[0]; // width of actual char
apm_litoral 0:ea1b1135bb4e 614 _spi.format(16,3); // pixel are 16 bit
apm_litoral 0:ea1b1135bb4e 615
apm_litoral 0:ea1b1135bb4e 616 for (j=0; j<vert; j++) { // vert line
apm_litoral 0:ea1b1135bb4e 617 for (i=0; i<hor; i++) { // horz line
apm_litoral 0:ea1b1135bb4e 618 z = zeichen[bpl * i + ((j & 0xF8) >> 3)+1];
apm_litoral 0:ea1b1135bb4e 619 b = 1 << (j & 0x07);
apm_litoral 0:ea1b1135bb4e 620 if (( z & b ) == 0x00) {
apm_litoral 0:ea1b1135bb4e 621 _spi.write(_background);
apm_litoral 0:ea1b1135bb4e 622 } else {
apm_litoral 0:ea1b1135bb4e 623 _spi.write(_foreground);
apm_litoral 0:ea1b1135bb4e 624 }
apm_litoral 0:ea1b1135bb4e 625 }
apm_litoral 0:ea1b1135bb4e 626 }
apm_litoral 0:ea1b1135bb4e 627 _spi.format(16,3); // 8 bit
apm_litoral 0:ea1b1135bb4e 628 wr_dat_stop();
apm_litoral 0:ea1b1135bb4e 629 WindowMax();
apm_litoral 0:ea1b1135bb4e 630 if ((w + 2) < hor) { // x offset to next char
apm_litoral 0:ea1b1135bb4e 631 char_x += w + 2;
apm_litoral 0:ea1b1135bb4e 632 } else char_x += hor;
apm_litoral 0:ea1b1135bb4e 633 }
apm_litoral 0:ea1b1135bb4e 634
apm_litoral 0:ea1b1135bb4e 635
apm_litoral 0:ea1b1135bb4e 636
apm_litoral 0:ea1b1135bb4e 637
apm_litoral 0:ea1b1135bb4e 638
apm_litoral 0:ea1b1135bb4e 639 void SPI_TFT::set_font(unsigned char* f) {
apm_litoral 0:ea1b1135bb4e 640 font = f;
apm_litoral 0:ea1b1135bb4e 641 }
apm_litoral 0:ea1b1135bb4e 642
apm_litoral 0:ea1b1135bb4e 643
apm_litoral 0:ea1b1135bb4e 644
apm_litoral 0:ea1b1135bb4e 645 void SPI_TFT::Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned char *bitmap) {
apm_litoral 0:ea1b1135bb4e 646 unsigned int i,j;
apm_litoral 0:ea1b1135bb4e 647 signed padd = -1;
apm_litoral 0:ea1b1135bb4e 648 unsigned short *bitmap_ptr = (unsigned short *)bitmap;
apm_litoral 0:ea1b1135bb4e 649 // the lines are padded to multiple of 4 bytes in a bitmap
apm_litoral 0:ea1b1135bb4e 650 //padd = -1;
apm_litoral 0:ea1b1135bb4e 651 do {
apm_litoral 0:ea1b1135bb4e 652 padd ++;
apm_litoral 0:ea1b1135bb4e 653 } while (2*(w + padd)%4 != 0);
apm_litoral 0:ea1b1135bb4e 654 windows(x, y, w, h);
apm_litoral 0:ea1b1135bb4e 655 wr_cmd(0x22);
apm_litoral 0:ea1b1135bb4e 656 wr_dat_start();
apm_litoral 0:ea1b1135bb4e 657 _spi.format(16,3);
apm_litoral 0:ea1b1135bb4e 658 bitmap_ptr += ((h - 1)* (w + padd));
apm_litoral 0:ea1b1135bb4e 659 //bitmap_ptr -= padd;
apm_litoral 0:ea1b1135bb4e 660 for (j = 0; j < h; j++) { //Lines
apm_litoral 0:ea1b1135bb4e 661 for (i = 0; i < w; i++) { // copy pixel data to TFT
apm_litoral 0:ea1b1135bb4e 662 _spi.write(*bitmap_ptr); // one line
apm_litoral 0:ea1b1135bb4e 663 bitmap_ptr++;
apm_litoral 0:ea1b1135bb4e 664 }
apm_litoral 0:ea1b1135bb4e 665 bitmap_ptr -= 2*w;
apm_litoral 0:ea1b1135bb4e 666 //bitmap_ptr -= padd;
apm_litoral 0:ea1b1135bb4e 667 }
apm_litoral 0:ea1b1135bb4e 668 _spi.format(16,3);
apm_litoral 0:ea1b1135bb4e 669 wr_dat_stop();
apm_litoral 0:ea1b1135bb4e 670 WindowMax();
apm_litoral 0:ea1b1135bb4e 671 }
apm_litoral 0:ea1b1135bb4e 672
apm_litoral 0:ea1b1135bb4e 673
apm_litoral 0:ea1b1135bb4e 674 int SPI_TFT::BMP_16(unsigned int x, unsigned int y, const char *Name_BMP) {
apm_litoral 0:ea1b1135bb4e 675
apm_litoral 0:ea1b1135bb4e 676 #define OffsetPixelWidth 18
apm_litoral 0:ea1b1135bb4e 677 #define OffsetPixelHeigh 22
apm_litoral 0:ea1b1135bb4e 678 #define OffsetFileSize 34
apm_litoral 0:ea1b1135bb4e 679 #define OffsetPixData 10
apm_litoral 0:ea1b1135bb4e 680 #define OffsetBPP 28
apm_litoral 0:ea1b1135bb4e 681
apm_litoral 0:ea1b1135bb4e 682 char filename[50];
apm_litoral 0:ea1b1135bb4e 683 unsigned char BMP_Header[54];
apm_litoral 0:ea1b1135bb4e 684 unsigned short BPP_t;
apm_litoral 0:ea1b1135bb4e 685 unsigned int PixelWidth,PixelHeigh,start_data;
apm_litoral 0:ea1b1135bb4e 686 unsigned int i,off;
apm_litoral 0:ea1b1135bb4e 687 int padd,j;
apm_litoral 0:ea1b1135bb4e 688 unsigned short *line;
apm_litoral 0:ea1b1135bb4e 689
apm_litoral 0:ea1b1135bb4e 690 // get the filename
apm_litoral 0:ea1b1135bb4e 691 //LocalFileSystem local("local");
apm_litoral 0:ea1b1135bb4e 692 sprintf(&filename[0],"/sd/");
apm_litoral 0:ea1b1135bb4e 693 i=7;
apm_litoral 0:ea1b1135bb4e 694 while (*Name_BMP!='\0') {
apm_litoral 0:ea1b1135bb4e 695 filename[i++]=*Name_BMP++;
apm_litoral 0:ea1b1135bb4e 696 }
apm_litoral 0:ea1b1135bb4e 697 FILE *Image = fopen((const char *)&filename[0], "r"); // open the bmp file
apm_litoral 0:ea1b1135bb4e 698 if (!Image) {
apm_litoral 0:ea1b1135bb4e 699 return(0); // error file not found !
apm_litoral 0:ea1b1135bb4e 700 }
apm_litoral 0:ea1b1135bb4e 701
apm_litoral 0:ea1b1135bb4e 702 fread(&BMP_Header[0],1,54,Image); // get the BMP Header
apm_litoral 0:ea1b1135bb4e 703
apm_litoral 0:ea1b1135bb4e 704 if (BMP_Header[0] != 0x42 || BMP_Header[1] != 0x4D) { // check magic byte
apm_litoral 0:ea1b1135bb4e 705 fclose(Image);
apm_litoral 0:ea1b1135bb4e 706 return(-1); // error no BMP file
apm_litoral 0:ea1b1135bb4e 707 }
apm_litoral 0:ea1b1135bb4e 708
apm_litoral 0:ea1b1135bb4e 709 BPP_t = BMP_Header[OffsetBPP] + (BMP_Header[OffsetBPP + 1] << 8);
apm_litoral 0:ea1b1135bb4e 710 if (BPP_t != 0x0010) {
apm_litoral 0:ea1b1135bb4e 711 fclose(Image);
apm_litoral 0:ea1b1135bb4e 712 return(-2); // error no 16 bit BMP
apm_litoral 0:ea1b1135bb4e 713 }
apm_litoral 0:ea1b1135bb4e 714
apm_litoral 0:ea1b1135bb4e 715 PixelHeigh = BMP_Header[OffsetPixelHeigh] + (BMP_Header[OffsetPixelHeigh + 1] << 8) + (BMP_Header[OffsetPixelHeigh + 2] << 16) + (BMP_Header[OffsetPixelHeigh + 3] << 24);
apm_litoral 0:ea1b1135bb4e 716 PixelWidth = BMP_Header[OffsetPixelWidth] + (BMP_Header[OffsetPixelWidth + 1] << 8) + (BMP_Header[OffsetPixelWidth + 2] << 16) + (BMP_Header[OffsetPixelWidth + 3] << 24);
apm_litoral 0:ea1b1135bb4e 717 if (PixelHeigh > height() + y || PixelWidth > width() + x) {
apm_litoral 0:ea1b1135bb4e 718 fclose(Image);
apm_litoral 0:ea1b1135bb4e 719 return(-3); // to big
apm_litoral 0:ea1b1135bb4e 720 }
apm_litoral 0:ea1b1135bb4e 721
apm_litoral 0:ea1b1135bb4e 722 start_data = BMP_Header[OffsetPixData] + (BMP_Header[OffsetPixData + 1] << 8) + (BMP_Header[OffsetPixData + 2] << 16) + (BMP_Header[OffsetPixData + 3] << 24);
apm_litoral 0:ea1b1135bb4e 723
apm_litoral 0:ea1b1135bb4e 724 line = (unsigned short *) malloc (PixelWidth); // we need a buffer for a line
apm_litoral 0:ea1b1135bb4e 725 if (line == NULL) {
apm_litoral 0:ea1b1135bb4e 726 return(-4); // error no memory
apm_litoral 0:ea1b1135bb4e 727 }
apm_litoral 0:ea1b1135bb4e 728
apm_litoral 0:ea1b1135bb4e 729 // the lines are padded to multiple of 4 bytes
apm_litoral 0:ea1b1135bb4e 730 padd = -1;
apm_litoral 0:ea1b1135bb4e 731 do {
apm_litoral 0:ea1b1135bb4e 732 padd ++;
apm_litoral 0:ea1b1135bb4e 733 } while ((PixelWidth * 2 + padd)%4 != 0);
apm_litoral 0:ea1b1135bb4e 734
apm_litoral 0:ea1b1135bb4e 735 window(x, y,PixelWidth,PixelHeigh);
apm_litoral 0:ea1b1135bb4e 736 wr_cmd(0x22);
apm_litoral 0:ea1b1135bb4e 737 wr_dat_start();
apm_litoral 0:ea1b1135bb4e 738 _spi.format(16,3);
apm_litoral 0:ea1b1135bb4e 739 for (j = PixelHeigh - 1; j >= 0; j--) { //Lines bottom up
apm_litoral 0:ea1b1135bb4e 740 off = j * (PixelWidth * 2 + padd) + start_data; // start of line
apm_litoral 0:ea1b1135bb4e 741 fseek(Image, off ,SEEK_SET);
apm_litoral 0:ea1b1135bb4e 742 fread(line,1,PixelWidth * 2,Image); // read a line - slow !
apm_litoral 0:ea1b1135bb4e 743 for (i = 0; i < PixelWidth; i++) { // copy pixel data to TFT
apm_litoral 0:ea1b1135bb4e 744 _spi.write(line[i]); // one 16 bit pixel
apm_litoral 0:ea1b1135bb4e 745 }
apm_litoral 0:ea1b1135bb4e 746 }
apm_litoral 0:ea1b1135bb4e 747 _spi.format(16,3);
apm_litoral 0:ea1b1135bb4e 748 wr_dat_stop();
apm_litoral 0:ea1b1135bb4e 749 free (line);
apm_litoral 0:ea1b1135bb4e 750 fclose(Image);
apm_litoral 0:ea1b1135bb4e 751 WindowMax();
apm_litoral 0:ea1b1135bb4e 752 return(1);
apm_litoral 0:ea1b1135bb4e 753 }
apm_litoral 0:ea1b1135bb4e 754
apm_litoral 0:ea1b1135bb4e 755 int SPI_TFT::BMP_SD(unsigned int x_sd, unsigned int y_sd, const char *Name_BMP_SD) {
apm_litoral 0:ea1b1135bb4e 756
apm_litoral 0:ea1b1135bb4e 757 #define OffsetPixelWidth_sd 18
apm_litoral 0:ea1b1135bb4e 758 #define OffsetPixelHeigh_sd 22
apm_litoral 0:ea1b1135bb4e 759 #define OffsetFileSize_sd 34
apm_litoral 0:ea1b1135bb4e 760 #define OffsetPixData_sd 10
apm_litoral 0:ea1b1135bb4e 761 #define OffsetBPP_sd 28
apm_litoral 0:ea1b1135bb4e 762
apm_litoral 0:ea1b1135bb4e 763
apm_litoral 0:ea1b1135bb4e 764 char filename_sd[50];
apm_litoral 0:ea1b1135bb4e 765 unsigned char BMP_Header_sd[54];
apm_litoral 0:ea1b1135bb4e 766 unsigned short BPP_t_sd=0;
apm_litoral 0:ea1b1135bb4e 767 unsigned int PixelWidth_sd=0,PixelHeigh_sd=0,start_data_sd=0;
apm_litoral 0:ea1b1135bb4e 768 unsigned int i_sd=0,off_sd=0;
apm_litoral 0:ea1b1135bb4e 769 int padd_sd=0,j_sd=0;
apm_litoral 0:ea1b1135bb4e 770 unsigned short *line_sd=0;
apm_litoral 0:ea1b1135bb4e 771
apm_litoral 0:ea1b1135bb4e 772 // get the filename
apm_litoral 0:ea1b1135bb4e 773 //LocalFileSystem local("local");
apm_litoral 0:ea1b1135bb4e 774 sprintf(&filename_sd[0],"/sd/");
apm_litoral 0:ea1b1135bb4e 775 i_sd=4;
apm_litoral 0:ea1b1135bb4e 776 while (*Name_BMP_SD!='\0') {
apm_litoral 0:ea1b1135bb4e 777 filename_sd[i_sd++]=*Name_BMP_SD++;
apm_litoral 0:ea1b1135bb4e 778 }
apm_litoral 0:ea1b1135bb4e 779 //FILE *fp = fopen("/sd/carpeta1/Saludo.txt", "w");
apm_litoral 0:ea1b1135bb4e 780 FILE *Image_sd = fopen((const char *)&filename_sd[0], "r"); // open the bmp file
apm_litoral 0:ea1b1135bb4e 781 //if (Image_sd == NULL) {
apm_litoral 0:ea1b1135bb4e 782 // mbed_reset();//error("No se puede acceder al archivo\n");
apm_litoral 0:ea1b1135bb4e 783 //}
apm_litoral 0:ea1b1135bb4e 784 if (!Image_sd) {
apm_litoral 0:ea1b1135bb4e 785 return(0); // error file not found !
apm_litoral 0:ea1b1135bb4e 786 //int c;
apm_litoral 0:ea1b1135bb4e 787 //c = fgetc(Image_sd);
apm_litoral 0:ea1b1135bb4e 788 //printf("file: %c\r\n", c);
apm_litoral 0:ea1b1135bb4e 789 //fclose(Image_sd);
apm_litoral 0:ea1b1135bb4e 790 }
apm_litoral 0:ea1b1135bb4e 791
apm_litoral 0:ea1b1135bb4e 792 fread(&BMP_Header_sd[0],1,54,Image_sd); // get the BMP Header
apm_litoral 0:ea1b1135bb4e 793
apm_litoral 0:ea1b1135bb4e 794 if (BMP_Header_sd[0] != 0x42 || BMP_Header_sd[1] != 0x4D) { // check magic byte
apm_litoral 0:ea1b1135bb4e 795 fclose(Image_sd);
apm_litoral 0:ea1b1135bb4e 796 return(-1); // error no BMP file
apm_litoral 0:ea1b1135bb4e 797 }
apm_litoral 0:ea1b1135bb4e 798
apm_litoral 0:ea1b1135bb4e 799 BPP_t_sd = BMP_Header_sd[OffsetBPP_sd] + (BMP_Header_sd[OffsetBPP_sd + 1] << 8);
apm_litoral 0:ea1b1135bb4e 800 if (BPP_t_sd != 0x0010) {
apm_litoral 0:ea1b1135bb4e 801 fclose(Image_sd);
apm_litoral 0:ea1b1135bb4e 802 return(-2); // error no 16 bit BMP
apm_litoral 0:ea1b1135bb4e 803 }
apm_litoral 0:ea1b1135bb4e 804
apm_litoral 0:ea1b1135bb4e 805 PixelHeigh_sd = BMP_Header_sd[OffsetPixelHeigh_sd] + (BMP_Header_sd[OffsetPixelHeigh_sd + 1] << 8) + (BMP_Header_sd[OffsetPixelHeigh_sd + 2] << 16) + (BMP_Header_sd[OffsetPixelHeigh_sd + 3] << 24);
apm_litoral 0:ea1b1135bb4e 806 PixelWidth_sd = BMP_Header_sd[OffsetPixelWidth_sd] + (BMP_Header_sd[OffsetPixelWidth_sd + 1] << 8) + (BMP_Header_sd[OffsetPixelWidth_sd + 2] << 16) + (BMP_Header_sd[OffsetPixelWidth_sd + 3] << 24);
apm_litoral 0:ea1b1135bb4e 807 if (PixelHeigh_sd > height() + y_sd || PixelWidth_sd > width() + x_sd) {
apm_litoral 0:ea1b1135bb4e 808 fclose(Image_sd);
apm_litoral 0:ea1b1135bb4e 809 return(-3); // to big
apm_litoral 0:ea1b1135bb4e 810 }
apm_litoral 0:ea1b1135bb4e 811
apm_litoral 0:ea1b1135bb4e 812 start_data_sd = BMP_Header_sd[OffsetPixData_sd] + (BMP_Header_sd[OffsetPixData_sd + 1] << 8) + (BMP_Header_sd[OffsetPixData_sd + 2] << 16) + (BMP_Header_sd[OffsetPixData_sd + 3] << 24);
apm_litoral 0:ea1b1135bb4e 813
apm_litoral 0:ea1b1135bb4e 814 line_sd = (unsigned short *) malloc(PixelWidth_sd); // we need a buffer for a line
apm_litoral 0:ea1b1135bb4e 815 if (line_sd == NULL) {
apm_litoral 0:ea1b1135bb4e 816 return(-4); // error no memory
apm_litoral 0:ea1b1135bb4e 817 }
apm_litoral 0:ea1b1135bb4e 818
apm_litoral 0:ea1b1135bb4e 819 // the lines are padded to multiple of 4 bytes
apm_litoral 0:ea1b1135bb4e 820 padd_sd = -1;
apm_litoral 0:ea1b1135bb4e 821 do {
apm_litoral 0:ea1b1135bb4e 822 padd_sd ++;
apm_litoral 0:ea1b1135bb4e 823 } while ((PixelWidth_sd * 2 + padd_sd)%4 != 0);
apm_litoral 0:ea1b1135bb4e 824 //int ifr=320;
apm_litoral 0:ea1b1135bb4e 825 window(x_sd, y_sd,PixelWidth_sd,PixelHeigh_sd);
apm_litoral 0:ea1b1135bb4e 826 wr_cmd(0x22);
apm_litoral 0:ea1b1135bb4e 827 wr_dat_start();
apm_litoral 0:ea1b1135bb4e 828 _spi.format(16,3);
apm_litoral 0:ea1b1135bb4e 829 _bk = 0;
apm_litoral 0:ea1b1135bb4e 830
apm_litoral 0:ea1b1135bb4e 831 for (j_sd = PixelHeigh_sd - 1; j_sd >= 0; j_sd--) { //Lines bottom up
apm_litoral 0:ea1b1135bb4e 832 off_sd = j_sd * (PixelWidth_sd * 2 + padd_sd) + start_data_sd; // start of line
apm_litoral 0:ea1b1135bb4e 833 fseek(Image_sd, off_sd ,SEEK_SET);
apm_litoral 0:ea1b1135bb4e 834 fread(line_sd,1,PixelWidth_sd * 2,Image_sd); // read a line - slow !
apm_litoral 0:ea1b1135bb4e 835 for (i_sd = 0; i_sd < PixelWidth_sd; i_sd++) { // copy pixel data to TFT
apm_litoral 0:ea1b1135bb4e 836 _spi.write(line_sd[i_sd]); // one 16 bit pixel
apm_litoral 0:ea1b1135bb4e 837 }
apm_litoral 0:ea1b1135bb4e 838 //sharepoint(0,0,320,off_sd,1,0);
apm_litoral 0:ea1b1135bb4e 839
apm_litoral 0:ea1b1135bb4e 840 }
apm_litoral 0:ea1b1135bb4e 841 //ifr=320;
apm_litoral 0:ea1b1135bb4e 842 _spi.format(16,3);
apm_litoral 0:ea1b1135bb4e 843 wr_dat_stop();
apm_litoral 0:ea1b1135bb4e 844 free (line_sd);
apm_litoral 0:ea1b1135bb4e 845 fclose(Image_sd);
apm_litoral 0:ea1b1135bb4e 846 WindowMax();
apm_litoral 0:ea1b1135bb4e 847 //sharepoint(0,0,320,ifr--,0,1);
apm_litoral 0:ea1b1135bb4e 848 return(1);
apm_litoral 0:ea1b1135bb4e 849 }
apm_litoral 0:ea1b1135bb4e 850
apm_litoral 0:ea1b1135bb4e 851 void SPI_TFT::tft_rst_hw() {
apm_litoral 0:ea1b1135bb4e 852 _reset = 0; // reset
apm_litoral 0:ea1b1135bb4e 853 _cs = 1;
apm_litoral 0:ea1b1135bb4e 854 wait_us(50);
apm_litoral 0:ea1b1135bb4e 855 _reset = 1; // end reset
apm_litoral 0:ea1b1135bb4e 856 wait_ms(5);//
apm_litoral 0:ea1b1135bb4e 857 }
apm_litoral 0:ea1b1135bb4e 858
apm_litoral 0:ea1b1135bb4e 859 void SPI_TFT::backlight(float intensity) {
apm_litoral 0:ea1b1135bb4e 860 _bk = intensity; // (0.01);
apm_litoral 0:ea1b1135bb4e 861 }
apm_litoral 0:ea1b1135bb4e 862
apm_litoral 0:ea1b1135bb4e 863 void SPI_TFT::contraste_pos(float min, float max, float steep, float delay) {
apm_litoral 0:ea1b1135bb4e 864 /* bk.period(0.001);
apm_litoral 0:ea1b1135bb4e 865 for (float s= 0.01; s < 1.0 ; s += 0.01){
apm_litoral 0:ea1b1135bb4e 866 }*/
apm_litoral 0:ea1b1135bb4e 867 for (float contrast= min; contrast < max ; contrast += steep) {
apm_litoral 0:ea1b1135bb4e 868 _bk = contrast;
apm_litoral 0:ea1b1135bb4e 869 wait(delay);
apm_litoral 0:ea1b1135bb4e 870 }
apm_litoral 0:ea1b1135bb4e 871 }
apm_litoral 0:ea1b1135bb4e 872
apm_litoral 0:ea1b1135bb4e 873 void SPI_TFT::contraste_neg(float max, float min, float steep, float delay) {
apm_litoral 0:ea1b1135bb4e 874 /* bk.period(0.001);
apm_litoral 0:ea1b1135bb4e 875 for (float s= 0.01; s < 1.0 ; s += 0.01){
apm_litoral 0:ea1b1135bb4e 876 }*/
apm_litoral 0:ea1b1135bb4e 877 for (float contrast= max; contrast > min ; contrast -= steep) {
apm_litoral 0:ea1b1135bb4e 878 _bk = contrast;
apm_litoral 0:ea1b1135bb4e 879 wait(delay);
apm_litoral 0:ea1b1135bb4e 880 }
apm_litoral 0:ea1b1135bb4e 881 }
apm_litoral 0:ea1b1135bb4e 882
apm_litoral 0:ea1b1135bb4e 883 void SPI_TFT::charge(int x0, int y0, int x1, int y1, int color_max, int color_min, float speed) {
apm_litoral 0:ea1b1135bb4e 884 int xi, yf=y0;
apm_litoral 0:ea1b1135bb4e 885 int painter;
apm_litoral 0:ea1b1135bb4e 886 x1++;
apm_litoral 0:ea1b1135bb4e 887 painter = abs(0x1F);
apm_litoral 0:ea1b1135bb4e 888 while (yf < 320) {
apm_litoral 0:ea1b1135bb4e 889 for (xi=x0 ; xi < x1; xi++) {
apm_litoral 0:ea1b1135bb4e 890 line(xi,y0,xi,y1,painter);
apm_litoral 0:ea1b1135bb4e 891 painter = painter+color_max;//azul perfecta barra 0x8000 azul mas entrecortado 0x0080;// azulado medio 0x0040;//a colores 0xf424;//color lila entrecortado 0x0800;// azulado 0.1//204
apm_litoral 0:ea1b1135bb4e 892 yf++;
apm_litoral 0:ea1b1135bb4e 893 wait(speed);
apm_litoral 0:ea1b1135bb4e 894 }
apm_litoral 0:ea1b1135bb4e 895 }
apm_litoral 0:ea1b1135bb4e 896 }
apm_litoral 0:ea1b1135bb4e 897
apm_litoral 0:ea1b1135bb4e 898 void SPI_TFT::parpadeo(int parpadeos, float max, float min, float steep, float delay,float stop, float brigthness) {
apm_litoral 0:ea1b1135bb4e 899 for (int bkl=0; bkl<parpadeos; bkl++) {
apm_litoral 0:ea1b1135bb4e 900 contraste_neg(max,min,steep,delay);
apm_litoral 0:ea1b1135bb4e 901 contraste_pos(min,max,steep,delay); //min, max, steep, delay
apm_litoral 0:ea1b1135bb4e 902 backlight(brigthness);
apm_litoral 0:ea1b1135bb4e 903 wait(stop);
apm_litoral 0:ea1b1135bb4e 904 }
apm_litoral 0:ea1b1135bb4e 905 }
apm_litoral 0:ea1b1135bb4e 906
apm_litoral 0:ea1b1135bb4e 907 void SPI_TFT::Init_Kernel_Up(float brillo, int color, int orientation, unsigned char* letra,int x,int y,int delay) {
apm_litoral 0:ea1b1135bb4e 908 backlight(brillo); //0.0001
apm_litoral 0:ea1b1135bb4e 909 foreground(color); //DarkGrey
apm_litoral 0:ea1b1135bb4e 910 set_orientation(orientation);
apm_litoral 0:ea1b1135bb4e 911 font = letra; //Arial12x12 select font 2
apm_litoral 0:ea1b1135bb4e 912 locate(x,y);//0,0
apm_litoral 0:ea1b1135bb4e 913 ///*
apm_litoral 0:ea1b1135bb4e 914 const char BioOs[28] = {
apm_litoral 0:ea1b1135bb4e 915 0x2F,0x73,0x64,0x2F,0x52,0x54,0x4F,0x53,
apm_litoral 0:ea1b1135bb4e 916 0x5F,0x41,0x50,0x4D,0x2F,0x43,0x6F,0x6E,
apm_litoral 0:ea1b1135bb4e 917 0x66,0x69,0x67,0x2F,0x74,0x66,0x74,0x2E,
apm_litoral 0:ea1b1135bb4e 918 0x62,0x69,0x6F,0x00
apm_litoral 0:ea1b1135bb4e 919 };
apm_litoral 0:ea1b1135bb4e 920
apm_litoral 0:ea1b1135bb4e 921 FILE *spi = fopen((const char *)&BioOs[0], "r");
apm_litoral 0:ea1b1135bb4e 922 if (spi) {
apm_litoral 0:ea1b1135bb4e 923 char c;
apm_litoral 0:ea1b1135bb4e 924 c = fgetc(spi);
apm_litoral 0:ea1b1135bb4e 925 printf("file: %c\r\n", c);
apm_litoral 0:ea1b1135bb4e 926 fclose(spi);
apm_litoral 0:ea1b1135bb4e 927 }
apm_litoral 0:ea1b1135bb4e 928 if (spi == NULL) {
apm_litoral 0:ea1b1135bb4e 929 mbed_reset();//error("No se puede acceder al archivo\n");
apm_litoral 0:ea1b1135bb4e 930 }
apm_litoral 0:ea1b1135bb4e 931 //*/
apm_litoral 0:ea1b1135bb4e 932 const char Shutup[24] = {
apm_litoral 0:ea1b1135bb4e 933 0x52,0x54,0x4F,0x53,0x5F,0x41,0x50,0x4D,
apm_litoral 0:ea1b1135bb4e 934 0x2F,0x43,0x6F,0x6E,0x66,0x69,0x67,0x2F,
apm_litoral 0:ea1b1135bb4e 935 0x6F,0x6E,0x6E,0x2E,0x62,0x69,0x6F,0x00
apm_litoral 0:ea1b1135bb4e 936 };
apm_litoral 0:ea1b1135bb4e 937
apm_litoral 0:ea1b1135bb4e 938 wait(delay);//0.30
apm_litoral 0:ea1b1135bb4e 939 cls();
apm_litoral 0:ea1b1135bb4e 940 BMP_SD(0,0,(const char *)&Shutup[0]);//bee
apm_litoral 0:ea1b1135bb4e 941 }
apm_litoral 0:ea1b1135bb4e 942
apm_litoral 0:ea1b1135bb4e 943 void SPI_TFT::Init_Kernel_Down(float brillo, int color, int orientation, unsigned char* letra,int x,int y,int delay) {
apm_litoral 0:ea1b1135bb4e 944 backlight(brillo); //0.0001
apm_litoral 0:ea1b1135bb4e 945 foreground(color); //DarkGrey
apm_litoral 0:ea1b1135bb4e 946 set_orientation(orientation);
apm_litoral 0:ea1b1135bb4e 947 font = letra; //Arial12x12 select font 2
apm_litoral 0:ea1b1135bb4e 948 locate(x,y);//0,0
apm_litoral 0:ea1b1135bb4e 949 const char Shutdown[24] = {
apm_litoral 0:ea1b1135bb4e 950 0x52,0x54,0x4F,0x53,0x5F,0x41,0x50,0x4D,
apm_litoral 0:ea1b1135bb4e 951 0x2F,0x43,0x6F,0x6E,0x66,0x69,0x67,0x2F,
apm_litoral 0:ea1b1135bb4e 952 0x6F,0x66,0x66,0x2E,0x62,0x69,0x6F,0x00
apm_litoral 0:ea1b1135bb4e 953 };
apm_litoral 0:ea1b1135bb4e 954
apm_litoral 0:ea1b1135bb4e 955 wait(delay);//0.30
apm_litoral 0:ea1b1135bb4e 956 cls();
apm_litoral 0:ea1b1135bb4e 957 BMP_SD(0,0,(const char *)&Shutdown[0]);//bee
apm_litoral 0:ea1b1135bb4e 958 }
apm_litoral 0:ea1b1135bb4e 959
apm_litoral 0:ea1b1135bb4e 960 void SPI_TFT::init_tasking(float brillo, int color, int orientation, unsigned char* letra,int x,int y,int delay) {
apm_litoral 0:ea1b1135bb4e 961 backlight(brillo); //0.0001
apm_litoral 0:ea1b1135bb4e 962 foreground(color); //DarkGrey
apm_litoral 0:ea1b1135bb4e 963 set_orientation(orientation);
apm_litoral 0:ea1b1135bb4e 964 font = letra; //Arial12x12 select font 2
apm_litoral 0:ea1b1135bb4e 965 locate(x,y);//0,0
apm_litoral 0:ea1b1135bb4e 966
apm_litoral 0:ea1b1135bb4e 967 const char chargue[24] = {
apm_litoral 0:ea1b1135bb4e 968 0x52,0x54,0x4F,0x53,0x5F,0x41,0x50,0x4D,
apm_litoral 0:ea1b1135bb4e 969 0x2F,0x43,0x6F,0x6E,0x66,0x69,0x67,0x2F,
apm_litoral 0:ea1b1135bb4e 970 0x62,0x65,0x65,0x2E,0x62,0x69,0x6F,0x00
apm_litoral 0:ea1b1135bb4e 971 };
apm_litoral 0:ea1b1135bb4e 972 const char Shutup[24] = {
apm_litoral 0:ea1b1135bb4e 973 0x52,0x54,0x4F,0x53,0x5F,0x41,0x50,0x4D,
apm_litoral 0:ea1b1135bb4e 974 0x2F,0x43,0x6F,0x6E,0x66,0x69,0x67,0x2F,
apm_litoral 0:ea1b1135bb4e 975 0x6F,0x6E,0x6E,0x2E,0x62,0x69,0x6F,0x00// on.bio
apm_litoral 0:ea1b1135bb4e 976 };
apm_litoral 0:ea1b1135bb4e 977 wait(delay);//0.30
apm_litoral 0:ea1b1135bb4e 978 cls();
apm_litoral 0:ea1b1135bb4e 979 BMP_SD(0,0,(const char *)&Shutup[0]);//bee
apm_litoral 0:ea1b1135bb4e 980 parpadeo(1,1,0.1,0.01,0.01,0.2,1.0);
apm_litoral 0:ea1b1135bb4e 981 contraste_neg(1.0,0.0,0.01,0.005);
apm_litoral 0:ea1b1135bb4e 982 backlight(0);
apm_litoral 0:ea1b1135bb4e 983 cls();
apm_litoral 0:ea1b1135bb4e 984 BMP_SD(0,0,(const char *)&chargue[0]);//bee
apm_litoral 0:ea1b1135bb4e 985 contraste_pos(0,1,0.05,0.005);
apm_litoral 0:ea1b1135bb4e 986 wait(2);
apm_litoral 0:ea1b1135bb4e 987 binary_init(20,285,220,290,2);
apm_litoral 0:ea1b1135bb4e 988
apm_litoral 0:ea1b1135bb4e 989 }
apm_litoral 0:ea1b1135bb4e 990
apm_litoral 0:ea1b1135bb4e 991
apm_litoral 0:ea1b1135bb4e 992 void SPI_TFT::binary_init(int a, int b, int c, int d, int delay) {
apm_litoral 0:ea1b1135bb4e 993 rect(a,b,c,d,0x000F); //18,148,302,158,w
apm_litoral 0:ea1b1135bb4e 994 rect(a+1,b+1,c-1,d-1,0x780F); //19,149,301,l57g
apm_litoral 0:ea1b1135bb4e 995 rect(a+2,b+2,c-2,d-2,0x07E0); //20,150,300,156,dg
apm_litoral 0:ea1b1135bb4e 996 fillrect(a+3,b+3,c-3,d-3,0xFFFF); //21,151,298,155,w
apm_litoral 0:ea1b1135bb4e 997 int x0=a+3;
apm_litoral 0:ea1b1135bb4e 998 int y0=b+3;
apm_litoral 0:ea1b1135bb4e 999 int x1=c-3;
apm_litoral 0:ea1b1135bb4e 1000 int y1=d-3;
apm_litoral 0:ea1b1135bb4e 1001 int xi, yf=y0;
apm_litoral 0:ea1b1135bb4e 1002 x1++;
apm_litoral 0:ea1b1135bb4e 1003 while (yf < 318) {
apm_litoral 0:ea1b1135bb4e 1004 for (xi=x0 ; xi < x1; xi++) {
apm_litoral 0:ea1b1135bb4e 1005 line(xi,y0,xi,y1,0x780F);
apm_litoral 0:ea1b1135bb4e 1006 wait(0.02);
apm_litoral 0:ea1b1135bb4e 1007 yf++;
apm_litoral 0:ea1b1135bb4e 1008 }
apm_litoral 0:ea1b1135bb4e 1009 }
apm_litoral 0:ea1b1135bb4e 1010 wait(delay);
apm_litoral 0:ea1b1135bb4e 1011 }
apm_litoral 0:ea1b1135bb4e 1012
apm_litoral 0:ea1b1135bb4e 1013
apm_litoral 0:ea1b1135bb4e 1014 void SPI_TFT::strcmp(float brillo, int color, int orientation, unsigned char* letra,int x,int y,int delay) {
apm_litoral 0:ea1b1135bb4e 1015 backlight(brillo); //0.0001
apm_litoral 0:ea1b1135bb4e 1016 foreground(color); //DarkGrey
apm_litoral 0:ea1b1135bb4e 1017 set_orientation(orientation);
apm_litoral 0:ea1b1135bb4e 1018 font = letra; //Arial12x12 select font 2
apm_litoral 0:ea1b1135bb4e 1019 wait(delay);//0.30
apm_litoral 0:ea1b1135bb4e 1020 cls();
apm_litoral 0:ea1b1135bb4e 1021 locate(x,y);//0,0
apm_litoral 0:ea1b1135bb4e 1022 int i=0, j=0, k=0, l=0;
apm_litoral 0:ea1b1135bb4e 1023 //RTOS_APM/Config/bin.bio
apm_litoral 0:ea1b1135bb4e 1024 const char build[24] = {
apm_litoral 0:ea1b1135bb4e 1025 0x52,0x54,0x4F,0x53,0x5F,0x41,0x50,0x4D,
apm_litoral 0:ea1b1135bb4e 1026 0x2F,0x43,0x6F,0x6E,0x66,0x69,0x67,0x2F,
apm_litoral 0:ea1b1135bb4e 1027 0x62,0x69,0x6E,0x2E,0x62,0x69,0x6F,0x00
apm_litoral 0:ea1b1135bb4e 1028 };
apm_litoral 0:ea1b1135bb4e 1029
apm_litoral 0:ea1b1135bb4e 1030 BMP_SD(0,0,(const char *)&build[0]);//bee
apm_litoral 0:ea1b1135bb4e 1031 backlight(1); //0.0001
apm_litoral 0:ea1b1135bb4e 1032
apm_litoral 0:ea1b1135bb4e 1033 const char stramp[15] = {//
apm_litoral 0:ea1b1135bb4e 1034 0x2F,0x73,0x64,0x2F,0x42,0x49,0x4F,0x5F,
apm_litoral 0:ea1b1135bb4e 1035 0x4F,0x53,0x2E,0x44,0x41,0x54,0x00
apm_litoral 0:ea1b1135bb4e 1036 };
apm_litoral 0:ea1b1135bb4e 1037
apm_litoral 0:ea1b1135bb4e 1038
apm_litoral 0:ea1b1135bb4e 1039 const unsigned short page[229] = {
apm_litoral 0:ea1b1135bb4e 1040 0x3C,0x21,0x2D,0x2D,0x20,0x41,0x6C,0x6C,0x20,0x50,0x6F,0x77,0x65,0x72,0x20,0x4D,
apm_litoral 0:ea1b1135bb4e 1041 0x69,0x63,0x72,0x6F,0x63,0x6F,0x6E,0x74,0x72,0x6F,0x6C,0x6C,0x65,0x72,0x20,0x57,
apm_litoral 0:ea1b1135bb4e 1042 0x65,0x62,0x73,0x69,0x74,0x65,0x20,0x61,0x6E,0x64,0x20,0x41,0x75,0x74,0x68,0x65,
apm_litoral 0:ea1b1135bb4e 1043 0x6E,0x74,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x53,0x68,0x6F,0x72,0x74,0x63,
apm_litoral 0:ea1b1135bb4e 1044 0x75,0x74,0x20,0x2D,0x2D,0x3E,0x0D,0x0A,0x3C,0x68,0x74,0x6D,0x6C,0x3E,0x0D,0x0A,
apm_litoral 0:ea1b1135bb4e 1045 0x3C,0x68,0x65,0x61,0x64,0x3E,0x0D,0x0A,0x3C,0x6D,0x65,0x74,0x61,0x20,0x68,0x74,
apm_litoral 0:ea1b1135bb4e 1046 0x74,0x70,0x2D,0x65,0x71,0x75,0x69,0x76,0x3D,0x22,0x72,0x65,0x66,0x72,0x65,0x73,
apm_litoral 0:ea1b1135bb4e 1047 0x68,0x22,0x20,0x63,0x6F,0x6E,0x74,0x65,0x6E,0x74,0x3D,0x22,0x30,0x3B,0x20,0x75,
apm_litoral 0:ea1b1135bb4e 1048 0x72,0x6C,0x3D,0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x77,0x77,0x77,0x2E,0x61,0x70,
apm_litoral 0:ea1b1135bb4e 1049 0x6D,0x6D,0x69,0x63,0x72,0x6F,0x2E,0x63,0x6F,0x6D,0x22,0x2F,0x3E,0x0D,0x0A,0x3C,
apm_litoral 0:ea1b1135bb4e 1050 0x74,0x69,0x74,0x6C,0x65,0x3E,0x41,0x50,0x4D,0x20,0x57,0x65,0x62,0x73,0x69,0x74,
apm_litoral 0:ea1b1135bb4e 1051 0x65,0x20,0x53,0x68,0x6F,0x72,0x74,0x63,0x75,0x74,0x3C,0x2F,0x74,0x69,0x74,0x6C,
apm_litoral 0:ea1b1135bb4e 1052 0x65,0x3E,0x0D,0x0A,0x3C,0x2F,0x68,0x65,0x61,0x64,0x3E,0x0D,0x0A,0x3C,0x62,0x6F,
apm_litoral 0:ea1b1135bb4e 1053 0x64,0x79,0x3E,0x3C,0x2F,0x62,0x6F,0x64,0x79,0x3E,0x0D,0x0A,0x3C,0x2F,0x68,0x74,
apm_litoral 0:ea1b1135bb4e 1054 0x6D,0x6C,0x3E,0x0D,0x0A
apm_litoral 0:ea1b1135bb4e 1055
apm_litoral 0:ea1b1135bb4e 1056 };
apm_litoral 0:ea1b1135bb4e 1057
apm_litoral 0:ea1b1135bb4e 1058 const char page_this_sd[12] = {
apm_litoral 0:ea1b1135bb4e 1059 0x2F,0x73,0x64,0x2F,0x41,0x50,0x4D,0x2E,0x48,0x54,0x4D,0x00//w->s
apm_litoral 0:ea1b1135bb4e 1060 };
apm_litoral 0:ea1b1135bb4e 1061
apm_litoral 0:ea1b1135bb4e 1062 const char page_this_lc[12] = {
apm_litoral 0:ea1b1135bb4e 1063 0x2F,0x75,0x63,0x2F,0x41,0x50,0x4D,0x2E,0x48,0x54,0x4D,0x00//w->l
apm_litoral 0:ea1b1135bb4e 1064 };
apm_litoral 0:ea1b1135bb4e 1065
apm_litoral 0:ea1b1135bb4e 1066 FILE *binary = fopen((const char *)&page_this_sd[0], "w");
apm_litoral 0:ea1b1135bb4e 1067 while (i<=229) {
apm_litoral 0:ea1b1135bb4e 1068 fprintf(binary,(const char *)&page[i]);
apm_litoral 0:ea1b1135bb4e 1069 i++;
apm_litoral 0:ea1b1135bb4e 1070 }
apm_litoral 0:ea1b1135bb4e 1071 fclose(binary);
apm_litoral 0:ea1b1135bb4e 1072
apm_litoral 0:ea1b1135bb4e 1073 FILE *hex = fopen((const char *)&page_this_lc[0], "w");
apm_litoral 0:ea1b1135bb4e 1074 while (j<=229) {
apm_litoral 0:ea1b1135bb4e 1075 fprintf(hex,(const char *)&page[j]);
apm_litoral 0:ea1b1135bb4e 1076 j++;
apm_litoral 0:ea1b1135bb4e 1077 }
apm_litoral 0:ea1b1135bb4e 1078 fclose(hex);
apm_litoral 0:ea1b1135bb4e 1079 /* --------------------------------------------------------------------------------- */
apm_litoral 0:ea1b1135bb4e 1080
apm_litoral 0:ea1b1135bb4e 1081 const char dat_this_sd[15] = {
apm_litoral 0:ea1b1135bb4e 1082 0x2F,0x73,0x64,0x2F,0x42,0x69,0x6F,0x5F,
apm_litoral 0:ea1b1135bb4e 1083 0x4F,0x73,0x2E,0x44,0x41,0x54,0x00//d->s
apm_litoral 0:ea1b1135bb4e 1084 };
apm_litoral 0:ea1b1135bb4e 1085
apm_litoral 0:ea1b1135bb4e 1086 const char dat_this_lc[15] = {
apm_litoral 0:ea1b1135bb4e 1087 0x2F,0x75,0x63,0x2F,0x42,0x69,0x6F,0x5F,
apm_litoral 0:ea1b1135bb4e 1088 0x4F,0x73,0x2E,0x44,0x41,0x54,0x00//d->l
apm_litoral 0:ea1b1135bb4e 1089 };
apm_litoral 0:ea1b1135bb4e 1090
apm_litoral 0:ea1b1135bb4e 1091 const unsigned short data_Os[976] = {
apm_litoral 0:ea1b1135bb4e 1092 0x42,0x6F,0x6F,0x74,0x6C,0x6F,0x61,0x64,0x65,0x72,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,
apm_litoral 0:ea1b1135bb4e 1093 0x0D,0x0A,0x41,0x52,0x4D,0x20,0x43,0x6F,0x72,0x74,0x65,0x78,0x20,0x4D,0x33,0x20,
apm_litoral 0:ea1b1135bb4e 1094 0x43,0x50,0x55,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x47,0x72,0x61,0x70,0x68,
apm_litoral 0:ea1b1135bb4e 1095 0x69,0x63,0x20,0x50,0x72,0x6F,0x63,0x65,0x73,0x73,0x69,0x6E,0x67,0x20,0x55,0x6E,
apm_litoral 0:ea1b1135bb4e 1096 0x69,0x74,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x4C,0x69,0x62,0x72,0x65,0x72,
apm_litoral 0:ea1b1135bb4e 1097 0x69,0x65,0x73,0x20,0x46,0x61,0x74,0x20,0x46,0x2E,0x20,0x53,0x79,0x73,0x74,0x65,
apm_litoral 0:ea1b1135bb4e 1098 0x6D,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x50,0x44,0x53,0x2E,0x20,0x53,0x65,
apm_litoral 0:ea1b1135bb4e 1099 0x63,0x75,0x72,0x69,0x74,0x79,0x20,0x41,0x72,0x65,0x61,0x2E,0x2E,0x2E,0x20,0x4F,
apm_litoral 0:ea1b1135bb4e 1100 0x4B,0x0D,0x0A,0x52,0x53,0x41,0x2E,0x20,0x50,0x72,0x6F,0x74,0x65,0x63,0x74,0x69,
apm_litoral 0:ea1b1135bb4e 1101 0x6F,0x6E,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x48,0x6F,0x73,0x74,0x20,0x55,
apm_litoral 0:ea1b1135bb4e 1102 0x53,0x42,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x44,0x65,0x76,0x69,0x63,0x65,
apm_litoral 0:ea1b1135bb4e 1103 0x20,0x55,0x53,0x42,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x53,0x44,0x20,0x43,
apm_litoral 0:ea1b1135bb4e 1104 0x61,0x72,0x64,0x2E,0x2E,0x2E,0x20,0x4F,0x4B,0x0D,0x0A,0x53,0x61,0x76,0x65,0x3A,
apm_litoral 0:ea1b1135bb4e 1105 0x20,0x62,0x69,0x6F,0x73,0x2E,0x44,0x41,0x54,0x0D,0x0A,0x0D,0x0A,0x2A,0x2F,0x2F,
apm_litoral 0:ea1b1135bb4e 1106 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
apm_litoral 0:ea1b1135bb4e 1107 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
apm_litoral 0:ea1b1135bb4e 1108 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
apm_litoral 0:ea1b1135bb4e 1109 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
apm_litoral 0:ea1b1135bb4e 1110 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x0D,0x0A,0x41,0x6C,0x6C,0x20,0x50,
apm_litoral 0:ea1b1135bb4e 1111 0x6F,0x77,0x65,0x72,0x20,0x4D,0x69,0x63,0x72,0x6F,0x63,0x6F,0x6E,0x74,0x72,0x6F,
apm_litoral 0:ea1b1135bb4e 1112 0x6C,0x6C,0x65,0x72,0x2C,0x20,0x4F,0x70,0x65,0x72,0x61,0x74,0x69,0x76,0x65,0x20,
apm_litoral 0:ea1b1135bb4e 1113 0x53,0x79,0x73,0x74,0x65,0x6D,0x20,0x42,0x69,0x6F,0x5F,0x4F,0x73,0x0D,0x0A,0x0D,
apm_litoral 0:ea1b1135bb4e 1114 0x0A,0x46,0x61,0x74,0x20,0x46,0x69,0x6C,0x65,0x20,0x53,0x79,0x73,0x74,0x65,0x6D,
apm_litoral 0:ea1b1135bb4e 1115 0x20,0x4C,0x69,0x62,0x72,0x61,0x72,0x79,0x20,0x42,0x61,0x73,0x65,0x20,0x43,0x6C,
apm_litoral 0:ea1b1135bb4e 1116 0x61,0x73,0x73,0x20,0x61,0x6E,0x64,0x20,0x47,0x72,0x61,0x70,0x68,0x69,0x63,0x20,
apm_litoral 0:ea1b1135bb4e 1117 0x49,0x6E,0x74,0x65,0x72,0x66,0x61,0x63,0x65,0x20,0x69,0x73,0x20,0x70,0x72,0x6F,
apm_litoral 0:ea1b1135bb4e 1118 0x74,0x65,0x63,0x74,0x65,0x64,0x20,0x77,0x68,0x69,0x74,0x68,0x0D,0x0A,0x43,0x6F,
apm_litoral 0:ea1b1135bb4e 1119 0x70,0x79,0x72,0x69,0x67,0x68,0x74,0x20,0x28,0x63,0x29,0x20,0x32,0x30,0x30,0x31,
apm_litoral 0:ea1b1135bb4e 1120 0x31,0x2D,0x32,0x30,0x31,0x32,0x20,0x45,0x63,0x75,0x61,0x64,0x6F,0x72,0x0D,0x0A,
apm_litoral 0:ea1b1135bb4e 1121 0x52,0x65,0x6C,0x65,0x61,0x73,0x65,0x64,0x20,0x75,0x6E,0x64,0x65,0x72,0x20,0x4C,
apm_litoral 0:ea1b1135bb4e 1122 0x69,0x63,0x65,0x6E,0x73,0x65,0x20,0x6F,0x66,0x20,0x69,0x6E,0x74,0x65,0x6C,0x65,
apm_litoral 0:ea1b1135bb4e 1123 0x63,0x74,0x75,0x61,0x6C,0x20,0x70,0x72,0x6F,0x70,0x69,0x65,0x74,0x79,0x20,0x6F,
apm_litoral 0:ea1b1135bb4e 1124 0x66,0x20,0x41,0x6E,0x67,0x65,0x6C,0x20,0x44,0x2E,0x20,0x59,0x61,0x67,0x75,0x61,
apm_litoral 0:ea1b1135bb4e 1125 0x6E,0x61,0x0D,0x0A,0x0D,0x0A,0x45,0x6C,0x20,0x70,0x72,0x65,0x73,0x65,0x6E,0x74,
apm_litoral 0:ea1b1135bb4e 1126 0x65,0x20,0x70,0x72,0x6F,0x79,0x65,0x63,0x74,0x6F,0x20,0x65,0x73,0x20,0x72,0x65,
apm_litoral 0:ea1b1135bb4e 1127 0x61,0x6C,0x69,0x7A,0x61,0x64,0x6F,0x20,0x62,0x61,0x6A,0x6F,0x20,0x61,0x63,0x75,
apm_litoral 0:ea1b1135bb4e 1128 0x65,0x72,0x64,0x6F,0x20,0x64,0x65,0x20,0x6C,0x69,0x63,0x65,0x6E,0x63,0x69,0x61,
apm_litoral 0:ea1b1135bb4e 1129 0x20,0x6F,0x74,0x6F,0x72,0x67,0x61,0x64,0x6F,0x20,0x70,0x6F,0x72,0x20,0x65,0x6C,
apm_litoral 0:ea1b1135bb4e 1130 0x20,0x0D,0x0A,0x41,0x75,0x74,0x6F,0x72,0x20,0x63,0x6F,0x6E,0x20,0x74,0x65,0x72,
apm_litoral 0:ea1b1135bb4e 1131 0x6D,0x69,0x6E,0x6F,0x73,0x20,0x65,0x73,0x70,0x65,0x63,0x69,0x66,0x69,0x63,0x61,
apm_litoral 0:ea1b1135bb4e 1132 0x64,0x6F,0x73,0x20,0x70,0x6F,0x72,0x20,0x6C,0x61,0x20,0x6C,0x69,0x63,0x65,0x6E,
apm_litoral 0:ea1b1135bb4e 1133 0x63,0x69,0x61,0x20,0x47,0x4E,0x55,0x20,0x47,0x50,0x4C,0x20,0x6C,0x61,0x20,0x63,
apm_litoral 0:ea1b1135bb4e 1134 0x75,0x61,0x6C,0x20,0x6C,0x65,0x20,0x70,0x65,0x72,0x6D,0x69,0x74,0x65,0x20,0x0D,
apm_litoral 0:ea1b1135bb4e 1135 0x0A,0x75,0x73,0x61,0x72,0x20,0x6C,0x61,0x73,0x20,0x6C,0x69,0x62,0x72,0x65,0x72,
apm_litoral 0:ea1b1135bb4e 1136 0x69,0x61,0x73,0x20,0x70,0x65,0x72,0x6F,0x20,0x70,0x72,0x6F,0x68,0x69,0x62,0x65,
apm_litoral 0:ea1b1135bb4e 1137 0x20,0x73,0x75,0x20,0x76,0x65,0x6E,0x74,0x61,0x20,0x6F,0x20,0x63,0x6F,0x6D,0x65,
apm_litoral 0:ea1b1135bb4e 1138 0x72,0x63,0x69,0x61,0x6C,0x69,0x7A,0x61,0x63,0x69,0x6F,0x6E,0x20,0x63,0x6F,0x6E,
apm_litoral 0:ea1b1135bb4e 1139 0x20,0x66,0x69,0x6E,0x65,0x73,0x20,0x64,0x65,0x20,0x6C,0x75,0x63,0x72,0x6F,0x20,
apm_litoral 0:ea1b1135bb4e 1140 0x0D,0x0A,0x73,0x69,0x6E,0x20,0x70,0x72,0x65,0x76,0x69,0x61,0x20,0x72,0x65,0x74,
apm_litoral 0:ea1b1135bb4e 1141 0x72,0x69,0x62,0x75,0x63,0x69,0x6F,0x6E,0x20,0x70,0x6F,0x72,0x20,0x64,0x65,0x72,
apm_litoral 0:ea1b1135bb4e 1142 0x65,0x63,0x68,0x6F,0x73,0x20,0x64,0x65,0x20,0x70,0x72,0x6F,0x70,0x69,0x65,0x64,
apm_litoral 0:ea1b1135bb4e 1143 0x61,0x64,0x20,0x69,0x6E,0x74,0x65,0x6C,0x65,0x63,0x74,0x75,0x61,0x6C,0x20,0x64,
apm_litoral 0:ea1b1135bb4e 1144 0x65,0x20,0x42,0x69,0x6F,0x5F,0x4F,0x73,0x0D,0x0A,0x2A,0x2F,0x2F,0x2F,0x2F,0x2F,
apm_litoral 0:ea1b1135bb4e 1145 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
apm_litoral 0:ea1b1135bb4e 1146 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
apm_litoral 0:ea1b1135bb4e 1147 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
apm_litoral 0:ea1b1135bb4e 1148 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,
apm_litoral 0:ea1b1135bb4e 1149 0x2F,0x2F,0x2F,0x2F,0x2F,0x2F,0x0D,0x0A,0x0D,0x0A,0x0D,0x0A,0x0D,0x0A,0x2F,0x2F,
apm_litoral 0:ea1b1135bb4e 1150 0x42,0x69,0x6F,0x5F,0x4F,0x73,0x20,0x77,0x61,0x73,0x20,0x64,0x65,0x76,0x65,0x6C,
apm_litoral 0:ea1b1135bb4e 1151 0x6F,0x70,0x6D,0x65,0x6E,0x74,0x20,0x62,0x79,0x20,0x53,0x68,0x65,0x72,0x63,0x6B,
apm_litoral 0:ea1b1135bb4e 1152 0x75,0x69,0x74,0x68,0x20,0x69,0x6E,0x20,0x32,0x30,0x31,0x32,0x2F,0x3C,0x00,0x00
apm_litoral 0:ea1b1135bb4e 1153 };
apm_litoral 0:ea1b1135bb4e 1154
apm_litoral 0:ea1b1135bb4e 1155 FILE *octal = fopen((const char *)&dat_this_sd[0], "w");
apm_litoral 0:ea1b1135bb4e 1156 while (k<=976) {
apm_litoral 0:ea1b1135bb4e 1157 fprintf(octal,(const char *)&data_Os[k]);
apm_litoral 0:ea1b1135bb4e 1158 k++;
apm_litoral 0:ea1b1135bb4e 1159 }
apm_litoral 0:ea1b1135bb4e 1160 fclose(octal);
apm_litoral 0:ea1b1135bb4e 1161
apm_litoral 0:ea1b1135bb4e 1162 FILE *dec = fopen((const char *)&dat_this_lc[0], "w");
apm_litoral 0:ea1b1135bb4e 1163 while (l<=976) {
apm_litoral 0:ea1b1135bb4e 1164 fprintf(dec,(const char *)&data_Os[l]);
apm_litoral 0:ea1b1135bb4e 1165 l++;
apm_litoral 0:ea1b1135bb4e 1166 }
apm_litoral 0:ea1b1135bb4e 1167 fclose(dec);
apm_litoral 0:ea1b1135bb4e 1168
apm_litoral 0:ea1b1135bb4e 1169 locate(0,122);
apm_litoral 0:ea1b1135bb4e 1170 printf(" Charging R.T.O.S.");
apm_litoral 0:ea1b1135bb4e 1171 wait(2);
apm_litoral 0:ea1b1135bb4e 1172 int a=0, b=134, d;
apm_litoral 0:ea1b1135bb4e 1173 locate(a,b);
apm_litoral 0:ea1b1135bb4e 1174 FILE *fp = fopen((const char *)&stramp[0], "r");
apm_litoral 0:ea1b1135bb4e 1175
apm_litoral 0:ea1b1135bb4e 1176 if (fp) {
apm_litoral 0:ea1b1135bb4e 1177 char c = 0;
apm_litoral 0:ea1b1135bb4e 1178 printf("\n ");
apm_litoral 0:ea1b1135bb4e 1179 for (;;) {
apm_litoral 0:ea1b1135bb4e 1180 c = fgetc(fp);
apm_litoral 0:ea1b1135bb4e 1181 if (feof(fp)) break;
apm_litoral 0:ea1b1135bb4e 1182 if (c == 0x2A) {
apm_litoral 0:ea1b1135bb4e 1183 d = fgetc(fp);
apm_litoral 0:ea1b1135bb4e 1184 if (d == 0x2F) break;
apm_litoral 0:ea1b1135bb4e 1185 }
apm_litoral 0:ea1b1135bb4e 1186 if (c == 0x0D) {
apm_litoral 0:ea1b1135bb4e 1187 wait(0.5);
apm_litoral 0:ea1b1135bb4e 1188 d = fgetc(fp);
apm_litoral 0:ea1b1135bb4e 1189 if (d == 0x0A) {
apm_litoral 0:ea1b1135bb4e 1190 d = fgetc(fp);
apm_litoral 0:ea1b1135bb4e 1191 printf("\n ");
apm_litoral 0:ea1b1135bb4e 1192 printf("%c", d);
apm_litoral 0:ea1b1135bb4e 1193 }
apm_litoral 0:ea1b1135bb4e 1194 } else printf("%c", c);
apm_litoral 0:ea1b1135bb4e 1195 }
apm_litoral 0:ea1b1135bb4e 1196 } else {
apm_litoral 0:ea1b1135bb4e 1197 error("Cant Init System Information");
apm_litoral 0:ea1b1135bb4e 1198 return;
apm_litoral 0:ea1b1135bb4e 1199 }
apm_litoral 0:ea1b1135bb4e 1200 fclose(fp);
apm_litoral 0:ea1b1135bb4e 1201
apm_litoral 0:ea1b1135bb4e 1202 }
apm_litoral 0:ea1b1135bb4e 1203
apm_litoral 0:ea1b1135bb4e 1204
apm_litoral 0:ea1b1135bb4e 1205 void SPI_TFT::Loading(float bkt,int fondo, int color, unsigned char* letra,const char *titulo1,int x,int y,int fondo2, int color2,unsigned char* sam, const char *titulo2, int z,int w, int delay,int a,int b, int c, int d, int max, int min, float alfa_cromatic) {
apm_litoral 0:ea1b1135bb4e 1206
apm_litoral 0:ea1b1135bb4e 1207 background(fondo); //Black
apm_litoral 0:ea1b1135bb4e 1208 foreground(color); //Red
apm_litoral 0:ea1b1135bb4e 1209 cls();
apm_litoral 0:ea1b1135bb4e 1210 font = letra; // Neu42x35 select font 2
apm_litoral 0:ea1b1135bb4e 1211 locate(x,y); //6,72
apm_litoral 0:ea1b1135bb4e 1212 printf((const char *)titulo1);
apm_litoral 0:ea1b1135bb4e 1213 contraste_pos(0.0,bkt,0.01,0.01);
apm_litoral 0:ea1b1135bb4e 1214 wait(delay/2);
apm_litoral 0:ea1b1135bb4e 1215
apm_litoral 0:ea1b1135bb4e 1216 background(fondo2); //Black
apm_litoral 0:ea1b1135bb4e 1217 foreground(color2); //Red
apm_litoral 0:ea1b1135bb4e 1218 locate(z,w); //120,132
apm_litoral 0:ea1b1135bb4e 1219 font = sam; // Arial12x12 select font 2
apm_litoral 0:ea1b1135bb4e 1220 printf((const char *)titulo2);
apm_litoral 0:ea1b1135bb4e 1221 wait(delay/2);
apm_litoral 0:ea1b1135bb4e 1222
apm_litoral 0:ea1b1135bb4e 1223 rect(a,b,c,d,White); //18,148,302,158,w
apm_litoral 0:ea1b1135bb4e 1224 rect(a+1,b+1,c-1,d-1,LightGrey); //19,149,301,l57g
apm_litoral 0:ea1b1135bb4e 1225 rect(a+2,b+2,c-2,d-2,DarkGrey); //20,150,300,156,dg
apm_litoral 0:ea1b1135bb4e 1226 fillrect(a+3,b+3,c-3,d-3,White); //21,151,298,155,w
apm_litoral 0:ea1b1135bb4e 1227 charge(a+3,b+3,c-3,d-3,max,min,alfa_cromatic); //21,151,298,155,0xffff,0xf800,0.1 20,200,185,195
apm_litoral 0:ea1b1135bb4e 1228 wait(delay);
apm_litoral 0:ea1b1135bb4e 1229 }
apm_litoral 0:ea1b1135bb4e 1230
apm_litoral 0:ea1b1135bb4e 1231 void SPI_TFT::sharepoint(unsigned int top, unsigned int button, unsigned int height, unsigned int pointer, unsigned int speed, unsigned repetitions) {
apm_litoral 0:ea1b1135bb4e 1232 wr_reg(0x0F, (top >> 0));
apm_litoral 0:ea1b1135bb4e 1233 wr_reg(0x0E, (top >> 8));
apm_litoral 0:ea1b1135bb4e 1234 wr_reg(0x13, (button >> 0));
apm_litoral 0:ea1b1135bb4e 1235 wr_reg(0x12, (button >> 8));
apm_litoral 0:ea1b1135bb4e 1236 wr_reg(0x11, (height-1 >> 0));
apm_litoral 0:ea1b1135bb4e 1237 wr_reg(0x10, (height-1 >> 8));
apm_litoral 0:ea1b1135bb4e 1238
apm_litoral 0:ea1b1135bb4e 1239 for (int v=0; v <= repetitions; v++) {
apm_litoral 0:ea1b1135bb4e 1240 if (top + button + height == 320) {
apm_litoral 0:ea1b1135bb4e 1241 for (int j=0; j < pointer-1; j++) {
apm_litoral 0:ea1b1135bb4e 1242 wr_reg(0x15, (j >> 0));
apm_litoral 0:ea1b1135bb4e 1243 wr_reg(0x14, (j >> 8));
apm_litoral 0:ea1b1135bb4e 1244 wait_us(speed);
apm_litoral 0:ea1b1135bb4e 1245 }
apm_litoral 0:ea1b1135bb4e 1246 } else //if(top + button + height != 320) {
apm_litoral 0:ea1b1135bb4e 1247 error("desplazamiento invalido\n");
apm_litoral 0:ea1b1135bb4e 1248 }
apm_litoral 0:ea1b1135bb4e 1249 }
apm_litoral 0:ea1b1135bb4e 1250
apm_litoral 0:ea1b1135bb4e 1251 void SPI_TFT::icon_ball(int x, int y, int state) {
apm_litoral 0:ea1b1135bb4e 1252 int a=0,b=0,c=0,d=0;
apm_litoral 0:ea1b1135bb4e 1253 a=x-2;
apm_litoral 0:ea1b1135bb4e 1254 b=y-4;
apm_litoral 0:ea1b1135bb4e 1255 c=x+2;
apm_litoral 0:ea1b1135bb4e 1256 d=y+4;
apm_litoral 0:ea1b1135bb4e 1257 if (state==1) {
apm_litoral 0:ea1b1135bb4e 1258 fillrect(a,b,c,d,Navy);
apm_litoral 0:ea1b1135bb4e 1259 fillrect(a-1,b+1,c+1,d-1,Navy);
apm_litoral 0:ea1b1135bb4e 1260 fillrect(a-2,b+2,c+2,d-2,Navy);
apm_litoral 0:ea1b1135bb4e 1261 fillrect(a,b+1,c,d-1,Blue);
apm_litoral 0:ea1b1135bb4e 1262 fillrect(a-1,b+2,c+1,d-2,Blue);
apm_litoral 0:ea1b1135bb4e 1263 fillrect(a+1,b+2,c-1,d-2,Cyan);
apm_litoral 0:ea1b1135bb4e 1264 fillrect(a,b+3,c,d-3,Cyan);
apm_litoral 0:ea1b1135bb4e 1265 }
apm_litoral 0:ea1b1135bb4e 1266 if (state==0) {
apm_litoral 0:ea1b1135bb4e 1267 fillrect(a,b,c,d,White);
apm_litoral 0:ea1b1135bb4e 1268 fillrect(a-1,b+1,c+1,d-1,White);
apm_litoral 0:ea1b1135bb4e 1269 fillrect(a-2,b+2,c+2,d-2,White);
apm_litoral 0:ea1b1135bb4e 1270 fillrect(a,b+1,c,d-1,White);
apm_litoral 0:ea1b1135bb4e 1271 fillrect(a-1,b+2,c+1,d-2,White);
apm_litoral 0:ea1b1135bb4e 1272 fillrect(a+1,b+2,c-1,d-2,White);
apm_litoral 0:ea1b1135bb4e 1273 fillrect(a,b+3,c,d-3,White);
apm_litoral 0:ea1b1135bb4e 1274 }
apm_litoral 0:ea1b1135bb4e 1275 }