2023-12-19 17:26:24 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <TaskSchedulerDeclarations.h>
|
|
|
|
|
#include <U8g2lib.h>
|
|
|
|
|
#include <array>
|
|
|
|
|
|
2024-01-13 11:31:12 +01:00
|
|
|
#define MAX_DATAPOINTS 128
|
2023-12-19 17:26:24 +01:00
|
|
|
|
|
|
|
|
class DisplayGraphicDiagramClass {
|
|
|
|
|
public:
|
|
|
|
|
DisplayGraphicDiagramClass();
|
|
|
|
|
|
|
|
|
|
void init(Scheduler& scheduler, U8G2* display);
|
2024-01-13 11:31:12 +01:00
|
|
|
void redraw(uint8_t screenSaverOffsetX, uint8_t xPos, uint8_t yPos, uint8_t width, uint8_t height, bool isFullscreen);
|
2023-12-19 17:26:24 +01:00
|
|
|
|
|
|
|
|
void updatePeriod();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void averageLoop();
|
|
|
|
|
void dataPointLoop();
|
|
|
|
|
|
2024-01-13 11:31:12 +01:00
|
|
|
uint32_t getSecondsPerDot();
|
2023-12-19 17:26:24 +01:00
|
|
|
|
|
|
|
|
Task _averageTask;
|
|
|
|
|
Task _dataPointTask;
|
|
|
|
|
|
|
|
|
|
U8G2* _display = nullptr;
|
2024-01-13 11:31:12 +01:00
|
|
|
std::array<float, MAX_DATAPOINTS> _graphValues = {};
|
2023-12-19 17:26:24 +01:00
|
|
|
uint8_t _graphValuesCount = 0;
|
|
|
|
|
|
2024-01-13 11:31:12 +01:00
|
|
|
uint8_t _chartWidth = MAX_DATAPOINTS;
|
|
|
|
|
|
2023-12-19 17:26:24 +01:00
|
|
|
float _iRunningAverage = 0;
|
|
|
|
|
uint16_t _iRunningAverageCnt = 0;
|
2023-12-22 23:35:17 +01:00
|
|
|
};
|