ssd1306 stm32l010
Dependents: oled_test7_16x24_010_1 i2c_HT16K33_test1_767_3 HAL_oled_16x24_010_1
SSD1308.cpp@1:20e48680a5f8, 2022-08-04 (annotated)
- Committer:
- caa45040
- Date:
- Thu Aug 04 14:35:32 2022 +0000
- Revision:
- 1:20e48680a5f8
- Parent:
- 0:5d70351255d1
stm32f767 oled hal
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
caa45040 | 0:5d70351255d1 | 1 | |
caa45040 | 0:5d70351255d1 | 2 | #include "mbed.h" |
caa45040 | 0:5d70351255d1 | 3 | #include "SSD1308.h" |
caa45040 | 0:5d70351255d1 | 4 | |
caa45040 | 0:5d70351255d1 | 5 | //#include "font_8x8.h" |
caa45040 | 0:5d70351255d1 | 6 | #include "font_16x24.h" |
caa45040 | 0:5d70351255d1 | 7 | |
caa45040 | 0:5d70351255d1 | 8 | |
caa45040 | 0:5d70351255d1 | 9 | //i2c initialization |
caa45040 | 0:5d70351255d1 | 10 | //I2C i2c(I2C_SDA, I2C_SCL); //767 |
caa45040 | 1:20e48680a5f8 | 11 | //I2C i2c(PA_10, PA_9); //010 |
caa45040 | 0:5d70351255d1 | 12 | |
caa45040 | 0:5d70351255d1 | 13 | |
caa45040 | 0:5d70351255d1 | 14 | //void fff(char *str1) |
caa45040 | 0:5d70351255d1 | 15 | //{ |
caa45040 | 0:5d70351255d1 | 16 | // printf(str1);//debug |
caa45040 | 0:5d70351255d1 | 17 | //} |
caa45040 | 0:5d70351255d1 | 18 | |
caa45040 | 0:5d70351255d1 | 19 | |
caa45040 | 0:5d70351255d1 | 20 | |
caa45040 | 0:5d70351255d1 | 21 | /** |
caa45040 | 0:5d70351255d1 | 22 | *@brief Constructor |
caa45040 | 0:5d70351255d1 | 23 | *@param I2C *i2c reference to i2c |
caa45040 | 0:5d70351255d1 | 24 | *@param uint8_t deviceAddress slaveaddress |
caa45040 | 0:5d70351255d1 | 25 | */ |
caa45040 | 0:5d70351255d1 | 26 | //SSD1308::SSD1308(I2C *i2c, uint8_t deviceAddress) : _i2c(i2c) { |
caa45040 | 1:20e48680a5f8 | 27 | //SSD1308::SSD1308( uint8_t deviceAddress) { |
caa45040 | 1:20e48680a5f8 | 28 | SSD1308::SSD1308( I2C_HandleTypeDef* hi2c , uint8_t deviceAddress ) { |
caa45040 | 0:5d70351255d1 | 29 | |
caa45040 | 1:20e48680a5f8 | 30 | _hi2c = hi2c; |
caa45040 | 0:5d70351255d1 | 31 | |
caa45040 | 0:5d70351255d1 | 32 | _writeOpcode = deviceAddress & 0xFE; // low order bit = 0 for write |
caa45040 | 0:5d70351255d1 | 33 | _readOpcode = deviceAddress | 0x01; // low order bit = 1 for read |
caa45040 | 0:5d70351255d1 | 34 | |
caa45040 | 0:5d70351255d1 | 35 | initialize(); |
caa45040 | 0:5d70351255d1 | 36 | }//SSD1308 |
caa45040 | 0:5d70351255d1 | 37 | |
caa45040 | 0:5d70351255d1 | 38 | //イニシャライズ |
caa45040 | 0:5d70351255d1 | 39 | void SSD1308::initialize() |
caa45040 | 0:5d70351255d1 | 40 | { |
caa45040 | 0:5d70351255d1 | 41 | |
caa45040 | 0:5d70351255d1 | 42 | //fff("initialize\r\n");//debug |
caa45040 | 0:5d70351255d1 | 43 | |
caa45040 | 0:5d70351255d1 | 44 | setHorizontalAddressingMode(); //メモリーアクセスモード |
caa45040 | 0:5d70351255d1 | 45 | |
caa45040 | 0:5d70351255d1 | 46 | clearDisplay(); |
caa45040 | 0:5d70351255d1 | 47 | |
caa45040 | 0:5d70351255d1 | 48 | //setInverted(false); //反転 |
caa45040 | 0:5d70351255d1 | 49 | |
caa45040 | 0:5d70351255d1 | 50 | setDisplayOn(); |
caa45040 | 0:5d70351255d1 | 51 | |
caa45040 | 0:5d70351255d1 | 52 | //fff("\r\n"); |
caa45040 | 0:5d70351255d1 | 53 | |
caa45040 | 0:5d70351255d1 | 54 | //charge pump add=>ca45040 |
caa45040 | 1:20e48680a5f8 | 55 | //i2c.write(SSD1308_SA0, "\200\215\200\024", 4); //0x80,0x8d,0x80,0x14 |
caa45040 | 1:20e48680a5f8 | 56 | HAL_I2C_Master_Transmit( _hi2c , _writeOpcode , (uint8_t*)"\200\215\200\024", 4, 3000); |
caa45040 | 0:5d70351255d1 | 57 | //set access |
caa45040 | 0:5d70351255d1 | 58 | //setDisplayFlip(false, false); |
caa45040 | 0:5d70351255d1 | 59 | |
caa45040 | 0:5d70351255d1 | 60 | |
caa45040 | 1:20e48680a5f8 | 61 | |
caa45040 | 1:20e48680a5f8 | 62 | |
caa45040 | 1:20e48680a5f8 | 63 | // uint8_t buf[16]; |
caa45040 | 1:20e48680a5f8 | 64 | // |
caa45040 | 1:20e48680a5f8 | 65 | // |
caa45040 | 1:20e48680a5f8 | 66 | // buf[0]=0; |
caa45040 | 1:20e48680a5f8 | 67 | // buf[1]= 0x55; |
caa45040 | 1:20e48680a5f8 | 68 | // |
caa45040 | 1:20e48680a5f8 | 69 | // HAL_I2C_Master_Transmit( _hi2c , _writeOpcode , buf, 2, 3000); |
caa45040 | 1:20e48680a5f8 | 70 | // wait_ms(600); |
caa45040 | 1:20e48680a5f8 | 71 | // |
caa45040 | 1:20e48680a5f8 | 72 | // buf[0]=0; |
caa45040 | 1:20e48680a5f8 | 73 | // buf[1]= 0xaa; |
caa45040 | 1:20e48680a5f8 | 74 | // |
caa45040 | 1:20e48680a5f8 | 75 | // |
caa45040 | 1:20e48680a5f8 | 76 | // HAL_I2C_Master_Transmit( _hi2c , _writeOpcode , buf, 2, 3000); |
caa45040 | 1:20e48680a5f8 | 77 | // wait_ms(600); |
caa45040 | 1:20e48680a5f8 | 78 | |
caa45040 | 1:20e48680a5f8 | 79 | |
caa45040 | 1:20e48680a5f8 | 80 | |
caa45040 | 1:20e48680a5f8 | 81 | |
caa45040 | 1:20e48680a5f8 | 82 | |
caa45040 | 0:5d70351255d1 | 83 | |
caa45040 | 0:5d70351255d1 | 84 | }//initialize |
caa45040 | 0:5d70351255d1 | 85 | |
caa45040 | 0:5d70351255d1 | 86 | //クリアディスプレー |
caa45040 | 0:5d70351255d1 | 87 | void SSD1308::clearDisplay() |
caa45040 | 0:5d70351255d1 | 88 | { |
caa45040 | 0:5d70351255d1 | 89 | |
caa45040 | 0:5d70351255d1 | 90 | //fff("clearDisplay\r\n");//debug |
caa45040 | 0:5d70351255d1 | 91 | |
caa45040 | 0:5d70351255d1 | 92 | //setDisplayOff(); |
caa45040 | 0:5d70351255d1 | 93 | setPageAddress(0, MAX_PAGE); // all pages |
caa45040 | 0:5d70351255d1 | 94 | setColumnAddress(0, MAX_COL); // all columns |
caa45040 | 0:5d70351255d1 | 95 | |
caa45040 | 0:5d70351255d1 | 96 | /* |
caa45040 | 0:5d70351255d1 | 97 | for (uint8_t page = 0; page < PAGES; page++) { |
caa45040 | 0:5d70351255d1 | 98 | for (uint8_t col = 0; col < COLUMNS; col++) { |
caa45040 | 0:5d70351255d1 | 99 | _sendData(0x00); |
caa45040 | 0:5d70351255d1 | 100 | } |
caa45040 | 0:5d70351255d1 | 101 | } |
caa45040 | 0:5d70351255d1 | 102 | */ |
caa45040 | 0:5d70351255d1 | 103 | |
caa45040 | 0:5d70351255d1 | 104 | //128*64/8=1024 |
caa45040 | 1:20e48680a5f8 | 105 | uint8_t databytes[2] = { DATA_MODE, 0x00 }; |
caa45040 | 0:5d70351255d1 | 106 | for (int icount = 0; icount < 1024; icount++) { |
caa45040 | 0:5d70351255d1 | 107 | //_sendData(0x00); |
caa45040 | 0:5d70351255d1 | 108 | |
caa45040 | 1:20e48680a5f8 | 109 | //i2c.write(_writeOpcode, databytes, 2); |
caa45040 | 1:20e48680a5f8 | 110 | HAL_I2C_Master_Transmit( _hi2c , _writeOpcode , databytes, 2, 3000); |
caa45040 | 0:5d70351255d1 | 111 | } |
caa45040 | 0:5d70351255d1 | 112 | |
caa45040 | 0:5d70351255d1 | 113 | //setDisplayOn(); |
caa45040 | 0:5d70351255d1 | 114 | }//clearDisplay |
caa45040 | 0:5d70351255d1 | 115 | |
caa45040 | 0:5d70351255d1 | 116 | //ライトビットマップ |
caa45040 | 0:5d70351255d1 | 117 | void SSD1308::writeBitmap(uint8_t* data, |
caa45040 | 0:5d70351255d1 | 118 | uint8_t start_page, uint8_t end_page, |
caa45040 | 0:5d70351255d1 | 119 | uint8_t start_col, uint8_t end_col) |
caa45040 | 0:5d70351255d1 | 120 | { |
caa45040 | 0:5d70351255d1 | 121 | |
caa45040 | 0:5d70351255d1 | 122 | //fff(" writeBitmap\r\n");//debug |
caa45040 | 0:5d70351255d1 | 123 | |
caa45040 | 0:5d70351255d1 | 124 | int count = (end_page - start_page + 1) * (end_col - start_col + 1); |
caa45040 | 0:5d70351255d1 | 125 | |
caa45040 | 0:5d70351255d1 | 126 | //setDisplayOff(); |
caa45040 | 0:5d70351255d1 | 127 | setPageAddress(start_page, end_page); // set page window |
caa45040 | 0:5d70351255d1 | 128 | setColumnAddress(start_col, end_col); // set column window |
caa45040 | 0:5d70351255d1 | 129 | |
caa45040 | 0:5d70351255d1 | 130 | |
caa45040 | 0:5d70351255d1 | 131 | |
caa45040 | 1:20e48680a5f8 | 132 | uint8_t databytes[2] = { DATA_MODE, 0 }; |
caa45040 | 0:5d70351255d1 | 133 | for (int i=0; i<count; i++) { |
caa45040 | 0:5d70351255d1 | 134 | //_sendData(data[i]); // Write Data |
caa45040 | 0:5d70351255d1 | 135 | |
caa45040 | 0:5d70351255d1 | 136 | databytes[1] = data[i]; |
caa45040 | 1:20e48680a5f8 | 137 | //i2c.write(_writeOpcode, databytes, 2); |
caa45040 | 1:20e48680a5f8 | 138 | HAL_I2C_Master_Transmit( _hi2c , _writeOpcode , databytes , 2, 3000); |
caa45040 | 0:5d70351255d1 | 139 | } |
caa45040 | 0:5d70351255d1 | 140 | |
caa45040 | 0:5d70351255d1 | 141 | |
caa45040 | 0:5d70351255d1 | 142 | //setDisplayOn(); |
caa45040 | 0:5d70351255d1 | 143 | }//writeBitmap |
caa45040 | 0:5d70351255d1 | 144 | |
caa45040 | 0:5d70351255d1 | 145 | |
caa45040 | 0:5d70351255d1 | 146 | //ライトビッグキャラ |
caa45040 | 0:5d70351255d1 | 147 | void SSD1308::writeBigChar(uint8_t row, uint8_t col, char chr) |
caa45040 | 0:5d70351255d1 | 148 | { |
caa45040 | 0:5d70351255d1 | 149 | |
caa45040 | 0:5d70351255d1 | 150 | //fff("writeBigChar\r\n");//debug |
caa45040 | 0:5d70351255d1 | 151 | |
caa45040 | 0:5d70351255d1 | 152 | |
caa45040 | 0:5d70351255d1 | 153 | writeBitmap((uint8_t*) font_16x24[int(chr) - FONT16x24_START], |
caa45040 | 0:5d70351255d1 | 154 | row, (row + FONT16x24_BYTES - 1), |
caa45040 | 0:5d70351255d1 | 155 | col, (col + FONT16x24_WIDTH - 1)); |
caa45040 | 0:5d70351255d1 | 156 | |
caa45040 | 0:5d70351255d1 | 157 | |
caa45040 | 0:5d70351255d1 | 158 | }//writeBigChar |
caa45040 | 0:5d70351255d1 | 159 | |
caa45040 | 0:5d70351255d1 | 160 | |
caa45040 | 0:5d70351255d1 | 161 | /* |
caa45040 | 0:5d70351255d1 | 162 | //センドコマンド コマンドx1 |
caa45040 | 0:5d70351255d1 | 163 | void SSD1308::_sendCommand(uint8_t command) |
caa45040 | 0:5d70351255d1 | 164 | { |
caa45040 | 0:5d70351255d1 | 165 | char databytes[2] = { COMMAND_MODE, command }; |
caa45040 | 0:5d70351255d1 | 166 | i2c.write(_writeOpcode,databytes, 2); |
caa45040 | 0:5d70351255d1 | 167 | //_i2c.write(_writeOpcode, databytes, 2); // Write command |
caa45040 | 0:5d70351255d1 | 168 | }// |
caa45040 | 0:5d70351255d1 | 169 | */ |
caa45040 | 0:5d70351255d1 | 170 | |
caa45040 | 0:5d70351255d1 | 171 | |
caa45040 | 0:5d70351255d1 | 172 | |
caa45040 | 0:5d70351255d1 | 173 | /* |
caa45040 | 0:5d70351255d1 | 174 | //センドコマンド コマンドx1 パラメーターx1 |
caa45040 | 0:5d70351255d1 | 175 | void SSD1308::_sendCommand(uint8_t command, uint8_t param1) |
caa45040 | 0:5d70351255d1 | 176 | { |
caa45040 | 0:5d70351255d1 | 177 | char databytes[4] = { COMMAND_MODE, command, COMMAND_MODE, param1 }; |
caa45040 | 0:5d70351255d1 | 178 | |
caa45040 | 0:5d70351255d1 | 179 | i2c.write(_writeOpcode, databytes, 4); |
caa45040 | 0:5d70351255d1 | 180 | //_i2c.write(_writeOpcode, databytes, 4); // Write command |
caa45040 | 0:5d70351255d1 | 181 | |
caa45040 | 0:5d70351255d1 | 182 | }// |
caa45040 | 0:5d70351255d1 | 183 | */ |
caa45040 | 0:5d70351255d1 | 184 | |
caa45040 | 0:5d70351255d1 | 185 | /* |
caa45040 | 0:5d70351255d1 | 186 | //センドコマンド コマンドx1 パラメーターx2 |
caa45040 | 0:5d70351255d1 | 187 | void SSD1308::_sendCommand(uint8_t command, uint8_t param1, uint8_t param2) |
caa45040 | 0:5d70351255d1 | 188 | { |
caa45040 | 0:5d70351255d1 | 189 | char databytes[6] = { COMMAND_MODE, command, COMMAND_MODE, param1, COMMAND_MODE, param2 }; |
caa45040 | 0:5d70351255d1 | 190 | i2c.write(_writeOpcode, databytes, 6); |
caa45040 | 0:5d70351255d1 | 191 | //_i2c.write(_writeOpcode, databytes, 6); // Write command |
caa45040 | 0:5d70351255d1 | 192 | |
caa45040 | 0:5d70351255d1 | 193 | }// |
caa45040 | 0:5d70351255d1 | 194 | */ |
caa45040 | 0:5d70351255d1 | 195 | |
caa45040 | 0:5d70351255d1 | 196 | /* |
caa45040 | 0:5d70351255d1 | 197 | //センドコマンド コマンドx1 パラメーターx5 |
caa45040 | 0:5d70351255d1 | 198 | void SSD1308::_sendCommand(uint8_t command, uint8_t param1, uint8_t param2, |
caa45040 | 0:5d70351255d1 | 199 | uint8_t param3, uint8_t param4, |
caa45040 | 0:5d70351255d1 | 200 | uint8_t param5) |
caa45040 | 0:5d70351255d1 | 201 | { |
caa45040 | 0:5d70351255d1 | 202 | char databytes[12] = { COMMAND_MODE, command, COMMAND_MODE, param1, COMMAND_MODE, param2, |
caa45040 | 0:5d70351255d1 | 203 | COMMAND_MODE, param3, COMMAND_MODE, param4, COMMAND_MODE, param5 }; |
caa45040 | 0:5d70351255d1 | 204 | i2c.write(_writeOpcode, databytes, 12); |
caa45040 | 0:5d70351255d1 | 205 | //_i2c.write(_writeOpcode, databytes, 12); // Write command |
caa45040 | 0:5d70351255d1 | 206 | }// |
caa45040 | 0:5d70351255d1 | 207 | */ |
caa45040 | 0:5d70351255d1 | 208 | |
caa45040 | 0:5d70351255d1 | 209 | /* |
caa45040 | 0:5d70351255d1 | 210 | //センドコマンド コマンドx1 パラメーターx6 |
caa45040 | 0:5d70351255d1 | 211 | void SSD1308::_sendCommand(uint8_t command, uint8_t param1, uint8_t param2, |
caa45040 | 0:5d70351255d1 | 212 | uint8_t param3, uint8_t param4, |
caa45040 | 0:5d70351255d1 | 213 | uint8_t param5, uint8_t param6) |
caa45040 | 0:5d70351255d1 | 214 | { |
caa45040 | 0:5d70351255d1 | 215 | char databytes[14] = { COMMAND_MODE, command, COMMAND_MODE, param1, COMMAND_MODE, param2, |
caa45040 | 0:5d70351255d1 | 216 | COMMAND_MODE, param3, COMMAND_MODE, param4, COMMAND_MODE, param5, COMMAND_MODE, param6 }; |
caa45040 | 0:5d70351255d1 | 217 | i2c.write(_writeOpcode, databytes, 14); |
caa45040 | 0:5d70351255d1 | 218 | //_i2c.write(_writeOpcode, databytes, 14); // Write command |
caa45040 | 0:5d70351255d1 | 219 | |
caa45040 | 0:5d70351255d1 | 220 | }// |
caa45040 | 0:5d70351255d1 | 221 | */ |
caa45040 | 0:5d70351255d1 | 222 | |
caa45040 | 0:5d70351255d1 | 223 | /* |
caa45040 | 0:5d70351255d1 | 224 | //センドデータ コマンドx1 |
caa45040 | 0:5d70351255d1 | 225 | void SSD1308::_sendData(uint8_t data) |
caa45040 | 0:5d70351255d1 | 226 | { |
caa45040 | 0:5d70351255d1 | 227 | char databytes[2] = { DATA_MODE, data }; |
caa45040 | 0:5d70351255d1 | 228 | i2c.write(_writeOpcode, databytes, 2); |
caa45040 | 0:5d70351255d1 | 229 | //_i2c.write(_writeOpcode, databytes, 2); // Write Data |
caa45040 | 0:5d70351255d1 | 230 | }// |
caa45040 | 0:5d70351255d1 | 231 | */ |
caa45040 | 0:5d70351255d1 | 232 | |
caa45040 | 0:5d70351255d1 | 233 | /* |
caa45040 | 0:5d70351255d1 | 234 | //センドデータ コマンドx1 データ |
caa45040 | 0:5d70351255d1 | 235 | void SSD1308::_sendData(uint8_t len, uint8_t* data) |
caa45040 | 0:5d70351255d1 | 236 | { |
caa45040 | 0:5d70351255d1 | 237 | for (int i=0; i<len ; i++) { |
caa45040 | 0:5d70351255d1 | 238 | _sendData(data[i]); // Write Data |
caa45040 | 0:5d70351255d1 | 239 | } |
caa45040 | 0:5d70351255d1 | 240 | }//_sendData |
caa45040 | 0:5d70351255d1 | 241 | */ |
caa45040 | 0:5d70351255d1 | 242 | |
caa45040 | 0:5d70351255d1 | 243 | //セット |
caa45040 | 0:5d70351255d1 | 244 | void SSD1308::setHorizontalAddressingMode() |
caa45040 | 0:5d70351255d1 | 245 | { |
caa45040 | 0:5d70351255d1 | 246 | |
caa45040 | 0:5d70351255d1 | 247 | //fff("setHorizontalAddressingMode\r\n");//debug |
caa45040 | 0:5d70351255d1 | 248 | |
caa45040 | 0:5d70351255d1 | 249 | setMemoryAddressingMode(HORIZONTAL_ADDRESSING_MODE); |
caa45040 | 0:5d70351255d1 | 250 | }//setHorizontalAddressingMode |
caa45040 | 0:5d70351255d1 | 251 | |
caa45040 | 0:5d70351255d1 | 252 | //セットメモリーアドレシングモード |
caa45040 | 0:5d70351255d1 | 253 | void SSD1308::setMemoryAddressingMode(uint8_t mode) |
caa45040 | 0:5d70351255d1 | 254 | { |
caa45040 | 0:5d70351255d1 | 255 | |
caa45040 | 0:5d70351255d1 | 256 | //fff("setMemoryAddressingMode\r\n"); |
caa45040 | 0:5d70351255d1 | 257 | |
caa45040 | 0:5d70351255d1 | 258 | //_sendCommand(SET_MEMORY_ADDRESSING_MODE, mode); |
caa45040 | 0:5d70351255d1 | 259 | |
caa45040 | 0:5d70351255d1 | 260 | |
caa45040 | 1:20e48680a5f8 | 261 | uint8_t databytes[4] = { COMMAND_MODE, SET_MEMORY_ADDRESSING_MODE, COMMAND_MODE, mode }; |
caa45040 | 0:5d70351255d1 | 262 | |
caa45040 | 1:20e48680a5f8 | 263 | //i2c.write(_writeOpcode, databytes, 4); |
caa45040 | 1:20e48680a5f8 | 264 | HAL_I2C_Master_Transmit( _hi2c , _writeOpcode , databytes, 4, 3000); |
caa45040 | 0:5d70351255d1 | 265 | |
caa45040 | 0:5d70351255d1 | 266 | |
caa45040 | 0:5d70351255d1 | 267 | }//setMemoryAddressingMode |
caa45040 | 0:5d70351255d1 | 268 | |
caa45040 | 0:5d70351255d1 | 269 | //セットページアドレス |
caa45040 | 0:5d70351255d1 | 270 | void SSD1308::setPageAddress(uint8_t start, uint8_t end) |
caa45040 | 0:5d70351255d1 | 271 | { |
caa45040 | 0:5d70351255d1 | 272 | |
caa45040 | 0:5d70351255d1 | 273 | //fff("setPageAddress\r\n"); |
caa45040 | 0:5d70351255d1 | 274 | |
caa45040 | 0:5d70351255d1 | 275 | //_sendCommand(SET_PAGE_ADDRESS, start, end); |
caa45040 | 0:5d70351255d1 | 276 | |
caa45040 | 1:20e48680a5f8 | 277 | uint8_t databytes[6] = { COMMAND_MODE, SET_PAGE_ADDRESS, COMMAND_MODE, start, COMMAND_MODE, end }; |
caa45040 | 1:20e48680a5f8 | 278 | //i2c.write(_writeOpcode, databytes, 6); |
caa45040 | 1:20e48680a5f8 | 279 | HAL_I2C_Master_Transmit( _hi2c , _writeOpcode , databytes, 6, 3000); |
caa45040 | 0:5d70351255d1 | 280 | |
caa45040 | 0:5d70351255d1 | 281 | |
caa45040 | 0:5d70351255d1 | 282 | }//setPageAddress |
caa45040 | 0:5d70351255d1 | 283 | |
caa45040 | 0:5d70351255d1 | 284 | //セットカラムアクセス |
caa45040 | 0:5d70351255d1 | 285 | void SSD1308::setColumnAddress(uint8_t start, uint8_t end) |
caa45040 | 0:5d70351255d1 | 286 | { |
caa45040 | 0:5d70351255d1 | 287 | |
caa45040 | 0:5d70351255d1 | 288 | //fff("setColumnAddress"); |
caa45040 | 0:5d70351255d1 | 289 | |
caa45040 | 0:5d70351255d1 | 290 | //_sendCommand(SET_COLUMN_ADDRESS, start, end); |
caa45040 | 0:5d70351255d1 | 291 | |
caa45040 | 1:20e48680a5f8 | 292 | uint8_t databytes[6] = { COMMAND_MODE, SET_COLUMN_ADDRESS, COMMAND_MODE, start, COMMAND_MODE, end }; |
caa45040 | 1:20e48680a5f8 | 293 | //i2c.write(_writeOpcode, databytes, 6); |
caa45040 | 1:20e48680a5f8 | 294 | HAL_I2C_Master_Transmit( _hi2c , _writeOpcode , databytes, 6, 3000); |
caa45040 | 0:5d70351255d1 | 295 | |
caa45040 | 0:5d70351255d1 | 296 | }//setColumnAddress |
caa45040 | 0:5d70351255d1 | 297 | |
caa45040 | 0:5d70351255d1 | 298 | //セットディスプレーオン |
caa45040 | 0:5d70351255d1 | 299 | void SSD1308::setDisplayOn() |
caa45040 | 0:5d70351255d1 | 300 | { |
caa45040 | 0:5d70351255d1 | 301 | |
caa45040 | 0:5d70351255d1 | 302 | //fff("setDisplayOn\r\n");//debug |
caa45040 | 0:5d70351255d1 | 303 | |
caa45040 | 0:5d70351255d1 | 304 | //_sendCommand(SET_DISPLAY_POWER_ON); |
caa45040 | 0:5d70351255d1 | 305 | |
caa45040 | 0:5d70351255d1 | 306 | |
caa45040 | 1:20e48680a5f8 | 307 | uint8_t databytes[2] = { COMMAND_MODE, SET_DISPLAY_POWER_ON }; |
caa45040 | 1:20e48680a5f8 | 308 | //i2c.write(_writeOpcode,databytes, 2); |
caa45040 | 1:20e48680a5f8 | 309 | HAL_I2C_Master_Transmit( _hi2c , _writeOpcode , databytes, 2, 3000); |
caa45040 | 0:5d70351255d1 | 310 | |
caa45040 | 0:5d70351255d1 | 311 | }//setDisplayOn |
caa45040 | 0:5d70351255d1 | 312 | |
caa45040 | 0:5d70351255d1 | 313 | |
caa45040 | 0:5d70351255d1 | 314 | /* |
caa45040 | 0:5d70351255d1 | 315 | //セットディスプレーオフ |
caa45040 | 0:5d70351255d1 | 316 | void SSD1308::setDisplayOff() |
caa45040 | 0:5d70351255d1 | 317 | { |
caa45040 | 0:5d70351255d1 | 318 | _sendCommand(SET_DISPLAY_POWER_OFF); |
caa45040 | 0:5d70351255d1 | 319 | }//setDisplayOff |
caa45040 | 0:5d70351255d1 | 320 | */ |
caa45040 | 0:5d70351255d1 | 321 | |
caa45040 | 0:5d70351255d1 | 322 | /* |
caa45040 | 0:5d70351255d1 | 323 | //セットディスプレー Flip |
caa45040 | 0:5d70351255d1 | 324 | void SSD1308::setDisplayFlip(bool left, bool down) |
caa45040 | 0:5d70351255d1 | 325 | { |
caa45040 | 0:5d70351255d1 | 326 | if (left) { |
caa45040 | 0:5d70351255d1 | 327 | // column address 0 is mapped to SEG0 (Reset) |
caa45040 | 0:5d70351255d1 | 328 | _sendCommand(SET_SEGMENT_REMAP_0); |
caa45040 | 0:5d70351255d1 | 329 | } else { |
caa45040 | 0:5d70351255d1 | 330 | // column address 127 is mapped to SEG0 |
caa45040 | 0:5d70351255d1 | 331 | _sendCommand(SET_SEGMENT_REMAP_127); |
caa45040 | 0:5d70351255d1 | 332 | } |
caa45040 | 0:5d70351255d1 | 333 | |
caa45040 | 0:5d70351255d1 | 334 | if (down) { |
caa45040 | 0:5d70351255d1 | 335 | // Reset mode |
caa45040 | 0:5d70351255d1 | 336 | _sendCommand(SET_COMMON_REMAP_0); |
caa45040 | 0:5d70351255d1 | 337 | } else { |
caa45040 | 0:5d70351255d1 | 338 | // Flip Up/Down (Need to rewrite display before H effect shows) |
caa45040 | 0:5d70351255d1 | 339 | _sendCommand(SET_COMMON_REMAP_63); |
caa45040 | 0:5d70351255d1 | 340 | } |
caa45040 | 0:5d70351255d1 | 341 | |
caa45040 | 0:5d70351255d1 | 342 | }//setDisplayFlip |
caa45040 | 0:5d70351255d1 | 343 | */ |