Ajout desc

This commit is contained in:
Serge NOEL
2026-02-13 09:28:40 +01:00
parent 758f73bc0e
commit d78e04366f
13 changed files with 619 additions and 44 deletions

View File

@@ -1,5 +1,69 @@
/**
* @file XPT2046.ino
* @brief XPT2046 SPI/Bitbang touchscreen interface for PacoMouseCYD throttle.
* @author F. Cañada
* @date 2025-2026
* @copyright https://usuaris.tinet.cat/fmco/
*
* This file contains the implementation of the XPT2046 touchscreen interface,
* including initialization, calibration, and touch detection for the PacoMouseCYD throttle.
*/
////////////////////////////////////////////////////////////
// API Documentation
////////////////////////////////////////////////////////////
/**
* @brief XPT2046 touchscreen class constructor.
* @param mosiPin MOSI pin number.
* @param misoPin MISO pin number.
* @param clkPin Clock pin number.
* @param csPin Chip select pin number.
*/
XPT2046_TS::XPT2046_TS(uint8_t mosiPin, uint8_t misoPin, uint8_t clkPin, uint8_t csPin);
/**
* @brief Initializes the touchscreen with given width and height.
* @param width Screen width.
* @param height Screen height.
*/
void XPT2046_TS::begin(uint16_t width, uint16_t height);
/**
* @brief Sets the touchscreen calibration values.
* @param xMin Minimum X value.
* @param xMax Maximum X value.
* @param yMin Minimum Y value.
* @param yMax Maximum Y value.
*/
void XPT2046_TS::setCalibration(uint16_t xMin, uint16_t xMax, uint16_t yMin, uint16_t yMax);
/**
* @brief Gets the current touchscreen calibration values.
* @return The current TouchCalibration struct.
*/
TouchCalibration XPT2046_TS::getCalibration();
/**
* @brief Sets the touchscreen rotation.
* @param n Rotation value (0-3).
*/
void XPT2046_TS::setRotation(uint8_t n);
/**
* @brief Checks if the touchscreen is currently being touched.
* @return True if touched, false otherwise.
*/
bool XPT2046_TS::touched();
// Add further function documentation here as needed for each public function.
////////////////////////////////////////////////////////////
// End API Documentation
////////////////////////////////////////////////////////////
/* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/
Simple XPT2046 SPI/Bitbang interface for PacoMouseCYD
Simple XPT2046 SPI/Bitbang interface for PacoMouseCYD
*/
#include "config.h"

View File

@@ -1,3 +1,29 @@
/**
* @file events.ino
* @brief Event processing and handling for PacoMouseCYD throttle.
* @author F. Cañada
* @date 2025-2026
* @copyright https://usuaris.tinet.cat/fmco/
*
* This file contains functions for processing system and user events, managing timers,
* and handling event-driven actions in the PacoMouseCYD throttle firmware.
*/
////////////////////////////////////////////////////////////
// API Documentation
////////////////////////////////////////////////////////////
/**
* @brief Processes the next event in the event queue.
*/
void eventProcess();
// Add further function documentation here as needed for each public function.
////////////////////////////////////////////////////////////
// End API Documentation
////////////////////////////////////////////////////////////
/* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/
*/

View File

@@ -1,3 +1,39 @@
/**
* @file file.ino
* @brief File handling and storage for PacoMouseCYD throttle.
* @author F. Cañada
* @date 2025-2026
* @copyright https://usuaris.tinet.cat/fmco/
*
* This file contains functions for managing locomotive data files, checking file names,
* saving and loading data to and from the SD card or internal filesystem, and related utilities.
*/
////////////////////////////////////////////////////////////
// API Documentation
////////////////////////////////////////////////////////////
/**
* @brief Checks if a file name has a .csv extension.
* @param fileName The file name to check.
* @return True if the file name ends with .csv, false otherwise.
*/
bool checkName(char *fileName);
/**
* @brief Saves locomotive data to a .csv file.
* @param fs The filesystem object.
* @param pos The position in the locomotive data array.
* @return True if the data was saved successfully, false otherwise.
*/
bool saveLocoData(fs::FS &fs, uint16_t pos);
// Add further function documentation here as needed for each public function.
////////////////////////////////////////////////////////////
// End API Documentation
////////////////////////////////////////////////////////////
/* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/
*/

