mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-12 18:57:36 +01:00
TLW64: Support setting displaysettings
* 24h/12h clock * metric/imperial units
This commit is contained in:
parent
0ed7c385fb
commit
56dc5211e7
@ -25,6 +25,7 @@ public final class TLW64Constants {
|
||||
public static final UUID UUID_CHARACTERISTIC_CONTROL = UUID.fromString("000033f1-0000-1000-8000-00805f9b34fb");
|
||||
|
||||
// Command bytes
|
||||
public static final byte CMD_DISPLAY_SETTINGS = (byte) 0xa0;
|
||||
public static final byte CMD_DATETIME = (byte) 0xa3;
|
||||
public static final byte CMD_ALARM = (byte) 0xab;
|
||||
|
||||
|
@ -21,6 +21,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.tlw64;
|
||||
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.net.Uri;
|
||||
import android.text.format.DateFormat;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@ -32,6 +33,9 @@ import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.tlw64.TLW64Constants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||
@ -67,6 +71,7 @@ public class TLW64Support extends AbstractBTLEDeviceSupport {
|
||||
ctrlCharacteristic = getCharacteristic(TLW64Constants.UUID_CHARACTERISTIC_CONTROL);
|
||||
|
||||
setTime(builder);
|
||||
setDisplaySettings(builder);
|
||||
|
||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZED, getContext()));
|
||||
|
||||
@ -272,4 +277,25 @@ public class TLW64Support extends AbstractBTLEDeviceSupport {
|
||||
};
|
||||
transaction.write(ctrlCharacteristic, datetimeBytes);
|
||||
}
|
||||
|
||||
private void setDisplaySettings(TransactionBuilder transaction) {
|
||||
byte[] displayBytes = new byte[]{
|
||||
TLW64Constants.CMD_DISPLAY_SETTINGS,
|
||||
0x00, // 1 - display distance in kilometers, 2 - in miles
|
||||
0x00 // 1 - display 24-hour clock, 2 - for 12-hour with AM/PM
|
||||
};
|
||||
String units = GBApplication.getPrefs().getString(SettingsActivity.PREF_MEASUREMENT_SYSTEM, getContext().getString(R.string.p_unit_metric));
|
||||
if (units.equals(getContext().getString(R.string.p_unit_metric))) {
|
||||
displayBytes[1] = 1;
|
||||
} else {
|
||||
displayBytes[1] = 2;
|
||||
}
|
||||
if (DateFormat.is24HourFormat(getContext())) {
|
||||
displayBytes[2] = 1;
|
||||
} else {
|
||||
displayBytes[2] = 2;
|
||||
}
|
||||
transaction.write(ctrlCharacteristic, displayBytes);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user