buttons and colors
This commit is contained in:
parent
89a2526a9d
commit
44aa60534c
|
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef CUSTOM_COLORS_H_
|
||||||
|
#define CUSTOM_COLORS_H_
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
|
||||||
|
// COLORS https://rgbcolorpicker.com/565
|
||||||
|
|
||||||
|
uint16_t redColor = 0xc8a2;
|
||||||
|
uint16_t redColorLight = 0xd8c4;
|
||||||
|
uint16_t redColorDark = 0xa082;
|
||||||
|
|
||||||
|
uint16_t greyColor = 0x7BEF;
|
||||||
|
uint16_t greyColorLight = 0xBDF7;
|
||||||
|
uint16_t greyColorDark = 0x39E7;
|
||||||
|
|
||||||
|
uint16_t greenColor = 0x1482;
|
||||||
|
uint16_t greenColorLight = 0x1d63;
|
||||||
|
uint16_t greenColorDark = 0x0b22;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include <logger.h>
|
#include <logger.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include "custom_characters.h"
|
#include "custom_characters.h"
|
||||||
|
#include "custom_colors.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "boards_pinout.h"
|
#include "boards_pinout.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
@ -13,7 +14,7 @@
|
||||||
TFT_eSPI tft = TFT_eSPI();
|
TFT_eSPI tft = TFT_eSPI();
|
||||||
TFT_eSprite sprite = TFT_eSprite(&tft);
|
TFT_eSprite sprite = TFT_eSprite(&tft);
|
||||||
|
|
||||||
#define red 0xB061
|
|
||||||
int brightnessValues[6] = {70, 90, 120, 160, 200, 250};
|
int brightnessValues[6] = {70, 90, 120, 160, 200, 250};
|
||||||
int tftBrightness = 5;
|
int tftBrightness = 5;
|
||||||
unsigned short grays[13];
|
unsigned short grays[13];
|
||||||
|
|
@ -80,28 +81,73 @@ bool symbolAvailable = true;
|
||||||
|
|
||||||
extern logging::Logger logger;
|
extern logging::Logger logger;
|
||||||
|
|
||||||
|
void drawButton(int xPos, int yPos, int wide, int height, String buttonText, int color) {
|
||||||
|
uint16_t baseColor, lightColor, darkColor;
|
||||||
|
switch (color) {
|
||||||
|
case 0: // Grey Theme
|
||||||
|
baseColor = greyColor;
|
||||||
|
lightColor = greyColorLight;
|
||||||
|
darkColor = greyColorDark;
|
||||||
|
break;
|
||||||
|
case 1: // Green Theme
|
||||||
|
baseColor = greenColor;
|
||||||
|
lightColor = greenColorLight;
|
||||||
|
darkColor = greenColorDark;
|
||||||
|
break;
|
||||||
|
case 2: // Red Theme
|
||||||
|
baseColor = redColor;
|
||||||
|
lightColor = redColorLight;
|
||||||
|
darkColor = redColorDark;
|
||||||
|
break;
|
||||||
|
default: // Fallback color
|
||||||
|
baseColor = 0x0000; // Black
|
||||||
|
lightColor = 0xFFFF; // White
|
||||||
|
darkColor = 0x0000; // Black
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprite.fillRect(xPos, yPos, wide, height, baseColor); // Dibuja el fondo del botón
|
||||||
|
sprite.fillRect(xPos, yPos + height - 2, wide, 2, darkColor); // Línea inferior
|
||||||
|
sprite.fillRect(xPos, yPos, wide, 2, lightColor); // Línea superior
|
||||||
|
sprite.fillRect(xPos, yPos, 2, height, lightColor); // Línea izquierda
|
||||||
|
sprite.fillRect(xPos + wide - 2, yPos, 2, height, darkColor); // Línea derecha
|
||||||
|
|
||||||
|
sprite.setTextSize(2);
|
||||||
|
sprite.setTextColor(TFT_WHITE, baseColor);
|
||||||
|
|
||||||
|
// Calcula la posición del texto para que esté centrado
|
||||||
|
int textWidth = sprite.textWidth(buttonText); // Ancho del texto
|
||||||
|
int textHeight = 16; // Altura aproximada (depende de `setTextSize`)
|
||||||
|
int textX = xPos + (wide - textWidth) / 2; // Centrado horizontal
|
||||||
|
int textY = yPos + (height - textHeight) / 2; // Centrado vertical
|
||||||
|
|
||||||
|
sprite.drawString(buttonText, textX, textY);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(HAS_TFT) && (defined(TTGO_T_DECK_PLUS) || defined(TTGO_T_DECK_GPS))
|
#if defined(HAS_TFT) && (defined(TTGO_T_DECK_PLUS) || defined(TTGO_T_DECK_GPS))
|
||||||
void draw_T_DECK_Top(const String& header, const String& datetime, const String& location) {
|
void draw_T_DECK_Top(const String& header, const String& datetime, const String& location) {
|
||||||
sprite.fillSprite(TFT_BLACK);
|
sprite.fillSprite(TFT_BLACK);
|
||||||
sprite.fillRect(0, 0, 320, 38, red);
|
sprite.fillRect(0, 0, 320, 38, redColor);
|
||||||
sprite.setTextFont(0);
|
sprite.setTextFont(0);
|
||||||
sprite.setTextSize(bigSizeFont);
|
sprite.setTextSize(bigSizeFont);
|
||||||
sprite.setTextColor(TFT_WHITE, red);
|
sprite.setTextColor(TFT_WHITE, redColor);
|
||||||
sprite.drawString(currentBeacon->callsign, 3, 5);
|
sprite.drawString(currentBeacon->callsign, 3, 5);
|
||||||
|
|
||||||
sprite.setTextSize(smallSizeFont);
|
sprite.setTextSize(smallSizeFont);
|
||||||
sprite.setTextColor(TFT_WHITE, red);
|
sprite.setTextColor(TFT_WHITE, redColor);
|
||||||
String date = datetime.substring(0, datetime.indexOf(" "));
|
String date = datetime.substring(0, datetime.indexOf(" "));
|
||||||
sprite.drawString(date, 258, 5);
|
sprite.drawString(date, 258, 5);
|
||||||
String time = datetime.substring(datetime.indexOf(" ") + 3);
|
String time = datetime.substring(datetime.indexOf(" ") + 3);
|
||||||
sprite.drawString("UTC:" + time, 246, 15);
|
sprite.drawString("UTC:" + time, 246, 15);
|
||||||
|
|
||||||
sprite.fillRect(0, 38, 320, 2, TFT_ORANGE);
|
sprite.fillRect(0, 38, 320, 2, redColorDark);//TFT_ORANGE);
|
||||||
|
|
||||||
sprite.fillRect(0, 40, 320, 22, TFT_DARKGREY);
|
sprite.fillRect(0, 40, 320, 2, greyColorLight);
|
||||||
|
sprite.fillRect(0, 42, 320, 20, greyColor);
|
||||||
sprite.setTextSize(2);
|
sprite.setTextSize(2);
|
||||||
sprite.setTextColor(TFT_WHITE, TFT_DARKGREY);
|
sprite.setTextColor(TFT_WHITE, greyColor);
|
||||||
sprite.drawString(location, 8, 44);
|
sprite.drawString(location, 8, 44);
|
||||||
|
sprite.fillRect(0, 60, 320, 2, greyColorDark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_T_DECK_Body(const String& line1, const String& line2, const String& line3, const String& line4, const String& line5, const String& line6) {
|
void draw_T_DECK_Body(const String& line1, const String& line2, const String& line3, const String& line4, const String& line5, const String& line6) {
|
||||||
|
|
@ -112,6 +158,12 @@ void draw_T_DECK_Body(const String& line1, const String& line2, const String& li
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
sprite.drawString(*lines[i], 3, 70 + (i * 20));
|
sprite.drawString(*lines[i], 3, 70 + (i * 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//drawButton(125, 210, 80, 28, "Menu", 0);
|
||||||
|
|
||||||
|
drawButton(30, 210, 80, 28, "Send", 1);
|
||||||
|
drawButton(125, 210, 80, 28, "Menu", 0);
|
||||||
|
drawButton(210, 210, 95, 28, "Cancel", 2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -119,7 +171,7 @@ void draw_T_DECK_Body(const String& line1, const String& line2, const String& li
|
||||||
//sprite.fillRect(0, 20, 320, 2, color2); // linea bajo techo
|
//sprite.fillRect(0, 20, 320, 2, color2); // linea bajo techo
|
||||||
//sprite.fillRect(0, 202, 320, 2, 0xBC81); // linea abajo amarilla
|
//sprite.fillRect(0, 202, 320, 2, 0xBC81); // linea abajo amarilla
|
||||||
|
|
||||||
//sprite.fillSmoothRoundRect( 0, 218, 320, 22 , 2, red, TFT_BLACK); // piso
|
//sprite.fillSmoothRoundRect( 0, 218, 320, 22 , 2, redColor, TFT_BLACK); // piso
|
||||||
|
|
||||||
//sprite.fillSmoothRoundRect( 4, 2, 56, 14 , 2, grays[6], grays[9]); // cuadrado gris izquierda arriba
|
//sprite.fillSmoothRoundRect( 4, 2, 56, 14 , 2, grays[6], grays[9]); // cuadrado gris izquierda arriba
|
||||||
//sprite.fillSmoothRoundRect( 2, 2, 16, 14 , 2, TFT_BLUE, grays[9]); // cuadrado rojo izquierda arriba
|
//sprite.fillSmoothRoundRect( 2, 2, 16, 14 , 2, TFT_BLUE, grays[9]); // cuadrado rojo izquierda arriba
|
||||||
|
|
@ -280,10 +332,10 @@ void displayShow(const String& header, const String& line1, const String& line2,
|
||||||
#endif
|
#endif
|
||||||
#if defined(HELTEC_WIRELESS_TRACKER)
|
#if defined(HELTEC_WIRELESS_TRACKER)
|
||||||
sprite.fillSprite(TFT_BLACK);
|
sprite.fillSprite(TFT_BLACK);
|
||||||
sprite.fillRect(0, 0, 160, 19, red);
|
sprite.fillRect(0, 0, 160, 19, redColor);
|
||||||
sprite.setTextFont(0);
|
sprite.setTextFont(0);
|
||||||
sprite.setTextSize(bigSizeFont);
|
sprite.setTextSize(bigSizeFont);
|
||||||
sprite.setTextColor(TFT_WHITE, red);
|
sprite.setTextColor(TFT_WHITE, redColor);
|
||||||
sprite.drawString(header, 3, 3);
|
sprite.drawString(header, 3, 3);
|
||||||
|
|
||||||
const String* const lines[] = {&line1, &line2};
|
const String* const lines[] = {&line1, &line2};
|
||||||
|
|
@ -349,10 +401,10 @@ void displayShow(const String& header, const String& line1, const String& line2,
|
||||||
#endif
|
#endif
|
||||||
#if defined(HELTEC_WIRELESS_TRACKER)
|
#if defined(HELTEC_WIRELESS_TRACKER)
|
||||||
sprite.fillSprite(TFT_BLACK);
|
sprite.fillSprite(TFT_BLACK);
|
||||||
sprite.fillRect(0, 0, 160, 19, red);
|
sprite.fillRect(0, 0, 160, 19, redColor);
|
||||||
sprite.setTextFont(0);
|
sprite.setTextFont(0);
|
||||||
sprite.setTextSize(bigSizeFont);
|
sprite.setTextSize(bigSizeFont);
|
||||||
sprite.setTextColor(TFT_WHITE, red);
|
sprite.setTextColor(TFT_WHITE, redColor);
|
||||||
sprite.drawString(header, 3, 3);
|
sprite.drawString(header, 3, 3);
|
||||||
|
|
||||||
const String* const lines[] = {&line1, &line2, &line3, &line4, &line5};
|
const String* const lines[] = {&line1, &line2, &line3, &line4, &line5};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue