Converted initialization to use System Events.
This commit is contained in:
parent
0dcbae7ec6
commit
c3362d42af
17 changed files with 243 additions and 58 deletions
|
|
@ -1,3 +1,25 @@
|
|||
/*
|
||||
* This program source code file is part of the KTag project, a DIY laser tag
|
||||
* game with customizable features and wide interoperability.
|
||||
*
|
||||
* 🛡️ <https://ktag.clubk.club> 🃞
|
||||
*
|
||||
* Copyright © 2024-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>
|
||||
#include <System_Events.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -150,6 +172,9 @@ void Initialize_Audio(void)
|
|||
{
|
||||
KLOG_ERROR(TAG, "Couldn't create the I2S Audio task.");
|
||||
}
|
||||
|
||||
xEventGroupSetBits(Get_System_Events(), SYS_AUDIO_READY);
|
||||
KLOG_INFO(TAG, "Initialization complete.");
|
||||
}
|
||||
|
||||
esp_err_t Play_Audio_File(const char *filename)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,25 @@
|
|||
/*
|
||||
* This program source code file is part of the KTag project, a DIY laser tag
|
||||
* game with customizable features and wide interoperability.
|
||||
*
|
||||
* 🛡️ <https://ktag.clubk.club> 🃞
|
||||
*
|
||||
* Copyright © 2024-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 "esp_err.h"
|
||||
|
||||
void Initialize_Audio(void);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,27 @@
|
|||
/*
|
||||
* This program source code file is part of the KTag project, a DIY laser tag
|
||||
* game with customizable features and wide interoperability.
|
||||
*
|
||||
* 🛡️ <https://ktag.clubk.club> 🃞
|
||||
*
|
||||
* Copyright © 2024-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>
|
||||
#include <System_Events.h>
|
||||
#include "esp_log.h"
|
||||
/* BLE */
|
||||
#include "esp_nimble_hci.h"
|
||||
|
|
@ -204,6 +227,9 @@ void Initialize_BLE(void)
|
|||
ble_store_config_init();
|
||||
|
||||
nimble_port_freertos_init(ble_host_task);
|
||||
|
||||
xEventGroupSetBits(Get_System_Events(), SYS_BLE_READY);
|
||||
KLOG_INFO(TAG, "Initialization complete.");
|
||||
}
|
||||
|
||||
void Disable_BLE(void)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,25 @@
|
|||
/*
|
||||
* This program source code file is part of the KTag project, a DIY laser tag
|
||||
* game with customizable features and wide interoperability.
|
||||
*
|
||||
* 🛡️ <https://ktag.clubk.club> 🃞
|
||||
*
|
||||
* Copyright © 2024-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 "esp_err.h"
|
||||
|
||||
void Initialize_BLE(void);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ idf_component_register(
|
|||
"."
|
||||
REQUIRES
|
||||
"SystemK"
|
||||
"System_Events"
|
||||
"driver"
|
||||
"bt"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -5,5 +5,6 @@ idf_component_register(
|
|||
"."
|
||||
REQUIRES
|
||||
"SystemK"
|
||||
"System_Events"
|
||||
"driver"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
*/
|
||||
|
||||
#include <SystemK.h>
|
||||
#include <System_Events.h>
|
||||
#include <IR.h>
|
||||
#include <driver/gpio.h>
|
||||
#include <driver/rmt_tx.h>
|
||||
|
|
@ -272,7 +273,7 @@ static void Initialize_Receive_Task(void)
|
|||
}
|
||||
}
|
||||
|
||||
void Initialize_IR(SemaphoreHandle_t init_complete)
|
||||
void Initialize_IR()
|
||||
{
|
||||
KLOG_INFO(TAG, "Initializing IR...");
|
||||
|
||||
|
|
@ -375,7 +376,8 @@ void Initialize_IR(SemaphoreHandle_t init_complete)
|
|||
ESP_ERROR_CHECK(rmt_enable(Right_Rx_Channel));
|
||||
ESP_ERROR_CHECK(rmt_receive(Right_Rx_Channel, &Right_Rxd_RMT_Data, sizeof(Right_Rxd_RMT_Data.pulsetrain), &Rx_Config));
|
||||
|
||||
xSemaphoreGive(init_complete);
|
||||
xEventGroupSetBits(Get_System_Events(), SYS_IR_READY);
|
||||
KLOG_INFO(TAG, "Initialization complete.");
|
||||
}
|
||||
|
||||
static inline void PrintPulseTrainToConsole(TimedPulseTrain_T *train)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@
|
|||
|
||||
#include "esp_err.h"
|
||||
|
||||
void Initialize_IR(SemaphoreHandle_t init_complete);
|
||||
void Initialize_IR();
|
||||
void Enable_IR_Transmit();
|
||||
void Disable_IR_Transmit();
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
static const char *TAG = "SPIFFS";
|
||||
const char *DEFAULT_CONFIG_FILE = "/spiffs/default_config.txt";
|
||||
|
||||
void Initialize_SPIFFS(SemaphoreHandle_t init_complete)
|
||||
void Initialize_SPIFFS(void)
|
||||
{
|
||||
KLOG_INFO(TAG, "Initializing SPI flash file system (SPIFFS)...");
|
||||
|
||||
|
|
@ -84,6 +84,4 @@ void Initialize_SPIFFS(SemaphoreHandle_t init_complete)
|
|||
|
||||
xEventGroupSetBits(Get_System_Events(), SYS_SPIFFS_READY);
|
||||
KLOG_INFO(TAG, "SPIFFS initialized.");
|
||||
|
||||
xSemaphoreGive(init_complete);
|
||||
}
|
||||
|
|
@ -21,6 +21,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
void Initialize_SPIFFS(SemaphoreHandle_t init_complete);
|
||||
void Initialize_SPIFFS(void);
|
||||
|
||||
extern const char *DEFAULT_CONFIG_FILE;
|
||||
|
|
@ -1,3 +1,25 @@
|
|||
/*
|
||||
* This program source code file is part of the KTag project, a DIY laser tag
|
||||
* game with customizable features and wide interoperability.
|
||||
*
|
||||
* 🛡️ <https://ktag.clubk.club> 🃞
|
||||
*
|
||||
* Copyright © 2024-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>
|
||||
#include <driver/gpio.h>
|
||||
#include <iot_button.h>
|
||||
|
|
|
|||
|
|
@ -1,2 +1,23 @@
|
|||
/*
|
||||
* This program source code file is part of the KTag project, a DIY laser tag
|
||||
* game with customizable features and wide interoperability.
|
||||
*
|
||||
* 🛡️ <https://ktag.clubk.club> 🃞
|
||||
*
|
||||
* Copyright © 2024-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/>.
|
||||
*/
|
||||
|
||||
void Initialize_Switches(void);
|
||||
|
|
|
|||
|
|
@ -38,4 +38,22 @@ void Initialize_System_Events(void)
|
|||
EventGroupHandle_t Get_System_Events(void)
|
||||
{
|
||||
return The_System_Events;
|
||||
}
|
||||
}
|
||||
|
||||
bool Wait_For_System_Event(EventBits_t event_bit, const char* timeout_message, uint32_t timeout_ms)
|
||||
{
|
||||
EventBits_t bits = xEventGroupWaitBits(
|
||||
The_System_Events,
|
||||
event_bit,
|
||||
pdFALSE,
|
||||
pdTRUE,
|
||||
pdMS_TO_TICKS(timeout_ms));
|
||||
|
||||
if ((bits & event_bit) == 0)
|
||||
{
|
||||
KLOG_ERROR(TAG, "%s", timeout_message);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,11 +31,13 @@
|
|||
#define SYS_NVS_READY (1 << 0)
|
||||
#define SYS_SPIFFS_READY (1 << 1)
|
||||
#define SYS_USB_FS_PRESENT (1 << 2)
|
||||
#define SYS_BLE_READY (1 << 3)
|
||||
#define SYS_AUDIO_READY (1 << 4)
|
||||
#define SYS_CONFIG_LOADED (1 << 5)
|
||||
#define SYS_AUDIO_READY (1 << 3)
|
||||
#define SYS_NEOPIXELS_READY (1 << 4)
|
||||
#define SYS_BLE_READY (1 << 5)
|
||||
#define SYS_IR_READY (1 << 6)
|
||||
|
||||
EventGroupHandle_t Get_System_Events(void);
|
||||
void Initialize_System_Events(void);
|
||||
bool Wait_For_System_Event(EventBits_t event_bit, const char* timeout_message, uint32_t timeout_ms);
|
||||
|
||||
#endif // SYSTEM_EVENTS_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue