Skip to content

Commit 4f23495

Browse files
authored
Merge pull request #40 from Strooom/develop minor Minor
Merge Development into a new Release
2 parents 350d85f + 94ef385 commit 4f23495

File tree

29 files changed

+562
-356
lines changed

29 files changed

+562
-356
lines changed

TODO.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# MuMo SW V3
22
## ToDo's
33

4+
2. make SNR work both in devStatusReq and on display
5+
3. make measurementGroup a template class, so we can make large ones (for sensorDeviceCollection) and small ones (for events such as usb plugin...)
6+
4. make epaper display refresh faster...
7+
5. start adding unit test for main application. eg. all changes for cli commands
8+
6. implement configuring display
9+
7. put MCU in sleep when waiting for low power timer...
10+
411
### Priority High
512

613
* measurementsGroupCollection

docs/kmska.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

lib/application/maincontroller.cpp

Lines changed: 161 additions & 142 deletions
Large diffs are not rendered by default.

lib/application/maincontroller.hpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@
1414
#include <applicationevent.hpp>
1515
#include <clicommand.hpp>
1616

17-
static constexpr bool forceInitialization{false};
18-
static constexpr batteryType defaultBatteryType{batteryType::alkaline_1200mAh};
19-
static constexpr radioType defaultRadioType{radioType::lowPower};
2017
static constexpr uint32_t maxNameLength{8U}; // maximum length of the node name, including the null terminator
2118
static constexpr char toBeName[maxNameLength + 1] = "MuMo";
2219

