Merge remote changes (diseño visual) con cambios locales (conexión a ECU y robustez OBD2)
This commit is contained in:
commit
4bb5986ce7
4 changed files with 7775 additions and 101 deletions
|
|
@ -41,8 +41,8 @@ const uint8_t maxMenu = 3;
|
||||||
|
|
||||||
// Menu list for warning setting (4 vehicle gauges)
|
// Menu list for warning setting (4 vehicle gauges)
|
||||||
const String parameterList[4][2] = {
|
const String parameterList[4][2] = {
|
||||||
{"- Refrigerante (ECT)", " `c "},
|
{"- Temperatura (ECT)", " `c "},
|
||||||
{"- Revoluciones (RPM)", " rpm "},
|
{"- RPM", " rpm "},
|
||||||
{"- Voltaje Bateria", " V "},
|
{"- Voltaje Bateria", " V "},
|
||||||
{"- Velocidad (SPEED)", " km/h"}
|
{"- Velocidad (SPEED)", " km/h"}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -32,14 +32,271 @@ String pidList[maxpidIndex] =
|
||||||
{}; //{"0104","0105","010C","010B","010C","0142","015C"}
|
{}; //{"0104","0105","010C","010B","010C","0142","015C"}
|
||||||
uint8_t pidReadSkip[maxpidIndex] = {}; // skip reading 0 - 3; 3 = max delay read
|
uint8_t pidReadSkip[maxpidIndex] = {}; // skip reading 0 - 3; 3 = max delay read
|
||||||
uint8_t pidCurrentSkip[maxpidIndex] = {}; // current skip counter
|
uint8_t pidCurrentSkip[maxpidIndex] = {}; // current skip counter
|
||||||
float old_data[maxpidIndex] =
|
uint8_t engine_off_count = 0; // counter to indicate engine is off then sleep
|
||||||
{}; // keep old data for each gauge to improve speed for pidIndex 0-6
|
float old_data[maxpidIndex] = {-999, -999, -999, -999}; // keep old data
|
||||||
float last_valid_data[maxpidIndex] = {-999, -999, -999, -999}; // keep last valid reading across view toggles
|
float last_valid_data[maxpidIndex] = {-999, -999, -999, -999}; // keep last valid data for instant redraw
|
||||||
|
|
||||||
// backlight variable average counter
|
// backlight variable average counter
|
||||||
uint8_t low_count = 0;
|
uint8_t low_count = 0;
|
||||||
uint8_t high_count = 0;
|
uint8_t high_count = 0;
|
||||||
|
|
||||||
|
const float factoryECUOff = 12.5; // default off voltage
|
||||||
|
float ecu_off_volt = factoryECUOff; // turn engine off if voltage lower
|
||||||
|
// than 12.4
|
||||||
|
|
||||||
|
// Draw parameter icon in header with transparent background (TFT_BLACK)
|
||||||
|
void drawPidIcon(int x, int y, const String &pidStr) {
|
||||||
|
if (pidStr == "0105") {
|
||||||
|
tft.pushImage(x, y, 24, 24, icon_temp, TFT_BLACK);
|
||||||
|
} else if (pidStr == "010D") {
|
||||||
|
tft.pushImage(x, y, 24, 24, icon_speed, TFT_BLACK);
|
||||||
|
} else if (pidStr == "010C") {
|
||||||
|
tft.pushImage(x, y, 24, 24, icon_rpm, TFT_BLACK);
|
||||||
|
} else if (pidStr == "0142" || pidStr == "ATRV") {
|
||||||
|
tft.pushImage(x, y, 24, 24, icon_battery, TFT_BLACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw header icon (42x42 px, ~30% larger) for full screen mode
|
||||||
|
void drawPidIconHeader(int x, int y, const String &pidStr) {
|
||||||
|
if (pidStr == "0105") {
|
||||||
|
tft.pushImage(x, y, 42, 42, icon_temp_42, TFT_BLACK);
|
||||||
|
} else if (pidStr == "010D") {
|
||||||
|
tft.pushImage(x, y, 42, 42, icon_speed_42, TFT_BLACK);
|
||||||
|
} else if (pidStr == "010C") {
|
||||||
|
tft.pushImage(x, y, 42, 42, icon_rpm_42, TFT_BLACK);
|
||||||
|
} else if (pidStr == "0142" || pidStr == "ATRV") {
|
||||||
|
tft.pushImage(x, y, 42, 42, icon_battery_42, TFT_BLACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Full Screen Exponential Segmented Block Bar Graph (20 blocks: 3mm width x 4mm height, 0.5mm gap, Anti-Aliased)
|
||||||
|
const uint8_t NUM_BAR_BLOCKS = 20;
|
||||||
|
const int16_t blockMinX[20] PROGMEM = { 0, 5, 11, 17, 25, 34, 46, 59, 76, 95, 114, 134, 154, 174, 193, 213, 232, 251, 271, 290 };
|
||||||
|
const int16_t blockMaxX[20] PROGMEM = { 28, 34, 40, 47, 55, 65, 76, 89, 104, 121, 138, 157, 175, 194, 214, 233, 252, 271, 290, 310 };
|
||||||
|
const int16_t blockMinY[20] PROGMEM = { 202, 183, 164, 146, 127, 110, 94, 80, 70, 63, 59, 56, 54, 53, 52, 52, 52, 52, 52, 52 };
|
||||||
|
const int16_t blockMaxY[20] PROGMEM = { 226, 208, 190, 172, 155, 139, 124, 111, 100, 92, 87, 83, 80, 79, 78, 77, 77, 77, 77, 77 };
|
||||||
|
|
||||||
|
const float blockNx[20][4] PROGMEM = {
|
||||||
|
{ 0.96709f, -0.26991f, -0.96711f, 0.24260f },
|
||||||
|
{ 0.95775f, -0.30696f, -0.95776f, 0.26991f },
|
||||||
|
{ 0.94416f, -0.35424f, -0.94418f, 0.30696f },
|
||||||
|
{ 0.92359f, -0.41544f, -0.92365f, 0.35424f },
|
||||||
|
{ 0.89126f, -0.49508f, -0.89141f, 0.41544f },
|
||||||
|
{ 0.83905f, -0.59638f, -0.83936f, 0.49508f },
|
||||||
|
{ 0.75533f, -0.71496f, -0.75581f, 0.59638f },
|
||||||
|
{ 0.63154f, -0.83065f, -0.63179f, 0.71496f },
|
||||||
|
{ 0.47873f, -0.91631f, -0.47824f, 0.83065f },
|
||||||
|
{ 0.33039f, -0.96398f, -0.32962f, 0.91631f },
|
||||||
|
{ 0.21408f, -0.98563f, -0.21356f, 0.96398f },
|
||||||
|
{ 0.13436f, -0.99446f, -0.13412f, 0.98563f },
|
||||||
|
{ 0.08319f, -0.99789f, -0.08309f, 0.99446f },
|
||||||
|
{ 0.05123f, -0.99920f, -0.05120f, 0.99789f },
|
||||||
|
{ 0.03149f, -0.99970f, -0.03148f, 0.99920f },
|
||||||
|
{ 0.01934f, -0.99989f, -0.01934f, 0.99970f },
|
||||||
|
{ 0.01188f, -0.99996f, -0.01187f, 0.99989f },
|
||||||
|
{ 0.00729f, -0.99998f, -0.00729f, 0.99996f },
|
||||||
|
{ 0.00448f, -0.99999f, -0.00448f, 0.99998f },
|
||||||
|
{ 0.00275f, -1.00000f, -0.00275f, 0.99999f },
|
||||||
|
};
|
||||||
|
|
||||||
|
const float blockNy[20][4] PROGMEM = {
|
||||||
|
{ 0.25444f, 0.96289f, -0.25437f, -0.97013f },
|
||||||
|
{ 0.28762f, 0.95172f, -0.28757f, -0.96289f },
|
||||||
|
{ 0.32950f, 0.93516f, -0.32942f, -0.95172f },
|
||||||
|
{ 0.38338f, 0.90962f, -0.38323f, -0.93516f },
|
||||||
|
{ 0.45348f, 0.86885f, -0.45320f, -0.90962f },
|
||||||
|
{ 0.54405f, 0.80270f, -0.54358f, -0.86885f },
|
||||||
|
{ 0.65535f, 0.69916f, -0.65480f, -0.80270f },
|
||||||
|
{ 0.77534f, 0.55679f, -0.77514f, -0.69916f },
|
||||||
|
{ 0.87796f, 0.40047f, -0.87823f, -0.55679f },
|
||||||
|
{ 0.94384f, 0.26596f, -0.94412f, -0.40047f },
|
||||||
|
{ 0.97682f, 0.16890f, -0.97693f, -0.26596f },
|
||||||
|
{ 0.99093f, 0.10510f, -0.99097f, -0.16890f },
|
||||||
|
{ 0.99653f, 0.06486f, -0.99654f, -0.10510f },
|
||||||
|
{ 0.99869f, 0.03990f, -0.99869f, -0.06486f },
|
||||||
|
{ 0.99950f, 0.02452f, -0.99950f, -0.03990f },
|
||||||
|
{ 0.99981f, 0.01506f, -0.99981f, -0.02452f },
|
||||||
|
{ 0.99993f, 0.00924f, -0.99993f, -0.01506f },
|
||||||
|
{ 0.99997f, 0.00568f, -0.99997f, -0.00924f },
|
||||||
|
{ 0.99999f, 0.00348f, -0.99999f, -0.00568f },
|
||||||
|
{ 1.00000f, 0.00223f, -1.00000f, -0.00348f },
|
||||||
|
};
|
||||||
|
|
||||||
|
const float blockC[20][4] PROGMEM = {
|
||||||
|
{ -57.0917f, -194.0217f, 79.0747f, 212.4570f },
|
||||||
|
{ -63.7256f, -171.8745f, 85.7128f, 191.2717f },
|
||||||
|
{ -71.2233f, -148.4987f, 93.2024f, 169.1245f },
|
||||||
|
{ -79.6909f, -123.2275f, 101.6563f, 145.7487f },
|
||||||
|
{ -89.0635f, -95.0180f, 111.0070f, 120.4775f },
|
||||||
|
{ -98.7898f, -62.4921f, 120.7056f, 92.2680f },
|
||||||
|
{ -107.1996f, -24.6792f, 129.0998f, 59.7421f },
|
||||||
|
{ -111.1224f, 16.8839f, 133.0287f, 21.9292f },
|
||||||
|
{ -107.7811f, 57.2365f, 129.6718f, -19.6339f },
|
||||||
|
{ -98.3836f, 92.0853f, 120.2644f, -59.9865f },
|
||||||
|
{ -87.1827f, 121.1162f, 109.0982f, -94.8353f },
|
||||||
|
{ -77.3181f, 146.0701f, 99.2734f, -123.8662f },
|
||||||
|
{ -69.7527f, 168.5916f, 91.7322f, -148.8201f },
|
||||||
|
{ -64.3207f, 189.7308f, 86.3119f, -171.3416f },
|
||||||
|
{ -60.5502f, 210.0867f, 82.5466f, -192.4808f },
|
||||||
|
{ -57.9834f, 229.9930f, 79.9819f, -212.8367f },
|
||||||
|
{ -56.2577f, 249.6371f, 78.2571f, -232.7430f },
|
||||||
|
{ -55.1079f, 269.1261f, 77.1076f, -252.3871f },
|
||||||
|
{ -54.3470f, 288.5222f, 76.3469f, -271.8761f },
|
||||||
|
{ -53.8454f, 307.8565f, 75.8453f, -291.2722f },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Draw an individual solid rectangular block with smooth subpixel anti-aliasing
|
||||||
|
inline void drawBarBlock(uint8_t i, uint16_t color) {
|
||||||
|
int16_t minX = pgm_read_word(&blockMinX[i]);
|
||||||
|
int16_t maxX = pgm_read_word(&blockMaxX[i]);
|
||||||
|
int16_t minY = pgm_read_word(&blockMinY[i]);
|
||||||
|
int16_t maxY = pgm_read_word(&blockMaxY[i]);
|
||||||
|
|
||||||
|
float nx[4], ny[4], c[4];
|
||||||
|
for (uint8_t k = 0; k < 4; k++) {
|
||||||
|
nx[k] = pgm_read_float(&blockNx[i][k]);
|
||||||
|
ny[k] = pgm_read_float(&blockNy[i][k]);
|
||||||
|
c[k] = pgm_read_float(&blockC[i][k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
tft.startWrite();
|
||||||
|
for (int16_t y = minY; y <= maxY; y++) {
|
||||||
|
float py = (float)y + 0.5f;
|
||||||
|
for (int16_t x = minX; x <= maxX; x++) {
|
||||||
|
float px = (float)x + 0.5f;
|
||||||
|
float min_d = 999.0f;
|
||||||
|
for (uint8_t k = 0; k < 4; k++) {
|
||||||
|
float d = px * nx[k] + py * ny[k] + c[k];
|
||||||
|
if (d < min_d) min_d = d;
|
||||||
|
}
|
||||||
|
if (min_d <= -0.5f) continue;
|
||||||
|
if (min_d >= 0.5f) {
|
||||||
|
tft.drawPixel(x, y, color);
|
||||||
|
} else {
|
||||||
|
uint8_t alpha = (uint8_t)((min_d + 0.5f) * 255.0f);
|
||||||
|
tft.drawPixel(x, y, color, alpha, TFT_BLACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tft.endWrite();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4-Quadrant Exponential Segmented Block Bar Graph (20 blocks per 160x120 quadrant, Anti-Aliased)
|
||||||
|
const int16_t quadBlockMinX[20] PROGMEM = { 0, 2, 5, 8, 12, 17, 22, 29, 37, 46, 56, 66, 76, 86, 96, 106, 115, 125, 135, 145 };
|
||||||
|
const int16_t quadBlockMaxX[20] PROGMEM = { 13, 15, 19, 22, 26, 31, 37, 44, 51, 60, 69, 79, 88, 98, 108, 117, 127, 137, 147, 156 };
|
||||||
|
const int16_t quadBlockMinY[20] PROGMEM = { 99, 89, 80, 71, 62, 53, 45, 38, 33, 30, 28, 27, 27, 27, 27, 27, 27, 27, 27, 27 };
|
||||||
|
const int16_t quadBlockMaxY[20] PROGMEM = { 112, 103, 94, 85, 76, 68, 60, 53, 47, 43, 40, 39, 38, 38, 38, 38, 38, 38, 38, 38 };
|
||||||
|
|
||||||
|
const float quadBlockNx[20][4] PROGMEM = {
|
||||||
|
{ -0.96559f, -0.27252f, 0.96559f, 0.24838f },
|
||||||
|
{ -0.95700f, -0.30564f, 0.95699f, 0.27558f },
|
||||||
|
{ -0.94472f, -0.34769f, 0.94471f, 0.30948f },
|
||||||
|
{ -0.92644f, -0.40223f, 0.92642f, 0.35263f },
|
||||||
|
{ -0.89793f, -0.47424f, 0.89788f, 0.40871f },
|
||||||
|
{ -0.85142f, -0.56935f, 0.85129f, 0.48283f },
|
||||||
|
{ -0.77354f, -0.68905f, 0.77328f, 0.58054f },
|
||||||
|
{ -0.64798f, -0.81800f, 0.64770f, 0.70233f },
|
||||||
|
{ -0.47589f, -0.91972f, 0.47607f, 0.83033f },
|
||||||
|
{ -0.29895f, -0.97319f, 0.29947f, 0.92739f },
|
||||||
|
{ -0.16408f, -0.99284f, 0.16442f, 0.97636f },
|
||||||
|
{ -0.08089f, -0.99843f, 0.08102f, 0.99382f },
|
||||||
|
{ -0.03600f, -0.99972f, 0.03604f, 0.99867f },
|
||||||
|
{ -0.01422f, -0.99996f, 0.01423f, 0.99977f },
|
||||||
|
{ -0.00481f, -1.00000f, 0.00481f, 0.99997f },
|
||||||
|
{ -0.00131f, -1.00000f, 0.00131f, 1.00000f },
|
||||||
|
{ -0.00026f, -1.00000f, 0.00026f, 1.00000f },
|
||||||
|
{ -0.00003f, -1.00000f, 0.00003f, 1.00000f },
|
||||||
|
{ -0.00000f, -1.00000f, 0.00000f, 1.00000f },
|
||||||
|
{ -0.00000f, -1.00000f, 0.00000f, 1.00000f },
|
||||||
|
};
|
||||||
|
|
||||||
|
const float quadBlockNy[20][4] PROGMEM = {
|
||||||
|
{ -0.26007f, 0.96215f, 0.26008f, -0.96866f },
|
||||||
|
{ -0.29010f, 0.95215f, 0.29012f, -0.96128f },
|
||||||
|
{ -0.32788f, 0.93761f, 0.32791f, -0.95090f },
|
||||||
|
{ -0.37644f, 0.91554f, 0.37650f, -0.93576f },
|
||||||
|
{ -0.44013f, 0.88039f, 0.44024f, -0.91266f },
|
||||||
|
{ -0.52449f, 0.82210f, 0.52469f, -0.87571f },
|
||||||
|
{ -0.63375f, 0.72471f, 0.63407f, -0.81423f },
|
||||||
|
{ -0.76166f, 0.57522f, 0.76190f, -0.71185f },
|
||||||
|
{ -0.87951f, 0.39257f, 0.87941f, -0.55728f },
|
||||||
|
{ -0.95427f, 0.23000f, 0.95411f, -0.37410f },
|
||||||
|
{ -0.98645f, 0.11943f, 0.98639f, -0.21615f },
|
||||||
|
{ -0.99672f, 0.05600f, 0.99671f, -0.11103f },
|
||||||
|
{ -0.99935f, 0.02355f, 0.99935f, -0.05152f },
|
||||||
|
{ -0.99990f, 0.00865f, 0.99990f, -0.02140f },
|
||||||
|
{ -0.99999f, 0.00264f, 0.99999f, -0.00774f },
|
||||||
|
{ -1.00000f, 0.00062f, 1.00000f, -0.00231f },
|
||||||
|
{ -1.00000f, 0.00010f, 1.00000f, -0.00052f },
|
||||||
|
{ -1.00000f, 0.00001f, 1.00000f, -0.00008f },
|
||||||
|
{ -1.00000f, 0.00000f, 1.00000f, -0.00000f },
|
||||||
|
{ -1.00000f, -0.00000f, 1.00000f, -0.00000f },
|
||||||
|
};
|
||||||
|
|
||||||
|
const float quadBlockC[20][4] PROGMEM = {
|
||||||
|
{ 37.4358f, -95.7104f, -29.4374f, 105.3111f },
|
||||||
|
{ 40.4052f, -84.6918f, -32.4076f, 94.5998f },
|
||||||
|
{ 43.7423f, -73.1663f, -35.7462f, 83.5384f },
|
||||||
|
{ 47.4998f, -60.8527f, -39.5065f, 71.9476f },
|
||||||
|
{ 51.6851f, -47.2838f, -43.6968f, 59.5307f },
|
||||||
|
{ 56.1380f, -31.7302f, -48.1577f, 45.7969f },
|
||||||
|
{ 60.2200f, -13.3339f, -52.2488f, 29.9893f },
|
||||||
|
{ 62.3450f, 7.8942f, -54.3778f, 11.2714f },
|
||||||
|
{ 60.4416f, 29.4505f, -52.4809f, -10.1523f },
|
||||||
|
{ 54.6617f, 47.9417f, -46.7062f, -31.5238f },
|
||||||
|
{ 47.9727f, 62.6966f, -40.0016f, -49.6097f },
|
||||||
|
{ 42.6961f, 74.9496f, -34.7083f, -64.0428f },
|
||||||
|
{ 39.3129f, 85.8690f, -31.3169f, -76.1142f },
|
||||||
|
{ 37.4353f, 96.1338f, -29.4363f, -86.9425f },
|
||||||
|
{ 36.5277f, 106.0939f, -28.5279f, -97.1639f },
|
||||||
|
{ 36.1555f, 115.9233f, -28.1555f, -107.1046f },
|
||||||
|
{ 36.0331f, 125.7043f, -28.0332f, -116.9264f },
|
||||||
|
{ 36.0042f, 135.4714f, -28.0042f, -126.7049f },
|
||||||
|
{ 36.0002f, 145.2358f, -28.0002f, -136.4714f },
|
||||||
|
{ 36.0000f, 155.0000f, -28.0000f, -146.2358f },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Draw an individual solid rectangular block for 4-quadrant view with smooth subpixel anti-aliasing
|
||||||
|
inline void drawQuadBarBlock(uint8_t cell, uint8_t i, uint16_t color) {
|
||||||
|
int16_t ox = cell4_x[cell];
|
||||||
|
int16_t oy = cell4_y[cell];
|
||||||
|
int16_t minX = pgm_read_word(&quadBlockMinX[i]);
|
||||||
|
int16_t maxX = pgm_read_word(&quadBlockMaxX[i]);
|
||||||
|
int16_t minY = pgm_read_word(&quadBlockMinY[i]);
|
||||||
|
int16_t maxY = pgm_read_word(&quadBlockMaxY[i]);
|
||||||
|
|
||||||
|
float nx[4], ny[4], c[4];
|
||||||
|
for (uint8_t k = 0; k < 4; k++) {
|
||||||
|
nx[k] = pgm_read_float(&quadBlockNx[i][k]);
|
||||||
|
ny[k] = pgm_read_float(&quadBlockNy[i][k]);
|
||||||
|
c[k] = pgm_read_float(&quadBlockC[i][k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
tft.startWrite();
|
||||||
|
for (int16_t y = minY; y <= maxY; y++) {
|
||||||
|
float py = (float)y + 0.5f;
|
||||||
|
int16_t sy = oy + y;
|
||||||
|
for (int16_t x = minX; x <= maxX; x++) {
|
||||||
|
float px = (float)x + 0.5f;
|
||||||
|
float min_d = 999.0f;
|
||||||
|
for (uint8_t k = 0; k < 4; k++) {
|
||||||
|
float d = px * nx[k] + py * ny[k] + c[k];
|
||||||
|
if (d < min_d) min_d = d;
|
||||||
|
}
|
||||||
|
if (min_d <= -0.5f) continue;
|
||||||
|
int16_t sx = ox + x;
|
||||||
|
if (min_d >= 0.5f) {
|
||||||
|
tft.drawPixel(sx, sy, color);
|
||||||
|
} else {
|
||||||
|
uint8_t alpha = (uint8_t)((min_d + 0.5f) * 255.0f);
|
||||||
|
tft.drawPixel(sx, sy, color, alpha, TFT_BLACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tft.endWrite();
|
||||||
|
}
|
||||||
|
|
||||||
/* ####################################
|
/* ####################################
|
||||||
draw digital numeric meter 160x80 px
|
draw digital numeric meter 160x80 px
|
||||||
####################################
|
####################################
|
||||||
|
|
@ -57,6 +314,7 @@ void numericMeter(uint8_t cell, uint8_t pid) {
|
||||||
tft.drawRect(x, y, w, screenHeight, TFT_GREY);
|
tft.drawRect(x, y, w, screenHeight, TFT_GREY);
|
||||||
tft.fillRect(x + 2, y + 2, w - 5, h - 5, TFT_BLACK);
|
tft.fillRect(x + 2, y + 2, w - 5, h - 5, TFT_BLACK);
|
||||||
tft.fillRectVGradient(x + 2, y + 2, w - 5, h * 0.33, TFT_BLUE, 0x0011);
|
tft.fillRectVGradient(x + 2, y + 2, w - 5, h * 0.33, TFT_BLUE, 0x0011);
|
||||||
|
drawPidIcon(x + 4, y + 2, pidConfig[pid][2]);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawCentreString(label, x + w / 2, y + 2, 4);
|
tft.drawCentreString(label, x + w / 2, y + 2, 4);
|
||||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||||
|
|
@ -149,9 +407,7 @@ void arcMeter(uint8_t cell, uint8_t pid) {
|
||||||
tft.drawCentreString(label.c_str(), x + 80, y + 58,
|
tft.drawCentreString(label.c_str(), x + 80, y + 58,
|
||||||
2); // Comment out to avoid font 4
|
2); // Comment out to avoid font 4
|
||||||
tft.setTextColor(TFT_GREEN);
|
tft.setTextColor(TFT_GREEN);
|
||||||
tft.setTextPadding(65);
|
tft.drawString("---", x + 10, y + 60, 2); // data
|
||||||
tft.drawRightString("---", x + 75, y + 60, 2); // data
|
|
||||||
tft.setTextPadding(0);
|
|
||||||
// draw arc animation
|
// draw arc animation
|
||||||
for (int angle = 135; angle < 225; angle++) {
|
for (int angle = 135; angle < 225; angle++) {
|
||||||
tft.drawSmoothArc(x + 80, y + 90, 80, 60, 134, angle, TFT_GREEN,
|
tft.drawSmoothArc(x + 80, y + 90, 80, 60, 134, angle, TFT_GREEN,
|
||||||
|
|
@ -172,6 +428,17 @@ void plotArc(uint8_t cell, String label, float data, int warn, int min, int max,
|
||||||
int y = cell1_y[cell - 1];
|
int y = cell1_y[cell - 1];
|
||||||
|
|
||||||
String result = String(data, digit);
|
String result = String(data, digit);
|
||||||
|
switch (result.length()) {
|
||||||
|
case 2:
|
||||||
|
result = result + " ";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
result = result + " ";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
result = result + " ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (data < min)
|
if (data < min)
|
||||||
data = min;
|
data = min;
|
||||||
|
|
@ -185,9 +452,7 @@ void plotArc(uint8_t cell, String label, float data, int warn, int min, int max,
|
||||||
else // no warn
|
else // no warn
|
||||||
arcColor = TFT_GREEN; // gren font green arc
|
arcColor = TFT_GREEN; // gren font green arc
|
||||||
tft.setTextColor(arcColor, TFT_BLACK);
|
tft.setTextColor(arcColor, TFT_BLACK);
|
||||||
tft.setTextPadding(65);
|
tft.drawString(result.c_str(), x + 10, y + 60, 2); // data
|
||||||
tft.drawRightString(result.c_str(), x + 75, y + 60, 2); // data
|
|
||||||
tft.setTextPadding(0);
|
|
||||||
int angle = map(data, min, max, 135, 225);
|
int angle = map(data, min, max, 135, 225);
|
||||||
if (data >= old_data[pidIndex]) // new data > old data -> draw only green
|
if (data >= old_data[pidIndex]) // new data > old data -> draw only green
|
||||||
// arc
|
// arc
|
||||||
|
|
@ -367,6 +632,45 @@ int get7SegWidth(const char *str, uint8_t dW, uint8_t t) {
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw blue header background for a 160x120 quadrant (25px height) with lateral and vertical smooth fade
|
||||||
|
void drawQuadHeaderGradient(uint8_t cell) {
|
||||||
|
int16_t ox = cell4_x[cell];
|
||||||
|
int16_t oy = cell4_y[cell];
|
||||||
|
uint16_t lineBuf[160];
|
||||||
|
const float fade_w_left = 12.0f;
|
||||||
|
const float fade_w_right = 12.0f;
|
||||||
|
const float x_right_start = 160.0f - fade_w_right;
|
||||||
|
|
||||||
|
tft.startWrite();
|
||||||
|
tft.setAddrWindow(ox, oy, 160, 25);
|
||||||
|
for (int16_t y = 0; y < 25; y++) {
|
||||||
|
float vy;
|
||||||
|
if (y < 14) {
|
||||||
|
vy = 1.0f;
|
||||||
|
} else {
|
||||||
|
float t = (24.0f - (float)y) / 10.0f;
|
||||||
|
vy = t * t * (3.0f - 2.0f * t);
|
||||||
|
}
|
||||||
|
for (int16_t x = 0; x < 160; x++) {
|
||||||
|
float hx = 1.0f;
|
||||||
|
if (x < (int16_t)fade_w_left) {
|
||||||
|
float t = (float)x / fade_w_left;
|
||||||
|
hx = t * t * (3.0f - 2.0f * t);
|
||||||
|
} else if (x > (int16_t)x_right_start) {
|
||||||
|
float t = (159.0f - (float)x) / fade_w_right;
|
||||||
|
if (t < 0.0f) t = 0.0f;
|
||||||
|
hx = t * t * (3.0f - 2.0f * t);
|
||||||
|
}
|
||||||
|
float b = vy * hx;
|
||||||
|
uint8_t g = (uint8_t)(140.0f * b);
|
||||||
|
uint8_t bl = (uint8_t)(255.0f * b);
|
||||||
|
lineBuf[x] = tft.color565(0, g, bl);
|
||||||
|
}
|
||||||
|
tft.pushPixels(lineBuf, 160);
|
||||||
|
}
|
||||||
|
tft.endWrite();
|
||||||
|
}
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
void plotNumeric4(uint8_t cell, float data, int warn, bool digit, String unit);
|
void plotNumeric4(uint8_t cell, float data, int warn, bool digit, String unit);
|
||||||
void plotArc4(uint8_t cell, float data, int warn, int min, int max, bool digit,
|
void plotArc4(uint8_t cell, float data, int warn, int min, int max, bool digit,
|
||||||
|
|
@ -381,25 +685,21 @@ void numericMeter4(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
||||||
int x = cell4_x[cell];
|
int x = cell4_x[cell];
|
||||||
int y = cell4_y[cell];
|
int y = cell4_y[cell];
|
||||||
String label = pidConfig[pid][0];
|
String label = pidConfig[pid][0];
|
||||||
String unit = pidConfig[pid][1];
|
|
||||||
if (unit == "volt")
|
|
||||||
unit = "V";
|
|
||||||
|
|
||||||
if (redrawHeader) {
|
if (redrawHeader) {
|
||||||
tft.drawRect(x, y, w, h, TFT_DARKGREY);
|
drawQuadHeaderGradient(cell);
|
||||||
tft.fillRectVGradient(x + 1, y + 1, w - 2, 24, TFT_BLUE, 0x0011);
|
drawPidIcon(x + 3, y + 1, pidConfig[pid][2]);
|
||||||
String headerText = label + " [" + unit + "]";
|
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawCentreString(headerText.c_str(), x + w / 2, y + 4, 2);
|
tft.drawCentreString(label.c_str(), x + w / 2, y + 4, 2);
|
||||||
}
|
}
|
||||||
// Clear only the body below the header to avoid any header flickering
|
// Clear only the body below the header to avoid any header flickering
|
||||||
tft.fillRect(x + 1, y + 25, w - 2, h - 26, TFT_BLACK);
|
tft.fillRect(x, y + 25, 160, 95, TFT_BLACK);
|
||||||
|
|
||||||
int warn = warningValue[pid].toInt();
|
|
||||||
bool digit = pidConfig[pid][7].toInt();
|
|
||||||
|
|
||||||
if (last_valid_data[cell] != -999) {
|
if (last_valid_data[cell] != -999) {
|
||||||
old_data[cell] = -999;
|
old_data[cell] = -999;
|
||||||
|
String unit = pidConfig[pid][1];
|
||||||
|
bool digit = pidConfig[pid][7].toInt();
|
||||||
|
int warn = warningValue[pid].toInt();
|
||||||
plotNumeric4(cell, last_valid_data[cell], warn, digit, unit);
|
plotNumeric4(cell, last_valid_data[cell], warn, digit, unit);
|
||||||
} else {
|
} else {
|
||||||
// Initial placeholder: right-aligned DSEG7 44pt number
|
// Initial placeholder: right-aligned DSEG7 44pt number
|
||||||
|
|
@ -431,49 +731,46 @@ void plotNumeric4(uint8_t cell, float data, int warn, bool digit, String unit) {
|
||||||
old_data[cell] = data;
|
old_data[cell] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4-quadrant Arc Meter (160x120 px) - Spanish label header with [unit], Lowered
|
// 4-quadrant Exponential Segmented Block Meter (160x120 px) - identical to full screen style
|
||||||
// Arc & Font 4 Value
|
|
||||||
void arcMeter4(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
void arcMeter4(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
||||||
int w = 160;
|
|
||||||
int h = 120;
|
|
||||||
int x = cell4_x[cell];
|
int x = cell4_x[cell];
|
||||||
int y = cell4_y[cell];
|
int y = cell4_y[cell];
|
||||||
String label = pidConfig[pid][0];
|
String label = pidConfig[pid][0];
|
||||||
String unit = pidConfig[pid][1];
|
|
||||||
if (unit == "volt")
|
|
||||||
unit = "V";
|
|
||||||
|
|
||||||
if (redrawHeader) {
|
if (redrawHeader) {
|
||||||
tft.drawRect(x, y, w, h, TFT_DARKGREY);
|
drawQuadHeaderGradient(cell);
|
||||||
tft.fillRectVGradient(x + 1, y + 1, w - 2, 24, TFT_BLUE, 0x0011);
|
drawPidIcon(x + 3, y + 1, pidConfig[pid][2]);
|
||||||
String headerText = label + " [" + unit + "]";
|
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawCentreString(headerText.c_str(), x + 80, y + 4, 2);
|
tft.drawCentreString(label.c_str(), x + 80, y + 4, 2);
|
||||||
|
}
|
||||||
|
// Clear only the body below the header
|
||||||
|
tft.fillRect(x, y + 25, 160, 95, TFT_BLACK);
|
||||||
|
tft.drawFastVLine(159, 0, 240, 0x2104);
|
||||||
|
tft.drawFastHLine(0, 119, 320, 0x2104);
|
||||||
|
|
||||||
|
// Initialize all 20 blocks in DARKGREY
|
||||||
|
for (uint8_t i = 0; i < NUM_BAR_BLOCKS; i++) {
|
||||||
|
drawQuadBarBlock(cell, i, TFT_DARKGREY);
|
||||||
}
|
}
|
||||||
// Clear only the body below the header to avoid any header flickering
|
|
||||||
tft.fillRect(x + 1, y + 25, w - 2, h - 26, TFT_BLACK);
|
|
||||||
|
|
||||||
int min = pidConfig[pid][4].toInt();
|
int min = pidConfig[pid][4].toInt();
|
||||||
int max = pidConfig[pid][5].toInt();
|
int max = pidConfig[pid][5].toInt();
|
||||||
bool digit = pidConfig[pid][7].toInt();
|
bool digit = pidConfig[pid][7].toInt();
|
||||||
int warn = warningValue[pid].toInt();
|
int warn = warningValue[pid].toInt();
|
||||||
|
String unit = pidConfig[pid][1];
|
||||||
// Lowered smooth arc track (Center Y = y + 96, R = 66, IR = 54, thickness
|
|
||||||
// 13px, sweep 130 deg: 115 to 245)
|
|
||||||
tft.drawSmoothArc(x + 80, y + 96, 66, 54, 115, 245, TFT_DARKGREY, TFT_BLACK,
|
|
||||||
false);
|
|
||||||
|
|
||||||
if (last_valid_data[cell] != -999) {
|
if (last_valid_data[cell] != -999) {
|
||||||
old_data[cell] = -999;
|
old_data[cell] = -999;
|
||||||
plotArc4(cell, last_valid_data[cell], warn, min, max, digit, unit);
|
plotArc4(cell, last_valid_data[cell], warn, min, max, digit, unit);
|
||||||
} else {
|
} else {
|
||||||
// Value placeholder using DSEG7 Modern 24pt smooth font
|
// Value placeholder using DSEG7 Modern 44pt smooth font
|
||||||
tft.loadFont(DSEG7_Modern_BoldItalic_24);
|
tft.loadFont(DSEG7_Modern_BoldItalic_44);
|
||||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||||
tft.setTextPadding(86);
|
tft.setTextPadding(115);
|
||||||
tft.drawRightString("---", x + 116, y + 86, 1);
|
tft.drawRightString("---", x + 152, y + 70, 1);
|
||||||
tft.setTextPadding(0);
|
tft.setTextPadding(0);
|
||||||
tft.unloadFont();
|
tft.unloadFont();
|
||||||
|
old_data[cell] = -999;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -481,8 +778,6 @@ void plotArc4(uint8_t cell, float data, int warn, int min, int max, bool digit,
|
||||||
String unit) {
|
String unit) {
|
||||||
if (data == old_data[cell])
|
if (data == old_data[cell])
|
||||||
return;
|
return;
|
||||||
int w = 160;
|
|
||||||
int h = 120;
|
|
||||||
int x = cell4_x[cell];
|
int x = cell4_x[cell];
|
||||||
int y = cell4_y[cell];
|
int y = cell4_y[cell];
|
||||||
if (data < min)
|
if (data < min)
|
||||||
|
|
@ -490,28 +785,87 @@ void plotArc4(uint8_t cell, float data, int warn, int min, int max, bool digit,
|
||||||
if (data > max)
|
if (data > max)
|
||||||
data = max;
|
data = max;
|
||||||
bool isWarn = (warn > 0 && data >= warn);
|
bool isWarn = (warn > 0 && data >= warn);
|
||||||
uint16_t arcCol = isWarn ? TFT_RED : TFT_GREEN;
|
uint16_t col = isWarn ? TFT_RED : TFT_GREEN;
|
||||||
|
|
||||||
int angle = map(data, min, max, 115, 245);
|
|
||||||
if (angle > 115) {
|
|
||||||
tft.drawSmoothArc(x + 80, y + 96, 66, 54, 115, angle, arcCol, TFT_BLACK,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
if (angle < 245) {
|
|
||||||
tft.drawSmoothArc(x + 80, y + 96, 66, 54, (angle > 115 ? angle + 1 : 115),
|
|
||||||
245, TFT_DARKGREY, TFT_BLACK, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
String numStr = String(data, digit);
|
String numStr = String(data, digit);
|
||||||
tft.loadFont(DSEG7_Modern_BoldItalic_24);
|
|
||||||
tft.setTextColor(arcCol, TFT_BLACK);
|
int newBlocks = map(data, min, max, 0, NUM_BAR_BLOCKS);
|
||||||
tft.setTextPadding(86);
|
if (newBlocks < 0)
|
||||||
tft.drawRightString(numStr.c_str(), x + 116, y + 86, 1);
|
newBlocks = 0;
|
||||||
|
if (newBlocks > NUM_BAR_BLOCKS)
|
||||||
|
newBlocks = NUM_BAR_BLOCKS;
|
||||||
|
|
||||||
|
int oldBlocks = (old_data[cell] < min) ? 0 : map(old_data[cell], min, max, 0, NUM_BAR_BLOCKS);
|
||||||
|
if (oldBlocks < 0)
|
||||||
|
oldBlocks = 0;
|
||||||
|
if (oldBlocks > NUM_BAR_BLOCKS)
|
||||||
|
oldBlocks = NUM_BAR_BLOCKS;
|
||||||
|
|
||||||
|
bool wasWarn = (warn > 0 && old_data[cell] >= warn);
|
||||||
|
if (isWarn != wasWarn || old_data[cell] < min) {
|
||||||
|
for (uint8_t i = 0; i < newBlocks; i++) {
|
||||||
|
drawQuadBarBlock(cell, i, col);
|
||||||
|
}
|
||||||
|
for (uint8_t i = newBlocks; i < NUM_BAR_BLOCKS; i++) {
|
||||||
|
drawQuadBarBlock(cell, i, TFT_DARKGREY);
|
||||||
|
}
|
||||||
|
} else if (newBlocks > oldBlocks) {
|
||||||
|
for (uint8_t i = oldBlocks; i < newBlocks; i++) {
|
||||||
|
drawQuadBarBlock(cell, i, col);
|
||||||
|
}
|
||||||
|
} else if (newBlocks < oldBlocks) {
|
||||||
|
for (uint8_t i = newBlocks; i < oldBlocks; i++) {
|
||||||
|
drawQuadBarBlock(cell, i, TFT_DARKGREY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tft.loadFont(DSEG7_Modern_BoldItalic_44);
|
||||||
|
tft.setTextColor(col, TFT_BLACK);
|
||||||
|
tft.setTextPadding(115);
|
||||||
|
tft.drawRightString(numStr.c_str(), x + 152, y + 70, 1);
|
||||||
tft.setTextPadding(0);
|
tft.setTextPadding(0);
|
||||||
tft.unloadFont();
|
tft.unloadFont();
|
||||||
old_data[cell] = data;
|
old_data[cell] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw blue header background with rich saturated body (top 30px full brightness)
|
||||||
|
// and compact lateral fades (16px), extended to 51px height without overlapping the original vumetro
|
||||||
|
void drawHeaderGradient() {
|
||||||
|
uint16_t lineBuf[320];
|
||||||
|
const float fade_w_left = 16.0f;
|
||||||
|
const float fade_w_right = 16.0f;
|
||||||
|
const float x_right_start = 320.0f - fade_w_right;
|
||||||
|
|
||||||
|
tft.startWrite();
|
||||||
|
tft.setAddrWindow(0, 0, 320, 51);
|
||||||
|
for (int16_t y = 0; y < 51; y++) {
|
||||||
|
float vy;
|
||||||
|
if (y < 30) {
|
||||||
|
vy = 1.0f;
|
||||||
|
} else {
|
||||||
|
float t = (50.0f - (float)y) / 20.0f;
|
||||||
|
vy = t * t * (3.0f - 2.0f * t);
|
||||||
|
}
|
||||||
|
for (int16_t x = 0; x < 320; x++) {
|
||||||
|
float hx = 1.0f;
|
||||||
|
if (x < (int16_t)fade_w_left) {
|
||||||
|
float t = (float)x / fade_w_left;
|
||||||
|
hx = t * t * (3.0f - 2.0f * t);
|
||||||
|
} else if (x > (int16_t)x_right_start) {
|
||||||
|
float t = (319.0f - (float)x) / fade_w_right;
|
||||||
|
if (t < 0.0f) t = 0.0f;
|
||||||
|
hx = t * t * (3.0f - 2.0f * t);
|
||||||
|
}
|
||||||
|
float b = vy * hx;
|
||||||
|
uint8_t g = (uint8_t)(140.0f * b);
|
||||||
|
uint8_t bl = (uint8_t)(255.0f * b);
|
||||||
|
lineBuf[x] = tft.color565(0, g, bl);
|
||||||
|
}
|
||||||
|
tft.pushPixels(lineBuf, 320);
|
||||||
|
}
|
||||||
|
tft.endWrite();
|
||||||
|
}
|
||||||
|
|
||||||
void fullScreenMeter(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
void fullScreenMeter(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
||||||
fullScreenCell = cell;
|
fullScreenCell = cell;
|
||||||
String label = pidConfig[pid][0];
|
String label = pidConfig[pid][0];
|
||||||
|
|
@ -520,14 +874,13 @@ void fullScreenMeter(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
||||||
unit = "V";
|
unit = "V";
|
||||||
|
|
||||||
if (redrawHeader) {
|
if (redrawHeader) {
|
||||||
// Blue gradient header with unit in brackets only
|
drawHeaderGradient();
|
||||||
tft.fillRectVGradient(0, 0, 320, 38, TFT_BLUE, 0x0011);
|
drawPidIconHeader(10, 4, pidConfig[pid][2]);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
String headerText = label + " [" + unit + "]";
|
tft.drawCentreString(label.c_str(), 175, 12, 4);
|
||||||
tft.drawCentreString(headerText.c_str(), 160, 8, 4);
|
|
||||||
}
|
}
|
||||||
// Clear only below header
|
// Clear only below header
|
||||||
tft.fillRect(0, 38, 320, 202, TFT_BLACK);
|
tft.fillRect(0, 51, 320, 189, TFT_BLACK);
|
||||||
|
|
||||||
int min = pidConfig[pid][4].toInt();
|
int min = pidConfig[pid][4].toInt();
|
||||||
int max = pidConfig[pid][5].toInt();
|
int max = pidConfig[pid][5].toInt();
|
||||||
|
|
@ -539,24 +892,24 @@ void fullScreenMeter(uint8_t cell, uint8_t pid, bool redrawHeader = true) {
|
||||||
plotFullScreen(cell, last_valid_data[cell], warn, min, max, digit, unit);
|
plotFullScreen(cell, last_valid_data[cell], warn, min, max, digit, unit);
|
||||||
} else {
|
} else {
|
||||||
if (!cellIsNumeric[cell]) {
|
if (!cellIsNumeric[cell]) {
|
||||||
// Arc mode full screen
|
// Exponential segmented block mode full screen (18 discrete blocks, 3mm x 5mm, 1mm gap)
|
||||||
// Large full screen arc (Center: 160, 195, R: 130, IR: 108, thickness 23px,
|
for (uint8_t i = 0; i < NUM_BAR_BLOCKS; i++) {
|
||||||
// sweep 130 deg: 115 to 245)
|
drawBarBlock(i, TFT_DARKGREY);
|
||||||
tft.drawSmoothArc(160, 195, 130, 108, 115, 245, TFT_DARKGREY, TFT_BLACK,
|
}
|
||||||
false);
|
|
||||||
|
|
||||||
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
||||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||||
tft.setTextPadding(265);
|
tft.setTextPadding(240);
|
||||||
tft.drawRightString("---", 260, 155, 1);
|
tft.drawRightString("---", 312, 148, 1);
|
||||||
tft.setTextPadding(0);
|
tft.setTextPadding(0);
|
||||||
tft.unloadFont();
|
tft.unloadFont();
|
||||||
|
old_data[cell] = -999;
|
||||||
} else {
|
} else {
|
||||||
// Digital numeric mode full screen with DSEG7 Smooth Font (Anti-Aliased)
|
// Digital numeric mode full screen with DSEG7 Smooth Font (Anti-Aliased)
|
||||||
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
||||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||||
tft.setTextPadding(300);
|
tft.setTextPadding(295);
|
||||||
tft.drawRightString("---", 305, 98, 1);
|
tft.drawRightString("---", 295, 98, 1);
|
||||||
tft.setTextPadding(0);
|
tft.setTextPadding(0);
|
||||||
tft.unloadFont();
|
tft.unloadFont();
|
||||||
}
|
}
|
||||||
|
|
@ -577,28 +930,49 @@ void plotFullScreen(uint8_t cell, float data, int warn, int min, int max,
|
||||||
String numStr = String(data, digit);
|
String numStr = String(data, digit);
|
||||||
|
|
||||||
if (!cellIsNumeric[cell]) {
|
if (!cellIsNumeric[cell]) {
|
||||||
int angle = map(data, min, max, 115, 245);
|
int newBlocks = map(data, min, max, 0, NUM_BAR_BLOCKS);
|
||||||
if (angle > 115) {
|
if (newBlocks < 0)
|
||||||
tft.drawSmoothArc(160, 195, 130, 108, 115, angle, col, TFT_BLACK, false);
|
newBlocks = 0;
|
||||||
|
if (newBlocks > NUM_BAR_BLOCKS)
|
||||||
|
newBlocks = NUM_BAR_BLOCKS;
|
||||||
|
|
||||||
|
int oldBlocks = (old_data[cell] < min) ? 0 : map(old_data[cell], min, max, 0, NUM_BAR_BLOCKS);
|
||||||
|
if (oldBlocks < 0)
|
||||||
|
oldBlocks = 0;
|
||||||
|
if (oldBlocks > NUM_BAR_BLOCKS)
|
||||||
|
oldBlocks = NUM_BAR_BLOCKS;
|
||||||
|
|
||||||
|
bool wasWarn = (warn > 0 && old_data[cell] >= warn);
|
||||||
|
if (isWarn != wasWarn || old_data[cell] < min) {
|
||||||
|
for (uint8_t i = 0; i < newBlocks; i++) {
|
||||||
|
drawBarBlock(i, col);
|
||||||
|
}
|
||||||
|
for (uint8_t i = newBlocks; i < NUM_BAR_BLOCKS; i++) {
|
||||||
|
drawBarBlock(i, TFT_DARKGREY);
|
||||||
|
}
|
||||||
|
} else if (newBlocks > oldBlocks) {
|
||||||
|
for (uint8_t i = oldBlocks; i < newBlocks; i++) {
|
||||||
|
drawBarBlock(i, col);
|
||||||
|
}
|
||||||
|
} else if (newBlocks < oldBlocks) {
|
||||||
|
for (uint8_t i = newBlocks; i < oldBlocks; i++) {
|
||||||
|
drawBarBlock(i, TFT_DARKGREY);
|
||||||
}
|
}
|
||||||
if (angle < 245) {
|
|
||||||
tft.drawSmoothArc(160, 195, 130, 108, (angle > 115 ? angle + 1 : 115),
|
|
||||||
245, TFT_DARKGREY, TFT_BLACK, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Value below the arc using DSEG7 Modern smooth font
|
// Value bottom-right using DSEG7 Modern smooth font
|
||||||
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
||||||
tft.setTextColor(col, TFT_BLACK);
|
tft.setTextColor(col, TFT_BLACK);
|
||||||
tft.setTextPadding(265);
|
tft.setTextPadding(240);
|
||||||
tft.drawRightString(numStr.c_str(), 260, 155, 1);
|
tft.drawRightString(numStr.c_str(), 312, 148, 1);
|
||||||
tft.setTextPadding(0);
|
tft.setTextPadding(0);
|
||||||
tft.unloadFont();
|
tft.unloadFont();
|
||||||
} else {
|
} else {
|
||||||
// Digital numeric mode full screen with DSEG7 Smooth Font (Anti-Aliased)
|
// Digital numeric mode full screen with DSEG7 Smooth Font (Anti-Aliased)
|
||||||
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
tft.loadFont(DSEG7_Modern_BoldItalic_80);
|
||||||
tft.setTextColor(col, TFT_BLACK);
|
tft.setTextColor(col, TFT_BLACK);
|
||||||
tft.setTextPadding(300);
|
tft.setTextPadding(295);
|
||||||
tft.drawRightString(numStr.c_str(), 305, 98, 1);
|
tft.drawRightString(numStr.c_str(), 295, 98, 1);
|
||||||
tft.setTextPadding(0);
|
tft.setTextPadding(0);
|
||||||
tft.unloadFont();
|
tft.unloadFont();
|
||||||
}
|
}
|
||||||
|
|
@ -629,6 +1003,8 @@ void initScreen() {
|
||||||
arcMeter4(c, pid);
|
arcMeter4(c, pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tft.drawFastVLine(159, 0, 240, 0x2104);
|
||||||
|
tft.drawFastHLine(0, 119, 320, 0x2104);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*-------------------------------*/
|
/*-------------------------------*/
|
||||||
|
|
|
||||||
|
|
@ -83,9 +83,9 @@ warn = default warning value
|
||||||
*/
|
*/
|
||||||
const String pidConfig[4][9] = {
|
const String pidConfig[4][9] = {
|
||||||
//[pid][data]
|
//[pid][data]
|
||||||
{ "Refrigerante", "`C", "0105", "1", "0", "120", "2", "0", "100" }, //0 = Refrigerante (0105)
|
{ "Temperatura", "`C", "0105", "1", "0", "120", "2", "0", "100" }, //0 = Temperatura (0105)
|
||||||
{ "Revoluciones", "rpm", "010C", "3", "0", "6000", "0", "0", "5000" }, //1 = Revoluciones (010C)
|
{ "RPM", "rpm", "010C", "3", "0", "6000", "0", "0", "5000" }, //1 = RPM (010C)
|
||||||
{ "Voltaje", "V", "ATRV", "8", "0", "16", "1", "1", "15" }, //2 = Voltaje Batería (ATRV)
|
{ "Voltaje", "V", "0142", "4", "0", "16", "1", "1", "15" }, //2 = Voltaje (0142)
|
||||||
{ "Velocidad", "km/h", "010D", "7", "0", "180", "0", "0", "130" } //3 = Velocidad (010D)
|
{ "Velocidad", "km/h", "010D", "7", "0", "180", "0", "0", "130" } //3 = Velocidad (010D)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue