Obsluha overlay ikon jako objekt

This commit is contained in:
Pavel Brychta 2020-11-26 06:33:16 +01:00
parent 9f417bbe42
commit 19782d2af5
2 changed files with 16 additions and 11 deletions

View File

@ -4,7 +4,7 @@ static statusIcon_t * icons[MAX_STATUS_ICONS];
static uint8_t visibleOnFrame[32]; static uint8_t visibleOnFrame[32];
// Kresleni indikacnich ikon (bezici wifi, nezname zarizeni na siti, ...) // 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; 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++) for (int i = 0; i < MAX_STATUS_ICONS; i++)
@ -56,7 +56,7 @@ void sico_init(void)
visibleOnFrame[i] = 0xff; visibleOnFrame[i] = 0xff;
} }
void sico_add(const statusIcon_t *ptr) void StatusIcons::add(const statusIcon_t *ptr)
{ {
int idx = -1; int idx = -1;
@ -70,7 +70,7 @@ void sico_add(const statusIcon_t *ptr)
icons[idx] = (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++) for (int i = 0; i < MAX_STATUS_ICONS; i++)
@ -78,7 +78,7 @@ void sico_remove(const statusIcon_t *ptr)
icons[i] = nullptr; icons[i] = nullptr;
} }
void sico_addVisibleFrameID(uint8_t id) void StatusIcons::addVisibleFrameId(uint8_t id)
{ {
for (size_t i = 0; i < sizeof(visibleOnFrame); i++) { for (size_t i = 0; i < sizeof(visibleOnFrame); i++) {
@ -90,3 +90,5 @@ void sico_addVisibleFrameID(uint8_t id)
} }
} }
} }
StatusIcons si;

View File

@ -12,13 +12,16 @@ typedef struct {
const uint8_t *xbmData; // ukazatel na data ikony const uint8_t *xbmData; // ukazatel na data ikony
} statusIcon_t; } 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 #endif