How set digital point ON/Off every second? (Clock project)

Hi to all,
I’m building a clock with 2 x 7 segments display x 4 digits (so 2 display in total, every one with a 4 digit).

Every digit has the Digital Point. They are driven via a MAX7219.

I’m using LedControl library (https://playground.arduino.cc/Main/LedControl).

All works very well, but my goal is light the digital point of 6’digit for 1 second, and after 1 second light off. In same time last 2 digits need to be increment, of course.

WIth my demo sketch I got only to mantain light on or off every 1/2 sec. I would that 1 second it be on, 1 second be off.

This is current mode: 2017-12-17 20.35.37 on Vimeo
You can see the DP only half second. I would it 1 second.

This is my sketch:

/**
 * Clock with RTC and 2 x 7 segments display
 * 
 * @ver 1.0
 * 
 * Testing from 17/12/2017
 */

#include "LedControl.h"

#define PIN_DATA_IN 11
#define PIN_CLK     12
#define PIN_LOAD    13
#define NUM_MAX7219 1

/*
 Now we need a LedControl to work with.
 */
LedControl lc=LedControl(PIN_DATA_IN , PIN_CLK , PIN_LOAD , NUM_MAX7219);

/**
 * Our setup.
 * 
 * @since 1.0
 */

void setup() {

  setupMax7219();
  Serial.begin(57600);
  
}

/**
 * Our loop
 * 
 * @since 1.0
 */
void loop() {

  printHour(193200);
  
}

void setupMax7219() {

  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
  lc.shutdown(0,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0,8);
  /* and clear the display */
  lc.clearDisplay(0);
  
}

void printHour ( long hour ) {

  //int ones, tens, hundreds, thousands;
  int digit_1 , digit_2 , digit_3 , digit_4 , digit_5 , digit_6;

  digit_6 = hour%10;
  digit_5 = ((hour/10)%10);
  digit_4 = ((hour/100)%10);
  digit_3 = ((hour/1000)%10);
  digit_2 = ((hour/10000)%10);
  digit_1 = ((hour/100000)%10);

  int i;

  for ( i = 1; i < 10; i++) {

    lc.setChar(0 , 0 , digit_1 , false);
    lc.setChar(0 , 1 , digit_2 , false);
    lc.setChar(0 , 2 , ' ' , false);
    lc.setChar(0 , 3 , digit_3 , false);
    lc.setChar(0 , 4 , digit_4 , false);
    lc.setChar(0 , 5 , ' ' , true);
    lc.setChar(0 , 6 , digit_5 , false);
    delay(500);
    lc.setChar(0 , 5 , ' ' , false);
    delay(500);
    lc.setChar(0 , 7 , i , false);

  }
  
}

This is a demo, from 0 to 9. I know that I don’t need to use the delay and time is not right, but I need to understand the logic for that DP.

Thank you

You only need to update your display once a second, eventually this will be from whatever clock you use.

void loop() {
  static boolean dp=false; 

  delay( 1000 ); // do everything once a second (from your clock eventually)

  printHour(193200);
}

Then, knowing it is only called once a second, you can flip the dp every time in printHour() like:

void printHour ( long hour ) {
  static boolean dp= false;

   ...

   lc.setChar(0 , 5 , ' ' , dp );  // output digit with dp

   dp= ! dp;  // flip the dp for next time

    ... don't do any delays in here
}

Yours,
TonyWilk

Thank you.

I did move the bool dp = false at the beginning of sketch, and now it works!

Thank you!