Initial public release of SystemK.

This commit is contained in:
Joe Kearney 2025-01-25 13:45:14 -06:00
parent 387f57cdda
commit 6f51f5b006
129 changed files with 11654 additions and 2 deletions

View file

@ -0,0 +1,40 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 void Reset(void * Data)
{
}
static AnimationStepResult_T NextStep(void)
{
NeoPixels_Set_Color_Range_On_All_Channels(0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, COLOR_BLACK);
return ANIMATION_COMPLETE;
}
Animation_T All_Off_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View 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 © 2016-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 ALL_OFF_H
#define ALL_OFF_H
extern Animation_T All_Off_Animation;
#endif // ALL_OFF_H

View file

@ -0,0 +1,108 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 color_t All_On_Color = COLOR_WHITE;
static DisplayStyle_T All_On_Style = DISPLAY_STYLE_DEFAULT;
static uint32_t Time_in_Animation_in_ms = 0;
static void Reset(void *Data)
{
All_On_Color = ((All_On_Data_T *)Data)->color;
All_On_Style = ((All_On_Data_T *)Data)->style;
Time_in_Animation_in_ms = 0;
}
static AnimationStepResult_T NextStep(void)
{
if (All_On_Style == DISPLAY_STYLE_ALTERNATE)
{
if ((Time_in_Animation_in_ms % 500) < 250)
{
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(All_On_Color);
Set_Heart(COLOR_BLACK);
Set_Square(All_On_Color);
Set_Circle(COLOR_BLACK);
Set_Arrow(All_On_Color);
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
for (uint_fast8_t pixel = 0; pixel < CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL; pixel++)
{
if (pixel % 2)
{
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_BARREL, pixel, All_On_Color);
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, pixel, All_On_Color);
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, pixel, All_On_Color);
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, pixel, All_On_Color);
}
else
{
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_BARREL, pixel, COLOR_BLACK);
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);
}
}
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
}
else
{
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(COLOR_BLACK);
Set_Heart(All_On_Color);
Set_Square(COLOR_BLACK);
Set_Circle(All_On_Color);
Set_Arrow(COLOR_BLACK);
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
for (uint_fast8_t pixel = 0; pixel < CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL; pixel++)
{
if (pixel % 2)
{
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_BARREL, pixel, COLOR_BLACK);
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);
}
else
{
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_BARREL, pixel, All_On_Color);
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, pixel, All_On_Color);
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, pixel, All_On_Color);
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, pixel, All_On_Color);
}
}
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
}
}
else
{
NeoPixels_Set_Color_Range_On_All_Channels(0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, All_On_Color);
}
Time_in_Animation_in_ms += CONFIG_KTAG_ANIMATION_STEP_TIME_IN_ms;
return ANIMATION_ONGOING;
}
Animation_T All_On_Animation =
{
.Reset = Reset,
.NextStep = NextStep};

View file

@ -0,0 +1,27 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 ALL_ON_H
#define ALL_ON_H
extern Animation_T All_On_Animation;
#endif // ALL_ON_H

View file

@ -0,0 +1,87 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 BLENearby_T * RXd_Data;
static inline uint8_t RSSItoBrightness(int8_t RSSI)
{
uint8_t brightness = 255;
if (RSSI < 0)
{
brightness += (2*RSSI);
}
return brightness;
}
static void Reset(void * Data)
{
RXd_Data = (BLENearby_T *)Data;
}
static AnimationStepResult_T NextStep(void)
{
AnimationStepResult_T result = ANIMATION_COMPLETE;
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
// TODO: Implement the "BLE Nearby" animation for a single NeoPixel channel.
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
for (uint_fast8_t slot = 0; slot < CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL; slot++)
{
if (RXd_Data->neighbors[slot].TimeToLive_in_ms > 0)
{
//NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, slot, ApplyMask(RXd_Data->neighbors[slot].Color, RSSItoBrightness(RXd_Data->neighbors[slot].RSSI)));
// TODO: Set a low brightness, and a blink rate proportional to RSSI.
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, slot, ApplyMask(RXd_Data->neighbors[slot].Color, 25));
}
else
{
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, slot, COLOR_BLACK);
}
}
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
for (uint_fast8_t slot = 0; slot < CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL; slot++)
{
if (RXd_Data->neighbors[slot].TimeToLive_in_ms > CONFIG_KTAG_ANIMATION_STEP_TIME_IN_ms)
{
result = ANIMATION_ONGOING;
RXd_Data->neighbors[slot].TimeToLive_in_ms -= CONFIG_KTAG_ANIMATION_STEP_TIME_IN_ms;
}
else
{
RXd_Data->neighbors[slot].TimeToLive_in_ms = 0;
}
}
return result;
}
Animation_T BLE_Nearby_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View file

