mirror of
https://github.com/usatiuk/cardboy.git
synced 2025-10-28 23:27:49 +01:00
Compare commits
9 Commits
9b5521fc28
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5532055cdc | |||
| 61f05b4e58 | |||
| 961da2ba33 | |||
| 96f5b1f0ee | |||
| f5a780c1c8 | |||
| 5c3cdaaae4 | |||
| f814c45532 | |||
| 65ee33a141 | |||
| 0e69debf39 |
@@ -18,6 +18,7 @@ public:
|
|||||||
float get_voltage() const;
|
float get_voltage() const;
|
||||||
float get_charge() const;
|
float get_charge() const;
|
||||||
float get_current() const;
|
float get_current() const;
|
||||||
|
float get_percentage() const;
|
||||||
|
|
||||||
void pooler(); // FIXME:
|
void pooler(); // FIXME:
|
||||||
private:
|
private:
|
||||||
@@ -33,6 +34,7 @@ private:
|
|||||||
volatile float _voltage;
|
volatile float _voltage;
|
||||||
volatile float _current;
|
volatile float _current;
|
||||||
volatile float _charge;
|
volatile float _charge;
|
||||||
|
volatile float _percentage;
|
||||||
|
|
||||||
TaskHandle_t _pooler_task;
|
TaskHandle_t _pooler_task;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ static constexpr uint16_t DesignCapMah = 180; // 100mOhm
|
|||||||
|
|
||||||
constexpr float mahToCap(float mah) { return mah * (1000.0 / 5.0) * RSense; }
|
constexpr float mahToCap(float mah) { return mah * (1000.0 / 5.0) * RSense; }
|
||||||
constexpr float capToMah(uint16_t cap) { return cap * (5.0 / 1000.0) / RSense; }
|
constexpr float capToMah(uint16_t cap) { return cap * (5.0 / 1000.0) / RSense; }
|
||||||
|
// lsb is 1/256%
|
||||||
|
constexpr float regToPercent(uint16_t reg) { return static_cast<float>(reg) / 256.0f; }
|
||||||
constexpr float regToCurrent(uint16_t reg) {
|
constexpr float regToCurrent(uint16_t reg) {
|
||||||
return static_cast<float>(static_cast<int16_t>(reg)) * 0.0015625f / RSense; // Convert to mA
|
return static_cast<float>(static_cast<int16_t>(reg)) * 0.0015625f / RSense; // Convert to mA
|
||||||
}
|
}
|
||||||
@@ -103,6 +105,7 @@ void BatMon::pooler() {
|
|||||||
_charge = capToMah(ReadRegister(0x05));
|
_charge = capToMah(ReadRegister(0x05));
|
||||||
_current = regToCurrent(ReadRegister(0x0B));
|
_current = regToCurrent(ReadRegister(0x0B));
|
||||||
_voltage = regToVoltage(ReadRegister(0x09));
|
_voltage = regToVoltage(ReadRegister(0x09));
|
||||||
|
_percentage = regToPercent(ReadRegister(0x06));
|
||||||
vTaskDelay(pdMS_TO_TICKS(10000));
|
vTaskDelay(pdMS_TO_TICKS(10000));
|
||||||
if (_voltage < 3.0f) {
|
if (_voltage < 3.0f) {
|
||||||
Shutdowner::get().shutdown();
|
Shutdowner::get().shutdown();
|
||||||
@@ -113,3 +116,4 @@ void BatMon::pooler() {
|
|||||||
float BatMon::get_voltage() const { return _voltage; }
|
float BatMon::get_voltage() const { return _voltage; }
|
||||||
float BatMon::get_charge() const { return _charge; }
|
float BatMon::get_charge() const { return _charge; }
|
||||||
float BatMon::get_current() const { return _current; }
|
float BatMon::get_current() const { return _current; }
|
||||||
|
float BatMon::get_percentage() const { return _percentage; }
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ public:
|
|||||||
[[nodiscard]] float voltage() const override { return BatMon::get().get_voltage(); }
|
[[nodiscard]] float voltage() const override { return BatMon::get().get_voltage(); }
|
||||||
[[nodiscard]] float charge() const override { return BatMon::get().get_charge(); }
|
[[nodiscard]] float charge() const override { return BatMon::get().get_charge(); }
|
||||||
[[nodiscard]] float current() const override { return BatMon::get().get_current(); }
|
[[nodiscard]] float current() const override { return BatMon::get().get_current(); }
|
||||||
|
[[nodiscard]] float percentage() const override { return BatMon::get().get_percentage(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class EspRuntime::StorageService final : public cardboy::sdk::IStorage {
|
class EspRuntime::StorageService final : public cardboy::sdk::IStorage {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <cmath>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -31,12 +32,12 @@ using Framebuffer = typename AppContext::Framebuffer;
|
|||||||
using Clock = typename AppContext::Clock;
|
using Clock = typename AppContext::Clock;
|
||||||
|
|
||||||
constexpr std::array<std::uint8_t, font16x8::kGlyphHeight> kArrowUpGlyph{
|
constexpr std::array<std::uint8_t, font16x8::kGlyphHeight> kArrowUpGlyph{
|
||||||
0b00011000, 0b00111100, 0b01111110, 0b11111111, 0b00011000, 0b00011000, 0b00011000, 0b00011000,
|
0b00010000, 0b00111000, 0b01111100, 0b11111110, 0b00010000, 0b00010000, 0b00010000, 0b00010000,
|
||||||
0b00011000, 0b00011000, 0b00011000, 0b00011000, 0b00011000, 0b00011000, 0b00000000, 0b00000000};
|
0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00000000, 0b00000000};
|
||||||
|
|
||||||
constexpr std::array<std::uint8_t, font16x8::kGlyphHeight> kArrowDownGlyph{
|
constexpr std::array<std::uint8_t, font16x8::kGlyphHeight> kArrowDownGlyph{
|
||||||
0b00000000, 0b00000000, 0b00011000, 0b00011000, 0b00011000, 0b00011000, 0b00011000, 0b00011000,
|
0b00000000, 0b00000000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00010000,
|
||||||
0b00011000, 0b00011000, 0b00011000, 0b11111111, 0b01111110, 0b00111100, 0b00011000, 0b00000000};
|
0b00010000, 0b00010000, 0b00010000, 0b11111110, 0b01111100, 0b00111000, 0b00010000, 0b00000000};
|
||||||
|
|
||||||
struct TimeSnapshot {
|
struct TimeSnapshot {
|
||||||
bool hasWallTime = false;
|
bool hasWallTime = false;
|
||||||
@@ -130,12 +131,14 @@ private:
|
|||||||
if (!notifications.empty() && (upPressed || downPressed)) {
|
if (!notifications.empty() && (upPressed || downPressed)) {
|
||||||
const std::size_t count = notifications.size();
|
const std::size_t count = notifications.size();
|
||||||
lastNotificationInteractionMs = clock.millis();
|
lastNotificationInteractionMs = clock.millis();
|
||||||
navPressed = true;
|
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
if (upPressed)
|
if (upPressed && selectedNotification > 0) {
|
||||||
selectedNotification = (selectedNotification + count - 1) % count;
|
selectedNotification--;
|
||||||
else if (downPressed)
|
navPressed = true;
|
||||||
selectedNotification = (selectedNotification + 1) % count;
|
} else if (downPressed && selectedNotification < count - 1) {
|
||||||
|
selectedNotification++;
|
||||||
|
navPressed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,6 +447,25 @@ private:
|
|||||||
|
|
||||||
framebuffer.frameReady();
|
framebuffer.frameReady();
|
||||||
|
|
||||||
|
const std::uint32_t nowMs = clock.millis();
|
||||||
|
const bool hasNotifications = !notifications.empty();
|
||||||
|
const bool showNotificationDetails =
|
||||||
|
hasNotifications && (nowMs - lastNotificationInteractionMs <= kNotificationHideMs);
|
||||||
|
|
||||||
|
if (!showNotificationDetails) {
|
||||||
|
if (auto* battery = context.battery(); battery && battery->hasData()) {
|
||||||
|
const float percentage = battery->percentage();
|
||||||
|
if (std::isfinite(percentage) && percentage >= 0.0f) {
|
||||||
|
char pct[8];
|
||||||
|
std::snprintf(pct, sizeof(pct), "%.0f%%", static_cast<double>(percentage));
|
||||||
|
const int pctWidth = font16x8::measureText(pct, 1, 1);
|
||||||
|
const int pctX = framebuffer.width() - pctWidth - 4;
|
||||||
|
const int pctY = 4;
|
||||||
|
font16x8::drawText(framebuffer, pctX, pctY, pct, 1, true, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const int scaleTime = 4;
|
const int scaleTime = 4;
|
||||||
const int scaleSeconds = 2;
|
const int scaleSeconds = 2;
|
||||||
const int scaleSmall = 1;
|
const int scaleSmall = 1;
|
||||||
@@ -456,10 +478,6 @@ private:
|
|||||||
int cardHeight = 0;
|
int cardHeight = 0;
|
||||||
const int cardWidth = framebuffer.width() - cardMarginSide * 2;
|
const int cardWidth = framebuffer.width() - cardMarginSide * 2;
|
||||||
|
|
||||||
const std::uint32_t nowMs = clock.millis();
|
|
||||||
const bool hasNotifications = !notifications.empty();
|
|
||||||
const bool showNotificationDetails =
|
|
||||||
hasNotifications && (nowMs - lastNotificationInteractionMs <= kNotificationHideMs);
|
|
||||||
|
|
||||||
if (hasNotifications) {
|
if (hasNotifications) {
|
||||||
const auto& note = notifications[selectedNotification];
|
const auto& note = notifications[selectedNotification];
|
||||||
@@ -500,8 +518,10 @@ private:
|
|||||||
const int arrowsTotalWide = arrowWidth * 2 + arrowSpacing;
|
const int arrowsTotalWide = arrowWidth * 2 + arrowSpacing;
|
||||||
const int arrowX = counterX + (counterWidth - arrowsTotalWide) / 2;
|
const int arrowX = counterX + (counterWidth - arrowsTotalWide) / 2;
|
||||||
const int arrowY = cardMarginTop + cardPadding + textLineHeight + 1;
|
const int arrowY = cardMarginTop + cardPadding + textLineHeight + 1;
|
||||||
drawArrow(framebuffer, arrowX, arrowY, true, scaleSmall);
|
if (selectedNotification > 0)
|
||||||
drawArrow(framebuffer, arrowX + arrowWidth + arrowSpacing, arrowY, false, scaleSmall);
|
drawArrow(framebuffer, arrowX, arrowY, true, scaleSmall);
|
||||||
|
if (selectedNotification < notifications.size() - 1)
|
||||||
|
drawArrow(framebuffer, arrowX + arrowWidth + arrowSpacing, arrowY, false, scaleSmall);
|
||||||
const int arrowHeight = font16x8::kGlyphHeight * scaleSmall;
|
const int arrowHeight = font16x8::kGlyphHeight * scaleSmall;
|
||||||
cardHeight = std::max(cardHeight, arrowY + arrowHeight - cardMarginTop);
|
cardHeight = std::max(cardHeight, arrowY + arrowHeight - cardMarginTop);
|
||||||
}
|
}
|
||||||
@@ -524,28 +544,13 @@ private:
|
|||||||
const int summaryX = (framebuffer.width() - summaryWidth) / 2;
|
const int summaryX = (framebuffer.width() - summaryWidth) / 2;
|
||||||
const int summaryY = cardMarginTop;
|
const int summaryY = cardMarginTop;
|
||||||
font16x8::drawText(framebuffer, summaryX, summaryY, summary, scaleSmall, true, 1);
|
font16x8::drawText(framebuffer, summaryX, summaryY, summary, scaleSmall, true, 1);
|
||||||
|
|
||||||
if (notifications.size() > 1) {
|
|
||||||
const int arrowWidth = font16x8::kGlyphWidth * scaleSmall;
|
|
||||||
const int arrowSpacing = std::max(1, scaleSmall);
|
|
||||||
const int arrowsTotalWide = arrowWidth * 2 + arrowSpacing;
|
|
||||||
const int arrowX = (framebuffer.width() - arrowsTotalWide) / 2;
|
|
||||||
const int arrowY = summaryY + textLineHeight + 1;
|
|
||||||
drawArrow(framebuffer, arrowX, arrowY, true, scaleSmall);
|
|
||||||
drawArrow(framebuffer, arrowX + arrowWidth + arrowSpacing, arrowY, false, scaleSmall);
|
|
||||||
const int arrowHeight = font16x8::kGlyphHeight * scaleSmall;
|
|
||||||
cardHeight = std::max(cardHeight, arrowY + arrowHeight - cardMarginTop);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const int defaultTimeY = (framebuffer.height() - font16x8::kGlyphHeight * scaleTime) / 2 - 8;
|
const int defaultTimeY = (framebuffer.height() - font16x8::kGlyphHeight * scaleTime) / 2 - 8;
|
||||||
int timeY = defaultTimeY;
|
const int minTimeY = (cardHeight > 0) ? (cardMarginTop + cardHeight + 12) : 16;
|
||||||
if (cardHeight > 0)
|
const int maxTimeY = std::max(minTimeY, framebuffer.height() - font16x8::kGlyphHeight * scaleTime - 48);
|
||||||
timeY = cardMarginTop + cardHeight + 16;
|
const int timeY = std::clamp(defaultTimeY, minTimeY, maxTimeY);
|
||||||
const int minTimeY = (cardHeight > 0) ? (cardMarginTop + cardHeight + 12) : 16;
|
|
||||||
const int maxTimeY = std::max(minTimeY, framebuffer.height() - font16x8::kGlyphHeight * scaleTime - 48);
|
|
||||||
timeY = std::clamp(timeY, minTimeY, maxTimeY);
|
|
||||||
|
|
||||||
char hoursMinutes[6];
|
char hoursMinutes[6];
|
||||||
std::snprintf(hoursMinutes, sizeof(hoursMinutes), "%02d:%02d", snap.hour24, snap.minute);
|
std::snprintf(hoursMinutes, sizeof(hoursMinutes), "%02d:%02d", snap.hour24, snap.minute);
|
||||||
@@ -562,24 +567,18 @@ private:
|
|||||||
const std::string dateLine = formatDate(snap);
|
const std::string dateLine = formatDate(snap);
|
||||||
drawCenteredText(framebuffer, timeY + font16x8::kGlyphHeight * scaleTime + 16, dateLine, scaleSmall, 1);
|
drawCenteredText(framebuffer, timeY + font16x8::kGlyphHeight * scaleTime + 16, dateLine, scaleSmall, 1);
|
||||||
|
|
||||||
const std::string instruction = holdActive ? "KEEP HOLDING A+SELECT" : "HOLD A+SELECT";
|
const std::string instruction = "HOLD A+SELECT TO UNLOCK";
|
||||||
const int instructionWidth = font16x8::measureText(instruction, scaleSmall, 1);
|
const int instructionWidth = font16x8::measureText(instruction, scaleSmall, 1);
|
||||||
const int barHeight = 14;
|
const int barHeight = 18;
|
||||||
const int barY = framebuffer.height() - 24;
|
const int barY = framebuffer.height() - 30;
|
||||||
const int textY = barY + (barHeight - textLineHeight) / 2;
|
const int textY = barY + (barHeight - textLineHeight) / 2 + 1;
|
||||||
const int textX = 8;
|
drawCenteredText(framebuffer, textY, instruction, scaleSmall, 1);
|
||||||
font16x8::drawText(framebuffer, textX, textY, instruction, scaleSmall, true, 1);
|
|
||||||
|
|
||||||
int barX = textX + instructionWidth + 12;
|
const int barWidth = framebuffer.width() - 64;
|
||||||
int barWidth = framebuffer.width() - barX - 8;
|
const int barX = 32;
|
||||||
if (barWidth < 40) {
|
|
||||||
barWidth = 40;
|
|
||||||
barX = std::min(barX, framebuffer.width() - barWidth - 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
drawRectOutline(framebuffer, barX, barY, barWidth, barHeight);
|
|
||||||
|
|
||||||
if (holdActive || holdProgressMs > 0) {
|
if (holdActive || holdProgressMs > 0) {
|
||||||
|
drawRectOutline(framebuffer, barX, barY, barWidth, barHeight);
|
||||||
const int innerWidth = barWidth - 2;
|
const int innerWidth = barWidth - 2;
|
||||||
const int innerHeight = barHeight - 2;
|
const int innerHeight = barHeight - 2;
|
||||||
const float ratio = std::clamp(holdProgressMs / static_cast<float>(kUnlockHoldMs), 0.0f, 1.0f);
|
const float ratio = std::clamp(holdProgressMs / static_cast<float>(kUnlockHoldMs), 0.0f, 1.0f);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ using cardboy::sdk::InputState;
|
|||||||
constexpr char kSnakeAppName[] = "Snake";
|
constexpr char kSnakeAppName[] = "Snake";
|
||||||
|
|
||||||
constexpr int kBoardWidth = 32;
|
constexpr int kBoardWidth = 32;
|
||||||
constexpr int kBoardHeight = 20;
|
constexpr int kBoardHeight = 18;
|
||||||
constexpr int kCellSize = 10;
|
constexpr int kCellSize = 10;
|
||||||
constexpr int kInitialSnakeLength = 5;
|
constexpr int kInitialSnakeLength = 5;
|
||||||
constexpr int kScorePerFood = 10;
|
constexpr int kScorePerFood = 10;
|
||||||
|
|||||||
@@ -11,6 +11,13 @@ struct InputState {
|
|||||||
bool b = false;
|
bool b = false;
|
||||||
bool select = false;
|
bool select = false;
|
||||||
bool start = false;
|
bool start = false;
|
||||||
|
|
||||||
|
bool operator==(const InputState& other) const {
|
||||||
|
return up == other.up && left == other.left && right == other.right && down == other.down && a == other.a &&
|
||||||
|
b == other.b && select == other.select && start == other.start;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const InputState& other) const { return !(*this == other); }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cardboy::sdk
|
} // namespace cardboy::sdk
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public:
|
|||||||
[[nodiscard]] virtual float voltage() const { return 0.0f; }
|
[[nodiscard]] virtual float voltage() const { return 0.0f; }
|
||||||
[[nodiscard]] virtual float charge() const { return 0.0f; }
|
[[nodiscard]] virtual float charge() const { return 0.0f; }
|
||||||
[[nodiscard]] virtual float current() const { return 0.0f; }
|
[[nodiscard]] virtual float current() const { return 0.0f; }
|
||||||
|
[[nodiscard]] virtual float percentage() const { return 0.0f; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class IStorage {
|
class IStorage {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
#include <SFML/Window/Keyboard.hpp>
|
#include <SFML/Window/Keyboard.hpp>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <deque>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <deque>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -40,240 +40,232 @@ public:
|
|||||||
class DesktopBattery final : public cardboy::sdk::IBatteryMonitor {
|
class DesktopBattery final : public cardboy::sdk::IBatteryMonitor {
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] bool hasData() const override { return false; }
|
[[nodiscard]] bool hasData() const override { return false; }
|
||||||
};
|
|
||||||
|
|
||||||
class DesktopStorage final : public cardboy::sdk::IStorage {
|
class DesktopStorage final : public cardboy::sdk::IStorage {
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] bool readUint32(std::string_view ns, std::string_view key, std::uint32_t& out) override;
|
[[nodiscard]] bool readUint32(std::string_view ns, std::string_view key, std::uint32_t& out) override;
|
||||||
void writeUint32(std::string_view ns, std::string_view key, std::uint32_t value) override;
|
void writeUint32(std::string_view ns, std::string_view key, std::uint32_t value) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<std::string, std::uint32_t> data;
|
std::unordered_map<std::string, std::uint32_t> data;
|
||||||
|
|
||||||
static std::string composeKey(std::string_view ns, std::string_view key);
|
static std::string composeKey(std::string_view ns, std::string_view key);
|
||||||
};
|
|
||||||
|
|
||||||
class DesktopRandom final : public cardboy::sdk::IRandom {
|
|
||||||
public:
|
|
||||||
DesktopRandom();
|
|
||||||
|
|
||||||
[[nodiscard]] std::uint32_t nextUint32() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::mt19937 rng;
|
|
||||||
std::uniform_int_distribution<std::uint32_t> dist;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DesktopHighResClock final : public cardboy::sdk::IHighResClock {
|
|
||||||
public:
|
|
||||||
DesktopHighResClock();
|
|
||||||
|
|
||||||
[[nodiscard]] std::uint64_t micros() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const std::chrono::steady_clock::time_point start;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DesktopFilesystem final : public cardboy::sdk::IFilesystem {
|
|
||||||
public:
|
|
||||||
DesktopFilesystem();
|
|
||||||
|
|
||||||
bool mount() override;
|
|
||||||
[[nodiscard]] bool isMounted() const override { return mounted; }
|
|
||||||
[[nodiscard]] std::string basePath() const override { return basePathPath.string(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::filesystem::path basePathPath;
|
|
||||||
bool mounted = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DesktopNotificationCenter final : public cardboy::sdk::INotificationCenter {
|
|
||||||
public:
|
|
||||||
void pushNotification(Notification notification) override;
|
|
||||||
[[nodiscard]] std::uint32_t revision() const override;
|
|
||||||
[[nodiscard]] std::vector<Notification> recent(std::size_t limit) const override;
|
|
||||||
void markAllRead() override;
|
|
||||||
void clear() override;
|
|
||||||
void removeById(std::uint64_t id) override;
|
|
||||||
void removeByExternalId(std::uint64_t externalId) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
static constexpr std::size_t kMaxEntries = 8;
|
|
||||||
|
|
||||||
mutable std::mutex mutex;
|
|
||||||
std::vector<Notification> entries;
|
|
||||||
std::uint64_t nextId = 1;
|
|
||||||
std::uint32_t revisionCounter = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DesktopEventBus final : public cardboy::sdk::IEventBus {
|
|
||||||
public:
|
|
||||||
explicit DesktopEventBus(DesktopRuntime& owner);
|
|
||||||
|
|
||||||
void signal(std::uint32_t bits) override;
|
|
||||||
void signalFromISR(std::uint32_t bits) override;
|
|
||||||
std::uint32_t wait(std::uint32_t mask, std::uint32_t timeout_ms) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
DesktopRuntime& runtime;
|
|
||||||
std::mutex mutex;
|
|
||||||
std::condition_variable cv;
|
|
||||||
std::uint32_t pendingBits = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DesktopScopedEventBus final : public cardboy::sdk::IAppEventBus {
|
|
||||||
public:
|
|
||||||
explicit DesktopScopedEventBus(cardboy::sdk::IEventBus& bus);
|
|
||||||
|
|
||||||
void post(const cardboy::sdk::AppEvent& event) override;
|
|
||||||
bool pop(cardboy::sdk::AppEvent& outEvent) override;
|
|
||||||
void clear() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
cardboy::sdk::IEventBus& globalBus;
|
|
||||||
std::mutex mutex;
|
|
||||||
std::deque<cardboy::sdk::AppEvent> queue;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DesktopTimerService final : public cardboy::sdk::ITimerService {
|
|
||||||
public:
|
|
||||||
DesktopTimerService(DesktopRuntime& owner, cardboy::sdk::IAppEventBus& appBus);
|
|
||||||
~DesktopTimerService() override;
|
|
||||||
|
|
||||||
cardboy::sdk::AppTimerHandle scheduleTimer(std::uint32_t delay_ms, bool repeat) override;
|
|
||||||
void cancelTimer(cardboy::sdk::AppTimerHandle handle) override;
|
|
||||||
void cancelAllTimers() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct TimerRecord {
|
|
||||||
cardboy::sdk::AppTimerHandle handle = cardboy::sdk::kInvalidAppTimer;
|
|
||||||
std::chrono::steady_clock::time_point due;
|
|
||||||
std::chrono::milliseconds interval{0};
|
|
||||||
bool repeat = false;
|
|
||||||
bool active = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void workerLoop();
|
class DesktopRandom final : public cardboy::sdk::IRandom {
|
||||||
void wakeWorker();
|
public:
|
||||||
void cleanupInactive();
|
DesktopRandom();
|
||||||
|
|
||||||
DesktopRuntime& runtime;
|
[[nodiscard]] std::uint32_t nextUint32() override;
|
||||||
cardboy::sdk::IAppEventBus& appEventBus;
|
|
||||||
std::mutex mutex;
|
|
||||||
std::condition_variable cv;
|
|
||||||
std::vector<TimerRecord> timers;
|
|
||||||
bool stopWorker = false;
|
|
||||||
std::thread worker;
|
|
||||||
cardboy::sdk::AppTimerHandle nextHandle = 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DesktopAppServiceProvider final : public cardboy::sdk::IAppServiceProvider {
|
private:
|
||||||
public:
|
std::mt19937 rng;
|
||||||
DesktopAppServiceProvider(DesktopRuntime& owner, cardboy::sdk::IEventBus& bus);
|
std::uniform_int_distribution<std::uint32_t> dist;
|
||||||
|
|
||||||
[[nodiscard]] std::unique_ptr<cardboy::sdk::AppScopedServices> createScopedServices(std::uint64_t generation) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct ScopedServices final : cardboy::sdk::AppScopedServices {
|
|
||||||
std::unique_ptr<DesktopScopedEventBus> ownedEventBus;
|
|
||||||
std::unique_ptr<DesktopTimerService> ownedTimer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DesktopRuntime& runtime;
|
class DesktopHighResClock final : public cardboy::sdk::IHighResClock {
|
||||||
cardboy::sdk::IEventBus& eventBus;
|
public:
|
||||||
};
|
DesktopHighResClock();
|
||||||
|
|
||||||
class DesktopFramebuffer final : public cardboy::sdk::FramebufferFacade<DesktopFramebuffer> {
|
[[nodiscard]] std::uint64_t micros() override;
|
||||||
public:
|
|
||||||
explicit DesktopFramebuffer(DesktopRuntime& runtime);
|
|
||||||
|
|
||||||
[[nodiscard]] int width_impl() const;
|
private:
|
||||||
[[nodiscard]] int height_impl() const;
|
const std::chrono::steady_clock::time_point start;
|
||||||
void drawPixel_impl(int x, int y, bool on);
|
};
|
||||||
void clear_impl(bool on);
|
|
||||||
void frameReady_impl();
|
|
||||||
void sendFrame_impl(bool clearAfterSend);
|
|
||||||
[[nodiscard]] bool frameInFlight_impl() const { return false; }
|
|
||||||
|
|
||||||
private:
|
class DesktopFilesystem final : public cardboy::sdk::IFilesystem {
|
||||||
DesktopRuntime& runtime;
|
public:
|
||||||
};
|
DesktopFilesystem();
|
||||||
|
|
||||||
class DesktopInput final : public cardboy::sdk::InputFacade<DesktopInput> {
|
bool mount() override;
|
||||||
public:
|
[[nodiscard]] bool isMounted() const override { return mounted; }
|
||||||
explicit DesktopInput(DesktopRuntime& runtime);
|
[[nodiscard]] std::string basePath() const override { return basePathPath.string(); }
|
||||||
|
|
||||||
cardboy::sdk::InputState readState_impl();
|
private:
|
||||||
void handleKey(sf::Keyboard::Key key, bool pressed);
|
std::filesystem::path basePathPath;
|
||||||
|
bool mounted = false;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
class DesktopNotificationCenter final : public cardboy::sdk::INotificationCenter {
|
||||||
DesktopRuntime& runtime;
|
public:
|
||||||
cardboy::sdk::InputState state{};
|
void pushNotification(Notification notification) override;
|
||||||
};
|
[[nodiscard]] std::uint32_t revision() const override;
|
||||||
|
[[nodiscard]] std::vector<Notification> recent(std::size_t limit) const override;
|
||||||
|
void markAllRead() override;
|
||||||
|
void clear() override;
|
||||||
|
void removeById(std::uint64_t id) override;
|
||||||
|
void removeByExternalId(std::uint64_t externalId) override;
|
||||||
|
|
||||||
class DesktopClock final : public cardboy::sdk::ClockFacade<DesktopClock> {
|
private:
|
||||||
public:
|
static constexpr std::size_t kMaxEntries = 8;
|
||||||
explicit DesktopClock(DesktopRuntime& runtime);
|
|
||||||
|
|
||||||
std::uint32_t millis_impl();
|
mutable std::mutex mutex;
|
||||||
void sleep_ms_impl(std::uint32_t ms);
|
std::vector<Notification> entries;
|
||||||
|
std::uint64_t nextId = 1;
|
||||||
|
std::uint32_t revisionCounter = 0;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
class DesktopLoopHooks final : public cardboy::sdk::ILoopHooks {
|
||||||
DesktopRuntime& runtime;
|
public:
|
||||||
const std::chrono::steady_clock::time_point start;
|
explicit DesktopLoopHooks(DesktopRuntime& owner);
|
||||||
};
|
|
||||||
|
|
||||||
class DesktopRuntime {
|
void onLoopIteration() override;
|
||||||
public:
|
|
||||||
DesktopRuntime();
|
|
||||||
|
|
||||||
cardboy::sdk::Services& serviceRegistry();
|
private:
|
||||||
void processEvents();
|
DesktopRuntime& runtime;
|
||||||
void presentIfNeeded();
|
};
|
||||||
void sleepFor(std::uint32_t ms);
|
|
||||||
|
|
||||||
[[nodiscard]] bool isRunning() const { return running; }
|
class DesktopEventBus final : public cardboy::sdk::IEventBus {
|
||||||
|
public:
|
||||||
|
void post(const cardboy::sdk::AppEvent& event) override;
|
||||||
|
std::optional<cardboy::sdk::AppEvent> pop(std::optional<std::uint32_t> timeout_ms = std::nullopt) override;
|
||||||
|
|
||||||
DesktopFramebuffer framebuffer;
|
private:
|
||||||
DesktopInput input;
|
std::mutex mutex;
|
||||||
DesktopClock clock;
|
std::condition_variable cv;
|
||||||
|
std::deque<cardboy::sdk::AppEvent> queue;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
class DesktopTimerService final : public cardboy::sdk::ITimerService {
|
||||||
friend class DesktopFramebuffer;
|
public:
|
||||||
friend class DesktopInput;
|
DesktopTimerService(DesktopRuntime& owner, cardboy::sdk::IEventBus& eventBus);
|
||||||
friend class DesktopClock;
|
~DesktopTimerService() override;
|
||||||
|
|
||||||
void setPixel(int x, int y, bool on);
|
cardboy::sdk::AppTimerHandle scheduleTimer(std::uint32_t delay_ms, bool repeat) override;
|
||||||
void clearPixels(bool on);
|
void cancelTimer(cardboy::sdk::AppTimerHandle handle) override;
|
||||||
|
void cancelAllTimers() override;
|
||||||
|
|
||||||
sf::RenderWindow window;
|
private:
|
||||||
sf::Texture texture;
|
struct TimerRecord {
|
||||||
sf::Sprite sprite;
|
cardboy::sdk::AppTimerHandle handle = cardboy::sdk::kInvalidAppTimer;
|
||||||
std::vector<std::uint8_t> pixels;
|
std::chrono::steady_clock::time_point due;
|
||||||
bool dirty = true;
|
std::chrono::milliseconds interval{0};
|
||||||
bool running = true;
|
bool repeat = false;
|
||||||
bool clearNextFrame = true;
|
bool active = true;
|
||||||
|
};
|
||||||
|
|
||||||
DesktopBuzzer buzzerService;
|
void workerLoop();
|
||||||
DesktopBattery batteryService;
|
void wakeWorker();
|
||||||
DesktopStorage storageService;
|
void cleanupInactive();
|
||||||
DesktopRandom randomService;
|
|
||||||
DesktopHighResClock highResService;
|
|
||||||
DesktopFilesystem filesystemService;
|
|
||||||
DesktopEventBus eventBusService;
|
|
||||||
DesktopAppServiceProvider appServiceProvider;
|
|
||||||
DesktopNotificationCenter notificationService;
|
|
||||||
cardboy::sdk::Services services{};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Backend {
|
DesktopRuntime& runtime;
|
||||||
using Framebuffer = DesktopFramebuffer;
|
cardboy::sdk::IEventBus& eventBus;
|
||||||
using Input = DesktopInput;
|
std::mutex mutex;
|
||||||
using Clock = DesktopClock;
|
std::condition_variable cv;
|
||||||
};
|
std::vector<TimerRecord> timers;
|
||||||
|
bool stopWorker = false;
|
||||||
|
std::thread worker;
|
||||||
|
cardboy::sdk::AppTimerHandle nextHandle = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DesktopAppServiceProvider final : public cardboy::sdk::IAppServiceProvider {
|
||||||
|
public:
|
||||||
|
DesktopAppServiceProvider(DesktopRuntime& owner, cardboy::sdk::IEventBus& bus);
|
||||||
|
|
||||||
|
[[nodiscard]] std::unique_ptr<cardboy::sdk::AppScopedServices>
|
||||||
|
createScopedServices(std::uint64_t generation) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct ScopedServices final : cardboy::sdk::AppScopedServices {
|
||||||
|
std::unique_ptr<DesktopTimerService> ownedTimer;
|
||||||
|
};
|
||||||
|
|
||||||
|
DesktopRuntime& runtime;
|
||||||
|
cardboy::sdk::IEventBus& eventBus;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DesktopFramebuffer final : public cardboy::sdk::FramebufferFacade<DesktopFramebuffer> {
|
||||||
|
public:
|
||||||
|
explicit DesktopFramebuffer(DesktopRuntime& runtime);
|
||||||
|
|
||||||
|
[[nodiscard]] int width_impl() const;
|
||||||
|
[[nodiscard]] int height_impl() const;
|
||||||
|
void drawPixel_impl(int x, int y, bool on);
|
||||||
|
void clear_impl(bool on);
|
||||||
|
void frameReady_impl();
|
||||||
|
void sendFrame_impl(bool clearAfterSend);
|
||||||
|
[[nodiscard]] bool frameInFlight_impl() const { return false; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
DesktopRuntime& runtime;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DesktopInput final : public cardboy::sdk::InputFacade<DesktopInput> {
|
||||||
|
public:
|
||||||
|
explicit DesktopInput(DesktopRuntime& runtime);
|
||||||
|
|
||||||
|
cardboy::sdk::InputState readState_impl();
|
||||||
|
void handleKey(sf::Keyboard::Key key, bool pressed);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DesktopRuntime& runtime;
|
||||||
|
cardboy::sdk::InputState state{};
|
||||||
|
};
|
||||||
|
|
||||||
|
class DesktopClock final : public cardboy::sdk::ClockFacade<DesktopClock> {
|
||||||
|
public:
|
||||||
|
explicit DesktopClock(DesktopRuntime& runtime);
|
||||||
|
|
||||||
|
std::uint32_t millis_impl();
|
||||||
|
void sleep_ms_impl(std::uint32_t ms);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DesktopRuntime& runtime;
|
||||||
|
const std::chrono::steady_clock::time_point start;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DesktopRuntime {
|
||||||
|
public:
|
||||||
|
DesktopRuntime();
|
||||||
|
|
||||||
|
cardboy::sdk::Services& serviceRegistry();
|
||||||
|
void processEvents();
|
||||||
|
void presentIfNeeded();
|
||||||
|
void sleepFor(std::uint32_t ms);
|
||||||
|
|
||||||
|
[[nodiscard]] bool isRunning() const { return running; }
|
||||||
|
|
||||||
|
DesktopFramebuffer framebuffer;
|
||||||
|
DesktopInput input;
|
||||||
|
DesktopClock clock;
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class DesktopFramebuffer;
|
||||||
|
friend class DesktopInput;
|
||||||
|
friend class DesktopClock;
|
||||||
|
|
||||||
|
void setPixel(int x, int y, bool on);
|
||||||
|
void clearPixels(bool on);
|
||||||
|
|
||||||
|
sf::RenderWindow window;
|
||||||
|
sf::Texture texture;
|
||||||
|
sf::Sprite sprite;
|
||||||
|
std::vector<std::uint8_t> pixels;
|
||||||
|
bool dirty = true;
|
||||||
|
bool running = true;
|
||||||
|
bool clearNextFrame = true;
|
||||||
|
|
||||||
|
DesktopBuzzer buzzerService;
|
||||||
|
DesktopBattery batteryService;
|
||||||
|
DesktopStorage storageService;
|
||||||
|
DesktopRandom randomService;
|
||||||
|
DesktopHighResClock highResService;
|
||||||
|
DesktopFilesystem filesystemService;
|
||||||
|
DesktopEventBus eventBusService;
|
||||||
|
DesktopAppServiceProvider appServiceProvider;
|
||||||
|
DesktopNotificationCenter notificationService;
|
||||||
|
DesktopLoopHooks loopHooksService;
|
||||||
|
cardboy::sdk::Services services{};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Backend {
|
||||||
|
using Framebuffer = DesktopFramebuffer;
|
||||||
|
using Input = DesktopInput;
|
||||||
|
using Clock = DesktopClock;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace cardboy::backend::desktop
|
} // namespace cardboy::backend::desktop
|
||||||
|
|
||||||
namespace cardboy::backend {
|
namespace cardboy::backend {
|
||||||
using DesktopBackend = desktop::Backend;
|
using DesktopBackend = desktop::Backend;
|
||||||
} // namespace cardboy::backend
|
} // namespace cardboy::backend
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -19,78 +20,31 @@ namespace {
|
|||||||
constexpr std::size_t kDesktopEventQueueLimit = 64;
|
constexpr std::size_t kDesktopEventQueueLimit = 64;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
DesktopEventBus::DesktopEventBus(DesktopRuntime& owner) : runtime(owner) {}
|
void DesktopEventBus::post(const cardboy::sdk::AppEvent& event) {
|
||||||
|
|
||||||
void DesktopEventBus::signal(std::uint32_t bits) {
|
|
||||||
if (bits == 0)
|
|
||||||
return;
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
|
||||||
pendingBits |= bits;
|
|
||||||
}
|
|
||||||
cv.notify_all();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DesktopEventBus::signalFromISR(std::uint32_t bits) { signal(bits); }
|
|
||||||
|
|
||||||
std::uint32_t DesktopEventBus::wait(std::uint32_t mask, std::uint32_t timeout_ms) {
|
|
||||||
if (mask == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
const auto start = std::chrono::steady_clock::now();
|
|
||||||
const bool infinite = timeout_ms == cardboy::sdk::IEventBus::kWaitForever;
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
|
||||||
const std::uint32_t ready = pendingBits & mask;
|
|
||||||
if (ready != 0) {
|
|
||||||
pendingBits &= ~mask;
|
|
||||||
return ready;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!infinite) {
|
|
||||||
const auto now = std::chrono::steady_clock::now();
|
|
||||||
const auto elapsedMs = std::chrono::duration_cast<std::chrono::milliseconds>(now - start).count();
|
|
||||||
if (elapsedMs >= static_cast<std::int64_t>(timeout_ms))
|
|
||||||
return 0;
|
|
||||||
const auto remaining = timeout_ms - static_cast<std::uint32_t>(elapsedMs);
|
|
||||||
runtime.sleepFor(std::min<std::uint32_t>(remaining, 8));
|
|
||||||
} else {
|
|
||||||
runtime.sleepFor(8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DesktopScopedEventBus::DesktopScopedEventBus(cardboy::sdk::IEventBus& bus) : globalBus(bus) {}
|
|
||||||
|
|
||||||
void DesktopScopedEventBus::post(const cardboy::sdk::AppEvent& event) {
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
|
||||||
if (queue.size() >= kDesktopEventQueueLimit)
|
|
||||||
queue.pop_front();
|
|
||||||
queue.push_back(event);
|
|
||||||
}
|
|
||||||
globalBus.signal(cardboy::sdk::to_event_bits(cardboy::sdk::EventBusSignal::Timer));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DesktopScopedEventBus::pop(cardboy::sdk::AppEvent& outEvent) {
|
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
if (queue.empty())
|
queue.push_back(event);
|
||||||
return false;
|
cv.notify_one();
|
||||||
outEvent = queue.front();
|
}
|
||||||
|
|
||||||
|
std::optional<cardboy::sdk::AppEvent> DesktopEventBus::pop(std::optional<std::uint32_t> timeout_ms) {
|
||||||
|
std::unique_lock<std::mutex> lock(mutex);
|
||||||
|
if (queue.empty()) {
|
||||||
|
if (!timeout_ms) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
auto timeout = std::chrono::milliseconds(*timeout_ms);
|
||||||
|
cv.wait_for(lock, timeout, [this] { return !queue.empty(); });
|
||||||
|
if (queue.empty()) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto event = queue.front();
|
||||||
queue.pop_front();
|
queue.pop_front();
|
||||||
return true;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesktopScopedEventBus::clear() {
|
DesktopTimerService::DesktopTimerService(DesktopRuntime& owner, cardboy::sdk::IEventBus& eventBus) :
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
runtime(owner), eventBus(eventBus) {
|
||||||
queue.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
DesktopTimerService::DesktopTimerService(DesktopRuntime& owner, cardboy::sdk::IAppEventBus& appBus) :
|
|
||||||
runtime(owner), appEventBus(appBus) {
|
|
||||||
worker = std::thread(&DesktopTimerService::workerLoop, this);
|
worker = std::thread(&DesktopTimerService::workerLoop, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +63,8 @@ cardboy::sdk::AppTimerHandle DesktopTimerService::scheduleTimer(std::uint32_t de
|
|||||||
const auto now = std::chrono::steady_clock::now();
|
const auto now = std::chrono::steady_clock::now();
|
||||||
const auto effectiveDelayMs = std::chrono::milliseconds(delay_ms);
|
const auto effectiveDelayMs = std::chrono::milliseconds(delay_ms);
|
||||||
const auto dueTime = delay_ms == 0 ? now : now + effectiveDelayMs;
|
const auto dueTime = delay_ms == 0 ? now : now + effectiveDelayMs;
|
||||||
const auto interval = std::chrono::milliseconds(std::max<std::uint32_t>(1, repeat ? std::max(delay_ms, 1u)
|
const auto interval = std::chrono::milliseconds(
|
||||||
: std::max(delay_ms, 1u)));
|
std::max<std::uint32_t>(1, repeat ? std::max(delay_ms, 1u) : std::max(delay_ms, 1u)));
|
||||||
|
|
||||||
TimerRecord record{};
|
TimerRecord record{};
|
||||||
record.repeat = repeat;
|
record.repeat = repeat;
|
||||||
@@ -119,7 +73,7 @@ cardboy::sdk::AppTimerHandle DesktopTimerService::scheduleTimer(std::uint32_t de
|
|||||||
record.active = true;
|
record.active = true;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
cardboy::sdk::AppTimerHandle handle = cardboy::sdk::kInvalidAppTimer;
|
cardboy::sdk::AppTimerHandle handle = cardboy::sdk::kInvalidAppTimer;
|
||||||
do {
|
do {
|
||||||
handle = nextHandle++;
|
handle = nextHandle++;
|
||||||
@@ -163,9 +117,8 @@ void DesktopTimerService::workerLoop() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto nextIt = std::min_element(timers.begin(), timers.end(), [](const TimerRecord& a, const TimerRecord& b) {
|
auto nextIt = std::min_element(timers.begin(), timers.end(),
|
||||||
return a.due < b.due;
|
[](const TimerRecord& a, const TimerRecord& b) { return a.due < b.due; });
|
||||||
});
|
|
||||||
|
|
||||||
if (nextIt == timers.end())
|
if (nextIt == timers.end())
|
||||||
continue;
|
continue;
|
||||||
@@ -189,7 +142,7 @@ void DesktopTimerService::workerLoop() {
|
|||||||
cardboy::sdk::AppEvent event{};
|
cardboy::sdk::AppEvent event{};
|
||||||
event.timestamp_ms = runtime.clock.millis();
|
event.timestamp_ms = runtime.clock.millis();
|
||||||
event.data = timerEvent;
|
event.data = timerEvent;
|
||||||
appEventBus.post(event);
|
eventBus.post(event);
|
||||||
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
continue;
|
continue;
|
||||||
@@ -209,13 +162,12 @@ void DesktopTimerService::cleanupInactive() {
|
|||||||
DesktopAppServiceProvider::DesktopAppServiceProvider(DesktopRuntime& owner, cardboy::sdk::IEventBus& bus) :
|
DesktopAppServiceProvider::DesktopAppServiceProvider(DesktopRuntime& owner, cardboy::sdk::IEventBus& bus) :
|
||||||
runtime(owner), eventBus(bus) {}
|
runtime(owner), eventBus(bus) {}
|
||||||
|
|
||||||
std::unique_ptr<cardboy::sdk::AppScopedServices> DesktopAppServiceProvider::createScopedServices(std::uint64_t generation) {
|
std::unique_ptr<cardboy::sdk::AppScopedServices>
|
||||||
(void)generation;
|
DesktopAppServiceProvider::createScopedServices(std::uint64_t generation) {
|
||||||
auto scoped = std::make_unique<ScopedServices>();
|
(void) generation;
|
||||||
scoped->ownedEventBus = std::make_unique<DesktopScopedEventBus>(eventBus);
|
auto scoped = std::make_unique<ScopedServices>();
|
||||||
scoped->events = scoped->ownedEventBus.get();
|
scoped->ownedTimer = std::make_unique<DesktopTimerService>(runtime, eventBus);
|
||||||
scoped->ownedTimer = std::make_unique<DesktopTimerService>(runtime, *scoped->ownedEventBus);
|
scoped->timer = scoped->ownedTimer.get();
|
||||||
scoped->timer = scoped->ownedTimer.get();
|
|
||||||
return scoped;
|
return scoped;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +264,7 @@ std::vector<DesktopNotificationCenter::Notification> DesktopNotificationCenter::
|
|||||||
void DesktopNotificationCenter::markAllRead() {
|
void DesktopNotificationCenter::markAllRead() {
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
for (auto& entry : entries) {
|
for (auto& entry: entries) {
|
||||||
if (entry.unread) {
|
if (entry.unread) {
|
||||||
entry.unread = false;
|
entry.unread = false;
|
||||||
changed = true;
|
changed = true;
|
||||||
@@ -337,8 +289,8 @@ void DesktopNotificationCenter::removeById(std::uint64_t id) {
|
|||||||
bool removed = false;
|
bool removed = false;
|
||||||
for (auto it = entries.begin(); it != entries.end();) {
|
for (auto it = entries.begin(); it != entries.end();) {
|
||||||
if (it->id == id) {
|
if (it->id == id) {
|
||||||
it = entries.erase(it);
|
it = entries.erase(it);
|
||||||
removed = true;
|
removed = true;
|
||||||
} else {
|
} else {
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
@@ -354,8 +306,8 @@ void DesktopNotificationCenter::removeByExternalId(std::uint64_t externalId) {
|
|||||||
bool removed = false;
|
bool removed = false;
|
||||||
for (auto it = entries.begin(); it != entries.end();) {
|
for (auto it = entries.begin(); it != entries.end();) {
|
||||||
if (it->externalId == externalId) {
|
if (it->externalId == externalId) {
|
||||||
it = entries.erase(it);
|
it = entries.erase(it);
|
||||||
removed = true;
|
removed = true;
|
||||||
} else {
|
} else {
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
@@ -364,6 +316,13 @@ void DesktopNotificationCenter::removeByExternalId(std::uint64_t externalId) {
|
|||||||
++revisionCounter;
|
++revisionCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DesktopLoopHooks::DesktopLoopHooks(DesktopRuntime& owner) : runtime(owner) {}
|
||||||
|
|
||||||
|
void DesktopLoopHooks::onLoopIteration() {
|
||||||
|
runtime.processEvents();
|
||||||
|
runtime.presentIfNeeded();
|
||||||
|
}
|
||||||
|
|
||||||
DesktopFramebuffer::DesktopFramebuffer(DesktopRuntime& runtime) : runtime(runtime) {}
|
DesktopFramebuffer::DesktopFramebuffer(DesktopRuntime& runtime) : runtime(runtime) {}
|
||||||
|
|
||||||
int DesktopFramebuffer::width_impl() const { return cardboy::sdk::kDisplayWidth; }
|
int DesktopFramebuffer::width_impl() const { return cardboy::sdk::kDisplayWidth; }
|
||||||
@@ -391,26 +350,29 @@ DesktopInput::DesktopInput(DesktopRuntime& runtime) : runtime(runtime) {}
|
|||||||
cardboy::sdk::InputState DesktopInput::readState_impl() { return state; }
|
cardboy::sdk::InputState DesktopInput::readState_impl() { return state; }
|
||||||
|
|
||||||
void DesktopInput::handleKey(sf::Keyboard::Key key, bool pressed) {
|
void DesktopInput::handleKey(sf::Keyboard::Key key, bool pressed) {
|
||||||
bool handled = true;
|
const auto oldState = state;
|
||||||
|
bool handled = true;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case sf::Keyboard::Key::Up:
|
case sf::Keyboard::Key::Up:
|
||||||
|
case sf::Keyboard::Key::W:
|
||||||
state.up = pressed;
|
state.up = pressed;
|
||||||
break;
|
break;
|
||||||
case sf::Keyboard::Key::Down:
|
case sf::Keyboard::Key::Down:
|
||||||
|
case sf::Keyboard::Key::S:
|
||||||
state.down = pressed;
|
state.down = pressed;
|
||||||
break;
|
break;
|
||||||
case sf::Keyboard::Key::Left:
|
case sf::Keyboard::Key::Left:
|
||||||
|
case sf::Keyboard::Key::A:
|
||||||
state.left = pressed;
|
state.left = pressed;
|
||||||
break;
|
break;
|
||||||
case sf::Keyboard::Key::Right:
|
case sf::Keyboard::Key::Right:
|
||||||
|
case sf::Keyboard::Key::D:
|
||||||
state.right = pressed;
|
state.right = pressed;
|
||||||
break;
|
break;
|
||||||
case sf::Keyboard::Key::Z:
|
case sf::Keyboard::Key::Z:
|
||||||
case sf::Keyboard::Key::A:
|
|
||||||
state.a = pressed;
|
state.a = pressed;
|
||||||
break;
|
break;
|
||||||
case sf::Keyboard::Key::X:
|
case sf::Keyboard::Key::X:
|
||||||
case sf::Keyboard::Key::S:
|
|
||||||
state.b = pressed;
|
state.b = pressed;
|
||||||
break;
|
break;
|
||||||
case sf::Keyboard::Key::Space:
|
case sf::Keyboard::Key::Space:
|
||||||
@@ -423,8 +385,11 @@ void DesktopInput::handleKey(sf::Keyboard::Key key, bool pressed) {
|
|||||||
handled = false;
|
handled = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (handled)
|
if (handled && oldState != state) {
|
||||||
runtime.eventBusService.signal(cardboy::sdk::to_event_bits(cardboy::sdk::EventBusSignal::Input));
|
cardboy::sdk::AppButtonEvent btnEvent{oldState, state};
|
||||||
|
cardboy::sdk::AppEvent event{runtime.clock.millis(), btnEvent};
|
||||||
|
runtime.eventBusService.post(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DesktopClock::DesktopClock(DesktopRuntime& runtime) : runtime(runtime), start(std::chrono::steady_clock::now()) {}
|
DesktopClock::DesktopClock(DesktopRuntime& runtime) : runtime(runtime), start(std::chrono::steady_clock::now()) {}
|
||||||
@@ -442,24 +407,28 @@ DesktopRuntime::DesktopRuntime() :
|
|||||||
"Cardboy Desktop"),
|
"Cardboy Desktop"),
|
||||||
texture(), sprite(texture),
|
texture(), sprite(texture),
|
||||||
pixels(static_cast<std::size_t>(cardboy::sdk::kDisplayWidth * cardboy::sdk::kDisplayHeight) * 4, 0),
|
pixels(static_cast<std::size_t>(cardboy::sdk::kDisplayWidth * cardboy::sdk::kDisplayHeight) * 4, 0),
|
||||||
framebuffer(*this), input(*this), clock(*this), eventBusService(*this), appServiceProvider(*this, eventBusService) {
|
framebuffer(*this), input(*this), clock(*this), eventBusService(), appServiceProvider(*this, eventBusService),
|
||||||
|
loopHooksService(*this) {
|
||||||
window.setFramerateLimit(60);
|
window.setFramerateLimit(60);
|
||||||
if (!texture.resize(sf::Vector2u{cardboy::sdk::kDisplayWidth, cardboy::sdk::kDisplayHeight}))
|
if (!texture.resize(sf::Vector2u{cardboy::sdk::kDisplayWidth, cardboy::sdk::kDisplayHeight}))
|
||||||
throw std::runtime_error("Failed to allocate texture for desktop framebuffer");
|
throw std::runtime_error("Failed to allocate texture for desktop framebuffer");
|
||||||
sprite.setTexture(texture, true);
|
sprite.setTexture(texture, true);
|
||||||
sprite.setScale(sf::Vector2f{static_cast<float>(kPixelScale), static_cast<float>(kPixelScale)});
|
sprite.setScale(sf::Vector2f{static_cast<float>(kPixelScale), static_cast<float>(kPixelScale)});
|
||||||
clearPixels(true);
|
clearPixels(false);
|
||||||
presentIfNeeded();
|
presentIfNeeded();
|
||||||
|
window.requestFocus();
|
||||||
|
|
||||||
services.buzzer = &buzzerService;
|
std::cout << "Desktop window initialized and presented." << std::endl;
|
||||||
services.battery = &batteryService;
|
|
||||||
services.storage = &storageService;
|
services.buzzer = &buzzerService;
|
||||||
services.random = &randomService;
|
services.battery = &batteryService;
|
||||||
services.highResClock = &highResService;
|
services.storage = &storageService;
|
||||||
services.filesystem = &filesystemService;
|
services.random = &randomService;
|
||||||
services.eventBus = &eventBusService;
|
services.highResClock = &highResService;
|
||||||
services.appServices = &appServiceProvider;
|
services.filesystem = &filesystemService;
|
||||||
services.loopHooks = nullptr;
|
services.eventBus = &eventBusService;
|
||||||
|
services.appServices = &appServiceProvider;
|
||||||
|
services.loopHooks = &loopHooksService;
|
||||||
services.notifications = ¬ificationService;
|
services.notifications = ¬ificationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ constexpr unsigned char kFallbackChar = '?';
|
|||||||
|
|
||||||
inline unsigned char normalizeChar(char ch) {
|
inline unsigned char normalizeChar(char ch) {
|
||||||
unsigned char uc = static_cast<unsigned char>(ch);
|
unsigned char uc = static_cast<unsigned char>(ch);
|
||||||
if (uc >= 'a' && uc <= 'z')
|
|
||||||
uc = static_cast<unsigned char>(std::toupper(static_cast<unsigned char>(uc)));
|
|
||||||
if (!std::isprint(static_cast<unsigned char>(uc)))
|
if (!std::isprint(static_cast<unsigned char>(uc)))
|
||||||
return kFallbackChar;
|
return kFallbackChar;
|
||||||
return uc;
|
return uc;
|
||||||
|
|||||||
@@ -56,9 +56,6 @@ private:
|
|||||||
fb.drawPixel(x, y, true);
|
fb.drawPixel(x, y, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = 0; x < width; ++x)
|
|
||||||
fb.drawPixel(x, 0, false);
|
|
||||||
|
|
||||||
const int textY = 1;
|
const int textY = 1;
|
||||||
const int bottomSeparatorY = textY + font16x8::kGlyphHeight + 1;
|
const int bottomSeparatorY = textY + font16x8::kGlyphHeight + 1;
|
||||||
if (bottomSeparatorY < fillHeight) {
|
if (bottomSeparatorY < fillHeight) {
|
||||||
|
|||||||
@@ -50,16 +50,12 @@ std::string StatusBar::prepareRightText() const {
|
|||||||
|
|
||||||
std::string right;
|
std::string right;
|
||||||
if (_services->battery && _services->battery->hasData()) {
|
if (_services->battery && _services->battery->hasData()) {
|
||||||
const float current = _services->battery->current();
|
const float current = _services->battery->current();
|
||||||
const float chargeMah = _services->battery->charge();
|
const float chargeMah = _services->battery->charge();
|
||||||
const float fallbackV = _services->battery->voltage();
|
const float percentage = _services->battery->percentage();
|
||||||
char buf[64];
|
char buf[64];
|
||||||
if (std::isfinite(current) && std::isfinite(chargeMah)) {
|
std::snprintf(buf, sizeof(buf), "%.2fmA %.2fmAh %.0f%%", static_cast<double>(current),
|
||||||
std::snprintf(buf, sizeof(buf), "cur %.2fmA chr %.2fmAh", static_cast<double>(current),
|
static_cast<double>(chargeMah), static_cast<double>(percentage));
|
||||||
static_cast<double>(chargeMah));
|
|
||||||
} else {
|
|
||||||
std::snprintf(buf, sizeof(buf), "vol %.2fV", static_cast<double>(fallbackV));
|
|
||||||
}
|
|
||||||
right.assign(buf);
|
right.assign(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -567,9 +567,9 @@ CONFIG_SECURE_TEE_LOG_LEVEL=0
|
|||||||
# Serial flasher config
|
# Serial flasher config
|
||||||
#
|
#
|
||||||
# CONFIG_ESPTOOLPY_NO_STUB is not set
|
# CONFIG_ESPTOOLPY_NO_STUB is not set
|
||||||
# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set
|
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
|
||||||
# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set
|
# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set
|
||||||
CONFIG_ESPTOOLPY_FLASHMODE_DIO=y
|
# CONFIG_ESPTOOLPY_FLASHMODE_DIO is not set
|
||||||
# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set
|
# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set
|
||||||
CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y
|
CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y
|
||||||
CONFIG_ESPTOOLPY_FLASHMODE="dio"
|
CONFIG_ESPTOOLPY_FLASHMODE="dio"
|
||||||
@@ -613,9 +613,9 @@ CONFIG_PARTITION_TABLE_MD5=y
|
|||||||
#
|
#
|
||||||
# Compiler options
|
# Compiler options
|
||||||
#
|
#
|
||||||
CONFIG_COMPILER_OPTIMIZATION_DEBUG=y
|
# CONFIG_COMPILER_OPTIMIZATION_DEBUG is not set
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set
|
# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_PERF is not set
|
CONFIG_COMPILER_OPTIMIZATION_PERF=y
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_NONE is not set
|
# CONFIG_COMPILER_OPTIMIZATION_NONE is not set
|
||||||
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y
|
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set
|
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set
|
||||||
@@ -1217,7 +1217,7 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y
|
|||||||
# ESP-Driver:USB Serial/JTAG Configuration
|
# ESP-Driver:USB Serial/JTAG Configuration
|
||||||
#
|
#
|
||||||
CONFIG_USJ_ENABLE_USB_SERIAL_JTAG=y
|
CONFIG_USJ_ENABLE_USB_SERIAL_JTAG=y
|
||||||
# CONFIG_USJ_NO_AUTO_LS_ON_CONNECTION is not set
|
CONFIG_USJ_NO_AUTO_LS_ON_CONNECTION=y
|
||||||
# end of ESP-Driver:USB Serial/JTAG Configuration
|
# end of ESP-Driver:USB Serial/JTAG Configuration
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1714,7 +1714,6 @@ CONFIG_FREERTOS_IDLE_TIME_BEFORE_SLEEP=3
|
|||||||
#
|
#
|
||||||
# Port
|
# Port
|
||||||
#
|
#
|
||||||
CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y
|
|
||||||
# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set
|
# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set
|
||||||
CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS=y
|
CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS=y
|
||||||
# CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK is not set
|
# CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK is not set
|
||||||
@@ -1762,16 +1761,16 @@ CONFIG_HAL_WDT_USE_ROM_IMPL=y
|
|||||||
#
|
#
|
||||||
# Heap memory debugging
|
# Heap memory debugging
|
||||||
#
|
#
|
||||||
# CONFIG_HEAP_POISONING_DISABLED is not set
|
CONFIG_HEAP_POISONING_DISABLED=y
|
||||||
# CONFIG_HEAP_POISONING_LIGHT is not set
|
# CONFIG_HEAP_POISONING_LIGHT is not set
|
||||||
CONFIG_HEAP_POISONING_COMPREHENSIVE=y
|
# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set
|
||||||
CONFIG_HEAP_TRACING_OFF=y
|
CONFIG_HEAP_TRACING_OFF=y
|
||||||
# CONFIG_HEAP_TRACING_STANDALONE is not set
|
# CONFIG_HEAP_TRACING_STANDALONE is not set
|
||||||
# CONFIG_HEAP_TRACING_TOHOST is not set
|
# CONFIG_HEAP_TRACING_TOHOST is not set
|
||||||
# CONFIG_HEAP_USE_HOOKS is not set
|
# CONFIG_HEAP_USE_HOOKS is not set
|
||||||
# CONFIG_HEAP_TASK_TRACKING is not set
|
# CONFIG_HEAP_TASK_TRACKING is not set
|
||||||
# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set
|
# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set
|
||||||
# CONFIG_HEAP_TLSF_USE_ROM_IMPL is not set
|
CONFIG_HEAP_TLSF_USE_ROM_IMPL=y
|
||||||
# CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH is not set
|
# CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH is not set
|
||||||
# end of Heap memory debugging
|
# end of Heap memory debugging
|
||||||
|
|
||||||
@@ -2459,14 +2458,14 @@ CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y
|
|||||||
# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set
|
# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set
|
||||||
CONFIG_LOG_BOOTLOADER_LEVEL=3
|
CONFIG_LOG_BOOTLOADER_LEVEL=3
|
||||||
# CONFIG_FLASH_ENCRYPTION_ENABLED is not set
|
# CONFIG_FLASH_ENCRYPTION_ENABLED is not set
|
||||||
# CONFIG_FLASHMODE_QIO is not set
|
CONFIG_FLASHMODE_QIO=y
|
||||||
# CONFIG_FLASHMODE_QOUT is not set
|
# CONFIG_FLASHMODE_QOUT is not set
|
||||||
CONFIG_FLASHMODE_DIO=y
|
# CONFIG_FLASHMODE_DIO is not set
|
||||||
# CONFIG_FLASHMODE_DOUT is not set
|
# CONFIG_FLASHMODE_DOUT is not set
|
||||||
CONFIG_MONITOR_BAUD=115200
|
CONFIG_MONITOR_BAUD=115200
|
||||||
CONFIG_OPTIMIZATION_LEVEL_DEBUG=y
|
# CONFIG_OPTIMIZATION_LEVEL_DEBUG is not set
|
||||||
CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y
|
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set
|
||||||
CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y
|
# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set
|
||||||
# CONFIG_OPTIMIZATION_LEVEL_RELEASE is not set
|
# CONFIG_OPTIMIZATION_LEVEL_RELEASE is not set
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set
|
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set
|
||||||
CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y
|
CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y
|
||||||
|
|||||||
@@ -613,9 +613,9 @@ CONFIG_PARTITION_TABLE_MD5=y
|
|||||||
#
|
#
|
||||||
# Compiler options
|
# Compiler options
|
||||||
#
|
#
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_DEBUG is not set
|
CONFIG_COMPILER_OPTIMIZATION_DEBUG=y
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set
|
# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set
|
||||||
CONFIG_COMPILER_OPTIMIZATION_PERF=y
|
# CONFIG_COMPILER_OPTIMIZATION_PERF is not set
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_NONE is not set
|
# CONFIG_COMPILER_OPTIMIZATION_NONE is not set
|
||||||
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y
|
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set
|
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set
|
||||||
@@ -1714,6 +1714,7 @@ CONFIG_FREERTOS_IDLE_TIME_BEFORE_SLEEP=3
|
|||||||
#
|
#
|
||||||
# Port
|
# Port
|
||||||
#
|
#
|
||||||
|
CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y
|
||||||
# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set
|
# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set
|
||||||
CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS=y
|
CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS=y
|
||||||
# CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK is not set
|
# CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK is not set
|
||||||
@@ -1761,16 +1762,16 @@ CONFIG_HAL_WDT_USE_ROM_IMPL=y
|
|||||||
#
|
#
|
||||||
# Heap memory debugging
|
# Heap memory debugging
|
||||||
#
|
#
|
||||||
CONFIG_HEAP_POISONING_DISABLED=y
|
# CONFIG_HEAP_POISONING_DISABLED is not set
|
||||||
# CONFIG_HEAP_POISONING_LIGHT is not set
|
# CONFIG_HEAP_POISONING_LIGHT is not set
|
||||||
# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set
|
CONFIG_HEAP_POISONING_COMPREHENSIVE=y
|
||||||
CONFIG_HEAP_TRACING_OFF=y
|
CONFIG_HEAP_TRACING_OFF=y
|
||||||
# CONFIG_HEAP_TRACING_STANDALONE is not set
|
# CONFIG_HEAP_TRACING_STANDALONE is not set
|
||||||
# CONFIG_HEAP_TRACING_TOHOST is not set
|
# CONFIG_HEAP_TRACING_TOHOST is not set
|
||||||
# CONFIG_HEAP_USE_HOOKS is not set
|
# CONFIG_HEAP_USE_HOOKS is not set
|
||||||
# CONFIG_HEAP_TASK_TRACKING is not set
|
# CONFIG_HEAP_TASK_TRACKING is not set
|
||||||
# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set
|
# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set
|
||||||
CONFIG_HEAP_TLSF_USE_ROM_IMPL=y
|
# CONFIG_HEAP_TLSF_USE_ROM_IMPL is not set
|
||||||
# CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH is not set
|
# CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH is not set
|
||||||
# end of Heap memory debugging
|
# end of Heap memory debugging
|
||||||
|
|
||||||
@@ -2463,9 +2464,9 @@ CONFIG_LOG_BOOTLOADER_LEVEL=3
|
|||||||
CONFIG_FLASHMODE_DIO=y
|
CONFIG_FLASHMODE_DIO=y
|
||||||
# CONFIG_FLASHMODE_DOUT is not set
|
# CONFIG_FLASHMODE_DOUT is not set
|
||||||
CONFIG_MONITOR_BAUD=115200
|
CONFIG_MONITOR_BAUD=115200
|
||||||
# CONFIG_OPTIMIZATION_LEVEL_DEBUG is not set
|
CONFIG_OPTIMIZATION_LEVEL_DEBUG=y
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set
|
CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set
|
CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y
|
||||||
# CONFIG_OPTIMIZATION_LEVEL_RELEASE is not set
|
# CONFIG_OPTIMIZATION_LEVEL_RELEASE is not set
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set
|
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set
|
||||||
CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y
|
CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y
|
||||||
|
|||||||
Reference in New Issue
Block a user