Initial public release of SystemK.
This commit is contained in:
parent
387f57cdda
commit
6f51f5b006
129 changed files with 11654 additions and 2 deletions
109
States/State_Wrapping_Up.c
Normal file
109
States/State_Wrapping_Up.c
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* 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 Files */
|
||||
#include "SystemK.h"
|
||||
|
||||
static const char *KLOG_TAG = "STATE_WRAPPING_UP";
|
||||
|
||||
static const uint16_t LONG_PRESS_FOR_CONFIGURING_in_ms = 5000;
|
||||
|
||||
static void Wrapping_Up_Entry(StateMachineContext_T * context);
|
||||
static void Wrapping_Up_Do(StateMachineContext_T * context);
|
||||
static void Wrapping_Up_Exit(StateMachineContext_T * context);
|
||||
|
||||
//! Activities for the **Wrapping Up** state.
|
||||
const StateActivity_T STATE_WRAPPING_UP_Activities =
|
||||
{
|
||||
.Entry = Wrapping_Up_Entry,
|
||||
.Do = Wrapping_Up_Do,
|
||||
.Exit = Wrapping_Up_Exit
|
||||
};
|
||||
|
||||
//! Sets up the Wrapping Up state.
|
||||
/*!
|
||||
* \param context Context in which this state is being run.
|
||||
*/
|
||||
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};
|
||||
xQueueSend(xQueueNeoPixels, &neopixels_action, 0);
|
||||
BLE_UpdateStatusPacket();
|
||||
if (BLE_ScanAndAdvertise() != SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
KLOG_ERROR(KLOG_TAG, "Couldn't start BLE!");
|
||||
}
|
||||
}
|
||||
|
||||
//! Executes the Wrapping Up state.
|
||||
/*!
|
||||
* \param context Context in which this state is being run.
|
||||
*/
|
||||
static void Wrapping_Up_Do(StateMachineContext_T * context)
|
||||
{
|
||||
portBASE_TYPE xStatus;
|
||||
static KEvent_T Event;
|
||||
|
||||
xStatus = Receive_KEvent(&Event);
|
||||
|
||||
if (xStatus == pdPASS)
|
||||
{
|
||||
switch (Event.ID)
|
||||
{
|
||||
case KEVENT_TRIGGER_SWITCH_PRESSED:
|
||||
break;
|
||||
|
||||
case KEVENT_TRIGGER_SWITCH_RELEASED:
|
||||
{
|
||||
uint32_t duration_of_press_in_ms = (uint32_t)Event.Data;
|
||||
|
||||
if (duration_of_press_in_ms > LONG_PRESS_FOR_CONFIGURING_in_ms)
|
||||
{
|
||||
Transition_For_Event(context, STATE_CONFIGURING, &Event);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case KEVENT_BLE_PACKET_RECEIVED:
|
||||
// TODO
|
||||
BLE_FreePacketBuffer(Event.Data);
|
||||
break;
|
||||
|
||||
default:
|
||||
// All other events are ignored in this state.
|
||||
ProcessUnhandledEvent(&Event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Cleans up the Wrapping Up state.
|
||||
/*!
|
||||
* \param context Context in which this state is being run.
|
||||
*/
|
||||
static void Wrapping_Up_Exit(StateMachineContext_T * context)
|
||||
{
|
||||
NeoPixelsAction_T neopixels_action = {.ID = NEOPIXELS_ALL_OFF, .Prominence = NEOPIXELS_FOREGROUND, .Data = (void *)0x00};
|
||||
xQueueSend(xQueueNeoPixels, &neopixels_action, 0);
|
||||
AudioAction_T audio_action = {.ID = AUDIO_SILENCE, .Data = (void *)0x00};
|
||||
Perform_Audio_Action(&audio_action);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue