Skip to content

Commit

Permalink
Merge pull request #96 from SUPLA/develop
Browse files Browse the repository at this point in the history
v2.3.18
  • Loading branch information
przemyslawzygmunt authored Aug 6, 2019
2 parents 171d9e5 + f89446f commit a15a40d
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 118 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.supla.android"
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionCode 71
versionName "2.3.17"
versionCode 72
versionName "2.3.18"

sourceSets.main {
jniLibs.srcDir 'src/main/libs'
Expand Down
59 changes: 29 additions & 30 deletions app/src/main/java/org/supla/android/ChannelDetailThermostatHP.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,6 @@ protected void init() {
R.id.hpBtnEcoMinus,
R.id.hpBtnEcoPlus, R.id.hpTvEco, 10, 30, 19)
);

Preferences prefs = new Preferences(getContext());
setCfgValue(CfgItem.ID_TURBO_TIME, prefs.getHeatpolTurboTime());
setCfgValue(CfgItem.ID_ECO_REDUCTION, prefs.getHeatpolEcoReduction());
}

@Override
Expand Down Expand Up @@ -433,6 +429,14 @@ public void setCfgValue(int id, int value) {
}
}

public void setCfgValue(int id, Integer value) {
setCfgValue(id, value == null ? 0 : value.intValue());
}

public void setCfgValue(int id, Double value) {
setCfgValue(id, value == null ? 0 : value.intValue());
}

