RTC Driver OK
This commit is contained in:
25
src/main.cpp
25
src/main.cpp
@@ -5,6 +5,9 @@
|
||||
#include <Arduino.h>
|
||||
#include <RS485_Driver.h>
|
||||
#include <TCA9554PWR_Driver.h>
|
||||
#include <PCF85063_Driver.h>
|
||||
|
||||
#include <ETH.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
@@ -25,15 +28,27 @@ void loop()
|
||||
const uint8_t baseRegister(0x00);
|
||||
|
||||
//////////////// DEVICES ////////////////
|
||||
// Declared here to keep devices local to the main loop otherwise the kernel crashes //
|
||||
auto i2c = drivers::I2C();
|
||||
auto relays = drivers::TCA9554PWR(i2c, TCA9554_ADDRESS);
|
||||
auto bus = drivers::MODBUS(9600, SERIAL_8N1);
|
||||
auto rtc = drivers::PCF85063(i2c, PCF85063_ADDRESS);
|
||||
|
||||
|
||||
////////////////////////////////////////
|
||||
///////// MAIN LOOP INSIDE LOOP ////////
|
||||
////////////////////////////////////////
|
||||
|
||||
while (true)
|
||||
{
|
||||
LOG_INFO("\n\n\n\n[", k++, "] Loop");
|
||||
LOG_INFO("[", k++, "] Loop");
|
||||
std::vector<uint16_t> results;
|
||||
std::vector<bool> values;
|
||||
|
||||
drivers::PCF85063::datetime_t dt;
|
||||
rtc.readDatetime(dt);
|
||||
LOG_INFO("Current Datetime", rtc.getTimeStr().c_str());
|
||||
|
||||
|
||||
if (bus.readHoldingRegisters(tempBoardAddr, baseRegister, 8, results))
|
||||
{
|
||||
@@ -43,7 +58,7 @@ void loop()
|
||||
}
|
||||
results.clear();
|
||||
}
|
||||
delay(100);
|
||||
delay(5000);
|
||||
|
||||
LOG_INFO("\n\n====>Write Status 1");
|
||||
bus.writeCoils(relayBoardAddr, 0x00, {true, false, true, false, true, false, true, false});
|
||||
@@ -55,7 +70,7 @@ void loop()
|
||||
bus.writeCoils(relayBoardAddr, 0x00, {false, true, false, true, false, true, false, true});
|
||||
bus.readCoils(relayBoardAddr, 0x00, 8, values);
|
||||
printBool("====>Status 2", values);
|
||||
|
||||
|
||||
delay(5000);
|
||||
LOG_INFO("\n\n====>Read Inputs");
|
||||
bus.readInputs(relayBoardAddr, 0x00, 8, values);
|
||||
@@ -63,4 +78,8 @@ void loop()
|
||||
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
///////// MAIN LOOP INSIDE LOOP ////////
|
||||
////////////////////////////////////////
|
||||
}
|
||||
Reference in New Issue
Block a user