/* * This program source code file is part of SystemK, a library in the KTag project. * * 🛡️ 🃞 * * 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 . */ #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 };