View File

@@ -1,6 +1,56 @@
/**
* @file gui.ino
* @brief Graphical User Interface (GUI) for PacoMouseCYD throttle.
* @author F. Cañada
* @date 2025-2026
* @copyright https://usuaris.tinet.cat/fmco/
*
* This file contains functions for initializing and managing the graphical user interface,
* including timers, drawing routines, and event handling for the PacoMouseCYD throttle.
*/
////////////////////////////////////////////////////////////
// API Documentation
////////////////////////////////////////////////////////////
/**
* @brief Initializes the GUI, timers, and object stacks.
*/
void initGUI();
/**
* @brief Clears all system timers.
*/
void clearTimers();
/**
* @brief Sets a timer with the specified parameters.
* @param id Timer ID.
* @param count Timer count value.
* @param type Timer type (oneshot, periodic, etc).
*/
void setTimer(uint16_t id, uint16_t count, uint16_t type);
/**
* @brief Stops a timer by ID.
* @param id Timer ID.
*/
void stopTimer(uint16_t id);
/**
* @brief Processes all timers, triggering events as needed.
*/
void timerProcess();
// Add further function documentation here as needed for each public function.
////////////////////////////////////////////////////////////
// End API Documentation
////////////////////////////////////////////////////////////
/* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/
Very basic Graphical User Interface (GUI) for PacoMouseCYD
All data in absolute coordinates
Very basic Graphical User Interface (GUI) for PacoMouseCYD
All data in absolute coordinates
*/
////////////////////////////////////////////////////////////

View File

@@ -1,13 +1,54 @@
/**
* @file lnet.ino
* @brief Loconet over TCP support for PacoMouseCYD throttle.
* @author F. Cañada
* @date 2025-2026
* @copyright https://usuaris.tinet.cat/fmco/
*
* This file contains functions for sending and receiving Loconet messages over TCP,
* handling Loconet protocol details, and managing communication with Loconet command stations.
*
* This software and associated files are a DIY project that is not intended for commercial use.
* This software uses libraries with different licenses, follow all their different terms included.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
*
* Sources are only provided for building and uploading to the device.
* You are not allowed to modify the source code or fork/publish this project.
* Commercial use is forbidden.
*/
////////////////////////////////////////////////////////////
// API Documentation
////////////////////////////////////////////////////////////
/**
* @brief Sends a Loconet message over TCP.
* @param Msg Pointer to the Loconet message structure.
*/
void lnetSend(lnMsg *Msg);
/**
* @brief Receives and processes Loconet messages from TCP.
*/
void lnetReceive();
// Add further function documentation here as needed for each public function.
////////////////////////////////////////////////////////////
// End API Documentation
////////////////////////////////////////////////////////////
/* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/
This software and associated files are a DIY project that is not intended for commercial use.
This software uses libraries with different licenses, follow all their different terms included.
This software and associated files are a DIY project that is not intended for commercial use.
This software uses libraries with different licenses, follow all their different terms included.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
Sources are only provided for building and uploading to the device.
You are not allowed to modify the source code or fork/publish this project.
Commercial use is forbidden.
Sources are only provided for building and uploading to the device.
You are not allowed to modify the source code or fork/publish this project.
Commercial use is forbidden.
*/
////////////////////////////////////////////////////////////

View File

