Skip to content

Commit

Permalink
Fix meters example
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodmer committed Aug 11, 2022
1 parent 285a7f4 commit 63146c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions examples/Meters/Analogue_meters/Analogue_meters.ino
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,23 @@ void loop()
float value = 50.0 + 50.0 * sin((d + 0) * 0.0174532925);

float current;
mapValue(value, current, (float)0.0, (float)100.0, (float)0.0, (float)2.0);
current = mapValue(value, (float)0.0, (float)100.0, (float)0.0, (float)2.0);
//Serial.print("I = "); Serial.print(current);
amps.updateNeedle(current, 0);

float voltage;
mapValue(value, voltage, (float)0.0, (float)100.0, (float)0.0, (float)10.0);
voltage = mapValue(value, (float)0.0, (float)100.0, (float)0.0, (float)10.0);
//Serial.print(", V = "); Serial.println(voltage);
volts.updateNeedle(voltage, 0);

float resistance;
mapValue(value, resistance, (float)0.0, (float)100.0, (float)0.0, (float)100.0);
resistance = mapValue(value, (float)0.0, (float)100.0, (float)0.0, (float)100.0);
//Serial.print(", R = "); Serial.println(resistance);
ohms.updateNeedle(resistance, 0);
}
}

float mapValue(float ip, float ipmin, float ipmax, float tomin, float tomax)
{
return tomin + (((tomax - tomin) * (ip - ipmin))/ (ipmax - ipmin));
}
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "TFT_eWidget",
"version": "0.0.3",
"version": "0.0.4",
"keywords": "Arduino, tft, display, button, gui, graph, meter, slider",
"description": "A TFT GUI widget library",
"repository":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TFT_eWidget
version=0.0.3
version=0.0.4
author=Bodmer
maintainer=Bodmer
sentence=A TFT GUI widget library
Expand Down

0 comments on commit 63146c9

Please sign in to comment.