I made the I2C code working, and I have LED drive working as well.
Right now I only show integer temperature, using /10 divide, and *10 multiply, which is costly in terms of code size. How can I display the fractional part?
The sensor gives 2 EXP 0 to 2 EXP 6 in the MSB, and 2 EXP -1 to 2 EXP -4 in the LSB.
The data I need for the 7segment drive is 16 bit integer (hexadecimal).
The points are driven seperately.
This is the code I wrote:
void i2_read()
{unsigned char temp;
led_numbers=0;
i2c_Stop();
i2c_Open(0b10011000,I2C_WRITE);
i2c_SendByte(0x00);
i2c_ReadAcknowledge();
i2c_Stop();
i2c_Open(0b10011001,I2C_READ);
temp=i2c_ReadByte();
i2c_ReadAcknowledge();
i2c_Stop();
TRISB=0b00011111;
// led_numbers|=i2c_ReadByte();
// i2c_ReadAcknowledge();
temp&=0x7f;
led_numbers=(temp/10)<<4;
led_numbers|=temp-((temp/10)*10);
led_numbers<<=8;
}