Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ESP-DASH v5
ESP-DASH v5 is a rewrite of ESP-DASH **OSS and Pro## Motivation versions with C++ 17.
Motivation
The rewrite has been motived by several factors including:
The rewrite uses C++ 17 inheritance, polymorphism and templating.
The rewrite is also backward compatible and will display deprecation compiler warnings if the old deprecated API is used.
Here is a screenshot of before / after during the development.
Now, the
website.cpp
file is 15KB, compared to the initial 36KB.The preliminary results in a big app with about 225 cards and 30 stats show a decrease in RAM usage of about 60%.
Benchmark5.ino Example
Benchmark5.ino is a new example that demonstrates the new API and the new features.
Compile flags
C++ 17 is required, which is the default in new Arduino versions, otherwise, you can add to your PIO file:
-D DASH_DEBUG
: activate debug mode-D DASH_USE_STL_STRING=1
: usesstd::string
instead ofString
for the string typeESP-DASH also defines its own string
dash::string
, which points toString
orstd::string
depending on the flag-D DASH_USE_STL_STRING=1
.dash::string
can be used to avoid usingString
orstd::string
directly and write portable code or examples.New API
All Widgets
const char*
,std::string
,String
)Note: working with floating point numbers is generally slower than working with integral numbers because of the rounding step requiring to convert the number to a string representation with a fixed number of decimals.
Statistics
dash::StatisticValue
: replacesStatistic
dash::StatisticProvider
: a new kind of auto-updatable statistic: the value is sourced from a function and is automatically updated when the dashboard is refreshed.Charts
Charts have 2 axis: X and Y.
For each axis, the type can be integral or floating point.
For the X axis, strings are also supported.
For performance reasons, floating point precision is not supported for charts.
It is advised to do the rounding in the value arrays.
Cards
dash::FeedbackCard
STATUS_CARD
dash::string
typeconst char*
withdash::FeedbackCard<const char*>
dash::GenericCard
GENERIC_CARD
dash::string
typedash::HumidityCard
anddash::TemperatureCard
HUMIDITY_CARD
andTEMPERATURE_CARD
float
type with a precision of 2 decimals%
for humidity and°C
for temperature but can be changeddash::ProgressCard
PROGRESS_CARD
int
typedash::SliderCard
SLIDER_CARD
int
typedash::SwitchCard
BUTTON_CARD
bool
typeFunctions and callbacks
onChange([](<type>)){}
Listen to card changes:
value()
: get the value of a cardmin()
,max()
,step()
: get the min, max, step of a slider cardsetMin()
,setMax()
,setStep()
: set the min, max, step of a slider cardsetFeedback()
: set the feedback of a feedback cardsetValue()
: set the value of a cardOptimisations
By default, the string type that will be used to store string values is
String
orstd::string
if the flag-D DASH_USE_STL_STRING=1
is set.To avoid allocating memory and copying strings, the
const char*
type can be used when the card is sourcing its content from constant strings only.Example: