mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-24 16:47:32 +01:00
Add support for some configuration options of TimeStylePebble watchface ( https://github.com/freakified/TimeStylePebble )
This commit is contained in:
parent
26646af974
commit
5f189aedbd
@ -0,0 +1,107 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.pebble;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.util.Pair;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||
|
||||
public class AppMessageHandlerTimeStylePebble extends AppMessageHandler {
|
||||
public static final int KEY_SETTING_SIDEBAR_LEFT = 9;
|
||||
public static final int KEY_CONDITION_CODE = 4;
|
||||
public static final int KEY_FORECAST_CONDITION = 25;
|
||||
public static final int KEY_FORECAST_TEMP_HIGH = 26;
|
||||
public static final int KEY_FORECAST_TEMP_LOW = 27;
|
||||
public static final int KEY_SETTING_ALTCLOCK_NAME = 28;
|
||||
public static final int KEY_SETTING_ALTCLOCK_OFFSET = 29;
|
||||
public static final int KEY_SETTING_BT_VIBE = 11;
|
||||
public static final int KEY_SETTING_CLOCK_FONT_ID = 18;
|
||||
public static final int KEY_SETTING_COLOR_BG = 7;
|
||||
public static final int KEY_SETTING_COLOR_SIDEBAR = 8;
|
||||
public static final int KEY_SETTING_COLOR_TIME = 6;
|
||||
public static final int KEY_SETTING_DISABLE_WEATHER = 17;
|
||||
public static final int KEY_SETTING_HOURLY_VIBE = 19;
|
||||
public static final int KEY_SETTING_LANGUAGE_ID = 13;
|
||||
public static final int KEY_SETTING_ONLY_SHOW_BATTERY_WHEN_LOW = 20;
|
||||
public static final int KEY_SETTING_SHOW_BATTERY_PCT = 16;
|
||||
public static final int KEY_SETTING_SHOW_LEADING_ZERO = 15;
|
||||
public static final int KEY_SETTING_SIDEBAR_TEXT_COLOR = 12;
|
||||
public static final int KEY_SETTING_USE_LARGE_FONTS = 21;
|
||||
public static final int KEY_SETTING_USE_METRIC = 10;
|
||||
public static final int KEY_TEMPERATURE = 3;
|
||||
public static final int KEY_USE_NIGHT_ICON = 5;
|
||||
public static final int KEY_WIDGET_0_ID = 22;
|
||||
public static final int KEY_WIDGET_1_ID = 23;
|
||||
public static final int KEY_WIDGET_2_ID = 24;
|
||||
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AppMessageHandlerTimeStylePebble.class);
|
||||
|
||||
public AppMessageHandlerTimeStylePebble(UUID uuid, PebbleProtocol pebbleProtocol) {
|
||||
super(uuid, pebbleProtocol);
|
||||
}
|
||||
|
||||
private byte[] encodeTimeStylePebbleConfig() {
|
||||
ArrayList<Pair<Integer, Object>> pairs = new ArrayList<>();
|
||||
//settings that give good legibility on pebble time
|
||||
pairs.add(new Pair<>(KEY_SETTING_SIDEBAR_LEFT, (Object) 1));
|
||||
pairs.add(new Pair<>(KEY_SETTING_CLOCK_FONT_ID, (Object) 1));
|
||||
pairs.add(new Pair<>(KEY_SETTING_COLOR_BG, (Object) Color.parseColor("#ffffff")));
|
||||
pairs.add(new Pair<>(KEY_SETTING_COLOR_SIDEBAR, (Object) Color.parseColor("#00aaff")));
|
||||
pairs.add(new Pair<>(KEY_SETTING_COLOR_TIME, (Object) Color.parseColor("#000000")));
|
||||
pairs.add(new Pair<>(KEY_SETTING_SHOW_LEADING_ZERO, (Object) 1));
|
||||
pairs.add(new Pair<>(KEY_SETTING_LANGUAGE_ID, (Object) 2)); //2 = Deutsch
|
||||
pairs.add(new Pair<>(KEY_SETTING_USE_METRIC, (Object) 1));
|
||||
|
||||
pairs.add(new Pair<>(KEY_WIDGET_0_ID, (Object) 7)); //7 = current weather
|
||||
pairs.add(new Pair<>(KEY_WIDGET_1_ID, (Object) 2)); //2 = battery
|
||||
pairs.add(new Pair<>(KEY_WIDGET_2_ID, (Object) 4)); //4 = Date
|
||||
|
||||
/*
|
||||
pairs.add(new Pair<>(KEY_TEMPERATURE, (Object) 6));
|
||||
pairs.add(new Pair<>(KEY_CONDITION_CODE, (Object) 25));
|
||||
pairs.add(new Pair<>(KEY_FORECAST_CONDITION, (Object) 2));
|
||||
pairs.add(new Pair<>(KEY_FORECAST_TEMP_HIGH, (Object) 12));
|
||||
pairs.add(new Pair<>(KEY_FORECAST_TEMP_LOW, (Object) 0));
|
||||
*/
|
||||
|
||||
byte[] ackMessage = mPebbleProtocol.encodeApplicationMessageAck(mUUID, mPebbleProtocol.last_id);
|
||||
byte[] testMessage = mPebbleProtocol.encodeApplicationMessagePush(PebbleProtocol.ENDPOINT_APPLICATIONMESSAGE, mUUID, pairs);
|
||||
|
||||
//byte[] weatherMessage=encodeTimeStylePebbleWeather();
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate(ackMessage.length + testMessage.length );
|
||||
|
||||
// encode ack and put in front of push message (hack for acknowledging the last message)
|
||||
buf.put(ackMessage);
|
||||
buf.put(testMessage);
|
||||
|
||||
return buf.array();
|
||||
}
|
||||
|
||||
private byte[] encodeTimeStylePebbleWeather() {
|
||||
ArrayList<Pair<Integer, Object>> pairs = new ArrayList<>();
|
||||
pairs.add(new Pair<>(KEY_TEMPERATURE, (Object) 6));
|
||||
pairs.add(new Pair<>(KEY_CONDITION_CODE, (Object) 1));
|
||||
pairs.add(new Pair<>(KEY_FORECAST_CONDITION, (Object) 2));
|
||||
pairs.add(new Pair<>(KEY_FORECAST_TEMP_HIGH, (Object) 12));
|
||||
pairs.add(new Pair<>(KEY_FORECAST_TEMP_LOW, (Object) 0));
|
||||
|
||||
byte[] weatherMessage = mPebbleProtocol.encodeApplicationMessagePush(PebbleProtocol.ENDPOINT_APPLICATIONMESSAGE, mUUID, pairs);
|
||||
return weatherMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GBDeviceEvent[] handleMessage(ArrayList<Pair<Integer, Object>> pairs) {
|
||||
GBDeviceEventSendBytes sendBytes = new GBDeviceEventSendBytes();
|
||||
sendBytes.encodedBytes = encodeTimeStylePebbleConfig();
|
||||
return new GBDeviceEvent[]{sendBytes};
|
||||
}
|
||||
}
|
@ -348,6 +348,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
private static final UUID UUID_WHETHERNEAT = UUID.fromString("3684003b-a685-45f9-a713-abc6364ba051");
|
||||
private static final UUID UUID_MISFIT = UUID.fromString("0b73b76a-cd65-4dc2-9585-aaa213320858");
|
||||
private static final UUID UUID_PEBBLE_HEALTH = UUID.fromString("36d8c6ed-4c83-4fa1-a9e2-8f12dc941f8c");
|
||||
private static final UUID UUID_PEBBLE_TIMESTYLE = UUID.fromString("4368ffa4-f0fb-4823-90be-f754b076bdaa");
|
||||
|
||||
private static final Map<UUID, AppMessageHandler> mAppMessageHandlers = new HashMap<>();
|
||||
|
||||
@ -356,6 +357,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
mAppMessageHandlers.put(UUID_MORPHEUZ, new AppMessageHandlerMorpheuz(UUID_MORPHEUZ, PebbleProtocol.this));
|
||||
mAppMessageHandlers.put(UUID_WHETHERNEAT, new AppMessageHandlerWeatherNeat(UUID_WHETHERNEAT, PebbleProtocol.this));
|
||||
mAppMessageHandlers.put(UUID_MISFIT, new AppMessageHandlerMisfit(UUID_MISFIT, PebbleProtocol.this));
|
||||
mAppMessageHandlers.put(UUID_PEBBLE_TIMESTYLE, new AppMessageHandlerTimeStylePebble(UUID_PEBBLE_TIMESTYLE, PebbleProtocol.this));
|
||||
}
|
||||
|
||||
private static byte[] encodeSimpleMessage(short endpoint, byte command) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user