Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single fan display issue fix #50

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions fancontrol/fancontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "TaskbarTextIcon.h"


#define FANCONTROLVERSION "2.1.5 Dual Fan"
#define FANCONTROLVERSION "2.1.6"

#define WM__DISMISSDLG WM_USER+5
#define WM__GETDATA WM_USER+6
Expand Down Expand Up @@ -63,7 +63,11 @@ class FANCONTROL {
FanSpeedLo1,
FanSpeedHi1,
FanSpeedLo2,
FanSpeedHi2;
FanSpeedHi2,

// Single Fan Mode
FanSpeedLoS,
FanSpeedHiS;

char Sensors[12];
int SensorAddr[12];
Expand Down
36 changes: 32 additions & 4 deletions fancontrol/fanstuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,21 @@ FANCONTROL::HandleData(void) {
this->fanspeed = (this->State.FanSpeedHi1 << 8) | this->State.FanSpeedLo1;

if (this->fanspeed > 0x1fff) fanspeed = lastfanspeed;

sprintf_s(obuf2, sizeof(obuf2), "%d/%d RPM", this->fanspeed,
(this->State.FanSpeedHi2 << 8) | this->State.FanSpeedLo2);

// Check if both fans are undetected or if second fan is undetected
if (obuf2 == "0/0 RPM" || ((this->State.FanSpeedHi2 << 8) | this->State.FanSpeedLo2) == 0) {

// revert display to single fan mode
this->lastfanspeed = this->fanspeed;
this->fanspeed = (this->State.FanSpeedHiS << 8) | this->State.FanSpeedLoS;

if (this->fanspeed > 0x1fff) fanspeed = lastfanspeed;
sprintf_s(obuf2, sizeof(obuf2), "%d RPM", this->fanspeed);
}

::SetDlgItemText(this->hwndDialog, 8102, obuf2);


Expand Down Expand Up @@ -618,6 +630,18 @@ FANCONTROL::ReadEcRaw(FCSTATE* pfcstate) {

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

if (ok)
ok = ReadByteFromEC(TP_ECOFFSET_FANSPEED, &pfcstate->FanSpeedLo1);
if (!ok) {
this->Trace("failed to read FanSpeedLowByte 1 from EC");
}

if (ok)
ok = ReadByteFromEC(TP_ECOFFSET_FANSPEED + 1, &pfcstate->FanSpeedHi1);
if (!ok) {
this->Trace("failed to read FanSpeedHighByte 1 from EC");
}

if (ok)
ok = ReadByteFromEC(TP_ECOFFSET_FANSPEED, &pfcstate->FanSpeedLo2);
if (!ok) {
Expand All @@ -630,18 +654,22 @@ FANCONTROL::ReadEcRaw(FCSTATE* pfcstate) {
this->Trace("failed to read FanSpeedHighByte 2 from EC");
}

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

if (ok)
ok = ReadByteFromEC(TP_ECOFFSET_FANSPEED, &pfcstate->FanSpeedLo1);
ok = ReadByteFromEC(TP_ECOFFSET_FANSPEED, &pfcstate->FanSpeedLoS);
if (!ok) {
this->Trace("failed to read FanSpeedLowByte 1 from EC");
this->Trace("failed to read FanSpeedLowByte Single from EC");
}

if (ok)
ok = ReadByteFromEC(TP_ECOFFSET_FANSPEED + 1, &pfcstate->FanSpeedHi1);
ok = ReadByteFromEC(TP_ECOFFSET_FANSPEED + 1, &pfcstate->FanSpeedHiS);
if (!ok) {
this->Trace("failed to read FanSpeedHighByte 1 from EC");
this->Trace("failed to read FanSpeedHighByte Single from EC");
}

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

if (!this->UseTWR) {
idxtemp = 0;

Expand Down
2 changes: 2 additions & 0 deletions fancontrol/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ FANCONTROL::ReadConfig(const char* configfile)
this->State.FanSpeedLo1 = 0x00;
this->State.FanSpeedHi2 = 0x00;
this->State.FanSpeedLo2 = 0x00;
this->State.FanSpeedHiS = 0x00;
this->State.FanSpeedLoS = 0x00;
this->fanspeed = 0;
this->IndSmartLevel = 0;
//
Expand Down