Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.

Added option for sparkline#7

Open
boekenwuurm wants to merge 1 commit into
revspace:mainfrom
boekenwuurm:sparkline
Open

Added option for sparkline#7
boekenwuurm wants to merge 1 commit into
revspace:mainfrom
boekenwuurm:sparkline

Conversation

@boekenwuurm

Copy link
Copy Markdown

Added option for a sparkline.

@Juerd Juerd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR; a sparkline would be a nice configurable option. I haven't tried it yet and won't accept the PR in its current form, but have provided some remarks.

Comment thread SparkLine.h
@@ -0,0 +1,150 @@
// Adaped version of ESParklines to sidestep random() issue in FixedPointsArduino library

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I strongly prefer not including forked libraries in the Operame repository, if it can be avoided at all. I've submitted a PR to fix the underlying library instead, at Pharap/FixedPointsArduino#71

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread operame.ino
bool wifi_enabled;
bool mqtt_enabled;
int max_failures;
bool sparkline_enable;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nitpick: the other variables are called _enabled. For consistency, _enabled would be preferred to _enable.

Comment thread operame.ino
bool mqtt_enabled;
int max_failures;
bool sparkline_enable;
int sparkline_bufferlenght;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Spelling: length

Comment thread operame.ino
}
}

SparkLine<uint16_t> display_sparkline(766, [&](const uint16_t x0, const uint16_t y0, const uint16_t x1, const uint16_t y1) {

@Juerd Juerd Jan 28, 2021

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm guessing the 766 was supposed to be sparkline_bufferlength? That variable is declared and assigned but not used elsewhere.

Comment thread operame.ino
sprite.drawString(text, display.width()/2, display.height()/2);

if (sparkline_enable) {
display_sparkline.draw( 10, display.height()/4*3, display.width()-20, display.height()/2-5);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm curious what the -5 is for.

Comment thread operame.ino
delay(30);
}
display_logo();
if (sparkline_enable ) display_sparkline.reset();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm wondering if having the sparkline in the demo is worth resetting the main history for. OTOH, this makes it consistent with accessing the portal (resetting the microcontroller is the only way out) and does make the demo include the sparkline.

Comment thread operame.ino
mqtt_template = WiFiSettings.string("operame_mqtt_template", "{} PPM", T.config_mqtt_template);
WiFiSettings.info(T.config_template_info);

WiFiSettings.heading("sparkline");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not translated.

Comment thread operame.ino

WiFiSettings.heading("sparkline");
sparkline_enable = WiFiSettings.checkbox("operame_sparkline", false, T.config_sparkline);
sparkline_bufferlenght = WiFiSettings.integer("operame_sparkline_buffer", 0, 16383, 512, T.config_sparkline_buffer); ;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe the buffer length should not be user configurable, at least not without explaining what it does. If it is configurable, I think it would be slightly more user friendly to let them specify the buffer size in minutes.

Why 16383 and 512?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants