#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <OneWire.h> //Temperature
#include <DallasTemperature.h> //Temperature
constexpr byte CLK_PIN {13};
constexpr byte DATA_PIN {11};
constexpr byte CS_PIN {10};
constexpr byte HARDWARE_TYPE {MD_MAX72XX::PAROLA_HW};
// constexpr byte HARDWARE_TYPE {MD_MAX72XX::FC16_HW};
constexpr byte MAX_DEVICES {5}; // 5 Modules
constexpr byte MAX_ZONES {1}; // 1 Row(s)
constexpr byte ZONE_SIZE {MAX_DEVICES / MAX_ZONES};
constexpr unsigned long DISPLAY_TIME_MS {3000};
constexpr unsigned long SCROLL_TIME_MS {30};
// Data wire is plugged into pin 2 on the Arduino
constexpr byte ONE_WIRE_BUS {2}; // DS18B20 Temp.Sensor
constexpr byte MAX_TEMPARRAY_LENGTH {7}; // -10.00 + Arrayend '\0'
constexpr byte MAX_BUFFER_LENGTH {10}; // -10.00 °C + Arrayend '\0'
MD_Parola mdP = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
OneWire oneWire(ONE_WIRE_BUS); // Setup a OneWire instance to communicate with any OneWire devices
DallasTemperature sensors(&oneWire); // Pass OneWire reference to Dallas Temperature
void setup(void) {
Serial.begin(9600);
mdP.begin(MAX_ZONES);
mdP.setInvert(false);
mdP.setIntensity(0);
mdP.setZone(0, 0, ZONE_SIZE - 1);
mdP.setZone(1, ZONE_SIZE, MAX_DEVICES - 1);
sensors.begin();
delay(2000);
}
void loop(void) {
static char buffer[MAX_BUFFER_LENGTH];
sensors.requestTemperatures();
const char myPoolTemp[MAX_TEMPARRAY_LENGTH];
dtostrf(sensors.getTempCByIndex(0), 6, 2, myPoolTemp);
snprintf(buffer, MAX_BUFFER_LENGTH, "%s%cC", myPoolTemp,0xB0); // 0xB0 = degree sign
Serial.println(buffer);
mdP.displayZoneText(0, buffer, PA_CENTER, SCROLL_TIME_MS, DISPLAY_TIME_MS, PA_SCROLL_DOWN, PA_SCROLL_UP);
mdP.synchZoneStart();
/*
for (uint8_t i=0; i<3; i++)
{
Serial.println(i);
switch(i) {
case 1:
mdP.setFont(0, BigFontBottom);
mdP.setFont(1, BigFontUp);
mdP.displayZoneText(0, buffer, PA_CENTER, 30, 1000, PA_SCROLL_DOWN, PA_SCROLL_UP);
mdP.displayZoneText(1, buffer, PA_CENTER, 30, 1000, PA_SCROLL_UP, PA_SCROLL_DOWN);
mdP.synchZoneStart();
break;
case 2:
mdP.setFont(0, BigFontBottom);
mdP.setFont(1, BigFontUp);
mdP.displayZoneText(0, buffer, PA_CENTER, 30, 2000, PA_SCROLL_DOWN, PA_SCROLL_UP);
mdP.displayZoneText(1, buffer, PA_CENTER, 30, 2000, PA_SCROLL_UP, PA_SCROLL_DOWN);
mdP.synchZoneStart();
break;
}
while (!mdP.getZoneStatus(0) || !mdP.getZoneStatus(1)) { mdP.displayAnimate(); }
}
*/
while (!mdP.getZoneStatus(0)) { mdP.displayAnimate(); }
delay(5000);
}