mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-15 20:27:32 +01:00
Mi Band 3: Change display items
This commit is contained in:
parent
9517fa211e
commit
470efa3e51
@ -405,8 +405,6 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
final Preference miBand3DisplayItems = findPreference("miband3_display_items");
|
final Preference miBand3DisplayItems = findPreference("miband3_display_items");
|
||||||
miBand3DisplayItems.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
miBand3DisplayItems.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -420,7 +418,6 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
final Preference corDisplayItems = findPreference("cor_display_items");
|
final Preference corDisplayItems = findPreference("cor_display_items");
|
||||||
corDisplayItems.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
corDisplayItems.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
|
@ -22,7 +22,7 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService.EN
|
|||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService.ENDPOINT_DISPLAY_ITEMS;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService.ENDPOINT_DISPLAY_ITEMS;
|
||||||
|
|
||||||
public class MiBand3Service {
|
public class MiBand3Service {
|
||||||
public static final byte[] COMMAND_CHANGE_SCREENS = new byte[]{ENDPOINT_DISPLAY_ITEMS, DISPLAY_ITEM_BIT_CLOCK, 0x30, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
|
public static final byte[] COMMAND_CHANGE_SCREENS = new byte[]{ENDPOINT_DISPLAY_ITEMS, DISPLAY_ITEM_BIT_CLOCK, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00};
|
||||||
public static final byte[] COMMAND_ENABLE_BAND_SCREEN_UNLOCK = new byte[]{ENDPOINT_DISPLAY, 0x16, 0x00, 0x01};
|
public static final byte[] COMMAND_ENABLE_BAND_SCREEN_UNLOCK = new byte[]{ENDPOINT_DISPLAY, 0x16, 0x00, 0x01};
|
||||||
public static final byte[] COMMAND_DISABLE_BAND_SCREEN_UNLOCK = new byte[]{ENDPOINT_DISPLAY, 0x16, 0x00, 0x00};
|
public static final byte[] COMMAND_DISABLE_BAND_SCREEN_UNLOCK = new byte[]{ENDPOINT_DISPLAY, 0x16, 0x00, 0x00};
|
||||||
}
|
}
|
||||||
|
@ -43,33 +43,46 @@ public class MiBand3Support extends AmazfitBipSupport {
|
|||||||
private static final Logger LOG = LoggerFactory.getLogger(MiBand3Support.class);
|
private static final Logger LOG = LoggerFactory.getLogger(MiBand3Support.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AmazfitBipSupport setDisplayItems(TransactionBuilder builder) {
|
protected MiBand3Support setDisplayItems(TransactionBuilder builder) {
|
||||||
if (true) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Prefs prefs = GBApplication.getPrefs();
|
Prefs prefs = GBApplication.getPrefs();
|
||||||
Set<String> pages = prefs.getStringSet("miband3_display_items", null);
|
Set<String> pages = prefs.getStringSet("miband3_display_items", null);
|
||||||
LOG.info("Setting display items to " + (pages == null ? "none" : pages));
|
LOG.info("Setting display items to " + (pages == null ? "none" : pages));
|
||||||
byte[] command = MiBand3Service.COMMAND_CHANGE_SCREENS.clone();
|
byte[] command = MiBand3Service.COMMAND_CHANGE_SCREENS.clone();
|
||||||
|
|
||||||
|
byte pos = 1;
|
||||||
if (pages != null) {
|
if (pages != null) {
|
||||||
if (pages.contains("notifications")) {
|
for (String page : pages) {
|
||||||
command[1] |= 0x02;
|
switch (page) {
|
||||||
}
|
case "notifications":
|
||||||
if (pages.contains("weather")) {
|
command[1] |= 0x02;
|
||||||
command[1] |= 0x04;
|
command[4] = pos++;
|
||||||
}
|
break;
|
||||||
if (pages.contains("more")) {
|
case "weather":
|
||||||
command[1] |= 0x10;
|
command[1] |= 0x04;
|
||||||
}
|
command[5] = pos++;
|
||||||
if (pages.contains("status")) {
|
break;
|
||||||
command[1] |= 0x20;
|
case "more":
|
||||||
}
|
command[1] |= 0x10;
|
||||||
if (pages.contains("heart_rate")) {
|
command[7] = pos++;
|
||||||
command[1] |= 0x40;
|
break;
|
||||||
|
case "status":
|
||||||
|
command[1] |= 0x20;
|
||||||
|
command[8] = pos++;
|
||||||
|
break;
|
||||||
|
case "heart_rate":
|
||||||
|
command[1] |= 0x40;
|
||||||
|
command[9] = pos++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 4; i <= 9; i++) {
|
||||||
|
if (command[i] == 0) {
|
||||||
|
command[i] = pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION), command);
|
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION), command);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@ -217,7 +217,6 @@
|
|||||||
android:key="mi3_band_screen_unlock"
|
android:key="mi3_band_screen_unlock"
|
||||||
android:summary="@string/mi3_prefs_band_screen_unlock_summary"
|
android:summary="@string/mi3_prefs_band_screen_unlock_summary"
|
||||||
android:title="@string/mi3_prefs_band_screen_unlock" />
|
android:title="@string/mi3_prefs_band_screen_unlock" />
|
||||||
<!--
|
|
||||||
<MultiSelectListPreference
|
<MultiSelectListPreference
|
||||||
android:dialogTitle="@string/mi2_prefs_display_items"
|
android:dialogTitle="@string/mi2_prefs_display_items"
|
||||||
android:defaultValue="@array/pref_miband3_display_items_default"
|
android:defaultValue="@array/pref_miband3_display_items_default"
|
||||||
@ -226,7 +225,6 @@
|
|||||||
android:key="miband3_display_items"
|
android:key="miband3_display_items"
|
||||||
android:summary="@string/mi2_prefs_display_items_summary"
|
android:summary="@string/mi2_prefs_display_items_summary"
|
||||||
android:title="@string/mi2_prefs_display_items"/>
|
android:title="@string/mi2_prefs_display_items"/>
|
||||||
-->
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:icon="@drawable/ic_device_hplus"
|
android:icon="@drawable/ic_device_hplus"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user