The ShellminatorLevelMeter is great for visualizing quantities such as pressure, temperature, speed, and more. These types of values typically have upper and lower limits, and using colors to represent different ranges makes them much easier for the human eye to understand.
In many cases, the exact numerical value isnโt important โitโs enough to see at a glance whether something is in a good or bad range. Because of this, the ShellminatorLevelMeter allows you to divide the scale into three color-coded sections:
- Normal range (default: WHITE)
- Warning range (default: YELLOW)
- Danger range (default: RED)
Of course, you can customize these colors:
@ YELLOW
Yellow text color.
You can also define the boundaries for when the warning and danger colors should appear:
meter.setWarningPercentage(50.0);
meter.setErrorPercentage(80.0);
Live Demo
Whole Code
uint32_t timerStart = 0;
uint32_t period = 100;
float percentage = 1.0;
float step = 1.0;
void setup(){
Serial.begin(115200);
shell.clear();
Serial.println( "Program Start!" );
meter.setWarningPercentage( 50.0 );
meter.setErrorPercentage( 80.0 );
shell.begin( "arnold" );
shell.beginScreen( &meter );
}
void loop(){
if( ( millis() - timerStart ) > period ){
timerStart = millis();
percentage += step;
if( percentage > 100.0 ){
step = -1.0;
percentage = 100.0;
}
if( percentage < 0.0 ){
step = 1.0;
percentage = 0.0;
}
meter.setPercentage( percentage );
}
shell.update();
}