diff --git a/app/build.gradle b/app/build.gradle
index 5cdf270..d381cb0 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -7,8 +7,8 @@ android {
applicationId "spider65.ebike.tsdz2_esp32"
minSdkVersion 23
targetSdkVersion 28
- versionCode 15
- versionName "2.1.8"
+ versionCode 16
+ versionName "2.1.9"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
diff --git a/app/src/main/java/spider65/ebike/tsdz2_esp32/activities/HallCalibrationActivity.java b/app/src/main/java/spider65/ebike/tsdz2_esp32/activities/HallCalibrationActivity.java
index df481fa..f3a4b98 100644
--- a/app/src/main/java/spider65/ebike/tsdz2_esp32/activities/HallCalibrationActivity.java
+++ b/app/src/main/java/spider65/ebike/tsdz2_esp32/activities/HallCalibrationActivity.java
@@ -54,7 +54,7 @@ public class HallCalibrationActivity extends AppCompatActivity {
private int msgCounter;
private int step = 0;
- private final byte[] dutyCycles = {25, 50, 100, (byte)(150 & 0xff)};
+ private final byte[] dutyCycles = {30, 70, 110, (byte)(160 & 0xff)};
private final RollingAverage[] avg = {
new RollingAverage(AVG_SIZE),
new RollingAverage(AVG_SIZE),
diff --git a/app/src/main/java/spider65/ebike/tsdz2_esp32/activities/ShowDebugInfo.java b/app/src/main/java/spider65/ebike/tsdz2_esp32/activities/ShowDebugInfo.java
index 7cffd47..156ecba 100644
--- a/app/src/main/java/spider65/ebike/tsdz2_esp32/activities/ShowDebugInfo.java
+++ b/app/src/main/java/spider65/ebike/tsdz2_esp32/activities/ShowDebugInfo.java
@@ -27,15 +27,16 @@ public class ShowDebugInfo extends AppCompatActivity {
private IntentFilter mIntentFilter = new IntentFilter();
- private LinearLayout mainTimeLL, pwmTimeLL;
- private TextView mainLoopTV, pwmTV;
- private TextView rxcTV, rxlTV, ebikeTimeTV, motorTimeTV, pwmDownTV, pwmUpTV;
- private View div1, div2;
+ private LinearLayout mainTimeLL, pwmTimeLL, hallErrLL;
+ private TextView mainLoopTV, pwmTV, hallErrTV;
+ private TextView rxcTV, rxlTV, ebikeTimeTV, motorTimeTV, pwmDownTV, pwmUpTV, hallStateErrTV, hallSeqErrTV;
+ private View div1, div2, div3;
private final TSDZ_Status status = new TSDZ_Status();
private final TSDZ_Debug debug = new TSDZ_Debug();
private boolean pwmDebug = false;
private boolean mainDebug = false;
+ private boolean hallDebug = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -65,6 +66,15 @@ protected void onCreate(Bundle savedInstanceState) {
pwmTV.setVisibility(View.GONE);
div2.setVisibility(View.GONE);
+ hallErrLL = findViewById(R.id.hallErrLinearLayout);
+ hallErrTV = findViewById(R.id.hallErrTV);
+ hallStateErrTV = findViewById(R.id.hallStateErrTV);
+ hallSeqErrTV = findViewById(R.id.hallSeqErrTV);
+ div3 = findViewById(R.id.dbg_infoDV3);
+ hallErrLL.setVisibility(View.GONE);
+ hallErrTV.setVisibility(View.GONE);
+ div3.setVisibility(View.GONE);
+
mIntentFilter.addAction(TSDZBTService.TSDZ_STATUS_BROADCAST);
mIntentFilter.addAction(TSDZBTService.TSDZ_DEBUG_BROADCAST);
@@ -106,6 +116,12 @@ private void refreshDebug() {
pwmTV.setVisibility(View.VISIBLE);
div2.setVisibility(View.VISIBLE);
}
+ if (!hallDebug && (debug.debugFlags & 0x20) != 0) {
+ hallDebug = true;
+ hallErrLL.setVisibility(View.VISIBLE);
+ hallErrTV.setVisibility(View.VISIBLE);
+ div3.setVisibility(View.VISIBLE);
+ }
if (pwmDebug) {
int upIRQ = ((debug.debug4 & 255) << 8) + (debug.debug3 & 255);
@@ -118,6 +134,11 @@ private void refreshDebug() {
ebikeTimeTV.setText(String.format(Locale.getDefault(),"%d", debug.debug2));
motorTimeTV.setText(String.format(Locale.getDefault(),"%d", debug.debug1));
}
+
+ if (hallDebug) {
+ hallStateErrTV.setText(String.format(Locale.getDefault(),"%d", debug.debug5));
+ hallSeqErrTV.setText(String.format(Locale.getDefault(),"%d", debug.debug6));
+ }
}
private void refreshStatus() {
diff --git a/app/src/main/java/spider65/ebike/tsdz2_esp32/data/LogManager.java b/app/src/main/java/spider65/ebike/tsdz2_esp32/data/LogManager.java
index a975ab9..4b4a595 100644
--- a/app/src/main/java/spider65/ebike/tsdz2_esp32/data/LogManager.java
+++ b/app/src/main/java/spider65/ebike/tsdz2_esp32/data/LogManager.java
@@ -69,6 +69,7 @@ public static class TimeInterval {
// max time interval between two log entries in a single log file. If more, a new log file is started.
private static final long MAX_LOG_PAUSE = 1000 * 60 * 20;
// log file retention is 7 days (in msec)
+ private static final int MAX_LOG_FILES = 20;
private static final long MAX_LOG_HISTORY = 1000 * 60 * 60 * 24 * 7;
// max single log file time is 6 hours (in msec)
private static final long MAX_FILE_HISTORY = 1000 * 60 * 60 * 6;
@@ -313,11 +314,12 @@ private void swapStatusFile() {
final File folder = MyApp.getInstance().getFilesDir();
final File[] files = folder.listFiles( (dir, name) ->
name.matches( STATUS_LOG_FILENAME + ".log\\.\\d+\\.\\d+$" ));
- if (files != null) {
+ if ((files != null) && (files.length > MAX_LOG_FILES)) {
Arrays.sort(files, (object1, object2) ->
object1.getName().compareTo(object2.getName()));
long now = System.currentTimeMillis();
- for (File f:files) {
+ for (int i = MAX_LOG_FILES; i < files.length; i++) {
+ File f = files[i];
String s1 = f.getName();
String[] s = s1.split("\\.");
long endTime = Long.parseLong(s[3]);
@@ -352,11 +354,12 @@ private void swapDebugFile() {
name.matches( DEBUG_LOG_FILENAME + ".log\\.\\d+\\.\\d+$" ));
// remove old log files
- if (files != null) {
+ if ((files != null) && (files.length > MAX_LOG_FILES)) {
Arrays.sort(files, (object1, object2) ->
object1.getName().compareTo(object2.getName()));
long now = System.currentTimeMillis();
- for (File f:files) {
+ for (int i = MAX_LOG_FILES; i < files.length; i++) {
+ File f = files[i];
String s1 = f.getName();
String[] s = s1.split("\\.");
long endTime = Long.parseLong(s[3]);
diff --git a/app/src/main/java/spider65/ebike/tsdz2_esp32/data/TSDZ_Debug.java b/app/src/main/java/spider65/ebike/tsdz2_esp32/data/TSDZ_Debug.java
index b112674..f53bce5 100644
--- a/app/src/main/java/spider65/ebike/tsdz2_esp32/data/TSDZ_Debug.java
+++ b/app/src/main/java/spider65/ebike/tsdz2_esp32/data/TSDZ_Debug.java
@@ -32,17 +32,22 @@ public class TSDZ_Debug {
/*
#pragma pack(1)
typedef struct _tsdz_debug {
- volatile uint8_t ui8_adc_throttle;
- volatile uint8_t ui8_throttle;
- volatile uint16_t ui16_adc_pedal_torque_sensor;
- volatile uint8_t ui8_duty_cycle;
- volatile uint16_t ui16_motor_speed_erps;
- volatile uint8_t ui8_foc_angle;
- volatile uint16_t ui16_pedal_torque_x100;
- volatile uint16_t ui16_dummy;
- volatile int16_t i16_pcb_temperaturex10;
- volatile uint8_t ui8_rxc_errors;
- volatile uint8_t ui8_rxl_errors;
+ volatile uint8_t ui8_adc_throttle;
+ volatile uint8_t ui8_throttle;
+ volatile uint16_t ui16_adc_pedal_torque_sensor;
+ volatile uint8_t ui8_duty_cycle;
+ volatile uint16_t ui16_motor_speed_erps;
+ volatile uint8_t ui8_foc_angle;
+ volatile uint16_t ui16_pedal_torque_x100;
+ volatile uint8_t ui8_fw_hall_cnt_offset;
+ volatile int16_t i16_pcb_temperaturex10;
+ volatile uint8_t ui8_debugFlags;
+ volatile uint8_t ui8_debug1;
+ volatile uint8_t ui8_debug2;
+ volatile uint8_t ui8_debug3;
+ volatile uint8_t ui8_debug4;
+ volatile uint8_t ui8_debug5;
+ volatile uint8_t ui8_debug6;
} struct_tsdz_debug;
*/
diff --git a/app/src/main/res/layout/activity_show_debug.xml b/app/src/main/res/layout/activity_show_debug.xml
index 14751e6..91a9dc8 100644
--- a/app/src/main/res/layout/activity_show_debug.xml
+++ b/app/src/main/res/layout/activity_show_debug.xml
@@ -210,6 +210,66 @@
android:layout_margin="10sp"
android:background="?android:attr/listDivider" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
PWM IRQ time
Up IRQ
Down IRQ
+ Hall Errors
+ State Err.
+ Seq. Err.
-
TSDZ2_ESP32