On a typical microcontroller project we may only have access to a relatively tiny screen. Information display can be a challenge, but it’s one that may be made easier by [0xPIT]’s ESParklines library for Espressif processors using the Arduino framework.
A sparkline is a simple line graph without annotations (like axes or units) intended to fit within the flow of text. They’re largely associated today with the statistician Edward Tufte, and if you’ve not encountered them or Tufte before then we suggest you’ll enjoy educating yourself.
It’s a simple enough library and it comes with example code. Usefully it maintains a data buffer all of its own allowing simple updating, and as well as the examples there is a YouTube video we’ve put below the fold showing graphs evolving as more information is added to them. We’re curious about one thing though, it’s billed as an ESP library, for either the ESP8266 or the ESP32, but we can’t find any ESP-specific code in there and neither could our friendly ESP-guru. Have we missed something? The comments are below if you can shed any light.
Ooh, that looks nice!
Very easy to figure out what’s going on. Use a source code level debugger or simulator to trace the code.
Very nice! Tried to write a sparkline for ESP myself a couple of months ago, but failed…. now I can just add it to my project :-) Thanks for sharing!
You can also use the big screen of your android phone / tablet with our app RoboRemoFree https://play.google.com/store/apps/details?id=com.hardcodedjoy.roboremofree&referrer=utm_source%3Dcomment
You can add multiple plots and text logs.
Went to your site and also read user comments on your app. Looks very interesting!
Do you have an iOS version of the app?
There’s no mystery. The source code of the library expects you to give it a “drawline” method which is specific to your display.
The example “SparklineExample_OLED_U8G2.cpp” shows how.
Worst case, you have to implement a “drawline” function for your display. The example uses a class specific to the used display, which provides a “drawline” method.
The ESParklines only provides the little bit you need to handle the data and draw the lines. It does NOT talk to any specific hardware.
Was pretty much going to say something similar. The guy probably only mentions esp, cause that’s all hes tested on. Either A) not having other platforms to test it on, or B) not caring enough to test it. I don’t ever bother testing code i’ve written for my esp based projects against arduino. I have the hardware, but a rarely use them anymore these days. The esp is a far superior micro controller in almost every way, except if you have have limited power budget. Though the ESP can do great for low power projects where you only need it to wake up occasionally to process something then go back to sleep. An example I have an esp32 attached to an e-ink dispay that displays the weather. It wakes up every 15minutes, connects to wifi, grabs the weather data from the internet, updates the eink display then goes back to sleep, this whole process only takes maybe 5seconds. It has been running off the same 1000mah lipo cell since I built it a month ago and has only drained the cell to 80% charge remaining.
This inspired me! After I read this I just had to create a similar `sparkline` class for CircuitPython:
Library:
https://github.com/kmatch98/Adafruit_CircuitPython_Display_Shapes/tree/master/examples
Usage:
https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes/pull/14
For a video of the example:
https://twitter.com/CycleMatch/status/1269659865779261440?s=20
As someone comoletely ignorant of his ideas, I found the linked Edward Tufte website to be quite uninformative. (which might be a bit ironic) If you’re a noob like me, start at
https://en.m.wikipedia.org/wiki/Edward_tufte THEN go to https://www.edwardtufte.com/tufte/