Go Down

Topic: [discontinued] Need help for a clock with Parola Double Height (Read 3458 times) previous topic - next topic

robiv8


marco_c

I can't understand the question and I suppose others cannot either.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

robiv8

Oh sorry! My english is bad.
So one more try.

I have built a watch with 8Dig7Segment LED, the time it takes from the RTC. The RTC is updated with Wlan and Ntp. If no Wlan is present, it continues to take the time out of the RTC.
This works excellently.
The 3 used ino files I have attached.
And now I want this with my big clock.

And now the question!
How can I install the code from my 1 post, for the double height clock in this way-set-rtc-via-wifi-german-matrix.ino?

Thanks

marco_c

That depends entirely on how well the code is written. If is is well structured and has isolation between the different parts (ie, the display part is quite separate from the clock/time/internet parts) then it will be a straightforward job. If the code is 'spaghetti' this will be more complex and take longer.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

robiv8

Hello Marco,
exactly what I meant, since I am no programmer would be nice if someone tells me whether the code is spaghetti or it is relatively easy to implement. Then I would also dare to try.
In my post no.14 I attached the sketch. That would be the weg-set-rtc-via-wifi_Deutsch_matrix.ino, in which should be installed.
If you could look at this and give me a tip would be great.
Thank you
Robert

marco_c

There is very little in the code you pointed me to (2 functions), so I would guess that including the matrix should be a straightforward job.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

robiv8

Thanks, I'll try it.
My only problem is that in my sketch the DS3231 is used and in the Parola Sketch the DS1307

marco_c

Those 2 clock modules are interchangeable for the basic RTC function.

DS3231 has built-in alarms that are not in the other. If you are worried get the DS3231 library from my libraries repo. Function calls are the same so it should be a drop in replacement with minimal changes.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

robiv8

#23
Oct 04, 2017, 01:21 am Last Edit: Oct 04, 2017, 01:37 am by robiv8
You mean the MD DS3231.h instead of the MD DS1307.h?
So i have changed the DS1307 to MD_DS3231

and become this error:
Arduino: 1.8.5 Hourly Build 2017/08/28 06:12 (Mac OS X), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

Build-Optionen wurden verändert, alles wird neu kompiliert
Archiving built core (caching) in: /var/folders/l9/27pqv_zs4zd0xmpx_03blk_m0000gn/T/arduino_cache_641022/core/core_esp8266_esp8266_nodemcuv2_CpuFrequency_80,UploadSpeed_115200,FlashSize_4M3M_e66f26f0b9de883465923b4da1419c23.a
libraries/MD_DS3231-master/MD_DS3231.cpp.o:(.bss.bufRTC+0x0): multiple definition of `bufRTC'
libraries/MD_Parola-master/MD_DS1307.cpp.o:(.bss.bufRTC+0x0): first defined here
libraries/MD_DS3231-master/MD_DS3231.cpp.o:(.bss.RTC+0x0): multiple definition of `RTC'
libraries/MD_Parola-master/MD_DS1307.cpp.o:(.bss.RTC+0x0): first defined here
/Users/robi/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: Warning: size of symbol `RTC' changed from 10 in libraries/MD_Parola-master/MD_DS1307.cpp.o to 24 in libraries/MD_DS3231-master/MD_DS3231.cpp.o
collect2: error: ld returned 1 exit status
exit status 1
Fehler beim Kompilieren für das Board NodeMCU 1.0 (ESP-12E Module).

The Sketch:

Code: [Select]

/ Use the DS3231 clock module
#define  USE_DS3231  1

// Header file includes
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include "Font_Data.h"

#if USE_GENERIC_HW || USE_PAROLA_HW
#define INVERT_UPPER_ZONE
#endif

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define MAX_ZONES 2
#define ZONE_SIZE 12
#define MAX_DEVICES (MAX_ZONES * ZONE_SIZE)
//#define MAX_DEVICES 16

#define ZONE_UPPER  1
#define ZONE_LOWER  0

#define CLK_PIN  14 // D6
#define DIN_PIN  13 // D8
#define CS_PIN   15 // D7

#if USE_DS3231
#include <MD_DS3231.h>
#include <Wire.h>
#endif

// Hardware SPI connection / Arbitrary output pins
MD_Parola P = MD_Parola(DIN_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

#define SPEED_TIME  75
#define PAUSE_TIME  0

#define MAX_MESG  10

// Turn on debug statements to the serial output
#define  DEBUG  0

// Global variables
char  szTimeL[MAX_MESG];    // mm:ss\0
char  szTimeH[MAX_MESG];

void getTime(char *psz, bool f = true)
// Code for reading clock time

// HH:MM:SS Von mir !
{
#if USE_DS3231
  RTC.readTime();
  sprintf(psz, "%02d%c%02d%c%02d", RTC.h, (f ? ':' : ' '), RTC.m, (f ? ':' : ' '), RTC.s);
#else
  uint16_t  h, m, s;
 
  m = millis()/1000;
  h = (m/60) % 24;
  m %= 60;
  sprintf(psz, "%02d%c%02d%c%02d", h, (f ? ':' : ' '), m, (f ? ':' : ' '), s);
#endif
}

void createHString(char *pH, char *pL)
{
  for (; *pL != '\0'; pL++)
    *pH++ = *pL | 0x80;   // offset character

  *pH = '\0'; // terminate the string
}

void setup(void)
{
  // initialise the LED display
  P.begin(MAX_ZONES);

  // Set up zones for 2 halves of the display
  P.setZone(ZONE_LOWER, 0, ZONE_SIZE - 1);
  P.setZone(ZONE_UPPER, ZONE_SIZE, MAX_DEVICES - 1);
  P.setFont(numeric7SegDouble);
//  P.setFont(BigFontBottom);
  P.setCharSpacing(P.getCharSpacing() * 2); // double height --> double spacing

#ifdef INVERT_UPPER_ZONE
  P.setZoneEffect(ZONE_UPPER, true, PA_FLIP_UD);
  P.setZoneEffect(ZONE_UPPER, true, PA_FLIP_LR);

  P.displayZoneText(ZONE_LOWER, szTimeL, PA_RIGHT, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
  P.displayZoneText(ZONE_UPPER, szTimeH, PA_LEFT, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
#else
  P.displayZoneText(ZONE_LOWER, szTimeL, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
  P.displayZoneText(ZONE_UPPER, szTimeH, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
#endif

#if USE_DS3231
  RTC.control(DS3231_CLOCK_HALT, DS3231_OFF);
  RTC.control(DS3231_12H, DS3231_OFF);
#endif
}

void loop(void)
{
  static uint32_t lastTime = 0; // millis() memory
  static bool flasher = false;  // seconds passing flasher

  P.displayAnimate();
  P.setIntensity(1); // Display Intensity
  if (P.getZoneStatus(ZONE_LOWER) && P.getZoneStatus(ZONE_UPPER))
  {
    // Adjust the time string if we have to. It will be adjusted
    // every second at least for the flashing colon separator.
    if (millis() - lastTime >= 1000)
    {
      lastTime = millis();
      getTime(szTimeL, flasher);
      createHString(szTimeH, szTimeL);
      flasher = !flasher;

      P.displayReset();

      // synchronise the start
      P.synchZoneStart();
    }
  }
}

marco_c

If you can't resolve those errors yourself, then please just use the DS1307 library.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

robiv8

Pity, had the hope that it would simply be exchangeable as you said.
Since I have as I have no idea of programming, I do not know where to change what would be the error message.
Any tip?

robiv8

#26
Oct 06, 2017, 05:28 pm Last Edit: Oct 06, 2017, 05:43 pm by robiv8
So! With a little help in a other forum i have resolved the code error problem.
The Sketch is now using the DS3231
I have also edited the font. :-)

Now i will try to implement this code in my Sketch.


robiv8

#27
Oct 06, 2017, 07:54 pm Last Edit: Oct 06, 2017, 11:35 pm by robiv8
I realize that the parola code runs with the MD_DS3231.h. My sketch runs with the DS3231.h

How can i fix this? Can you give me a hint.

Here are my code what i am building, it is work and the serial Monitor says Wlan is connected and the time is set. But the Clock starts with 00:00:00
I mean it is because the DS3231 is set by ntp and not the MD_DS3231

Code: [Select]

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <DS3231.h>
#include <Wire.h>
#include <TimeLib.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include "Font_Data2.h"

const char *ssid = "Daisy*****";
const char *password ="12345*****";

// NTP Servers:
//IPAddress timeServer(192, 168, 179, 1);  //meine.fritz.box //(192, 168, 179, 1);
IPAddress timeServer(192, 53, 103, 108);  //ptbtime1.ptb.de //(192, 43, 244, 18);

WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP
unsigned int localPort = 8888;      // local port to listen for UDP packets

const int timeZone = 1;     // Central European Time
//const int timeZone = -5;  // Eastern Standard Time (USA)

//DS3231-Clock
DS3231 Clock;
bool Century=false;
bool h12;
bool PM;

#if USE_GENERIC_HW || USE_PAROLA_HW
#define INVERT_UPPER_ZONE
#endif

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define MAX_ZONES 2
#define ZONE_SIZE 12
#define MAX_DEVICES (MAX_ZONES * ZONE_SIZE)
//#define MAX_DEVICES 16

#define ZONE_UPPER  1
#define ZONE_LOWER  0

#define CLK_PIN  14 // D6
#define DIN_PIN  13 // D8
#define CS_PIN   15 // D7

#if USE_DS3231
#include <MD_DS3231.h>
#include <Wire.h>
#endif

// Hardware SPI connection / Arbitrary output pins
MD_Parola P = MD_Parola(DIN_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

#define SPEED_TIME  75
#define PAUSE_TIME  0

#define MAX_MESG  10

// ################################# MAX7219 ##########################

// Global variables
char  szTimeL[MAX_MESG];    // mm:ss\0
char  szTimeH[MAX_MESG];

void getTime(char *psz, bool f = true)
// Code for reading clock time

// HH:MM:SS By me !
{
#if USE_DS3231
  RTC.readTime();
  sprintf(psz, "%02d%c%02d%c%02d", RTC.h, (f ? ':' : ' '), RTC.m, (f ? ':' : ' '), RTC.s);
#else
  uint16_t  h, m, s;
 
  m = millis()/1000;
  h = (m/60) % 24;
  m %= 60;
  sprintf(psz, "%02d%c%02d%c%02d", h, (f ? ':' : ' '), m, (f ? ':' : ' '), s);
#endif
}

void createHString(char *pH, char *pL)
{
  for (; *pL != '\0'; pL++)
    *pH++ = *pL | 0x80;   // offset character

  *pH = '\0'; // terminate the string
}

boolean cleared = false;

void setup() {
  //clock
    Wire.begin(); //clock communication
    Serial.begin(115200);
  //display
 
  String errormessage ="";
 
  //scan for networks
  if(scan_for_network(errormessage) == true)
  {
    //network found
    Serial.println("Netzwerk " + String(ssid) + " gefunden");
    //try connecting to network
    if(connect_to_network() == true)
    {
      //connected to network
      Serial.println("Mit Netzwerk " + String(ssid) + " verbunden");
      Serial.println("IP address: ");
      Serial.println(WiFi.localIP());

      Serial.println("Starting UDP");
      Udp.begin(localPort);
      Serial.print("Local port: ");
      Serial.println(Udp.localPort());
     
      //set clock
      if(settime()==true)
      {
        //Clock has been set
        WiFi.disconnect();
        Serial.println("Die Uhrzeit wurde gesetzt: " + String(Clock.getHour(h12,PM)) + ":" + String(Clock.getMinute()));
        delay(500);
      }
      else
      {
        Serial.println("Could not set the RTC.");
      }
    }
    else
    {
      Serial.println("Netzwerkname gefunden, es konnte keine Verbindung hergestellt werden. Falsches Passwort?");
    }
  }
  else
  {
     Serial.println(errormessage);
  }
// initialise the LED display
  P.begin(MAX_ZONES);

  // Set up zones for 2 halves of the display
  P.setZone(ZONE_LOWER, 0, ZONE_SIZE - 1);
  P.setZone(ZONE_UPPER, ZONE_SIZE, MAX_DEVICES - 1);
  P.setFont(numeric7SegDouble);
//  P.setFont(BigFontBottom);
  P.setCharSpacing(P.getCharSpacing() * 2); // double height --> double spacing

#ifdef INVERT_UPPER_ZONE
  P.setZoneEffect(ZONE_UPPER, true, PA_FLIP_UD);
  P.setZoneEffect(ZONE_UPPER, true, PA_FLIP_LR);

  P.displayZoneText(ZONE_LOWER, szTimeL, PA_RIGHT, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
  P.displayZoneText(ZONE_UPPER, szTimeH, PA_LEFT, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
#else
  P.displayZoneText(ZONE_LOWER, szTimeL, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
  P.displayZoneText(ZONE_UPPER, szTimeH, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
#endif

#if USE_DS3231
  RTC.control(DS3231_CLOCK_HALT, DS3231_OFF);
  RTC.control(DS3231_12H, DS3231_OFF);
#endif

}

//main loop: show time, add your own code to display it
void loop()
{
  static uint32_t lastTime = 0; // millis() memory
  static bool flasher = false;  // seconds passing flasher

  P.displayAnimate();
  P.setIntensity(1); // Display Intensity
  if (P.getZoneStatus(ZONE_LOWER) && P.getZoneStatus(ZONE_UPPER))
  {
    // Adjust the time string if we have to. It will be adjusted
    // every second at least for the flashing colon separator.
    if (millis() - lastTime >= 1000)
    {
      lastTime = millis();
      getTime(szTimeL, flasher);
      createHString(szTimeH, szTimeL);
      flasher = !flasher;

      P.displayReset();

      // synchronise the start
      P.synchZoneStart();
    }
  }
}


marco_c

The library you use makes no difference to the way the clock works.

The RTC will start at 0 unless you have a battery back up for the time. Once set it should continue to work until the power is removed.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

robiv8

Trank for your coment,
The DS3231 is working good without the Parola code. So its in good condition and the Batterie is new and full.

The DS3231 gets also the right time set, which I can examine if I attach it at another clock without Wlan.
I mean the problem is not the RTC but the code or MD_DS3231.
I believe the DS3231 and MD_DS3231 interfere with each other.?

Have you looked at the code times briefly?

Go Up