@ -0,0 +1,42 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 BLE_NEARBY_H
#define BLE_NEARBY_H
typedef struct
{
uint8_t BD_ADDR[6];
int8_t RSSI;
color_t Color;
uint16_t TimeToLive_in_ms;
} BLENeighbor_T;
typedef struct
{
BLENeighbor_T neighbors[CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL];
} BLENearby_T;
extern Animation_T BLE_Nearby_Animation;
#endif // BLE_NEARBY_H

View file

@ -0,0 +1,53 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 color_t RSSSIColor = (color_t) 0x00000000;
static uint8_t Brightness = 255;
static void Reset(void * Data)
{
RSSSIColor = *((color_t *)Data);
Brightness = 255 + *((int8_t *)Data) + *((int8_t *)Data);
}
static AnimationStepResult_T NextStep(void)
{
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(Color(0x00, 0x00, 0x00, 0x00));
Set_Heart(ApplyMask(RSSSIColor, Brightness));
Set_Square(ApplyMask(RSSSIColor, Brightness));
Set_Circle(ApplyMask(RSSSIColor, Brightness));
Set_Arrow(ApplyMask(RSSSIColor, Brightness));
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
NeoPixels_Set_Color_Range_On_All_Channels(0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL-1, ApplyMask(RSSSIColor, Brightness));
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
return ANIMATION_ONGOING;
}
Animation_T BLE_RSSI_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View 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 © 2016-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 BLE_RSSI_H
#define BLE_RSSI_H
extern Animation_T BLE_RSSI_Animation;
#endif // BLE_RSSI_H

View file

@ -0,0 +1,165 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 N_Lights;
static color_t My_Color = COLOR_BLACK;
static const uint8_t BRIGHTNESS = 0x7F;
static void Reset(void *Data)
{
N_Lights = *((uint8_t *)Data);
My_Color = HW_NeoPixels_Get_My_Color();
}
static AnimationStepResult_T NextStep(void)
{
switch (N_Lights)
{
case 0:
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(ApplyMask(My_Color, 0x00));
Set_Heart(ApplyMask(My_Color, 0x00));
Set_Square(ApplyMask(My_Color, 0x00));
Set_Circle(ApplyMask(My_Color, 0x00));
Set_Arrow(ApplyMask(My_Color, 0x00));
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_RECEIVER, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, 0x00));
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_DISPLAY, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, 0x00));
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_EFFECTS, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, 0x00));
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
break;
case 1:
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(ApplyMask(My_Color, 0x00));
Set_Heart(ApplyMask(My_Color, 0x00));
Set_Square(ApplyMask(My_Color, 0x00));
Set_Circle(ApplyMask(My_Color, 0x00));
Set_Arrow(ApplyMask(My_Color, BRIGHTNESS));
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, RIGHT_RECEIVER_INDICATOR_PIXEL, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, LEFT_RECEIVER_INDICATOR_PIXEL, COLOR_BLACK);
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_DISPLAY, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, 0x00));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, 4, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_EFFECTS, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, 0x00));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, 4, ApplyMask(My_Color, BRIGHTNESS));
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
break;
case 2:
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(ApplyMask(My_Color, 0x00));
Set_Heart(ApplyMask(My_Color, 0x00));
Set_Square(ApplyMask(My_Color, 0x00));
Set_Circle(ApplyMask(My_Color, BRIGHTNESS));
Set_Arrow(ApplyMask(My_Color, BRIGHTNESS));
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, RIGHT_RECEIVER_INDICATOR_PIXEL, COLOR_BLACK);
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, LEFT_RECEIVER_INDICATOR_PIXEL, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_DISPLAY, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, 0x00));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, 3, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, 4, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_EFFECTS, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, 0x00));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, 3, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, 4, ApplyMask(My_Color, BRIGHTNESS));
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
break;
case 3:
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(ApplyMask(My_Color, 0x00));
Set_Heart(ApplyMask(My_Color, 0x00));
Set_Square(ApplyMask(My_Color, BRIGHTNESS));
Set_Circle(ApplyMask(My_Color, BRIGHTNESS));
Set_Arrow(ApplyMask(My_Color, BRIGHTNESS));
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, RIGHT_RECEIVER_INDICATOR_PIXEL, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, LEFT_RECEIVER_INDICATOR_PIXEL, COLOR_BLACK);
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_DISPLAY, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, 0x00));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, 2, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, 3, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, 4, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_EFFECTS, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, 0x00));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, 2, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, 3, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, 4, ApplyMask(My_Color, BRIGHTNESS));
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
break;
case 4:
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(ApplyMask(My_Color, 0x00));
Set_Heart(ApplyMask(My_Color, BRIGHTNESS));
Set_Square(ApplyMask(My_Color, BRIGHTNESS));
Set_Circle(ApplyMask(My_Color, BRIGHTNESS));
Set_Arrow(ApplyMask(My_Color, BRIGHTNESS));
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, RIGHT_RECEIVER_INDICATOR_PIXEL, COLOR_BLACK);
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, LEFT_RECEIVER_INDICATOR_PIXEL, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_DISPLAY, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, 0x00));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, 1, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, 2, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, 3, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_DISPLAY, 4, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_EFFECTS, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, 0x00));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, 1, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, 2, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, 3, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_EFFECTS, 4, ApplyMask(My_Color, BRIGHTNESS));
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
break;
case 5:
default:
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(ApplyMask(My_Color, BRIGHTNESS));
Set_Heart(ApplyMask(My_Color, BRIGHTNESS));
Set_Square(ApplyMask(My_Color, BRIGHTNESS));
Set_Circle(ApplyMask(My_Color, BRIGHTNESS));
Set_Arrow(ApplyMask(My_Color, BRIGHTNESS));
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_RECEIVER, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_DISPLAY, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, BRIGHTNESS));
NeoPixels_Set_Color_Range(NEOPIXEL_CHANNEL_EFFECTS, 0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, ApplyMask(My_Color, BRIGHTNESS));
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
break;
}
return ANIMATION_ONGOING;
}
Animation_T Countdown_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View 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 © 2016-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 COUNTDOWN_H
#define COUNTDOWN_H
extern Animation_T Countdown_Animation;
#endif // COUNTDOWN_H

View file

@ -0,0 +1,107 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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"
#define RED_DELTA_MAX 15
#define GREEN_DELTA_MAX 8
#define MAX_RED 128
#define MIN_RED RED_DELTA_MAX
#define MIN_GREEN 1
#define LESS_GREEN_THAN_RED 20
static int16_t RedLevel = 0;
static int16_t GreenLevel = 0;
// From https://stackoverflow.com/a/1180465
static uint8_t lfsr113_Bits (uint32_t min, uint32_t max)
{
static uint32_t z1 = 12345, z2 = 12345, z3 = 12345, z4 = 12345;
uint32_t b;
b = ((z1 << 6) ^ z1) >> 13;
z1 = ((z1 & 4294967294U) << 18) ^ b;
b = ((z2 << 2) ^ z2) >> 27;
z2 = ((z2 & 4294967288U) << 2) ^ b;
b = ((z3 << 13) ^ z3) >> 21;
z3 = ((z3 & 4294967280U) << 7) ^ b;
b = ((z4 << 3) ^ z4) >> 12;
z4 = ((z4 & 4294967168U) << 13) ^ b;
uint64_t raw = (z1 ^ z2 ^ z3 ^ z4);
uint32_t scaled = ((((max - min) * raw) + (UINT32_MAX / 2)) / UINT32_MAX) + min;
return (uint8_t) scaled;
}
static void Reset(void * Data)
{
RedLevel = MIN_RED;
GreenLevel = MIN_GREEN;
}
// TODO: Need to reimplement this with HSB--see https://blog.adafruit.com/2012/03/14/constant-brightness-hsb-to-rgb-algorithm/
static AnimationStepResult_T NextStep(void)
{
// get our next changes in red and green
int16_t delta_red = (lfsr113_Bits(0, RED_DELTA_MAX*2) - RED_DELTA_MAX);
int16_t delta_green = (lfsr113_Bits(0, GREEN_DELTA_MAX*2) - GREEN_DELTA_MAX);
RedLevel = RedLevel + delta_red;
if (RedLevel > MAX_RED)
{
RedLevel = MAX_RED;
}
else if (RedLevel < MIN_RED)
{
RedLevel = MIN_RED;
}
RedLevel = (uint8_t) RedLevel;
GreenLevel = GreenLevel + delta_green;
// Green has to be less than red, to keep the flame red-orange-yellow.
if (RedLevel > LESS_GREEN_THAN_RED)
{
if (GreenLevel > (RedLevel - LESS_GREEN_THAN_RED))
{
GreenLevel = (RedLevel - LESS_GREEN_THAN_RED);
}
else if (GreenLevel < MIN_GREEN)
{
GreenLevel = MIN_GREEN;
}
}
else
{
GreenLevel = MIN_GREEN;
}
GreenLevel = (uint8_t) GreenLevel;
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_BARREL, BARREL_FLASH_PIXEL, Color(0xFF, RedLevel, GreenLevel, 0x00));
return ANIMATION_ONGOING;
}
Animation_T Flamethrower_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View 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 © 2016-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 FLAMETHROWER_H
#define FLAMETHROWER_H
extern Animation_T Flamethrower_Animation;
#endif // FLAMETHROWER_H