@@ -1,39 +1,47 @@
/**
* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/
* @file main.ino
* @brief Main entry point and core logic for PacoMouseCYD throttle.
* @author F. Cañada
* @date 2025-2026
* @copyright https://usuaris.tinet.cat/fmco/
*
* This software and associated files are a DIY project that is not intended for commercial use.
* This software uses libraries with different licenses, follow all their different terms included.
* This file contains the main setup and loop functions, version history, and
* overall initialization for the PacoMouseCYD throttle firmware.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
* This software and associated files are a DIY project that is not intended for commercial use.
* This software uses libraries with different licenses, follow all their different terms included.
*
* Sources are only provided for building and uploading to the device.
* You are not allowed to modify the source code or fork/publish this project.
* Commercial use is forbidden.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
*
* --------------------------------------------------------------------------------------------------
* Sources are only provided for building and uploading to the device.
* You are not allowed to modify the source code or fork/publish this project.
* Commercial use is forbidden.
*
* Use 2.8" Cheap Yellow Display ESP32-2432S028 (CYD)
* - ILI9341 driver chip (320x240)
* - XPT2046 chip for touch screen
* --------------------------------------------------------------------------------------------------
*
* CYD Also available in 2.4" and 3.2" (Use Resistive touch)
* Use 2.8" Cheap Yellow Display ESP32-2432S028 (CYD)
* - ILI9341 driver chip (320x240)
* - XPT2046 chip for touch screen
*
* Select ESP32 Dev Module in Arduino IDE
* CYD Also available in 2.4" and 3.2" (Use Resistive touch)
*
* SD Card. IMPORTANT!!!: use FAT32 SD card (max. 32GB)
* Select ESP32 Dev Module in Arduino IDE
*
* --------------------------------------------------------------------------------------------------
* SD Card. IMPORTANT!!!: use FAT32 SD card (max. 32GB)
*
* v0.1 24feb25 Start writting code
* v0.2 07mar25 GUI, SD Pictures, Wifi configuration and loco throttle on Z21 working
* v0.3 21mar25 Added loco list sorting and loco image selection. Added internal file system for loco data.
* v0.4 19apr25 Added configuration menu screen. Corrected touch rotation for CYD 2.4". Changed translations files. Added programming CV. Added speedometer.
* v0.5 02jun25 Added steam loco throttle. Adding more function icons. Added Xpressnet LAN and Loconet over TCP protocols. Added experimental identify command station for Loconet.
* v0.6 08oct25 Added Loconet programming. New LocoEditor for browser on SD.
* v0.7 23nov25 Corrected bugs on loconet steam direction. Added accessory panels. Added WiFi analyzer.
* v0.8 15dec25 Added ECoS/CS1 protocol. Updated user defined CYDs. Changes in modal windows.
* v0.9 03jan26 Added Station Run for kids. Corrected minor bugs on loconet
*/
* --------------------------------------------------------------------------------------------------
*
* v0.1 24feb25 Start writing code
* v0.2 07mar25 GUI, SD Pictures, Wifi configuration and loco throttle on Z21 working
* v0.3 21mar25 Added loco list sorting and loco image selection. Added internal file system for loco data.
* v0.4 19apr25 Added configuration menu screen. Corrected touch rotation for CYD 2.4". Changed translations files. Added programming CV. Added speedometer.
* v0.5 02jun25 Added steam loco throttle. Adding more function icons. Added Xpressnet LAN and Loconet over TCP protocols. Added experimental identify command station for Loconet.
* v0.6 08oct25 Added Loconet programming. New LocoEditor for browser on SD.
* v0.7 23nov25 Corrected bugs on loconet steam direction. Added accessory panels. Added WiFi analyzer.
* v0.8 15dec25 Added ECoS/CS1 protocol. Updated user defined CYDs. Changes in modal windows.
* v0.9 03jan26 Added Station Run for kids. Corrected minor bugs on loconet
*/
// PacoMouseCYD program version
#define VER_H "0"

View File

@@ -1,3 +1,71 @@
/**
* @file play.ino
* @brief Station Run - Model Train Game for Kids for PacoMouseCYD throttle.
* @author F. Cañada
* @date 2025-2026
* @copyright https://usuaris.tinet.cat/fmco/
*
* This file contains functions for the Station Run game, including station time updates,
* level and target management, and game logic for the PacoMouseCYD throttle.
*/
////////////////////////////////////////////////////////////
// API Documentation
////////////////////////////////////////////////////////////
/**
* @brief Updates the station time display.
* @param seconds The number of seconds to display.
*/
void updateStationTime(uint16_t seconds);
/**
* @brief Updates the target number of stations for the current level.
*/
void updateStationTarget();
/**
* @brief Initializes or resets station counters for the game.
* @param ini If true, initializes counters; otherwise, resets for new round.
*/
void newStationCounters(bool ini);
/**
* @brief Generates a new station number, avoiding repetition of the last.
* @param last The last station number used.
* @return The new station number.
*/
uint8_t newStation(byte last);
/**
* @brief Updates the display for the target number of stations.
*/
void updateTargetStations();
/**
* @brief Updates the display for the current count of stations.
*/
void updateCountStations();
/**
* @brief Updates the display for the current game level.
*/
void updateStationLevel();
/**
* @brief Updates the display for the number of stars earned.
*/
void updateStationStars();
/**
* @brief Sets a new target station and updates icon positions.
*/
void setNewTarget();
////////////////////////////////////////////////////////////
// End API Documentation
////////////////////////////////////////////////////////////
/* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/
*/

View File

@@ -1,3 +1,34 @@
/**
* @file steam.ino
* @brief Steam throttle control for PacoMouseCYD throttle.
* @author F. Cañada
* @date 2025-2026
* @copyright https://usuaris.tinet.cat/fmco/
*
* This file contains functions for managing the steam locomotive throttle,
* including pressure, water, and speed control for the PacoMouseCYD throttle.
*/
////////////////////////////////////////////////////////////
// API Documentation
////////////////////////////////////////////////////////////
/**
* @brief Initializes the steam throttle and related variables.
*/
void initSteamThrottle();
/**
* @brief Updates the steam throttle state and encoder value.
*/
void updateSteamThrottle();
// Add further function documentation here as needed for each public function.
////////////////////////////////////////////////////////////
// End API Documentation
////////////////////////////////////////////////////////////
/* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/
*/

View File

@@ -1,3 +1,54 @@
/**
* @file system.ino
* @brief System support functions for PacoMouseCYD throttle.
* @author F. Cañada
* @date 2025-2026
* @copyright https://usuaris.tinet.cat/fmco/
*
* This file contains functions for hardware initialization, backlight control,
* display rotation, and system-level utilities for the PacoMouseCYD throttle.
*/
////////////////////////////////////////////////////////////
// API Documentation
////////////////////////////////////////////////////////////
/**
* @brief Initializes all hardware pins and peripherals.
*/
void initPins();
/**
* @brief Sets the PWM backlight value.
* @param value The backlight intensity value.
*/
void setBacklight(uint8_t value);
/**
* @brief Rotates the display and touchscreen.
* @param pos The rotation position.
*/
void setRotationDisplay(uint8_t pos);
/**
* @brief Resets the inactivity timer and restores backlight if needed.
*/
void aliveAndKicking();
#if (USE_RGB_LED == PRESENT)
/**
* @brief Sets the color of the RGB LED.
* @param color The color value.
*/
void setColorRGB(uint16_t color);
#endif
// Add further function documentation here as needed for each public function.
////////////////////////////////////////////////////////////
// End API Documentation
////////////////////////////////////////////////////////////
/* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/
*/

View File

