More settings rework

This commit is contained in:
Ben V. Brown
2023-07-19 23:13:13 +10:00
parent 5120235e2e
commit b38a5396f0
6 changed files with 149 additions and 106 deletions

View File

@@ -4,50 +4,21 @@
#include "portmacro.h"
#include <stdint.h>
/**
* A helper class for showing a full-screen scrolling message.
* A helper for showing a full-screen scrolling message.
*/
class ScrollMessage {
TickType_t messageStart = 0;
int16_t lastOffset = -1;
/**
* Calcualte the width in pixels of the message string, in the large
* font and taking into account multi-byte chars.
*
* @param message The null-terminated message string.
*/
static uint16_t messageWidth(const char *message);
public:
ScrollMessage() {}
/**
* Resets this `ScrollMessage` instance to its initial state.
*/
void reset() {
messageStart = 0;
lastOffset = -1;
}
/**
* Gets whether this `ScrollMessage` instance is in its initial state.
*/
bool isReset() const { return messageStart == 0; }
/**
* Draw and update the scroll message if needed.
*
* This function does not call `OLED::refresh()`. If this function
* returns `true`, the caller shall call `OLED::refresh()` to draw the
* modified framebuffer to the OLED screen.
*
* @param message The null-terminated message string. This must be the
* same string as the previous call, unless this `ScrollMessage` instance
* is in its initial state or `reset()` has been called.
* @param currentTick The current tick as returned by `xTaskGetTickCount()`.
* @return Whether the OLED framebuffer has been modified.
*/
bool drawUpdate(const char *message, TickType_t currentTick);
};
/**
* Draw and update the scroll message if needed.
*
* This function does not call `OLED::refresh()`. If this function
* returns `true`, the caller shall call `OLED::refresh()` to draw the
* modified framebuffer to the OLED screen.
*
* @param message The null-terminated message string. This must be the
* same string as the previous call, unless this `ScrollMessage` instance
* is in its initial state or `reset()` has been called.
* @param currentTick The current tick as returned by `xTaskGetTickCount()` offset to 0 at start of scrolling.
*/
void drawScrollingText(const char *message, TickType_t currentTickOffset);
#endif /* SCROLL_MESSAGE_HPP_ */

View File

@@ -13,7 +13,6 @@
#include "Settings.h"
#include "Translation.h"
#define PRESS_ACCEL_STEP (TICKS_100MS / 3)
#define PRESS_ACCEL_INTERVAL_MIN TICKS_100MS
#define PRESS_ACCEL_INTERVAL_MAX (TICKS_100MS * 3)
@@ -37,8 +36,9 @@ typedef struct {
uint8_t shortDescriptionSize;
} menuitem;
void enterSettingsMenu();
bool warnUser(const char *warning, const ButtonState buttons);
extern const menuitem rootSettingsMenu[];
void enterSettingsMenu();
bool warnUser(const char *warning, const ButtonState buttons);
extern const menuitem rootSettingsMenu[];
extern const menuitem *subSettingsMenus[];
#endif /* GUI_HPP_ */