|
| 1 | +/** |
| 2 | + * @file SensorDrawing.h |
| 3 | + * @brief Shared procedural icons for sensor panel rendering. |
| 4 | + * |
| 5 | + * Each icon function is guarded by its sensor's compile flag — when a sensor |
| 6 | + * is disabled via SIMUT_SENSOR_*, its icon code is stripped from flash. |
| 7 | + * |
| 8 | + * All functions draw into a GFXcanvas16. The caller is responsible for |
| 9 | + * blitting the canvas to the TFT at the correct position. |
| 10 | + * |
| 11 | + * @project SIMUT — Integrated Universal Monitoring and Telemetry System |
| 12 | + * @license MIT License |
| 13 | + */ |
| 14 | + |
| 15 | +#pragma once |
| 16 | +#include <Adafruit_GFX.h> |
| 17 | +#ifndef RGB565 |
| 18 | +#define RGB565(r,g,b) ((((r) & 0xF8) << 8) | (((g) & 0xFC) << 3) | ((b) >> 3)) |
| 19 | +#endif |
| 20 | + |
| 21 | +/* ── Thermometer (large, 18×28 px) ──────────────────────────────────────── */ |
| 22 | + |
| 23 | +#if SIMUT_SENSOR_DS18B20 || SIMUT_SENSOR_DHT22 || SIMUT_SENSOR_BME280 |
| 24 | +inline void drawThermometerLarge(GFXcanvas16* cv, int16_t x, int16_t y, |
| 25 | + uint16_t outline, uint16_t bg, uint16_t mercury) { |
| 26 | + cv->fillCircle(x + 5, y + 26, 7, outline); |
| 27 | + cv->fillRoundRect(x + 1, y, 8, 24, 4, outline); |
| 28 | + cv->fillRoundRect(x + 3, y + 2, 4, 20, 2, bg); |
| 29 | + cv->fillCircle(x + 5, y + 26, 5, bg); |
| 30 | + cv->fillRect(x + 4, y + 10, 2, 14, mercury); |
| 31 | + cv->fillCircle(x + 5, y + 26, 4, mercury); |
| 32 | + cv->fillCircle(x + 5, y + 2, 2, outline); |
| 33 | +} |
| 34 | +#endif |
| 35 | + |
| 36 | +/* ── Thermometer (mini, ~12×20 px) ──────────────────────────────────────── */ |
| 37 | + |
| 38 | +#if SIMUT_SENSOR_DS18B20 || SIMUT_SENSOR_DHT22 || SIMUT_SENSOR_BME280 |
| 39 | +inline void drawThermometerMini(GFXcanvas16* cv, int16_t x, int16_t y, |
| 40 | + uint16_t outline, uint16_t bg, uint16_t mercury) { |
| 41 | + cv->fillCircle(x + 4, y + 15, 5, outline); |
| 42 | + cv->fillRoundRect(x + 1, y, 7, 14, 3, outline); |
| 43 | + cv->fillRoundRect(x + 2, y + 1, 5, 12, 2, bg); |
| 44 | + cv->fillCircle(x + 4, y + 15, 4, bg); |
| 45 | + cv->fillRect(x + 3, y + 8, 3, 6, mercury); |
| 46 | + cv->fillCircle(x + 4, y + 15, 3, mercury); |
| 47 | + cv->fillCircle(x + 4, y + 2, 2, outline); |
| 48 | +} |
| 49 | +#endif |
| 50 | + |
| 51 | +/* ── Drop / water droplet (large, ~20×22 px) ────────────────────────────── */ |
| 52 | + |
| 53 | +#if SIMUT_SENSOR_DHT22 || SIMUT_SENSOR_BME280 |
| 54 | +inline void drawDropLarge(GFXcanvas16* cv, int16_t x, int16_t y, |
| 55 | + uint16_t color, uint16_t shine) { |
| 56 | + cv->fillCircle(x + 6, y + 20, 8, color); |
| 57 | + cv->fillTriangle(x + 6, y, x - 1, y + 18, x + 13, y + 18, color); |
| 58 | + cv->fillCircle(x + 4, y + 17, 3, shine); |
| 59 | + cv->fillCircle(x + 3, y + 14, 1, shine); |
| 60 | +} |
| 61 | +#endif |
| 62 | + |
| 63 | +/* ── Drop / water droplet (mini, ~12×14 px) ─────────────────────────────── */ |
| 64 | + |
| 65 | +#if SIMUT_SENSOR_DHT22 || SIMUT_SENSOR_BME280 |
| 66 | +inline void drawDropMini(GFXcanvas16* cv, int16_t x, int16_t y, |
| 67 | + uint16_t color, uint16_t shine) { |
| 68 | + cv->fillCircle(x + 5, y + 7, 6, color); |
| 69 | + cv->fillTriangle(x + 5, y - 5, x, y + 5, x + 10, y + 5, color); |
| 70 | + cv->fillCircle(x + 3, y + 5, 2, shine); |
| 71 | + cv->drawPixel(x + 3, y + 2, shine); |
| 72 | +} |
| 73 | +#endif |
| 74 | + |
| 75 | +/* ── "°C" unit (normal mode, 24pt value) ────────────────────────────────── */ |
| 76 | + |
| 77 | +inline void drawUnitDegC_Normal(GFXcanvas16* cv, int16_t x, |
| 78 | + uint16_t color, const GFXfont& font9, |
| 79 | + const GFXfont& font12) { |
| 80 | + cv->setFont(&font9); |
| 81 | + cv->setTextColor(color); |
| 82 | + cv->setCursor(x, 17); |
| 83 | + cv->print("o"); |
| 84 | + cv->setFont(&font12); |
| 85 | + cv->setCursor(x + 8, 35); |
| 86 | + cv->print("C"); |
| 87 | +} |
| 88 | + |
| 89 | +/* ── "°C" unit (min/max mode, 9pt value) ────────────────────────────────── */ |
| 90 | + |
| 91 | +inline void drawUnitDegC_Mini(GFXcanvas16* cv, int16_t x, int16_t baseY, |
| 92 | + uint16_t color, const GFXfont& font9) { |
| 93 | + cv->setFont(NULL); |
| 94 | + cv->setTextSize(1); |
| 95 | + cv->setTextColor(color); |
| 96 | + cv->setCursor(x, baseY + 2); |
| 97 | + cv->print("o"); |
| 98 | + cv->setFont(&font9); |
| 99 | + cv->setCursor(x + 6, baseY + 15); |
| 100 | + cv->print("C"); |
| 101 | +} |
| 102 | + |
0 commit comments