Skip to content

Commit

Permalink
Merge branch 'tbnobody-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
womoak75 committed Jan 17, 2024
2 parents d1ed3cd + 7f6d276 commit 868c055
Show file tree
Hide file tree
Showing 53 changed files with 4,227 additions and 3,564 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# http://editorconfig.org
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// for the documentation about the extensions.json format
"recommendations": [
"DavidAnson.vscode-markdownlint",
"EditorConfig.EditorConfig",
"Vue.volar",
"Vue.vscode-typescript-vue-plugin",
"platformio.platformio-ide"
Expand Down
10 changes: 7 additions & 3 deletions include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <cstdint>

#define CONFIG_FILENAME "/config.json"
#define CONFIG_VERSION 0x00011a00 // 0.1.26 // make sure to clean all after change
#define CONFIG_VERSION 0x00011b00 // 0.1.27 // make sure to clean all after change

#define WIFI_MAX_SSID_STRLEN 32
#define WIFI_MAX_PASSWORD_STRLEN 64
Expand Down Expand Up @@ -129,6 +129,7 @@ struct CONFIG_T {
struct {
int8_t PaLevel;
uint32_t Frequency;
uint8_t CountryMode;
} Cmt;
} Dtu;

Expand All @@ -143,7 +144,10 @@ struct CONFIG_T {
uint8_t Rotation;
uint8_t Contrast;
uint8_t Language;
uint32_t DiagramDuration;
struct {
uint32_t Duration;
uint8_t Mode;
} Diagram;
} Display;

struct {
Expand All @@ -166,4 +170,4 @@ class ConfigurationClass {
INVERTER_CONFIG_T* getInverterConfig(const uint64_t serial);
};

extern ConfigurationClass Configuration;
extern ConfigurationClass Configuration;
23 changes: 20 additions & 3 deletions include/Display_Graphic.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
#include <TaskSchedulerDeclarations.h>
#include <U8g2lib.h>

#define CHART_HEIGHT 20 // chart area hight in pixels
#define CHART_WIDTH 47 // chart area width in pixels

// Left-Upper position of diagram is drawn
// (text of Y-axis is display left of that pos)
#define CHART_POSX 80
#define CHART_POSY 0

enum DisplayType_t {
None,
PCD8544,
Expand All @@ -15,6 +23,13 @@ enum DisplayType_t {
DisplayType_Max,
};

enum DiagramMode_t {
Off,
Small,
Fullscreen,
DisplayMode_Max,
};

class DisplayGraphicClass {
public:
DisplayGraphicClass();
Expand All @@ -25,6 +40,7 @@ class DisplayGraphicClass {
void setStatus(const bool turnOn);
void setOrientation(const uint8_t rotation = DISPLAY_ROTATION);
void setLanguage(const uint8_t language);
void setDiagramMode(DiagramMode_t mode);
void setStartupDisplay();

DisplayGraphicDiagramClass& Diagram();
Expand All @@ -47,14 +63,15 @@ class DisplayGraphicClass {
bool _displayTurnedOn;

DisplayType_t _display_type = DisplayType_t::None;
DiagramMode_t _diagram_mode = DiagramMode_t::Off;
uint8_t _display_language = DISPLAY_LANGUAGE;
uint8_t _mExtra;
uint16_t _period = 1000;
uint16_t _interval = 60000; // interval at which to power save (milliseconds)
const uint16_t _period = 1000;
const uint16_t _interval = 60000; // interval at which to power save (milliseconds)
uint32_t _previousMillis = 0;
char _fmtText[32];
bool _isLarge = false;
uint8_t _lineOffsets[5];
};

extern DisplayGraphicClass Display;
extern DisplayGraphicClass Display;
16 changes: 6 additions & 10 deletions include/Display_Graphic_Diagram.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,32 @@
#include <U8g2lib.h>
#include <array>

#define CHART_HEIGHT 20 // chart area hight in pixels
#define CHART_WIDTH 47 // chart area width in pixels

// Left-Upper position of diagram is drawn
// (text of Y-axis is display left of that pos)
#define DIAG_POSX 80
#define DIAG_POSY 0
#define MAX_DATAPOINTS 128

class DisplayGraphicDiagramClass {
public:
DisplayGraphicDiagramClass();

void init(Scheduler& scheduler, U8G2* display);
void redraw(uint8_t screenSaverOffsetX);
void redraw(uint8_t screenSaverOffsetX, uint8_t xPos, uint8_t yPos, uint8_t width, uint8_t height, bool isFullscreen);

void updatePeriod();

private:
void averageLoop();
void dataPointLoop();

static uint32_t getSecondsPerDot();
uint32_t getSecondsPerDot();

Task _averageTask;
Task _dataPointTask;

U8G2* _display = nullptr;
std::array<float, CHART_WIDTH> _graphValues = {};
std::array<float, MAX_DATAPOINTS> _graphValues = {};
uint8_t _graphValuesCount = 0;

uint8_t _chartWidth = MAX_DATAPOINTS;

float _iRunningAverage = 0;
uint16_t _iRunningAverageCnt = 0;
};
3 changes: 2 additions & 1 deletion include/WebApi_dtu.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ class WebApiDtuClass {
void onDtuAdminPost(AsyncWebServerRequest* request);

AsyncWebServer* _server;
};
bool _performReload = false;
};
3 changes: 2 additions & 1 deletion include/WebApi_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum WebApiError {
DtuPollZero,
DtuInvalidPowerLevel,
DtuInvalidCmtFrequency,
DtuInvalidCmtCountry,

ConfigBase = 3000,
ConfigNotDeleted,
Expand Down Expand Up @@ -89,4 +90,4 @@ enum WebApiError {

HardwareBase = 12000,
HardwarePinMappingLength,
};
};
6 changes: 4 additions & 2 deletions include/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
#define DTU_POLL_INTERVAL 5U
#define DTU_NRF_PA_LEVEL 0U
#define DTU_CMT_PA_LEVEL 0
#define DTU_CMT_FREQUENCY 865000U
#define DTU_CMT_FREQUENCY 865000000U
#define DTU_CMT_COUNTRY_MODE 0U

#define MQTT_HASS_ENABLED false
#define MQTT_HASS_EXPIRE true
Expand All @@ -99,9 +100,10 @@
#define DISPLAY_CONTRAST 60U
#define DISPLAY_LANGUAGE 0U
#define DISPLAY_DIAGRAM_DURATION (10UL * 60UL * 60UL)
#define DISPLAY_DIAGRAM_MODE 1U

#define REACHABLE_THRESHOLD 2U

#define LED_BRIGHTNESS 100U

#define MAX_INVERTER_LIMIT 2250
#define MAX_INVERTER_LIMIT 2250
Loading

0 comments on commit 868c055

Please sign in to comment.