Added animation for the Wrapping Up state.
This commit is contained in:
parent
e914558e63
commit
c034427c3c
6 changed files with 157 additions and 3 deletions
|
@ -32,6 +32,7 @@ idf_component_register(
|
|||
"NeoPixels/Animations/Tag_Received.c"
|
||||
"NeoPixels/Animations/Team_Colors.c"
|
||||
"NeoPixels/Animations/Test_Pattern.c"
|
||||
"NeoPixels/Animations/Wrapping_Up_Animation.c"
|
||||
"Protocols/Dubuque.c"
|
||||
"Protocols/Dynasty.c"
|
||||
"Protocols/Laser_X.c"
|
||||
|
|
119
NeoPixels/Animations/Wrapping_Up_Animation.c
Normal file
119
NeoPixels/Animations/Wrapping_Up_Animation.c
Normal file
|
@ -0,0 +1,119 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
* 🛡️ <https://ktag.clubk.club> 🃞
|
||||
*
|
||||
* Copyright © 2025 Joseph P. Kearney and the KTag developers.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* There should be a copy of the GNU Affero General Public License in the LICENSE
|
||||
* file in the root of this repository. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "SystemK.h"
|
||||
|
||||
static uint8_t Scene = 0;
|
||||
static uint8_t N_SCENES = 8;
|
||||
static uint16_t Time_in_Current_Scene_in_ms = 0;
|
||||
static color_t My_Color = COLOR_BLACK;
|
||||
|
||||
static void Reset(void * Data)
|
||||
{
|
||||
Time_in_Current_Scene_in_ms = 0;
|
||||
Scene = N_SCENES - 1;
|
||||
}
|
||||
|
||||
static AnimationStepResult_T NextStep(void)
|
||||
{
|
||||
My_Color = HW_NeoPixels_Get_My_Color();
|
||||
|
||||
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
|
||||
switch (Scene)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
Set_Barrel_Flash(Color(0x70, 0xFF, 0xFF, 0xFF));
|
||||
Set_Heart(Color(0x00, 0x00, 0x00, 0x00));
|
||||
Set_Square(Color(0x00, 0x00, 0x00, 0x00));
|
||||
Set_Circle(Color(0x00, 0x00, 0x00, 0x00));
|
||||
Set_Arrow(ApplyMask(My_Color, 0x70));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
Set_Barrel_Flash(Color(0x00, 0x00, 0x00, 0x00));
|
||||
Set_Heart(Color(0x00, 0x00, 0x00, 0x00));
|
||||
Set_Square(Color(0x00, 0x00, 0x00, 0x00));
|
||||
Set_Circle(ApplyMask(My_Color, 0x70));
|
||||
Set_Arrow(Color(0x00, 0x00, 0x00, 0x00));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
Set_Barrel_Flash(Color(0x70, 0xFF, 0xFF, 0xFF));
|
||||
Set_Heart(Color(0x00, 0x00, 0x00, 0x00));
|
||||
Set_Square(ApplyMask(My_Color, 0x70));
|
||||
Set_Circle(Color(0x00, 0x00, 0x00, 0x00));
|
||||
Set_Arrow(Color(0x00, 0x00, 0x00, 0x00));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
Set_Barrel_Flash(Color(0x00, 0x00, 0x00, 0x00));
|
||||
Set_Heart(ApplyMask(My_Color, 0x70));
|
||||
Set_Square(Color(0x00, 0x00, 0x00, 0x00));
|
||||
Set_Circle(Color(0x00, 0x00, 0x00, 0x00));
|
||||
Set_Arrow(Color(0x00, 0x00, 0x00, 0x00));
|
||||
break;
|
||||
}
|
||||
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
|
||||
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_BARREL, BARREL_FLASH_PIXEL, ApplyMask(COLOR_WHITE, 0x70));
|
||||
for (uint_fast8_t pixel = 0; pixel < CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL; pixel++)
|
||||
{
|
||||
if ((pixel % N_SCENES) == Scene)
|
||||
{
|
||||
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, pixel, ApplyMask(My_Color, 0x70));
|
||||
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, pixel, ApplyMask(My_Color, 0x70));
|
||||
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, pixel, ApplyMask(My_Color, 0x70));
|
||||
}
|
||||
else
|
||||
{
|
||||
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, pixel, COLOR_BLACK);
|
||||
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, pixel, COLOR_BLACK);
|
||||
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, pixel, COLOR_BLACK);
|
||||
}
|
||||
}
|
||||
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, RECEIVER_INDICATOR_PIXEL, ApplyMask(COLOR_WHITE, 0x70));
|
||||
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
|
||||
|
||||
Time_in_Current_Scene_in_ms += CONFIG_KTAG_ANIMATION_STEP_TIME_IN_ms;
|
||||
|
||||
if (Time_in_Current_Scene_in_ms > 25)
|
||||
{
|
||||
Time_in_Current_Scene_in_ms = 0;
|
||||
|
||||
if (Scene > 0)
|
||||
{
|
||||
Scene--;
|
||||
}
|
||||
else
|
||||
{
|
||||
Scene = N_SCENES - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return ANIMATION_ONGOING;
|
||||
}
|
||||
|
||||
Animation_T Wrapping_Up_Animation =
|
||||
{
|
||||
.Reset = Reset,
|
||||
.NextStep = NextStep
|
||||
};
|
28
NeoPixels/Animations/Wrapping_Up_Animation.h
Normal file
28
NeoPixels/Animations/Wrapping_Up_Animation.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
/*
|
||||
* This program source code file is part of SystemK, a library in the KTag project.
|
||||
*
|
||||
* 🛡️ <https://ktag.clubk.club> 🃞
|
||||
*
|
||||
* Copyright © 2025 Joseph P. Kearney and the KTag developers.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* There should be a copy of the GNU Affero General Public License in the LICENSE
|
||||
* file in the root of this repository. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef WRAPPING_UP_ANIMATION_H
|
||||
#define WRAPPING_UP_ANIMATION_H
|
||||
|
||||
extern Animation_T Wrapping_Up_Animation;
|
||||
|
||||
#endif // WRAPPING_UP_ANIMATION_H
|
|
@ -120,6 +120,10 @@ void NeoPixels_Task(void * pvParameters)
|
|||
case NEOPIXELS_BLE_NEARBY:
|
||||
New_Animation = &BLE_Nearby_Animation;
|
||||
break;
|
||||
|
||||
case NEOPIXELS_WRAPPING_UP:
|
||||
New_Animation = &Wrapping_Up_Animation;
|
||||
break;
|
||||
}
|
||||
|
||||
if (New_Animation != NULL)
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
#include "Animations/Tagged_Out.h"
|
||||
#include "Animations/Team_Colors.h"
|
||||
#include "Animations/Test_Pattern.h"
|
||||
#include "Animations/Wrapping_Up_Animation.h"
|
||||
|
||||
extern QueueHandle_t xQueueNeoPixels;
|
||||
extern TaskHandle_t NeoPixels_Task_Handle;
|
||||
|
@ -138,8 +139,9 @@ typedef enum
|
|||
NEOPIXELS_COUNTDOWN,
|
||||
//! For #NEOPIXELS_TEAM_COLORS, #NeoPixelsAction_T::Data is a #DisplayStyle_T.
|
||||
NEOPIXELS_TEAM_COLORS,
|
||||
//! For #NEOPIXELS_TEAM_COLORS, #NeoPixelsAction_T::Data is a #BLENearby_T.
|
||||
NEOPIXELS_BLE_NEARBY
|
||||
//! For #NEOPIXELS_BLE_NEARBY, #NeoPixelsAction_T::Data is a #BLENearby_T.
|
||||
NEOPIXELS_BLE_NEARBY,
|
||||
NEOPIXELS_WRAPPING_UP
|
||||
} NeoPixelsActionID_T;
|
||||
|
||||
typedef enum
|
||||
|
|
|
@ -54,7 +54,7 @@ const StateActivity_T STATE_WRAPPING_UP_Activities =
|
|||
static void Wrapping_Up_Entry(StateMachineContext_T * context)
|
||||
{
|
||||
LOG("Entering the Wrapping Up state.");
|
||||
NeoPixelsAction_T neopixels_action = {.ID = NEOPIXELS_IDLE, .Prominence = NEOPIXELS_FOREGROUND, .Data = (void *)0x00};
|
||||
NeoPixelsAction_T neopixels_action = {.ID = NEOPIXELS_WRAPPING_UP, .Prominence = NEOPIXELS_FOREGROUND, .Data = (void *)0x00};
|
||||
xQueueSend(xQueueNeoPixels, &neopixels_action, 0);
|
||||
BLE_UpdateStatusPacket(STATE_WRAPPING_UP);
|
||||
if (BLE_ScanAndAdvertise() != SYSTEMK_RESULT_SUCCESS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue