All checks were successful
CI / build (push) Successful in 2m23s
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.
61 lines
2.4 KiB
C++
61 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
class GfxRenderer;
|
|
|
|
struct TabInfo {
|
|
const char* label;
|
|
bool selected;
|
|
};
|
|
|
|
class ScreenComponents {
|
|
public:
|
|
static const int BOOK_PROGRESS_BAR_HEIGHT = 4;
|
|
|
|
static void drawBattery(const GfxRenderer& renderer, int left, int top, bool showPercentage = true);
|
|
static void drawBookProgressBar(const GfxRenderer& renderer, size_t bookProgress);
|
|
|
|
// Draw a larger battery icon suitable for bottom button hint area
|
|
static void drawBatteryLarge(const GfxRenderer& renderer, int left, int top, bool showPercentage = true);
|
|
|
|
// Draw a horizontal tab bar with underline indicator for selected tab
|
|
// Returns the height of the tab bar (for positioning content below)
|
|
// When selectedIndex is provided, tabs scroll so the selected tab is visible
|
|
// When showCursor is true, bullet indicators are drawn around the selected tab
|
|
static int drawTabBar(const GfxRenderer& renderer, int y, const std::vector<TabInfo>& tabs, int selectedIndex = -1,
|
|
bool showCursor = false);
|
|
|
|
// Draw a scroll/page indicator on the right side of the screen
|
|
// Shows up/down arrows and current page fraction (e.g., "1/3")
|
|
static void drawScrollIndicator(const GfxRenderer& renderer, int currentPage, int totalPages, int contentTop,
|
|
int contentHeight);
|
|
|
|
/**
|
|
* Draw a progress bar with percentage text.
|
|
* @param renderer The graphics renderer
|
|
* @param x Left position of the bar
|
|
* @param y Top position of the bar
|
|
* @param width Width of the bar
|
|
* @param height Height of the bar
|
|
* @param current Current progress value
|
|
* @param total Total value for 100% progress
|
|
*/
|
|
static void drawProgressBar(const GfxRenderer& renderer, int x, int y, int width, int height, size_t current,
|
|
size_t total);
|
|
|
|
/**
|
|
* Draw a pill-shaped badge with text.
|
|
* @param renderer The graphics renderer
|
|
* @param x Left position of the badge
|
|
* @param y Top position of the badge (baseline of text)
|
|
* @param text Text to display in the badge
|
|
* @param fontId Font ID to use for the text
|
|
* @param inverted If true, draw white fill with black text (for selected items)
|
|
* @return The width of the badge drawn (for chaining multiple badges)
|
|
*/
|
|
static int drawPillBadge(const GfxRenderer& renderer, int x, int y, const char* text, int fontId, bool inverted);
|
|
};
|