Fix render issues with fonts

This commit is contained in:
Adolfo Reyna
2026-01-30 22:02:15 -05:00
parent e3445b545d
commit 436245a7a2
5 changed files with 30 additions and 17 deletions

View File

@@ -259,7 +259,7 @@ int main()
// Initialize standard I/O for debugging with timeout
// This prevents hanging when USB is not connected
stdio_init_all();
sleep_ms(5000); // Wait for USB connection (if present)
sleep_ms(100); // Wait for USB connection (if present)
printf("\n=== %s Demo ===\n", BOARD_NAME);
printf("Starting dual-core system...\n");

View File

@@ -56,7 +56,7 @@ Font font_tama_mini02_obj(reinterpret_cast<const unsigned char*>(font_tama_mini0
Font font_zxpix_obj(reinterpret_cast<const unsigned char*>(font_zxpix), 96, 6, 8);
LowLevelRenderer::LowLevelRenderer(uint8_t* buffer, int width, int height)
: bit_buffer(buffer), V_WIDTH(width), V_HEIGHT(height), current_font(nullptr),
: bit_buffer(buffer), V_WIDTH(width), V_HEIGHT(height), current_font(&font_5x5_obj),
clipping_enabled(false), clip_x(0), clip_y(0), clip_width(width), clip_height(height), text_color(true) {}
void LowLevelRenderer::set_font(const Font* font) {

View File

@@ -4,6 +4,7 @@
// Simple demo game to test the launcher
#include "demo_game.h"
#include "board_config.h"
#include <stdio.h>
#include <string.h>
@@ -53,7 +54,11 @@ void DemoGame::draw() {
// Instructions
if (tap_count < 3) {
#ifdef BUTTON_KEY0_PIN
renderer->draw_string(width/2 - 80, y + 80, "Tap or press 3 times", true);
#else
renderer->draw_string(width/2 - 80, y + 80, "Tap 3 times to exit", true);
#endif
} else {
renderer->draw_string(width/2 - 70, y + 80, "Exiting to menu...", true);
}

View File

@@ -220,12 +220,20 @@ void TicTacToeGame::draw() {
} else {
renderer->draw_string(20, 40, "TIE GAME!", true);
}
#ifdef BUTTON_KEY0_PIN
renderer->draw_string(20, 55, "Touch or KEY0 to restart", true);
#else
renderer->draw_string(20, 55, "Touch to restart", true);
#endif
} else {
char turn_text[30];
snprintf(turn_text, sizeof(turn_text), "Turn: %s", state.current_player == 1 ? "X" : "O");
renderer->draw_string(20, 40, turn_text, true);
#ifdef BUTTON_KEY0_PIN
renderer->draw_string(20, 55, "Touch cell or use keys", true);
#else
renderer->draw_string(20, 55, "Touch cell to play", true);
#endif
}
// Draw game board (use same layout as touch detection!)

View File

@@ -4,6 +4,7 @@
// Menu system for selecting and launching games
#include "game_launcher.h"
#include "board_config.h"
#include "display/low_level_render.h"
#include "display/low_level_gui.h"
#include <stdio.h>
@@ -27,27 +28,25 @@ void GameLauncher::register_game(const char* name, const char* description,
void GameLauncher::draw() {
// Draw main window
gui->draw_new_window(10, 10, width - 20, height - 20, "Game Launcher");
LowLevelWindow* window = gui->draw_new_window(10, 10, width - 20, height - 20, "Game Launcher");
renderer->set_font(&font_5x5_obj);
// Draw title
renderer->draw_string(30, 30, "Select a Game:", true);
renderer->draw_string_scaled(30, 40, "Select a Game:", 2);
// Draw game list
// Draw game list with GUI buttons
for (size_t i = 0; i < games.size(); i++) {
int y = MENU_Y_START + (i * MENU_ITEM_HEIGHT);
// Highlight selected item
if ((int)i == selected_index) {
// Draw selection box
renderer->draw_rectangle(20, y - 5, width - 40, MENU_ITEM_HEIGHT - 10, true, 2);
renderer->draw_string(30, y + 2, ">", true);
}
// Draw button (pressed/highlighted if selected)
bool is_selected = ((int)i == selected_index);
gui->draw_button(window, 20, y, games[i].name, is_selected, true);
// Draw game name
renderer->draw_string(45, y + 2, games[i].name, true);
// Draw description (smaller, below name)
renderer->draw_string(45, y + 15, games[i].description, true);
// Draw description below button
renderer->set_font(&font_5x5_obj); // Restore small font for description
renderer->set_text_color(true); // Normal text color
renderer->draw_string_scaled(50, y + 36, games[i].description, 1);
}
// Draw instructions at bottom
@@ -57,7 +56,8 @@ void GameLauncher::draw() {
#else
instructions = "Touch game to play";
#endif
renderer->draw_string(30, height - 35, instructions, true);
renderer->set_font(&font_5x5_obj);
renderer->draw_string_scaled(30, height - 35, instructions, 2);
}
bool GameLauncher::update(const InputEvent& event) {