@@ -98,6 +98,8 @@ This library was inspired by [ICSMeter](https://github.com/armel/ICSMeter).
9898
9999```C++
100100
101+ #include <M5Unified.h>
102+ #include <LGFXMeter.h>
101103
102104
103105void setup()
@@ -141,7 +143,6 @@ void setup()
141143
142144 ICSGauge = new Gauge_Class( cfg );
143145 ICSGauge->pushGauge(); // render empty gauge (no needle yet)
144-
145146}
146147
147148
@@ -154,10 +155,17 @@ void loop()
154155 // map() it to the gauge angular range [0...90]
155156 float my_angle = utils::mapFloat( mySensorValue, 0, 4095, 0.0, 90.0 );
156157
157- // either animate (300ms blocking) ...
158+ // Either animate (300ms blocking) ...
158159 ICSGauge->animateNeedle( my_angle );
159160
160- // .. or just update
161+ // .. or use eased drawing (300ms non blocking) ...
162+ ICSGauge->setNeedle( my_angle );
163+ ICSGauge->easeNeedle( 300 );
164+ // ICSGauge->easeNeedle( 300, easing::easeOutBounce );
165+ // /!\ See lgfxmeter_types.hpp for complete list of available easing function
166+ // Function names
167+
168+ // .. or just render the needle without easing or animation
161169 ICSGauge->drawNeedle( my_angle );
162170
163171}
@@ -171,20 +179,21 @@ void loop()
171179
172180Background, needle and needle shadow images can be any of the following formats:
173181
174- - PNG
175- - QOI
176- - JPG
177- - BMP
182+ - PNG: ` IMAGE_PNG `
183+ - QOI: ` IMAGE_QOI `
184+ - JPG: ` IMAGE_JPG `
185+ - BMP: ` IMAGE_BMP `
186+ - RAW: ` IMAGE_RAW ` (e.g. Sprite, untested)
187+
178188
179- As seen in the examples, image data should be stored in byte arrays.
189+ As seen in the examples, image data can be stored in byte arrays.
180190
181191``` C++
182192
183193 const image_t bgImg = { 16, bg_png, bg_png_len, IMAGE_PNG, 320, 240 };
184194 const image_t vuMeterArrow = { 16, clock_arrow_png, clock_arrow_png_len, IMAGE_PNG, 16, 144 };
185195 const image_t vuMeterShadow = { 16, clock_arrow_shadow_png, clock_arrow_shadow_png_len, IMAGE_PNG, 16, 144 };
186196
187-
188197```
189198
190199Custom background, needle and shadow can be setup as follows:
@@ -198,6 +207,7 @@ Custom background, needle and shadow can be setup as follows:
198207 cfg.needleCfg.needleImg = &vuMeterArrow;
199208 cfg.needleCfg.shadowImg = &vuMeterShadow;
200209 //cfg.needleCfg.scaleX = 0.5; // scaling down a stretched image to produce nicer antialiased result
210+ //cfg.needle.axis = { GaugeWidth/2, GaugePosY + GaugeHeight }; // will be automatically positioned with a clunky calculation otherwise
201211
202212
203213 // Optionally share a background image between TFT and the gauge sprite
@@ -210,7 +220,25 @@ Custom background, needle and shadow can be setup as follows:
210220
211221```
212222
223+ Background can eventually be changed after gauge creation, but it will remove any previously drawn rulers.
224+ However if the gauge is built without rulers and uses a simple background image, then custom modes (e.g. dark/light) are possible.
225+
226+ ``` C++
227+
228+ // firt create your image entity
229+ const image_t alternateBgImage = { 16, my_image_data, my_image_data_len, IMAGE_PNG, GaugeWidth, GaugeWidth };
230+
231+ // overwrite the gauge background (will also remove the rulers !)
232+ utils::drawImage ( ICSGauge->getGaugeSprite(), alternateBgImage, 0, 0 );
233+
234+ // eventually change the transparency color depending on the saturation
235+ needle::cfg.transparent_color = is_background_dark ? 0x000000U : 0xffffffU;
213236
237+ // or toggle needle shadow in dark mode
238+ needle::cfg.drop_shadow = is_background_dark ? false : true;
239+
240+
241+ ```
214242
215243
216244
0 commit comments