HX1230_FB improving DS3231 time display

I am starting a project for monitoring/controlling the enviroment in my greehouse using the HX1230 display as a local inicator. I am comfortable with the progamming/display of the sensor data but the code I am using for for adding a time stamp to the screen is, I think, very “clunky”. Due to the nature of the HX1230_FB.h library the most documented “fixes” for buffering zero’s don’t appear available to me as it appears the the only command I have to print to the screen is “print.Str”.

I have done a lot of trawling the internet and have found no solution.

If anyone could point me to a refernce it would be much appreciated.

// HX1230 96x68 LCD FB library example
// (c) 2019 Pawel A. Hernik

/*
  HX1230 96x68 LCD connections (header on bottom, from left):
  #1 RST - D6 or any digital
  #2 CE  - D7 or any digital
  #3 N/C
  #4 DIN - D11/MOSI
  #5 CLK - D13/SCK
  #6 VCC - 3V3
  #7 BL  - 3V3 or any digital
  #8 GND - GND
*/
#include <DS3231_Simple.h>
#include "HX1230_FB.h"
#include <SPI.h>

#include "c64enh_font.h" // from PropFonts library

#define LCD_RST 6
#define LCD_CS  7
#define LCD_BL  8

HX1230_FB lcd(LCD_RST, LCD_CS);
DS3231_Simple Clock;


void setup()
{
  Serial.begin(9600);
  pinMode(LCD_BL, OUTPUT); //Backlight on
  //analogWrite(LCD_BL,30);
  digitalWrite(LCD_BL, HIGH);

  SPI.begin();
  Clock.begin(); // start clock
  lcd.init(); // Start HX1230
  lcd.cls();
  lcd.setFont(c64enh);


}

void loop()
{


  DateTime now; // Create a variable to hold the data
  now = Clock.read(); // Ask the clock for the data.

  float H = (now.Hour); // Hours
  char H_string[2];

  float M = (now.Minute); // Minutes
  char M_string[2];

  float S = (now.Second); // Seconds
  char S_string[2];

    
  lcd.cls();

  dtostrf(H, 2, 0, H_string); //convert float to string
  lcd.printStr(0, 0, H_string);
  lcd.printStr(17, 0, ":");
  dtostrf(M, 2, 0, M_string); //convert float to string
  lcd.printStr(21, 0, M_string);
  lcd.printStr(37, 0, ":");
  dtostrf(S, 2, 0, S_string); //convert float to string
  lcd.printStr(41, 0, S_string);


  delay (1000);
  lcd.display();

}

why do you converting all your time elements to floating point numbers? They are integers. You can also use sprinf() to create your formatted string

// HX1230 96x68 LCD FB library example
// (c) 2019 Pawel A. Hernik

/*
  HX1230 96x68 LCD connections (header on bottom, from left):
  #1 RST - D6 or any digital
  #2 CE  - D7 or any digital
  #3 N/C
  #4 DIN - D11/MOSI
  #5 CLK - D13/SCK
  #6 VCC - 3V3
  #7 BL  - 3V3 or any digital
  #8 GND - GND
*/
#include <DS3231_Simple.h>
#include "HX1230_FB.h"
#include <SPI.h>

#include "c64enh_font.h" // from PropFonts library

#define LCD_RST 6
#define LCD_CS  7
#define LCD_BL  8

HX1230_FB lcd(LCD_RST, LCD_CS);
DS3231_Simple Clock;


void setup()
{
  Serial.begin(9600);
  pinMode(LCD_BL, OUTPUT); //Backlight on
  //analogWrite(LCD_BL,30);
  digitalWrite(LCD_BL, HIGH);

  SPI.begin();
  Clock.begin(); // start clock
  lcd.init(); // Start HX1230
  lcd.cls();
  lcd.setFont(c64enh);
}

void loop()
{
  DateTime now; // Create a variable to hold the data
  now = Clock.read(); // Ask the clock for the data.

  int H = (now.Hour); // Hours
  int M = (now.Minute); // Minutes
  int S = (now.Second); // Seconds
  char string[20];

  lcd.cls();

  sprintf(string, "%02d:%02d:%02d", H, M, S);
  lcd.printStr(41, 0, string);
  delay (1000);
  lcd.display();
}

I was working from a wrong assumption based on the the code I used for my sensors which are floating point numbers.

I think an appropriate adage would be:

"cutting 6" from the bottom of a blanket and sewing it to the top doesn't make it longer"

Thank you for your help