mirror of
https://github.com/meshtastic/firmware.git
synced 2026-08-01 19:08:59 -04:00
* Snake! * Add spiLock to snake score saving * Check fixes * More careful locking * WIP: Big Display Node * Update src/graphics/HUB75Display.cpp Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Add HUB75 Native * Add Tetris game module with core logic and UI integration - Implement TetrisGame class for game logic, including piece movement, rotation, and line clearing. - Create TetrisModule class to manage game state, input handling, and rendering on OLED display. - Introduce high score tracking with persistence and optional mesh broadcasting. - Define UI states for title, playing, paused, game over, and high scores. - Implement input handling for game controls and state transitions. - Add rendering functions for the game board, high scores, and title screen. * feat(snake): add snake graphics and update display logic in SnakeModule * Prompt for Initials for Tetris, too * refactor games module * Games refactor * hub75 native double buffer * Games tuning * Make joystick repeat events on held button * Add clouds and colors * Fix breakout and more color * difficulty tuning * trunk * refactor game announcements, etc * Scale chirpy gravity as game speed increases * Portduino, check for hub75 display before reading in hub75 options * Final(?) games tuning * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Properly ignore input when games screen not shown * Fail gracefully when HUB75 is selected but not supported. --------- Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Ixitxachitl <kramerfm@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
288 lines
9.2 KiB
C++
288 lines
9.2 KiB
C++
#include "configuration.h"
|
|
#if !MESHTASTIC_EXCLUDE_INPUTBROKER
|
|
#include "buzz/BuzzerFeedbackThread.h"
|
|
#include "modules/SystemCommandsModule.h"
|
|
#endif
|
|
#include "modules/StatusLEDModule.h"
|
|
#if !MESHTASTIC_EXCLUDE_REPLYBOT
|
|
#include "ReplyBotModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_PKI
|
|
#include "KeyVerificationModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_ADMIN
|
|
#include "modules/AdminModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_ATAK
|
|
#include "modules/AtakPluginModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_CANNEDMESSAGES
|
|
#include "modules/CannedMessageModule.h"
|
|
#endif
|
|
#if HAS_SCREEN && BASEUI_HAS_GAMES
|
|
#include "modules/games/GamesModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_DETECTIONSENSOR
|
|
#include "modules/DetectionSensorModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_NEIGHBORINFO
|
|
#include "modules/NeighborInfoModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_NODEINFO
|
|
#include "modules/NodeInfoModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_BEACON
|
|
#include "modules/MeshBeaconModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_GPS
|
|
#include "modules/PositionModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_REMOTEHARDWARE
|
|
#include "modules/RemoteHardwareModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_POWERSTRESS
|
|
#include "modules/PowerStressModule.h"
|
|
#endif
|
|
#include "modules/RoutingModule.h"
|
|
#if HAS_TRAFFIC_MANAGEMENT && !MESHTASTIC_EXCLUDE_TRAFFIC_MANAGEMENT
|
|
#include "modules/TrafficManagementModule.h"
|
|
#endif
|
|
#if HAS_VARIABLE_HOPS
|
|
#include "modules/HopScalingModule.h"
|
|
#endif
|
|
#include "modules/TextMessageModule.h"
|
|
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
|
|
#include "modules/TraceRouteModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_WAYPOINT
|
|
#include "modules/WaypointModule.h"
|
|
#endif
|
|
#if ARCH_PORTDUINO
|
|
#include "modules/Telemetry/HostMetrics.h"
|
|
#if !MESHTASTIC_EXCLUDE_STOREFORWARD
|
|
#include "modules/StoreForwardModule.h"
|
|
#endif
|
|
#endif
|
|
#if HAS_TELEMETRY
|
|
#include "modules/Telemetry/DeviceTelemetry.h"
|
|
#endif
|
|
#if HAS_SENSOR && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
|
#include "main.h"
|
|
#include "modules/Telemetry/EnvironmentTelemetry.h"
|
|
#include "modules/Telemetry/HealthTelemetry.h"
|
|
#include "modules/Telemetry/Sensor/TelemetrySensor.h"
|
|
#endif
|
|
#if HAS_SENSOR && !MESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR
|
|
#include "main.h"
|
|
#include "modules/Telemetry/AirQualityTelemetry.h"
|
|
#include "modules/Telemetry/Sensor/TelemetrySensor.h"
|
|
#endif
|
|
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_POWER_TELEMETRY
|
|
#include "modules/Telemetry/PowerTelemetry.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_GENERIC_THREAD_MODULE
|
|
#include "modules/GenericThreadModule.h"
|
|
#endif
|
|
|
|
#ifdef ARCH_ESP32
|
|
#if defined(USE_SX1280) && !MESHTASTIC_EXCLUDE_AUDIO
|
|
#include "modules/esp32/AudioModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_PAXCOUNTER
|
|
#include "modules/esp32/PaxcounterModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_STOREFORWARD
|
|
#include "modules/StoreForwardModule.h"
|
|
#endif
|
|
#endif
|
|
|
|
#if !MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION
|
|
#include "modules/ExternalNotificationModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_RANGETEST && !MESHTASTIC_EXCLUDE_GPS
|
|
#include "modules/RangeTestModule.h"
|
|
#endif
|
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_SERIAL
|
|
#include "modules/SerialModule.h"
|
|
#endif
|
|
|
|
#if !MESHTASTIC_EXCLUDE_DROPZONE
|
|
#include "modules/DropzoneModule.h"
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_STATUS
|
|
#include "modules/StatusMessageModule.h"
|
|
#endif
|
|
|
|
#if defined(HAS_HARDWARE_WATCHDOG)
|
|
#include "watchdog/watchdogThread.h"
|
|
#endif
|
|
/**
|
|
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
|
|
*/
|
|
void setupModules()
|
|
{
|
|
#if (HAS_BUTTON || ARCH_PORTDUINO) && !MESHTASTIC_EXCLUDE_INPUTBROKER
|
|
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
|
inputBroker = new InputBroker();
|
|
systemCommandsModule = new SystemCommandsModule();
|
|
buzzerFeedbackThread = new BuzzerFeedbackThread();
|
|
}
|
|
#endif
|
|
statusLEDModule = new StatusLEDModule();
|
|
#if !MESHTASTIC_EXCLUDE_REPLYBOT
|
|
new ReplyBotModule();
|
|
#endif
|
|
|
|
#if HAS_TRAFFIC_MANAGEMENT && !MESHTASTIC_EXCLUDE_TRAFFIC_MANAGEMENT
|
|
if (moduleConfig.has_traffic_management) {
|
|
trafficManagementModule = new TrafficManagementModule();
|
|
}
|
|
#endif
|
|
|
|
#if HAS_VARIABLE_HOPS
|
|
hopScalingModule = new HopScalingModule();
|
|
#endif
|
|
|
|
#if !MESHTASTIC_EXCLUDE_ADMIN
|
|
adminModule = new AdminModule();
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_NODEINFO
|
|
nodeInfoModule = new NodeInfoModule();
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_BEACON
|
|
meshBeaconBroadcastModule = new MeshBeaconBroadcastModule();
|
|
meshBeaconListenerModule = new MeshBeaconListenerModule();
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_GPS
|
|
positionModule = new PositionModule();
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_WAYPOINT
|
|
waypointModule = new WaypointModule();
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_TEXTMESSAGE
|
|
textMessageModule = new TextMessageModule();
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
|
|
traceRouteModule = new TraceRouteModule();
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_NEIGHBORINFO
|
|
if (moduleConfig.has_neighbor_info && moduleConfig.neighbor_info.enabled) {
|
|
neighborInfoModule = new NeighborInfoModule();
|
|
}
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_DETECTIONSENSOR
|
|
if (moduleConfig.has_detection_sensor && moduleConfig.detection_sensor.enabled) {
|
|
detectionSensorModule = new DetectionSensorModule();
|
|
}
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_ATAK
|
|
if (config.device.role == meshtastic_Config_DeviceConfig_Role_TAK ||
|
|
config.device.role == meshtastic_Config_DeviceConfig_Role_TAK_TRACKER) {
|
|
atakPluginModule = new AtakPluginModule();
|
|
}
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_PKI
|
|
keyVerificationModule = new KeyVerificationModule();
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_DROPZONE
|
|
dropzoneModule = new DropzoneModule();
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_STATUS
|
|
statusMessageModule = new StatusMessageModule();
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_GENERIC_THREAD_MODULE
|
|
new GenericThreadModule();
|
|
#endif
|
|
// Note: if the rest of meshtastic doesn't need to explicitly use your module, you do not need to assign the instance
|
|
// to a global variable.
|
|
|
|
#if !MESHTASTIC_EXCLUDE_REMOTEHARDWARE
|
|
new RemoteHardwareModule();
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_POWERSTRESS
|
|
new PowerStressModule();
|
|
#endif
|
|
// Example: Put your module here
|
|
// new ReplyModule();
|
|
#if HAS_SCREEN && !MESHTASTIC_EXCLUDE_CANNEDMESSAGES
|
|
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
|
cannedMessageModule = new CannedMessageModule();
|
|
}
|
|
#endif
|
|
#if HAS_SCREEN && BASEUI_HAS_GAMES
|
|
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
|
gamesModule = new GamesModule();
|
|
}
|
|
#endif
|
|
#if ARCH_PORTDUINO
|
|
new HostMetricsModule();
|
|
#endif
|
|
#if HAS_TELEMETRY
|
|
new DeviceTelemetryModule();
|
|
#endif
|
|
#if HAS_TELEMETRY && HAS_SENSOR && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
|
if (moduleConfig.has_telemetry &&
|
|
(moduleConfig.telemetry.environment_measurement_enabled || moduleConfig.telemetry.environment_screen_enabled)) {
|
|
new EnvironmentTelemetryModule();
|
|
}
|
|
#if HAS_TELEMETRY && HAS_SENSOR && !MESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR
|
|
if (moduleConfig.has_telemetry &&
|
|
(moduleConfig.telemetry.air_quality_enabled || moduleConfig.telemetry.air_quality_screen_enabled)) {
|
|
new AirQualityTelemetryModule();
|
|
}
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_HEALTH_TELEMETRY
|
|
if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_MAX30102].first > 0 ||
|
|
nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_MLX90614].first > 0) {
|
|
new HealthTelemetryModule();
|
|
}
|
|
#endif
|
|
#endif
|
|
#if HAS_TELEMETRY && !MESHTASTIC_EXCLUDE_POWER_TELEMETRY && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
|
if (moduleConfig.has_telemetry &&
|
|
(moduleConfig.telemetry.power_measurement_enabled || moduleConfig.telemetry.power_screen_enabled)) {
|
|
new PowerTelemetryModule();
|
|
}
|
|
#endif
|
|
#if (defined(ARCH_ESP32) || defined(ARCH_NRF52) || defined(ARCH_RP2040) || defined(ARCH_STM32WL)) && \
|
|
!defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
|
|
#if !MESHTASTIC_EXCLUDE_SERIAL
|
|
if (moduleConfig.has_serial && moduleConfig.serial.enabled &&
|
|
config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_COLOR) {
|
|
new SerialModule();
|
|
}
|
|
#endif
|
|
#endif
|
|
#ifdef ARCH_ESP32
|
|
// Only run on an esp32 based device.
|
|
#if defined(USE_SX1280) && !MESHTASTIC_EXCLUDE_AUDIO
|
|
audioModule = new AudioModule();
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_PAXCOUNTER
|
|
if (moduleConfig.has_paxcounter && moduleConfig.paxcounter.enabled) {
|
|
paxcounterModule = new PaxcounterModule();
|
|
}
|
|
#endif
|
|
#endif
|
|
#if defined(ARCH_ESP32) || defined(ARCH_PORTDUINO)
|
|
#if !MESHTASTIC_EXCLUDE_STOREFORWARD
|
|
if (moduleConfig.has_store_forward && moduleConfig.store_forward.enabled) {
|
|
storeForwardModule = new StoreForwardModule();
|
|
}
|
|
#endif
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_EXTERNALNOTIFICATION
|
|
externalNotificationModule = new ExternalNotificationModule();
|
|
#endif
|
|
#if !MESHTASTIC_EXCLUDE_RANGETEST && !MESHTASTIC_EXCLUDE_GPS
|
|
if (moduleConfig.has_range_test && moduleConfig.range_test.enabled)
|
|
new RangeTestModule();
|
|
#endif
|
|
#if defined(HAS_HARDWARE_WATCHDOG)
|
|
watchdogThread = new WatchdogThread();
|
|
#endif
|
|
// NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra
|
|
// acks
|
|
routingModule = new RoutingModule();
|
|
}
|