diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 6bc34713..00f284cd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -8,25 +8,25 @@ assignees: Ralim --- **Describe the bug** -A clear and concise description of what the bug is. + **To Reproduce** -Steps to reproduce the behavior: + **Expected behavior** -A clear and concise description of what you expected to happen. + **Details on your device:** + - Device: [e.g. TS80/Pinecil etc] - Release: [eg 2.15.40087E6] - Power adapter being used: - -Note you can grab these from the debug menu. + - If this is an acceleromter related issue, please include its model number here: **Additional context** -Add any other context about the problem here. + diff --git a/.github/ISSUE_TEMPLATE/everything-else--questions--notes-etc-.md b/.github/ISSUE_TEMPLATE/everything-else--questions--notes-etc-.md index 440f1f67..1a1c7fd6 100644 --- a/.github/ISSUE_TEMPLATE/everything-else--questions--notes-etc-.md +++ b/.github/ISSUE_TEMPLATE/everything-else--questions--notes-etc-.md @@ -7,4 +7,4 @@ assignees: '' --- -**Questions are preferred to be kept to the discussions tab where possible, but otherwise go for it. be polite and as clear as possible.** + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 259c5294..f0608cd9 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -8,13 +8,13 @@ assignees: Ralim --- **Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + **Describe the solution you'd like** -A clear and concise description of what you want to happen. + **Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. + **Additional context** -Add any other context or screenshots about the feature request here. + diff --git a/Documentation/DebugMenu.md b/Documentation/DebugMenu.md index 6e622999..d2751a05 100644 --- a/Documentation/DebugMenu.md +++ b/Documentation/DebugMenu.md @@ -52,18 +52,17 @@ This is shown in degrees C x10, so 200 == 20.0C The input voltage as read by the internal ADC. Can be used to sanity check its being read correctly. -### PCB +### ACC -This is slightly miss-named, but preserving the name for now. -This indicates the PCB "version" number, which comes from the TS100 changing the model of accelerometer without warning. This indicates the accelerometer that is fitted inside the unit. -- 1 = MMA8652 -- 2 = LIS2DH12 -- 3 = BMA223 -- 4 = MSA301 -- 5 = SC7A20 -- 99 = None detected (running in fallback without movement detection) +- MMA8652 +- LIS2DH12 +- BMA223 +- MSA301 +- SC7A20 +- None detected -> running in fallback without movement detection +- Scanning -> Still searching I2C for one ### PWR diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 09867702..b80d237a 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -1,17 +1,17 @@ -Please try and fill out this template where possible, not all fields are required and can be removed. + * **Please check if the PR fulfills these requirements** - [] The changes have been tested locally - [] There are no breaking changes * **What kind of change does this PR introduce?** -(Bug fix, feature, docs update, ...) + * **What is the current behavior?** -(You can also link to an open issue here) + * **What is the new behavior (if this is a feature change)?** diff --git a/Translations/make_translation.py b/Translations/make_translation.py index 97c9c395..77bb7b81 100755 --- a/Translations/make_translation.py +++ b/Translations/make_translation.py @@ -124,12 +124,24 @@ def get_debug_menu() -> List[str]: "CTip ", "CHan ", "Vin ", - "PCB ", + "ACC ", "PWR ", "Max ", ] +def get_accel_names_list() -> List[str]: + return [ + "Scanning", + "None", + "MMA8652FC", + "LIS2DH12", + "BMA223", + "MSA301", + "SC7A20", + ] + + def get_letter_counts( defs: dict, lang: dict, build_version: str ) -> Tuple[List[str], Dict[str, int]]: @@ -189,6 +201,7 @@ def get_letter_counts( for x in constants: text_list.append(x[1]) text_list.extend(get_debug_menu()) + text_list.extend(get_accel_names_list()) # collapse all strings down into the composite letters and store totals for these @@ -948,6 +961,16 @@ def get_translation_common_text( f'\t "{convert_string(symbol_conversion_table, c)}",//{c} \n' ) translation_common_text += "};\n\n" + + # accel names + translation_common_text += "const char* AccelTypeNames[] = {\n" + + for c in get_accel_names_list(): + translation_common_text += ( + f'\t "{convert_string(symbol_conversion_table, c)}",//{c} \n' + ) + translation_common_text += "};\n\n" + return translation_common_text diff --git a/source/Core/Inc/Translation.h b/source/Core/Inc/Translation.h index f90d606c..5012d0da 100644 --- a/source/Core/Inc/Translation.h +++ b/source/Core/Inc/Translation.h @@ -26,6 +26,7 @@ extern const char *SymbolCellCount; extern const char *SymbolVersionNumber; extern const char *DebugMenu[]; +extern const char *AccelTypeNames[]; enum class SettingsItemIndex : uint8_t { DCInCutoff, diff --git a/source/Core/Inc/main.hpp b/source/Core/Inc/main.hpp index a139694c..42ee98e0 100644 --- a/source/Core/Inc/main.hpp +++ b/source/Core/Inc/main.hpp @@ -3,7 +3,6 @@ #include "OLED.hpp" #include "Setup.h" -extern uint8_t DetectedAccelerometerVersion; extern uint32_t currentTempTargetDegC; extern bool settingsWereReset; extern bool usb_pd_available; @@ -13,8 +12,6 @@ extern "C" { void vApplicationStackOverflowHook(TaskHandle_t *pxTask, signed portCHAR *pcTaskName); -#define NO_DETECTED_ACCELEROMETER 99 -#define ACCELEROMETERS_SCANNING 100 // Threads void startGUITask(void const *argument); void startPIDTask(void const *argument); @@ -26,5 +23,17 @@ extern uint8_t accelInit; extern TickType_t lastMovementTime; #ifdef __cplusplus } +// Accelerometer type +enum class AccelType { + Scanning = 0, + None = 1, + MMA = 2, + LIS = 3, + BMA = 4, + MSA = 5, + SC7 = 6, +}; +extern AccelType DetectedAccelerometerVersion; + #endif #endif /* __MAIN_H */ diff --git a/source/Core/Src/main.cpp b/source/Core/Src/main.cpp index 451dd2d2..e2e891cc 100644 --- a/source/Core/Src/main.cpp +++ b/source/Core/Src/main.cpp @@ -9,8 +9,8 @@ #include "Settings.h" #include "cmsis_os.h" #include "power.hpp" -uint8_t DetectedAccelerometerVersion = 0; -bool settingsWereReset = false; +AccelType DetectedAccelerometerVersion = AccelType::Scanning; +bool settingsWereReset = false; // FreeRTOS variables osThreadId GUITaskHandle; diff --git a/source/Core/Threads/GUIThread.cpp b/source/Core/Threads/GUIThread.cpp index d3add6ca..a3ba674c 100644 --- a/source/Core/Threads/GUIThread.cpp +++ b/source/Core/Threads/GUIThread.cpp @@ -713,7 +713,7 @@ void showDebugMenu(void) { break; case 10: // Print PCB ID number - OLED::printNumber(DetectedAccelerometerVersion, 2, FontStyle::SMALL); + OLED::print(AccelTypeNames[(int)DetectedAccelerometerVersion], FontStyle::SMALL); break; case 11: // Power negotiation status @@ -768,11 +768,11 @@ void showWarnings() { // We also want to alert if accel or pd is not detected / not responding // In this case though, we dont want to nag the user _too_ much // So only show first 2 times - while (DetectedAccelerometerVersion == ACCELEROMETERS_SCANNING) { + while (DetectedAccelerometerVersion == AccelType::Scanning) { osDelay(5); } // Display alert if accelerometer is not detected - if (DetectedAccelerometerVersion == NO_DETECTED_ACCELEROMETER) { + if (DetectedAccelerometerVersion == AccelType::None) { if (getSettingValue(SettingsOptions::AccelMissingWarningCounter) < 2) { nextSettingValue(SettingsOptions::AccelMissingWarningCounter); saveSettings(); diff --git a/source/Core/Threads/MOVThread.cpp b/source/Core/Threads/MOVThread.cpp index e0e7c86e..86c538f5 100644 --- a/source/Core/Threads/MOVThread.cpp +++ b/source/Core/Threads/MOVThread.cpp @@ -29,11 +29,11 @@ uint8_t accelInit = 0; TickType_t lastMovementTime = 0; void detectAccelerometerVersion() { - DetectedAccelerometerVersion = ACCELEROMETERS_SCANNING; + DetectedAccelerometerVersion = AccelType::Scanning; #ifdef ACCEL_MMA if (MMA8652FC::detect()) { if (MMA8652FC::initalize()) { - DetectedAccelerometerVersion = 1; + DetectedAccelerometerVersion = AccelType::MMA; } } else #endif @@ -41,7 +41,7 @@ void detectAccelerometerVersion() { if (LIS2DH12::detect()) { // Setup the ST Accelerometer if (LIS2DH12::initalize()) { - DetectedAccelerometerVersion = 2; + DetectedAccelerometerVersion = AccelType::LIS; } } else #endif @@ -49,7 +49,7 @@ void detectAccelerometerVersion() { if (BMA223::detect()) { // Setup the BMA223 Accelerometer if (BMA223::initalize()) { - DetectedAccelerometerVersion = 3; + DetectedAccelerometerVersion = AccelType::BMA; } } else #endif @@ -57,7 +57,7 @@ void detectAccelerometerVersion() { if (MSA301::detect()) { // Setup the MSA301 Accelerometer if (MSA301::initalize()) { - DetectedAccelerometerVersion = 4; + DetectedAccelerometerVersion = AccelType::MSA; } } else #endif @@ -65,43 +65,43 @@ void detectAccelerometerVersion() { if (SC7A20::detect()) { // Setup the SC7A20 Accelerometer if (SC7A20::initalize()) { - DetectedAccelerometerVersion = 5; + DetectedAccelerometerVersion = AccelType::SC7; } } else #endif { // disable imu sensitivity setSettingValue(SettingsOptions::Sensitivity, 0); - DetectedAccelerometerVersion = NO_DETECTED_ACCELEROMETER; + DetectedAccelerometerVersion = AccelType::None; } } inline void readAccelerometer(int16_t &tx, int16_t &ty, int16_t &tz, Orientation &rotation) { -#ifdef ACCEL_LIS - if (DetectedAccelerometerVersion == 2) { - LIS2DH12::getAxisReadings(tx, ty, tz); - rotation = LIS2DH12::getOrientation(); - } else -#endif #ifdef ACCEL_MMA - if (DetectedAccelerometerVersion == 1) { + if (DetectedAccelerometerVersion == AccelType::MMA) { MMA8652FC::getAxisReadings(tx, ty, tz); rotation = MMA8652FC::getOrientation(); } else #endif +#ifdef ACCEL_LIS + if (DetectedAccelerometerVersion == AccelType::LIS) { + LIS2DH12::getAxisReadings(tx, ty, tz); + rotation = LIS2DH12::getOrientation(); + } else +#endif #ifdef ACCEL_BMA - if (DetectedAccelerometerVersion == 3) { + if (DetectedAccelerometerVersion == AccelType::BMA) { BMA223::getAxisReadings(tx, ty, tz); rotation = BMA223::getOrientation(); } else #endif #ifdef ACCEL_MSA - if (DetectedAccelerometerVersion == 4) { + if (DetectedAccelerometerVersion == AccelType::MSA) { MSA301::getAxisReadings(tx, ty, tz); rotation = MSA301::getOrientation(); } else #endif #ifdef ACCEL_SC7 - if (DetectedAccelerometerVersion == 5) { + if (DetectedAccelerometerVersion == AccelType::SC7) { SC7A20::getAxisReadings(tx, ty, tz); rotation = SC7A20::getOrientation(); } else