#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // ESPMega Pro R3 Board Address #define FRAM_ADDRESS 0x56 #define INPUT_BANK_A_ADDRESS 0x21 #define INPUT_BANK_B_ADDRESS 0x22 #define PWM_BANK_ADDRESS 0x5F #define RTC_ADDRESS 0x68 /** * @brief The ESPMegaPRO class is the main class for the ESPMegaPRO library. * * This class provides functions for managing the ESPMegaPRO board, such as installing expansion cards, managing the internal RTC, and managing the internal FRAM. * This class also provides functions for managing the ESPMegaIoT module and the internal display. * * This class provide a Object Oriented Programming (OOP) interface for the ESPMegaPRO board. * If you are looking for a more simple and a more procedural interface, please use the ESPMegaPRO class in ESPMegaPRO.hpp. * But note that the ESPMegaPRO class only interfaces with the built-in Digital Input and Digital Output cards and other onboard components. * It does not provide an interface for expansion cards, the ESPMegaIoT module, and the internal display. * * @warning Only one ESPMegaPRO object can be created, creating more than one will result in undefined behavior. */ class ESPMegaPRO { public: ESPMegaPRO(); bool begin(); void loop(); bool installCard(uint8_t slot, ExpansionCard* card); bool updateTimeFromNTP(); void enableIotModule(); void enableInternalDisplay(HardwareSerial *serial); rtctime_t getTime(); void dumpFRAMtoSerial(uint16_t start, uint16_t end); void dumpFRAMtoSerialASCII(uint16_t start, uint16_t end); void setTime(int hours, int minutes, int seconds, int day, int month, int year); ExpansionCard* getCard(uint8_t slot); FRAM fram; /** * @brief The Digital Input Card Built-in to the ESPMegaPRO board. * @typedef DigitalInputCard * @note This card is installed by default at slot 0 on the ESPMegaPRO R3 board. */ DigitalInputCard inputs = DigitalInputCard(INPUT_BANK_A_ADDRESS, INPUT_BANK_B_ADDRESS); /** * @brief The Digital Output Card Built-in to the ESPMegaPRO board. * @typedef DigitalOutputCard * @note This card is installed by default at slot 1 on the ESPMegaPRO R3 board. */ DigitalOutputCard outputs = DigitalOutputCard(PWM_BANK_ADDRESS); InternalDisplay *display; ESPMegaIoT *iot; private: bool iotEnabled = false; bool internalDisplayEnabled = false; ExpansionCard* cards[255]; bool cardInstalled[255]; uint8_t cardCount = 0; };