1
0
forked from me/IronOS

Merge pull request #1059 from discip/master

Rename PCB -> ACC and use real model numbers
This commit is contained in:
Ben V. Brown
2021-09-25 11:04:03 +10:00
committed by GitHub
11 changed files with 82 additions and 50 deletions

View File

@@ -8,25 +8,25 @@ assignees: Ralim
---
**Describe the bug**
A clear and concise description of what the bug is.
<!-- A clear and concise description of what the bug is. -->
**To Reproduce**
Steps to reproduce the behavior:
<!-- Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
4. See error -->
**Expected behavior**
A clear and concise description of what you expected to happen.
<!-- A clear and concise description of what you expected to happen. -->
**Details on your device:**
<!-- You can get these from the debug menu by holding the rear button down and then using the front one to cycle through-->
- 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.
<!-- Add any other context about the problem here. -->

View File

@@ -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.**
<!-- **Questions are preferred to be kept to the discussions tab where possible, but otherwise go for it. be polite and as clear as possible.** -->

View File

@@ -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 [...]
<!-- 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.
<!-- 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.
<!-- 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.
<!-- Add any other context or screenshots about the feature request here. -->

View File

@@ -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

View File

@@ -1,17 +1,17 @@
Please try and fill out this template where possible, not all fields are required and can be removed.
<!-- 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, ...)
<!-- (Bug fix, feature, docs update, ...) -->
* **What is the current behavior?**
(You can also link to an open issue here)
<!-- (You can also just link to an open issue here) -->
* **What is the new behavior (if this is a feature change)?**

View File

@@ -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

View File

@@ -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,

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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();

View File

@@ -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