web
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
#include "index.h"
|
||||
#include "fonts.h"
|
||||
#include "lowLevel.h"
|
||||
#include "upload_page.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
#ifdef __AVR__
|
||||
@@ -25,6 +24,16 @@ unsigned char bottom_text_state = 0;
|
||||
unsigned char scroll_node_global_id = 0;
|
||||
bool scroll_node_active = false;
|
||||
|
||||
bool program2_active = false;
|
||||
unsigned char bottom_text_iteration_count = 0;
|
||||
|
||||
bool program_top_text_enabled = true;
|
||||
bool program_bottom_text_enabled = true;
|
||||
bool program_vehicles_enabled = true;
|
||||
unsigned char program2_vehicles_spawned = 0;
|
||||
short program2_drain_counter = 0;
|
||||
bool program2_done = false;
|
||||
|
||||
Image saved_images[MAX_IMAGES_SAVED] = {
|
||||
{},{}
|
||||
};
|
||||
@@ -526,7 +535,20 @@ void resetGlobalIdToAfterIntroValue()
|
||||
|
||||
void handleProgram1()
|
||||
{
|
||||
if (!main_animation_started)
|
||||
// --- Top text section ---
|
||||
if (!program_top_text_enabled)
|
||||
{
|
||||
// Kill existing multi-color node if any
|
||||
for (unsigned char i = 0; i < MAX_TEXT_NODES_COUNT; i++)
|
||||
{
|
||||
if (multi_color_text_node[i].disappear_time != 0)
|
||||
{
|
||||
multi_color_text_node[i].disappear_time = 1;
|
||||
}
|
||||
}
|
||||
main_animation_started = false;
|
||||
}
|
||||
else if (!main_animation_started)
|
||||
{
|
||||
if (!isNodeExistingByGlobal(0) && !isNodeExistingByGlobal(1))
|
||||
{
|
||||
@@ -541,10 +563,54 @@ void handleProgram1()
|
||||
}
|
||||
}
|
||||
|
||||
// --- Bottom text section ---
|
||||
if (!program_bottom_text_enabled)
|
||||
{
|
||||
// Kill active scroll node if any
|
||||
if (scroll_node_active)
|
||||
{
|
||||
for (unsigned char i = 0; i < MAX_TEXT_NODES_COUNT; i++)
|
||||
{
|
||||
if (text_nodes[i].disappear_time != 0)
|
||||
{
|
||||
text_nodes[i].disappear_time = 1;
|
||||
}
|
||||
}
|
||||
scroll_node_active = false;
|
||||
}
|
||||
if (program2_active)
|
||||
{
|
||||
program2_active = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip bottom text management if vehicles are active
|
||||
if (program2_active) return;
|
||||
|
||||
// Bottom row: alternating scrolling texts
|
||||
if (main_animation_started &&
|
||||
if ((main_animation_started || !program_top_text_enabled) &&
|
||||
(!scroll_node_active || !isNodeExistingByGlobal(scroll_node_global_id)))
|
||||
{
|
||||
// A bottom text just finished — check if we should trigger vehicles
|
||||
if (scroll_node_active)
|
||||
{
|
||||
bottom_text_iteration_count++;
|
||||
scroll_node_active = false;
|
||||
|
||||
if (program_vehicles_enabled && bottom_text_iteration_count >= PROGRAM2_TEXT_ITERATIONS)
|
||||
{
|
||||
bottom_text_iteration_count = 0;
|
||||
if ((unsigned char)random(0, 100) < PROGRAM2_TRIGGER_CHANCE)
|
||||
{
|
||||
program2_active = true;
|
||||
resetProgram2();
|
||||
fillPixels(0, 9, DISPLAY_MAX_X, DISPLAY_MAX_Y, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextNode* node = nullptr;
|
||||
if (bottom_text_state == 0)
|
||||
{
|
||||
@@ -596,7 +662,16 @@ void drawVehichle(unsigned char index = 0, short pos_x = 0, short pos_y = 0)
|
||||
unsigned char program2_scroll_progress = 0;
|
||||
short program2_spacing_counter = 0;
|
||||
|
||||
void handleProgram2(unsigned char spacing = 4, unsigned char scroll_slowness = 1, short y = 0)
|
||||
void resetProgram2()
|
||||
{
|
||||
program2_scroll_progress = 0;
|
||||
program2_spacing_counter = 0;
|
||||
program2_vehicles_spawned = 0;
|
||||
program2_drain_counter = 0;
|
||||
program2_done = false;
|
||||
}
|
||||
|
||||
void handleProgram2(unsigned char spacing = 4, unsigned char scroll_slowness = 1, short y = 0, unsigned char max_vehicles = 0)
|
||||
{
|
||||
if (scroll_slowness > program2_scroll_progress)
|
||||
{
|
||||
@@ -607,11 +682,26 @@ void handleProgram2(unsigned char spacing = 4, unsigned char scroll_slowness = 1
|
||||
|
||||
shiftGivenRectangleLeft(0, y, DISPLAY_MAX_X, y + 3, 1);
|
||||
|
||||
// If we have a vehicle limit and reached it, drain remaining vehicles off screen
|
||||
if (max_vehicles > 0 && program2_vehicles_spawned >= max_vehicles)
|
||||
{
|
||||
program2_drain_counter++;
|
||||
if (program2_drain_counter >= DISPLAY_MAX_X + 1)
|
||||
{
|
||||
program2_done = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
program2_spacing_counter--;
|
||||
if (program2_spacing_counter <= 0)
|
||||
{
|
||||
drawVehichle(random(0, 11), DISPLAY_MAX_X - 7, y);
|
||||
program2_spacing_counter = 8 + spacing;
|
||||
if (max_vehicles > 0)
|
||||
{
|
||||
program2_vehicles_spawned++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -632,13 +722,50 @@ void loop()
|
||||
{
|
||||
handle_server();
|
||||
|
||||
handleProgram2(4, 1, 0);
|
||||
// Clear top area for text redraw
|
||||
fillPixels(0, 0, DISPLAY_MAX_X, 7, 0);
|
||||
|
||||
// Manage top text + bottom state machine
|
||||
handleProgram1();
|
||||
|
||||
// Draw/scroll top "Witamy w PTI" (skip if disabled — area already cleared)
|
||||
if (program_top_text_enabled)
|
||||
{
|
||||
scrollAllMultiColorTexts(true);
|
||||
handleMultiColorDisappearTimers();
|
||||
}
|
||||
|
||||
// Handle bottom text disable mid-frame
|
||||
if (!program_bottom_text_enabled)
|
||||
{
|
||||
if (program2_active)
|
||||
{
|
||||
program2_active = false;
|
||||
}
|
||||
fillPixels(0, 9, DISPLAY_MAX_X, DISPLAY_MAX_Y, 0);
|
||||
}
|
||||
// Handle vehicles disabled while vehicle animation active
|
||||
else if (program2_active && !program_vehicles_enabled)
|
||||
{
|
||||
program2_active = false;
|
||||
fillPixels(0, 9, DISPLAY_MAX_X, DISPLAY_MAX_Y, 0);
|
||||
}
|
||||
else if (program2_active)
|
||||
{
|
||||
handleProgram2(4, 1, 12, PROGRAM2_VEHICLE_COUNT);
|
||||
if (program2_done)
|
||||
{
|
||||
program2_active = false;
|
||||
fillPixels(0, 9, DISPLAY_MAX_X, DISPLAY_MAX_Y, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear bottom area for text redraw
|
||||
fillPixels(0, 9, DISPLAY_MAX_X, DISPLAY_MAX_Y, 0);
|
||||
scrollAllScrollableTexts(true);
|
||||
handleDisappearTimers();
|
||||
}
|
||||
|
||||
// pixels.clear();
|
||||
// handleProgram1();
|
||||
// handleDisappearTimers();
|
||||
// handleMultiColorDisappearTimers();
|
||||
// scrollAllScrollableTexts(true);
|
||||
// scrollAllMultiColorTexts(true);
|
||||
pixels.show();
|
||||
}
|
||||
Reference in New Issue
Block a user