View time on LCD 5110

I'm using this 5110 library: http://www.rinkydinkelectronics.com/library.php?id=47 I get the time with DCF77 and this library: https://github.com/udoklein/dcf77

Can somebody explain what this does:

void paddedPrint(BCD::bcd_t n) {
   Serial.print(n.digit.hi);
   Serial.print(n.digit.lo);
}

Serial output works but i can't figure out how to show it on the LCD.

This does not work:

void paddedPrint(BCD::bcd_t n) {
   Serial.print(n.digit.hi);
   Serial.print(n.digit.lo);
}

void LCDpaddedPrint(BCD::bcd_t n) { 
  lcd.print(n.digit.hi);
  lcd.print(n.digit.lo);
}

void loop() {

   Clock::time_t now;

   DCF77_Clock::get_current_time(now);
   if (now.month.val > 0) {
      paddedPrint(now.second);

      LCDpaddedPrint(now.second, CENTER, 3);

   }

}

I get the compiling error: no matching function for call to 'LCD5110::print(unsigned char:4&)'

I don't think your code

void LCDpaddedPrint

has the slightest thing to do with the RinkyDink LCD library. The great thing about the Henning Karlsen libraries is their comprehensive manuals, which you seem to have ignored, and their easily understood examples, likewise. I don't know anything about the DCF77 but you evidently have that under control using the monitor, and it is really just a matter of sending the same values to LCD in the kosher manner.

I still don’t know what “BCD::bcd_t n” and “print(n.digit.hi)” does.
But i switch the LCD library to U8g2 because the other one has not much font choices.
With U8g2 it works.

I wonder if there is something to improve it.
The output to Serial1 should be as fast as possible so that the delay of receiving/decoding the time and sending it to the server (RPi) is as short as possible.
My concern is that writing to the LCD does introduce some lag.

/**************************************************************
* CONNECTION Pro Micro                                        *
***************************************************************
LCD GND              <> GND
LCD VCC              <> 3.3V
LCD CLK/SCLK/SCK     <> D15 SCK
LCD DIN/DN/MOSI/DATA <> D16 MOSI
LCD DC/"D/C"         <> D9
LCD CE/CS/SCE        <> D8
LCD RST              <> D7

DCF77 Receiver DCF   <> D21
DCF77 Monitor LED    <> D6

**************************************************************/

#include <dcf77.h>    // Get it here: github.com/udoklein/dcf77
#include <U8g2lib.h>  // Get it here: github.com/olikraus/u8g2

/**************************************************************
* LCD 5110 (U8g2lib) SETUP                                    *
**************************************************************/
const unsigned int CLOCK_PIN = 15, DATA_PIN = 16, CS_PIN = 8, DC_PIN = 9, RESET_PIN = 7;
U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2 = U8G2_PCD8544_84X48_1_4W_HW_SPI(U8G2_R0, CS_PIN, DC_PIN, RESET_PIN); // HW SPI

/**************************************************************
* DCF77 SETUP                                                 *
**************************************************************/
const uint8_t dcf77_sample_pin = 21; // D21 == A3
const uint8_t dcf77_inverted_samples = 1;
const uint8_t dcf77_pin_mode = INPUT_PULLUP;  // enable internal pull up
const uint8_t dcf77_monitor_pin = 6;

uint8_t sample_input_pin() {
   const uint8_t sampled_data =
      dcf77_inverted_samples ^ digitalRead(dcf77_sample_pin);

   digitalWrite(dcf77_monitor_pin, sampled_data);
   return sampled_data;
}

/**************************************************************
* MISC SETUP                                                  *
**************************************************************/
#define DEBUG 1 // Set to 1 for USB serial output

// Define unused pins
const uint8_t pin[] = {2, 3, 5, 14};                 // Array of unused digital pins
const uint8_t pinA[] = {A0, A1, A2, A6, A10};        // Array of unused analog pins
uint8_t pinCount = sizeof(pin) / sizeof(pin[0]);     // Count unused digital pins
uint8_t pinACount = sizeof(pinA) / sizeof(pinA[0]);  // Count unused analog pins

