feat: change display refresh rate to 60

This commit is contained in:
dark98
2026-09-25 21:02:27 +01:00
parent 59b0318579
commit 31b93c2a9a
2 changed files with 28 additions and 15 deletions
+13 -1
View File
@@ -58,7 +58,11 @@ static void game_update(uint32_t delta_ms)
}
if (s_game_state == GAME_STATE_PLAYING) {
static uint32_t jump_acc = 0;
if (s_is_jumping) {
jump_acc += delta_ms;
if (jump_acc >= 45) {
jump_acc = 0;
s_player_y += s_player_vy;
s_player_vy += 1;
if (s_player_y >= GROUND_Y) {
@@ -67,14 +71,22 @@ static void game_update(uint32_t delta_ms)
s_is_jumping = false;
}
}
} else {
jump_acc = 0;
}
s_obs_x -= 3;
static uint32_t move_acc = 0;
move_acc += delta_ms;
if (move_acc >= 16) {
move_acc = 0;
s_obs_x -= 1;
if (s_obs_x < -4) {
s_obs_x = 72 + (rand() % 16);
s_obs_h = 5 + (rand() % 5);
s_score++;
if (s_score > s_high_score) s_high_score = s_score;
}
}
if (s_obs_x <= 13 && (s_obs_x + 3) >= 8) {
if ((s_player_y - 1) >= (GROUND_Y - s_obs_h + 1)) {
+4 -3
View File
@@ -1,4 +1,4 @@
#include <stdio.h>
#include <stdio.h>
#include <inttypes.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
@@ -25,7 +25,7 @@ static const char *TAG = "MICRO_OS";
#define PIN_LED_USER GPIO_NUM_8
#define PIN_BUTTON_BOOT GPIO_NUM_9
#define UI_REFRESH_HZ 20
#define UI_REFRESH_HZ 60
#define UI_FRAME_MS (1000 / UI_REFRESH_HZ)
/* Task: Onboard LED Heartbeat */
@@ -62,6 +62,7 @@ static void on_input_event(input_action_t action, void *user_arg)
static void os_ui_task(void *pvParameters)
{
ESP_LOGI(TAG, "Starting UI compositor loop @ %d FPS", UI_REFRESH_HZ);
TickType_t last_wake_time = xTaskGetTickCount();
uint32_t last_time_ms = (uint32_t)(esp_timer_get_time() / 1000ULL);
while (1) {
@@ -75,7 +76,7 @@ static void os_ui_task(void *pvParameters)
sys_gfx_render_toast_if_active();
sys_gfx_flush();
vTaskDelay(pdMS_TO_TICKS(UI_FRAME_MS));
vTaskDelayUntil(&last_wake_time, pdMS_TO_TICKS(UI_FRAME_MS));
}
}