It’s time for the first official episode of Tech Talk with Gus. In this episode we’ll be talking about and demonstrating an OLED 0.96" display. These cool little displays can be used in a number of projects, and are very cheap.
Since the value 0x78 had to be shifted then why didn’t they just put 0x3C… weird.
@ Gus, in your evaluation did you notice anywhere where you can change the address. Also, do you have to update the entire screen each time or can it be partially updated.
@ Gary - As programmers we all know that zero (0) is a number, but most humans start counting from one (1). Since this was the first real episode (i.e. episode 1) then the introduction episode before would count as episode zero (0). It’s an inside joke among programmers.
It’s really not that weird. The slave address consists of 7bits as the address and the 8’th is the R/~W bit. On the PCB they are simply giving you the full 8 bits that you are to send as the device address. Which on 0x78 the R/~W bit is 0 indicating we want to write to it.
Here is where it does get weird. Some compilers are smart, and others take what you pass litterally when it comes to this.
For example, say with compiler A(smart) & B(literally) i want to write to a I2C device that has a slave address of 0x3F.
// this will automatically shift up the value passed by one, then send it
Compiler A:
I2cWriteAddress(0x3f);
// this will literally send what you pass
Compiler B:
I2cWriteAddress(0x7E);
So it’s all about knowing how your compiler talks to I2C devices.
The simplest way i have found when in doubt about the address is to do the following.
for(x=0;x<0xfe;x++)
{
// Assuming your compilers write will return if you got an ack or not. Some do, some dont.
y = I2cWriteAddress(x);
printf(“%x=%d\r\n”,x,y);
}
when you run this it will quickly show you what devices it picks up on the bus as the address.
@ Gus - Hi Gus. I don’t see any pins being passed in a constructor for the I2C class. I am making the move to .netmf and don’t see how the code knows which pins to use.
I bought a couple of these displays and am working with a G30.
Thanks for the video. I hope there are many more coming.
I2C pins are dedicated on each processor, so you don’t need to tell it what one to use, it’ll always be the same. You will find the pins labelled SDA and SCL on the schematics of the board you’re using…
If you want to use Software I2C which lets you define what pins to use (but the code has to handle the hardware interaction instead of letting hardware do it) you can check out the software I2C section of https://www.ghielectronics.com/docs/12/i2c