This repository has been archived on 2026-02-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
crosspoint-reader/src/activities/boot_sleep/SleepActivity.h
cottongin 4db384edb6
All checks were successful
CI / build (push) Successful in 2m23s
fix: prevent Serial.printf from blocking when USB disconnected
On ESP32-C3 with USB CDC, Serial.printf() blocks indefinitely when USB
is not connected. This caused device freezes when booted without USB.

Solution: Call Serial.setTxTimeoutMs(0) after Serial.begin() to make
all Serial output non-blocking.

Also added if (Serial) guards to high-traffic logging paths in
EpubReaderActivity as belt-and-suspenders protection.

Includes documentation of the debugging process and Serial call inventory.

Also applies clang-format to fix pre-existing formatting issues.
2026-01-28 16:16:11 -05:00

34 lines
1.2 KiB
C++

#pragma once
#include <Bitmap.h>
#include <string>
#include "../Activity.h"
class SleepActivity final : public Activity {
public:
explicit SleepActivity(GfxRenderer& renderer, MappedInputManager& mappedInput)
: Activity("Sleep", renderer, mappedInput) {}
void onEnter() override;
private:
void renderPopup(const char* message) const;
void renderDefaultSleepScreen() const;
void renderCustomSleepScreen() const;
void renderCoverSleepScreen() const;
void renderBitmapSleepScreen(const Bitmap& bitmap, const std::string& bmpPath) const;
void renderBlankSleepScreen() const;
// Edge luminance caching helpers
static std::string getEdgeCachePath(const std::string& bmpPath);
EdgeLuminance getEdgeLuminance(const Bitmap& bitmap, const std::string& bmpPath) const;
// Book-level edge cache helpers (for skipping book metadata loading)
static std::string getBookEdgeCachePath(const std::string& bookPath);
static std::string getCoverBmpPath(const std::string& cacheDir, const std::string& bookPath, bool cropped);
bool tryRenderCachedCoverSleep(const std::string& bookPath, bool cropped) const;
// Quantize luminance (0-255) to 4-level grayscale (0-3)
static uint8_t quantizeGray(uint8_t lum);
};