#ifndef PROPS_BLADE_ID_LOGGER_H #define PROPS_BLADE_ID_LOGGER_H #include "../props/prop_base.h" // Function to read Blade ID int BladeIDRead() { return analogRead(A3); // Replace A3 with your actual Blade ID pin } // Function to write data to SD card void LogToSD(const char* data) { // Open the file in append mode File logFile = LSFS::Open("blade_id_log.txt"); if (logFile) { // Check if the file is valid logFile.print(data); // Write string data to the file logFile.print("\n"); // Add a newline logFile.close(); // Close the file } else { Serial.println("Error: Could not open file on SD card."); // Handle errors } } // Blade ID Logger Prop class BladeIDLogger : public PropBase { public: void Setup() override { LogToSD("Blade ID Logger Initialized"); // Log initialization message } void Loop() override { // Optional: Add periodic logic here if needed } const char* name() override { return "BladeIDLogger"; // Return the name of the prop } bool Event2(enum BUTTON button, EVENT event, uint32_t modifiers) override { if (button == BUTTON_AUX && event == EVENT_PRESSED) { LogBladeID(); // Log Blade ID when auxiliary button is pressed return true; } return false; // Unhandled events } void LogBladeID() { int bladeID = BladeIDRead(); // Read the Blade ID char logData[50]; sprintf(logData, "Blade ID: %d", bladeID); // Format the log message LogToSD(logData); // Write the log message to the SD card Serial.println(logData); // Optional: Print to Serial Monitor } }; // Instantiate the BladeIDLogger BladeIDLogger bladeIDLogger; #endif // PROPS_BLADE_ID_LOGGER_H