/**************************************************************
* SETUP                                                       *
**************************************************************/
void setup() {
  for (uint8_t i = 0; i < pinCount; i++) {
    pinMode(pin[i], INPUT_PULLUP);    // Set unused digital pins as input and HIGH
  }

  for (uint8_t i = 0; i < pinACount; i++) {
    pinMode(pinA[i], INPUT_PULLUP);   // Set unused analog pins as input and HIGH
  }

  pinMode(dcf77_monitor_pin, OUTPUT);
  pinMode(dcf77_sample_pin, dcf77_pin_mode);

  DCF77_Clock::setup();
  DCF77_Clock::set_input_provider(sample_input_pin);

  startupTasks(); // Run tasks
}

void startupTasks() {
  #ifdef DEBUG
    Serial.begin(9600);
  #endif // END DEBUG
  Serial1.begin(9600, SERIAL_7E2);

  u8g2.begin();
  u8g2.enableUTF8Print();
  u8g2.setContrast(135);

  // Wait till clock is synced
  for (uint8_t state = Clock::useless;
    state == Clock::useless || state == Clock::dirty;
    state = DCF77_Clock::get_clock_state()) {

    // wait for next sec
    Clock::time_t now;
    DCF77_Clock::get_current_time(now);

    #ifdef DEBUG
      // render one dot per second while initializing
      static uint8_t count = 0;
      Serial.print('.');
      ++count;
      if (count == 60) {
        count = 0;
        Serial.println();
      }
    #endif // END DEBUG
  }
}


void paddedPrintUSB(BCD::bcd_t n) {
  Serial.print(n.digit.hi);
  Serial.print(n.digit.lo);
}

void paddedPrint(BCD::bcd_t n) {
  Serial1.print(n.digit.hi);
  Serial1.print(n.digit.lo);
}

void LCDpaddedPrint(BCD::bcd_t n) { 
  u8g2.print(n.digit.hi);
  u8g2.print(n.digit.lo);
}

Rest of the code:

/**************************************************************
* MAIN LOOP                                                   *
**************************************************************/
void loop() {
  const char STX = 2;
  const char ETX = 3;

  Clock::time_t now;

  DCF77_Clock::get_current_time(now);
  if (now.month.val > 0) {
    Serial1.print(STX);
    
    Serial1.print("D:");
    paddedPrint(now.day);
    Serial1.print('.');
    #ifdef DEBUG
      Serial.println();
      paddedPrintUSB(now.day);
      Serial.print('.');
    #endif // END DEBUG
    paddedPrint(now.month);
    Serial1.print('.');
    #ifdef DEBUG
      paddedPrintUSB(now.month);
      Serial.print('.');
    #endif // END DEBUG      
    paddedPrint(now.year);
    Serial1.print(';');
    #ifdef DEBUG
      paddedPrintUSB(now.year);
      Serial.print(' ');
    #endif // END DEBUG

    Serial1.print("T:");
    Serial1.print(now.weekday.digit.lo);
    Serial1.print(';');
    #ifdef DEBUG
      Serial.print("T:");
      Serial.print(now.weekday.digit.lo);
      Serial.print(' ');
    #endif // END DEBUG

    Serial1.print("U:");
    paddedPrint(now.hour);
    Serial1.print('.');
    #ifdef DEBUG
      paddedPrintUSB(now.hour);
      Serial.print(':');
    #endif // END DEBUG
    paddedPrint(now.minute);
    Serial1.print('.');
    #ifdef DEBUG
      paddedPrintUSB(now.minute);
      Serial.print(':');
    #endif // END DEBUG
    paddedPrint(now.second);
    Serial1.print(';');
    #ifdef DEBUG
      paddedPrintUSB(now.second);
      Serial.print(' ');
    #endif // END DEBUG

    uint8_t state = DCF77_Clock::get_clock_state();
    Serial1.print(
      state == Clock::useless || state == Clock::dirty? '#'  // not synced
                                                      : ' '  // good
    );

    Serial1.print(
      state == Clock::synced || state == Clock::locked? ' '  // DCF77
                                                      : '*'  // crystal clock
    );

    #ifdef DEBUG
      switch (state) {
        case Clock::useless: Serial.print(F("useless")); break;
        case Clock::dirty:   Serial.print(F("dirty")); break;
        case Clock::synced:  Serial.print(F("synced")); break;
        case Clock::locked:  Serial.print(F("locked")); break;
      }
      Serial.print(' ');
    #endif // END DEBUG

    Serial1.print(now.uses_summertime? 'S': ' ');
    #ifdef DEBUG
      Serial.print(now.uses_summertime? "Summer": "Winter");
      Serial.print(' ');
    #endif // END DEBUG
    Serial1.print(
    now.timezone_change_scheduled? '!':
    now.leap_second_scheduled?     'A':
                                   ' '
    );

    Serial1.print(ETX);

    uint8_t signalQual = DCF77_Clock::get_prediction_match();
    if(signalQual == 255 || signalQual == 0 ){
      signalQual = 00;
    } else {
      signalQual = signalQual * 2;
    }
    #ifdef DEBUG
      Serial.print("Quality ");
      Serial.print(signalQual);
      Serial.print("%");
    #endif // END DEBUG

    u8g2.firstPage();
    do {
      u8g2.setFont(u8g2_font_crox4hb_tr); // 14px
      u8g2.setCursor(3, 15);
      LCDpaddedPrint(now.hour);
      u8g2.setCursor(25, 15);
      u8g2.print(":");
      u8g2.setCursor(31, 15);
      LCDpaddedPrint(now.minute);
      u8g2.setCursor(53, 15);
      u8g2.print(":");
      u8g2.setCursor(59, 15);
      LCDpaddedPrint(now.second);

      u8g2.setFont(u8g2_font_profont11_tr); // 11px
      u8g2.setCursor(12, 25);
      u8g2.print(now.uses_summertime? "Sommerzeit": "Winterzeit");
    
      u8g2.setCursor(7, 35);
      switch (state) {
        case Clock::useless: u8g2.print("Useless"); break;
        case Clock::dirty:   u8g2.print("Dirty"); break;
        case Clock::synced:  u8g2.print("Synced"); break;
        case Clock::locked:  u8g2.print("Locked"); break;
      }
      u8g2.setCursor(54, 35);
      u8g2.print(signalQual);
      u8g2.setCursor(72, 35);
      u8g2.print("%");

      u8g2.setCursor(5, 46);
      u8g2.print("D");
      u8g2.setCursor(11, 46);
      u8g2.print(now.weekday.digit.lo);
         
      u8g2.setCursor(22, 46);
      LCDpaddedPrint(now.day);
      u8g2.setCursor(33, 46);
      u8g2.print(".");
      u8g2.setCursor(39, 46);
      LCDpaddedPrint(now.month);
      u8g2.setCursor(50, 46);
      u8g2.print(".");
      u8g2.setCursor(56, 46);
      u8g2.print("20");
      u8g2.setCursor(68, 46);
      LCDpaddedPrint(now.year);
    } while ( u8g2.nextPage() );        
  }
}

My concern is that writing to the LCD does introduce some lag.

You misspelled considerable.

Why do you need to tell the RPi what time it is? It has a clock.

The original function paddedPrint() is almost certainly taking (some form of) a byte, representing, in your case, a pair of digits from a time/date stamp and printing these with, if required, a leading zero.

You can do it yourself:

void myPaddedPrint(byte n) {
  Serial.print(n/10);  // first digit (can be zero)
  Serial.print(n%10);  // second digit
}

PaulS: You misspelled considerable.

Why do you need to tell the RPi what time it is? It has a clock.

The RPi has no RTC and is getting it's time with NTP from the internet (timeservers). Without a RTC and internet you lose the time after reboot.

I get the time from DCF77: https://en.wikipedia.org/wiki/DCF77 Then the RPi is the timeserver where all other network devices get the time from.

https://www.meinbergglobal.com/english/products/ru226.htm https://www.meinbergglobal.com/english/products/pci-express-clocks.htm https://www.meinbergglobal.com/english/products/ntp-time-server.htm