View file

@ -0,0 +1,40 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 void Reset(void * Data)
{
}
static AnimationStepResult_T NextStep(void)
{
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_BARREL, BARREL_FLASH_PIXEL, COLOR_WHITE);
return ANIMATION_ONGOING;
}
Animation_T Flashlight_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View 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 © 2016-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 FLASHLIGHT_H
#define FLASHLIGHT_H
extern Animation_T Flashlight_Animation;
#endif // FLASHLIGHT_H

View file

@ -0,0 +1,116 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 Health_in_percent;
static uint8_t On = 0xFF / 2;
static uint8_t Blink;
static uint8_t State = 0;
static uint16_t Time_in_Current_Scene_in_ms = 0;
static void Reset(void * Data)
{
Health_in_percent = *((uint8_t *)Data);
Time_in_Current_Scene_in_ms = 0;
}
static AnimationStepResult_T NextStep(void)
{
if (State > 1)
{
State = 0;
}
Blink = On * State;
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
if (Health_in_percent > 0) // 10
{
Set_Heart(Color(Blink, 0xFF, 0x00, 0x00));
}
if (Health_in_percent > 10) // 20 - 30
{
Set_Heart(Color(On, 0xFF, 0x00, 0x00));
}
if (Health_in_percent > 30) // 40
{
Set_Heart(Color(On, 0xFF, 0xFF, 0x00));
Set_Square(Color(Blink, 0xFF, 0xFF, 0x00));
}
if (Health_in_percent > 40) // 50
{
Set_Heart(Color(On, 0xFF, 0xFF, 0x00));
Set_Square(Color(On, 0xFF, 0xFF, 0x00));
}
if (Health_in_percent > 50) // 60
{
Set_Heart(Color(On, 0x00, 0xFF, 0x00));
Set_Square(Color(On, 0x00, 0xFF, 0x00));
Set_Circle(Color(Blink, 0x00, 0xFF, 0x00));
}
if (Health_in_percent > 60) // 70 - 80
{
Set_Heart(Color(On, 0x00, 0xFF, 0x00));
Set_Square(Color(On, 0x00, 0xFF, 0x00));
Set_Circle(Color(On, 0x00, 0xFF, 0x00));
}
if (Health_in_percent > 80) // 90 - 100
{
Set_Heart(Color(On, 0x00, 0xFF, 0x00));
Set_Square(Color(On, 0x00, 0xFF, 0x00));
Set_Circle(Color(On, 0x00, 0xFF, 0x00));
Set_Arrow(Color(Blink, 0x00, 0xFF, 0x00));
}
if (Health_in_percent == 100) // 100
{
Set_Heart(Color(On, 0x00, 0xFF, 0x00));
Set_Square(Color(On, 0x00, 0xFF, 0x00));
Set_Circle(Color(On, 0x00, 0xFF, 0x00));
Set_Arrow(Color(On, 0x00, 0xFF, 0x00));
}
Time_in_Current_Scene_in_ms += CONFIG_KTAG_ANIMATION_STEP_TIME_IN_ms;
if (Time_in_Current_Scene_in_ms > 100)
{
Time_in_Current_Scene_in_ms = 0;
State++;
}
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
// TODO: Implement the "Health Report" animation for four NeoPixel channels.
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
return ANIMATION_ONGOING;
}
Animation_T Health_Report_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View 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 © 2016-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 HEALTH_REPORT_H
#define HEALTH_REPORT_H
extern Animation_T Health_Report_Animation;
#endif // HEALTH_REPORT_H

