Closed WangShuoran closed 2 years ago
#define OLED_CONTROL_BYTE_CMD_SINGLE 0x80 --> CO=1 DC=0
#define OLED_CONTROL_BYTE_CMD_STREAM 0x00 --> CO=0 DC=0
#define OLED_CONTROL_BYTE_DATA_SINGLE 0xC0 --> CO=1 DC=1
#define OLED_CONTROL_BYTE_DATA_STREAM 0x40 --> CO=0 DC=1
When OLED_CONTROL_BYTE_CMD_STREAM(CO=0 DC=0), the n-byte command continues.
i2c_master_start(cmd); ---> Start Condition
i2c_master_write_byte(cmd, (dev->_address << 1) | I2C_MASTER_WRITE, true); ---> Slave Address & write mode + ACK
i2c_master_write_byte(cmd, OLED_CONTROL_BYTE_CMD_STREAM, true); ---> Control byte (CO=0 DC=0) + ACK
// Set Lower Column Start Address for Page Addressing Mode
i2c_master_write_byte(cmd, (0x00 + columLow), true); ---> Command + ACK
// Set Higher Column Start Address for Page Addressing Mode
i2c_master_write_byte(cmd, (0x10 + columHigh), true); ---> Command + ACK
// Set Page Start Address for Page Addressing Mode
i2c_master_write_byte(cmd, 0xB0 | _page, true); ---> Command + ACK
i2c_master_stop(cmd); ---> Stop Condition
When OLED_CONTROL_DATA_STREAM(CO=0 DC=1), the n-byte data continues.
When OLED_CONTROL_CMD_SINGLE(CO=1 DC=0), the 1-byte command continues.
When OLED_CONTROL_DATA_SINGLE(CO=1 DC=1), the 1-byte data continues.
Any case, The write mode will be finished when a stop condition is applied.
when I want to send command with co=0, I will send some commands and Stop Condition. when I want to send data with co=0, I will send some datas and Stop Condition.
Thank you, Because of your enthusiastic answer, I am understand the relationship between CO and DC. And I have a new question: when I set CO=0 and DC=0 the double byte of command type will send one by on in one I2C connect. Does it is? If I want to send the first byte in the first I2C connect, and the second byte in the last I2C connct, does both of situation is ok to config the ssd1306? For example: When I want to send 0xD3 and the second byte 0x00 I will send those bytes in once I2C connect? In your code ssd1306_i2c.c 58 lines is this method. (I just want to make sure)
i2c_master_write_byte(cmd, OLED_CMD_SET_DISPLAY_OFFSET, true); // D3
i2c_master_write_byte(cmd, 0x00, true);
If I want to send those byte In different I2C connect, at first I send "D3" at last I send "00", Does this is ok? (when I test this behavior, It is ok)
I want to know why?
Thank you!
When I read stm32-oled-ssd1306 I find
the Control Byte can be:
Single Command mode: 0x80
Stream Command mode: 0x00
Single Data mode: 0xC0
Stream Data mode: 0x40
I have a little question, if I set 0x80 in I2C connect at the second send byte, the third byte is command type, and the 4th is the data type, and the 5th is command type, 6th is command type, etc... Don't this right?
I have a little question, if I set 0x80 in I2C connect at the second send byte, the third byte is command type, and the 4th is the data type, and the 5th is command type, 6th is command type, etc...
No
If you set 0x80 for the I2C connection in the second send byte, everything after that is a command.
When I want to send 0xD3 and the second byte 0x00 I will send those bytes in once I2C connect?
It may be possible to send via separate ic2 links, as shown below, but I have never sent it.
cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (dev->_address << 1) | I2C_MASTER_WRITE, true);
i2c_master_write_byte(cmd, OLED_CONTROL_BYTE_CMD_SINGLE, true);
i2c_master_write_byte(cmd, 0xD3, true);
//i2c_master_stop(cmd);
i2c_master_cmd_begin(I2C_NUM, cmd, 10/portTICK_PERIOD_MS);
i2c_cmd_link_delete(cmd);
cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (dev->_address << 1) | I2C_MASTER_WRITE, true);
i2c_master_write_byte(cmd, OLED_CONTROL_BYTE_CMD_SINGLE, true);
i2c_master_write_byte(cmd, 0x00, true);
i2c_master_stop(cmd);
i2c_master_cmd_begin(I2C_NUM, cmd, 10/portTICK_PERIOD_MS);
i2c_cmd_link_delete(cmd);
https://github.com/nopnop2002/esp-idf-ssd1306/issues/14#issuecomment-1082755959
Your send is same as #define OLED_CONTROL_BYTE_CMD_STREAM 0x00 --> CO=0 DC=0
,Can you check again?
If you set 0x80 for the I2C connection in the second send byte, everything after that is a command.
If you set 0x80(Single Command mode) for the I2C connection in the second send byte, next byte is command. Only 1 byte is possible.
Maybe this is possible. 2nd byte = 0x80 (Single Command mode) 3rd byte = command 1 4th byte = 0x80 (Single Command mode) 5th byte = command 2 / / / Stop Condition
Sorry, I read too many answers with different meanings. As Co==1: this tell me co will be the data command type switch flag this tell me when co=1 only one byte to follow and this tell me co will be the data command type switch flag and this tell me when co=1 only one byte to follow
As Co==1:
this tell me co will be the data command type switch flag
No DC is Data / Command Selection bit Co and Dc are different bits
this tell me when co=1 only one byte to follow
Yes
#define OLED_CONTROL_BYTE_CMD_SINGLE 0x80 --> CO=1 DC=0
#define OLED_CONTROL_BYTE_CMD_STREAM 0x00 --> CO=0 DC=0
#define OLED_CONTROL_BYTE_DATA_SINGLE 0xC0 --> CO=1 DC=1
#define OLED_CONTROL_BYTE_DATA_STREAM 0x40 --> CO=0 DC=1
See Figure 8-7 in the data sheet.
Thank you! fuck those error document. Those Error document spend lot of my time. And thank you!
I want to sponsor this project, can you give me any sponsor method?
I want to sponsor this project, can you give me any sponsor method?
I don't even know.
I want to study ssd1306 with your porject. I use I2C with 0.96 oled. When I2C is init, your code is ssd1306_i2c.c 54 lines:
I want to know, in ssd1306 manual, it tell me when Co == 0, i2c frame is follow with contain data byte
Don't the contain data byte is last send data type (when I want to send command type, I will send command types until I close I2C, when I want to send data type, I will send data types until I close I2C)?