for CountupNumber_sample3
MIP8F_SPI_Ver7.0
Ver7.0 Addtional function is SpeedMeter Sample for 4.4" MIP8F Display (Japan Display Inc)
MIP8F_SPI.cpp@6:4bfbc7e50577, 2018-11-21 (annotated)
- Committer:
- JDI_Mbed_Team
- Date:
- Wed Nov 21 07:28:10 2018 +0000
- Revision:
- 6:4bfbc7e50577
- Parent:
- 5:8cc8e00fed46
MIP8F_SPI_Ver60
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JDI_Mbed_Team | 0:b2d46804658c | 1 | /** |
JDI_Mbed_Team | 0:b2d46804658c | 2 | * @file MIP8F_SPI.cpp |
JDI_Mbed_Team | 5:8cc8e00fed46 | 3 | * @brief ver5.0 Library source code file: Class for JDI MIP8 display |
JDI_Mbed_Team | 0:b2d46804658c | 4 | * @details |
JDI_Mbed_Team | 5:8cc8e00fed46 | 5 | * Ver5.0 Addtional function is checking the refresh display speed between 4bit,3bit and 1bit transfer mode |
JDI_Mbed_Team | 3:c67b96404016 | 6 | * Ver4.0 Addtional function is Line buffer version |
JDI_Mbed_Team | 3:c67b96404016 | 7 | * Ver3.0 Addtional function is font display |
JDI_Mbed_Team | 3:c67b96404016 | 8 | * ver2.0 Addtional function is Monochome display by 1bit mode of SPI transfer. |
JDI_Mbed_Team | 3:c67b96404016 | 9 | * |
JDI_Mbed_Team | 5:8cc8e00fed46 | 10 | * spi-transfer to Display has 3 mode. |
JDI_Mbed_Team | 5:8cc8e00fed46 | 11 | * 4bit mode is color display, this bit arrange is R,G,B,x. R,G,B = R,G,B subpixel bit. x bit is Dummy. |
JDI_Mbed_Team | 5:8cc8e00fed46 | 12 | * 3bit mode is color display, this bit arrange is R,G,B. R,G,B = R,G,B subpixel bit. No bit is Dummy. |
JDI_Mbed_Team | 5:8cc8e00fed46 | 13 | * 1bit mode is monocrome display,high speed refresh mode. a only Green subpixel of bitmap data is transfered. |
JDI_Mbed_Team | 5:8cc8e00fed46 | 14 | * |
JDI_Mbed_Team | 3:c67b96404016 | 15 | * <license> |
JDI_Mbed_Team | 0:b2d46804658c | 16 | * Copyright 2018 Japan Display Inc. |
JDI_Mbed_Team | 0:b2d46804658c | 17 | * Licensed under the Apache License, Version 2.0 (the "License"); |
JDI_Mbed_Team | 0:b2d46804658c | 18 | * you may not use this file except in compliance with the License. |
JDI_Mbed_Team | 0:b2d46804658c | 19 | * You may obtain a copy of the License at |
JDI_Mbed_Team | 0:b2d46804658c | 20 | * http://www.apache.org/licenses/LICENSE-2.0 |
JDI_Mbed_Team | 0:b2d46804658c | 21 | * Unless required by applicable law or agreed to in writing, software |
JDI_Mbed_Team | 0:b2d46804658c | 22 | * distributed under the License is distributed on an "AS IS" BASIS, |
JDI_Mbed_Team | 0:b2d46804658c | 23 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
JDI_Mbed_Team | 0:b2d46804658c | 24 | * See the License for the specific language governing permissions and |
JDI_Mbed_Team | 0:b2d46804658c | 25 | * limitations under the License. |
JDI_Mbed_Team | 0:b2d46804658c | 26 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 27 | |
JDI_Mbed_Team | 0:b2d46804658c | 28 | #include "mbed.h" |
JDI_Mbed_Team | 0:b2d46804658c | 29 | #include "MIP8F_SPI.h" |
JDI_Mbed_Team | 0:b2d46804658c | 30 | |
JDI_Mbed_Team | 0:b2d46804658c | 31 | // for debug |
JDI_Mbed_Team | 6:4bfbc7e50577 | 32 | Serial pc2(USBTX, USBRX); // tx, rx |
JDI_Mbed_Team | 0:b2d46804658c | 33 | |
JDI_Mbed_Team | 0:b2d46804658c | 34 | memLCD8::memLCD8(PinName mosi,PinName miso,PinName sclk,PinName cs,PinName disp,PinName power) |
JDI_Mbed_Team | 0:b2d46804658c | 35 | : _spi(mosi, miso, sclk),_cs(cs),_disp(disp),_power(power) |
JDI_Mbed_Team | 0:b2d46804658c | 36 | { |
JDI_Mbed_Team | 0:b2d46804658c | 37 | |
JDI_Mbed_Team | 0:b2d46804658c | 38 | _power= 0; |
JDI_Mbed_Team | 0:b2d46804658c | 39 | _disp= 0; |
JDI_Mbed_Team | 0:b2d46804658c | 40 | _cs = 0; |
JDI_Mbed_Team | 0:b2d46804658c | 41 | wait_us(100); |
JDI_Mbed_Team | 0:b2d46804658c | 42 | |
JDI_Mbed_Team | 0:b2d46804658c | 43 | _power= 1; |
JDI_Mbed_Team | 0:b2d46804658c | 44 | _spi.format(8,0); // 8bit mode3 |
JDI_Mbed_Team | 0:b2d46804658c | 45 | _spi.frequency(2000000); // 2 Mhz SPI clock |
JDI_Mbed_Team | 0:b2d46804658c | 46 | _spi.write(0x00); // mbed dummy |
JDI_Mbed_Team | 0:b2d46804658c | 47 | |
JDI_Mbed_Team | 0:b2d46804658c | 48 | /* |
JDI_Mbed_Team | 0:b2d46804658c | 49 | _cs = 1; |
JDI_Mbed_Team | 0:b2d46804658c | 50 | command(0x02); // All crear mode |
JDI_Mbed_Team | 0:b2d46804658c | 51 | _cs = 0; |
JDI_Mbed_Team | 0:b2d46804658c | 52 | */ |
JDI_Mbed_Team | 2:944f2968c19f | 53 | _FixedFontWidth=0;//setting:actual font width display if _FixedFontWidth !=1: font fixed witdh |
JDI_Mbed_Team | 6:4bfbc7e50577 | 54 | #if MOVIEBUFF_MODE |
JDI_Mbed_Team | 6:4bfbc7e50577 | 55 | //movie_height = 80; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 56 | //movie_width = 80; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 57 | _height = 240; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 58 | _width = 400; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 59 | #endif |
JDI_Mbed_Team | 0:b2d46804658c | 60 | } |
JDI_Mbed_Team | 0:b2d46804658c | 61 | |
JDI_Mbed_Team | 0:b2d46804658c | 62 | /** |
JDI_Mbed_Team | 0:b2d46804658c | 63 | * @brief set font name |
JDI_Mbed_Team | 0:b2d46804658c | 64 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 65 | void memLCD8::set_font(unsigned char* f) |
JDI_Mbed_Team | 0:b2d46804658c | 66 | { |
JDI_Mbed_Team | 0:b2d46804658c | 67 | font = f; |
JDI_Mbed_Team | 0:b2d46804658c | 68 | } |
JDI_Mbed_Team | 0:b2d46804658c | 69 | |
JDI_Mbed_Team | 0:b2d46804658c | 70 | /** |
JDI_Mbed_Team | 2:944f2968c19f | 71 | * @brief set allocation for font display |
JDI_Mbed_Team | 0:b2d46804658c | 72 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 73 | void memLCD8::locate(int x, int y) |
JDI_Mbed_Team | 0:b2d46804658c | 74 | { |
JDI_Mbed_Team | 0:b2d46804658c | 75 | char_x = x; |
JDI_Mbed_Team | 0:b2d46804658c | 76 | char_y = y; |
JDI_Mbed_Team | 0:b2d46804658c | 77 | } |
JDI_Mbed_Team | 2:944f2968c19f | 78 | |
JDI_Mbed_Team | 0:b2d46804658c | 79 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 80 | * @brief setting fixed width between charactor and charctor for font display |
JDI_Mbed_Team | 2:944f2968c19f | 81 | */ |
JDI_Mbed_Team | 2:944f2968c19f | 82 | void memLCD8::set_FixedFontWidth( unsigned char width ) |
JDI_Mbed_Team | 2:944f2968c19f | 83 | { |
JDI_Mbed_Team | 2:944f2968c19f | 84 | _FixedFontWidth = width; |
JDI_Mbed_Team | 2:944f2968c19f | 85 | } |
JDI_Mbed_Team | 3:c67b96404016 | 86 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 87 | * @brief setting Actual width between charactor and charctor for font display |
JDI_Mbed_Team | 3:c67b96404016 | 88 | */ |
JDI_Mbed_Team | 2:944f2968c19f | 89 | void memLCD8::set_ActualFontWidth(void) |
JDI_Mbed_Team | 2:944f2968c19f | 90 | { |
JDI_Mbed_Team | 2:944f2968c19f | 91 | _FixedFontWidth = 0; |
JDI_Mbed_Team | 2:944f2968c19f | 92 | } |
JDI_Mbed_Team | 3:c67b96404016 | 93 | |
JDI_Mbed_Team | 2:944f2968c19f | 94 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 95 | * @brief set Configuration for transfer mode |
JDI_Mbed_Team | 3:c67b96404016 | 96 | * @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit and some parameter |
JDI_Mbed_Team | 3:c67b96404016 | 97 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 98 | void memLCD8::SetTransfermode(int transfermode) |
JDI_Mbed_Team | 3:c67b96404016 | 99 | { |
JDI_Mbed_Team | 3:c67b96404016 | 100 | switch(transfermode) |
JDI_Mbed_Team | 3:c67b96404016 | 101 | { |
JDI_Mbed_Team | 3:c67b96404016 | 102 | case TrBIT4: |
JDI_Mbed_Team | 3:c67b96404016 | 103 | TrModeCommand = 0x90; |
JDI_Mbed_Team | 3:c67b96404016 | 104 | TrAdd = 1; |
JDI_Mbed_Team | 3:c67b96404016 | 105 | TrValNum = 1; |
JDI_Mbed_Team | 3:c67b96404016 | 106 | break; |
JDI_Mbed_Team | 3:c67b96404016 | 107 | case TrBIT3: |
JDI_Mbed_Team | 3:c67b96404016 | 108 | TrModeCommand = 0x80; |
JDI_Mbed_Team | 3:c67b96404016 | 109 | TrAdd = 4; |
JDI_Mbed_Team | 3:c67b96404016 | 110 | TrValNum = 3; |
JDI_Mbed_Team | 3:c67b96404016 | 111 | break; |
JDI_Mbed_Team | 3:c67b96404016 | 112 | case TrBIT1: |
JDI_Mbed_Team | 3:c67b96404016 | 113 | TrModeCommand = 0x88; |
JDI_Mbed_Team | 3:c67b96404016 | 114 | TrAdd = 4; |
JDI_Mbed_Team | 3:c67b96404016 | 115 | TrValNum = 1; |
JDI_Mbed_Team | 3:c67b96404016 | 116 | break; |
JDI_Mbed_Team | 3:c67b96404016 | 117 | } |
JDI_Mbed_Team | 3:c67b96404016 | 118 | } |
JDI_Mbed_Team | 3:c67b96404016 | 119 | |
JDI_Mbed_Team | 3:c67b96404016 | 120 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 121 | * @brief set a display size ,width ,height |
JDI_Mbed_Team | 3:c67b96404016 | 122 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 123 | void memLCD8::setWH(int width, int height) |
JDI_Mbed_Team | 3:c67b96404016 | 124 | { |
JDI_Mbed_Team | 3:c67b96404016 | 125 | _width = width; |
JDI_Mbed_Team | 3:c67b96404016 | 126 | _height = height; |
JDI_Mbed_Team | 3:c67b96404016 | 127 | } |
JDI_Mbed_Team | 3:c67b96404016 | 128 | |
JDI_Mbed_Team | 3:c67b96404016 | 129 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 130 | * @brief set color data of foreground |
JDI_Mbed_Team | 3:c67b96404016 | 131 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 132 | void memLCD8::foreground(uint8_t colour) |
JDI_Mbed_Team | 3:c67b96404016 | 133 | { |
JDI_Mbed_Team | 3:c67b96404016 | 134 | _foreground = colour; |
JDI_Mbed_Team | 3:c67b96404016 | 135 | } |
JDI_Mbed_Team | 3:c67b96404016 | 136 | |
JDI_Mbed_Team | 3:c67b96404016 | 137 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 138 | * @brief set color data of background |
JDI_Mbed_Team | 3:c67b96404016 | 139 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 140 | void memLCD8::background(uint8_t colour) |
JDI_Mbed_Team | 3:c67b96404016 | 141 | { |
JDI_Mbed_Team | 3:c67b96404016 | 142 | _background = colour; |
JDI_Mbed_Team | 3:c67b96404016 | 143 | } |
JDI_Mbed_Team | 3:c67b96404016 | 144 | |
JDI_Mbed_Team | 3:c67b96404016 | 145 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 146 | * @brief set the Diaplay On/Off data |
JDI_Mbed_Team | 3:c67b96404016 | 147 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 148 | void memLCD8::SwDisp(bool ONorOFF) |
JDI_Mbed_Team | 3:c67b96404016 | 149 | { |
JDI_Mbed_Team | 3:c67b96404016 | 150 | _disp= ONorOFF; |
JDI_Mbed_Team | 3:c67b96404016 | 151 | } |
JDI_Mbed_Team | 3:c67b96404016 | 152 | |
JDI_Mbed_Team | 3:c67b96404016 | 153 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 154 | * @brief transfer a command code to the display by SPI |
JDI_Mbed_Team | 3:c67b96404016 | 155 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 156 | void memLCD8::command(char command) |
JDI_Mbed_Team | 3:c67b96404016 | 157 | { |
JDI_Mbed_Team | 3:c67b96404016 | 158 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 159 | _cs = 1; |
JDI_Mbed_Team | 3:c67b96404016 | 160 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 161 | _spi.write(command);// |
JDI_Mbed_Team | 3:c67b96404016 | 162 | _spi.write(0x00);// dummy |
JDI_Mbed_Team | 3:c67b96404016 | 163 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 164 | _cs = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 165 | } |
JDI_Mbed_Team | 3:c67b96404016 | 166 | |
JDI_Mbed_Team | 3:c67b96404016 | 167 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 168 | * @brief putc |
JDI_Mbed_Team | 3:c67b96404016 | 169 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 170 | int memLCD8::_putc(int value) |
JDI_Mbed_Team | 3:c67b96404016 | 171 | { |
JDI_Mbed_Team | 3:c67b96404016 | 172 | if (value == '\n') { // new line |
JDI_Mbed_Team | 3:c67b96404016 | 173 | char_x = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 174 | char_y = char_y + font[3]; |
JDI_Mbed_Team | 3:c67b96404016 | 175 | if (char_y >= _height - font[3]) { |
JDI_Mbed_Team | 3:c67b96404016 | 176 | char_y = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 177 | } |
JDI_Mbed_Team | 3:c67b96404016 | 178 | } |
JDI_Mbed_Team | 3:c67b96404016 | 179 | #if FRAMEBUFF_MODE |
JDI_Mbed_Team | 3:c67b96404016 | 180 | else { |
JDI_Mbed_Team | 3:c67b96404016 | 181 | character(char_x, char_y, value); |
JDI_Mbed_Team | 3:c67b96404016 | 182 | } |
JDI_Mbed_Team | 3:c67b96404016 | 183 | #endif |
JDI_Mbed_Team | 3:c67b96404016 | 184 | return value; |
JDI_Mbed_Team | 3:c67b96404016 | 185 | } |
JDI_Mbed_Team | 3:c67b96404016 | 186 | |
JDI_Mbed_Team | 3:c67b96404016 | 187 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 188 | * @brief getc |
JDI_Mbed_Team | 3:c67b96404016 | 189 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 190 | int memLCD8::_getc() |
JDI_Mbed_Team | 3:c67b96404016 | 191 | { |
JDI_Mbed_Team | 3:c67b96404016 | 192 | return -1; |
JDI_Mbed_Team | 3:c67b96404016 | 193 | } |
JDI_Mbed_Team | 3:c67b96404016 | 194 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 195 | * @brief get color data of background |
JDI_Mbed_Team | 3:c67b96404016 | 196 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 197 | unsigned char memLCD8::get_Background(void) |
JDI_Mbed_Team | 3:c67b96404016 | 198 | { |
JDI_Mbed_Team | 3:c67b96404016 | 199 | return _background; |
JDI_Mbed_Team | 3:c67b96404016 | 200 | } |
JDI_Mbed_Team | 3:c67b96404016 | 201 | /* |
JDI_Mbed_Team | 3:c67b96404016 | 202 | void memLCD8::setmarge(bool ifMarge) |
JDI_Mbed_Team | 3:c67b96404016 | 203 | { |
JDI_Mbed_Team | 3:c67b96404016 | 204 | _ifMarge = ifMarge; |
JDI_Mbed_Team | 3:c67b96404016 | 205 | } |
JDI_Mbed_Team | 3:c67b96404016 | 206 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 207 | ////////////////////////////////////////////////////////////////////////////// |
JDI_Mbed_Team | 3:c67b96404016 | 208 | // line buffer mode |
JDI_Mbed_Team | 3:c67b96404016 | 209 | ////////////////////////////////////////////////////////////////////////////// |
JDI_Mbed_Team | 3:c67b96404016 | 210 | #if LINEBUFF_MODE |
JDI_Mbed_Team | 3:c67b96404016 | 211 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 212 | * @brief Transfer One Pixel Data with x,y allocation Line buffer mode |
JDI_Mbed_Team | 3:c67b96404016 | 213 | * @param[in] int x : horizontal allocation left to right |
JDI_Mbed_Team | 3:c67b96404016 | 214 | * @param[in] uint8_t color : the color data for Drawing 0x0X x is color data(RGBC) C is not used |
JDI_Mbed_Team | 3:c67b96404016 | 215 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 216 | void memLCD8::pixel(int x, uint8_t color) |
JDI_Mbed_Team | 3:c67b96404016 | 217 | { |
JDI_Mbed_Team | 3:c67b96404016 | 218 | if(!(x % 2)) _dispLINEBUF[x/2] = _dispLINEBUF[x/2]&0x0F | (color << 4)&0xF0 ; //MASK 0000 1111 |
JDI_Mbed_Team | 3:c67b96404016 | 219 | else _dispLINEBUF[x/2] = _dispLINEBUF[x/2]&0xF0 | (color )&0x0F ; //MASK 1111 0000 |
JDI_Mbed_Team | 3:c67b96404016 | 220 | } |
JDI_Mbed_Team | 3:c67b96404016 | 221 | |
JDI_Mbed_Team | 3:c67b96404016 | 222 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 223 | * @brief Transfer Pixel Data from same Line buffer to Display |
JDI_Mbed_Team | 3:c67b96404016 | 224 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 225 | void memLCD8::writeDISPLinebuffer(void) // refresh whole display |
JDI_Mbed_Team | 3:c67b96404016 | 226 | { |
JDI_Mbed_Team | 3:c67b96404016 | 227 | |
JDI_Mbed_Team | 3:c67b96404016 | 228 | char pol = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 229 | char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW A 1010 |
JDI_Mbed_Team | 3:c67b96404016 | 230 | |
JDI_Mbed_Team | 3:c67b96404016 | 231 | // frame |
JDI_Mbed_Team | 3:c67b96404016 | 232 | for (int i=0; i<_height; i++) { |
JDI_Mbed_Team | 3:c67b96404016 | 233 | // line |
JDI_Mbed_Team | 3:c67b96404016 | 234 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 235 | _cs = 1; |
JDI_Mbed_Team | 3:c67b96404016 | 236 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 237 | _spi.write(command | (pol << 6) | (i+1)>>8 ); // COMMAND |
JDI_Mbed_Team | 3:c67b96404016 | 238 | _spi.write((i+1)& 0x00FF ); // V ADDR |
JDI_Mbed_Team | 3:c67b96404016 | 239 | for(int j=0; j<_width/2; j++) _spi.write(_dispLINEBUF[j]); |
JDI_Mbed_Team | 3:c67b96404016 | 240 | _spi.write(0x00); // DUMMY transfer |
JDI_Mbed_Team | 3:c67b96404016 | 241 | _spi.write(0x00); // DUMMY transfer |
JDI_Mbed_Team | 3:c67b96404016 | 242 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 243 | _cs = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 244 | if(pol) pol=0x00; |
JDI_Mbed_Team | 3:c67b96404016 | 245 | else pol=0x01; |
JDI_Mbed_Team | 3:c67b96404016 | 246 | } |
JDI_Mbed_Team | 3:c67b96404016 | 247 | } |
JDI_Mbed_Team | 3:c67b96404016 | 248 | |
JDI_Mbed_Team | 3:c67b96404016 | 249 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 250 | * @brief Transfer Pixel Data from line buffer to Display |
JDI_Mbed_Team | 3:c67b96404016 | 251 | * @param[in] int line : set line number for display. |
JDI_Mbed_Team | 3:c67b96404016 | 252 | * @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit |
JDI_Mbed_Team | 3:c67b96404016 | 253 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 254 | void memLCD8::writeDISP(int line,int transfermode) // refresh gate line display |
JDI_Mbed_Team | 3:c67b96404016 | 255 | { |
JDI_Mbed_Team | 3:c67b96404016 | 256 | |
JDI_Mbed_Team | 3:c67b96404016 | 257 | char pol = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 258 | //char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW A 1010 |
JDI_Mbed_Team | 3:c67b96404016 | 259 | SetTransfermode(transfermode); |
JDI_Mbed_Team | 3:c67b96404016 | 260 | |
JDI_Mbed_Team | 3:c67b96404016 | 261 | // frame |
JDI_Mbed_Team | 3:c67b96404016 | 262 | // line |
JDI_Mbed_Team | 3:c67b96404016 | 263 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 264 | _cs = 1; |
JDI_Mbed_Team | 3:c67b96404016 | 265 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 266 | _spi.write(TrModeCommand | (pol << 6) | (line+1)>>8 ); // COMMAND |
JDI_Mbed_Team | 3:c67b96404016 | 267 | //pc2.printf("com 0x%x\n",TrModeCommand | (pol << 6) | (i+1)>>8); |
JDI_Mbed_Team | 3:c67b96404016 | 268 | |
JDI_Mbed_Team | 3:c67b96404016 | 269 | _spi.write((line+1)& 0x00FF ); // V ADDR |
JDI_Mbed_Team | 3:c67b96404016 | 270 | //pc2.printf("v adr 0x%x\n",(i+1)& 0x00FF); |
JDI_Mbed_Team | 3:c67b96404016 | 271 | |
JDI_Mbed_Team | 3:c67b96404016 | 272 | for(int j=0; j<_width; j+=TrAdd) |
JDI_Mbed_Team | 3:c67b96404016 | 273 | { |
JDI_Mbed_Team | 3:c67b96404016 | 274 | GetPixelValueFromLineBuffer(j,_dispLINEBUF); |
JDI_Mbed_Team | 3:c67b96404016 | 275 | //pc2.printf("data=[%d]{%d][%d]/[%d]\n",j*TrAdd,i,TrValue[0],TrAdd); |
JDI_Mbed_Team | 3:c67b96404016 | 276 | for(int k=0;k<TrValNum;k++) |
JDI_Mbed_Team | 3:c67b96404016 | 277 | _spi.write(TrValue[k]); |
JDI_Mbed_Team | 3:c67b96404016 | 278 | } |
JDI_Mbed_Team | 3:c67b96404016 | 279 | _spi.write(0x00); // DUMMY transfer |
JDI_Mbed_Team | 3:c67b96404016 | 280 | _spi.write(0x00); // DUMMY transfer |
JDI_Mbed_Team | 3:c67b96404016 | 281 | // wait_ms(1); //1.8Hz simulation |
JDI_Mbed_Team | 3:c67b96404016 | 282 | // wait_ms(2); //1.35Hz simulation |
JDI_Mbed_Team | 3:c67b96404016 | 283 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 284 | _cs = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 285 | if(pol) pol=0x00; |
JDI_Mbed_Team | 3:c67b96404016 | 286 | else pol=0x01; |
JDI_Mbed_Team | 3:c67b96404016 | 287 | |
JDI_Mbed_Team | 3:c67b96404016 | 288 | } |
JDI_Mbed_Team | 3:c67b96404016 | 289 | |
JDI_Mbed_Team | 3:c67b96404016 | 290 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 291 | * @brief Get Edited data for SPI transfer from line buffer |
JDI_Mbed_Team | 3:c67b96404016 | 292 | * @param[in] int x : horizontal allocation left to right |
JDI_Mbed_Team | 3:c67b96404016 | 293 | * @param[in] uint8_t* buff : buffer data for Display |
JDI_Mbed_Team | 3:c67b96404016 | 294 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 295 | int* memLCD8::GetPixelValueFromLineBuffer(int _x,uint8_t* buff) |
JDI_Mbed_Team | 3:c67b96404016 | 296 | { |
JDI_Mbed_Team | 3:c67b96404016 | 297 | //bitmap data = 4bit data => modify transfer data bit size; |
JDI_Mbed_Team | 3:c67b96404016 | 298 | switch(TrModeCommand) |
JDI_Mbed_Team | 3:c67b96404016 | 299 | { |
JDI_Mbed_Team | 3:c67b96404016 | 300 | case 0x90: //TrBIT4: |
JDI_Mbed_Team | 3:c67b96404016 | 301 | // buffer 2pixel/1byte => 2pixel/1byte buffe 2byte毎進める。 |
JDI_Mbed_Team | 3:c67b96404016 | 302 | TrValue[0] = _dispLINEBUF[_x]; |
JDI_Mbed_Team | 3:c67b96404016 | 303 | break; |
JDI_Mbed_Team | 3:c67b96404016 | 304 | case 0x80://TrBIT3: |
JDI_Mbed_Team | 3:c67b96404016 | 305 | // buffer 2pixel/1byte => 3pixel-1subpixel/1bye (24 pixel/3byte) buffer 3byte毎進める。 |
JDI_Mbed_Team | 3:c67b96404016 | 306 | for(int j=0;j<3;j++) TrValue[j] = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 307 | //for( int i = 0 ; i<12 ; i--) |
JDI_Mbed_Team | 3:c67b96404016 | 308 | { |
JDI_Mbed_Team | 3:c67b96404016 | 309 | //4 bit RGBN(Nは予備) => 3bit RGB |
JDI_Mbed_Team | 3:c67b96404016 | 310 | if( _width/2 > _x ) |
JDI_Mbed_Team | 3:c67b96404016 | 311 | { |
JDI_Mbed_Team | 3:c67b96404016 | 312 | TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x ]&0xE0) ) ); |
JDI_Mbed_Team | 3:c67b96404016 | 313 | TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x ]&0x0E) ) << 1); |
JDI_Mbed_Team | 3:c67b96404016 | 314 | } |
JDI_Mbed_Team | 3:c67b96404016 | 315 | if( _width/2 > _x + 1 ) |
JDI_Mbed_Team | 3:c67b96404016 | 316 | { |
JDI_Mbed_Team | 3:c67b96404016 | 317 | TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x + 1]&0xC0) ) >> 6); |
JDI_Mbed_Team | 3:c67b96404016 | 318 | |
JDI_Mbed_Team | 3:c67b96404016 | 319 | TrValue[1] = TrValue[1] | ( ( (_dispLINEBUF[_x + 1]&0x20) ) << 2); |
JDI_Mbed_Team | 3:c67b96404016 | 320 | TrValue[1] = TrValue[1] | ( ( (_dispLINEBUF[_x + 1]&0x0E) ) << 3); |
JDI_Mbed_Team | 3:c67b96404016 | 321 | } |
JDI_Mbed_Team | 3:c67b96404016 | 322 | if( _width/2 > _x + 2 ) |
JDI_Mbed_Team | 3:c67b96404016 | 323 | { |
JDI_Mbed_Team | 3:c67b96404016 | 324 | TrValue[1] = TrValue[1] | ( ( (_dispLINEBUF[ _x + 2]&0xE0) ) >> 4); |
JDI_Mbed_Team | 3:c67b96404016 | 325 | TrValue[1] = TrValue[1] | ( ( (_dispLINEBUF[ _x + 2]&0x08) ) >> 3); |
JDI_Mbed_Team | 3:c67b96404016 | 326 | |
JDI_Mbed_Team | 3:c67b96404016 | 327 | TrValue[2] = TrValue[2] | ( ( (_dispLINEBUF[_x + 2]&0x06) ) << 5); |
JDI_Mbed_Team | 3:c67b96404016 | 328 | } |
JDI_Mbed_Team | 3:c67b96404016 | 329 | if( _width/2 > _x + 3 ) |
JDI_Mbed_Team | 3:c67b96404016 | 330 | { |
JDI_Mbed_Team | 3:c67b96404016 | 331 | TrValue[2] = TrValue[2] | ( ( (_dispLINEBUF[ _x + 3]&0xE0) ) >> 2); |
JDI_Mbed_Team | 3:c67b96404016 | 332 | TrValue[2] = TrValue[2] | ( ( (_dispLINEBUF[_x + 3]&0x0E) ) >> 1); |
JDI_Mbed_Team | 3:c67b96404016 | 333 | } |
JDI_Mbed_Team | 3:c67b96404016 | 334 | } |
JDI_Mbed_Team | 3:c67b96404016 | 335 | break; |
JDI_Mbed_Team | 3:c67b96404016 | 336 | case 0x88://TrBIT1: |
JDI_Mbed_Team | 3:c67b96404016 | 337 | // buffer 2pixel/1byte => 8 pixel/1byte buffe 4byte毎進める。 |
JDI_Mbed_Team | 3:c67b96404016 | 338 | for(int j=0;j<3;j++) TrValue[j] = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 339 | for(int i = 0 ; i<4 ; i++) |
JDI_Mbed_Team | 3:c67b96404016 | 340 | { |
JDI_Mbed_Team | 3:c67b96404016 | 341 | //Green bit => monochrome bit |
JDI_Mbed_Team | 3:c67b96404016 | 342 | if( _width/2 > _x + i ) |
JDI_Mbed_Team | 3:c67b96404016 | 343 | { |
JDI_Mbed_Team | 3:c67b96404016 | 344 | TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x + i]&0x40) == 0 ? 0 : 1 ) << (7-i*2) ); |
JDI_Mbed_Team | 3:c67b96404016 | 345 | TrValue[0] = TrValue[0] | ( ( (_dispLINEBUF[_x + i]&0x04) == 0 ? 0 : 1 ) << (7-i*2)-1 ); |
JDI_Mbed_Team | 3:c67b96404016 | 346 | //pc2.printf("[%d+%d][%d]<0x%x>\n",_x,i,_y,_dispBUF[_y* _width/2 + _x + i]); |
JDI_Mbed_Team | 3:c67b96404016 | 347 | } |
JDI_Mbed_Team | 3:c67b96404016 | 348 | } |
JDI_Mbed_Team | 3:c67b96404016 | 349 | break; |
JDI_Mbed_Team | 3:c67b96404016 | 350 | } |
JDI_Mbed_Team | 3:c67b96404016 | 351 | return TrValue; |
JDI_Mbed_Team | 3:c67b96404016 | 352 | } |
JDI_Mbed_Team | 3:c67b96404016 | 353 | |
JDI_Mbed_Team | 3:c67b96404016 | 354 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 355 | * @brief clear line buffer data by background color data |
JDI_Mbed_Team | 3:c67b96404016 | 356 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 357 | void memLCD8::clsLINEBUF(void) |
JDI_Mbed_Team | 3:c67b96404016 | 358 | { |
JDI_Mbed_Team | 3:c67b96404016 | 359 | |
JDI_Mbed_Team | 3:c67b96404016 | 360 | for (int j=0; j<_width; j++) { |
JDI_Mbed_Team | 3:c67b96404016 | 361 | pixel(j,_background); |
JDI_Mbed_Team | 3:c67b96404016 | 362 | } |
JDI_Mbed_Team | 3:c67b96404016 | 363 | } |
JDI_Mbed_Team | 3:c67b96404016 | 364 | #endif |
JDI_Mbed_Team | 3:c67b96404016 | 365 | ////////////////////////////////////////////////////////////////////////////// |
JDI_Mbed_Team | 3:c67b96404016 | 366 | // Frame buffer mode |
JDI_Mbed_Team | 3:c67b96404016 | 367 | ////////////////////////////////////////////////////////////////////////////// |
JDI_Mbed_Team | 3:c67b96404016 | 368 | #if FRAMEBUFF_MODE |
JDI_Mbed_Team | 3:c67b96404016 | 369 | |
JDI_Mbed_Team | 3:c67b96404016 | 370 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 371 | * @brief display the text. |
JDI_Mbed_Team | 3:c67b96404016 | 372 | * @param[in] int x : horizontal allocation , up-left of text |
JDI_Mbed_Team | 3:c67b96404016 | 373 | * @param[in] int y : vertical allocation , bottom-right of text |
JDI_Mbed_Team | 3:c67b96404016 | 374 | * @param[in] char* text : strings |
JDI_Mbed_Team | 3:c67b96404016 | 375 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 376 | int memLCD8::textout(int x,int y,char* text) |
JDI_Mbed_Team | 3:c67b96404016 | 377 | { |
JDI_Mbed_Team | 3:c67b96404016 | 378 | int i=0; |
JDI_Mbed_Team | 3:c67b96404016 | 379 | char_x = x; |
JDI_Mbed_Team | 3:c67b96404016 | 380 | char_y = y; |
JDI_Mbed_Team | 3:c67b96404016 | 381 | |
JDI_Mbed_Team | 3:c67b96404016 | 382 | while(text[i] != 0x00 ) |
JDI_Mbed_Team | 3:c67b96404016 | 383 | { |
JDI_Mbed_Team | 3:c67b96404016 | 384 | character(char_x, char_y, text[i]); |
JDI_Mbed_Team | 3:c67b96404016 | 385 | i++; |
JDI_Mbed_Team | 3:c67b96404016 | 386 | } |
JDI_Mbed_Team | 3:c67b96404016 | 387 | return text[i]; |
JDI_Mbed_Team | 3:c67b96404016 | 388 | } |
JDI_Mbed_Team | 3:c67b96404016 | 389 | |
JDI_Mbed_Team | 3:c67b96404016 | 390 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 391 | * @brief display the oblique text. |
JDI_Mbed_Team | 3:c67b96404016 | 392 | * @param[in] int x : horizontal allocation , up-left of text |
JDI_Mbed_Team | 3:c67b96404016 | 393 | * @param[in] int y : vertical allocation , bottom-right of text |
JDI_Mbed_Team | 3:c67b96404016 | 394 | * @param[in] char* text : strings |
JDI_Mbed_Team | 3:c67b96404016 | 395 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 396 | int memLCD8::obliqueout(int x,int y,char* text) |
JDI_Mbed_Team | 3:c67b96404016 | 397 | { |
JDI_Mbed_Team | 3:c67b96404016 | 398 | int i=0; |
JDI_Mbed_Team | 3:c67b96404016 | 399 | char_x = x; |
JDI_Mbed_Team | 3:c67b96404016 | 400 | char_y = y; |
JDI_Mbed_Team | 3:c67b96404016 | 401 | |
JDI_Mbed_Team | 3:c67b96404016 | 402 | while(text[i] != 0x00 ) |
JDI_Mbed_Team | 3:c67b96404016 | 403 | { |
JDI_Mbed_Team | 3:c67b96404016 | 404 | oblique(char_x, char_y, text[i]); |
JDI_Mbed_Team | 3:c67b96404016 | 405 | i++; |
JDI_Mbed_Team | 3:c67b96404016 | 406 | } |
JDI_Mbed_Team | 3:c67b96404016 | 407 | return text[i]; |
JDI_Mbed_Team | 3:c67b96404016 | 408 | } |
JDI_Mbed_Team | 3:c67b96404016 | 409 | |
JDI_Mbed_Team | 3:c67b96404016 | 410 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 411 | * @brief dispay a character by bog font. big font is that "char data" byte size is over 0xff. |
JDI_Mbed_Team | 3:c67b96404016 | 412 | * @param[in] int x : horizontal allocation , up-left of text |
JDI_Mbed_Team | 3:c67b96404016 | 413 | * @param[in] int y : vertical allocation , bottom-right of text |
JDI_Mbed_Team | 3:c67b96404016 | 414 | * @param[in] char c : a charactor. |
JDI_Mbed_Team | 1:2b85e7edcc4e | 415 | * |
JDI_Mbed_Team | 0:b2d46804658c | 416 | */ |
JDI_Mbed_Team | 2:944f2968c19f | 417 | void memLCD8::character(int x, int y, int c) |
JDI_Mbed_Team | 0:b2d46804658c | 418 | { |
JDI_Mbed_Team | 0:b2d46804658c | 419 | unsigned int hor,vert,offset0,offset1,bpl,j,i,b; // T.Okamoto modified, for big font |
JDI_Mbed_Team | 2:944f2968c19f | 420 | unsigned int headroffset;// 2018-10-26 added by Y.Saruhashi |
JDI_Mbed_Team | 0:b2d46804658c | 421 | unsigned char* zeichen; |
JDI_Mbed_Team | 0:b2d46804658c | 422 | unsigned char z,w; |
JDI_Mbed_Team | 2:944f2968c19f | 423 | |
JDI_Mbed_Team | 3:c67b96404016 | 424 | if ((c < 32) || (c > 127)) return; // test char range |
JDI_Mbed_Team | 1:2b85e7edcc4e | 425 | |
JDI_Mbed_Team | 2:944f2968c19f | 426 | //for big font |
JDI_Mbed_Team | 2:944f2968c19f | 427 | offset0 = font[0]; // bytes / char uppser adress |
JDI_Mbed_Team | 2:944f2968c19f | 428 | offset1 = font[1]; // bytes / char lower adress |
JDI_Mbed_Team | 2:944f2968c19f | 429 | hor = font[2]; // get hor size of font |
JDI_Mbed_Team | 2:944f2968c19f | 430 | vert = font[3]; // get vert size of font |
JDI_Mbed_Team | 2:944f2968c19f | 431 | bpl = font[4]; // bytes per line |
JDI_Mbed_Team | 2:944f2968c19f | 432 | headroffset = 5; |
JDI_Mbed_Team | 0:b2d46804658c | 433 | |
JDI_Mbed_Team | 2:944f2968c19f | 434 | if (char_x + hor > _width) { |
JDI_Mbed_Team | 2:944f2968c19f | 435 | char_x = 0; |
JDI_Mbed_Team | 2:944f2968c19f | 436 | char_y = char_y + vert; |
JDI_Mbed_Team | 2:944f2968c19f | 437 | if (char_y >= _height - vert) char_y = 0; // original = font[2] T.Okamoto modified, for big font |
JDI_Mbed_Team | 2:944f2968c19f | 438 | } |
JDI_Mbed_Team | 0:b2d46804658c | 439 | |
JDI_Mbed_Team | 2:944f2968c19f | 440 | zeichen = &font[(c -32) * (offset0 *256 + offset1) + headroffset]; // start of char bitmap // original = +4 T.Okamoto modified, for big font |
JDI_Mbed_Team | 1:2b85e7edcc4e | 441 | |
JDI_Mbed_Team | 2:944f2968c19f | 442 | if( _FixedFontWidth == 0 ) w = zeichen[0]; // width of actual char |
JDI_Mbed_Team | 2:944f2968c19f | 443 | else w = _FixedFontWidth; // fixed width of char |
JDI_Mbed_Team | 2:944f2968c19f | 444 | |
JDI_Mbed_Team | 0:b2d46804658c | 445 | for (j=0; j<vert; j++) { // vert line |
JDI_Mbed_Team | 0:b2d46804658c | 446 | for (i=0; i<hor; i++) { // horz line |
JDI_Mbed_Team | 0:b2d46804658c | 447 | z = zeichen[bpl * i + ((j & 0xF8) >> 3)+1]; |
JDI_Mbed_Team | 0:b2d46804658c | 448 | b = 1 << (j & 0x07); |
JDI_Mbed_Team | 0:b2d46804658c | 449 | if (( z & b ) != 0x00) pixel(x+i,y+j,_foreground); |
JDI_Mbed_Team | 0:b2d46804658c | 450 | else if (_ifMarge == 0) pixel(x+i,y+j,_background);// _background -> _LayerBUF[index]; |
JDI_Mbed_Team | 0:b2d46804658c | 451 | |
JDI_Mbed_Team | 0:b2d46804658c | 452 | } |
JDI_Mbed_Team | 0:b2d46804658c | 453 | } |
JDI_Mbed_Team | 0:b2d46804658c | 454 | if ((w + 2) < hor) char_x += w + 2; // x offset to next char |
JDI_Mbed_Team | 0:b2d46804658c | 455 | else char_x += hor; |
JDI_Mbed_Team | 0:b2d46804658c | 456 | } |
JDI_Mbed_Team | 0:b2d46804658c | 457 | |
JDI_Mbed_Team | 0:b2d46804658c | 458 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 459 | * @brief dispay a oblique typte character by big font. |
JDI_Mbed_Team | 3:c67b96404016 | 460 | * @param[in] int x : horizontal allocation , up-left of text |
JDI_Mbed_Team | 3:c67b96404016 | 461 | * @param[in] int y : vertical allocation , bottom-right of text |
JDI_Mbed_Team | 3:c67b96404016 | 462 | * @param[in] char c : a charactor. |
JDI_Mbed_Team | 2:944f2968c19f | 463 | */ |
JDI_Mbed_Team | 2:944f2968c19f | 464 | void memLCD8::oblique(int x, int y, int c) |
JDI_Mbed_Team | 2:944f2968c19f | 465 | { |
JDI_Mbed_Team | 2:944f2968c19f | 466 | unsigned int hor,vert,offset0,offset1,bpl,j,i,b; // T.Okamoto modified, for big font |
JDI_Mbed_Team | 2:944f2968c19f | 467 | unsigned int headroffset;// 2018-10-26 added by Y.Saruhashi |
JDI_Mbed_Team | 2:944f2968c19f | 468 | unsigned char* zeichen; |
JDI_Mbed_Team | 2:944f2968c19f | 469 | unsigned char z,w; |
JDI_Mbed_Team | 3:c67b96404016 | 470 | if ((c < 32) || (c > 127)) return; // test char range |
JDI_Mbed_Team | 2:944f2968c19f | 471 | |
JDI_Mbed_Team | 2:944f2968c19f | 472 | //for big font |
JDI_Mbed_Team | 2:944f2968c19f | 473 | offset0 = font[0]; // bytes / char uppser adress |
JDI_Mbed_Team | 2:944f2968c19f | 474 | offset1 = font[1]; // bytes / char lower adress |
JDI_Mbed_Team | 2:944f2968c19f | 475 | hor = font[2]; // get hor size of font |
JDI_Mbed_Team | 2:944f2968c19f | 476 | vert = font[3]; // get vert size of font |
JDI_Mbed_Team | 2:944f2968c19f | 477 | bpl = font[4]; // bytes per line |
JDI_Mbed_Team | 2:944f2968c19f | 478 | headroffset = 5; |
JDI_Mbed_Team | 2:944f2968c19f | 479 | |
JDI_Mbed_Team | 2:944f2968c19f | 480 | int oblique_raio=3; // 3 = 30(%percentage) / 10 |
JDI_Mbed_Team | 2:944f2968c19f | 481 | int shift_x = (hor*oblique_raio)/10; //oblique pixel x size, top of char; |
JDI_Mbed_Team | 2:944f2968c19f | 482 | int shift_y = vert / shift_x; //oblique ratio for vertical. |
JDI_Mbed_Team | 2:944f2968c19f | 483 | |
JDI_Mbed_Team | 2:944f2968c19f | 484 | if (char_x + hor > _width) { |
JDI_Mbed_Team | 2:944f2968c19f | 485 | char_x = 0; |
JDI_Mbed_Team | 2:944f2968c19f | 486 | char_y = char_y + vert; |
JDI_Mbed_Team | 2:944f2968c19f | 487 | if (char_y >= _height - vert) char_y = 0; |
JDI_Mbed_Team | 2:944f2968c19f | 488 | } |
JDI_Mbed_Team | 2:944f2968c19f | 489 | |
JDI_Mbed_Team | 2:944f2968c19f | 490 | zeichen = &font[(c -32) * (offset0 *256 + offset1) + headroffset]; |
JDI_Mbed_Team | 2:944f2968c19f | 491 | if( _FixedFontWidth == 0 ) w = zeichen[0]; // actual width of char |
JDI_Mbed_Team | 2:944f2968c19f | 492 | else w = _FixedFontWidth; // fixed width of char |
JDI_Mbed_Team | 2:944f2968c19f | 493 | |
JDI_Mbed_Team | 2:944f2968c19f | 494 | for (j=0; j<vert; j++) { // vert line |
JDI_Mbed_Team | 2:944f2968c19f | 495 | for (i=0; i<hor; i++) { // horz line |
JDI_Mbed_Team | 2:944f2968c19f | 496 | z = zeichen[bpl * i + ((j & 0xF8) >> 3)+1]; |
JDI_Mbed_Team | 2:944f2968c19f | 497 | b = 1 << (j & 0x07); |
JDI_Mbed_Team | 2:944f2968c19f | 498 | if (( z & b ) != 0x00) pixel(x+i+shift_x-(j/shift_y),y+j,_foreground); |
JDI_Mbed_Team | 2:944f2968c19f | 499 | else if (_ifMarge == 0) pixel(x+i+shift_x-(j/shift_y),y+j,_background);// _background -> _LayerBUF[index]; |
JDI_Mbed_Team | 2:944f2968c19f | 500 | |
JDI_Mbed_Team | 2:944f2968c19f | 501 | } |
JDI_Mbed_Team | 2:944f2968c19f | 502 | } |
JDI_Mbed_Team | 2:944f2968c19f | 503 | if ((w + 2) < hor) char_x += w + 2; // x offset to next char |
JDI_Mbed_Team | 2:944f2968c19f | 504 | else char_x += hor; |
JDI_Mbed_Team | 2:944f2968c19f | 505 | } |
JDI_Mbed_Team | 2:944f2968c19f | 506 | |
JDI_Mbed_Team | 2:944f2968c19f | 507 | /** |
JDI_Mbed_Team | 2:944f2968c19f | 508 | * @brief dispay the image from symbol data |
JDI_Mbed_Team | 0:b2d46804658c | 509 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 510 | void memLCD8::Symbol(unsigned int x, unsigned int y, unsigned char *symbol) |
JDI_Mbed_Team | 0:b2d46804658c | 511 | { |
JDI_Mbed_Team | 0:b2d46804658c | 512 | unsigned int hor,vert,bpl,j,i,b; |
JDI_Mbed_Team | 0:b2d46804658c | 513 | unsigned char* zeichen; |
JDI_Mbed_Team | 0:b2d46804658c | 514 | unsigned char z,w; |
JDI_Mbed_Team | 0:b2d46804658c | 515 | hor = symbol[0]; // get hor size of font |
JDI_Mbed_Team | 0:b2d46804658c | 516 | vert = symbol[1]; // get vert size of font |
JDI_Mbed_Team | 0:b2d46804658c | 517 | bpl = symbol[2]; // bytes per line |
JDI_Mbed_Team | 0:b2d46804658c | 518 | |
JDI_Mbed_Team | 0:b2d46804658c | 519 | if (char_x + hor > _width) { |
JDI_Mbed_Team | 0:b2d46804658c | 520 | char_x = 0; |
JDI_Mbed_Team | 0:b2d46804658c | 521 | char_y = char_y + vert; |
JDI_Mbed_Team | 0:b2d46804658c | 522 | if (char_y >= _height - symbol[1]) char_y = 0; |
JDI_Mbed_Team | 0:b2d46804658c | 523 | } |
JDI_Mbed_Team | 2:944f2968c19f | 524 | |
JDI_Mbed_Team | 0:b2d46804658c | 525 | zeichen = &symbol[3]; |
JDI_Mbed_Team | 2:944f2968c19f | 526 | w = zeichen[0]; // actual width of char |
JDI_Mbed_Team | 0:b2d46804658c | 527 | for (j=0; j<vert; j++) { // vert line |
JDI_Mbed_Team | 0:b2d46804658c | 528 | for (i=0; i<hor; i++) { // horz line |
JDI_Mbed_Team | 0:b2d46804658c | 529 | z = zeichen[bpl * i + ((j & 0xF8) >> 3)+1]; |
JDI_Mbed_Team | 0:b2d46804658c | 530 | b = 1 << (j & 0x07); |
JDI_Mbed_Team | 0:b2d46804658c | 531 | if (( z & b ) != 0x00) pixel(x+i,y+j,_foreground); |
JDI_Mbed_Team | 0:b2d46804658c | 532 | else if (_ifMarge == 0) pixel(x+i,y+j,_background);// _background -> _LayerBUF[index]; |
JDI_Mbed_Team | 0:b2d46804658c | 533 | } |
JDI_Mbed_Team | 0:b2d46804658c | 534 | } |
JDI_Mbed_Team | 0:b2d46804658c | 535 | if ((w + 2) < hor) char_x += w + 2; // x offset to next char |
JDI_Mbed_Team | 0:b2d46804658c | 536 | else char_x += hor; |
JDI_Mbed_Team | 0:b2d46804658c | 537 | } |
JDI_Mbed_Team | 0:b2d46804658c | 538 | |
JDI_Mbed_Team | 0:b2d46804658c | 539 | /** |
JDI_Mbed_Team | 0:b2d46804658c | 540 | * @brief dispay a circle line by color data |
JDI_Mbed_Team | 0:b2d46804658c | 541 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 542 | void memLCD8::circle(int x0, int y0, int r, uint8_t color) |
JDI_Mbed_Team | 0:b2d46804658c | 543 | { |
JDI_Mbed_Team | 0:b2d46804658c | 544 | int x = -r, y = 0, err = 2-2*r, e2; |
JDI_Mbed_Team | 0:b2d46804658c | 545 | do { |
JDI_Mbed_Team | 0:b2d46804658c | 546 | pixel(x0-x, y0+y,color); |
JDI_Mbed_Team | 0:b2d46804658c | 547 | pixel(x0+x, y0+y,color); |
JDI_Mbed_Team | 0:b2d46804658c | 548 | pixel(x0+x, y0-y,color); |
JDI_Mbed_Team | 0:b2d46804658c | 549 | pixel(x0-x, y0-y,color); |
JDI_Mbed_Team | 0:b2d46804658c | 550 | e2 = err; |
JDI_Mbed_Team | 0:b2d46804658c | 551 | if (e2 <= y) { |
JDI_Mbed_Team | 0:b2d46804658c | 552 | err += ++y*2+1; |
JDI_Mbed_Team | 0:b2d46804658c | 553 | if (-x == y && e2 <= x) e2 = 0; |
JDI_Mbed_Team | 0:b2d46804658c | 554 | } |
JDI_Mbed_Team | 0:b2d46804658c | 555 | if (e2 > x) err += ++x*2+1; |
JDI_Mbed_Team | 0:b2d46804658c | 556 | } while (x <= 0); |
JDI_Mbed_Team | 0:b2d46804658c | 557 | |
JDI_Mbed_Team | 0:b2d46804658c | 558 | } |
JDI_Mbed_Team | 3:c67b96404016 | 559 | |
JDI_Mbed_Team | 0:b2d46804658c | 560 | /** |
JDI_Mbed_Team | 0:b2d46804658c | 561 | * @brief dispay a filled circle by color data |
JDI_Mbed_Team | 0:b2d46804658c | 562 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 563 | void memLCD8::fillcircle(int x0, int y0, int r, uint8_t color) |
JDI_Mbed_Team | 0:b2d46804658c | 564 | { |
JDI_Mbed_Team | 0:b2d46804658c | 565 | int x = -r, y = 0, err = 2-2*r, e2; |
JDI_Mbed_Team | 0:b2d46804658c | 566 | do { |
JDI_Mbed_Team | 0:b2d46804658c | 567 | vline(x0-x, y0-y, y0+y, color); |
JDI_Mbed_Team | 0:b2d46804658c | 568 | vline(x0+x, y0-y, y0+y, color); |
JDI_Mbed_Team | 0:b2d46804658c | 569 | e2 = err; |
JDI_Mbed_Team | 0:b2d46804658c | 570 | if (e2 <= y) { |
JDI_Mbed_Team | 0:b2d46804658c | 571 | err += ++y*2+1; |
JDI_Mbed_Team | 0:b2d46804658c | 572 | if (-x == y && e2 <= x) e2 = 0; |
JDI_Mbed_Team | 0:b2d46804658c | 573 | } |
JDI_Mbed_Team | 0:b2d46804658c | 574 | if (e2 > x) err += ++x*2+1; |
JDI_Mbed_Team | 0:b2d46804658c | 575 | } while (x <= 0); |
JDI_Mbed_Team | 0:b2d46804658c | 576 | } |
JDI_Mbed_Team | 2:944f2968c19f | 577 | |
JDI_Mbed_Team | 0:b2d46804658c | 578 | /** |
JDI_Mbed_Team | 0:b2d46804658c | 579 | * @brief dispay a horizontal line by color data |
JDI_Mbed_Team | 0:b2d46804658c | 580 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 581 | void memLCD8::hline(int x0, int x1, int y, uint8_t color) |
JDI_Mbed_Team | 0:b2d46804658c | 582 | { |
JDI_Mbed_Team | 0:b2d46804658c | 583 | int w; |
JDI_Mbed_Team | 0:b2d46804658c | 584 | w = x1 - x0 + 1; |
JDI_Mbed_Team | 0:b2d46804658c | 585 | for (int j=0; j<w; j++) pixel(x0+j, y,color); |
JDI_Mbed_Team | 0:b2d46804658c | 586 | } |
JDI_Mbed_Team | 0:b2d46804658c | 587 | /** |
JDI_Mbed_Team | 0:b2d46804658c | 588 | * @brief dispay a vertical line by color data |
JDI_Mbed_Team | 0:b2d46804658c | 589 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 590 | void memLCD8::vline(int x, int y0, int y1, uint8_t color) |
JDI_Mbed_Team | 0:b2d46804658c | 591 | { |
JDI_Mbed_Team | 0:b2d46804658c | 592 | int h; |
JDI_Mbed_Team | 0:b2d46804658c | 593 | h = y1 - y0 + 1; |
JDI_Mbed_Team | 0:b2d46804658c | 594 | for (int j=0; j<h; j++) pixel(x, y0+j,color); |
JDI_Mbed_Team | 0:b2d46804658c | 595 | } |
JDI_Mbed_Team | 3:c67b96404016 | 596 | |
JDI_Mbed_Team | 0:b2d46804658c | 597 | /** |
JDI_Mbed_Team | 0:b2d46804658c | 598 | * @brief dispay a line by color data |
JDI_Mbed_Team | 0:b2d46804658c | 599 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 600 | void memLCD8::line(int x0, int y0, int x1, int y1, uint8_t color) |
JDI_Mbed_Team | 0:b2d46804658c | 601 | { |
JDI_Mbed_Team | 0:b2d46804658c | 602 | int dx = 0, dy = 0; |
JDI_Mbed_Team | 0:b2d46804658c | 603 | int dx_sym = 0, dy_sym = 0; |
JDI_Mbed_Team | 0:b2d46804658c | 604 | int dx_x2 = 0, dy_x2 = 0; |
JDI_Mbed_Team | 0:b2d46804658c | 605 | int di = 0; |
JDI_Mbed_Team | 0:b2d46804658c | 606 | |
JDI_Mbed_Team | 0:b2d46804658c | 607 | dx = x1-x0; |
JDI_Mbed_Team | 0:b2d46804658c | 608 | dy = y1-y0; |
JDI_Mbed_Team | 0:b2d46804658c | 609 | |
JDI_Mbed_Team | 3:c67b96404016 | 610 | if (dx == 0) { // vertical line |
JDI_Mbed_Team | 0:b2d46804658c | 611 | if (y1 > y0) vline(x0,y0,y1,color); |
JDI_Mbed_Team | 0:b2d46804658c | 612 | else vline(x0,y1,y0,color); |
JDI_Mbed_Team | 0:b2d46804658c | 613 | return; |
JDI_Mbed_Team | 0:b2d46804658c | 614 | } |
JDI_Mbed_Team | 0:b2d46804658c | 615 | |
JDI_Mbed_Team | 0:b2d46804658c | 616 | if (dx > 0) { |
JDI_Mbed_Team | 0:b2d46804658c | 617 | dx_sym = 1; |
JDI_Mbed_Team | 0:b2d46804658c | 618 | } else { |
JDI_Mbed_Team | 0:b2d46804658c | 619 | dx_sym = -1; |
JDI_Mbed_Team | 0:b2d46804658c | 620 | } |
JDI_Mbed_Team | 3:c67b96404016 | 621 | if (dy == 0) { // horizontal line |
JDI_Mbed_Team | 0:b2d46804658c | 622 | if (x1 > x0) hline(x0,x1,y0,color); |
JDI_Mbed_Team | 0:b2d46804658c | 623 | else hline(x1,x0,y0,color); |
JDI_Mbed_Team | 0:b2d46804658c | 624 | return; |
JDI_Mbed_Team | 0:b2d46804658c | 625 | } |
JDI_Mbed_Team | 0:b2d46804658c | 626 | |
JDI_Mbed_Team | 0:b2d46804658c | 627 | if (dy > 0) { |
JDI_Mbed_Team | 0:b2d46804658c | 628 | dy_sym = 1; |
JDI_Mbed_Team | 0:b2d46804658c | 629 | } else { |
JDI_Mbed_Team | 0:b2d46804658c | 630 | dy_sym = -1; |
JDI_Mbed_Team | 0:b2d46804658c | 631 | } |
JDI_Mbed_Team | 0:b2d46804658c | 632 | |
JDI_Mbed_Team | 0:b2d46804658c | 633 | dx = dx_sym*dx; |
JDI_Mbed_Team | 0:b2d46804658c | 634 | dy = dy_sym*dy; |
JDI_Mbed_Team | 0:b2d46804658c | 635 | |
JDI_Mbed_Team | 0:b2d46804658c | 636 | dx_x2 = dx*2; |
JDI_Mbed_Team | 0:b2d46804658c | 637 | dy_x2 = dy*2; |
JDI_Mbed_Team | 0:b2d46804658c | 638 | |
JDI_Mbed_Team | 0:b2d46804658c | 639 | if (dx >= dy) { |
JDI_Mbed_Team | 0:b2d46804658c | 640 | di = dy_x2 - dx; |
JDI_Mbed_Team | 0:b2d46804658c | 641 | while (x0 != x1) { |
JDI_Mbed_Team | 0:b2d46804658c | 642 | |
JDI_Mbed_Team | 0:b2d46804658c | 643 | pixel(x0, y0, color); |
JDI_Mbed_Team | 0:b2d46804658c | 644 | x0 += dx_sym; |
JDI_Mbed_Team | 0:b2d46804658c | 645 | if (di<0) { |
JDI_Mbed_Team | 0:b2d46804658c | 646 | di += dy_x2; |
JDI_Mbed_Team | 0:b2d46804658c | 647 | } else { |
JDI_Mbed_Team | 0:b2d46804658c | 648 | di += dy_x2 - dx_x2; |
JDI_Mbed_Team | 0:b2d46804658c | 649 | y0 += dy_sym; |
JDI_Mbed_Team | 0:b2d46804658c | 650 | } |
JDI_Mbed_Team | 0:b2d46804658c | 651 | } |
JDI_Mbed_Team | 0:b2d46804658c | 652 | pixel(x0, y0, color); |
JDI_Mbed_Team | 0:b2d46804658c | 653 | } else { |
JDI_Mbed_Team | 0:b2d46804658c | 654 | di = dx_x2 - dy; |
JDI_Mbed_Team | 0:b2d46804658c | 655 | while (y0 != y1) { |
JDI_Mbed_Team | 0:b2d46804658c | 656 | pixel(x0, y0, color); |
JDI_Mbed_Team | 0:b2d46804658c | 657 | y0 += dy_sym; |
JDI_Mbed_Team | 0:b2d46804658c | 658 | if (di < 0) { |
JDI_Mbed_Team | 0:b2d46804658c | 659 | di += dx_x2; |
JDI_Mbed_Team | 0:b2d46804658c | 660 | } else { |
JDI_Mbed_Team | 0:b2d46804658c | 661 | di += dx_x2 - dy_x2; |
JDI_Mbed_Team | 0:b2d46804658c | 662 | x0 += dx_sym; |
JDI_Mbed_Team | 0:b2d46804658c | 663 | } |
JDI_Mbed_Team | 0:b2d46804658c | 664 | } |
JDI_Mbed_Team | 0:b2d46804658c | 665 | pixel(x0, y0, color); |
JDI_Mbed_Team | 0:b2d46804658c | 666 | } |
JDI_Mbed_Team | 0:b2d46804658c | 667 | return; |
JDI_Mbed_Team | 0:b2d46804658c | 668 | } |
JDI_Mbed_Team | 0:b2d46804658c | 669 | /** |
JDI_Mbed_Team | 0:b2d46804658c | 670 | * @brief dispay a rectangle line by color data |
JDI_Mbed_Team | 0:b2d46804658c | 671 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 672 | void memLCD8::rect(int x0, int y0, int x1, int y1, uint8_t color) |
JDI_Mbed_Team | 0:b2d46804658c | 673 | { |
JDI_Mbed_Team | 0:b2d46804658c | 674 | |
JDI_Mbed_Team | 0:b2d46804658c | 675 | if (x1 > x0) hline(x0,x1,y0,color); |
JDI_Mbed_Team | 0:b2d46804658c | 676 | else hline(x1,x0,y0,color); |
JDI_Mbed_Team | 0:b2d46804658c | 677 | |
JDI_Mbed_Team | 0:b2d46804658c | 678 | if (y1 > y0) vline(x0,y0,y1,color); |
JDI_Mbed_Team | 0:b2d46804658c | 679 | else vline(x0,y1,y0,color); |
JDI_Mbed_Team | 0:b2d46804658c | 680 | |
JDI_Mbed_Team | 0:b2d46804658c | 681 | if (x1 > x0) hline(x0,x1,y1,color); |
JDI_Mbed_Team | 0:b2d46804658c | 682 | else hline(x1,x0,y1,color); |
JDI_Mbed_Team | 0:b2d46804658c | 683 | |
JDI_Mbed_Team | 0:b2d46804658c | 684 | if (y1 > y0) vline(x1,y0,y1,color); |
JDI_Mbed_Team | 0:b2d46804658c | 685 | else vline(x1,y1,y0,color); |
JDI_Mbed_Team | 0:b2d46804658c | 686 | |
JDI_Mbed_Team | 0:b2d46804658c | 687 | return; |
JDI_Mbed_Team | 0:b2d46804658c | 688 | } |
JDI_Mbed_Team | 0:b2d46804658c | 689 | /** |
JDI_Mbed_Team | 0:b2d46804658c | 690 | * @brief dispay a filled rectangle by color data |
JDI_Mbed_Team | 0:b2d46804658c | 691 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 692 | void memLCD8::fillrect(int x0, int y0, int x1, int y1, uint8_t color) |
JDI_Mbed_Team | 0:b2d46804658c | 693 | { |
JDI_Mbed_Team | 0:b2d46804658c | 694 | int h = y1 - y0 + 1; |
JDI_Mbed_Team | 0:b2d46804658c | 695 | for (int i=0; i<h; i++) hline(x0, x1, y0+i, color); |
JDI_Mbed_Team | 0:b2d46804658c | 696 | } |
JDI_Mbed_Team | 0:b2d46804658c | 697 | /** |
JDI_Mbed_Team | 0:b2d46804658c | 698 | * @brief Transfer One Pixel Data with x,y allocation |
JDI_Mbed_Team | 0:b2d46804658c | 699 | * @param[in] int x : horizontal allocation left to right |
JDI_Mbed_Team | 0:b2d46804658c | 700 | * @param[in] int y : vertival allocation top to bottom |
JDI_Mbed_Team | 0:b2d46804658c | 701 | * @param[in] uint8_t color : the color data for Drawing 0x0X x is color data(RGBC) C is not used |
JDI_Mbed_Team | 0:b2d46804658c | 702 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 703 | void memLCD8::pixel(int x, int y, uint8_t color) |
JDI_Mbed_Team | 0:b2d46804658c | 704 | { |
JDI_Mbed_Team | 0:b2d46804658c | 705 | if(!(x % 2)) _dispBUF[y*_width/2+x/2] = _dispBUF[y*_width/2+x/2]&0x0F | (color << 4)&0xF0 ; //MASK 0000 1111 |
JDI_Mbed_Team | 0:b2d46804658c | 706 | else _dispBUF[y*_width/2+x/2] = _dispBUF[y*_width/2+x/2]&0xF0 | (color )&0x0F ; //MASK 1111 0000 |
JDI_Mbed_Team | 0:b2d46804658c | 707 | } |
JDI_Mbed_Team | 2:944f2968c19f | 708 | |
JDI_Mbed_Team | 0:b2d46804658c | 709 | /** |
JDI_Mbed_Team | 0:b2d46804658c | 710 | * @brief Get Edited data for SPI transfer |
JDI_Mbed_Team | 3:c67b96404016 | 711 | * @param[in] int x : horizontal allocation left to right |
JDI_Mbed_Team | 3:c67b96404016 | 712 | * @param[in] int y : vertival allocation top to bottom |
JDI_Mbed_Team | 3:c67b96404016 | 713 | * @param[in] uint8_t* buff : buffer data for Display |
JDI_Mbed_Team | 0:b2d46804658c | 714 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 715 | int* memLCD8::GetPixelValue(int _x, int _y ,uint8_t* buff) |
JDI_Mbed_Team | 0:b2d46804658c | 716 | { |
JDI_Mbed_Team | 0:b2d46804658c | 717 | //bitmap data = 4bit data => modify transfer data bit size; |
JDI_Mbed_Team | 0:b2d46804658c | 718 | switch(TrModeCommand) |
JDI_Mbed_Team | 0:b2d46804658c | 719 | { |
JDI_Mbed_Team | 0:b2d46804658c | 720 | case 0x90: //TrBIT4: |
JDI_Mbed_Team | 0:b2d46804658c | 721 | // buffer 2pixel/1byte => 2pixel/1byte buffe 2byte毎進める。 |
JDI_Mbed_Team | 6:4bfbc7e50577 | 722 | TrValue[0] = buff[_y* _width/2 + _x]; |
JDI_Mbed_Team | 0:b2d46804658c | 723 | break; |
JDI_Mbed_Team | 0:b2d46804658c | 724 | case 0x80://TrBIT3: |
JDI_Mbed_Team | 0:b2d46804658c | 725 | // buffer 2pixel/1byte => 3pixel-1subpixel/1bye (24 pixel/3byte) buffer 3byte毎進める。 |
JDI_Mbed_Team | 0:b2d46804658c | 726 | for(int j=0;j<3;j++) TrValue[j] = 0; |
JDI_Mbed_Team | 0:b2d46804658c | 727 | //for( int i = 0 ; i<12 ; i--) |
JDI_Mbed_Team | 0:b2d46804658c | 728 | { |
JDI_Mbed_Team | 0:b2d46804658c | 729 | //4 bit RGBN(Nは予備) => 3bit RGB |
JDI_Mbed_Team | 0:b2d46804658c | 730 | if( _width/2 > _x ) |
JDI_Mbed_Team | 0:b2d46804658c | 731 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 732 | TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x ]&0xE0) ) ); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 733 | TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x ]&0x0E) ) << 1); |
JDI_Mbed_Team | 0:b2d46804658c | 734 | } |
JDI_Mbed_Team | 0:b2d46804658c | 735 | if( _width/2 > _x + 1 ) |
JDI_Mbed_Team | 0:b2d46804658c | 736 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 737 | TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x + 1]&0xC0) ) >> 6); |
JDI_Mbed_Team | 0:b2d46804658c | 738 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 739 | TrValue[1] = TrValue[1] | ( ( (buff[_y* _width/2 + _x + 1]&0x20) ) << 2); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 740 | TrValue[1] = TrValue[1] | ( ( (buff[_y* _width/2 + _x + 1]&0x0E) ) << 3); |
JDI_Mbed_Team | 0:b2d46804658c | 741 | } |
JDI_Mbed_Team | 0:b2d46804658c | 742 | if( _width/2 > _x + 2 ) |
JDI_Mbed_Team | 0:b2d46804658c | 743 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 744 | TrValue[1] = TrValue[1] | ( ( (buff[_y* _width/2 + _x + 2]&0xE0) ) >> 4); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 745 | TrValue[1] = TrValue[1] | ( ( (buff[_y* _width/2 + _x + 2]&0x08) ) >> 3); |
JDI_Mbed_Team | 0:b2d46804658c | 746 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 747 | TrValue[2] = TrValue[2] | ( ( (buff[_y* _width/2 + _x + 2]&0x06) ) << 5); |
JDI_Mbed_Team | 0:b2d46804658c | 748 | } |
JDI_Mbed_Team | 0:b2d46804658c | 749 | if( _width/2 > _x + 3 ) |
JDI_Mbed_Team | 0:b2d46804658c | 750 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 751 | TrValue[2] = TrValue[2] | ( ( (buff[_y* _width/2 + _x + 3]&0xE0) ) >> 2); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 752 | TrValue[2] = TrValue[2] | ( ( (buff[_y* _width/2 + _x + 3]&0x0E) ) >> 1); |
JDI_Mbed_Team | 0:b2d46804658c | 753 | } |
JDI_Mbed_Team | 0:b2d46804658c | 754 | } |
JDI_Mbed_Team | 0:b2d46804658c | 755 | break; |
JDI_Mbed_Team | 0:b2d46804658c | 756 | case 0x88://TrBIT1: |
JDI_Mbed_Team | 0:b2d46804658c | 757 | // buffer 2pixel/1byte => 8 pixel/1byte buffe 4byte毎進める。 |
JDI_Mbed_Team | 0:b2d46804658c | 758 | for(int j=0;j<3;j++) TrValue[j] = 0; |
JDI_Mbed_Team | 0:b2d46804658c | 759 | for(int i = 0 ; i<4 ; i++) |
JDI_Mbed_Team | 0:b2d46804658c | 760 | { |
JDI_Mbed_Team | 0:b2d46804658c | 761 | //Green bit => monochrome bit |
JDI_Mbed_Team | 0:b2d46804658c | 762 | if( _width/2 > _x + i ) |
JDI_Mbed_Team | 0:b2d46804658c | 763 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 764 | TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x + i]&0x40) == 0 ? 0 : 1 ) << (7-i*2) ); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 765 | TrValue[0] = TrValue[0] | ( ( (buff[_y* _width/2 + _x + i]&0x04) == 0 ? 0 : 1 ) << (7-i*2)-1 ); |
JDI_Mbed_Team | 0:b2d46804658c | 766 | //pc2.printf("[%d+%d][%d]<0x%x>\n",_x,i,_y,_dispBUF[_y* _width/2 + _x + i]); |
JDI_Mbed_Team | 0:b2d46804658c | 767 | } |
JDI_Mbed_Team | 0:b2d46804658c | 768 | } |
JDI_Mbed_Team | 0:b2d46804658c | 769 | break; |
JDI_Mbed_Team | 0:b2d46804658c | 770 | } |
JDI_Mbed_Team | 0:b2d46804658c | 771 | return TrValue; |
JDI_Mbed_Team | 0:b2d46804658c | 772 | } |
JDI_Mbed_Team | 2:944f2968c19f | 773 | |
JDI_Mbed_Team | 0:b2d46804658c | 774 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 775 | * @brief Transfer Pixel Data from buffer to Display |
JDI_Mbed_Team | 3:c67b96404016 | 776 | * @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit |
JDI_Mbed_Team | 0:b2d46804658c | 777 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 778 | void memLCD8::writeDISP(int transfermode) // refresh whole display |
JDI_Mbed_Team | 3:c67b96404016 | 779 | { |
JDI_Mbed_Team | 3:c67b96404016 | 780 | char pol = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 781 | //char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW A 1010 |
JDI_Mbed_Team | 3:c67b96404016 | 782 | SetTransfermode(transfermode); |
JDI_Mbed_Team | 3:c67b96404016 | 783 | |
JDI_Mbed_Team | 3:c67b96404016 | 784 | // frame |
JDI_Mbed_Team | 3:c67b96404016 | 785 | for (int i=0; i<_height; i++) { |
JDI_Mbed_Team | 3:c67b96404016 | 786 | // line |
JDI_Mbed_Team | 3:c67b96404016 | 787 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 788 | _cs = 1; |
JDI_Mbed_Team | 3:c67b96404016 | 789 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 790 | _spi.write(TrModeCommand | (pol << 6) | (i+1)>>8 ); // COMMAND |
JDI_Mbed_Team | 3:c67b96404016 | 791 | //pc2.printf("com 0x%x\n",TrModeCommand | (pol << 6) | (i+1)>>8); |
JDI_Mbed_Team | 3:c67b96404016 | 792 | |
JDI_Mbed_Team | 3:c67b96404016 | 793 | _spi.write((i+1)& 0x00FF ); // V ADDR |
JDI_Mbed_Team | 3:c67b96404016 | 794 | //pc2.printf("v adr 0x%x\n",(i+1)& 0x00FF); |
JDI_Mbed_Team | 3:c67b96404016 | 795 | |
JDI_Mbed_Team | 3:c67b96404016 | 796 | for(int j=0; j<_width; j+=TrAdd) |
JDI_Mbed_Team | 3:c67b96404016 | 797 | { |
JDI_Mbed_Team | 3:c67b96404016 | 798 | GetPixelValue(j,i,_dispBUF); |
JDI_Mbed_Team | 3:c67b96404016 | 799 | //pc2.printf("data=[%d]{%d][%d]/[%d]\n",j*TrAdd,i,TrValue[0],TrAdd); |
JDI_Mbed_Team | 3:c67b96404016 | 800 | for(int k=0;k<TrValNum;k++) |
JDI_Mbed_Team | 3:c67b96404016 | 801 | _spi.write(TrValue[k]); |
JDI_Mbed_Team | 3:c67b96404016 | 802 | } |
JDI_Mbed_Team | 3:c67b96404016 | 803 | _spi.write(0x00); // DUMMY transfer |
JDI_Mbed_Team | 3:c67b96404016 | 804 | _spi.write(0x00); // DUMMY transfer |
JDI_Mbed_Team | 3:c67b96404016 | 805 | // wait_ms(1); //1.8Hz simulation |
JDI_Mbed_Team | 3:c67b96404016 | 806 | // wait_ms(2); //1.35Hz simulation |
JDI_Mbed_Team | 3:c67b96404016 | 807 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 808 | _cs = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 809 | if(pol) pol=0x00; |
JDI_Mbed_Team | 3:c67b96404016 | 810 | else pol=0x01; |
JDI_Mbed_Team | 3:c67b96404016 | 811 | } |
JDI_Mbed_Team | 3:c67b96404016 | 812 | } |
JDI_Mbed_Team | 3:c67b96404016 | 813 | |
JDI_Mbed_Team | 3:c67b96404016 | 814 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 815 | * @brief Transfer Pixel Data : from Start line number to Display of frame buffer |
JDI_Mbed_Team | 3:c67b96404016 | 816 | * @param[in] int startline : Start line number to Display |
JDI_Mbed_Team | 3:c67b96404016 | 817 | * @param[in] int endline : end line number to Display |
JDI_Mbed_Team | 3:c67b96404016 | 818 | * @param[in] int transfermode : instruction the transfer data size ,4bit,3bit,1bit |
JDI_Mbed_Team | 3:c67b96404016 | 819 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 820 | void memLCD8::writeDISP(int startline , int endline , int transfermode) // refresh display selected line |
JDI_Mbed_Team | 0:b2d46804658c | 821 | { |
JDI_Mbed_Team | 3:c67b96404016 | 822 | char pol = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 823 | //char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW A 1010 |
JDI_Mbed_Team | 3:c67b96404016 | 824 | SetTransfermode(transfermode); |
JDI_Mbed_Team | 3:c67b96404016 | 825 | |
JDI_Mbed_Team | 3:c67b96404016 | 826 | // frame |
JDI_Mbed_Team | 3:c67b96404016 | 827 | for (int i=startline; i<=endline; i++) { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 828 | if( i >= _height ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 829 | if( i <0 ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 830 | |
JDI_Mbed_Team | 3:c67b96404016 | 831 | // line |
JDI_Mbed_Team | 3:c67b96404016 | 832 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 833 | _cs = 1; |
JDI_Mbed_Team | 3:c67b96404016 | 834 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 835 | _spi.write(TrModeCommand | (pol << 6) | (i+1)>>8 ); // COMMAND |
JDI_Mbed_Team | 3:c67b96404016 | 836 | //pc2.printf("com 0x%x\n",TrModeCommand | (pol << 6) | (i+1)>>8); |
JDI_Mbed_Team | 3:c67b96404016 | 837 | |
JDI_Mbed_Team | 3:c67b96404016 | 838 | _spi.write((i+1)& 0x00FF ); // V ADDR |
JDI_Mbed_Team | 3:c67b96404016 | 839 | //pc2.printf("v adr 0x%x\n",(i+1)& 0x00FF); |
JDI_Mbed_Team | 3:c67b96404016 | 840 | |
JDI_Mbed_Team | 3:c67b96404016 | 841 | for(int j=0; j<_width; j+=TrAdd) |
JDI_Mbed_Team | 3:c67b96404016 | 842 | //for(int j=0; j<100; j+=TrAdd) |
JDI_Mbed_Team | 3:c67b96404016 | 843 | { |
JDI_Mbed_Team | 3:c67b96404016 | 844 | GetPixelValue(j,i,_dispBUF); |
JDI_Mbed_Team | 3:c67b96404016 | 845 | //pc2.printf("data=[%d]{%d][%d]/[%d]\n",j*TrAdd,i,TrValue[0],TrAdd); |
JDI_Mbed_Team | 3:c67b96404016 | 846 | for(int k=0;k<TrValNum;k++) |
JDI_Mbed_Team | 3:c67b96404016 | 847 | _spi.write(TrValue[k]); |
JDI_Mbed_Team | 3:c67b96404016 | 848 | } |
JDI_Mbed_Team | 3:c67b96404016 | 849 | _spi.write(0x00); // DUMMY transfer |
JDI_Mbed_Team | 3:c67b96404016 | 850 | _spi.write(0x00); // DUMMY transfer |
JDI_Mbed_Team | 3:c67b96404016 | 851 | // wait_ms(1); //1.8Hz simulation |
JDI_Mbed_Team | 3:c67b96404016 | 852 | // wait_ms(2); //1.35Hz simulation |
JDI_Mbed_Team | 3:c67b96404016 | 853 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 854 | _cs = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 855 | if(pol) pol=0x00; |
JDI_Mbed_Team | 3:c67b96404016 | 856 | else pol=0x01; |
JDI_Mbed_Team | 3:c67b96404016 | 857 | } |
JDI_Mbed_Team | 3:c67b96404016 | 858 | } |
JDI_Mbed_Team | 3:c67b96404016 | 859 | |
JDI_Mbed_Team | 3:c67b96404016 | 860 | /** |
JDI_Mbed_Team | 3:c67b96404016 | 861 | * @brief Transfer Pixel Data from frame buffer to Display |
JDI_Mbed_Team | 3:c67b96404016 | 862 | */ |
JDI_Mbed_Team | 3:c67b96404016 | 863 | void memLCD8::writeDISP(void) // refresh whole display |
JDI_Mbed_Team | 3:c67b96404016 | 864 | { |
JDI_Mbed_Team | 3:c67b96404016 | 865 | |
JDI_Mbed_Team | 3:c67b96404016 | 866 | char pol = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 867 | char command = 0x90; // 8b 1*0xNNNN *=POL x=AutoW A 1010 |
JDI_Mbed_Team | 3:c67b96404016 | 868 | |
JDI_Mbed_Team | 3:c67b96404016 | 869 | // frame |
JDI_Mbed_Team | 3:c67b96404016 | 870 | for (int i=0; i<_height; i++) { |
JDI_Mbed_Team | 3:c67b96404016 | 871 | // line |
JDI_Mbed_Team | 3:c67b96404016 | 872 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 873 | _cs = 1; |
JDI_Mbed_Team | 3:c67b96404016 | 874 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 875 | _spi.write(command | (pol << 6) | (i+1)>>8 ); // COMMAND |
JDI_Mbed_Team | 3:c67b96404016 | 876 | _spi.write((i+1)& 0x00FF ); // V ADDR |
JDI_Mbed_Team | 3:c67b96404016 | 877 | for(int j=0; j<_width/2; j++) _spi.write(_dispBUF[i*_width/2 + j]); |
JDI_Mbed_Team | 3:c67b96404016 | 878 | _spi.write(0x00); // DUMMY transfer |
JDI_Mbed_Team | 3:c67b96404016 | 879 | _spi.write(0x00); // DUMMY transfer |
JDI_Mbed_Team | 3:c67b96404016 | 880 | wait_us(6); |
JDI_Mbed_Team | 3:c67b96404016 | 881 | _cs = 0; |
JDI_Mbed_Team | 3:c67b96404016 | 882 | if(pol) pol=0x00; |
JDI_Mbed_Team | 3:c67b96404016 | 883 | else pol=0x01; |
JDI_Mbed_Team | 0:b2d46804658c | 884 | } |
JDI_Mbed_Team | 0:b2d46804658c | 885 | } |
JDI_Mbed_Team | 2:944f2968c19f | 886 | |
JDI_Mbed_Team | 0:b2d46804658c | 887 | /** |
JDI_Mbed_Team | 0:b2d46804658c | 888 | * @brief clear buffer data by background color data |
JDI_Mbed_Team | 0:b2d46804658c | 889 | */ |
JDI_Mbed_Team | 0:b2d46804658c | 890 | void memLCD8::clsBUF(void) |
JDI_Mbed_Team | 0:b2d46804658c | 891 | { |
JDI_Mbed_Team | 0:b2d46804658c | 892 | |
JDI_Mbed_Team | 0:b2d46804658c | 893 | for (int i=0; i<_height; i++) { |
JDI_Mbed_Team | 0:b2d46804658c | 894 | for (int j=0; j<_width; j++) { |
JDI_Mbed_Team | 0:b2d46804658c | 895 | pixel(j,i,_background); |
JDI_Mbed_Team | 0:b2d46804658c | 896 | } |
JDI_Mbed_Team | 0:b2d46804658c | 897 | } |
JDI_Mbed_Team | 0:b2d46804658c | 898 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 899 | #if MOVIEBUFF_MODE |
JDI_Mbed_Team | 6:4bfbc7e50577 | 900 | /** |
JDI_Mbed_Team | 6:4bfbc7e50577 | 901 | * @brief Transfer One Pixel Data with x,y allocation to Animation buffer |
JDI_Mbed_Team | 6:4bfbc7e50577 | 902 | * @param[in] int x : horizontal allocation left to right |
JDI_Mbed_Team | 6:4bfbc7e50577 | 903 | * @param[in] int y : vertival allocation top to bottom |
JDI_Mbed_Team | 6:4bfbc7e50577 | 904 | * @param[in] uint8_t color : the color data for Drawing 0x0X x is color data(RGBC) C is not used |
JDI_Mbed_Team | 6:4bfbc7e50577 | 905 | * @param[in] int memnu : animation buffer number. |
JDI_Mbed_Team | 6:4bfbc7e50577 | 906 | */ |
JDI_Mbed_Team | 6:4bfbc7e50577 | 907 | void memLCD8::movie_pixel(int x, int y, uint8_t color,int memnum) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 908 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 909 | //pc2.printf("movie_pixel[%d][%d]col[%d]\n",x,y,color); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 910 | if(!(x % 2)) _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2] = _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0x0F | (color << 4)&0xF0 ; //MASK 0000 1111 |
JDI_Mbed_Team | 6:4bfbc7e50577 | 911 | else _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2] = _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0xF0 | (color )&0x0F ; //MASK 1111 0000 |
JDI_Mbed_Team | 6:4bfbc7e50577 | 912 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 913 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 914 | /** |
JDI_Mbed_Team | 6:4bfbc7e50577 | 915 | * @brief Transfer Pixel Data of Animation buffer with x,y allocation to frame buffer. |
JDI_Mbed_Team | 6:4bfbc7e50577 | 916 | * @param[in] int sx : horizontal start allocation left to right |
JDI_Mbed_Team | 6:4bfbc7e50577 | 917 | * @param[in] int sy : vertival start allocation top to bottom |
JDI_Mbed_Team | 6:4bfbc7e50577 | 918 | * @param[in] int memnu : animation buffer number. |
JDI_Mbed_Team | 6:4bfbc7e50577 | 919 | */ |
JDI_Mbed_Team | 6:4bfbc7e50577 | 920 | void memLCD8::makeMovieFrame(int sx , int sy, int memnum) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 921 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 922 | int x,y; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 923 | //pc2.printf("1<%d,%d>\n",_width,_height); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 924 | for(y = 0; y < MOVIE_VERT_SIZE;y++) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 925 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 926 | for(x = 0; x < MOVIE_HORI_SIZE ;x+=2) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 927 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 928 | if( (sx + x) >= _width ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 929 | if( (sx + x) < 0 ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 930 | if( (sy + y) >= _height ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 931 | if( (sy + y) < 0 ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 932 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 933 | _dispBACKUPBUF[y*MOVIE_HORI_SIZE/2+x/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 934 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 935 | if( (_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0xF0) != 0 ) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 936 | _dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]&0x0F | _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0xF0; //MASK 0000 1111 |
JDI_Mbed_Team | 6:4bfbc7e50577 | 937 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 938 | if( (_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0x0F) != 0 ) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 939 | _dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]&0xF0 | _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]&0x0F; //MASK 0000 1111 |
JDI_Mbed_Team | 6:4bfbc7e50577 | 940 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 941 | //pc2.printf("dispMOVIEBUF[%d][%d] = %d\n",x,y,_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 942 | //_dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 943 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 944 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 945 | //pc2.printf("memnum=%d,x=%d,y=%d>sx=%d,sy=%d\n",memnum,sx,sy,(sx+x)-1,(sy+y)-1); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 946 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 947 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 948 | /** |
JDI_Mbed_Team | 6:4bfbc7e50577 | 949 | * @brief Transfer Pixel Data of Animation buffer with x,y allocation to frame buffer. animation data read right to left. |
JDI_Mbed_Team | 6:4bfbc7e50577 | 950 | * @param[in] int sx : horizontal start allocation left to right |
JDI_Mbed_Team | 6:4bfbc7e50577 | 951 | * @param[in] int sy : vertival start allocation top to bottom |
JDI_Mbed_Team | 6:4bfbc7e50577 | 952 | * @param[in] int memnu : animation buffer number. |
JDI_Mbed_Team | 6:4bfbc7e50577 | 953 | */ |
JDI_Mbed_Team | 6:4bfbc7e50577 | 954 | void memLCD8::makeMovieFrame_Reverse(int sx , int sy, int memnum) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 955 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 956 | int x,y; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 957 | //pc2.printf("1<%d,%d>\n",_width,_height); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 958 | for(y = 0; y < MOVIE_VERT_SIZE ;y++) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 959 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 960 | for(x = 0; x < MOVIE_HORI_SIZE ;x+=2) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 961 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 962 | if( (sx + x) >= _width ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 963 | if( (sx + x) < 0 ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 964 | if( (sy + y) >= _height ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 965 | if( (sy + y) < 0 ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 966 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 967 | _dispBACKUPBUF[y*MOVIE_HORI_SIZE/2+x/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 968 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 969 | if( (_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+(MOVIE_HORI_SIZE-2-x)/2]&0xF0) != 0 ) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 970 | _dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]&0x0F | _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+(MOVIE_HORI_SIZE-2-x)/2]&0xF0; //MASK 0000 1111 |
JDI_Mbed_Team | 6:4bfbc7e50577 | 971 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 972 | if( (_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+(MOVIE_HORI_SIZE-2-x)/2]&0x0F) != 0 ) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 973 | _dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]&0xF0 | _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+(MOVIE_HORI_SIZE-2-x)/2]&0x0F; //MASK 0000 1111 |
JDI_Mbed_Team | 6:4bfbc7e50577 | 974 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 975 | //pc2.printf("dispMOVIEBUF[%d][%d] = %d\n",x,y,_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 976 | //_dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 977 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 978 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 979 | //pc2.printf("memnum=%d,x=%d,y=%d>sx=%d,sy=%d\n",memnum,sx,sy,(sx+x)-1,(sy+y)-1); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 980 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 981 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 982 | /** |
JDI_Mbed_Team | 6:4bfbc7e50577 | 983 | * @brief Transfer Pixel Data of Animation buffer with x,y allocation to frame buffer. animation data bottom to top. |
JDI_Mbed_Team | 6:4bfbc7e50577 | 984 | * @param[in] int sx : horizontal start allocation left to right |
JDI_Mbed_Team | 6:4bfbc7e50577 | 985 | * @param[in] int sy : vertival start allocation top to bottom |
JDI_Mbed_Team | 6:4bfbc7e50577 | 986 | * @param[in] int memnu : animation buffer number. |
JDI_Mbed_Team | 6:4bfbc7e50577 | 987 | */ |
JDI_Mbed_Team | 6:4bfbc7e50577 | 988 | void memLCD8::makeMovieFrame_Updown(int sx , int sy, int memnum) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 989 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 990 | int x,y; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 991 | //pc2.printf("1<%d,%d>\n",_width,_height); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 992 | for(y = 0; y < MOVIE_VERT_SIZE ;y++) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 993 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 994 | for(x = 0; x < MOVIE_HORI_SIZE ;x+=2) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 995 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 996 | if( (sx + x) >= _width ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 997 | if( (sx + x) < 0 ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 998 | if( (sy + y) >= _height ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 999 | if( (sy + y) < 0 ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1000 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1001 | _dispBACKUPBUF[y*MOVIE_HORI_SIZE/2+x/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1002 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1003 | if( (_dispMOVIEBUF[memnum][(MOVIE_VERT_SIZE-1-y)*MOVIE_HORI_SIZE/2+x/2]&0xF0) != 0 ) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1004 | _dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]&0x0F | _dispMOVIEBUF[memnum][(MOVIE_VERT_SIZE-1-y)*MOVIE_HORI_SIZE/2+x/2]&0xF0; //MASK 0000 1111 |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1005 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1006 | if( (_dispMOVIEBUF[memnum][(MOVIE_VERT_SIZE-1-y)*MOVIE_HORI_SIZE/2+x/2]&0x0F) != 0 ) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1007 | _dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]&0xF0 | _dispMOVIEBUF[memnum][(MOVIE_VERT_SIZE-1-y)*MOVIE_HORI_SIZE/2+x/2]&0x0F; //MASK 0000 1111 |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1008 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1009 | //pc2.printf("dispMOVIEBUF[%d][%d] = %d\n",x,y,_dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1010 | //_dispBUF[(sy+y)*(_width)/2+(sx+x)/2] = _dispMOVIEBUF[memnum][y*MOVIE_HORI_SIZE/2+x/2]; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1011 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1012 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1013 | //pc2.printf("memnum=%d,x=%d,y=%d>sx=%d,sy=%d\n",memnum,sx,sy,(sx+x)-1,(sy+y)-1); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1014 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1015 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1016 | /** |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1017 | * @brief Transfer Pixel Data of backuped original frame buffer with x,y allocation to frame buffer. |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1018 | * @param[in] int sx : horizontal start allocation left to right |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1019 | * @param[in] int sy : vertival start allocation top to bottom |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1020 | * @param[in] int memnu : animation buffer number. |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1021 | */ |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1022 | void memLCD8::RestoreMovieFrame(int sx , int sy, int memnum) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1023 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1024 | int x,y; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1025 | //pc2.printf("1<%d,%d>\n",_width,_height); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1026 | for(y = 0; y < MOVIE_VERT_SIZE;y++) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1027 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1028 | for(x = 0; x < MOVIE_HORI_SIZE ;x++) |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1029 | { |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1030 | if( (sx + x) >= _width ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1031 | if( (sx + x) < 0 ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1032 | if( (sy + y) >= _height ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1033 | if( (sy + y) < 0 ) continue; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1034 | _dispBUF[(sy+y)*(_width)/2+(sx+x)/2]=_dispBACKUPBUF[y*MOVIE_HORI_SIZE/2+x/2]; |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1035 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1036 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1037 | //pc2.printf("memnum=%d,x=%d,y=%d>sx=%d,sy=%d\n",memnum,sx,sy,(sx+x)-1,(sy+y)-1); |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1038 | |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1039 | } |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1040 | //end MOVIEBUFF_MODE |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1041 | #endif |
JDI_Mbed_Team | 6:4bfbc7e50577 | 1042 | //end FRAMEBUFF_MODE |
JDI_Mbed_Team | 3:c67b96404016 | 1043 | #endif |
JDI_Mbed_Team | 2:944f2968c19f | 1044 |