View file

@ -0,0 +1,121 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 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 = 0;
My_Color = HW_NeoPixels_Get_My_Color();
}
static AnimationStepResult_T NextStep(void)
{
switch (Scene)
{
default:
case 0:
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_BARREL, BARREL_FLASH_PIXEL, ApplyMask(COLOR_WHITE, 0x70));
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, RECEIVER_INDICATOR_PIXEL, ApplyMask(COLOR_WHITE, 0x70));
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
break;
case 1:
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(ApplyMask(COLOR_WHITE, 0x70));
Set_Heart(COLOR_BLACK);
Set_Square(ApplyMask(My_Color, 0x70));
Set_Circle(COLOR_BLACK);
Set_Arrow(ApplyMask(My_Color, 0x70));
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
for (uint_fast8_t pixel = 0; pixel < CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL; pixel++)
{
if (pixel % 2)
{
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
break;
case 2:
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(ApplyMask(COLOR_WHITE, 0x70));
Set_Heart(ApplyMask(My_Color, 0x70));
Set_Square(COLOR_BLACK);
Set_Circle(ApplyMask(My_Color, 0x70));
Set_Arrow(COLOR_BLACK);
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
for (uint_fast8_t pixel = 0; pixel < CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL; pixel++)
{
if (pixel % 2)
{
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);
}
else
{
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));
}
}
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, RECEIVER_INDICATOR_PIXEL, ApplyMask(COLOR_WHITE, 0x70));
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
break;
}
Time_in_Current_Scene_in_ms += CONFIG_KTAG_ANIMATION_STEP_TIME_IN_ms;
if (Time_in_Current_Scene_in_ms > 500)
{
Time_in_Current_Scene_in_ms = 0;
Scene++;
if (Scene > 2)
{
Scene = 1;
}
}
return ANIMATION_ONGOING;
}
Animation_T Idle_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View 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 © 2016-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 IDLE_ANIMATION_H
#define IDLE_ANIMATION_H
extern Animation_T Idle_Animation;
#endif // IDLE_ANIMATION_H

View file

@ -0,0 +1,115 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 = 4;
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 = 0;
}
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 > 100)
{
Time_in_Current_Scene_in_ms = 0;
Scene++;
if (Scene >= N_SCENES)
{
Scene = 0;
}
}
return ANIMATION_ONGOING;
}
Animation_T Menu_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View 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 © 2016-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 MENU_ANIMATION_H
#define MENU_ANIMATION_H
extern Animation_T Menu_Animation;
#endif // MENU_ANIMATION_H

View file

@ -0,0 +1,59 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 uint16_t Time_in_Animation_in_ms = 0;
static color_t Flash_Color = COLOR_BLACK;
static void Reset(void * Data)
{
Time_in_Animation_in_ms = 0;
Flash_Color = HW_NeoPixels_Get_My_Color();
NeoPixels_Set_Color_Range_On_All_Channels(0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, COLOR_BLACK);
}
static AnimationStepResult_T NextStep(void)
{
AnimationStepResult_T result;
if (Time_in_Animation_in_ms < 250)
{
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_BARREL, BARREL_FLASH_PIXEL, Flash_Color);
Time_in_Animation_in_ms += CONFIG_KTAG_ANIMATION_STEP_TIME_IN_ms;
result = ANIMATION_ONGOING;
}
else
{
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_BARREL, BARREL_FLASH_PIXEL, COLOR_BLACK);
result = ANIMATION_COMPLETE;
}
return result;
}
Animation_T Shot_Fired_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View 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 © 2016-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 SHOT_FIRED_H
#define SHOT_FIRED_H
extern Animation_T Shot_Fired_Animation;
#endif // SHOT_FIRED_H

View file

@ -0,0 +1,70 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 uint16_t Time_in_Animation_in_ms = 0;
static color_t TagTeamColor = (color_t) 0x00000000;
static uint8_t Fade = 0x40;
static void Reset(void * Data)
{
Time_in_Animation_in_ms = 0;
TagTeamColor = *((color_t *)Data);
Fade = 128;
}
static AnimationStepResult_T NextStep(void)
{
AnimationStepResult_T result;
if (Fade < 255)
{
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(ApplyMask(TagTeamColor, Sine8[Fade]));
Set_Heart(ApplyMask(TagTeamColor, Sine8[Fade]));
Set_Square(ApplyMask(TagTeamColor, Sine8[Fade]));
Set_Circle(ApplyMask(TagTeamColor, Sine8[Fade]));
Set_Arrow(ApplyMask(TagTeamColor, Sine8[Fade]));
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_BARREL, BARREL_FLASH_PIXEL, ApplyMask(TagTeamColor, Sine8[Fade]));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, RECEIVER_INDICATOR_PIXEL, ApplyMask(TagTeamColor, Sine8[Fade]));
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
Fade += 1;
result = ANIMATION_ONGOING;
}
else
{
NeoPixels_Set_Color_Range_On_All_Channels(0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, COLOR_BLACK);
result = ANIMATION_COMPLETE;
}
return result;
}
Animation_T Tag_Received_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View 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 © 2016-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 TAG_RECEIVED_H
#define TAG_RECEIVED_H
extern Animation_T Tag_Received_Animation;
#endif // TAG_RECEIVED_H

View file

@ -0,0 +1,82 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 Fade = 0xFF;
static color_t My_Color = COLOR_BLACK;
static void Reset(void * Data)
{
Fade = 0xFF;
My_Color = HW_NeoPixels_Get_My_Color();
}
static AnimationStepResult_T NextStep(void)
{
uint8_t phase_0 = Fade;
uint8_t phase_1 = phase_0 - (uint8_t)64;
uint8_t phase_2 = phase_1 - (uint8_t)64;
uint8_t phase_3 = phase_2 - (uint8_t)64;
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(Color(Sine8[phase_0], 0xFF, 0x00, 0x00));
Set_Heart(Color(Sine8[phase_1], 0xFF, 0x00, 0x00));
Set_Square(Color(Sine8[phase_2], 0xFF, 0x00, 0x00));
Set_Circle(Color(Sine8[phase_3], 0xFF, 0x00, 0x00));
Set_Arrow(Color(Sine8[phase_0], 0xFF, 0x00, 0x00));
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
for (uint_fast8_t pixel = 0; pixel < CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL; pixel++)
{
switch (pixel % 4)
{
default:
case 0:
NeoPixels_Set_Color_On_All_Channels(pixel, ApplyMask(My_Color, Sine8[phase_0]));
break;
case 1:
NeoPixels_Set_Color_On_All_Channels(pixel, ApplyMask(My_Color, Sine8[phase_1]));
break;
case 2:
NeoPixels_Set_Color_On_All_Channels(pixel, ApplyMask(My_Color, Sine8[phase_2]));
break;
case 3:
NeoPixels_Set_Color_On_All_Channels(pixel, ApplyMask(My_Color, Sine8[phase_3]));
break;
}
}
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_BARREL, BARREL_FLASH_PIXEL, COLOR_WHITE);
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
Fade += 2;
return ANIMATION_ONGOING;
}
Animation_T Tagged_Out_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View 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 © 2016-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 TAGGED_OUT_H
#define TAGGED_OUT_H
extern Animation_T Tagged_Out_Animation;
#endif // TAGGED_OUT_H

View file

