1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-02-11 17:36:48 +01:00

Moyoung: Implement camera trigger function

Big thanks to sptech@noreply.codeberg.org for figuring this out!
This commit is contained in:
Arjan Schrijver 2025-02-05 21:31:27 +01:00
parent f5e5b3ee14
commit b889addc0a
3 changed files with 37 additions and 7 deletions

View File

@ -207,8 +207,13 @@ public abstract class AbstractMoyoungDeviceCoordinator extends AbstractBLEDevice
generic.add(R.xml.devicesettings_liftwrist_display); 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_no_auto); // not supported by Colmi i28 Ultra
generic.add(R.xml.devicesettings_donotdisturb_on_off_follow); generic.add(R.xml.devicesettings_donotdisturb_on_off_follow);
generic.add(R.xml.devicesettings_camera_remote);
if (getWorldClocksSlotCount() > 0) {
generic.add(R.xml.devicesettings_world_clocks); generic.add(R.xml.devicesettings_world_clocks);
}
if (supportsCalendarEvents()) {
generic.add(R.xml.devicesettings_sync_calendar); generic.add(R.xml.devicesettings_sync_calendar);
}
final List<Integer> health = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.HEALTH); final List<Integer> health = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.HEALTH);
health.add(R.xml.devicesettings_heartrate_interval); health.add(R.xml.devicesettings_heartrate_interval);
health.add(R.xml.devicesettings_inactivity_with_steps); health.add(R.xml.devicesettings_inactivity_with_steps);

View File

@ -190,6 +190,8 @@ public class MoyoungConstants {
public static final byte CMD_GSENSOR_CALIBRATION = 82; // (?) {} public static final byte CMD_GSENSOR_CALIBRATION = 82; // (?) {}
public static final byte CMD_RETURN_PRINCIPAL_SCREEN = 83; // (?) {}
public static final byte CMD_QUERY_STEPS_CATEGORY = 89; // (*) {i} -> {0, data:uint16[*]}, {1}, {2, data:uint16[*]}, {3}, query 0+1 together and 2+3 together public static final byte CMD_QUERY_STEPS_CATEGORY = 89; // (*) {i} -> {0, data:uint16[*]}, {1}, {2, data:uint16[*]}, {3}, query 0+1 together and 2+3 together
//public static final byte ARG_QUERY_STEPS_CATEGORY_TODAY_STEPS = 0; //public static final byte ARG_QUERY_STEPS_CATEGORY_TODAY_STEPS = 0;
//public static final byte ARG_QUERY_STEPS_CATEGORY_YESTERDAY_STEPS = 2; //public static final byte ARG_QUERY_STEPS_CATEGORY_YESTERDAY_STEPS = 2;

View File

@ -61,6 +61,7 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences;
@ -153,6 +154,7 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
private boolean realTimeHeartRate; private boolean realTimeHeartRate;
private boolean findMyPhoneActive = false; private boolean findMyPhoneActive = false;
private boolean takePhotoActive = false;
private final Set<CalendarEvent> lastSync = new HashSet<>(); private final Set<CalendarEvent> lastSync = new HashSet<>();
public int getMtu() { public int getMtu() {
@ -263,6 +265,15 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
private boolean handlePacket(byte packetType, byte[] payload) private boolean handlePacket(byte packetType, byte[] payload)
{ {
if (packetType == MoyoungConstants.CMD_RETURN_PRINCIPAL_SCREEN) { // 83
LOG.info("Return to a principal screen...");
if (takePhotoActive) {
handleCameraRemote(GBDeviceEventCameraRemote.Event.CLOSE_CAMERA);
takePhotoActive = false;
}
return true;
}
if (packetType == MoyoungConstants.CMD_TRIGGER_MEASURE_HEARTRATE) if (packetType == MoyoungConstants.CMD_TRIGGER_MEASURE_HEARTRATE)
{ {
int heartRate = payload[0]; int heartRate = payload[0];
@ -418,13 +429,15 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
evaluateGBDeviceEvent(musicCmd); evaluateGBDeviceEvent(musicCmd);
return true; return true;
} }
} }
if (packetType == MoyoungConstants.CMD_SWITCH_CAMERA_VIEW) if (packetType == MoyoungConstants.CMD_SWITCH_CAMERA_VIEW) {
{ if (!takePhotoActive) {
// TODO: trigger camera photo handleCameraRemote(GBDeviceEventCameraRemote.Event.OPEN_CAMERA);
LOG.info("Camera shutter triggered from watch"); takePhotoActive = true;
} else {
handleCameraRemote(GBDeviceEventCameraRemote.Event.TAKE_PICTURE);
}
return true; return true;
} }
@ -537,6 +550,16 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
handleGBDeviceEvent(batteryCmd); handleGBDeviceEvent(batteryCmd);
} }
private void handleCameraRemote(GBDeviceEventCameraRemote.Event eventType) {
Prefs prefs = getDevicePrefs();
if (!prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_CAMERA_REMOTE, false))
return;
final GBDeviceEventCameraRemote event = new GBDeviceEventCameraRemote();
event.event = eventType;
evaluateGBDeviceEvent(event);
}
@Override @Override
public boolean useAutoConnect() { public boolean useAutoConnect() {
return true; return true;