Make simulator compile

This commit is contained in:
Jasper Blanckenburg 2023-05-23 02:51:40 +02:00
parent 2347b738c5
commit 5a56ce394f
9 changed files with 29 additions and 9 deletions

View File

@ -4,8 +4,14 @@
// This is wacky preprocessor magic that allows us to count the number of
// members of an enum. Unfortunately, it doesn't work with enum classes, so we
// have to use C-style enums.
// The preprocessor magic is so wacky we have to prevent GCC from failing with a
// -Werror=pedantic when compiling the simulator
#pragma GCC diagnostic ignored "-Wpedantic"
#define CountedEnum(NAME, TYPE, ...) \
typedef enum { __VA_ARGS__ } NAME; \
static const size_t NAME##_COUNT = sizeof((int[]){__VA_ARGS__}) / sizeof(int);
static const size_t NAME##_COUNT = \
sizeof(__extension__(int[]){__VA_ARGS__}) / sizeof(int);
#endif // INC_UTIL_H

View File

@ -230,7 +230,7 @@ void led_anim_blinker(uint8_t r, uint8_t g, uint8_t b,
colors[i][1] = g * i / (brightness_steps - 1);
colors[i][2] = b * i / (brightness_steps - 1);
}
size_t simultaneous_leds = brightness_steps / next_led_steps;
int32_t simultaneous_leds = brightness_steps / next_led_steps;
if (simultaneous_leds * next_led_steps != brightness_steps) {
simultaneous_leds++;
}
@ -239,7 +239,7 @@ void led_anim_blinker(uint8_t r, uint8_t g, uint8_t b,
int32_t furthest = 0;
size_t color_idx = 0;
while (furthest < 5 + simultaneous_leds) {
for (size_t offset = 0; offset < simultaneous_leds; offset++) {
for (int32_t offset = 0; offset < simultaneous_leds; offset++) {
int32_t diff = furthest - offset;
size_t led_color_idx = color_idx + offset * next_led_steps;
if (diff < 0 || diff > 4 || led_color_idx >= brightness_steps) {

View File

@ -41,9 +41,19 @@ cxxDefinitionsFile:
asDefinitionsFile:
# Compiler flags
cFlags: []
cFlags:
- -Wall
- -Wextra
- -Werror
- -Wno-unused-parameter
- -Wno-missing-field-initializers
cxxFlags:
- -fno-rtti
- -Wall
- -Wextra
- -Werror
- -Wno-unused-parameter
- -Wno-missing-field-initializers
assemblyFlags: []
linkerFlags:
- -specs=nosys.specs

View File

@ -535,9 +535,9 @@ CXXFLAGS += -g -gdwarf -ggdb
endif
# Add additional flags
CFLAGS +=
CFLAGS += -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-unused-parameter
ASFLAGS +=
CXXFLAGS += -fno-rtti
CXXFLAGS += -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -fno-rtti
# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"

View File

@ -33,7 +33,9 @@
/* USER CODE BEGIN PD */
// Redefine here so it doesn't get overwritten on code generation
#undef TOUCHGFX_STACK_SIZE
#define TOUCHGFX_STACK_SIZE (8160)
#undef TOUCHGFX_BYTE_POOL_SIZE
#define TOUCHGFX_BYTE_POOL_SIZE (8192)
/* USER CODE END PD */

View File

@ -5,4 +5,4 @@ touchgfx_path := ../Middlewares/ST/touchgfx
# Location of the TouchGFX Environment
touchgfx_env := C:/TouchGFX/4.21.2/env
# Optional additional compiler flags
user_cflags := -DUSE_BPP=16
user_cflags := -DUSE_BPP=16 -std=gnu++1z -Wno-cast-qual -Wno-missing-declarations

View File

@ -59,7 +59,7 @@ void DriverViewView::tearDownScreen() { DriverViewViewBase::tearDownScreen(); }
void DriverViewView::fieldTypeSelectionUpdateItem(
DriverViewFieldSelection &item, int16_t itemIndex) {
item.setName(dataFieldDescs[itemIndex].title);
item.setSelected(itemIndex == selectedFieldType);
item.setSelected(itemIndex == (int)selectedFieldType);
}
void DriverViewView::setFieldType(size_t i, DataFieldType type) {

View File

@ -92,7 +92,7 @@ void VehicleConfigView::updateSelectedParam(int select) {
}
if (firstWanted < 0) {
firstWanted = 0;
} else if (firstWanted > ParamType_COUNT - 1) {
} else if (firstWanted > (int16_t)(ParamType_COUNT - 1)) {
firstWanted = ParamType_COUNT - 1;
}
params.animateToItem(firstWanted, 0);

View File

@ -1542,10 +1542,12 @@
}
},
"GenerateAssetsCommand": "make -f simulator/gcc/Makefile assets -j8",
"GenerateAssetsCommandOverride": "make -f simulator/gcc/Makefile assets -j2",
"PostGenerateCommand": "touchgfx update_project --project-file=simulator/msvs/Application.vcxproj",
"PostGenerateTargetCommand": "touchgfx update_project",
"PostGenerateTargetCommandOverride": "",
"CompileSimulatorCommand": "make -f simulator/gcc/Makefile -j8",
"CompileSimulatorCommandOverride": "make -f simulator/gcc/Makefile -j2",
"RunSimulatorCommand": "build\\bin\\simulator.exe",
"LandscapeSkinX": 0,
"LandscapeSkinY": 0,