diff --git a/PacoMouseCYD/Platformio/.devcontainer/Dockerfile b/PacoMouseCYD/Platformio/.devcontainer/Dockerfile index 1cc8d8e..5fea3ea 100644 --- a/PacoMouseCYD/Platformio/.devcontainer/Dockerfile +++ b/PacoMouseCYD/Platformio/.devcontainer/Dockerfile @@ -1,24 +1,22 @@ FROM python:3.11 +# RUN python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)" +# RUN platformio platforms install atmelavr \ +# --with-package framework-arduinoavr -RUN python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)" - -RUN platformio platforms install atmelavr \ - --with-package framework-arduinoavr - -RUN platformio platforms install ststm32 \ - --with-package framework-libopencm3 \ - --with-package framework-spl \ - --with-package framework-cmsis \ - --with-package framework-mbed +# RUN platformio platforms install ststm32 \ +# --with-package framework-libopencm3 \ +# --with-package framework-spl \ +# --with-package framework-cmsis \ +# --with-package framework-mbed # Install PlatformIO -# RUN pip install platformio +RUN pip install platformio # Install OpenSSH for remote access RUN apt-get update && apt-get install -y openssh-server && rm -rf /var/lib/apt/lists/* # Set up SSH -RUN mkdir /var/run/sshd +# RUN mkdir /var/run/sshd RUN echo 'root:root' | chpasswd RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config EXPOSE 22 diff --git a/PacoMouseCYD/Platformio/.devcontainer/build.sh b/PacoMouseCYD/Platformio/.devcontainer/build.sh new file mode 100644 index 0000000..fe4f51c --- /dev/null +++ b/PacoMouseCYD/Platformio/.devcontainer/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker build -t easylinux/platformio-dev:1.0 . +docker image push easylinux/platformio-dev:1.0 \ No newline at end of file diff --git a/PacoMouseCYD/Platformio/.gitignore b/PacoMouseCYD/Platformio/.gitignore index 89cc49c..6327b47 100644 --- a/PacoMouseCYD/Platformio/.gitignore +++ b/PacoMouseCYD/Platformio/.gitignore @@ -1,4 +1,4 @@ -.pio +.pio/* .vscode/.browse.c_cpp.db* .vscode/c_cpp_properties.json .vscode/launch.json diff --git a/PacoMouseCYD/Platformio/.pio/build/project.checksum b/PacoMouseCYD/Platformio/.pio/build/project.checksum index 736d703..6b25824 100644 --- a/PacoMouseCYD/Platformio/.pio/build/project.checksum +++ b/PacoMouseCYD/Platformio/.pio/build/project.checksum @@ -1 +1 @@ -fed900e679701433dcf0b1c100208ae4193278e2 \ No newline at end of file +5b3abfbb1412581b7a1f0de41d5ba1926b6f6f95 \ No newline at end of file diff --git a/PacoMouseCYD/Platformio/src/XPT2046.old b/PacoMouseCYD/Platformio/Arduino.old/XPT2046.ino similarity index 100% rename from PacoMouseCYD/Platformio/src/XPT2046.old rename to PacoMouseCYD/Platformio/Arduino.old/XPT2046.ino diff --git a/PacoMouseCYD/Platformio/src/accessories.old b/PacoMouseCYD/Platformio/Arduino.old/accessories.ino similarity index 89% rename from PacoMouseCYD/Platformio/src/accessories.old rename to PacoMouseCYD/Platformio/Arduino.old/accessories.ino index 8360860..3af7cdf 100644 --- a/PacoMouseCYD/Platformio/src/accessories.old +++ b/PacoMouseCYD/Platformio/Arduino.old/accessories.ino @@ -1,3 +1,56 @@ + +/** + * @file accessories.ino + * @brief Accessory FIFO and control functions for PacoMouseCYD throttle. + * @author F. Cañada + * @date 2025-2026 + * @copyright https://usuaris.tinet.cat/fmco/ + * + * This file contains functions to manage accessory commands using a FIFO buffer, + * and to send accessory commands to the model train system. + */ + +//////////////////////////////////////////////////////////// +// API Documentation +//////////////////////////////////////////////////////////// +/** + * @brief Initializes the accessory FIFO buffer. + * + * Resets FIFO indices and state to empty. + */ +void initFIFO(); + +/** + * @brief Reads the next accessory command from the FIFO. + * @return The next accessory command in the FIFO. + */ +unsigned int readFIFO(); + +/** + * @brief Writes an accessory command to the FIFO. + * @param FAdr The accessory address. + * @param pos The position or state to set. + */ +void writeFIFO(uint16_t FAdr, uint8_t pos); + +/** + * @brief Processes and sends accessory commands from the FIFO. + * + * Handles timing and state transitions for accessory activation and deactivation. + */ +void sendAccessoryFIFO(); + +/** + * @brief Adds an accessory command to the FIFO for later execution. + * @param FAdr The accessory address. + * @param pos The position or state to set. + */ +void moveAccessory(uint16_t FAdr, uint8_t pos); + +//////////////////////////////////////////////////////////// +// End API Documentation +//////////////////////////////////////////////////////////// + /* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/ */ diff --git a/PacoMouseCYD/Platformio/src/ecos.old b/PacoMouseCYD/Platformio/Arduino.old/ecos.ino similarity index 93% rename from PacoMouseCYD/Platformio/src/ecos.old rename to PacoMouseCYD/Platformio/Arduino.old/ecos.ino index b899094..80a0876 100644 --- a/PacoMouseCYD/Platformio/src/ecos.old +++ b/PacoMouseCYD/Platformio/Arduino.old/ecos.ino @@ -1,13 +1,69 @@ + +/** + * @file ecos.ino + * @brief ECoS protocol support for PacoMouseCYD throttle. + * @author F. Cañada + * @date 2025-2026 + * @copyright https://usuaris.tinet.cat/fmco/ + * + * This file contains functions to communicate with ECoS/CS1 command stations, + * including sending and receiving messages, requesting locomotive and system status, + * and handling ECoS-specific operations. + * + * 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 message to the ECoS command station. + * @param buf The message buffer to send. + */ +void sendMsgECOS(char *buf); + +/** + * @brief Requests various views and information from the ECoS command station. + */ +void requestViews(); + +/** + * @brief Requests the power status from the ECoS command station. + */ +void getStatusECoS(); + +/** + * @brief Requests the list of locomotives from the ECoS command station. + */ +void requestLocoList(); + +/** + * @brief Requests information about a specific locomotive from the ECoS command station. + * @param ID The ECoS locomotive ID. + */ +void infoLocomotoraECoS(unsigned int ID); + +//////////////////////////////////////////////////////////// +// 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. */ diff --git a/PacoMouseCYD/Platformio/src/encoder.old b/PacoMouseCYD/Platformio/Arduino.old/encoder.ino similarity index 85% rename from PacoMouseCYD/Platformio/src/encoder.old rename to PacoMouseCYD/Platformio/Arduino.old/encoder.ino index d4a0eed..04b3106 100644 --- a/PacoMouseCYD/Platformio/src/encoder.old +++ b/PacoMouseCYD/Platformio/Arduino.old/encoder.ino @@ -1,3 +1,44 @@ + +/** + * @file encoder.ino + * @brief Rotary encoder and button handling for PacoMouseCYD throttle. + * @author F. Cañada + * @date 2025-2026 + * @copyright https://usuaris.tinet.cat/fmco/ + * + * This file contains interrupt service routines and functions for reading and processing + * rotary encoder and button input, including debouncing and value management. + */ + +//////////////////////////////////////////////////////////// +// API Documentation +//////////////////////////////////////////////////////////// +/** + * @brief Interrupt Service Routine for the encoder. + * + * Sets a flag indicating the encoder needs service. + */ +void IRAM_ATTR encoderISR(); + +/** + * @brief Handles encoder state changes and updates encoder value. + */ +void encoderService(); + +/** + * @brief Reads the encoder button and updates its state. + */ +void readButtons(); + +/** + * @brief Processes encoder movement and updates UI or state accordingly. + */ +void controlEncoder(); + +//////////////////////////////////////////////////////////// +// End API Documentation +//////////////////////////////////////////////////////////// + /* PacoMouseCYD throttle -- F. Cañada 2025-2026 -- https://usuaris.tinet.cat/fmco/ */ diff --git a/PacoMouseCYD/Platformio/src/events.old b/PacoMouseCYD/Platformio/Arduino.old/events.ino similarity index 100% rename from PacoMouseCYD/Platformio/src/events.old rename to PacoMouseCYD/Platformio/Arduino.old/events.ino diff --git a/PacoMouseCYD/Platformio/src/file.old b/PacoMouseCYD/Platformio/Arduino.old/file.ino similarity index 100% rename from PacoMouseCYD/Platformio/src/file.old rename to PacoMouseCYD/Platformio/Arduino.old/file.ino diff --git a/PacoMouseCYD/Platformio/src/gui.old b/PacoMouseCYD/Platformio/Arduino.old/gui.ino similarity index 100% rename from PacoMouseCYD/Platformio/src/gui.old rename to PacoMouseCYD/Platformio/Arduino.old/gui.ino diff --git a/PacoMouseCYD/Platformio/src/lnet.old b/PacoMouseCYD/Platformio/Arduino.old/lnet.ino similarity index 100% rename from PacoMouseCYD/Platformio/src/lnet.old rename to PacoMouseCYD/Platformio/Arduino.old/lnet.ino diff --git a/PacoMouseCYD/Platformio/src/main.old b/PacoMouseCYD/Platformio/Arduino.old/main.ino similarity index 100% rename from PacoMouseCYD/Platformio/src/main.old rename to PacoMouseCYD/Platformio/Arduino.old/main.ino diff --git a/PacoMouseCYD/Platformio/src/play.old b/PacoMouseCYD/Platformio/Arduino.old/play.ino similarity index 100% rename from PacoMouseCYD/Platformio/src/play.old rename to PacoMouseCYD/Platformio/Arduino.old/play.ino diff --git a/PacoMouseCYD/Platformio/src/steam.old b/PacoMouseCYD/Platformio/Arduino.old/steam.ino similarity index 100% rename from PacoMouseCYD/Platformio/src/steam.old rename to PacoMouseCYD/Platformio/Arduino.old/steam.ino diff --git a/PacoMouseCYD/Platformio/src/system.old b/PacoMouseCYD/Platformio/Arduino.old/system.ino similarity index 100% rename from PacoMouseCYD/Platformio/src/system.old rename to PacoMouseCYD/Platformio/Arduino.old/system.ino diff --git a/PacoMouseCYD/Platformio/src/window.old b/PacoMouseCYD/Platformio/Arduino.old/window.ino similarity index 100% rename from PacoMouseCYD/Platformio/src/window.old rename to PacoMouseCYD/Platformio/Arduino.old/window.ino diff --git a/PacoMouseCYD/Platformio/src/xnet.old b/PacoMouseCYD/Platformio/Arduino.old/xnet.ino similarity index 100% rename from PacoMouseCYD/Platformio/src/xnet.old rename to PacoMouseCYD/Platformio/Arduino.old/xnet.ino diff --git a/PacoMouseCYD/Platformio/src/z21.old b/PacoMouseCYD/Platformio/Arduino.old/z21.ino similarity index 100% rename from PacoMouseCYD/Platformio/src/z21.old rename to PacoMouseCYD/Platformio/Arduino.old/z21.ino diff --git a/PacoMouseCYD/Platformio/SD/LocoEditor.html b/PacoMouseCYD/Platformio/SD/LocoEditor.html index 34a81e7..61174b7 100644 --- a/PacoMouseCYD/Platformio/SD/LocoEditor.html +++ b/PacoMouseCYD/Platformio/SD/LocoEditor.html @@ -4,282 +4,8 @@