Fixing import loop

This commit is contained in:
Ben V. Brown
2023-06-29 20:26:00 +10:00
parent 7535a64bc7
commit c31fb5725b
10 changed files with 62 additions and 42 deletions

View File

@@ -9,13 +9,13 @@ WORKDIR /build
# musl-dev is required for the multi lang firmwares
# clang is required for clang-format (for dev)
ARG APK_COMPS="gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf \
newlib-arm-none-eabi"
newlib-arm-none-eabi"
ARG APK_PYTHON="python3 py3-pip black"
ARG APK_MISC="findutils make git"
ARG APK_DEV="musl-dev clang bash clang-extra-tools"
# PIP packages
ARG PIP_PKGS='bdflib'
ARG PIP_PKGS='bdflib pyyaml'
RUN apk add --no-cache ${APK_COMPS} ${APK_PYTHON} ${APK_MISC} ${APK_DEV}

View File

@@ -103,7 +103,7 @@ public:
static int16_t getCursorX() { return cursor_x; }
static void printBounded(const char *str, const uint8_t x, const uint8_t y, const uint8_t w, const uint8_t h, FontStyle fontStyle = FontStyle::FROM_TEXT);
void printNumberBounded(const uint16_t num, bool noLeaderZeros, const uint8_t x, const uint8_t y, const uint8_t w, const uint8_t h);
static void printNumberBounded(const uint16_t num, bool noLeaderZeros, const uint8_t x, const uint8_t y, const uint8_t w, const uint8_t h);
static void print(const char *string, FontStyle fontStyle,
uint8_t length = 255); // Draw a string to the current location, with selected font; optionally - with MAX length only

View File

