Skip to content

Commit

Permalink
Many changes regarding Json support and memory improvement
Browse files Browse the repository at this point in the history
- Support for ArduinoJson 7
- Fixed missing `float step` for slider when using short ranges or big ranges
- Supports WebSocket batching to avoid crash with the initial layout sending. Batch sizes can be controlled with `DASH_JSON_SIZE`.
- Mitigate concurrency issue with `isAsyncAccessInProgress()` to avoid updating cards while the layout is being generated
- Added `DASH_DEBUG` to show WS frames information
- Changed card and stat names to `const char*` to improve memory usage. This makes them immutable and require to use constants.
- Removed the ability to change a stat name (for this dynamic use case we can remove and recreate a stat)
- refreshLayout() refactoring in order to avoid too many layout refresh requests when updating components dynamically: let the caller trigger a layout refresh once.
- Removed refreshStatistics() because it it not refreshing the stats only but all the updated cards also
- Removed update calls when adding / removing cards and stats in order to avoid trigger a sequence of full layout updates: this is u to the user to call refreshLayout() when he has finished
  • Loading branch information
mathieucarbou committed Jan 12, 2024
1 parent b677bf6 commit a9f8904
Show file tree
Hide file tree
Showing 11 changed files with 3,391 additions and 3,340 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

node_modules
.DS_Store
.vscode
/.vscode/*
!/.vscode/settings.json
./vue-frontend/dist
/build
/portal
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 2, TabWidth: 2, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: true, ColumnLimit: 0, AccessModifierOffset: -2, NamespaceIndentation: All, FixNamespaceComments: false, IndentAccessModifiers: true, PointerAlignment: Left, ReferenceAlignment: Left, ContinuationIndentWidth: 2}"
}
3 changes: 2 additions & 1 deletion src/Card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
/*
Constructor
*/
Card::Card(ESPDash *dashboard, const int type, const char* name, const char* symbol, const int min, const int max){
Card::Card(ESPDash *dashboard, const int type, const char* name, const char* symbol, const int min, const int max, const float step){
_dashboard = dashboard;
_id = dashboard->nextId();
_type = type;
_name = name;
_symbol = symbol;
_value_min = min;
_value_max = max;
_value_step = step;
_dashboard->add(this);
}

Expand Down
5 changes: 3 additions & 2 deletions src/Card.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Card {
ESPDash *_dashboard;

uint32_t _id;
String _name;
const char* _name;
int _type;
bool _changed;
enum { INTEGER, FLOAT, STRING } _value_type;
Expand All @@ -44,11 +44,12 @@ class Card {
String _value_s;
int _value_min;
int _value_max;
float _value_step;
String _symbol;
std::function<void(int value)> _callback = nullptr;

public:
Card(ESPDash *dashboard, const int type, const char* name, const char* symbol = "", const int min = 0, const int max = 0);
Card(ESPDash *dashboard, const int type, const char* name, const char* symbol = "", const int min = 0, const int max = 0, const float step = 1);
void attachCallback(std::function<void(int)> cb);
void update(int value);
void update(int value, const char* symbol);
Expand Down
2 changes: 1 addition & 1 deletion src/Chart.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Chart {
ESPDash *_dashboard;

uint32_t _id;
String _name;
const char *_name;
int _type;
bool _changed;
GraphAxisType _x_axis_type;
Expand Down
Loading

0 comments on commit a9f8904

Please sign in to comment.