[discontinued] Need help for a clock with Parola Double Height

Hallo everybody, i need help with this code. The code is working but i need seconds too. hh:mm:ss How can i resolve this.

Thanks for help

// Use the DS1307 clock module
#define USE_DS1307  1

// Header file includes
#include 
#include 
#include 
#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 8
#define MAX_DEVICES (MAX_ZONES * ZONE_SIZE)
//#define MAX_DEVICES 16

#define ZONE_UPPER  1
#define ZONE_LOWER  0

#define CLK_PIN   14
#define DATA_PIN  13
#define CS_PIN    15

#if USE_DS1307
#include 
#include 
#endif

// Hardware SPI connection
//MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);
// Arbitrary output pins
MD_Parola P = MD_Parola(DATA_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
// Simulated clock runs 1 minute every second
{
#if USE_DS1307
  RTC.readTime();
  sprintf(psz, "%02d%c%02d", RTC.h, (f ? ':' : ' '), RTC.m);
#else
  uint16_t  h, m, s;
  
  m = millis()/1000;
  h = (m/60) % 24;
  m %= 60;
  sprintf(psz, "%02d%c%02d", h, (f ? ':' : ' '), m);
#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.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_DS1307
  RTC.control(DS1307_CLOCK_HALT, DS1307_OFF);
  RTC.control(DS1307_12H, DS1307_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();
    }
  }
}

Are you using a ds1307?

void getTime(char *psz, bool f = true)
// Code for reading clock time
// Simulated clock runs 1 minute every second
{
#if USE_DS1307
  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
}

Hallo,
yes! a DS3231 and works fine and show the correct time

Thank you for the code, it works :slight_smile:
But 1 more problem.
The whole time does not fit anymore.
It is offset by one and a half segments. How do I get this fixed.
Has something to do with the font?
I have 2 pictures attached, the first as it comes and the second when I move the segments.

IMG_6340 (1).jpg

IMG_6341 (1).jpg

|500x375 |500x375

Maybe try increasing MAX_MESG by a few more characters. But in theory it should be enough already.

You need someone expert in Parola library to help you.

Try using a fixed width font instead of a variable spaced font. when you invert the top section variable spaced may not line up. You can also try left or right justify rather than centered so that the time lines up on one edge.

Thanks to both for the support. I have no idea of programming, but will try. Is there any finished fonts I can test?

If the font was only slightly narrower, it would fit. And if I knew how I could shorten the code in the "Font_Data.h" I would do that. Is there an online tool where I can create the ones and it me the values which I can then enter or replace?

Look at the documentation for MD_Max72xx library, especially around fonts. There is a font builder with the library.

Also look at the blog site next to my ID block on the left and search for "Parola A to Z", there are a few articles on how to use and also about double height displays.

OK Thank you. I will search and look at your hints.

So is there a newer Parola MD_MAX72xx Font Builder v1 In my missing the "Double Height Enabled" Checkbox. There is in Work Sheet only Project:, Show all and Copy to Clipboard

THX

Sorry i found the V2 :-) But it is only for Windows! and i am a Mac user :-) And yes! Windows, because it is Activ X required. So i must search these days a windows PC in my Office and hope i have rights for Activ X

Where did you get the library from? Please download the latest copy from my distribution site on Github. Or use the library manager in the ide to download.

OK I looked at it and realized that it is too high for me. I do not understand that. So this has been done and I give up. Maybe I'll find another solution. I thank you for your support.

Sorry to hear that but if you are a beginner maybe you should start with a single height display first.

news :: news :: news :: news

I wrote: Maybe I'll find another solution. And I found one. I have buy two more modules and now i have room for the whole time.

But i will maybe soon still need your help ;-)

I have a clock built with 8Dig7Segment which takes itself by Wlan and Ntp the time and brings into the RTC. If no Wlan is on then it takes the time from the RTC. This works excellently. So! And now I would like this with my big clock. If I do not go further I ask here :-)

regards Robert

So that I do not spend nights with it for free, is there a chance to implement the code from Post1 into this sketch without great programing? This I also use for my 8dig7segment display. But there runs with LedControl :frowning:
Thanks Robert

weg-set-rtc-via-wifi_Deutsch_matrix.ino (1.68 KB)

search_connect_network.ino (1.43 KB)

ntp_functions.ino (3.83 KB)

1 week no answer!
Nobody can help me?

I can't understand the question and I suppose others cannot either.

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

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.

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