2320
class mainController {
2421
public:
2522
mainController() = delete;
2623
static void initialize();
24+
static void initializeLogging();
25+
static void initializeNonVolatileStorage();
26+
static void initializeName();
27+
static void initializeBattery();
28+
static void initializeDisplay();
29+
static void initializeRadio();
30+
static void initializeSensors();
2731
static void runUsbPowerDetection();
2832
static void runStateMachine();
2933
static void handleEvents();
@@ -33,14 +37,14 @@ class mainController {
3337

3438
static constexpr uint32_t minNmbrAnswers{2};
3539
static constexpr uint32_t maxNmbrRequests{12};
36-
static const uint32_t displayDeviceIndex[screen::nmbrOfMeasurementTextLines];
37-
static const uint32_t displayChannelIndex[screen::nmbrOfMeasurementTextLines];
38-
39-
#ifndef unitTesting
40-
40+
41+
#ifndef unitTesting
42+
4143
// private:
42-
#endif
44+
#endif
4345
static char name[maxNameLength + 1];
46+
static uint32_t displayDeviceIndex[screen::nmbrOfMeasurementTextLines];
47+
static uint32_t displayChannelIndex[screen::nmbrOfMeasurementTextLines];
4448

4549
static void goTo(mainState newState);
4650
static mainState state;

lib/display/display.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,8 @@ To map the OpenGL coordinate system onto the display hardware, the following set
144144

145145
# Partial Update
146146
SSD1681 has 2 update modes :
147-
* Mode 1 : full update. The display will cycle through all white, all black, new image, etc. to activate all pigments particles and results in a clean, high contrast image, gets rig of any ghosting. This update mode takes longer, depending on temperature, about 2500 ms
148-
* Mode 2 : partial update. The display needs the old (current) image in RAM2 and the new image in RAM1. It will apply an update depending on the needed pixel statechange. This typically takes less time, about 1000ms, but it requires you to write old and new displayBuffer to the display. Also this mode creates less contrast, may leave a bit of ghosting image. Mode two can also be applied to a selected area instead of the whole display. You need to set xStart, xEnd, yStart, yEnd to mark the window with changes. There is a small gain in update time when updating a region io. the whole display, typically like 800 ms for an update.
147+
* Mode 1 : full update. The display will cycle through all white, all black, new image, etc. to activate all pigments particles and results in a clean, high contrast image, gets rid of any ghosting. This update mode takes longer, depending on temperature, about 2500 ms
148+
* Mode 2 : partial update. The display needs the old (current) image in RAM2 and the new image in RAM1. It will apply an update depending on the needed pixel statechange. This typically takes less time, about 1000ms, but it requires you to write old and new displayBuffer to the display. Also this mode creates less contrast, may leave a bit of ghosting image. Mode two can also be applied to a selected area instead of the whole display. You need to set xStart, xEnd, yStart, yEnd to mark the window with changes. There is a small gain in update time when updating a region io. the whole display, typically like 800 ms for an update.
149+
150+
# Faster update
151+
* The display update time depends on the temperature : when colder, the pixel pigments move slower. So a trick to make the display update faster, is to NOT use the internal temperature sensor, but rather write the temperature, and make the display believe temp is 100 degrees. The update is the really quick, with very limited ghosting. To get rid of any ghosting, you could do a 'normal' update, every x fast updates.

lib/logging/logging.cpp

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,12 @@ uint32_t logging::activeDestinations{0};
2626
char logging::buffer[bufferLength]{};
2727

2828
void logging::initialize() {
29-
#ifndef generic
30-
if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == 0x0001) { // is a SWD debugprobe connected ?
31-
#ifndef platformio // SWO TRACE is not working on PlatformIO
32-
logging::enable(logging::destination::swo);
33-
#endif
34-
LL_DBGMCU_EnableDBGStopMode();
35-
} else {
36-
LL_DBGMCU_DisableDBGStopMode();
37-
}
38-
#endif
39-
if (power::hasUsbPower()) {
40-
logging::enable(logging::destination::uart2);
41-
}
42-
if (!logging::isActive(logging::destination::swo)) {
43-
gpio::disableGpio(gpio::group::debugPort);
44-
}
29+
enable(logging::destination::uart1);
30+
enable(logging::source::error);
31+
enable(logging::source::criticalError);
4532
}
4633

34+
4735
uint32_t logging::snprintf(const char *format, ...) {
4836
uint32_t length{0};
4937
if (activeDestinations != 00) {
@@ -113,27 +101,6 @@ void logging::write(const uint32_t dataLength) {
113101
}
114102
}
115103

116-
void logging::dump() {
117-
logging::snprintf("logging : \n");
118-
if (activeSources == 0) {
119-
logging::snprintf(" no active sources\n");
120-
} else {
121-
logging::snprintf(" sources : ");
122-
for (uint32_t index = 0; index < 32; index++) {
123-
if ((activeSources & (0x01 << index)) != 0) {
124-
logging::snprintf("%s ", toString(static_cast<source>(index)));
125-
}
126-
}
127-
logging::snprintf("\n");
128-
}
129-
logging::snprintf(" destinations : ");
130-
for (uint32_t index = 0; index < 32; index++) {
131-
if ((activeDestinations & (0x01 << index)) != 0) {
132-
logging::snprintf("%s ", toString(static_cast<destination>(index)));
133-
}
134-
}
135-
logging::snprintf("\n");
136-
}
137104
const char *toString(const logging::source aSource) {
138105
switch (aSource) {
139106
case logging::source::applicationEvents:

lib/logging/logging.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ class logging {
4040
activeSources = 0;
4141
activeDestinations = 0;
4242
}
43-
static uint32_t snprintf(const char *format, ...); // logs always, to all active destinations
44-
static uint32_t snprintf(const source aSource, const char *format, ...); // logs to all active destinations, but only if the source is active
45-
static uint32_t snprintf(const destination aDestination, const char *format, ...); // logs to a specific destination
43+
static uint32_t snprintf(const char *format, ...);
44+
static uint32_t snprintf(const source aSource, const char *format, ...);
45+
static uint32_t snprintf(const destination aDestination, const char *format, ...);
46+
4647
static void enable(const source aSource) { activeSources = activeSources | (0x01 << static_cast<uint32_t>(aSource)); }
4748
static void disable(const source aSource) { activeSources = activeSources & ~(0x01 << static_cast<uint32_t>(aSource)); }
4849
static void enable(const destination aDestination) { activeDestinations = activeDestinations | (0x01 << static_cast<uint32_t>(aDestination)); }
@@ -63,7 +64,6 @@ class logging {
6364
static uint32_t getActiveDestinations() { return activeDestinations; }
6465
static void setActiveDestinations(const uint32_t aDestinations) { activeDestinations = aDestinations; }
6566

66-
static void dump();
6767
#ifndef unitTesting
6868

6969
private:

lib/qrcode/gf256.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ class gf256 {
812812
z = (z << 1) ^ ((z >> 7) * 0x11D);
813813
z ^= ((y >> i) & 1) * x;
814814
}
815-
return z;
815+
return static_cast<uint8_t>(z);
816816
}
817817

818818
static uint8_t inv(uint8_t a) {

lib/qrcode/qrcode.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -905,14 +905,13 @@ void qrCode::selectMask() {
905905

906906
#pragma endregion
907907

908-
// ?????
909-
910908
uint32_t qrCode::payloadLengthInBits(uint32_t dataLengthInBytes, uint32_t someVersion, encodingFormat someEncodingFormat) {
911909
uint32_t modeIndicatorLength{4U};
912910
switch (someEncodingFormat) {
913911
case encodingFormat::numeric:
914912
uint32_t remainderLength;
915913
switch (dataLengthInBytes % 3) {
914+
default: // intentional fallthrough
916915
case 0:
917916
remainderLength = 0;
918917
break;

lib/sensors/battery.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
class battery {
1414
public:
15+
static constexpr batteryType defaultBatteryType{batteryType::liFePO4_700mAh};
1516
static void setType(uint8_t index);
1617
static bool isValidType(batteryType newBatteryType);
1718
static void initialize(batteryType newBatteryType);

0 commit comments

Comments
 (0)