mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-22 10:42:49 +00:00
Initial Chatter 2.0 fix for baseUI (#8615)
* Initial Chatter 2.0 fix for baseUI * trunk fix --------- Co-authored-by: Jason P <applewiz@mac.com>
This commit is contained in:
@@ -17,6 +17,12 @@ namespace graphics
|
|||||||
|
|
||||||
void determineResolution(int16_t screenheight, int16_t screenwidth)
|
void determineResolution(int16_t screenheight, int16_t screenwidth)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef FORCE_LOW_RES
|
||||||
|
isHighResolution = false;
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (screenwidth > 128) {
|
if (screenwidth > 128) {
|
||||||
isHighResolution = true;
|
isHighResolution = true;
|
||||||
}
|
}
|
||||||
@@ -24,11 +30,6 @@ void determineResolution(int16_t screenheight, int16_t screenwidth)
|
|||||||
if (screenwidth > 128 && screenheight <= 64) {
|
if (screenwidth > 128 && screenheight <= 64) {
|
||||||
isHighResolution = false;
|
isHighResolution = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case for Heltec Wireless Tracker v1.1
|
|
||||||
if (screenwidth == 160 && screenheight == 80) {
|
|
||||||
isHighResolution = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Shared External State ===
|
// === Shared External State ===
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include <Throttle.h>
|
#include <Throttle.h>
|
||||||
|
|
||||||
|
SerialKeyboard *globalSerialKeyboard = nullptr;
|
||||||
|
|
||||||
#ifdef INPUTBROKER_SERIAL_TYPE
|
#ifdef INPUTBROKER_SERIAL_TYPE
|
||||||
#define CANNED_MESSAGE_MODULE_ENABLE 1 // in case it's not set in the variant file
|
#define CANNED_MESSAGE_MODULE_ENABLE 1 // in case it's not set in the variant file
|
||||||
|
|
||||||
@@ -25,6 +27,8 @@ unsigned char KeyMap[3][4][10] = {{{'.', 'a', 'd', 'g', 'j', 'm', 'p', 't', 'w',
|
|||||||
SerialKeyboard::SerialKeyboard(const char *name) : concurrency::OSThread(name)
|
SerialKeyboard::SerialKeyboard(const char *name) : concurrency::OSThread(name)
|
||||||
{
|
{
|
||||||
this->_originName = name;
|
this->_originName = name;
|
||||||
|
|
||||||
|
globalSerialKeyboard = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerialKeyboard::erase()
|
void SerialKeyboard::erase()
|
||||||
@@ -85,9 +89,21 @@ int32_t SerialKeyboard::runOnce()
|
|||||||
e.source = this->_originName;
|
e.source = this->_originName;
|
||||||
// SELECT OR SEND OR CANCEL EVENT
|
// SELECT OR SEND OR CANCEL EVENT
|
||||||
if (!(shiftRegister2 & (1 << 3))) {
|
if (!(shiftRegister2 & (1 << 3))) {
|
||||||
e.inputEvent = INPUT_BROKER_UP;
|
if (shift > 0) {
|
||||||
|
e.inputEvent = INPUT_BROKER_ANYKEY; // REQUIRED
|
||||||
|
e.kbchar = 0x09; // TAB
|
||||||
|
shift = 0; // reset shift after TAB
|
||||||
|
} else {
|
||||||
|
e.inputEvent = INPUT_BROKER_LEFT;
|
||||||
|
}
|
||||||
} else if (!(shiftRegister2 & (1 << 2))) {
|
} else if (!(shiftRegister2 & (1 << 2))) {
|
||||||
e.inputEvent = INPUT_BROKER_RIGHT;
|
if (shift > 0) {
|
||||||
|
e.inputEvent = INPUT_BROKER_ANYKEY; // REQUIRED
|
||||||
|
e.kbchar = 0x09; // TAB
|
||||||
|
shift = 0; // reset shift after TAB
|
||||||
|
} else {
|
||||||
|
e.inputEvent = INPUT_BROKER_RIGHT;
|
||||||
|
}
|
||||||
e.kbchar = 0;
|
e.kbchar = 0;
|
||||||
} else if (!(shiftRegister2 & (1 << 1))) {
|
} else if (!(shiftRegister2 & (1 << 1))) {
|
||||||
e.inputEvent = INPUT_BROKER_SELECT;
|
e.inputEvent = INPUT_BROKER_SELECT;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ class SerialKeyboard : public Observable<const InputEvent *>, public concurrency
|
|||||||
public:
|
public:
|
||||||
explicit SerialKeyboard(const char *name);
|
explicit SerialKeyboard(const char *name);
|
||||||
|
|
||||||
|
uint8_t getShift() const { return shift; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
void erase();
|
void erase();
|
||||||
@@ -22,4 +24,6 @@ class SerialKeyboard : public Observable<const InputEvent *>, public concurrency
|
|||||||
int lastKeyPressed = 13;
|
int lastKeyPressed = 13;
|
||||||
int quickPress = 0;
|
int quickPress = 0;
|
||||||
unsigned long lastPressTime = 0;
|
unsigned long lastPressTime = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern SerialKeyboard *globalSerialKeyboard;
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "graphics/draw/NotificationRenderer.h"
|
#include "graphics/draw/NotificationRenderer.h"
|
||||||
#include "graphics/emotes.h"
|
#include "graphics/emotes.h"
|
||||||
#include "graphics/images.h"
|
#include "graphics/images.h"
|
||||||
|
#include "input/SerialKeyboard.h"
|
||||||
#include "main.h" // for cardkb_found
|
#include "main.h" // for cardkb_found
|
||||||
#include "mesh/generated/meshtastic/cannedmessages.pb.h"
|
#include "mesh/generated/meshtastic/cannedmessages.pb.h"
|
||||||
#include "modules/AdminModule.h"
|
#include "modules/AdminModule.h"
|
||||||
@@ -1848,7 +1849,88 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
display->drawString(x + display->getWidth() - display->getStringWidth(buffer), y + 0, buffer);
|
display->drawString(x + display->getWidth() - display->getStringWidth(buffer), y + 0, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Draw Free Text input with multi-emote support and proper line wrapping ---
|
#if INPUTBROKER_SERIAL_TYPE == 1
|
||||||
|
// Chatter Modifier key mode label (right side)
|
||||||
|
{
|
||||||
|
uint8_t mode = globalSerialKeyboard ? globalSerialKeyboard->getShift() : 0;
|
||||||
|
const char *label = (mode == 0) ? "a" : (mode == 1) ? "A" : "#";
|
||||||
|
|
||||||
|
display->setFont(FONT_SMALL);
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
|
const int16_t th = FONT_HEIGHT_SMALL;
|
||||||
|
const int16_t tw = display->getStringWidth(label);
|
||||||
|
const int16_t padX = 3;
|
||||||
|
const int16_t padY = 2;
|
||||||
|
const int16_t r = 3;
|
||||||
|
|
||||||
|
const int16_t bw = tw + padX * 2;
|
||||||
|
const int16_t bh = th + padY * 2;
|
||||||
|
|
||||||
|
const int16_t bx = x + display->getWidth() - bw - 2;
|
||||||
|
const int16_t by = y + display->getHeight() - bh - 2;
|
||||||
|
|
||||||
|
display->setColor(WHITE);
|
||||||
|
display->fillRect(bx + r, by, bw - r * 2, bh);
|
||||||
|
display->fillRect(bx, by + r, r, bh - r * 2);
|
||||||
|
display->fillRect(bx + bw - r, by + r, r, bh - r * 2);
|
||||||
|
display->fillCircle(bx + r, by + r, r);
|
||||||
|
display->fillCircle(bx + bw - r - 1, by + r, r);
|
||||||
|
display->fillCircle(bx + r, by + bh - r - 1, r);
|
||||||
|
display->fillCircle(bx + bw - r - 1, by + bh - r - 1, r);
|
||||||
|
|
||||||
|
display->setColor(BLACK);
|
||||||
|
display->drawString(bx + padX, by + padY, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
// LEFT-SIDE DESTINATION-HINT BOX (“Dest: Shift + ◄”)
|
||||||
|
{
|
||||||
|
display->setFont(FONT_SMALL);
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
|
const char *label = "Dest: Shift + ";
|
||||||
|
int16_t labelW = display->getStringWidth(label);
|
||||||
|
|
||||||
|
// triangle size visually matches glyph height, not full line height
|
||||||
|
const int triH = FONT_HEIGHT_SMALL - 3;
|
||||||
|
const int triW = triH * 0.7;
|
||||||
|
|
||||||
|
const int16_t padX = 3;
|
||||||
|
const int16_t padY = 2;
|
||||||
|
const int16_t r = 3;
|
||||||
|
|
||||||
|
const int16_t bw = labelW + triW + padX * 2 + 2;
|
||||||
|
const int16_t bh = FONT_HEIGHT_SMALL + padY * 2;
|
||||||
|
|
||||||
|
const int16_t bx = x + 2;
|
||||||
|
const int16_t by = y + display->getHeight() - bh - 2;
|
||||||
|
|
||||||
|
// Rounded white box
|
||||||
|
display->setColor(WHITE);
|
||||||
|
display->fillRect(bx + r, by, bw - (r * 2), bh);
|
||||||
|
display->fillRect(bx, by + r, r, bh - (r * 2));
|
||||||
|
display->fillRect(bx + bw - r, by + r, r, bh - (r * 2));
|
||||||
|
display->fillCircle(bx + r, by + r, r);
|
||||||
|
display->fillCircle(bx + bw - r - 1, by + r, r);
|
||||||
|
display->fillCircle(bx + r, by + bh - r - 1, r);
|
||||||
|
display->fillCircle(bx + bw - r - 1, by + bh - r - 1, r);
|
||||||
|
|
||||||
|
// Draw text
|
||||||
|
display->setColor(BLACK);
|
||||||
|
display->drawString(bx + padX, by + padY, label);
|
||||||
|
|
||||||
|
// Perfectly center triangle on text baseline
|
||||||
|
int16_t tx = bx + padX + labelW;
|
||||||
|
int16_t ty = by + padY + (FONT_HEIGHT_SMALL / 2) - (triH / 2) - 1; // -1 for optical centering
|
||||||
|
|
||||||
|
// ◄ Left-pointing triangle
|
||||||
|
display->fillTriangle(tx + triW, ty, // top-right
|
||||||
|
tx, ty + triH / 2, // left center
|
||||||
|
tx + triW, ty + triH // bottom-right
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// Draw Free Text input with multi-emote support and proper line wrapping
|
||||||
display->setColor(WHITE);
|
display->setColor(WHITE);
|
||||||
{
|
{
|
||||||
int inputY = 0 + y + FONT_HEIGHT_SMALL;
|
int inputY = 0 + y + FONT_HEIGHT_SMALL;
|
||||||
|
|||||||
@@ -62,6 +62,7 @@
|
|||||||
#define TFT_OFFSET_X 0
|
#define TFT_OFFSET_X 0
|
||||||
#define TFT_OFFSET_Y 0
|
#define TFT_OFFSET_Y 0
|
||||||
#define TFT_INVERT false
|
#define TFT_INVERT false
|
||||||
|
#define FORCE_LOW_RES 1
|
||||||
#define SCREEN_ROTATE
|
#define SCREEN_ROTATE
|
||||||
#define SCREEN_TRANSITION_FRAMERATE 5 // fps
|
#define SCREEN_TRANSITION_FRAMERATE 5 // fps
|
||||||
#define DISPLAY_FORCE_SMALL_FONTS
|
#define DISPLAY_FORCE_SMALL_FONTS
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#define VTFT_CTRL 46 // Heltec Tracker needs this pulled low for TFT
|
#define VTFT_CTRL 46 // Heltec Tracker needs this pulled low for TFT
|
||||||
#define SCREEN_TRANSITION_FRAMERATE 3 // fps
|
#define SCREEN_TRANSITION_FRAMERATE 3 // fps
|
||||||
#define DISPLAY_FORCE_SMALL_FONTS
|
#define DISPLAY_FORCE_SMALL_FONTS
|
||||||
|
#define FORCE_LOW_RES 1
|
||||||
|
|
||||||
#define VEXT_ENABLE Vext // active low, powers the oled display and the lora antenna boost
|
#define VEXT_ENABLE Vext // active low, powers the oled display and the lora antenna boost
|
||||||
#define VEXT_ON_VALUE LOW
|
#define VEXT_ON_VALUE LOW
|
||||||
|
|||||||
Reference in New Issue
Block a user