diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/AbstractMoyoungDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/AbstractMoyoungDeviceCoordinator.java index 5cf16c375..534df1491 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/AbstractMoyoungDeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/AbstractMoyoungDeviceCoordinator.java @@ -191,7 +191,8 @@ public abstract class AbstractMoyoungDeviceCoordinator extends AbstractBLEDevice new MoyoungSettingBool("DO_NOT_DISTURB_ONOFF", MoyoungConstants.CMD_QUERY_DO_NOT_DISTURB_TIME, MoyoungConstants.CMD_SET_DO_NOT_DISTURB_TIME), // (*) new MoyoungSetting("PSYCHOLOGICAL_PERIOD", MoyoungConstants.CMD_QUERY_PSYCHOLOGICAL_PERIOD, MoyoungConstants.CMD_SET_PSYCHOLOGICAL_PERIOD), - new MoyoungSettingBool("BREATHING_LIGHT", MoyoungConstants.CMD_QUERY_BREATHING_LIGHT, MoyoungConstants.CMD_SET_BREATHING_LIGHT) + new MoyoungSettingBool("BREATHING_LIGHT", MoyoungConstants.CMD_QUERY_BREATHING_LIGHT, MoyoungConstants.CMD_SET_BREATHING_LIGHT), + new MoyoungSettingBool("POWER_SAVING", MoyoungConstants.CMD_QUERY_POWER_SAVING, MoyoungConstants.CMD_SET_POWER_SAVING) }; @@ -202,6 +203,7 @@ public abstract class AbstractMoyoungDeviceCoordinator extends AbstractBLEDevice generic.add(R.xml.devicesettings_moyoung_device_version); generic.add(R.xml.devicesettings_timeformat); generic.add(R.xml.devicesettings_moyoung_watchface); + generic.add(R.xml.devicesettings_power_saving); generic.add(R.xml.devicesettings_liftwrist_display); // generic.add(R.xml.devicesettings_donotdisturb_no_auto); // not supported by Colmi i28 Ultra generic.add(R.xml.devicesettings_donotdisturb_on_off_follow); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungConstants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungConstants.java index 0949fc4b9..8527f786d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungConstants.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/moyoung/MoyoungConstants.java @@ -214,6 +214,9 @@ public class MoyoungConstants { public static final byte CMD_ADVANCED_QUERY = (byte) 0xb9; public static final byte CMD_DAGPT = (byte) 0xbb; + public static final byte CMD_QUERY_POWER_SAVING = (byte) 0xa4; + public static final byte CMD_SET_POWER_SAVING = (byte) 0x94; + public static final byte ARG_ADVANCED_SET_ALARM = 0x05; public static final byte ARG_ADVANCED_SET_CALENDAR = 0x08; public static final byte ARG_ADVANCED_QUERY_STOCKS = 0x0e; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungDeviceSupport.java index b7ec03d49..9f6f091d8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/moyoung/MoyoungDeviceSupport.java @@ -452,6 +452,13 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport { return true; } + if (packetType == MoyoungConstants.CMD_QUERY_POWER_SAVING) + { + LOG.info("Power saving set to: {}", payload[0] == 0x01); + onReadConfigurationDone(getSetting("POWER_SAVING"), payload[0], null); + return true; + } + if (packetType == MoyoungConstants.CMD_QUERY_DISPLAY_WATCH_FACE) { LOG.info("Watchface changed on watch to nr {}", payload[0]); @@ -1671,6 +1678,11 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport { sendSetting(getSetting("QUICK_VIEW_TIME"), quickViewTime); break; + case DeviceSettingsPreferenceConst.PREF_POWER_SAVING: + boolean powerSavingPref = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_POWER_SAVING, false); + sendSetting(getSetting("POWER_SAVING"), powerSavingPref); + break; + case MoyoungConstants.PREF_SEDENTARY_REMINDER: String sedentaryReminderPref = prefs.getString(MoyoungConstants.PREF_SEDENTARY_REMINDER, "off"); boolean sedentaryReminderEnabled = !sedentaryReminderPref.equals("off"); @@ -1821,6 +1833,13 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport { // changedProperties.put(MoyoungConstants.PREF_MOYOUNG_DEVICE_VERSION, String.valueOf(deviceVersion.value())); break; + case "POWER_SAVING": + eventUpdatePreferences.withPreference( + DeviceSettingsPreferenceConst.PREF_POWER_SAVING, + (byte) value == 0x01 + ); + break; + case "DO_NOT_DISTURB_ONOFF": eventUpdatePreferences.withPreference( DeviceSettingsPreferenceConst.PREF_DO_NOT_DISTURB_BOOL,