From 5d76771fabf64496ec860ea3a5ce50b437377759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 16 Aug 2023 22:07:22 +0200 Subject: [PATCH] Permanently Enable Canned Messages on T-Deck and Picomputer (#2728) * - Permanently Enable Canned Messages on T-Deck and Picomputer - picomputer has a really dark TFT; switch color to white for better UX. * well, you know... bullock... --- src/configuration.h | 3 +++ src/graphics/TFTDisplay.cpp | 4 ++-- src/modules/CannedMessageModule.cpp | 10 +++++----- src/modules/CannedMessageModule.h | 4 ++++ variants/picomputer-s3/variant.h | 5 +++++ variants/t-deck/variant.h | 1 + 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/configuration.h b/src/configuration.h index aa9064251..fb96430bc 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -147,6 +147,9 @@ along with this program. If not, see . #define GPS_THREAD_INTERVAL 100 #endif +// convert 24-bit color to 16-bit (56K) +#define COLOR565(r, g, b) (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)) + /* Step #1: offer chance for variant-specific defines */ #include "variant.h" diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index a9611d888..71ce35e82 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -4,9 +4,9 @@ #define TFT_BACKLIGHT_ON HIGH #endif -// convert 24-bit color to 16-bit (56K) -#define COLOR565(r, g, b) (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)) +#ifndef TFT_MESH #define TFT_MESH COLOR565(0x67, 0xEA, 0x94) +#endif #if defined(ST7735S) #include // Graphics and font library for ST7735 driver chip diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index e1267ba2a..1e605656f 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -63,10 +63,10 @@ CannedMessageModule *cannedMessageModule; CannedMessageModule::CannedMessageModule() : SinglePortModule("canned", meshtastic_PortNum_TEXT_MESSAGE_APP), concurrency::OSThread("CannedMessageModule") { - if (moduleConfig.canned_message.enabled) { + if (moduleConfig.canned_message.enabled || CANNED_MESSAGE_MODULE_ENABLE) { this->loadProtoForModule(); if ((this->splitConfiguredMessages() <= 0) && (cardkb_found.address != CARDKB_ADDR) && - (cardkb_found.address != TDECK_KB_ADDR) && !INPUTBROKER_MATRIX_TYPE) { + (cardkb_found.address != TDECK_KB_ADDR) && !INPUTBROKER_MATRIX_TYPE && !CANNED_MESSAGE_MODULE_ENABLE) { LOG_INFO("CannedMessageModule: No messages are configured. Module is disabled\n"); this->runState = CANNED_MESSAGE_RUN_STATE_DISABLED; disable(); @@ -237,8 +237,8 @@ void CannedMessageModule::sendText(NodeNum dest, const char *message, bool wantR int32_t CannedMessageModule::runOnce() { - if ((!moduleConfig.canned_message.enabled) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED) || - (this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE)) { + if (((!moduleConfig.canned_message.enabled) && !CANNED_MESSAGE_MODULE_ENABLE) || + (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED) || (this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE)) { return INT32_MAX; } // LOG_DEBUG("Check status\n"); @@ -454,7 +454,7 @@ const char *CannedMessageModule::getNodeName(NodeNum node) bool CannedMessageModule::shouldDraw() { - if (!moduleConfig.canned_message.enabled) { + if (!moduleConfig.canned_message.enabled && !CANNED_MESSAGE_MODULE_ENABLE) { return false; } return (currentMessageIndex != -1) || (this->runState != CANNED_MESSAGE_RUN_STATE_INACTIVE); diff --git a/src/modules/CannedMessageModule.h b/src/modules/CannedMessageModule.h index 4e9dadccf..98467215e 100644 --- a/src/modules/CannedMessageModule.h +++ b/src/modules/CannedMessageModule.h @@ -20,6 +20,10 @@ enum cannedMessageModuleRunState { */ #define CANNED_MESSAGE_MODULE_MESSAGES_SIZE 800 +#ifndef CANNED_MESSAGE_MODULE_ENABLE +#define CANNED_MESSAGE_MODULE_ENABLE 0 +#endif + class CannedMessageModule : public SinglePortModule, public Observable, private concurrency::OSThread { CallbackObserver inputObserver = diff --git a/variants/picomputer-s3/variant.h b/variants/picomputer-s3/variant.h index 197eb3da1..716f2779d 100644 --- a/variants/picomputer-s3/variant.h +++ b/variants/picomputer-s3/variant.h @@ -43,6 +43,11 @@ #define SCREEN_ROTATE #define SCREEN_TRANSITION_FRAMERATE 5 +// Picomputer gets a white on black display +#define TFT_MESH COLOR565(0xFF, 0xFF, 0xFF) + +#define CANNED_MESSAGE_MODULE_ENABLE 1 + #define INPUTBROKER_MATRIX_TYPE 1 #define KEYS_COLS \ diff --git a/variants/t-deck/variant.h b/variants/t-deck/variant.h index c00229ab9..2f4643fde 100644 --- a/variants/t-deck/variant.h +++ b/variants/t-deck/variant.h @@ -49,6 +49,7 @@ #define KB_POWERON 10 // must be set to HIGH #define KB_SLAVE_ADDRESS TDECK_KB_ADDR // 0x55 #define KB_BL_PIN 46 // not used for now +#define CANNED_MESSAGE_MODULE_ENABLE 1 // trackball #define HAS_TRACKBALL 1