mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
ATC_TSLR_Paper: allow setting the display type
This will reboot the system and load a preset from the firmware Some displays still need tweaks which is not supported yet.
This commit is contained in:
+2
@@ -649,4 +649,6 @@ public class DeviceSettingsPreferenceConst {
|
||||
public static final String PREF_DEVICE_STRESS_TEST_CONNECT_COUNT = "pref_device_stress_test_connect_count";
|
||||
public static final String PREF_DEVICE_STRESS_TEST_CONNECT_PARALLEL = "pref_device_stress_test_connect_parallel";
|
||||
public static final String PREF_DEVICE_STRESS_TEST_DISPOSE = "pref_device_stress_test_dispose";
|
||||
|
||||
public static final String PREF_ATC_TSLR_PAPER_MODEL = "pref_atc_tslr_paper_model";
|
||||
}
|
||||
|
||||
+2
@@ -967,6 +967,8 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
|
||||
addPreferenceHandlerFor(PREF_CALENDAR_MAX_DESC_LENGTH);
|
||||
addPreferenceHandlerFor(PREF_CALENDAR_TARGET_APP);
|
||||
|
||||
addPreferenceHandlerFor(PREF_ATC_TSLR_PAPER_MODEL);
|
||||
|
||||
final Preference dischargeIntervalsSet = findPreference(PREF_BATTERY_DISCHARGE_INTERVALS_SET);
|
||||
if (dischargeIntervalsSet != null) {
|
||||
dischargeIntervalsSet.setOnPreferenceClickListener(preference -> {
|
||||
|
||||
+25
@@ -1,3 +1,20 @@
|
||||
/* Copyright (C) 2025 Andreas Shimokawa
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.atctlsrpaper;
|
||||
|
||||
import android.bluetooth.le.ScanFilter;
|
||||
@@ -39,6 +56,7 @@ public class ATCTLSRPaperCoordinator extends AbstractDeviceCoordinator {
|
||||
public Class<? extends DeviceSupport> getDeviceSupportClass(final GBDevice device) {
|
||||
return ATCTLSRPaperDeviceSupport.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Pattern getSupportedDeviceName() {
|
||||
return Pattern.compile("ATC_.*");
|
||||
@@ -62,4 +80,11 @@ public class ATCTLSRPaperCoordinator extends AbstractDeviceCoordinator {
|
||||
ATCTLSRPaperInstallHandler installHandler = new ATCTLSRPaperInstallHandler(uri, context);
|
||||
return installHandler.isValid() ? installHandler : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
||||
return new int[]{
|
||||
R.xml.devicesettings_atc_trsr_paper
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2023-2024 Andreas Shimokawa
|
||||
/* Copyright (C) 2025 Andreas Shimokawa
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
|
||||
+43
-1
@@ -1,7 +1,25 @@
|
||||
/* Copyright (C) 2025 Andreas Shimokawa
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.atctlsrpaper;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
@@ -23,6 +41,7 @@ import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLESingleDeviceSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
@@ -207,6 +226,9 @@ public class ATCTLSRPaperDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
||||
buf.position(6);
|
||||
int version = buf.getInt();
|
||||
|
||||
buf.position(17);
|
||||
int model = buf.getShort();
|
||||
|
||||
buf.position(21);
|
||||
boolean is_wh_swapped = buf.get() == 0x01;
|
||||
|
||||
@@ -217,13 +239,33 @@ public class ATCTLSRPaperDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
||||
buf.position(32);
|
||||
epaper_colors = buf.get();
|
||||
|
||||
LOG.info("decoded data: version={}, width={}, height={}, nr_colors={}, w/h swapped={}", version, epaper_width, epaper_height, epaper_colors, is_wh_swapped);
|
||||
LOG.info("decoded data: version={}, width={}, height={}, nr_colors={}, w/h swapped={}, model={}", version, epaper_width, epaper_height, epaper_colors, is_wh_swapped, model);
|
||||
|
||||
SharedPreferences.Editor editor = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).edit();
|
||||
editor.putString(DeviceSettingsPreferenceConst.PREF_ATC_TSLR_PAPER_MODEL, String.valueOf(model));
|
||||
editor.apply();
|
||||
|
||||
final TransactionBuilder builder = new TransactionBuilder("set initialized");
|
||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZED, getContext()));
|
||||
builder.queue(getQueue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSendConfiguration(String config) {
|
||||
TransactionBuilder builder;
|
||||
try {
|
||||
builder = performInitialized("Sending configuration for option: " + config);
|
||||
if (DeviceSettingsPreferenceConst.PREF_ATC_TSLR_PAPER_MODEL.equals(config)) {
|
||||
SharedPreferences sharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
|
||||
String display_model = sharedPrefs.getString(DeviceSettingsPreferenceConst.PREF_ATC_TSLR_PAPER_MODEL, "1");
|
||||
builder.write(getCharacteristic(UUID_CHARACTERISTIC_MAIN), new byte[]{0x00, 0x04, 0x00, Byte.parseByte(display_model)});
|
||||
}
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast("Error setting configuration", Toast.LENGTH_LONG, GB.ERROR, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInstallApp(Uri uri) {
|
||||
try {
|
||||
|
||||
@@ -4985,4 +4985,101 @@
|
||||
<item>90</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="atc_tlsr_paper_models">
|
||||
<item name="29">Gici 213 BW SSD</item>
|
||||
<item name="13">Gici 213 BW ST</item>
|
||||
<item name="30">Gici 213 BW UC</item>
|
||||
|
||||
<item name="11">Gici 213 BWR SSD</item>
|
||||
<item name="28">Gici 213 BWR UC</item>
|
||||
<item name="12">Gici 290 BWR SSD</item>
|
||||
<item name="22">Gici 420 BWR SSD</item>
|
||||
|
||||
<item name="25">HS 213 BW SSD</item>
|
||||
<item name="10">HS 213 BW UC</item>
|
||||
<item name="32">HS 350 BW SSD</item>
|
||||
<item name="4">HS 350 BW UC</item>
|
||||
|
||||
<item name="18">HS 154 BWR H SSD</item>
|
||||
<item name="16">HS 213 BWR SSD</item>
|
||||
<item name="19">HS 213 BWR UC</item>
|
||||
<item name="9">HS 266 BWR SSD</item>
|
||||
<item name="33">HS 266 BWR SSD Offset</item>
|
||||
<item name="24">HS 290 BWR SSD</item>
|
||||
<item name="8">HS 350 BWR SSD</item>
|
||||
<item name="7">HS 350 BWR UC</item>
|
||||
<item name="20">HS 420 BWR SSD</item>
|
||||
<item name="21">HS 420 BWR UC</item>
|
||||
|
||||
<item name="5">HS 200 BWY SSD</item>
|
||||
<item name="35">HS 346 BWY UC</item>
|
||||
<item name="3">HS 350 BWY SSD</item>
|
||||
<item name="1">HS 350 BWY UC</item>
|
||||
<item name="2">HS 350 BWY UC Inverted</item>
|
||||
<item name="31">HS 583 BWY UC</item>
|
||||
<item name="6">HS 750 BWY UC</item>
|
||||
|
||||
<item name="38">HS 200 BWRY JD</item>
|
||||
<item name="17">HS 350 BWRY JD</item>
|
||||
<item name="37">HS 750 BWRY JD</item>
|
||||
|
||||
<item name="26">TI 581 BW</item>
|
||||
<item name="27">TI 581 BWR</item>
|
||||
<item name="34">TI 581 BWR UC</item>
|
||||
<item name="14">TI 970 BWR</item>
|
||||
<item name="15">TI 1200 BWR</item>
|
||||
<item name="23">TI 1200 BWR V2</item>
|
||||
|
||||
<item name="36">WO 290 BWRY JD</item>
|
||||
<item name="39">WO 290 BWRY JD V2</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="atc_tlsr_paper_models_values">
|
||||
<item>29</item>
|
||||
<item>13</item>
|
||||
<item>30</item>
|
||||
|
||||
<item>11</item>
|
||||
<item>28</item>
|
||||
<item>12</item>
|
||||
<item>22</item>
|
||||
|
||||
<item>25</item>
|
||||
<item>10</item>
|
||||
<item>32</item>
|
||||
<item>4</item>
|
||||
|
||||
<item>18</item>
|
||||
<item>16</item>
|
||||
<item>19</item>
|
||||
<item>9</item>
|
||||
<item>33</item>
|
||||
<item>24</item>
|
||||
<item>8</item>
|
||||
<item>7</item>
|
||||
<item>20</item>
|
||||
<item>21</item>
|
||||
|
||||
<item>5</item>
|
||||
<item>35</item>
|
||||
<item>3</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>31</item>
|
||||
<item>6</item>
|
||||
|
||||
<item>38</item>
|
||||
<item>17</item>
|
||||
<item>37</item>
|
||||
|
||||
<item>26</item>
|
||||
<item>27</item>
|
||||
<item>34</item>
|
||||
<item>14</item>
|
||||
<item>15</item>
|
||||
<item>23</item>
|
||||
|
||||
<item>36</item>
|
||||
<item>39</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -4085,4 +4085,5 @@
|
||||
<string name="pref_calendar_target_app_title">Target app on watch for calendar events</string>
|
||||
<string name="same_image_already_on_device">same image already on device</string>
|
||||
<string name="sending_image">sending image</string>
|
||||
<string name="pref_atc_tlsr_model_title">Display Model</string>
|
||||
</resources>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ListPreference
|
||||
android:defaultValue="1"
|
||||
android:entries="@array/atc_tlsr_paper_models"
|
||||
android:entryValues="@array/atc_tlsr_paper_models_values"
|
||||
android:key="pref_atc_tslr_paper_model"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_atc_tlsr_model_title" />
|
||||
</androidx.preference.PreferenceScreen>
|
||||
Reference in New Issue
Block a user