Preparation PlatformIO
This commit is contained in:
@@ -1,37 +1,38 @@
|
||||
/* 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.
|
||||
|
||||
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)
|
||||
|
||||
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
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* 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)
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
// PacoMouseCYD program version
|
||||
@@ -43,7 +44,7 @@
|
||||
|
||||
// Libraries
|
||||
|
||||
#include "arduino.h"
|
||||
#include <Arduino.h>
|
||||
#include "config.h" // PacoMouseCYD config file
|
||||
#include "icon.h" // PacoMouseCYD icons
|
||||
#include "gui.h" // PacoMouseCYD Graphic User Interface
|
||||
@@ -268,7 +269,7 @@ byte lockOptions;
|
||||
unsigned long infoTimer;
|
||||
unsigned long pingTimer;
|
||||
|
||||
byte myLocoData; // current oco data index
|
||||
byte myLocoData; // current loco data index
|
||||
|
||||
typedef union { // Loco address
|
||||
uint8_t adr[2];
|
||||
@@ -705,23 +706,25 @@ const uint8_t FunktionsTastenSymboleCS1[] = { // Conversion table
|
||||
// ***** MAIN PROGRAM *****
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// Arduino setup function: runs once at boot
|
||||
void setup() {
|
||||
uint16_t posLabel;
|
||||
initPins();
|
||||
delay(500); // power-up safety delay
|
||||
uint16_t posLabel; // Variable for label positioning (if used)
|
||||
initPins(); // Initialize GPIO pins
|
||||
delay(500); // Power-up safety delay
|
||||
// Initialize serial for debug output if enabled
|
||||
#ifdef DEBUG
|
||||
Serial.begin(115200); // Debug messages, serial at 115200b
|
||||
Serial.begin(115200); // Debug messages, serial at 115200b
|
||||
DEBUG_MSG("\n\nPacoMouseCYD v%s.%s", VER_H, VER_L);
|
||||
DEBUG_MSG(USER_SETUP_INFO);
|
||||
DEBUG_MSG("Chip Model: %s \nFlash Chip Size: %lu", ESP.getChipModel(), ESP.getFlashChipSize())
|
||||
DEBUG_MSG("ESP_ARDUINO_VERSION: %d.%d.%d", ESP_ARDUINO_VERSION_MAJOR, ESP_ARDUINO_VERSION_MINOR, ESP_ARDUINO_VERSION_PATCH)
|
||||
#endif
|
||||
initGUI();
|
||||
initVariables();
|
||||
sdDetected = SD.begin(SD_CS) ? true : false;
|
||||
initGUI(); // Initialize graphical user interface
|
||||
initVariables(); // Initialize global variables and settings
|
||||
sdDetected = SD.begin(SD_CS) ? true : false; // Initialize SD card
|
||||
DEBUG_MSG("SD Card %s", sdDetected ? "found" : "begin failed")
|
||||
tft.init();
|
||||
tft.fillScreen(COLOR_BLACK);
|
||||
tft.init(); // Initialize TFT display
|
||||
tft.fillScreen(COLOR_BLACK); // Clear display
|
||||
#ifdef DEBUG
|
||||
DEBUG_MSG("Display driver: %X %dx%d", TFT_DRIVER, TFT_WIDTH, TFT_HEIGHT)
|
||||
DEBUG_MSG("TFT BL pin: %d", TFT_BL)
|
||||
@@ -742,40 +745,42 @@ void setup() {
|
||||
ledcSetup(LEDC_CHANNEL_0, LEDC_BASE_FREQ, LEDC_RESOLUTION); // backlight PWM
|
||||
ledcAttachPin(TFT_BL, LEDC_CHANNEL_0);
|
||||
#endif
|
||||
setBacklight (backlight);
|
||||
setBacklight (backlight); // Set initial backlight level
|
||||
|
||||
// setup the touchscreen
|
||||
// NOTE: this needs to be done after tft.init()
|
||||
touchscreen.begin(TFT_WIDTH, TFT_HEIGHT);
|
||||
setRotationDisplay(locationUSB);
|
||||
copyOutA = digitalRead (ENCODER_A); // init encoder ISR
|
||||
// Setup the touchscreen (must be after tft.init())
|
||||
touchscreen.begin(TFT_WIDTH, TFT_HEIGHT); // Initialize touchscreen
|
||||
setRotationDisplay(locationUSB); // Set display rotation based on USB location
|
||||
copyOutA = digitalRead (ENCODER_A); // Init encoder ISR
|
||||
copyOutB = 0x80;
|
||||
attachInterrupt (digitalPinToInterrupt (ENCODER_A), encoderISR, CHANGE);
|
||||
attachInterrupt (digitalPinToInterrupt (ENCODER_A), encoderISR, CHANGE); // Attach encoder interrupt
|
||||
|
||||
openWindow(WIN_LOGO); // special window, don't use events just draw
|
||||
initStatus = initSequence();
|
||||
getLastLoco();
|
||||
openWindow(WIN_LOGO); // Show logo window (no events, just draw)
|
||||
initStatus = initSequence(); // Run initialization sequence
|
||||
getLastLoco(); // Load last used locomotive
|
||||
}
|
||||
|
||||
|
||||
// Arduino main loop: runs repeatedly after setup()
|
||||
void loop() {
|
||||
timerProcess();
|
||||
hidProcess();
|
||||
wifiProcess();
|
||||
timerProcess(); // Handle timers
|
||||
hidProcess(); // Handle human interface devices (buttons, encoders, etc.)
|
||||
wifiProcess(); // Handle WiFi events and communication
|
||||
if (isWindow(WIN_STEAM))
|
||||
steamProcess();
|
||||
if (eventsPending > 0) { // execute pending events
|
||||
steamProcess(); // If steam window is active, process steam logic
|
||||
if (eventsPending > 0) { // Execute pending events
|
||||
eventProcess();
|
||||
DEBUG_MSG("New Event...")
|
||||
}
|
||||
if (! bootPressed) { // check BOOT button to enter Touchscreen Calibration
|
||||
// Check BOOT button to enter touchscreen calibration
|
||||
if (! bootPressed) {
|
||||
if (digitalRead(SW_BOOT) == LOW) {
|
||||
bootPressed = true;
|
||||
newEvent(OBJ_WIN, WIN_CALIBRATE, EVNT_BOOT);
|
||||
DEBUG_MSG("BOOT switch pressed...")
|
||||
}
|
||||
}
|
||||
if (clickDetected) { // only individual clicks
|
||||
// Handle touchscreen click detection
|
||||
if (clickDetected) {
|
||||
if (! touchscreen.touched())
|
||||
clickDetected = false;
|
||||
}
|
||||
@@ -799,6 +804,7 @@ void loop() {
|
||||
void initVariables() {
|
||||
byte pos;
|
||||
uint16_t xm, xM, ym, yM, value;
|
||||
|
||||
EEPROM.begin(EEPROM_SIZE);
|
||||
eepromChanged = false;
|
||||
currLanguage = EEPROM.read(EE_LANGUAGE);
|
||||
|
||||
Reference in New Issue
Block a user