UCTRONICS / U6143_ssd1306

70 stars 88 forks source link

Changing Temp Display and Loop Delay #17

Open BzkrZA opened 3 years ago

BzkrZA commented 3 years ago

How do I change the Temp display from Fahrenheit to Celsius, and is it possible to slow down the rate at which it changes between the different info displays. You barely get time to loot a reading and it switches.

darkgrue commented 3 years ago

The error in the temp display requires a fix to bmp.h, take a look at Pull Request #16, I fixed that and a lot of other things.

The loop delay is the call to sleep(), in display.h, you can increase that in increments of seconds.

mountain-pitt commented 3 years ago

Temperature is still showing Fahrenheit on Display. Need to display Celsius. This is a new install and followed the README.md

U6143_ssd1306

Preparation

sudo raspi-config

Choose Interface Options Enable i2c

Clone U6143_ssd1306 library

git clone https://github.com/UCTRONICS/U6143_ssd1306.git

Compile

cd U6143_ssd1306/C
sudo make clean && sudo make 

Run

sudo ./display
jasonwitty commented 3 years ago

i am not sure what this is referring to in your release notes. there is no way to change the unit to Celcius with this C code in this repo. if you see the following function.

unsigned char Obaintemperature(void) { FILE fd; unsigned int temp; char buff[150] = {0}; fd = fopen("/sys/class/thermal/thermal_zone0/temp","r"); fgets(buff,sizeof(buff),fd); sscanf(buff, "%d", &temp); fclose(fd); return temp/10001.8+32;

}

if you run "cat /sys/class/thermal/thermal_zone0/temp" the result is in celcius. but then on this line:

return temp/1000*1.8+32;

it is converted to F, /1000*1.8+32 is the formula to convert C to F. Also there are other If conditions in this file which contain hard coded value of 100.

if(temp>=100)

100 degrees in C is boiling ! :)

I dont understand this comments on these check ins in your link above, either it is referencing different code that in main branch or developers are confused about Celsius.

WaaromZoMoeilijk commented 2 years ago

I would also need Celsius instead of Fahrenheit. Anything we can test?

darkgrue commented 2 years ago

I would also need Celsius instead of Fahrenheit. Anything we can test?

I'd recommend looking at the PR that's been sitting there, or my own fork, which fixed all this well before they decided to make things worse.

WaaromZoMoeilijk commented 2 years ago

Dude, you're amazing. I'm gonna dig in. Last night i've spend a couple of hours editing and adding stuff. Still unable to find certain references at to symbols etc. Expect some testing of the PR on this side, thanks.

mmcfee commented 1 year ago

To make the display show the temperature in Celsius and the C symbol after it:

in U6143_ssd1306/C/ssd1306_i2c.h make these changes

define CELSIUS 1

define FAHRENHEIT 0

define TEMEPRATURE_TYPE CELSIUS

in U6143_ssd1306/C/ssd1306_i2c.c change return TEMPERATURE_TYPE == FAHRENHEIT ? temp/10001.8+32 : temp/1000; to return TEMPERATURE_TYPE == CELSIUS ? temp/10001.8+32 : temp/1000;