mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-02-11 01:16:48 +01:00
Moyoung: Implement camera trigger function
Big thanks to sptech@noreply.codeberg.org for figuring this out!
This commit is contained in:
parent
f5e5b3ee14
commit
b889addc0a
@ -207,8 +207,13 @@ public abstract class AbstractMoyoungDeviceCoordinator extends AbstractBLEDevice
|
||||
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);
|
||||
generic.add(R.xml.devicesettings_world_clocks);
|
||||
generic.add(R.xml.devicesettings_sync_calendar);
|
||||
generic.add(R.xml.devicesettings_camera_remote);
|
||||
if (getWorldClocksSlotCount() > 0) {
|
||||
generic.add(R.xml.devicesettings_world_clocks);
|
||||
}
|
||||
if (supportsCalendarEvents()) {
|
||||
generic.add(R.xml.devicesettings_sync_calendar);
|
||||
}
|
||||
final List<Integer> health = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.HEALTH);
|
||||
health.add(R.xml.devicesettings_heartrate_interval);
|
||||
health.add(R.xml.devicesettings_inactivity_with_steps);
|
||||
|
@ -190,6 +190,8 @@ public class MoyoungConstants {
|
||||
|
||||
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 ARG_QUERY_STEPS_CATEGORY_TODAY_STEPS = 0;
|
||||
//public static final byte ARG_QUERY_STEPS_CATEGORY_YESTERDAY_STEPS = 2;
|
||||
|
@ -61,6 +61,7 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences;
|
||||
@ -153,6 +154,7 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
private boolean realTimeHeartRate;
|
||||
private boolean findMyPhoneActive = false;
|
||||
private boolean takePhotoActive = false;
|
||||
private final Set<CalendarEvent> lastSync = new HashSet<>();
|
||||
|
||||
public int getMtu() {
|
||||
@ -263,6 +265,15 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
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)
|
||||
{
|
||||
int heartRate = payload[0];
|
||||
@ -418,13 +429,15 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
evaluateGBDeviceEvent(musicCmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (packetType == MoyoungConstants.CMD_SWITCH_CAMERA_VIEW)
|
||||
{
|
||||
// TODO: trigger camera photo
|
||||
LOG.info("Camera shutter triggered from watch");
|
||||
if (packetType == MoyoungConstants.CMD_SWITCH_CAMERA_VIEW) {
|
||||
if (!takePhotoActive) {
|
||||
handleCameraRemote(GBDeviceEventCameraRemote.Event.OPEN_CAMERA);
|
||||
takePhotoActive = true;
|
||||
} else {
|
||||
handleCameraRemote(GBDeviceEventCameraRemote.Event.TAKE_PICTURE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -537,6 +550,16 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
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
|
||||
public boolean useAutoConnect() {
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user