Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SW-SPI over Patch Method. #1291

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ struct CONFIG_T {
uint8_t Display_Rotation;
uint8_t Display_Contrast;
uint8_t Display_Language;
uint16_t Display_UpdatePeriod;
};

class ConfigurationClass {
Expand Down
4 changes: 4 additions & 0 deletions include/Datastore.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class DatastoreClass {
// True if all enabled inverters are reachable
bool getIsAllEnabledReachable();

// Sum of all Producing Inverters
uint8_t getTotalProducing();

private:
TimeoutHelper _updateTimeout;
std::mutex _mutex;
Expand All @@ -77,6 +80,7 @@ class DatastoreClass {
bool _isAllEnabledProducing = false;
bool _isAllEnabledReachable = false;
bool _isAtLeastOnePollEnabled = false;
uint8_t _isProducing = 0;
};

extern DatastoreClass Datastore;
30 changes: 30 additions & 0 deletions include/Display.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include "Display_helper.h"
#include "defaults.h"
#include <Arduino.h>

class DisplayClass {
public:
void init(DisplayType_t _type, uint8_t _data, uint8_t _clk, uint8_t _cs, uint8_t _reset, uint8_t _busy, uint8_t _dc);
void loop();

void setContrast(uint8_t contrast);
void setStatus(bool turnOn);
void setOrientation(uint8_t rotation = DISPLAY_ROTATION);
void setLanguage(uint8_t language);
void setUpdatePeriod(uint16_t updatePeriod);
void setEnablePowerSafe(bool display_PowerSafe);
void setEnableScreensaver(bool display_ScreenSaver);

private:
bool _displayTurnedOn;

DisplayType_t _display_type = DisplayType_t::None;
uint32_t _lastDisplayUpdate = 0;
uint16_t _counterEPaper;
uint16_t _settedUpdatePeriod = 10000; // Achtung, max 65535
};

extern DisplayClass Display;
51 changes: 0 additions & 51 deletions include/Display_Graphic.h

This file was deleted.

48 changes: 48 additions & 0 deletions include/Display_Mono.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include "Display_helper.h"
#include "defaults.h"
#include <U8g2lib.h>

class DisplayMonoClass {
public:
DisplayMonoClass();
~DisplayMonoClass();

void init(DisplayType_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI);
void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod);

void setContrast(uint8_t contrast);
void setOrientation(uint8_t rotation);
void setLanguage(uint8_t language);
void setStartupDisplay();

bool enablePowerSafe = true;
bool enableScreensaver = true;

private:
void calcLineHeights();
void setFont(uint8_t line);
void printText(const char* text, uint8_t line, uint8_t dispX);

U8G2* _display;

bool _mIsLarge = false;
uint8_t mLoopCnt;
uint32_t* mUtcTs;
uint8_t mLineOffsets[5];

uint16_t _dispY = 0;
uint32_t _previousMillis = 0;
uint8_t _display_language = DISPLAY_LANGUAGE;

uint8_t _mExtra;
uint16_t _mTimeout; // interval at which to power save (milliseconds)
char _fmtText[32];

const u8g2_cb_t* disp_rotation = U8G2_R2;
uint8_t contrast = 60;
};

extern DisplayMonoClass DisplayMono;
53 changes: 53 additions & 0 deletions include/Display_ePaper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

/// uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX, to use less code and ram
// #include <GFX.h>
// base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
// enable GxEPD2_GFX base class
#define ENABLE_GxEPD2_GFX 1

#include <GxEPD2_3C.h>
#include <GxEPD2_BW.h>
#include <SPI.h>
#include <map>

// FreeFonts from Adafruit_GFX
#include <Fonts/FreeSans12pt7b.h>
#include <Fonts/FreeSans18pt7b.h>
#include <Fonts/FreeSans24pt7b.h>
#include <Fonts/FreeSans9pt7b.h>

#include "Display_helper.h"
#include "defaults.h"
#include "imagedata.h"

// GDEW027C44 2.7 " b/w/r 176x264, IL91874
// GDEH0154D67 1.54" b/w 200x200

class DisplayEPaperClass {
public:
DisplayEPaperClass();
~DisplayEPaperClass();

void init(DisplayType_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI);
void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod);
void fullRefresh();
void setOrientation(uint8_t rotation);
void setLanguage(uint8_t language);

private:
void headlineIP();
void actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod);
void lastUpdatePaged();

bool _changed = false;
char _fmtText[35];
const char* _settedIP;
uint8_t _headfootline = 16;
uint8_t _displayRotation = DISPLAY_ROTATION;
uint8_t _display_language = DISPLAY_LANGUAGE;
GxEPD2_GFX* _display;
};

extern DisplayEPaperClass DisplayEPaper;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot tell whether or not memory is limited. If memory is limited the different display classes could go into a union and get initialized with a placement new.

17 changes: 17 additions & 0 deletions include/Display_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

enum DisplayType_t
{
None,
PCD8544,
SSD1306,
SH1106,
SSD1309,
dummy5,
dummy6,
dummy7,
dummy8,
dummy9,
ePaper154
};
2 changes: 2 additions & 0 deletions include/PinMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ struct PinMapping_t {
uint8_t display_clk;
uint8_t display_cs;
uint8_t display_reset;
uint8_t display_busy;
uint8_t display_dc;
int8_t led[PINMAPPING_LED_COUNT];
};

Expand Down
1 change: 1 addition & 0 deletions include/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@
#define DISPLAY_SCREENSAVER true
#define DISPLAY_ROTATION 2U
#define DISPLAY_CONTRAST 60U
#define DISPLAY_UPDATE 10000
#define DISPLAY_LANGUAGE 0U
12 changes: 12 additions & 0 deletions include/imagedata.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

extern const unsigned char AhoyLogo[];
extern const unsigned char OpenDTULogo[];
extern const unsigned char myHoy[];
extern const unsigned char mySigma[];
extern const unsigned char mySun[];
extern const unsigned char myToday[];
extern const unsigned char myWR[];

extern const unsigned char gImage_1in54[];
Loading