mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 15:27:53 +00:00
Klondike - extra zero value and range checking in temp conversion
This commit is contained in:
parent
44f96c64b2
commit
8e82da4320
@ -120,6 +120,9 @@ static double cvtKlnToC(uint8_t temp)
|
|||||||
{
|
{
|
||||||
double Rt, stein, celsius;
|
double Rt, stein, celsius;
|
||||||
|
|
||||||
|
if (temp == 0)
|
||||||
|
return 0.0;
|
||||||
|
|
||||||
Rt = 1000.0 * 255.0 / (double)temp - 1000.0;
|
Rt = 1000.0 * 255.0 / (double)temp - 1000.0;
|
||||||
|
|
||||||
stein = log(Rt / 2200.0) / 3987.0;
|
stein = log(Rt / 2200.0) / 3987.0;
|
||||||
@ -128,13 +131,39 @@ static double cvtKlnToC(uint8_t temp)
|
|||||||
|
|
||||||
celsius = (1.0 / stein) - 273.15;
|
celsius = (1.0 / stein) - 273.15;
|
||||||
|
|
||||||
|
// For display of bad data
|
||||||
|
if (celsius < 0.0)
|
||||||
|
celsius = 0.0;
|
||||||
|
if (celsius > 200.0)
|
||||||
|
celsius = 200.0;
|
||||||
|
|
||||||
return celsius;
|
return celsius;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cvtCToKln(double deg)
|
static int cvtCToKln(double deg)
|
||||||
{
|
{
|
||||||
double R = exp((1/(deg+273.15)-1/(273.15+25))*3987)*2200;
|
double Rt, stein, temp;
|
||||||
return 256*R/(R+1000);
|
|
||||||
|
if (deg < 0.0)
|
||||||
|
deg = 0.0;
|
||||||
|
|
||||||
|
stein = 1.0 / (deg + 273.15);
|
||||||
|
|
||||||
|
stein -= 1.0 / (double)(25.0 + 273.15);
|
||||||
|
|
||||||
|
Rt = exp(stein * 3987.0) * 2200.0;
|
||||||
|
|
||||||
|
if (Rt == -1000.0)
|
||||||
|
Rt++;
|
||||||
|
|
||||||
|
temp = 1000.0 * 256.0 / (Rt + 1000.0);
|
||||||
|
|
||||||
|
if (temp > 255)
|
||||||
|
temp = 255;
|
||||||
|
if (temp < 0)
|
||||||
|
temp = 0;
|
||||||
|
|
||||||
|
return (int)temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *SendCmdGetReply(struct cgpu_info *klncgpu, char Cmd, int device, int datalen, void *data)
|
static char *SendCmdGetReply(struct cgpu_info *klncgpu, char Cmd, int device, int datalen, void *data)
|
||||||
|
Loading…
Reference in New Issue
Block a user