2020-02-07 21:51:17 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-07-31 12:11:47 +00:00
|
|
|
|
#include "configuration.h"
|
|
|
|
|
|
2023-03-09 03:13:46 +00:00
|
|
|
|
#include "detect/ScanI2C.h"
|
|
|
|
|
#include "mesh/generated/meshtastic/config.pb.h"
|
|
|
|
|
#include <OLEDDisplay.h>
|
|
|
|
|
|
2022-07-31 12:11:47 +00:00
|
|
|
|
#if !HAS_SCREEN
|
2022-05-06 13:41:37 +00:00
|
|
|
|
#include "power.h"
|
2021-03-15 02:00:20 +00:00
|
|
|
|
namespace graphics
|
|
|
|
|
{
|
|
|
|
|
// Noop class for boards without screen.
|
2023-01-19 09:16:42 +00:00
|
|
|
|
class Screen
|
2021-03-15 02:00:20 +00:00
|
|
|
|
{
|
|
|
|
|
public:
|
2023-03-09 03:13:46 +00:00
|
|
|
|
explicit Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY);
|
2021-03-15 02:00:20 +00:00
|
|
|
|
void onPress() {}
|
|
|
|
|
void setup() {}
|
|
|
|
|
void setOn(bool) {}
|
2023-01-19 09:16:42 +00:00
|
|
|
|
void print(const char *) {}
|
2021-03-15 02:00:20 +00:00
|
|
|
|
void doDeepSleep() {}
|
2024-04-06 13:04:26 +00:00
|
|
|
|
void forceDisplay(bool forceUiUpdate = false) {}
|
2022-12-09 10:27:12 +00:00
|
|
|
|
void startFirmwareUpdateScreen() {}
|
2024-06-25 16:26:02 +00:00
|
|
|
|
void startAlert(const char *) {}
|
|
|
|
|
void endAlert() {}
|
2021-03-15 02:00:20 +00:00
|
|
|
|
};
|
2023-01-19 09:16:42 +00:00
|
|
|
|
} // namespace graphics
|
2021-03-15 02:00:20 +00:00
|
|
|
|
#else
|
2020-03-15 23:47:38 +00:00
|
|
|
|
#include <cstring>
|
2020-02-08 04:59:21 +00:00
|
|
|
|
|
2020-03-15 23:47:38 +00:00
|
|
|
|
#include <OLEDDisplayUi.h>
|
2020-06-14 08:28:23 +00:00
|
|
|
|
|
2021-08-01 18:15:02 +00:00
|
|
|
|
#include "../configuration.h"
|
2024-06-25 16:26:02 +00:00
|
|
|
|
#include "gps/GeoCoord.h"
|
|
|
|
|
#include "graphics/ScreenFonts.h"
|
2021-08-01 18:15:02 +00:00
|
|
|
|
|
2022-03-24 16:36:56 +00:00
|
|
|
|
#ifdef USE_ST7567
|
2020-10-23 10:00:43 +00:00
|
|
|
|
#include <ST7567Wire.h>
|
2023-03-08 14:42:45 +00:00
|
|
|
|
#elif defined(USE_SH1106) || defined(USE_SH1107) || defined(USE_SH1107_128_64)
|
2022-04-25 05:13:41 +00:00
|
|
|
|
#include <SH1106Wire.h>
|
|
|
|
|
#elif defined(USE_SSD1306)
|
|
|
|
|
#include <SSD1306Wire.h>
|
2020-06-14 08:28:23 +00:00
|
|
|
|
#else
|
2022-03-24 16:36:56 +00:00
|
|
|
|
// the SH1106/SSD1306 variant is auto-detected
|
|
|
|
|
#include <AutoOLEDWire.h>
|
2020-06-14 08:28:23 +00:00
|
|
|
|
#endif
|
2020-02-08 04:59:21 +00:00
|
|
|
|
|
2021-06-27 18:17:53 +00:00
|
|
|
|
#include "EInkDisplay2.h"
|
2024-03-03 02:07:29 +00:00
|
|
|
|
#include "EInkDynamicDisplay.h"
|
2024-05-23 12:21:27 +00:00
|
|
|
|
#include "PointStruct.h"
|
2020-09-26 16:40:48 +00:00
|
|
|
|
#include "TFTDisplay.h"
|
2020-03-15 23:47:38 +00:00
|
|
|
|
#include "TypedQueue.h"
|
2020-08-28 22:06:52 +00:00
|
|
|
|
#include "commands.h"
|
2020-07-06 08:45:55 +00:00
|
|
|
|
#include "concurrency/LockGuard.h"
|
2020-10-09 06:16:51 +00:00
|
|
|
|
#include "concurrency/OSThread.h"
|
2023-07-30 12:51:26 +00:00
|
|
|
|
#include "input/InputBroker.h"
|
2023-01-19 09:16:42 +00:00
|
|
|
|
#include "mesh/MeshModule.h"
|
2020-03-26 16:24:53 +00:00
|
|
|
|
#include "power.h"
|
2020-04-15 03:22:27 +00:00
|
|
|
|
#include <string>
|
2020-02-21 12:57:08 +00:00
|
|
|
|
|
2020-10-24 00:16:15 +00:00
|
|
|
|
// 0 to 255, though particular variants might define different defaults
|
|
|
|
|
#ifndef BRIGHTNESS_DEFAULT
|
|
|
|
|
#define BRIGHTNESS_DEFAULT 150
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-09-22 02:37:36 +00:00
|
|
|
|
// Meters to feet conversion
|
|
|
|
|
#ifndef METERS_TO_FEET
|
|
|
|
|
#define METERS_TO_FEET 3.28
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Feet to miles conversion
|
|
|
|
|
#ifndef MILES_TO_FEET
|
|
|
|
|
#define MILES_TO_FEET 5280
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-03-28 23:31:11 +00:00
|
|
|
|
// Intuitive colors. E-Ink display is inverted from OLED(?)
|
|
|
|
|
#define EINK_BLACK OLEDDISPLAY_COLOR::WHITE
|
|
|
|
|
#define EINK_WHITE OLEDDISPLAY_COLOR::BLACK
|
|
|
|
|
|
2024-05-23 12:21:27 +00:00
|
|
|
|
// Base segment dimensions for T-Watch segmented display
|
|
|
|
|
#define SEGMENT_WIDTH 16
|
|
|
|
|
#define SEGMENT_HEIGHT 4
|
|
|
|
|
|
2024-06-29 02:28:18 +00:00
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
/// A basic 2D point class for drawing
|
|
|
|
|
class Point
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
float x, y;
|
|
|
|
|
|
|
|
|
|
Point(float _x, float _y) : x(_x), y(_y) {}
|
|
|
|
|
|
|
|
|
|
/// Apply a rotation around zero (standard rotation matrix math)
|
|
|
|
|
void rotate(float radian)
|
|
|
|
|
{
|
|
|
|
|
float cos = cosf(radian), sin = sinf(radian);
|
|
|
|
|
float rx = x * cos + y * sin, ry = -x * sin + y * cos;
|
|
|
|
|
|
|
|
|
|
x = rx;
|
|
|
|
|
y = ry;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void translate(int16_t dx, int dy)
|
|
|
|
|
{
|
|
|
|
|
x += dx;
|
|
|
|
|
y += dy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void scale(float f)
|
|
|
|
|
{
|
|
|
|
|
// We use -f here to counter the flip that happens
|
|
|
|
|
// on the y axis when drawing and rotating on screen
|
|
|
|
|
x *= f;
|
|
|
|
|
y *= -f;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
static uint16_t getCompassDiam(OLEDDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
uint16_t diam = 0;
|
|
|
|
|
uint16_t offset = 0;
|
|
|
|
|
|
|
|
|
|
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT)
|
|
|
|
|
offset = FONT_HEIGHT_SMALL;
|
|
|
|
|
|
|
|
|
|
// get the smaller of the 2 dimensions and subtract 20
|
|
|
|
|
if (display->getWidth() > (display->getHeight() - offset)) {
|
|
|
|
|
diam = display->getHeight() - offset;
|
|
|
|
|
// if 2/3 of the other size would be smaller, use that
|
|
|
|
|
if (diam > (display->getWidth() * 2 / 3)) {
|
|
|
|
|
diam = display->getWidth() * 2 / 3;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
diam = display->getWidth();
|
|
|
|
|
if (diam > ((display->getHeight() - offset) * 2 / 3)) {
|
|
|
|
|
diam = (display->getHeight() - offset) * 2 / 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return diam - 20;
|
|
|
|
|
};
|
|
|
|
|
|
2020-07-07 08:46:49 +00:00
|
|
|
|
namespace graphics
|
2020-03-15 23:47:38 +00:00
|
|
|
|
{
|
2020-02-21 18:51:36 +00:00
|
|
|
|
|
2020-03-26 16:24:53 +00:00
|
|
|
|
// Forward declarations
|
|
|
|
|
class Screen;
|
|
|
|
|
|
|
|
|
|
/// Handles gathering and displaying debug information.
|
|
|
|
|
class DebugInfo
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
DebugInfo(const DebugInfo &) = delete;
|
|
|
|
|
DebugInfo &operator=(const DebugInfo &) = delete;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
friend Screen;
|
|
|
|
|
|
|
|
|
|
DebugInfo() {}
|
|
|
|
|
|
|
|
|
|
/// Renders the debug screen.
|
|
|
|
|
void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
2020-09-05 16:30:18 +00:00
|
|
|
|
void drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
2020-09-13 04:43:41 +00:00
|
|
|
|
void drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
2020-09-05 16:30:18 +00:00
|
|
|
|
|
2020-03-26 16:24:53 +00:00
|
|
|
|
/// Protects all of internal state.
|
2020-07-05 22:54:30 +00:00
|
|
|
|
concurrency::Lock lock;
|
2020-03-26 16:24:53 +00:00
|
|
|
|
};
|
|
|
|
|
|
2020-07-07 08:46:49 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief This class deals with showing things on the screen of the device.
|
2020-08-28 22:06:52 +00:00
|
|
|
|
*
|
|
|
|
|
* @details Other than setup(), this class is thread-safe as long as drawFrame is not called
|
|
|
|
|
* multiple times simultaneously. All state-changing calls are queued and executed
|
2020-07-07 08:46:49 +00:00
|
|
|
|
* when the main loop calls us.
|
|
|
|
|
*/
|
2020-10-09 06:16:51 +00:00
|
|
|
|
class Screen : public concurrency::OSThread
|
2020-02-21 18:51:36 +00:00
|
|
|
|
{
|
2020-08-28 22:06:52 +00:00
|
|
|
|
CallbackObserver<Screen, const meshtastic::Status *> powerStatusObserver =
|
|
|
|
|
CallbackObserver<Screen, const meshtastic::Status *>(this, &Screen::handleStatusUpdate);
|
|
|
|
|
CallbackObserver<Screen, const meshtastic::Status *> gpsStatusObserver =
|
|
|
|
|
CallbackObserver<Screen, const meshtastic::Status *>(this, &Screen::handleStatusUpdate);
|
|
|
|
|
CallbackObserver<Screen, const meshtastic::Status *> nodeStatusObserver =
|
|
|
|
|
CallbackObserver<Screen, const meshtastic::Status *>(this, &Screen::handleStatusUpdate);
|
2023-01-21 17:22:19 +00:00
|
|
|
|
CallbackObserver<Screen, const meshtastic_MeshPacket *> textMessageObserver =
|
|
|
|
|
CallbackObserver<Screen, const meshtastic_MeshPacket *>(this, &Screen::handleTextMessage);
|
2024-06-24 07:04:46 +00:00
|
|
|
|
CallbackObserver<Screen, const meshtastic_MeshPacket *> waypointObserver =
|
|
|
|
|
CallbackObserver<Screen, const meshtastic_MeshPacket *>(this, &Screen::handleWaypoint);
|
2022-01-13 08:19:36 +00:00
|
|
|
|
CallbackObserver<Screen, const UIFrameEvent *> uiFrameEventObserver =
|
|
|
|
|
CallbackObserver<Screen, const UIFrameEvent *>(this, &Screen::handleUIFrameEvent);
|
2023-07-30 12:51:26 +00:00
|
|
|
|
CallbackObserver<Screen, const InputEvent *> inputObserver =
|
|
|
|
|
CallbackObserver<Screen, const InputEvent *>(this, &Screen::handleInputEvent);
|
2020-06-28 04:19:49 +00:00
|
|
|
|
|
2020-03-15 23:47:38 +00:00
|
|
|
|
public:
|
2023-03-09 03:13:46 +00:00
|
|
|
|
explicit Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY);
|
2020-02-21 18:51:36 +00:00
|
|
|
|
|
2024-03-21 14:06:37 +00:00
|
|
|
|
~Screen();
|
|
|
|
|
|
2020-03-15 23:47:38 +00:00
|
|
|
|
Screen(const Screen &) = delete;
|
|
|
|
|
Screen &operator=(const Screen &) = delete;
|
2020-02-21 18:51:36 +00:00
|
|
|
|
|
2023-03-09 03:13:46 +00:00
|
|
|
|
ScanI2C::DeviceAddress address_found;
|
|
|
|
|
meshtastic_Config_DisplayConfig_OledType model;
|
|
|
|
|
OLEDDISPLAY_GEOMETRY geometry;
|
2021-12-18 16:02:54 +00:00
|
|
|
|
|
2020-03-15 23:47:38 +00:00
|
|
|
|
/// Initializes the UI, turns on the display, starts showing boot screen.
|
|
|
|
|
//
|
|
|
|
|
// Not thread safe - must be called before any other methods are called.
|
2020-02-21 18:51:36 +00:00
|
|
|
|
void setup();
|
2020-03-05 00:46:57 +00:00
|
|
|
|
|
2024-03-28 23:31:11 +00:00
|
|
|
|
/// Turns the screen on/off. Optionally, pass a custom screensaver frame for E-Ink
|
|
|
|
|
void setOn(bool on, FrameCallback einkScreensaver = NULL)
|
2020-05-17 12:11:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (!on)
|
2024-03-28 23:31:11 +00:00
|
|
|
|
// We handle off commands immediately, because they might be called because the CPU is shutting down
|
|
|
|
|
handleSetOn(false, einkScreensaver);
|
2020-05-17 12:11:32 +00:00
|
|
|
|
else
|
2024-03-31 12:04:05 +00:00
|
|
|
|
enqueueCmd(ScreenCmd{.cmd = Cmd::SET_ON});
|
2020-05-17 12:11:32 +00:00
|
|
|
|
}
|
2020-02-21 18:51:36 +00:00
|
|
|
|
|
2020-11-12 23:49:01 +00:00
|
|
|
|
/**
|
2023-01-19 09:16:42 +00:00
|
|
|
|
* Prepare the display for the unit going to the lowest power mode possible. Most screens will just
|
2020-11-12 23:49:01 +00:00
|
|
|
|
* poweroff, but eink screens will show a "I'm sleeping" graphic, possibly with a QR code
|
|
|
|
|
*/
|
|
|
|
|
void doDeepSleep();
|
|
|
|
|
|
2020-12-20 22:45:45 +00:00
|
|
|
|
void blink();
|
|
|
|
|
|
2024-06-29 02:28:18 +00:00
|
|
|
|
void drawFrameText(OLEDDisplay *, OLEDDisplayUiState *, int16_t, int16_t, const char *);
|
|
|
|
|
|
|
|
|
|
// Draw north
|
|
|
|
|
void drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t compassY, float myHeading)
|
|
|
|
|
{
|
|
|
|
|
// If north is supposed to be at the top of the compass we want rotation to be +0
|
|
|
|
|
if (config.display.compass_north_top)
|
|
|
|
|
myHeading = -0;
|
|
|
|
|
|
|
|
|
|
Point N1(-0.04f, 0.65f), N2(0.04f, 0.65f);
|
|
|
|
|
Point N3(-0.04f, 0.55f), N4(0.04f, 0.55f);
|
|
|
|
|
Point *rosePoints[] = {&N1, &N2, &N3, &N4};
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
// North on compass will be negative of heading
|
|
|
|
|
rosePoints[i]->rotate(-myHeading);
|
|
|
|
|
rosePoints[i]->scale(getCompassDiam(display));
|
|
|
|
|
rosePoints[i]->translate(compassX, compassY);
|
|
|
|
|
}
|
|
|
|
|
display->drawLine(N1.x, N1.y, N3.x, N3.y);
|
|
|
|
|
display->drawLine(N2.x, N2.y, N4.x, N4.y);
|
|
|
|
|
display->drawLine(N1.x, N1.y, N4.x, N4.y);
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-30 12:51:26 +00:00
|
|
|
|
/// Handle button press, trackball or swipe action)
|
2020-07-07 08:46:49 +00:00
|
|
|
|
void onPress() { enqueueCmd(ScreenCmd{.cmd = Cmd::ON_PRESS}); }
|
2023-07-30 12:51:26 +00:00
|
|
|
|
void showPrevFrame() { enqueueCmd(ScreenCmd{.cmd = Cmd::SHOW_PREV_FRAME}); }
|
|
|
|
|
void showNextFrame() { enqueueCmd(ScreenCmd{.cmd = Cmd::SHOW_NEXT_FRAME}); }
|
2020-02-22 20:01:59 +00:00
|
|
|
|
|
2024-06-25 16:26:02 +00:00
|
|
|
|
// generic alert start
|
|
|
|
|
void startAlert(FrameCallback _alertFrame)
|
2020-03-15 23:47:38 +00:00
|
|
|
|
{
|
2024-06-25 16:26:02 +00:00
|
|
|
|
alertFrame = _alertFrame;
|
2020-07-07 08:46:49 +00:00
|
|
|
|
ScreenCmd cmd;
|
2024-06-25 16:26:02 +00:00
|
|
|
|
cmd.cmd = Cmd::START_ALERT_FRAME;
|
2020-03-15 23:47:38 +00:00
|
|
|
|
enqueueCmd(cmd);
|
|
|
|
|
}
|
2020-02-22 20:01:59 +00:00
|
|
|
|
|
2024-06-25 16:26:02 +00:00
|
|
|
|
void startAlert(const char *_alertMessage)
|
2021-02-12 05:48:12 +00:00
|
|
|
|
{
|
2024-06-25 16:26:02 +00:00
|
|
|
|
startAlert([_alertMessage](OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) -> void {
|
|
|
|
|
uint16_t x_offset = display->width() / 2;
|
|
|
|
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
|
|
|
display->setFont(FONT_MEDIUM);
|
|
|
|
|
display->drawString(x_offset + x, 26 + y, _alertMessage);
|
|
|
|
|
});
|
2021-02-12 05:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-25 16:26:02 +00:00
|
|
|
|
void endAlert()
|
2022-01-19 23:10:02 +00:00
|
|
|
|
{
|
|
|
|
|
ScreenCmd cmd;
|
2024-06-25 16:26:02 +00:00
|
|
|
|
cmd.cmd = Cmd::STOP_ALERT_FRAME;
|
2022-01-19 23:10:02 +00:00
|
|
|
|
enqueueCmd(cmd);
|
|
|
|
|
}
|
2021-02-12 05:48:12 +00:00
|
|
|
|
|
2024-06-25 16:26:02 +00:00
|
|
|
|
void startFirmwareUpdateScreen()
|
2022-08-22 21:41:23 +00:00
|
|
|
|
{
|
|
|
|
|
ScreenCmd cmd;
|
2024-06-25 16:26:02 +00:00
|
|
|
|
cmd.cmd = Cmd::START_FIRMWARE_UPDATE_SCREEN;
|
2022-08-22 21:41:23 +00:00
|
|
|
|
enqueueCmd(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-11 22:47:45 +00:00
|
|
|
|
// Function to allow the AccelerometerThread to set the heading if a sensor provides it
|
|
|
|
|
// Mutex needed?
|
|
|
|
|
void setHeading(long _heading)
|
|
|
|
|
{
|
|
|
|
|
hasCompass = true;
|
|
|
|
|
compassHeading = _heading;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool hasHeading() { return hasCompass; }
|
|
|
|
|
|
|
|
|
|
long getHeading() { return compassHeading; }
|
Added modifier key combination to allow keyboard shortcuts on t-deck (#3668)
* Updated kbI2cBase.cpp
Updated keyboard settings for t-deck to allow a modifier key to trigger 'tab', mute notifications, or quit. To trigger the modifier press the shift key and mic (0) button at the same time. Then press q (quit), m (mute), or t (tab).
* Update kbI2cBase.cpp
* fixed formatting issues in kbI2cBase.cpp
* Removed keyboard shortcut code that doesnt work
alt+t does not work on a t-deck so I removed it to avoid confusion.
* Updated kbI2cBase.cpp
Updated keyboard settings for t-deck to allow a modifier key to trigger 'tab', mute notifications, or quit. To trigger the modifier press the shift key and mic (0) button at the same time. Then press q (quit), m (mute), or t (tab).
* Update kbI2cBase.cpp
* fixed formatting issues in kbI2cBase.cpp
* Removed keyboard shortcut code that doesnt work
alt+t does not work on a t-deck so I removed it to avoid confusion.
* Changed modifier key to alt+c
* Added screen brightness functionality
Use modifier key with o(+) to increase brightness or i(-) to decrease.
Currently there are 4 levels of brightness, (L, ML, MH, H). I would like to add a popup message to tell you the brightness.
* Added checks to disable screen brightness changes on unsupported hardware
* Setting the brightness code to work on only applicable devices
* Added "function symbol" display to bottom right corner of screen. Now shows when mute is active or modifier key is pressed. Also fixed some other minor issues.
* commented out a log
* Reworked how modifier functions worked, added
I wasn’t happy with my previous implementation, and I think it would have caused issues with other devices. This should work on all devices.
* Added back the function I moved causing issue with versions
* Fixed the version conflicts, everything seems to work fine now
---------
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
2024-05-08 12:37:50 +00:00
|
|
|
|
// functions for display brightness
|
|
|
|
|
void increaseBrightness();
|
|
|
|
|
void decreaseBrightness();
|
|
|
|
|
|
|
|
|
|
void setFunctionSymbal(std::string sym);
|
|
|
|
|
void removeFunctionSymbal(std::string sym);
|
|
|
|
|
|
2020-03-15 23:47:38 +00:00
|
|
|
|
/// Stops showing the boot screen.
|
2020-07-07 08:46:49 +00:00
|
|
|
|
void stopBootScreen() { enqueueCmd(ScreenCmd{.cmd = Cmd::STOP_BOOT_SCREEN}); }
|
2020-03-05 00:46:57 +00:00
|
|
|
|
|
2020-03-15 23:47:38 +00:00
|
|
|
|
/// Writes a string to the screen.
|
|
|
|
|
void print(const char *text)
|
|
|
|
|
{
|
2020-07-07 08:46:49 +00:00
|
|
|
|
ScreenCmd cmd;
|
2020-03-15 23:47:38 +00:00
|
|
|
|
cmd.cmd = Cmd::PRINT;
|
|
|
|
|
// TODO(girts): strdup() here is scary, but we can't use std::string as
|
|
|
|
|
// FreeRTOS queue is just dumbly copying memory contents. It would be
|
|
|
|
|
// nice if we had a queue that could copy objects by value.
|
|
|
|
|
cmd.print_text = strdup(text);
|
|
|
|
|
if (!enqueueCmd(cmd)) {
|
|
|
|
|
free(cmd.print_text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-02 23:40:51 +00:00
|
|
|
|
/// generates a very brief time delta display
|
2023-02-05 00:46:16 +00:00
|
|
|
|
std::string drawTimeDelta(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds);
|
2023-02-02 23:40:51 +00:00
|
|
|
|
|
2020-06-22 19:03:26 +00:00
|
|
|
|
/// Overrides the default utf8 character conversion, to replace empty space with question marks
|
2020-08-28 22:06:52 +00:00
|
|
|
|
static char customFontTableLookup(const uint8_t ch)
|
|
|
|
|
{
|
2020-06-22 19:03:26 +00:00
|
|
|
|
// UTF-8 to font table index converter
|
|
|
|
|
// Code form http://playground.arduino.cc/Main/Utf8ascii
|
|
|
|
|
static uint8_t LASTCHAR;
|
2020-08-28 22:06:52 +00:00
|
|
|
|
static bool SKIPREST; // Only display a single unconvertable-character symbol per sequence of unconvertable characters
|
2020-06-22 19:03:26 +00:00
|
|
|
|
|
|
|
|
|
if (ch < 128) { // Standard ASCII-set 0..0x7F handling
|
|
|
|
|
LASTCHAR = 0;
|
|
|
|
|
SKIPREST = false;
|
|
|
|
|
return ch;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-28 22:06:52 +00:00
|
|
|
|
uint8_t last = LASTCHAR; // get last char
|
2020-06-22 19:03:26 +00:00
|
|
|
|
LASTCHAR = ch;
|
|
|
|
|
|
2022-09-04 20:00:10 +00:00
|
|
|
|
switch (last) { // conversion depending on first UTF8-character
|
2023-01-19 09:16:42 +00:00
|
|
|
|
case 0xC2: {
|
|
|
|
|
SKIPREST = false;
|
|
|
|
|
return (uint8_t)ch;
|
|
|
|
|
}
|
|
|
|
|
case 0xC3: {
|
|
|
|
|
SKIPREST = false;
|
|
|
|
|
return (uint8_t)(ch | 0xC0);
|
|
|
|
|
}
|
|
|
|
|
// map UTF-8 cyrillic chars to it Windows-1251 (CP-1251) ASCII codes
|
|
|
|
|
// note: in this case we must use compatible font - provided ArialMT_Plain_10/16/24 by 'ThingPulse/esp8266-oled-ssd1306'
|
|
|
|
|
// library have empty chars for non-latin ASCII symbols
|
|
|
|
|
case 0xD0: {
|
|
|
|
|
SKIPREST = false;
|
2023-02-20 16:05:11 +00:00
|
|
|
|
if (ch == 132)
|
|
|
|
|
return (uint8_t)(170); // Є
|
|
|
|
|
if (ch == 134)
|
|
|
|
|
return (uint8_t)(178); // І
|
|
|
|
|
if (ch == 135)
|
|
|
|
|
return (uint8_t)(175); // Ї
|
2023-01-19 09:16:42 +00:00
|
|
|
|
if (ch == 129)
|
|
|
|
|
return (uint8_t)(168); // Ё
|
|
|
|
|
if (ch > 143 && ch < 192)
|
|
|
|
|
return (uint8_t)(ch + 48);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 0xD1: {
|
|
|
|
|
SKIPREST = false;
|
2023-02-20 16:05:11 +00:00
|
|
|
|
if (ch == 148)
|
|
|
|
|
return (uint8_t)(186); // є
|
|
|
|
|
if (ch == 150)
|
|
|
|
|
return (uint8_t)(179); // і
|
|
|
|
|
if (ch == 151)
|
|
|
|
|
return (uint8_t)(191); // ї
|
2023-01-19 09:16:42 +00:00
|
|
|
|
if (ch == 145)
|
|
|
|
|
return (uint8_t)(184); // ё
|
|
|
|
|
if (ch > 127 && ch < 144)
|
|
|
|
|
return (uint8_t)(ch + 112);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2023-02-20 16:03:32 +00:00
|
|
|
|
case 0xD2: {
|
|
|
|
|
SKIPREST = false;
|
2023-02-20 16:05:11 +00:00
|
|
|
|
if (ch == 144)
|
|
|
|
|
return (uint8_t)(165); // Ґ
|
|
|
|
|
if (ch == 145)
|
|
|
|
|
return (uint8_t)(180); // ґ
|
2023-02-20 16:03:32 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2020-06-22 19:03:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We want to strip out prefix chars for two-byte char formats
|
2022-09-04 20:00:10 +00:00
|
|
|
|
if (ch == 0xC2 || ch == 0xC3 || ch == 0x82 || ch == 0xD0 || ch == 0xD1)
|
2020-08-28 22:06:52 +00:00
|
|
|
|
return (uint8_t)0;
|
2020-06-22 19:03:26 +00:00
|
|
|
|
|
2020-08-28 22:06:52 +00:00
|
|
|
|
// If we already returned an unconvertable-character symbol for this unconvertable-character sequence, return NULs for the
|
|
|
|
|
// rest of it
|
|
|
|
|
if (SKIPREST)
|
|
|
|
|
return (uint8_t)0;
|
2020-06-22 19:03:26 +00:00
|
|
|
|
SKIPREST = true;
|
|
|
|
|
|
2020-08-28 22:06:52 +00:00
|
|
|
|
return (uint8_t)191; // otherwise: return ¿ if character can't be converted (note that the font map we're using doesn't
|
|
|
|
|
// stick to standard EASCII codes)
|
2020-06-22 19:03:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 16:24:53 +00:00
|
|
|
|
/// Returns a handle to the DebugInfo screen.
|
|
|
|
|
//
|
|
|
|
|
// Use this handle to set things like battery status, user count, GPS status, etc.
|
2020-08-28 22:06:52 +00:00
|
|
|
|
DebugInfo *debug_info() { return &debugInfo; }
|
2020-03-26 16:24:53 +00:00
|
|
|
|
|
2023-07-30 12:51:26 +00:00
|
|
|
|
// Handle observer events
|
2020-06-29 01:17:52 +00:00
|
|
|
|
int handleStatusUpdate(const meshtastic::Status *arg);
|
2023-01-21 17:22:19 +00:00
|
|
|
|
int handleTextMessage(const meshtastic_MeshPacket *arg);
|
2022-01-13 08:19:36 +00:00
|
|
|
|
int handleUIFrameEvent(const UIFrameEvent *arg);
|
2023-07-30 12:51:26 +00:00
|
|
|
|
int handleInputEvent(const InputEvent *arg);
|
2024-06-24 07:04:46 +00:00
|
|
|
|
int handleWaypoint(const meshtastic_MeshPacket *arg);
|
2020-06-28 04:19:49 +00:00
|
|
|
|
|
2020-10-15 07:56:38 +00:00
|
|
|
|
/// Used to force (super slow) eink displays to draw critical frames
|
2024-04-06 13:04:26 +00:00
|
|
|
|
void forceDisplay(bool forceUiUpdate = false);
|
2020-10-15 07:56:38 +00:00
|
|
|
|
|
2021-11-26 20:09:16 +00:00
|
|
|
|
/// Draws our SSL cert screen during boot (called from WebServer)
|
|
|
|
|
void setSSLFrames();
|
|
|
|
|
|
2022-04-11 02:15:10 +00:00
|
|
|
|
void setWelcomeFrames();
|
|
|
|
|
|
2024-03-28 23:31:11 +00:00
|
|
|
|
#ifdef USE_EINK
|
|
|
|
|
/// Draw an image to remain on E-Ink display after screen off
|
|
|
|
|
void setScreensaverFrames(FrameCallback einkScreensaver = NULL);
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-03-15 23:47:38 +00:00
|
|
|
|
protected:
|
|
|
|
|
/// Updates the UI.
|
|
|
|
|
//
|
|
|
|
|
// Called periodically from the main loop.
|
2020-10-10 01:57:57 +00:00
|
|
|
|
int32_t runOnce() final;
|
2020-03-15 23:47:38 +00:00
|
|
|
|
|
2023-12-13 02:27:31 +00:00
|
|
|
|
bool isAUTOOled = false;
|
|
|
|
|
|
2020-03-15 23:47:38 +00:00
|
|
|
|
private:
|
2024-06-25 16:26:02 +00:00
|
|
|
|
FrameCallback alertFrames[1];
|
2020-07-07 08:46:49 +00:00
|
|
|
|
struct ScreenCmd {
|
2020-03-15 23:47:38 +00:00
|
|
|
|
Cmd cmd;
|
|
|
|
|
union {
|
|
|
|
|
uint32_t bluetooth_pin;
|
|
|
|
|
char *print_text;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// Enques given command item to be processed by main loop().
|
2020-07-07 08:46:49 +00:00
|
|
|
|
bool enqueueCmd(const ScreenCmd &cmd)
|
2020-03-15 23:47:38 +00:00
|
|
|
|
{
|
2020-03-29 18:13:53 +00:00
|
|
|
|
if (!useDisplay)
|
2024-05-26 11:42:44 +00:00
|
|
|
|
return false; // not enqueued if our display is not in use
|
2020-03-29 18:13:53 +00:00
|
|
|
|
else {
|
|
|
|
|
bool success = cmdQueue.enqueue(cmd, 0);
|
2020-10-12 00:13:32 +00:00
|
|
|
|
enabled = true; // handle ASAP (we are the registered reader for cmdQueue, but might have been disabled)
|
2020-03-29 18:13:53 +00:00
|
|
|
|
return success;
|
|
|
|
|
}
|
2020-03-15 23:47:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Implementations of various commands, called from doTask().
|
2024-03-28 23:31:11 +00:00
|
|
|
|
void handleSetOn(bool on, FrameCallback einkScreensaver = NULL);
|
2020-03-15 23:47:38 +00:00
|
|
|
|
void handleOnPress();
|
2023-07-30 12:51:26 +00:00
|
|
|
|
void handleShowNextFrame();
|
|
|
|
|
void handleShowPrevFrame();
|
2020-03-15 23:47:38 +00:00
|
|
|
|
void handlePrint(const char *text);
|
2021-02-12 05:48:12 +00:00
|
|
|
|
void handleStartFirmwareUpdateScreen();
|
2020-03-15 23:47:38 +00:00
|
|
|
|
/// Rebuilds our list of frames (screens) to default ones.
|
2020-03-05 00:46:57 +00:00
|
|
|
|
void setFrames();
|
2020-03-18 22:00:17 +00:00
|
|
|
|
|
2020-10-16 02:53:55 +00:00
|
|
|
|
/// Try to start drawing ASAP
|
|
|
|
|
void setFastFramerate();
|
|
|
|
|
|
2023-10-10 01:43:16 +00:00
|
|
|
|
// Sets frame up for immediate drawing
|
|
|
|
|
void setFrameImmediateDraw(FrameCallback *drawFrames);
|
|
|
|
|
|
2020-03-26 16:24:53 +00:00
|
|
|
|
/// Called when debug screen is to be drawn, calls through to debugInfo.drawFrame.
|
|
|
|
|
static void drawDebugInfoTrampoline(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
|
|
|
|
|
2020-09-05 16:30:18 +00:00
|
|
|
|
static void drawDebugInfoSettingsTrampoline(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
|
|
|
|
|
2020-09-13 04:43:41 +00:00
|
|
|
|
static void drawDebugInfoWiFiTrampoline(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
|
|
|
|
|
2024-05-23 12:21:27 +00:00
|
|
|
|
#ifdef T_WATCH_S3
|
|
|
|
|
static void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
|
|
|
|
|
|
|
|
|
static void drawDigitalClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y);
|
|
|
|
|
|
|
|
|
|
static void drawSegmentedDisplayCharacter(OLEDDisplay *display, int x, int y, uint8_t number, float scale = 1);
|
|
|
|
|
|
|
|
|
|
static void drawHorizontalSegment(OLEDDisplay *display, int x, int y, int width, int height);
|
|
|
|
|
|
|
|
|
|
static void drawVerticalSegment(OLEDDisplay *display, int x, int y, int width, int height);
|
|
|
|
|
|
|
|
|
|
static void drawSegmentedDisplayColon(OLEDDisplay *display, int x, int y, float scale = 1);
|
|
|
|
|
|
|
|
|
|
static void drawWatchFaceToggleButton(OLEDDisplay *display, int16_t x, int16_t y, bool digitalMode = true, float scale = 1);
|
|
|
|
|
|
|
|
|
|
static void drawBluetoothConnectedIcon(OLEDDisplay *display, int16_t x, int16_t y);
|
|
|
|
|
|
|
|
|
|
// Whether we are showing the digital watch face or the analog one
|
|
|
|
|
bool digitalWatchFace = true;
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-06-25 16:26:02 +00:00
|
|
|
|
/// callback for current alert frame
|
|
|
|
|
FrameCallback alertFrame;
|
|
|
|
|
|
2020-03-15 23:47:38 +00:00
|
|
|
|
/// Queue of commands to execute in doTask.
|
2020-07-07 08:46:49 +00:00
|
|
|
|
TypedQueue<ScreenCmd> cmdQueue;
|
2020-03-15 23:47:38 +00:00
|
|
|
|
/// Whether we are using a display
|
|
|
|
|
bool useDisplay = false;
|
|
|
|
|
/// Whether the display is currently powered
|
|
|
|
|
bool screenOn = false;
|
|
|
|
|
// Whether we are showing the regular screen (as opposed to booth screen or
|
|
|
|
|
// Bluetooth PIN screen)
|
|
|
|
|
bool showingNormalScreen = false;
|
2020-03-26 16:24:53 +00:00
|
|
|
|
|
Added modifier key combination to allow keyboard shortcuts on t-deck (#3668)
* Updated kbI2cBase.cpp
Updated keyboard settings for t-deck to allow a modifier key to trigger 'tab', mute notifications, or quit. To trigger the modifier press the shift key and mic (0) button at the same time. Then press q (quit), m (mute), or t (tab).
* Update kbI2cBase.cpp
* fixed formatting issues in kbI2cBase.cpp
* Removed keyboard shortcut code that doesnt work
alt+t does not work on a t-deck so I removed it to avoid confusion.
* Updated kbI2cBase.cpp
Updated keyboard settings for t-deck to allow a modifier key to trigger 'tab', mute notifications, or quit. To trigger the modifier press the shift key and mic (0) button at the same time. Then press q (quit), m (mute), or t (tab).
* Update kbI2cBase.cpp
* fixed formatting issues in kbI2cBase.cpp
* Removed keyboard shortcut code that doesnt work
alt+t does not work on a t-deck so I removed it to avoid confusion.
* Changed modifier key to alt+c
* Added screen brightness functionality
Use modifier key with o(+) to increase brightness or i(-) to decrease.
Currently there are 4 levels of brightness, (L, ML, MH, H). I would like to add a popup message to tell you the brightness.
* Added checks to disable screen brightness changes on unsupported hardware
* Setting the brightness code to work on only applicable devices
* Added "function symbol" display to bottom right corner of screen. Now shows when mute is active or modifier key is pressed. Also fixed some other minor issues.
* commented out a log
* Reworked how modifier functions worked, added
I wasn’t happy with my previous implementation, and I think it would have caused issues with other devices. This should work on all devices.
* Added back the function I moved causing issue with versions
* Fixed the version conflicts, everything seems to work fine now
---------
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
2024-05-08 12:37:50 +00:00
|
|
|
|
// Implementation to Adjust Brightness
|
|
|
|
|
uint8_t brightness = BRIGHTNESS_DEFAULT; // H = 254, MH = 192, ML = 130 L = 103
|
|
|
|
|
|
2024-06-11 22:47:45 +00:00
|
|
|
|
bool hasCompass = false;
|
|
|
|
|
float compassHeading;
|
2020-03-26 16:24:53 +00:00
|
|
|
|
/// Holds state for debug information
|
|
|
|
|
DebugInfo debugInfo;
|
2020-07-07 08:46:49 +00:00
|
|
|
|
|
2022-04-25 05:13:41 +00:00
|
|
|
|
/// Display device
|
2023-12-13 02:27:31 +00:00
|
|
|
|
OLEDDisplay *dispdev;
|
2022-04-25 05:13:41 +00:00
|
|
|
|
|
2020-03-15 23:47:38 +00:00
|
|
|
|
/// UI helper for rendering to frames and switching between them
|
2023-12-13 02:27:31 +00:00
|
|
|
|
OLEDDisplayUi *ui;
|
2020-02-21 18:51:36 +00:00
|
|
|
|
};
|
|
|
|
|
|
2020-07-07 08:46:49 +00:00
|
|
|
|
} // namespace graphics
|
2024-06-25 16:26:02 +00:00
|
|
|
|
|
2023-07-22 14:26:54 +00:00
|
|
|
|
#endif
|