mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 22:57:50 +03:00
Compare commits
38 Commits
b0b5e977ce
...
bcaae08ca0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcaae08ca0 | ||
|
|
78d6e5931c | ||
|
|
dac11c3fdd | ||
|
|
b96e62520b | ||
|
|
f5390a821e | ||
|
|
052b058643 | ||
|
|
1b607f6de1 | ||
|
|
3de8472501 | ||
|
|
a979a83732 | ||
|
|
12c764d117 | ||
|
|
44ddf110b2 | ||
|
|
1c3073f472 | ||
|
|
5ca778fe6a | ||
|
|
6791198522 | ||
|
|
a64a465f5b | ||
|
|
c198100709 | ||
|
|
ac291f2473 | ||
|
|
ab75dd08fb | ||
|
|
8cbd72bdae | ||
|
|
1e95a353bf | ||
|
|
72c96ef7ff | ||
|
|
a8bfa42f17 | ||
|
|
d2b6506d23 | ||
|
|
9de96e9812 | ||
|
|
31437e05fb | ||
|
|
170e16033e | ||
|
|
05e5db76f6 | ||
|
|
bf38e2c3dc | ||
|
|
511fa485be | ||
|
|
a5ade3fe81 | ||
|
|
73fbf2a812 | ||
|
|
91bcafebb9 | ||
|
|
cecf5a3fa7 | ||
|
|
7638680ee5 | ||
|
|
2a65d10925 | ||
|
|
0e6d7dd140 | ||
|
|
0b3e8f1102 | ||
|
|
68854812e9 |
@ -102,13 +102,18 @@ After flashing the new features, it’s recommended to capture detailed logs fro
|
||||
First, make sure all required Python packages are installed:
|
||||
|
||||
```python
|
||||
python3 -m pip install serial colorama matplotlib
|
||||
python3 -m pip install pyserial colorama matplotlib
|
||||
```
|
||||
after that run the script:
|
||||
```sh
|
||||
# For Linux
|
||||
# This was tested on Debian and should work on most Linux systems.
|
||||
python3 scripts/debugging_monitor.py
|
||||
|
||||
# For macOS
|
||||
python3 scripts/debugging_monitor.py /dev/cu.usbmodem2101
|
||||
```
|
||||
This was tested on Debian and should work on most Linux systems. Minor adjustments may be required for Windows or macOS.
|
||||
Minor adjustments may be required for Windows.
|
||||
|
||||
## Internals
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ void readAndValidate(FsFile& file, uint8_t& member, const uint8_t maxValue) {
|
||||
namespace {
|
||||
constexpr uint8_t SETTINGS_FILE_VERSION = 1;
|
||||
// Increment this when adding new persisted settings fields
|
||||
constexpr uint8_t SETTINGS_COUNT = 23;
|
||||
constexpr uint8_t SETTINGS_COUNT = 24;
|
||||
constexpr char SETTINGS_FILE[] = "/.crosspoint/settings.bin";
|
||||
} // namespace
|
||||
|
||||
@ -38,6 +38,7 @@ bool CrossPointSettings::saveToFile() const {
|
||||
serialization::writePod(outputFile, SETTINGS_FILE_VERSION);
|
||||
serialization::writePod(outputFile, SETTINGS_COUNT);
|
||||
serialization::writePod(outputFile, sleepScreen);
|
||||
serialization::writePod(outputFile, showSleepScreen);
|
||||
serialization::writePod(outputFile, extraParagraphSpacing);
|
||||
serialization::writePod(outputFile, shortPwrBtn);
|
||||
serialization::writePod(outputFile, statusBar);
|
||||
@ -148,6 +149,8 @@ bool CrossPointSettings::loadFromFile() {
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
readAndValidate(inputFile, sleepScreenCoverFilter, SLEEP_SCREEN_COVER_FILTER_COUNT);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, showSleepScreen);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
// New fields added at end for backward compatibility
|
||||
} while (false);
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ class CrossPointSettings {
|
||||
CrossPointSettings& operator=(const CrossPointSettings&) = delete;
|
||||
|
||||
enum SLEEP_SCREEN_MODE { DARK = 0, LIGHT = 1, CUSTOM = 2, COVER = 3, BLANK = 4, SLEEP_SCREEN_MODE_COUNT };
|
||||
enum SHOW_SLEEP_SCREEN { ALWAYS = 0, EXCEPT_TIMEOUT = 1, NEVER = 2 };
|
||||
enum SLEEP_SCREEN_COVER_MODE { FIT = 0, CROP = 1, SLEEP_SCREEN_COVER_MODE_COUNT };
|
||||
enum SLEEP_SCREEN_COVER_FILTER {
|
||||
NO_FILTER = 0,
|
||||
@ -99,6 +100,8 @@ class CrossPointSettings {
|
||||
|
||||
// Sleep screen settings
|
||||
uint8_t sleepScreen = DARK;
|
||||
// Show sleep screen settings
|
||||
uint8_t showSleepScreen = ALWAYS;
|
||||
// Sleep screen cover mode settings
|
||||
uint8_t sleepScreenCoverMode = FIT;
|
||||
// Sleep screen cover filter
|
||||
|
||||
@ -11,12 +11,20 @@
|
||||
#include "ScreenComponents.h"
|
||||
#include "fontIds.h"
|
||||
#include "images/CrossLarge.h"
|
||||
#include "images/MoonIcon.h"
|
||||
#include "util/StringUtils.h"
|
||||
|
||||
void SleepActivity::onEnter() {
|
||||
Activity::onEnter();
|
||||
const bool SHOW_SLEEP_SCREEN =
|
||||
SETTINGS.showSleepScreen == CrossPointSettings::SHOW_SLEEP_SCREEN::ALWAYS ||
|
||||
(!fromTimeout && SETTINGS.showSleepScreen == CrossPointSettings::SHOW_SLEEP_SCREEN::EXCEPT_TIMEOUT);
|
||||
|
||||
ScreenComponents::drawPopup(renderer, "Entering Sleep...");
|
||||
Activity::onEnter();
|
||||
if (SHOW_SLEEP_SCREEN) {
|
||||
ScreenComponents::drawPopup(renderer, "Entering Sleep...");
|
||||
} else {
|
||||
return renderLastScreenSleepScreen();
|
||||
}
|
||||
|
||||
if (SETTINGS.sleepScreen == CrossPointSettings::SLEEP_SCREEN_MODE::BLANK) {
|
||||
return renderBlankSleepScreen();
|
||||
@ -266,6 +274,13 @@ void SleepActivity::renderCoverSleepScreen() const {
|
||||
renderDefaultSleepScreen();
|
||||
}
|
||||
|
||||
void SleepActivity::renderLastScreenSleepScreen() const {
|
||||
const auto pageHeight = renderer.getScreenHeight();
|
||||
|
||||
renderer.drawImage(MoonIcon, 0, pageHeight - 48, 48, 48);
|
||||
renderer.displayBuffer(HalDisplay::HALF_REFRESH);
|
||||
}
|
||||
|
||||
void SleepActivity::renderBlankSleepScreen() const {
|
||||
renderer.clearScreen();
|
||||
renderer.displayBuffer(HalDisplay::HALF_REFRESH);
|
||||
|
||||
@ -5,8 +5,8 @@ class Bitmap;
|
||||
|
||||
class SleepActivity final : public Activity {
|
||||
public:
|
||||
explicit SleepActivity(GfxRenderer& renderer, MappedInputManager& mappedInput)
|
||||
: Activity("Sleep", renderer, mappedInput) {}
|
||||
explicit SleepActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, bool fromTimeout)
|
||||
: Activity("Sleep", renderer, mappedInput), fromTimeout(fromTimeout) {}
|
||||
void onEnter() override;
|
||||
|
||||
private:
|
||||
@ -14,5 +14,8 @@ class SleepActivity final : public Activity {
|
||||
void renderCustomSleepScreen() const;
|
||||
void renderCoverSleepScreen() const;
|
||||
void renderBitmapSleepScreen(const Bitmap& bitmap) const;
|
||||
void renderLastScreenSleepScreen() const;
|
||||
void renderBlankSleepScreen() const;
|
||||
|
||||
bool fromTimeout = false;
|
||||
};
|
||||
|
||||
@ -520,7 +520,7 @@ void WifiSelectionActivity::renderNetworkList() const {
|
||||
const auto height = renderer.getLineHeight(UI_10_FONT_ID);
|
||||
const auto top = (pageHeight - height) / 2;
|
||||
renderer.drawCenteredText(UI_10_FONT_ID, top, "No networks found");
|
||||
renderer.drawCenteredText(SMALL_FONT_ID, top + height + 10, "Press OK to scan again");
|
||||
renderer.drawCenteredText(SMALL_FONT_ID, top + height + 10, "Press Connect to scan again");
|
||||
} else {
|
||||
// Calculate how many networks we can display
|
||||
constexpr int startY = 60;
|
||||
|
||||
@ -11,10 +11,11 @@
|
||||
const char* SettingsActivity::categoryNames[categoryCount] = {"Display", "Reader", "Controls", "System"};
|
||||
|
||||
namespace {
|
||||
constexpr int displaySettingsCount = 6;
|
||||
constexpr int displaySettingsCount = 7;
|
||||
const SettingInfo displaySettings[displaySettingsCount] = {
|
||||
// Should match with SLEEP_SCREEN_MODE
|
||||
SettingInfo::Enum("Sleep Screen", &CrossPointSettings::sleepScreen, {"Dark", "Light", "Custom", "Cover", "None"}),
|
||||
SettingInfo::Enum("Show Sleep Screen", &CrossPointSettings::showSleepScreen, {"Always", "Except Timeout", "Never"}),
|
||||
SettingInfo::Enum("Sleep Screen Cover Mode", &CrossPointSettings::sleepScreenCoverMode, {"Fit", "Crop"}),
|
||||
SettingInfo::Enum("Sleep Screen Cover Filter", &CrossPointSettings::sleepScreenCoverFilter,
|
||||
{"None", "Contrast", "Inverted"}),
|
||||
|
||||
24
src/images/MoonIcon.h
Normal file
24
src/images/MoonIcon.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
// Image dimensions: 48x48
|
||||
#define MOONICON_WIDTH 48
|
||||
#define MOONICON_HEIGHT 48
|
||||
|
||||
static const uint8_t MoonIcon[] = {
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0xF9, 0xFF, 0xF0, 0xFF, 0xFF,
|
||||
0xFF, 0xC0, 0x1F, 0xF0, 0x3F, 0xFF, 0xFF, 0x00, 0x1F, 0xF8, 0x0F, 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FF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
@ -191,9 +191,9 @@ void waitForPowerRelease() {
|
||||
}
|
||||
|
||||
// Enter deep sleep mode
|
||||
void enterDeepSleep() {
|
||||
void enterDeepSleep(bool fromTimeout) {
|
||||
exitActivity();
|
||||
enterNewActivity(new SleepActivity(renderer, mappedInputManager));
|
||||
enterNewActivity(new SleepActivity(renderer, mappedInputManager, fromTimeout));
|
||||
|
||||
display.deepSleep();
|
||||
Serial.printf("[%lu] [ ] Power button press calibration value: %lu ms\n", millis(), t2 - t1);
|
||||
@ -359,13 +359,13 @@ void loop() {
|
||||
const unsigned long sleepTimeoutMs = SETTINGS.getSleepTimeoutMs();
|
||||
if (millis() - lastActivityTime >= sleepTimeoutMs) {
|
||||
Serial.printf("[%lu] [SLP] Auto-sleep triggered after %lu ms of inactivity\n", millis(), sleepTimeoutMs);
|
||||
enterDeepSleep();
|
||||
enterDeepSleep(true);
|
||||
// This should never be hit as `enterDeepSleep` calls esp_deep_sleep_start
|
||||
return;
|
||||
}
|
||||
|
||||
if (gpio.isPressed(HalGPIO::BTN_POWER) && gpio.getHeldTime() > SETTINGS.getPowerButtonDuration()) {
|
||||
enterDeepSleep();
|
||||
enterDeepSleep(false);
|
||||
// This should never be hit as `enterDeepSleep` calls esp_deep_sleep_start
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user