@@ -1,3 +1,30 @@
/**
* @file window.ino
* @brief Window object and UI management for PacoMouseCYD throttle.
* @author F. Cañada
* @date 2025-2026
* @copyright https://usuaris.tinet.cat/fmco/
*
* This file contains functions for creating, opening, and managing window objects,
* drawing UI elements, and handling window-related events for the PacoMouseCYD throttle.
*/
////////////////////////////////////////////////////////////
// API Documentation
////////////////////////////////////////////////////////////
/**
* @brief Opens a window by its ID and initializes its objects.
* @param id The window ID to open.
*/
void openWindow(uint16_t id);
// Add further function documentation here as needed for each public function.
////////////////////////////////////////////////////////////
// End API Documentation
////////////////////////////////////////////////////////////
/* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/
*/

View File

@@ -1,13 +1,60 @@
/**
* @file xnet.ino
* @brief XpressNet LAN protocol support for PacoMouseCYD throttle.
* @author F. Cañada
* @date 2025-2026
* @copyright https://usuaris.tinet.cat/fmco/
*
* This file contains functions for handling XpressNet LAN protocol operations,
* error handling, and communication with command stations for the PacoMouseCYD throttle.
*
* This software and associated files are a DIY project that is not intended for commercial use.
* This software uses libraries with different licenses, follow all their different terms included.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
*
* Sources are only provided for building and uploading to the device.
* You are not allowed to modify the source code or fork/publish this project.
* Commercial use is forbidden.
*/
////////////////////////////////////////////////////////////
// API Documentation
////////////////////////////////////////////////////////////
/**
* @brief Shows error states for XpressNet LAN and updates UI accordingly.
*/
void showErrorXnet();
/**
* @brief Shows normal operation state for XpressNet LAN and updates UI accordingly.
*/
void showNormalOpsXnet();
/**
* @brief Computes the XpressNet address, handling long addresses.
* @param adr The input address.
* @return The computed XpressNet address.
*/
uint16_t addrXnet(uint16_t adr);
// Add further function documentation here as needed for each public function.
////////////////////////////////////////////////////////////
// End API Documentation
////////////////////////////////////////////////////////////
/* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/
This software and associated files are a DIY project that is not intended for commercial use.
This software uses libraries with different licenses, follow all their different terms included.
This software and associated files are a DIY project that is not intended for commercial use.
This software uses libraries with different licenses, follow all their different terms included.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
Sources are only provided for building and uploading to the device.
You are not allowed to modify the source code or fork/publish this project.
Commercial use is forbidden.
Sources are only provided for building and uploading to the device.
You are not allowed to modify the source code or fork/publish this project.
Commercial use is forbidden.
*/

View File

@@ -1,6 +1,14 @@
/**
* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/
*
* @file z21.ino
* @brief Z21 protocol support for PacoMouseCYD throttle.
* @author F. Cañada
* @date 2025-2026
* @copyright https://usuaris.tinet.cat/fmco/
*
* This file contains functions for Z21 protocol operations, including reading and writing CVs,
* sending commands, and handling Z21-specific communication for the PacoMouseCYD throttle.
*
* This software and associated files are a DIY project that is not intended for commercial use.
* This software uses libraries with different licenses, follow all their different terms included.
*
@@ -9,8 +17,31 @@
* Sources are only provided for building and uploading to the device.
* You are not allowed to modify the source code or fork/publish this project.
* Commercial use is forbidden.
*
**/
*/
////////////////////////////////////////////////////////////
// API Documentation
////////////////////////////////////////////////////////////
/**
* @brief Reads a CV value from the Z21 command station.
* @param adr The CV address to read.
* @param stepPrg Programming step.
*/
void readCVZ21(unsigned int adr, byte stepPrg);
/**
* @brief Writes a CV value to the Z21 command station.
* @param adr The CV address to write.
* @param data The data to write.
* @param stepPrg Programming step.
*/
void writeCVZ21(unsigned int adr, unsigned int data, byte stepPrg);
// Add further function documentation here as needed for each public function.
////////////////////////////////////////////////////////////
// End API Documentation
////////////////////////////////////////////////////////////