@@ -171,6 +171,7 @@ SOURCE_DRIVERS_DIR = ./Core/Drivers
INC_PD_DRIVERS_DIR = ./Core/Drivers/usb-pd/include
PD_DRIVER_TESTS_DIR = ./Core/Drivers/usb-pd/tests
PD_DRIVER_DIR = ./Core/Drivers/usb-pd
UI_DIR = ./UI
# Find-all's used for formatting; have to exclude external modules
@@ -419,6 +420,7 @@ INCLUDES = -I$(APP_INC_DIR) \
-I$(FRTOS_INC_DIR) \
-I$(DRIVER_INC_DIR) \
-I$(BSP_INC_DIR) \
-I$(UI_DIR) \
-I$(THREADS_INC_DIR) \
-I$(THREADS_OP_MODES_INC_DIR) \
-I$(THREADS_OP_MODES_TOOLS_INC_DIR) \
@@ -433,6 +435,7 @@ EXCLUDED_DIRS := -path $(PINECILV2_VENDOR_BSP_ES8388_DIR) \
-o -path $(PINECILV2_VENDOR_BSP_USB_DIR) \
SOURCE := $(shell find $(SOURCE_THREADS_DIR) -type f -name '*.c') \
$(shell find $(UI_DIR) -type f -name '*.c') \
$(shell find $(SOURCE_CORE_DIR) -type f -name '*.c') \
$(shell find $(SOURCE_DRIVERS_DIR) -type f -name '*.c') \
$(shell find $(DEVICE_BSP_DIR) -type d \( $(EXCLUDED_DIRS) \) -prune -false -o -type f -name '*.c')\
@@ -441,6 +444,7 @@ $(SOURCE_BRIEFLZ_DIR)/depack.c
# We exclude the USB-PD stack tests $(PD_DRIVER_TESTS_DIR)
SOURCE_CPP := $(shell find $(SOURCE_THREADS_DIR) -type f -name '*.cpp') \
$(shell find $(SOURCE_CORE_DIR) -type f -name '*.cpp') \
$(shell find $(UI_DIR) -type f -name '*.cpp') \
$(shell find $(SOURCE_DRIVERS_DIR) -path $(PD_DRIVER_TESTS_DIR) -prune -false -o -type f -name '*.cpp') \
$(shell find $(DEVICE_BSP_DIR) -type d \( $(EXCLUDED_DIRS) \) -prune -false -o -type f -name '*.cpp') \
$(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp')

View File

@@ -1,4 +1,8 @@
#include "UI.h"
void ui_render_screen(Screen_t *screen, ScreenContext_t *context) {
// Basically switch out the handlers
#include "OLED.hpp"
void ui_render_screen(screenLayout_t *screen, ScreenContext_t *context) {
// Walk the struct associated to the screen, calling render for each element of the screen
// Then start OLED refresh
OLED::refresh();
}

View File

@@ -1,37 +1,7 @@
#pragma once
#include "UI_Layouts.h"
#include <stdint.h>
typedef enum {
SimplifiedHome, // Basic home
SimplifiedHomeWarning, // Home with temp warning
DetailedHome, // Detailed home view
DetailedHomeWarning, // Home with temp warning
DebugMenu, // Debugging metrics
settingsCategory, // Settings category with icon
SettingsEntryBool, // Tickbox setting
SettingsEntry3Number, // Settings adjust with 3 number digits
SettingsEntry2Number, // Settings adjust with 2 number digits
SettingsEntry1Number, // Settings adjust with 2 number digits
SettingsEntry1Text, // Setting with single text char for state
ScrollingText, // Scrolling large text (warnings, help text)
SolderingMode, // Basic soldering mode
DetailedSolderingMode, // Detailed soldering mode
NumberAdjust, // Number adjust of number with <> either side
} screenLayout_t;
typedef void (*render_prep_fn)();
typedef void (*tick_fn)();
typedef void (*button_handler_fn)();
typedef struct {
// on_enter
// on_exit
tick_fn tick;
render_prep_fn render_prepare;
screenLayout_t layout; // Render layout used
button_handler_fn handle_button;
} Screen_t;
typedef union {
int32_t i32;
void *ptr;
@@ -42,4 +12,5 @@ typedef struct {
} ScreenContext_t;
//
void ui_render_screen(Screen_t *screen, ScreenContext_t *context);
void ui_render_screen(screenLayout_t *screen, ScreenContext_t *context);
void ui_render_element(const ElementTypes_t element, const ElementSettings_t *settings, screen_arg_t *args);

View File

@@ -1,6 +1,7 @@
#include "UI_Elements.h"
#include "FontUtils.h"
#include "OLED.hpp"
#include "UI.h"
void render_Text(const ElementSettings_t *settings, screen_arg_t *args);
void render_Number(const ElementSettings_t *settings, screen_arg_t *args);
void render_Image(const ElementSettings_t *settings, screen_arg_t *args);
@@ -54,7 +55,7 @@ void render_Number(const ElementSettings_t *settings, screen_arg_t *args) {
}
void render_Image(const ElementSettings_t *settings, screen_arg_t *args) {
// arg is a pointer to the raw image data to display
OLED::drawArea(settings->position.x, settings->position.y, settings->size.w, settings->size.h, (uint8_t *)args->ptr)
OLED::drawArea(settings->position.x, settings->position.y, settings->size.w, settings->size.h, (uint8_t *)args->ptr);
}
void render_PowerSource(const ElementSettings_t *settings, screen_arg_t *args) {
//

View File

@@ -1,5 +1,6 @@
#pragma once
#include "UI.h"
#include <stdint.h>
typedef enum {
Text, // Basic text splat, using re-encoded strings
Number, // Draws numbers using best size for the height (always one line)
@@ -23,5 +24,3 @@ typedef struct {
} size;
} ElementSettings_t;
void ui_render_element(const ElementTypes_t element,const ElementSettings_t * settings, screen_arg_t *args);

26
source/UI/UI_Layouts.h Normal file
View File

@@ -0,0 +1,26 @@
#pragma once
#include "UI_Elements.h"
typedef enum {
SimplifiedHome, // Basic home
SimplifiedHomeWarning, // Home with temp warning
DetailedHome, // Detailed home view
DetailedHomeWarning, // Home with temp warning
DebugView, // Debugging metrics
settingsCategory, // Settings category with icon
SettingsEntryBool, // Tickbox setting
SettingsEntry3Number, // Settings adjust with 3 number digits
SettingsEntry2Number, // Settings adjust with 2 number digits
SettingsEntry1Number, // Settings adjust with 2 number digits
SettingsEntry1Text, // Setting with single text char for state
ScrollingText, // Scrolling large text (warnings, help text)
SolderingMode, // Basic soldering mode
DetailedSolderingMode, // Detailed soldering mode
NumberAdjust, // Number adjust of number with <> either side
} screenLayout_t;
typedef struct {
struct {
ElementTypes_t elementType;
ElementSettings_t elementSettings;
} elements[5];
} ScreenLayoutRecord_t;

15
source/UI/UI_Screens.h Normal file
View File

@@ -0,0 +1,15 @@
#pragma once
#include "UI_Layouts.h"
typedef void (*render_prep_fn)();
typedef void (*tick_fn)();
typedef void (*button_handler_fn)();
typedef struct {
// on_enter
// on_exit
tick_fn tick;
render_prep_fn render_prepare;
screenLayout_t layout; // Render layout used
button_handler_fn handle_button;
} Screen_t;

View File

@@ -1,5 +1,5 @@
layouts:
simplifiedHome:
SimplifiedHome:
mirrorOnRotate: true
elements:
- type: image