New Display screen modes: Pin Viewer and Stats (#1113)
* Added "Pin Viewer" and "Stats" screen types to Display. Moved special character definitions to global Display defines. Included new "Build", "Config", and "Platform" conditionals. Fixed issue where text rendering would wrap if line was too long. To-Do: add wrapping abilities to tiny_ssd1306. * Displays pins in use, undefined, as well as defined mappings. * Added changed variable used for version and added new build ID variable.
This commit is contained in:
@@ -18,11 +18,16 @@ execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_REPO_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=7
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_REPO_BUILD_ID
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REGEX REPLACE "v([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" CMAKE_GIT_REPO_VERSION ${GIT_REPO_VERSION})
|
||||
string(REGEX REPLACE "^(.......-.*)|(.......)$" "0.0.0" CMAKE_GIT_REPO_VERSION ${CMAKE_GIT_REPO_VERSION}) # fix if all we have is the git SHA
|
||||
configure_file("headers/version.h.in" "headers/version.h")
|
||||
message("GIT_REPO_VERSION is ${GIT_REPO_VERSION}")
|
||||
message("CMAKE_GIT_REPO_VERSION is ${CMAKE_GIT_REPO_VERSION}")
|
||||
message("GIT_REPO_BUILD_ID is ${GIT_REPO_BUILD_ID}")
|
||||
|
||||
# Uncomment the next line for an unomptimized build for debugging. Use in conjunction with the Debug build type.
|
||||
# set(PICO_DEOPTIMIZED_DEBUG 1)
|
||||
@@ -187,6 +192,8 @@ src/display/ui/elements/GPSprite.cpp
|
||||
src/display/ui/screens/ButtonLayoutScreen.cpp
|
||||
src/display/ui/screens/ConfigScreen.cpp
|
||||
src/display/ui/screens/MainMenuScreen.cpp
|
||||
src/display/ui/screens/PinViewerScreen.cpp
|
||||
src/display/ui/screens/StatsScreen.cpp
|
||||
src/display/ui/screens/SplashScreen.cpp
|
||||
src/display/GPGFX.cpp
|
||||
src/display/GPGFX_UI.cpp
|
||||
|
||||
@@ -5,12 +5,16 @@ enum DisplayMode {
|
||||
CONFIG_INSTRUCTION,
|
||||
BUTTONS,
|
||||
SPLASH,
|
||||
PIN_VIEWER,
|
||||
STATS,
|
||||
MAIN_MENU
|
||||
};
|
||||
|
||||
#include "ui/screens/ButtonLayoutScreen.h"
|
||||
#include "ui/screens/ConfigScreen.h"
|
||||
#include "ui/screens/MainMenuScreen.h"
|
||||
#include "ui/screens/PinViewerScreen.h"
|
||||
#include "ui/screens/SplashScreen.h"
|
||||
#include "ui/screens/StatsScreen.h"
|
||||
|
||||
#endif
|
||||
@@ -8,4 +8,31 @@
|
||||
#include "fonts/GP_Font_Big.h"
|
||||
#include "fonts/GP_Font_Standard.h"
|
||||
|
||||
// special characters
|
||||
#define CHAR_TRIANGLE "\x80"
|
||||
#define CHAR_CIRCLE "\x81"
|
||||
#define CHAR_CROSS "\x82"
|
||||
#define CHAR_SQUARE "\x83"
|
||||
|
||||
#define CHAR_UP "\x84"
|
||||
#define CHAR_DOWN "\x85"
|
||||
#define CHAR_LEFT "\x86"
|
||||
#define CHAR_RIGHT "\x87"
|
||||
|
||||
#define CHAR_UL "\x88"
|
||||
#define CHAR_UR "\x89"
|
||||
#define CHAR_DL "\x8A"
|
||||
#define CHAR_DR "\x8B"
|
||||
|
||||
#define CHAR_CAP_S "\x8C"
|
||||
#define CHAR_HOME_S "\x8D"
|
||||
|
||||
#define CHAR_VIEW_X "\x8E"
|
||||
#define CHAR_MENU_X "\x8F"
|
||||
#define CHAR_HOME_X "\x90"
|
||||
|
||||
#define CHAR_TPAD_P "\x91"
|
||||
#define CHAR_HOME_P "\x92"
|
||||
#define CHAR_SHARE_P "\x93"
|
||||
|
||||
#endif
|
||||
@@ -11,32 +11,6 @@
|
||||
#include "GPGFX_UI_widgets.h"
|
||||
#include "GPGFX_UI_layouts.h"
|
||||
|
||||
#define CHAR_TRIANGLE "\x80"
|
||||
#define CHAR_CIRCLE "\x81"
|
||||
#define CHAR_CROSS "\x82"
|
||||
#define CHAR_SQUARE "\x83"
|
||||
|
||||
#define CHAR_UP "\x84"
|
||||
#define CHAR_DOWN "\x85"
|
||||
#define CHAR_LEFT "\x86"
|
||||
#define CHAR_RIGHT "\x87"
|
||||
|
||||
#define CHAR_UL "\x88"
|
||||
#define CHAR_UR "\x89"
|
||||
#define CHAR_DL "\x8A"
|
||||
#define CHAR_DR "\x8B"
|
||||
|
||||
#define CHAR_CAP_S "\x8C"
|
||||
#define CHAR_HOME_S "\x8D"
|
||||
|
||||
#define CHAR_VIEW_X "\x8E"
|
||||
#define CHAR_MENU_X "\x8F"
|
||||
#define CHAR_HOME_X "\x90"
|
||||
|
||||
#define CHAR_TPAD_P "\x91"
|
||||
#define CHAR_HOME_P "\x92"
|
||||
#define CHAR_SHARE_P "\x93"
|
||||
|
||||
#define INPUT_HISTORY_MAX_INPUTS 22
|
||||
#define INPUT_HISTORY_MAX_MODES 11
|
||||
|
||||
|
||||
75
headers/display/ui/screens/PinViewerScreen.h
Normal file
75
headers/display/ui/screens/PinViewerScreen.h
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifndef _PINVIEWERSCREEN_H_
|
||||
#define _PINVIEWERSCREEN_H_
|
||||
|
||||
#include <map>
|
||||
#include "GPGFX_UI_widgets.h"
|
||||
|
||||
class PinViewerScreen : public GPScreen {
|
||||
public:
|
||||
PinViewerScreen() {}
|
||||
PinViewerScreen(GPGFX* renderer) { setRenderer(renderer); }
|
||||
virtual int8_t update();
|
||||
virtual void init();
|
||||
virtual void shutdown();
|
||||
protected:
|
||||
virtual void drawScreen();
|
||||
uint16_t prevButtonState = 0;
|
||||
|
||||
std::map<GpioAction,const char*> buttonLookup = {
|
||||
{GpioAction::BUTTON_PRESS_UP, CHAR_UP},
|
||||
{GpioAction::BUTTON_PRESS_DOWN, CHAR_DOWN},
|
||||
{GpioAction::BUTTON_PRESS_LEFT, CHAR_LEFT},
|
||||
{GpioAction::BUTTON_PRESS_RIGHT, CHAR_RIGHT},
|
||||
{GpioAction::BUTTON_PRESS_B1, "B1"},
|
||||
{GpioAction::BUTTON_PRESS_B2, "B2"},
|
||||
{GpioAction::BUTTON_PRESS_B3, "B3"},
|
||||
{GpioAction::BUTTON_PRESS_B4, "B4"},
|
||||
{GpioAction::BUTTON_PRESS_L1, "L1"},
|
||||
{GpioAction::BUTTON_PRESS_R1, "R1"},
|
||||
{GpioAction::BUTTON_PRESS_L2, "L2"},
|
||||
{GpioAction::BUTTON_PRESS_R2, "R2"},
|
||||
{GpioAction::BUTTON_PRESS_S1, "S1"},
|
||||
{GpioAction::BUTTON_PRESS_S2, "S2"},
|
||||
{GpioAction::BUTTON_PRESS_A1, "A1"},
|
||||
{GpioAction::BUTTON_PRESS_A2, "A2"},
|
||||
{GpioAction::BUTTON_PRESS_L3, "L3"},
|
||||
{GpioAction::BUTTON_PRESS_R3, "R3"},
|
||||
{GpioAction::BUTTON_PRESS_FN, "FN"},
|
||||
{GpioAction::BUTTON_PRESS_DDI_UP, "DDI" CHAR_UP},
|
||||
{GpioAction::BUTTON_PRESS_DDI_DOWN, "DDI" CHAR_DOWN},
|
||||
{GpioAction::BUTTON_PRESS_DDI_LEFT, "DDI" CHAR_LEFT},
|
||||
{GpioAction::BUTTON_PRESS_DDI_RIGHT, "DDI" CHAR_RIGHT},
|
||||
{GpioAction::SUSTAIN_DP_MODE_DP, "DP"},
|
||||
{GpioAction::SUSTAIN_DP_MODE_LS, "LS"},
|
||||
{GpioAction::SUSTAIN_DP_MODE_RS, "RS"},
|
||||
{GpioAction::SUSTAIN_SOCD_MODE_UP_PRIO, "SOCD-UP"},
|
||||
{GpioAction::SUSTAIN_SOCD_MODE_NEUTRAL, "SOCD-N"},
|
||||
{GpioAction::SUSTAIN_SOCD_MODE_SECOND_WIN, "SOCD-2W"},
|
||||
{GpioAction::SUSTAIN_SOCD_MODE_FIRST_WIN, "SOCD-1W"},
|
||||
{GpioAction::SUSTAIN_SOCD_MODE_BYPASS, "SOCD-BP"},
|
||||
{GpioAction::BUTTON_PRESS_TURBO, "TRB"},
|
||||
{GpioAction::BUTTON_PRESS_MACRO, "M"},
|
||||
{GpioAction::BUTTON_PRESS_MACRO_1, "M1"},
|
||||
{GpioAction::BUTTON_PRESS_MACRO_2, "M2"},
|
||||
{GpioAction::BUTTON_PRESS_MACRO_3, "M3"},
|
||||
{GpioAction::BUTTON_PRESS_MACRO_4, "M4"},
|
||||
{GpioAction::BUTTON_PRESS_MACRO_5, "M5"},
|
||||
{GpioAction::BUTTON_PRESS_MACRO_6, "M6"},
|
||||
{GpioAction::BUTTON_PRESS_A3, "A3"},
|
||||
{GpioAction::BUTTON_PRESS_A4, "A4"},
|
||||
{GpioAction::BUTTON_PRESS_E1, "E1"},
|
||||
{GpioAction::BUTTON_PRESS_E2, "E2"},
|
||||
{GpioAction::BUTTON_PRESS_E3, "E3"},
|
||||
{GpioAction::BUTTON_PRESS_E4, "E4"},
|
||||
{GpioAction::BUTTON_PRESS_E5, "E5"},
|
||||
{GpioAction::BUTTON_PRESS_E6, "E6"},
|
||||
{GpioAction::BUTTON_PRESS_E7, "E7"},
|
||||
{GpioAction::BUTTON_PRESS_E8, "E8"},
|
||||
{GpioAction::BUTTON_PRESS_E9, "E9"},
|
||||
{GpioAction::BUTTON_PRESS_E10, "E10"},
|
||||
{GpioAction::BUTTON_PRESS_E11, "E11"},
|
||||
{GpioAction::BUTTON_PRESS_E12, "E12"},
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
18
headers/display/ui/screens/StatsScreen.h
Normal file
18
headers/display/ui/screens/StatsScreen.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _STATSSCREEN_H_
|
||||
#define _STATSSCREEN_H_
|
||||
|
||||
#include "GPGFX_UI_widgets.h"
|
||||
|
||||
class StatsScreen : public GPScreen {
|
||||
public:
|
||||
StatsScreen() {}
|
||||
StatsScreen(GPGFX* renderer) { setRenderer(renderer); }
|
||||
virtual int8_t update();
|
||||
virtual void init();
|
||||
virtual void shutdown();
|
||||
protected:
|
||||
virtual void drawScreen();
|
||||
uint16_t prevButtonState = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1 +1,5 @@
|
||||
#define GP2040VERSION "${GIT_REPO_VERSION}"
|
||||
#define GP2040VERSIONID "${CMAKE_GIT_REPO_VERSION}"
|
||||
#define GP2040BUILD "${GIT_REPO_BUILD_ID}"
|
||||
#define GP2040CONFIG "${CMAKE_BUILD_TYPE}"
|
||||
#define GP2040PLATFORM "${PICO_PLATFORM}"
|
||||
|
||||
@@ -84,6 +84,12 @@ bool DisplayAddon::updateDisplayScreen() {
|
||||
case BUTTONS:
|
||||
delete (ButtonLayoutScreen*)gpScreen;
|
||||
break;
|
||||
case PIN_VIEWER:
|
||||
delete (PinViewerScreen*)gpScreen;
|
||||
break;
|
||||
case STATS:
|
||||
delete (StatsScreen*)gpScreen;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -102,6 +108,12 @@ bool DisplayAddon::updateDisplayScreen() {
|
||||
case BUTTONS:
|
||||
gpScreen = new ButtonLayoutScreen(gpDisplay);
|
||||
break;
|
||||
case PIN_VIEWER:
|
||||
gpScreen = new PinViewerScreen(gpDisplay);
|
||||
break;
|
||||
case STATS:
|
||||
gpScreen = new StatsScreen(gpDisplay);
|
||||
break;
|
||||
default:
|
||||
gpScreen = nullptr;
|
||||
break;
|
||||
|
||||
@@ -16,15 +16,18 @@ int8_t ConfigScreen::update() {
|
||||
if (prevButtonState && !buttonState) {
|
||||
switch (prevButtonState) {
|
||||
case (GAMEPAD_MASK_B1):
|
||||
//prevDisplayMode = prevDisplayMode == DisplayMode::BUTTONS ? DisplayMode::CONFIG_INSTRUCTION : DisplayMode::BUTTONS;
|
||||
prevButtonState = 0;
|
||||
return DisplayMode::BUTTONS;
|
||||
case (GAMEPAD_MASK_B2):
|
||||
//prevDisplayMode = prevDisplayMode == DisplayMode::SPLASH ? DisplayMode::CONFIG_INSTRUCTION : DisplayMode::SPLASH;
|
||||
prevButtonState = 0;
|
||||
return DisplayMode::SPLASH;
|
||||
case (GAMEPAD_MASK_B3):
|
||||
prevButtonState = 0;
|
||||
return DisplayMode::PIN_VIEWER;
|
||||
case (GAMEPAD_MASK_B4):
|
||||
prevButtonState = 0;
|
||||
return DisplayMode::STATS;
|
||||
default:
|
||||
//prevDisplayMode = DisplayMode::CONFIG_INSTRUCTION;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -33,10 +36,12 @@ int8_t ConfigScreen::update() {
|
||||
}
|
||||
|
||||
void ConfigScreen::drawScreen() {
|
||||
getRenderer()->drawText(0, 0, "[Web Config Mode]");
|
||||
getRenderer()->drawText(2, 0, "[Web Config Mode]");
|
||||
getRenderer()->drawText(0, 1, version);
|
||||
getRenderer()->drawText(0, 2, "[http://192.168.7.1]");
|
||||
getRenderer()->drawText(0, 3, "Preview:");
|
||||
getRenderer()->drawText(5, 4, " B1 > Button");
|
||||
getRenderer()->drawText(5, 5, " B2 > Splash");
|
||||
getRenderer()->drawText(3, 4, " B1 > Button");
|
||||
getRenderer()->drawText(3, 5, " B2 > Splash");
|
||||
getRenderer()->drawText(3, 6, " B3 > Pin Viewer");
|
||||
getRenderer()->drawText(3, 7, " B4 > Stats");
|
||||
}
|
||||
66
src/display/ui/screens/PinViewerScreen.cpp
Normal file
66
src/display/ui/screens/PinViewerScreen.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "PinViewerScreen.h"
|
||||
|
||||
#include "pico/stdlib.h"
|
||||
|
||||
void PinViewerScreen::init() {
|
||||
getRenderer()->clearScreen();
|
||||
}
|
||||
|
||||
void PinViewerScreen::shutdown() {
|
||||
clearElements();
|
||||
}
|
||||
|
||||
void PinViewerScreen::drawScreen() {
|
||||
Mask_t pinValues = ~gpio_get_all();
|
||||
GpioMappingInfo* pinMappings = Storage::getInstance().getProfilePinMappings();
|
||||
|
||||
std::string pinsPressed = "PIN: ";
|
||||
std::string pinsInUse = "In Use: ";
|
||||
std::string pinsUndefined = "Undef: ";
|
||||
std::string buttonsPressed = "BTN: ";
|
||||
|
||||
getRenderer()->drawText(5, 0, "[Pin Viewer]");
|
||||
|
||||
for (Pin_t pin = 0; pin < (Pin_t)NUM_BANK0_GPIOS; pin++) {
|
||||
if ((pinMappings[pin].action > 0) && (pinMappings[pin].action != GpioAction::CUSTOM_BUTTON_COMBO)) {
|
||||
if ((pinValues >> pin) & 0x01) {
|
||||
pinsPressed += std::to_string(pin);
|
||||
pinsPressed += " ";
|
||||
|
||||
const char * action = buttonLookup[pinMappings[pin].action];
|
||||
buttonsPressed += action;
|
||||
buttonsPressed += " ";
|
||||
}
|
||||
} else {
|
||||
if (pinMappings[pin].action != GpioAction::NONE) {
|
||||
pinsInUse += std::to_string(pin);
|
||||
pinsInUse += " ";
|
||||
} else {
|
||||
pinsUndefined += std::to_string(pin);
|
||||
pinsUndefined += " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getRenderer()->drawText(0, 2, pinsUndefined.c_str());
|
||||
getRenderer()->drawText(0, 3, pinsInUse.c_str());
|
||||
getRenderer()->drawText(0, 4, pinsPressed.c_str());
|
||||
getRenderer()->drawText(0, 5, buttonsPressed.c_str());
|
||||
|
||||
getRenderer()->drawText(4, 7, "A2 to Return");
|
||||
}
|
||||
|
||||
int8_t PinViewerScreen::update() {
|
||||
if (Storage::getInstance().GetConfigMode()) {
|
||||
uint16_t buttonState = getGamepad()->state.buttons;
|
||||
if (prevButtonState && !buttonState) {
|
||||
if (prevButtonState == GAMEPAD_MASK_A2) {
|
||||
prevButtonState = 0;
|
||||
return DisplayMode::CONFIG_INSTRUCTION;
|
||||
}
|
||||
}
|
||||
prevButtonState = buttonState;
|
||||
}
|
||||
|
||||
return -1; // -1 means no change in screen state
|
||||
}
|
||||
38
src/display/ui/screens/StatsScreen.cpp
Normal file
38
src/display/ui/screens/StatsScreen.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "StatsScreen.h"
|
||||
|
||||
#include "pico/stdlib.h"
|
||||
#include "version.h"
|
||||
|
||||
void StatsScreen::init() {
|
||||
getRenderer()->clearScreen();
|
||||
}
|
||||
|
||||
void StatsScreen::shutdown() {
|
||||
clearElements();
|
||||
}
|
||||
|
||||
void StatsScreen::drawScreen() {
|
||||
getRenderer()->drawText(2, 0, "[GP2040-CE Stats]");
|
||||
getRenderer()->drawText(0, 1, "Version: " GP2040VERSIONID);
|
||||
getRenderer()->drawText(0, 2, "Build: " GP2040BUILD);
|
||||
getRenderer()->drawText(0, 3, "Board: " GP2040_BOARDCONFIG);
|
||||
getRenderer()->drawText(0, 4, "Type: " GP2040CONFIG);
|
||||
getRenderer()->drawText(0, 5, "Arch: " GP2040PLATFORM);
|
||||
|
||||
getRenderer()->drawText(5, 7, "B2 to Return");
|
||||
}
|
||||
|
||||
int8_t StatsScreen::update() {
|
||||
if (Storage::getInstance().GetConfigMode()) {
|
||||
uint16_t buttonState = getGamepad()->state.buttons;
|
||||
if (prevButtonState && !buttonState) {
|
||||
if (prevButtonState == GAMEPAD_MASK_B2) {
|
||||
prevButtonState = 0;
|
||||
return DisplayMode::CONFIG_INSTRUCTION;
|
||||
}
|
||||
}
|
||||
prevButtonState = buttonState;
|
||||
}
|
||||
|
||||
return -1; // -1 means no change in screen state
|
||||
}
|
||||
@@ -147,7 +147,9 @@ void GPGFX_TinySSD1306::drawText(uint8_t x, uint8_t y, std::string text, uint8_t
|
||||
uint8_t charOffset = 0;
|
||||
const uint8_t* currGlyph;
|
||||
|
||||
for (uint8_t charIndex = 0; charIndex < text.size(); charIndex++) {
|
||||
uint8_t maxTextSize = (MAX_SCREEN_WIDTH / _options.font.width);
|
||||
|
||||
for (uint8_t charIndex = 0; charIndex < MIN(text.size(), maxTextSize); charIndex++) {
|
||||
currChar = text[charIndex];
|
||||
glyphIndex = currChar - GPGFX_FONT_CHAR_OFFSET;
|
||||
currGlyph = &_options.font.fontData[glyphIndex * ((_options.font.width - 1) * (_options.font.height/8))];
|
||||
|
||||
Reference in New Issue
Block a user