Omit leading zero on Led clock

Help please I don't know how you all do this coding stuff I'm about to loose what hair I got left
I have taken a couple of codes off the web and patched then together and I have got my clock
working but I will be dammed if I can figure out how to remove the leading zero on hour
I'm wanting it to show 1:00 not 01:00
any help with the would be so much appreciated
My code is below
Thanks
Kenkay

#include <FastLED.h>
#include <Wire.h>
#include "RTClib.h"
#define NUM_LEDS 30
#define DATA_PIN 6
#define wait_time 10
CRGB LEDs[NUM_LEDS];
// Convert ten CHSV rainbow values to ten CRGB values;
// CHSV hsvs[10];
// CRGB leds[10];
// (set hsv values here)
// hsv2rgb_rainbow( hsvs, leds, 10); // convert all
//char* c="colour1";
CRGB color = CRGB::Red; //Clock Numbers
//CRGB color = colour();
CRGB color1 = CRGB::White;//Center Blinking Dots

//int fill_rainbow( &(leds[i]), 1 /led count/, 222 /starting hue/);
RTC_DS3231 rtc;
uint8_t hue = 0;
void setup () {

FastLED.delay(3000);
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(LEDs, NUM_LEDS);

Serial.begin(9600);
while (!Serial) {
}

if (!rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}

if (rtc.lostPower()) {
Serial.println("RTC lost power, lets set the time!");
// below line sets the RTC with provided date & time (April 26, 2020 at 12:30).
//rtc.adjust(DateTime(2020, 4, 26, 5, 12, 0));
}
// rtc.adjust(DateTime(2021, 4, 22, 7, 5, 0));
}

void loop () {

DateTime now = rtc.now();

int hl = now.hour() / 10;
int hr = now.hour() % 10;
int ml = now.minute() / 10;
int mr = now.minute() % 10;

displayTime(0, mr);
displayTime(7, ml);
displayTime(16, hr);
displayTime(23, hl);

FastLED.show();

// delay(1000 * 29);

LEDs[14] = color1;
LEDs[15] = color1;
FastLED.show();
delay(1000);
LEDs[14] = CRGB::Black;
LEDs[15] = CRGB::Black;
FastLED.show();
delay(1000);

  }

void displayTime(int startindex, int number) {

byte numbers[] = {
0b00111111, // 0
0b00000110, // 1
0b01011011, // 2
0b01001111, // 3
0b01100110, // 4
0b01101101, // 5
0b01111101, // 6
0b00000111, // 7
0b01111111, // 8
0b01101111, // 9
};

for (int i = 0; i < 7; i++) {
LEDs[i + startindex] = ((numbers[number] & 1 << i) == 1 << i) ? color : CRGB::Black;

}

}

I hope you can see that this the line what prints the tens of hours.

So what you can do is test right there if. it would be making a zero, and don't do that.

You'll have to turn off all the segments from before when it wasn't zero:

To turn off that digit, you could add one more pattern to your byte number[] array, like

0b00000000 // all segments off

and when you want a blank instead use displayTime(10);

displayTime is badly named, dispalyDigit would be more sense.

a7

Thanks alto777
but that's all over my head
Can you fix it for me and I will pay you
I have been days on this and getting nowhere
If you are interested let me know please

Please confirm that at this point, it all works, works perfectly with the single exception of having a zero display in the tens column.

And does everything you need otherwise.

BTW programming can be a slog, lotta people with less hair than they once had, so don't feel too bad.

a7

Using alto777's suggestion, it would be something like this

displayTime(23, hl != 0 ? hl : 10);

Then in displayTime add a line at the end of the array:

0b01111111, // 8
0b01101111, // 9
0           // 10 (all segments off)

works great got the center dots blinking and everything is fine except the leading zero on the hour
at 10:00 ,11:00 ,12;00 works great

Yes. In case @kenkay wants to make a bit of sense of this, a beginner might have written

  if (hl != 0)
    displatTime(hL);
  else
    displatTime(10);

a7

I'm not even a beginner I suck at this

where do I insert display time ?
I got the bottom part
Thanks guix

alto777
Do you have an Email that I can contact you at ?
There are a couple of things I would like to ask you
Thanks
Kenkay
Mine is Kenkay321@yahoo.com

The forum has a PM private message mechanism, use that if you must but it is far better to just post your questions.

After all, look at the fish @guix fed you whilst I was trying to help you see the light and learn a bit (more) about fishing…

More eyes better. More answers, different styles and points of view &c.

a7

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.