From 19782d2af5419b840d81ea94a066f216a2fc9496 Mon Sep 17 00:00:00 2001 From: Pavel Brychta Date: Thu, 26 Nov 2020 06:33:16 +0100 Subject: [PATCH] Obsluha overlay ikon jako objekt --- src/overlays/StatusIcons.cpp | 12 +++++++----- src/overlays/StatusIcons.h | 15 +++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/overlays/StatusIcons.cpp b/src/overlays/StatusIcons.cpp index e28f3a1..3432f73 100644 --- a/src/overlays/StatusIcons.cpp +++ b/src/overlays/StatusIcons.cpp @@ -4,7 +4,7 @@ static statusIcon_t * icons[MAX_STATUS_ICONS]; static uint8_t visibleOnFrame[32]; // Kresleni indikacnich ikon (bezici wifi, nezname zarizeni na siti, ...) -void sico_draw(OLEDDisplay *display, OLEDDisplayUiState *state) +void SIdraw(OLEDDisplay *display, OLEDDisplayUiState *state) { bool on = false; @@ -47,7 +47,7 @@ void sico_draw(OLEDDisplay *display, OLEDDisplayUiState *state) } } -void sico_init(void) +StatusIcons::StatusIcons() { for (int i = 0; i < MAX_STATUS_ICONS; i++) @@ -56,7 +56,7 @@ void sico_init(void) visibleOnFrame[i] = 0xff; } -void sico_add(const statusIcon_t *ptr) +void StatusIcons::add(const statusIcon_t *ptr) { int idx = -1; @@ -70,7 +70,7 @@ void sico_add(const statusIcon_t *ptr) icons[idx] = (statusIcon_t *)ptr; } -void sico_remove(const statusIcon_t *ptr) +void StatusIcons::remove(const statusIcon_t *ptr) { for (int i = 0; i < MAX_STATUS_ICONS; i++) @@ -78,7 +78,7 @@ void sico_remove(const statusIcon_t *ptr) icons[i] = nullptr; } -void sico_addVisibleFrameID(uint8_t id) +void StatusIcons::addVisibleFrameId(uint8_t id) { for (size_t i = 0; i < sizeof(visibleOnFrame); i++) { @@ -90,3 +90,5 @@ void sico_addVisibleFrameID(uint8_t id) } } } + +StatusIcons si; diff --git a/src/overlays/StatusIcons.h b/src/overlays/StatusIcons.h index e415bce..3c11d9a 100644 --- a/src/overlays/StatusIcons.h +++ b/src/overlays/StatusIcons.h @@ -12,13 +12,16 @@ typedef struct { const uint8_t *xbmData; // ukazatel na data ikony } statusIcon_t; -void sico_init(void); +class StatusIcons { +public: + StatusIcons(); + void add(const statusIcon_t *ptr); + void remove(const statusIcon_t *ptr); + void addVisibleFrameId(uint8_t id); +}; -void sico_draw(OLEDDisplay *display, OLEDDisplayUiState *state); +void SIdraw(OLEDDisplay *display, OLEDDisplayUiState *state); -void sico_add(const statusIcon_t *ptr); +extern StatusIcons si; -void sico_remove(const statusIcon_t *ptr); - -void sico_addVisibleFrameID(uint8_t id); #endif