2023-12-27 18:25:35 +00:00
|
|
|
#pragma once
|
|
|
|
#include <ExpansionCard.hpp>
|
|
|
|
#include <DigitalInputCard.hpp>
|
|
|
|
#include <DigitalOutputCard.hpp>
|
2023-12-28 06:14:18 +00:00
|
|
|
#include <ESPMegaIoT.hpp>
|
2023-12-27 18:25:35 +00:00
|
|
|
#include <Arduino.h>
|
|
|
|
#include <Wire.h>
|
|
|
|
#include <FRAM.h>
|
|
|
|
#include <TimeLib.h>
|
|
|
|
#include <DS1307RTC.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2023-12-29 13:04:25 +00:00
|
|
|
|
2023-12-27 18:25:35 +00:00
|
|
|
struct rtctime_t {
|
|
|
|
uint8_t hours;
|
|
|
|
uint8_t minutes;
|
|
|
|
uint8_t seconds;
|
|
|
|
uint8_t day;
|
|
|
|
uint8_t month;
|
|
|
|
uint16_t year;
|
|
|
|
};
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
class ESPMegaPRO {
|
|
|
|
public:
|
|
|
|
ESPMegaPRO();
|
2023-12-27 19:18:21 +00:00
|
|
|
bool begin();
|
2023-12-27 18:25:35 +00:00
|
|
|
void loop();
|
2023-12-27 19:18:21 +00:00
|
|
|
bool installCard(uint8_t slot, ExpansionCard* card);
|
2023-12-27 18:25:35 +00:00
|
|
|
bool updateTimeFromNTP();
|
2023-12-28 07:52:52 +00:00
|
|
|
void enableIotModule();
|
2023-12-27 18:25:35 +00:00
|
|
|
rtctime_t getTime();
|
2023-12-27 18:33:37 +00:00
|
|
|
void setTime(int hours, int minutes, int seconds, int day, int month, int year);
|
2023-12-27 18:25:35 +00:00
|
|
|
FRAM fram;
|
2023-12-27 18:44:15 +00:00
|
|
|
DigitalInputCard inputs = DigitalInputCard(INPUT_BANK_A_ADDRESS, INPUT_BANK_B_ADDRESS);
|
|
|
|
DigitalOutputCard outputs = DigitalOutputCard(PWM_BANK_ADDRESS);
|
2023-12-28 06:14:18 +00:00
|
|
|
ESPMegaIoT iot = ESPMegaIoT();
|
2023-12-27 18:25:35 +00:00
|
|
|
private:
|
|
|
|
ExpansionCard* cards[255];
|
2023-12-27 18:33:37 +00:00
|
|
|
bool cardInstalled[255];
|
2023-12-27 18:25:35 +00:00
|
|
|
uint8_t cardCount = 0;
|
|
|
|
};
|