SystemK/SystemK.h
Joe Kearney c4350ebd27 Added support for configurable logging on the ESP32 platform. (#10)
Because the ESP-IDF supports [runtime log level control](https://docs.espressif.com/projects/esp-idf/en/v5.5.2/esp32s3/api-reference/system/log.html#log-level-control), SystemK required some tweak to take full advantage of this.

This PR makes the following changes to SystemK:
- On the ESP32 platform, the highest logging level *compiled in* to the app is now controlable by Kconfig, as "SystemK maximum log level".
- [Protocols.c](272618d49d/Protocols/Protocols.c) was refactored, and the `DEBUG_PACKET_[EN/DE]CODE` #defines were renamed to make it clear that they now only apply to the PSoC platform.
- Some decoding warnings in the Test Protocol were downgraded to debug, since they were a nuisance most of the time.

Co-authored-by: Joe Kearney <joe@clubk.club>
Reviewed-on: #10
2026-01-10 22:25:50 +00:00

117 lines
4.9 KiB
C

/*
* 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/>.
*/
/** \file
* \brief This is the top-level include file for the KTag system (SystemK).
*
* By including this file (and only this file) from SystemK, include dependency order is maintained.
*
*/
// KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
// KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
// KKKKKKKKKKKKKKKKKKKKKKKKKKKKky+.`/ykKKKKKKKKKKKKKKKKKKKKKKKKKKKK
// KKKKKKKKKKKKKKKKKKKKKKKKds/. -+o:` ./sdNKKKKKKKKKKKKKKKKKKKKKKK
// KKKKKKKKKKKKKKKKKKNds+-` `-+hNKKKKNho:` `-+shNKKKKKKKKKKKKKKKKKK
// KKKKKKKKKKNkhyo+:. `-/sdNKKKKKKKKKKKKKky+:` .-/oyhdNKKKKKKKKKK
// KKys++:-.````.-:+oykNKKKKKKKKKKKKKKKKKKKKKKNkhs+/-.````.-:/+syKK
// KK -/+osydkNNNKKKkkkkkkkNKKKKKKKKKKKkkkkkkkkNKKKKNNkdhyso/: KK
// KK sKKKKKKKKKKKKK```````/KKKKKKKKKd-```````:kKKKKKKKKKKKKKd `KK
// KK- oKKKKKKKKKKKKK :KKKKKKKKo` `oNKKKKKKKKKKKKKKh :KK
// KK/ +KKKKKKKKKKKKK :KKKKKKd- -dKKKKKKKKKKKKKKKKy /KK
// KK+ /KKKKKKKKKKKKK :KKKKKs` +NKKKKKKKKKKKKKKKKKs +KK
// KKo :KKKKKKKKKKKKK :KKKk: .hKKKKKKKKKKKKKKKKKKKo oKK
// KKy -KKKKKKKKKKKKK :KKy` +NKKKKKKKKKKKKKKKKKKKK/ yKK
// KKd `KKKKKKKKKKKKK :k/ .hKKKKKKKKKKKKKKKKKKKKKK: dKK
// KKN NKKKKKKKKKKKK .. /kKKKKKKKKKKKKKKKKKKKKKKK. NKK
// KKK. dKKKKKKKKKKKK .yKKKKKKKKKKKKKKKKKKKKKKKKN .KKK
// KKK+ oKKKKKKKKKKKK -kKKKKKKKKKKKKKKKKKKKKKKKKKh +KKK
// KKKd .KKKKKKKKKKKK `sNKKKKKKKKKKKKKKKKKKKKKKKK/ dKKK
// KKKK: hKKKKKKKKKKK :kKKKKKKKKKKKKKKKKKKKKKKk :KKKK
// KKKKh -KKKKKKKKKKK `` .yKKKKKKKKKKKKKKKKKKKKK+ hKKKK
// KKKKK/ yKKKKKKKKKK T :d: /kKKKKKKKKKKKKKKKKKKk`:KKKKK
// KKKKKk`.NKKKKKKKKK :KNo` .hKKKKKKKKKKKK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KKKKKKKKKKKKKKKKKKKK
#ifndef SYSTEMK_H
#define SYSTEMK_H
#define SYSTEMK_MAJOR_VERSION 1
#define SYSTEMK_MINOR_VERSION 1
#define SYSTEMK_VERSION_STRING "01.01"
#ifdef ESP_PLATFORM
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "freertos/timers.h"
#endif // ESP_PLATFORM
#ifdef PSOC_PLATFORM
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
#include "timers.h"
#endif // PSOC_PLATFORM
#include "Results.h"
#include "Colors.h"
#include "Console_HW_Interface.h"
#include "Events/KEvents.h"
#include "Logging/KLog.h"
#include "Protocols/Protocols.h"
#include "Settings/Settings_Interface.h"
#include "Audio/Audio_HW_Interface.h"
#include "Game/Game.h"
#include "NeoPixels/NeoPixels.h"
#include "BLE/BLE_Packets.h"
#include "BLE/BLE_Packet_Tracker.h"
#include "BLE/BLE_HW_Interface.h"
#include "BLE/BLE_Utils.h"
#include "IR/IR_HW_Interface.h"
#include "States/State_Machine.h"
#include "Menu/Menu.h"
SystemKResult_T Initialize_SystemK(void);
#ifndef pdTICKS_TO_MS
#define pdTICKS_TO_MS(xTicks) ((TickType_t)((((uint64_t)(xTicks) * 1000) + (configTICK_RATE_HZ/2)) / configTICK_RATE_HZ))
#endif // pdTICKS_TO_MS
#endif // SYSTEMK_H