@ -0,0 +1,162 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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"
typedef enum
{
STEP_LONG_DARK,
STEP_BLINK_ONE,
STEP_BLINK_TWO,
STEP_BLINK_THREE,
STEP_HEARTBEAT_GLOW
} TeamColorsStep_T;
static DisplayStyle_T Style = DISPLAY_STYLE_BLINK;
static TeamColorsStep_T Step = STEP_LONG_DARK;
static uint16_t Time_in_Animation_Step_in_ms = 0;
static color_t Team_Color = COLOR_BLACK;
static uint8_t Brightness = 0;
static uint8_t Phase = 0;
static const uint8_t LOW_BRIGHTNESS = 10;
static const uint8_t HIGH_BRIGHTNESS = 50;
static const uint16_t LONG_DARK_TIME_IN_ms = 20000;
static const uint16_t BLINK_TIME_ON_IN_ms = 100;
static const uint16_t BLINK_TIME_OFF_IN_ms = 100;
static void Reset(void * Data)
{
// Start just before the dawn.
Time_in_Animation_Step_in_ms = LONG_DARK_TIME_IN_ms;
Style = NeoPixels_ToDisplayStyle(Data);
Team_Color = HW_NeoPixels_Get_My_Color();
NeoPixels_Set_Color_Range_On_All_Channels(0, CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL - 1, COLOR_BLACK);
}
static AnimationStepResult_T NextStep(void)
{
Time_in_Animation_Step_in_ms += CONFIG_KTAG_ANIMATION_STEP_TIME_IN_ms;
switch (Step)
{
default:
case STEP_LONG_DARK:
Brightness = LOW_BRIGHTNESS;
if (Time_in_Animation_Step_in_ms > LONG_DARK_TIME_IN_ms)
{
Time_in_Animation_Step_in_ms = 0;
if (Style == DISPLAY_STYLE_HEARTBEAT)
{
Step = STEP_HEARTBEAT_GLOW;
Phase = 0;
}
else
{
Step = STEP_BLINK_ONE;
}
}
break;
case STEP_BLINK_ONE:
if (Time_in_Animation_Step_in_ms > (BLINK_TIME_ON_IN_ms + BLINK_TIME_OFF_IN_ms))
{
Brightness = HIGH_BRIGHTNESS;
Time_in_Animation_Step_in_ms = 0;
Step = STEP_BLINK_TWO;
}
else if (Time_in_Animation_Step_in_ms > BLINK_TIME_ON_IN_ms)
{
Brightness = LOW_BRIGHTNESS;
}
else
{
Brightness = HIGH_BRIGHTNESS;
}
break;
case STEP_BLINK_TWO:
if (Time_in_Animation_Step_in_ms > (BLINK_TIME_ON_IN_ms + BLINK_TIME_OFF_IN_ms))
{
Brightness = HIGH_BRIGHTNESS;
Time_in_Animation_Step_in_ms = 0;
Step = STEP_BLINK_THREE;
}
else if (Time_in_Animation_Step_in_ms > BLINK_TIME_ON_IN_ms)
{
Brightness = LOW_BRIGHTNESS;
}
else
{
Brightness = HIGH_BRIGHTNESS;
}
break;
case STEP_BLINK_THREE:
if (Time_in_Animation_Step_in_ms > (BLINK_TIME_ON_IN_ms + BLINK_TIME_OFF_IN_ms))
{
Brightness = LOW_BRIGHTNESS;
Time_in_Animation_Step_in_ms = 0;
Step = STEP_LONG_DARK;
}
else if (Time_in_Animation_Step_in_ms > BLINK_TIME_ON_IN_ms)
{
Brightness = LOW_BRIGHTNESS;
}
else
{
Brightness = HIGH_BRIGHTNESS;
}
break;
case STEP_HEARTBEAT_GLOW:
Brightness = Sine8[Phase] / 2;
Phase++;
if (Phase == 0)
{
Brightness = LOW_BRIGHTNESS;
Time_in_Animation_Step_in_ms = 0;
Step = STEP_LONG_DARK;
}
break;
}
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
Set_Barrel_Flash(ApplyMask(Team_Color, Brightness));
Set_Heart(COLOR_BLACK);
Set_Square(COLOR_BLACK);
Set_Circle(COLOR_BLACK);
Set_Arrow(COLOR_BLACK);
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, RECEIVER_INDICATOR_PIXEL, ApplyMask(Team_Color, Brightness));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, RIGHT_RECEIVER_INDICATOR_PIXEL, ApplyMask(Team_Color, Brightness));
NeoPixels_Set_Color(NEOPIXEL_CHANNEL_RECEIVER, LEFT_RECEIVER_INDICATOR_PIXEL, ApplyMask(Team_Color, Brightness));
#endif // CONFIG_KTAG_N_NEOPIXEL_CHANNELS
return ANIMATION_ONGOING;
}
Animation_T Team_Colors_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View 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 © 2016-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 TEAM_COLORS_H
#define TEAM_COLORS_H
extern Animation_T Team_Colors_Animation;
#endif // TEAM_COLORS_H

View file

@ -0,0 +1,116 @@
/*
* This program source code file is part of SystemK, a library in the KTag project.
*
* 🛡 <https://ktag.clubk.club> 🃞
*
* Copyright © 2016-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 uint16_t Time_in_Current_Scene_in_ms = 0;
static void Reset(void * Data)
{
Time_in_Current_Scene_in_ms = 0;
Scene = 0;
}
static AnimationStepResult_T NextStep(void)
{
#if (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 1)
switch (Scene)
{
default:
case 0:
Set_Barrel_Flash(Color(0xFF, 0xFF, 0x00, 0x00));
Set_Heart(Color(0xFF / 2, 0xFF, 0x00, 0x00));
Set_Square(Color(0xFF / 2, 0x00, 0xFF, 0x00));
Set_Circle(Color(0xFF / 2, 0xFF, 0x00, 0xFF));
Set_Arrow(Color(0xFF / 2, 0xFF, 0xFF, 0x00));
break;
case 1:
Set_Barrel_Flash(Color(0xFF, 0xFF, 0xFF, 0xFF));
Set_Heart(Color(0xFF / 2, 0xFF, 0xFF, 0x00));
Set_Square(Color(0xFF / 2, 0xFF, 0x00, 0x00));
Set_Circle(Color(0xFF / 2, 0x00, 0xFF, 0x00));
Set_Arrow(Color(0xFF / 2, 0xFF, 0x00, 0xFF));
break;
case 2:
Set_Barrel_Flash(Color(0xFF, 0x00, 0x00, 0xFF));
Set_Heart(Color(0xFF / 2, 0xFF, 0x00, 0xFF));
Set_Square(Color(0xFF / 2, 0xFF, 0xFF, 0x00));
Set_Circle(Color(0xFF / 2, 0xFF, 0x00, 0x00));
Set_Arrow(Color(0xFF / 2, 0x00, 0xFF, 0x00));
break;
case 3:
Set_Barrel_Flash(Color(0xFF, 0x00, 0x00, 0x00));
Set_Heart(Color(0xFF / 2, 0x00, 0xFF, 0x00));
Set_Square(Color(0xFF / 2, 0xFF, 0x00, 0xFF));
Set_Circle(Color(0xFF / 2, 0xFF, 0xFF, 0x00));
Set_Arrow(Color(0xFF / 2, 0xFF, 0x00, 0x00));
break;
}
#elif (CONFIG_KTAG_N_NEOPIXEL_CHANNELS == 4)
for (uint_fast8_t pixel = 0; pixel < CONFIG_KTAG_MAX_NEOPIXELS_PER_CHANNEL; pixel++)
{
switch ((pixel + Scene) % 4)
{
default:
case 0:
NeoPixels_Set_Color_On_All_Channels(pixel, ApplyMask(COLOR_RED, 0xFF / 2));
break;
case 1:
NeoPixels_Set_Color_On_All_Channels(pixel, ApplyMask(COLOR_WHITE, 0xFF / 2));
break;
case 2:
NeoPixels_Set_Color_On_All_Channels(pixel, ApplyMask(COLOR_BLUE, 0xFF / 2));
break;
case 3:
NeoPixels_Set_Color_On_All_Channels(pixel, COLOR_BLACK);
break;
}
}
#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 > 100)
{
Time_in_Current_Scene_in_ms = 0;
Scene++;
if (Scene > 3)
{
Scene = 0;
}
}
return ANIMATION_ONGOING;
}
Animation_T Test_Pattern_Animation =
{
.Reset = Reset,
.NextStep = NextStep
};

View 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 © 2016-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 TEST_PATTERN_H
#define TEST_PATTERN_H
extern Animation_T Test_Pattern_Animation;
#endif // TEST_PATTERN_H