Skip to content

Commit

Permalink
Merge branch 'Development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Notice-Jeroen-Meijer committed Sep 30, 2023
2 parents 356e0e7 + 50caa50 commit e9554a6
Show file tree
Hide file tree
Showing 8 changed files with 1,002 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ android {
defaultConfig {
applicationId "lu.fisch.canze"
minSdkVersion 21
versionName '1.67'
versionCode 100
versionName '1.68beta2'
versionCode 102
}
buildTypes {
release {
//minifyEnabled false
minifyEnabled true
// minifyEnabled false
// minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
//debug {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package lu.fisch.canze.activities;

import android.content.res.Resources;
import android.graphics.Paint;
import android.os.Bundle;
import android.util.TypedValue;
import android.widget.TextView;
Expand All @@ -45,6 +46,7 @@ public class HeatmapCellvoltageActivity extends CanzeActivity implements FieldLi
private double lowest, highest;
private double cutoff;
private final double[] lastVoltage = {0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4};
private final boolean[] balancingBits = new boolean[97];
private final int lastCell = 96;
@ColorInt
private int baseColor;
Expand All @@ -66,11 +68,15 @@ protected void initListeners() {
MainActivity.getInstance().setDebugListener(this);
// Battery compartment temperatures
for (int i = 1; i <= 62; i++) {
String sid = Sid.Preamble_CellVoltages1 + (i * 16); // remember, first is pos 16, i starts s at 1
String sid = Sid.Preamble_CellVoltages1 + (i * 16); // remember, first is pos 16, i starts at 1
addField(sid);
}
for (int i = 63; i <= 96; i++) {
String sid = Sid.Preamble_CellVoltages2 + ((i - 62) * 16); // remember, first is pos 16, i starts s at 1
String sid = Sid.Preamble_CellVoltages2 + ((i - 62) * 16); // remember, first is pos 16, i starts at 1
addField(sid);
}
for (int i = 0; i < 12; i++) {
String sid = Sid.Preamble_BalancingBytes + ((i + 2) * 8); // remember, first is pos 16, i starts at 0
addField(sid);
}
}
Expand All @@ -86,6 +92,15 @@ public void onFieldUpdateEvent(final Field field) {
cell = (Integer.parseInt(fieldId.split("[.]")[2])) / 16; // cell is 1-based
} else if (fieldId.startsWith(Sid.Preamble_CellVoltages2)) {
cell = (Integer.parseInt(fieldId.split("[.]")[2])) / 16 + 62; // cell is 1-based
} else if (fieldId.startsWith(Sid.Preamble_BalancingBytes)) {
cell = (Integer.parseInt(fieldId.split("[.]")[2])) / 8 - 2; // cell is 0-based
int mask = 0b10000000;
int value = (int) field.getValue();
for (int i = 0; i < 8; i++) {
balancingBits[cell * 8 + i + 1] = ((value & mask) != 0);
mask = mask >> 1;
}
return;
}
if (cell > 0 && cell <= lastCell) {
final double value = field.getValue();
Expand Down Expand Up @@ -113,6 +128,11 @@ public void run() {
TextView tv = findViewById(getResources().getIdentifier("text_cell_" + i + "_voltage", "id", getPackageName()));
if (tv != null) {
// tv.setText(String.format("%.3f", lastVoltage[i]));
if (balancingBits[i]) {
tv.setPaintFlags(tv.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
} else {
tv.setPaintFlags(tv.getPaintFlags() & (~Paint.UNDERLINE_TEXT_FLAG));
}
tv.setText(String.format(Locale.getDefault(), "%.3f", lastVoltage[i]));
int delta = (int) (5000 * (lastVoltage[i] - mean)); // color is temp minus mean. 1mV difference is 5 color ticks
tv.setBackgroundColor(makeColor (delta));
Expand All @@ -137,6 +157,7 @@ public void run() {
}
});
}
return;
}
}

Expand Down
16 changes: 8 additions & 8 deletions app/src/main/java/lu/fisch/canze/activities/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -520,27 +520,27 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
case 100:
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
toast("BLUETOOTH_CONNECT Granted!");
// toast("BLUETOOTH_CONNECT Granted!");
configureBluetoothManager();
} else {
toast("BLUETOOTH_CONNECT Denied!");
// toast("BLUETOOTH_CONNECT Denied!");
}
case 101:
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
toast("BLUETOOTH_SCAN Granted!");
// toast("BLUETOOTH_SCAN Granted!");
configureBluetoothManager();
} else {
toast("BLUETOOTH_SCAN Denied!");
// toast("BLUETOOTH_SCAN Denied!");
}
case 102:
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
toast("WRITE_EXTERNAL_STORAGE Granted!");
storageGranted=true;
// toast("WRITE_EXTERNAL_STORAGE Granted!");
storageGranted = true;
} else {
toast("WRITE_EXTERNAL_STORAGE Denied!");
storageGranted=false;
// toast("WRITE_EXTERNAL_STORAGE Denied!");
storageGranted = false;
}
}
}
Expand Down
Loading

0 comments on commit e9554a6

Please sign in to comment.