private void OnChannelGroupDataChanged() {
ChannelGroup channelGroup = DBH.getChannelGroup(getRemoteId());
tvChannelTitle.setText(channelGroup.getNotEmptyCaption(this.getContext()));
Expand Down Expand Up @@ -499,24 +503,29 @@ public void run() {
displayTemperature();

if (thermostat.getWaterMax() != null) {
setCfgValue(CfgItem.ID_WATER_MAX, thermostat.getWaterMax().intValue());
}

if (thermostat.getEcoReduction() != null) {
setBtnAppearance(btnEco, thermostat.getEcoReduction().doubleValue() > 0.0);
setCfgValue(CfgItem.ID_WATER_MAX, thermostat.getWaterMax());
}

if (thermostat.getComfortTemp() != null) {
setCfgValue(CfgItem.ID_TEMP_COMFORT, thermostat.getComfortTemp().intValue());
setCfgValue(CfgItem.ID_TEMP_COMFORT, thermostat.getComfortTemp());
}

if (thermostat.getEcoTemp() != null) {
setCfgValue(CfgItem.ID_TEMP_ECO, thermostat.getEcoTemp().intValue());
setCfgValue(CfgItem.ID_TEMP_ECO, thermostat.getEcoTemp());
}

if (thermostat.getEcoReductionTemperature() != null) {
setCfgValue(CfgItem.ID_ECO_REDUCTION, thermostat.getEcoReductionTemperature());
}

if (thermostat.getTurboTime() != null) {
setCfgValue(CfgItem.ID_TURBO_TIME, thermostat.getTurboTime());
}

setBtnAppearance(btnOnOff, thermostat.isThermostatOn() ? BTN_SET_ON : BTN_SET_OFF,
R.string.hp_on, R.string.hp_off);
setBtnAppearance(btnAuto, thermostat.isAutoOn() ? BTN_SET_ON : BTN_SET_OFF);
setBtnAppearance(btnEco, thermostat.isEcoRecuctionApplied());
setBtnAppearance(btnTurbo, thermostat.isTurboOn() ? BTN_SET_ON : BTN_SET_OFF);

if (!btnIsOn(btnOnOff) || btnIsOn(btnEco)
Expand Down Expand Up @@ -637,21 +646,13 @@ public void onClick(View view) {
case CfgItem.ID_TEMP_ECO:
idx = 4;
break;
case CfgItem.ID_TURBO_TIME:
prefs.setHeatpolTurboTime(item.getValue());

if (btnIsOn(btnTurbo)) {
deviceCalCfgRequest(SuplaConst.SUPLA_THERMOSTAT_CMD_SET_MODE_TURBO,
(byte)item.getValue());
}
break;
case CfgItem.ID_ECO_REDUCTION:
prefs.setHeatpolEcoReduction(item.getValue());
idx = 5;
break;
case CfgItem.ID_TURBO_TIME:
deviceCalCfgRequest(SuplaConst.SUPLA_THERMOSTAT_CMD_SET_TIME,
(byte)item.getValue());

if (btnIsOn(btnEco)) {
deviceCalCfgRequest(SuplaConst.SUPLA_THERMOSTAT_CMD_SET_MODE_ECO,
(byte)(item.getValue()));
}
break;
}

Expand Down Expand Up @@ -719,15 +720,13 @@ public void onClick(View view) {
deviceCalCfgRequest(SuplaConst.SUPLA_THERMOSTAT_CMD_SET_MODE_NORMAL);
} else if (view == btnEco) {
on = setBtnAppearance(btnEco, BTN_SET_TOGGLE);
deviceCalCfgRequest(SuplaConst.SUPLA_THERMOSTAT_CMD_SET_MODE_ECO,
(byte)(on > 0 ? getCfgValue(CfgItem.ID_ECO_REDUCTION) * 10 : 0));
deviceCalCfgRequest(SuplaConst.SUPLA_THERMOSTAT_CMD_SET_MODE_ECO, on);
} else if (view == btnAuto) {
on = setBtnAppearance(btnAuto, BTN_SET_TOGGLE);
deviceCalCfgRequest(SuplaConst.SUPLA_THERMOSTAT_CMD_SET_MODE_AUTO, on);
} else {
on = setBtnAppearance(btnTurbo, BTN_SET_TOGGLE);
deviceCalCfgRequest(SuplaConst.SUPLA_THERMOSTAT_CMD_SET_MODE_TURBO,
(byte)(on > 0 ? getCfgValue(CfgItem.ID_TURBO_TIME) : 0));
deviceCalCfgRequest(SuplaConst.SUPLA_THERMOSTAT_CMD_SET_MODE_TURBO, on);
}
}

Expand Down Expand Up @@ -852,7 +851,7 @@ private void loadChannelList() {

int setBtnOnOff = thermostat.isThermostatOn() ? BTN_SET_ON : BTN_SET_OFF;
int setBtnNormal = thermostat.isNormalOn() ? BTN_SET_ON : BTN_SET_OFF;
int setBtnEco = thermostat.isEcoOn() ? BTN_SET_ON : BTN_SET_OFF;
int setBtnEco = thermostat.isEcoRecuctionApplied() ? BTN_SET_ON : BTN_SET_OFF;
int setBtnTurbo = thermostat.isTurboOn() ? BTN_SET_ON : BTN_SET_OFF;
int setBtnAuto = thermostat.isAutoOn() ? BTN_SET_ON : BTN_SET_OFF;

Expand All @@ -875,7 +874,7 @@ private void loadChannelList() {

if (setBtnEco != BTN_SET_OFF_UNKNOWN
&& setBtnEco !=
(thermostat.isEcoOn() ? BTN_SET_ON : BTN_SET_OFF)) {
(thermostat.isEcoRecuctionApplied() ? BTN_SET_ON : BTN_SET_OFF)) {
setBtnEco = BTN_SET_OFF_UNKNOWN;
}

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/org/supla/android/NavigationActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class NavigationActivity extends BaseActivity implements View.OnClickList
private Button HelpButton;
private Button HomepageButton;
private Button AddDeviceButton;
private Button EmptySpaceButton;

private boolean Anim = false;

Expand Down Expand Up @@ -152,13 +153,15 @@ private RelativeLayout getMenuItemsLayout() {
HelpButton = MenuItemsLayout.findViewById(R.id.btn_help);
HomepageButton = MenuItemsLayout.findViewById(R.id.btn_homepage);
AddDeviceButton = MenuItemsLayout.findViewById(R.id.btn_add);
EmptySpaceButton = MenuItemsLayout.findViewById(R.id.btn_empty_space);

SettingsButton.setOnClickListener(this);
AboutButton.setOnClickListener(this);
DonateButton.setOnClickListener(this);
HelpButton.setOnClickListener(this);
HomepageButton.setOnClickListener(this);
AddDeviceButton.setOnClickListener(this);
EmptySpaceButton.setOnClickListener(this);

Typeface type = Typeface.createFromAsset(getAssets(),"fonts/OpenSans-Regular.ttf");
SettingsButton.setTypeface(type);
Expand Down
21 changes: 0 additions & 21 deletions app/src/main/java/org/supla/android/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,25 +245,4 @@ public void wizardSetSelectedWifi(String SSID) {
editor.putString(pref_wizard_selected_wifi, SSID);
editor.apply();
}

public void setHeatpolTurboTime(int time) {
SharedPreferences.Editor editor = _prefs.edit();
editor.putInt(pref_hp_turbo_time, time);
editor.apply();
}

public int getHeatpolTurboTime() {
return _prefs.getInt(pref_hp_turbo_time, 1);
}

public void setHeatpolEcoReduction(int temp) {
SharedPreferences.Editor editor = _prefs.edit();
editor.putInt(pref_hp_eco_reduction, temp);
editor.apply();
}

public int getHeatpolEcoReduction() {
return _prefs.getInt(pref_hp_eco_reduction, 5);
}

}
27 changes: 3 additions & 24 deletions app/src/main/java/org/supla/android/SuplaThermostatCalendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,39 +263,18 @@ public boolean onTouchEvent(MotionEvent event) {
return true;
}

private short day(short day) {
if (day < 1) {
day = 1;
} else if (day > 7) {
day = 7;
}

return day;
}


private short hour(short hour) {
if (hour > 0) {
hour = 0;
} else if (hour > 23) {
hour = 23;
}

return hour;
}

private boolean isDayAndHourAreCorrect(short day, short hour) {
private boolean areTheDayAndHourCorrect(short day, short hour) {
return !(day < 1 || day > 7 || hour < 0 || hour > 23);
}

public void setHourProgramTo1(short day, short hour, boolean one) {
if (isDayAndHourAreCorrect(day, hour)) {
if (areTheDayAndHourCorrect(day, hour)) {
mHourProgramGrid[day-1][hour] = one;
}
}

public boolean isHourProgramIsSetTo1(short day, short hour) {
return isDayAndHourAreCorrect(day, hour) && mHourProgramGrid[day-1][hour];
return areTheDayAndHourCorrect(day, hour) && mHourProgramGrid[day-1][hour];
}

public void setReadOnly(boolean readOnly) {
Expand Down
75 changes: 36 additions & 39 deletions app/src/main/java/org/supla/android/ThermostatHP.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,29 @@ of the License, or (at your option) any later version.
import org.supla.android.lib.SuplaConst;
import org.supla.android.lib.SuplaChannelThermostatValue;

import java.lang.annotation.Target;

public class ThermostatHP {

private final static int STATUS_POWERON = 0x01;
private final static int STATUS_PROGRAMMODE = 0x04;
private final static int STATUS_HEATERANDWATERTEST = 0x10;
private final static int STATUS_HEATING = 0x20;

private final static int STATUS2_TURBO_ON = 0x1;
private final static int STATUS2_ECOREDUCTION_ON = 0x2;

private int presetTemperatureMin;
private Double measuredTemperatureMin;
private Double waterMax;
Double ecoReduction;
Double ecoReductionTemperature;
Double comfortTemp;
Double ecoTemp;
Integer flags;
Integer turbo;
Integer flags1;
Integer flags2;
Integer turboTime;
int errors;
boolean thermostatOn;
boolean ecoOn;
boolean turboOn;
boolean autoOn;

SuplaChannelThermostatValue.Schedule schedule;

public ThermostatHP() {
Expand All @@ -68,16 +71,13 @@ public boolean assign(ChannelExtendedValue cev) {
presetTemperatureMin = 0;
measuredTemperatureMin = null;
waterMax = null;
ecoReduction = null;
ecoReductionTemperature = null;
comfortTemp = null;
ecoTemp = null;
flags = null;
turbo = null;
flags1 = null;
flags2 = null;
turboTime = null;
errors = 0;
thermostatOn = false;
ecoOn = false;
turboOn = false;
autoOn = false;
schedule = null;

if (cev == null
Expand All @@ -90,23 +90,16 @@ public boolean assign(ChannelExtendedValue cev) {
presetTemperatureMin = temp != null ? temp.intValue() : 0;
measuredTemperatureMin = cev.getExtendedValue().ThermostatValue.getMeasuredTemperature(0);
waterMax = cev.getExtendedValue().ThermostatValue.getPresetTemperature(2);
ecoReduction = cev.getExtendedValue().ThermostatValue.getPresetTemperature(3);
ecoReductionTemperature = cev.getExtendedValue().ThermostatValue.getPresetTemperature(3);
comfortTemp = cev.getExtendedValue().ThermostatValue.getPresetTemperature(4);
ecoTemp = cev.getExtendedValue().ThermostatValue.getPresetTemperature(5);
flags = cev.getExtendedValue().ThermostatValue.getFlags(4);

if (flags != null) {
thermostatOn = (flags & STATUS_POWERON) > 0;
autoOn = (flags & STATUS_PROGRAMMODE) > 0;
}

turbo = cev.getExtendedValue().ThermostatValue.getValues(4);
if (turbo != null) {
turboOn = turbo > 0;
}

flags1 = cev.getExtendedValue().ThermostatValue.getFlags(4);
turboTime = cev.getExtendedValue().ThermostatValue.getValues(4);
schedule = cev.getExtendedValue().ThermostatValue.getSchedule();
errors = cev.getExtendedValue().ThermostatValue.getFlags(6);
flags2 = cev.getExtendedValue().ThermostatValue.getFlags(7);

Trace.d("Flags2", Integer.toString(flags2));

return true;
}
Expand Down Expand Up @@ -134,8 +127,8 @@ public Double getWaterMax() {
return waterMax;
}

public Double getEcoReduction() {
return ecoReduction;
public Double getEcoReductionTemperature() {
return ecoReductionTemperature;
}

public Double getComfortTemp() {
Expand All @@ -146,12 +139,16 @@ public Double getEcoTemp() {
return ecoTemp;
}

public Integer getFlags() {
return flags;
public Integer getFlags1() {
return flags1;
}

public Integer getFlags2() {
return flags2;
}

public Integer getTurbo() {
return turbo;
public Integer getTurboTime() {
return turboTime;
}

public int getErrors() {
Expand Down Expand Up @@ -201,23 +198,23 @@ public String getErrorMessage(Context context) {
}

public boolean isThermostatOn() {
return thermostatOn;
return flags1 != null && (flags1 & STATUS_POWERON) > 0;
}

public boolean isNormalOn() {
return isThermostatOn() && !isEcoOn() && !isTurboOn() && !isAutoOn();
return isThermostatOn() && !isEcoRecuctionApplied() && !isTurboOn() && !isAutoOn();
}

public boolean isEcoOn() {
return ecoOn;
public boolean isEcoRecuctionApplied() {
return flags2 != null && (flags2 & STATUS2_ECOREDUCTION_ON) > 0;
}

public boolean isTurboOn() {
return turboOn;
return flags2 != null && (flags2 & STATUS2_TURBO_ON) > 0;
}

public boolean isAutoOn() {
return autoOn;
return flags1 != null && (flags1 & STATUS_PROGRAMMODE) > 0;
}

public SuplaChannelThermostatValue.Schedule getSchedule() {
Expand Down
Loading

0 comments on commit a15a40d

Please sign in to comment.