Files
tactility/Tactility/Source/service/displayidle/BouncingBallsScreensaver.h
T
Shadowtrance c05d46a28c Screensavers (#462)
Adds screensavers in addition to the backlight idle off. 
More info in screensavers.md

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Added a screensaver system with multiple styles (Bouncing Balls, Mystify, Matrix Rain) and a common screensaver interface; auto-starts after inactivity, dismisses on interaction, and supports auto-off/backlight behavior.
  * New Display setting and UI dropdown to choose and persist the screensaver.

* **Documentation**
  * Added comprehensive screensaver docs covering usage, extension, and configuration.

* **Chores**
  * Registered the display-idle service.

* **Bug Fixes**
  * Updated LVGL API calls to match renamed functions.

<sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-01-27 17:21:16 +01:00

60 lines
1.8 KiB
C++

#pragma once
#ifdef ESP_PLATFORM
#include "Screensaver.h"
#include <array>
#include <cstdint>
namespace tt::service::displayidle {
class BouncingBallsScreensaver final : public Screensaver {
public:
BouncingBallsScreensaver() = default;
~BouncingBallsScreensaver() override = default;
BouncingBallsScreensaver(const BouncingBallsScreensaver&) = delete;
BouncingBallsScreensaver& operator=(const BouncingBallsScreensaver&) = delete;
BouncingBallsScreensaver(BouncingBallsScreensaver&&) = delete;
BouncingBallsScreensaver& operator=(BouncingBallsScreensaver&&) = delete;
void start(lv_obj_t* overlay, lv_coord_t screenW, lv_coord_t screenH) override;
void stop() override;
void update(lv_coord_t screenW, lv_coord_t screenH) override;
private:
static constexpr int BALL_SIZE = 20;
static constexpr int NUM_BALLS = 5;
static constexpr int COLOR_FADE_STEPS = 15;
struct Ball {
lv_obj_t* obj = nullptr;
lv_coord_t x = 0;
lv_coord_t y = 0;
lv_coord_t dx = 0;
lv_coord_t dy = 0;
uint8_t currentR = 0, currentG = 0, currentB = 0;
uint8_t targetR = 0, targetG = 0, targetB = 0;
int colorStep = 0;
};
static constexpr std::array<uint32_t, 8> COLORS = {
0xFF0000, // Red
0x00FF00, // Green
0x0000FF, // Blue
0xFFFF00, // Yellow
0xFF00FF, // Magenta
0x00FFFF, // Cyan
0xFF8000, // Orange
0x80FF00, // Lime
};
std::array<Ball, NUM_BALLS> balls_;
void initBall(Ball& ball, lv_obj_t* parent, lv_coord_t screenW, lv_coord_t screenH, int index);
static void setRandomTargetColor(Ball& ball);
static void updateBallColor(Ball& ball);
};
} // namespace tt::service::displayidle
#endif // ESP_PLATFORM