Skip to content

Commit

Permalink
Merge pull request #4 from Shuzhengz/gc
Browse files Browse the repository at this point in the history
Fix °C for garbled characters systems
  • Loading branch information
Shuzhengz authored Sep 5, 2021
2 parents 4b3ff55 + dfcaf0f commit ff1edeb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
8 changes: 4 additions & 4 deletions fancontrol/fancontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1096,9 +1096,9 @@ switch (msg) {
if (temp < 128 && temp!= 0)
{
if (Fahrenheit)
sprintf_s(obuf2,sizeof(obuf2), "%d°F", temp* 9 /5 +32);
sprintf_s(obuf2,sizeof(obuf2), "%d° F", temp* 9 /5 +32);
else
sprintf_s(obuf2, sizeof(obuf2), "%d°C", temp);
sprintf_s(obuf2, sizeof(obuf2), "%d° C", temp);

size_t strlen_templist2 = strlen_s(templist2,sizeof(templist2));

Expand Down Expand Up @@ -1599,11 +1599,11 @@ void FANCONTROL::ProcessTextIcons(void){

if (dishow && !this->NoBallons){
if (Fahrenheit){
ppTbTextIcon[0]->DiShowballon(_T("shows max. temperature in °F and sensor name, left click on icon shows or hides control window, right click shows menue"),
ppTbTextIcon[0]->DiShowballon(_T("shows max. temperature in ° F and sensor name, left click on icon shows or hides control window, right click shows menue"),
_T("TPFanControl new text icon"),NIIF_INFO,11);
}
else {
ppTbTextIcon[0]->DiShowballon(_T("shows max. temperature in °C and sensor name, left click on icon shows or hides control window, right click shows menue"),
ppTbTextIcon[0]->DiShowballon(_T("shows max. temperature in ° C and sensor name, left click on icon shows or hides control window, right click shows menue"),
_T("TPFanControl new text icon"),NIIF_INFO,11);
}

Expand Down
39 changes: 20 additions & 19 deletions fancontrol/fanstuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
#include "TVicPort.h"

#define TP_ECOFFSET_FAN_SWITCH (char)0x31
#define TP_ECOFFSET_FAN1 (char)0x0000
#define TP_ECOFFSET_FAN2 (char)0x0001
#define TP_ECOFFSET_FAN (char)0x2F // 1 byte (binary xyzz zzz)
#define TP_ECOFFSET_FANSPEED (char)0x84 // 16 bit word, lo/hi byte
#define TP_ECOFFSET_TEMP0 (char)0x78 // 8 temp sensor bytes from here
#define TP_ECOFFSET_TEMP1 (char)0xC0 // 4 temp sensor bytes from here
#define TP_ECOFFSET_FAN1 (char)0x0000
#define TP_ECOFFSET_FAN2 (char)0x0001
#define TP_ECOFFSET_FAN (char)0x2F // 1 byte (binary xyzz zzz)
#define TP_ECOFFSET_FANSPEED (char)0x84 // 16 bit word, lo/hi byte
#define TP_ECOFFSET_TEMP0 (char)0x78 // 8 temp sensor bytes from here
#define TP_ECOFFSET_TEMP1 (char)0xC0 // 4 temp sensor bytes from here



Expand Down Expand Up @@ -99,9 +99,9 @@ FANCONTROL::HandleData(void)

// title string (for minimized window)
if(Fahrenheit)
sprintf_s(title2,sizeof(title2), "%d°F", this->MaxTemp* 9/5 +32);
sprintf_s(title2,sizeof(title2), "%d° F", this->MaxTemp* 9/5 +32);
else
sprintf_s(title2,sizeof(title2), "%d°C", this->MaxTemp);
sprintf_s(title2,sizeof(title2), "%d° C", this->MaxTemp);


// display fan state
Expand Down Expand Up @@ -160,9 +160,9 @@ FANCONTROL::HandleData(void)

// display temperature list
if(Fahrenheit)
sprintf_s(obuf2,sizeof(obuf2), "%d°F", this->MaxTemp* 9 /5 +32);
sprintf_s(obuf2,sizeof(obuf2), "%d° F", this->MaxTemp* 9 /5 +32);
else
sprintf_s(obuf2,sizeof(obuf2), "%d°C", this->MaxTemp);
sprintf_s(obuf2,sizeof(obuf2), "%d° C", this->MaxTemp);
::SetDlgItemText(this->hwndDialog, 8103, obuf2);


Expand All @@ -173,9 +173,9 @@ FANCONTROL::HandleData(void)
if (temp < 128 && temp!= 0)
{
if(Fahrenheit)
sprintf_s(obuf2,sizeof(obuf2), "%d°F", temp* 9 /5 +32);
sprintf_s(obuf2,sizeof(obuf2), "%d° F", temp* 9 /5 +32);
else
sprintf_s(obuf2,sizeof(obuf2), "%d°C", temp);
sprintf_s(obuf2,sizeof(obuf2), "%d° C", temp);

if (SlimDialog && StayOnTop)
sprintf_s(templist2+strlen(templist2), sizeof(templist2)-strlen(templist2), "%d %s %s", i+1,
Expand Down Expand Up @@ -237,9 +237,9 @@ FANCONTROL::HandleData(void)
}
templist[strlen(templist)-1]= '\0';
if (Fahrenheit)
sprintf_s(CurrentStatus, sizeof(CurrentStatus), "Fan: 0x%02x / Switch: %d°F (%s)", State.FanCtrl, MaxTemp* 9 /5 +32, templist);
sprintf_s(CurrentStatus, sizeof(CurrentStatus), "Fan: 0x%02x / Switch: %d° F (%s)", State.FanCtrl, MaxTemp* 9 /5 +32, templist);
else
sprintf_s(CurrentStatus, sizeof(CurrentStatus), "Fan: 0x%02x / Switch: %d°C (%s)", State.FanCtrl, MaxTemp, templist);
sprintf_s(CurrentStatus, sizeof(CurrentStatus), "Fan: 0x%02x / Switch: %d° C (%s)", State.FanCtrl, MaxTemp, templist);

// display fan speed (experimental, not visible)
// fanspeed= (this->State.FanSpeedHi << 8) | this->State.FanSpeedLo;
Expand Down Expand Up @@ -413,17 +413,17 @@ FANCONTROL::SetFan(const char *source, int fanctrl, BOOL final)
for (int i = 0; i < 5; i++)
{
// set new fan level
ok= this->WriteByteToEC(TP_ECOFFSET_FAN_SWITCH, TP_ECOFFSET_FAN1);
ok= this->WriteByteToEC(TP_ECOFFSET_FAN, fanctrl);
ok = this->WriteByteToEC(TP_ECOFFSET_FAN_SWITCH, TP_ECOFFSET_FAN1);
ok = this->WriteByteToEC(TP_ECOFFSET_FAN, fanctrl);

::Sleep(300);

ok= this->WriteByteToEC(TP_ECOFFSET_FAN_SWITCH, TP_ECOFFSET_FAN2);
ok = this->WriteByteToEC(TP_ECOFFSET_FAN_SWITCH, TP_ECOFFSET_FAN2);
ok = this->WriteByteToEC(TP_ECOFFSET_FAN, fanctrl);

// verify completion
ok= this->ReadByteFromEC(TP_ECOFFSET_FAN, &this->State.FanCtrl);
ok= this->WriteByteToEC(TP_ECOFFSET_FAN_SWITCH, TP_ECOFFSET_FAN1);
ok = this->ReadByteFromEC(TP_ECOFFSET_FAN, &this->State.FanCtrl);
ok = this->WriteByteToEC(TP_ECOFFSET_FAN_SWITCH, TP_ECOFFSET_FAN1);
ok = this->ReadByteFromEC(TP_ECOFFSET_FAN, &this->State.FanCtrl);

if (this->State.FanCtrl == fanctrl)
Expand Down Expand Up @@ -618,6 +618,7 @@ FANCONTROL::ReadEcRaw(FCSTATE *pfcstate)
}
if (!this->UseTWR){
idxtemp= 0;

for (i= 0; i<8 && ok; i++) { // temp sensors 0x78 - 0x7f
ok= ReadByteFromEC(TP_ECOFFSET_TEMP0+i, &pfcstate->Sensors[idxtemp]);
if (this->ShowBiasedTemps)
Expand Down
12 changes: 6 additions & 6 deletions fancontrol/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ FANCONTROL::ReadConfig(const char *configfile)
if (Fahrenheit){
strcpy_s(buf,sizeof(buf), " ");
for (i= 0; this->SmartLevels[i].temp!=-1; i++) {
sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%s%d°F->",
sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%s%d° F->",
i>0 ? ", " : "", this->SmartLevels[i].temp);
if (this->SmartLevels[i].fan!=0x80)
sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%d",
Expand All @@ -530,7 +530,7 @@ FANCONTROL::ReadConfig(const char *configfile)
else {
strcpy_s(buf,sizeof(buf), " Levels= ");
for (i= 0; this->SmartLevels[i].temp!=-1; i++) {
sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%s%d°C -> ",
sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%s%d° C -> ",
i>0 ? ", " : "",
this->SmartLevels[i].temp);
if (this->SmartLevels[i].fan!=0x80)
Expand All @@ -551,7 +551,7 @@ FANCONTROL::ReadConfig(const char *configfile)
if (Fahrenheit){
strcpy_s(buf,sizeof(buf), " ");
for (i= 0; this->SmartLevels2[i].temp2!=-1; i++) {
sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%s%d°F->",
sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%s%d° F->",
i>0 ? ", " : "", this->SmartLevels2[i].temp2);
if (this->SmartLevels2[i].fan2!=0x80)
sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%d",
Expand All @@ -563,7 +563,7 @@ FANCONTROL::ReadConfig(const char *configfile)
else {
strcpy_s(buf,sizeof(buf), " Levels2= ");
for (i= 0; this->SmartLevels2[i].temp2!=-1; i++) {
sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%s%d°C -> ",
sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%s%d° C -> ",
i>0 ? ", " : "",
this->SmartLevels2[i].temp2);
if (this->SmartLevels2[i].fan2!=0x80)
Expand All @@ -578,7 +578,7 @@ FANCONTROL::ReadConfig(const char *configfile)
}

if (Fahrenheit) {
sprintf_s(buf,sizeof(buf), " SensorOffset1-12= %d %d %d %d %d %d %d %d %d %d %d %d °F",
sprintf_s(buf,sizeof(buf), " SensorOffset1-12= %d %d %d %d %d %d %d %d %d %d %d %d ° F",
this->SensorOffset[0], this->SensorOffset[1], this->SensorOffset[2],
this->SensorOffset[3], this->SensorOffset[4], this->SensorOffset[5],
this->SensorOffset[6], this->SensorOffset[7], this->SensorOffset[8],
Expand All @@ -587,7 +587,7 @@ FANCONTROL::ReadConfig(const char *configfile)
for (i= 0; i<15; i++) {SensorOffset[i]= SensorOffset[i] * 5/9;}
}
else {
sprintf_s(buf,sizeof(buf), " SensorOffset1-12= %d %d %d %d %d %d %d %d %d %d %d %d °C",
sprintf_s(buf,sizeof(buf), " SensorOffset1-12= %d %d %d %d %d %d %d %d %d %d %d %d ° C",
this->SensorOffset[0], this->SensorOffset[1], this->SensorOffset[2],
this->SensorOffset[3], this->SensorOffset[4], this->SensorOffset[5],
this->SensorOffset[6], this->SensorOffset[7], this->SensorOffset[8],
Expand Down
Binary file modified fancontrol/res/fancontrol.aps
Binary file not shown.

0 comments on commit ff1edeb

Please sign in to comment.