mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Marstek B2500: also display current battery change level in Wh, not only percentage
This commit is contained in:
parent
f99b43fc56
commit
151f633247
@ -2,6 +2,7 @@
|
||||
|
||||
#### Next
|
||||
* Marstek B2500: Fix wrong gauge display for panel 2 and output 2
|
||||
* Marstek B2500: also display current battery change level in Wh, not only percentage
|
||||
|
||||
#### 0.83.0
|
||||
* Add first start onboarding screen
|
||||
|
@ -48,6 +48,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
public class SolarEquipmentStatusActivity extends AbstractGBActivity {
|
||||
public static String ACTION_SEND_SOLAR_EQUIPMENT_STATUS = "send_solar_equipment_status";
|
||||
public static String EXTRA_BATTERY_PCT = "battery_pct";
|
||||
public static String EXTRA_BATTERY_WH = "battery_wh";
|
||||
public static String EXTRA_PANEL1_WATT = "panel1_watt";
|
||||
public static String EXTRA_PANEL2_WATT = "panel2_watt";
|
||||
public static String EXTRA_OUTPUT1_WATT = "output1_watt";
|
||||
@ -64,11 +65,12 @@ public class SolarEquipmentStatusActivity extends AbstractGBActivity {
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras != null) {
|
||||
int battery_pct = extras.getInt(EXTRA_BATTERY_PCT);
|
||||
int battery_wh = extras.getInt(EXTRA_BATTERY_WH);
|
||||
int panel1_watt = extras.getInt(EXTRA_PANEL1_WATT);
|
||||
int panel2_watt = extras.getInt(EXTRA_PANEL2_WATT);
|
||||
int output1_watt = extras.getInt(EXTRA_OUTPUT1_WATT);
|
||||
int output2_watt = extras.getInt(EXTRA_OUTPUT2_WATT);
|
||||
updateWidget("battery", battery_pct + "%", (float) (battery_pct / 100.0));
|
||||
updateWidget("battery", battery_pct + "%\n" + battery_wh + "Wh", (float) (battery_pct / 100.0));
|
||||
updateWidget("panel1", panel1_watt + "W", (float) (panel1_watt / 380.0));
|
||||
updateWidget("panel2", panel2_watt + "W", (float) (panel2_watt / 380.0));
|
||||
updateWidget("output1", output1_watt + "W", (float) (output1_watt / 400.0));
|
||||
|
@ -192,37 +192,38 @@ public class MarstekB2500DeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
buf.position(buf.position() + 2); // unknown;
|
||||
|
||||
firmwareVersion = buf.get() & 0xff;
|
||||
boolean battery_allow_passthough = buf.get() != 0x01;
|
||||
boolean battery_allow_passthrough = buf.get() != 0x01;
|
||||
boolean battery_manual_discharge_intervals = buf.get() != 0x01;
|
||||
buf.position(buf.position() + 3); // skip unknown
|
||||
byte battery_max_use_pct = buf.get();
|
||||
int output_to_inverter_target = buf.getShort();
|
||||
buf.position(buf.position() + 1); // skip unknown
|
||||
int battery_charge_kwh = buf.getShort();
|
||||
int battery_wh = buf.getShort();
|
||||
int output_to_inverter_1_watt = buf.getShort();
|
||||
int output_to_inverter_2_watt = buf.getShort();
|
||||
|
||||
int battery_minimum_charge_pct = 100 - battery_max_use_pct;
|
||||
int output_to_inverter_sum_watt = output_to_inverter_1_watt + output_to_inverter_2_watt;
|
||||
|
||||
LOG.info("p1_active: {}, p2_active: {}, p1_watt: {}W, p2_watt: {}W, battery_charge_kwh: {}kWh, battery_minimum_charge_pct: {}%, battery_allow_passthrough: {}, battery_manual_discharge_intervals: {}, output_to_inverter_target: {}W, output_to_inverter: {}W+{}W={}W, firmwareVersion: V{}, ",
|
||||
p1_active, p2_active, p1_watt, p2_watt, battery_charge_kwh, battery_minimum_charge_pct, battery_allow_passthough, battery_manual_discharge_intervals, output_to_inverter_target, output_to_inverter_1_watt, output_to_inverter_2_watt, output_to_inverter_sum_watt, firmwareVersion);
|
||||
LOG.info("p1_active: {}, p2_active: {}, p1_watt: {}W, p2_watt: {}W, battery_wh: {}Wh, battery_minimum_charge_pct: {}%, battery_allow_passthrough: {}, battery_manual_discharge_intervals: {}, output_to_inverter_target: {}W, output_to_inverter: {}W+{}W={}W, firmwareVersion: V{}, ",
|
||||
p1_active, p2_active, p1_watt, p2_watt, battery_wh, battery_minimum_charge_pct, battery_allow_passthrough, battery_manual_discharge_intervals, output_to_inverter_target, output_to_inverter_1_watt, output_to_inverter_2_watt, output_to_inverter_sum_watt, firmwareVersion);
|
||||
|
||||
getDevice().setFirmwareVersion("V" + firmwareVersion);
|
||||
getDevice().sendDeviceUpdateIntent(getContext());
|
||||
|
||||
devicePrefsEdit.putString(PREF_BATTERY_MINIMUM_CHARGE, String.valueOf(battery_minimum_charge_pct));
|
||||
devicePrefsEdit.putBoolean(PREF_BATTERY_DISCHARGE_MANAUAL, battery_manual_discharge_intervals);
|
||||
devicePrefsEdit.putBoolean(PREF_BATTERY_ALLOW_PASS_THOUGH, battery_allow_passthough);
|
||||
devicePrefsEdit.putBoolean(PREF_BATTERY_ALLOW_PASS_THOUGH, battery_allow_passthrough);
|
||||
devicePrefsEdit.apply();
|
||||
devicePrefsEdit.commit();
|
||||
|
||||
int battery_percentage = (int) Math.ceil((battery_charge_kwh / 2240.0f) * 100);
|
||||
getDevice().setBatteryLevel(battery_percentage);
|
||||
int battery_pct = (int) Math.ceil((battery_wh / 2240.0f) * 100);
|
||||
getDevice().setBatteryLevel(battery_pct);
|
||||
getDevice().sendDeviceUpdateIntent(getContext());
|
||||
|
||||
Intent intent = new Intent(SolarEquipmentStatusActivity.ACTION_SEND_SOLAR_EQUIPMENT_STATUS);
|
||||
intent.putExtra(SolarEquipmentStatusActivity.EXTRA_BATTERY_PCT, battery_percentage);
|
||||
intent.putExtra(SolarEquipmentStatusActivity.EXTRA_BATTERY_WH, battery_wh);
|
||||
intent.putExtra(SolarEquipmentStatusActivity.EXTRA_BATTERY_PCT, battery_pct);
|
||||
intent.putExtra(SolarEquipmentStatusActivity.EXTRA_PANEL1_WATT, p1_watt);
|
||||
intent.putExtra(SolarEquipmentStatusActivity.EXTRA_PANEL2_WATT, p2_watt);
|
||||
intent.putExtra(SolarEquipmentStatusActivity.EXTRA_OUTPUT1_WATT, output_to_inverter_1_watt);
|
||||
|
@ -27,6 +27,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="28dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/stats_empty_value"
|
||||
android:textSize="30sp" />
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user