Use PROJECT_VER variable for version, display version on main menu

This commit is contained in:
Renze Nicolai 2022-06-03 07:17:22 +02:00
parent a123f04ecf
commit 9f36d027a2
5 changed files with 24 additions and 10 deletions

View file

@ -1,4 +1,8 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(PROJECT_NAME "MCH2022 launcher")
set(PROJECT_VER "0.1")
project(main) project(main)

View file

@ -15,7 +15,7 @@
#include "pax_gfx.h" #include "pax_gfx.h"
#include "sdcard.h" #include "sdcard.h"
#include "appfs.h" #include "appfs.h"
#include "esp_ota_ops.h"
#include "rp2040.h" #include "rp2040.h"
#include "rp2040bl.h" #include "rp2040bl.h"
@ -71,6 +71,10 @@ void display_fatal_error(pax_buf_t* pax_buffer, ILI9341* ili9341, const char* li
void app_main(void) { void app_main(void) {
esp_err_t res; esp_err_t res;
const esp_app_desc_t *app_description = esp_ota_get_app_description();
ESP_LOGI(TAG, "App version: %s", app_description->version);
//ESP_LOGI(TAG, "Project name: %s", app_description->project_name);
/* Initialize memory */ /* Initialize memory */
uint8_t* framebuffer = heap_caps_malloc(ILI9341_BUFFER_SIZE, MALLOC_CAP_8BIT); uint8_t* framebuffer = heap_caps_malloc(ILI9341_BUFFER_SIZE, MALLOC_CAP_8BIT);
@ -236,7 +240,7 @@ void app_main(void) {
/* Launcher menu */ /* Launcher menu */
while (true) { while (true) {
menu_start(rp2040->queue, pax_buffer, ili9341); menu_start(rp2040->queue, pax_buffer, ili9341, app_description->version);
} }
free(framebuffer); free(framebuffer);

View file

@ -41,14 +41,20 @@ typedef enum action {
ACTION_SETTINGS ACTION_SETTINGS
} menu_start_action_t; } menu_start_action_t;
void render_start_help(pax_buf_t* pax_buffer) { void render_start_help(pax_buf_t* pax_buffer, const char* version) {
const pax_font_t *font = pax_get_font("saira regular"); const pax_font_t *font = pax_get_font("saira regular");
pax_background(pax_buffer, 0xFFFFFF); pax_background(pax_buffer, 0xFFFFFF);
pax_noclip(pax_buffer); pax_noclip(pax_buffer);
pax_draw_text(pax_buffer, 0xFF491d88, font, 18, 5, 240 - 18, "[A] accept"); pax_draw_text(pax_buffer, 0xFF491d88, font, 18, 5, 240 - 18, "[A] accept");
char version_text[64];
snprintf(version_text, sizeof(version_text), "v%s", version);
pax_vec1_t version_size = pax_text_size(font, 18, version_text);
pax_draw_text(pax_buffer, 0xFF491d88, font, 18, 320 - 5 - version_size.x, 240 - 18, version_text);
} }
void menu_start(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341) { void menu_start(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341, const char* version) {
menu_t* menu = menu_alloc("Main menu", 34, 18); menu_t* menu = menu_alloc("Main menu", 34, 18);
menu->fgColor = 0xFF000000; menu->fgColor = 0xFF000000;
@ -83,7 +89,7 @@ void menu_start(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili934
bool render = true; bool render = true;
menu_start_action_t action = ACTION_NONE; menu_start_action_t action = ACTION_NONE;
render_start_help(pax_buffer); render_start_help(pax_buffer, version);
while (1) { while (1) {
rp2040_input_message_t buttonMessage = {0}; rp2040_input_message_t buttonMessage = {0};
@ -135,7 +141,7 @@ void menu_start(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili934
} }
action = ACTION_NONE; action = ACTION_NONE;
render = true; render = true;
render_start_help(pax_buffer); render_start_help(pax_buffer, version);
} }
} }

View file

@ -5,4 +5,4 @@
#include "pax_gfx.h" #include "pax_gfx.h"
#include "ili9341.h" #include "ili9341.h"
void menu_start(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341); void menu_start(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341, const char* version);

View file

@ -157,15 +157,15 @@ CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y
CONFIG_APP_BUILD_GENERATE_BINARIES=y CONFIG_APP_BUILD_GENERATE_BINARIES=y
CONFIG_APP_BUILD_BOOTLOADER=y CONFIG_APP_BUILD_BOOTLOADER=y
CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y
CONFIG_APP_REPRODUCIBLE_BUILD=y # CONFIG_APP_REPRODUCIBLE_BUILD is not set
# end of Build type # end of Build type
# #
# Application manager # Application manager
# #
# CONFIG_APP_COMPILE_TIME_DATE is not set # CONFIG_APP_COMPILE_TIME_DATE is not set
CONFIG_APP_EXCLUDE_PROJECT_VER_VAR=y # CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set
CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR=y # CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set
# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set # CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set
CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16
# end of Application manager # end of Application manager