Using (DFR0469 RTC) with (DFR0645 display) problem

userHead Lucas.Barnes 2023-01-07 10:33:26 323 Views2 Replies

Hi All,

 

I've been searching and trying to find a way to display the current time in (HH.MM) on a 4 digit 7-segment display.  I've been able to get the RTC module and 7-segment display modulea talking just fine through the I2C bus on a arduino Nano.  I've basically combined some example code from DFR0469 and DFR0645, but I'm unable to display the time in HH.MM on the 7 segment display without generating code errors.  The attached code below ‘works’ but it flashes between hours and minutes with the first two digits being hours and the second two being minutes.  I would like to display all four digits at the same time.  As you can see below a lot of the ways I attempted are commented out as they did not work.  I had initially thought the line,  LED.print(rtc.hour, rtc.minute); would work but it yields the following error…  The serial monitor provided with IDE displays everything correctly too.

 

Error

 

C:\Documents\Arduino\ledPrint_test2_with_rtc_time\ledPrint_test2_with_rtc_time.ino: In function 'void loop()':
C:\Documents\Arduino\ledPrint_test2_with_rtc_time\ledPrint_test2_with_rtc_time.ino:58:17: warning: invalid conversion from 'uint8_t {aka unsigned char}' to 'const char*' [-fpermissive]
  LED.print(rtc.hour, rtc.minute);
            ~~~~^~~~
In file included from C:\Documents\Arduino\ledPrint_test2_with_rtc_time\ledPrint_test2_with_rtc_time.ino:1:0:
C:\Documents\Arduino\libraries\DFRobot_LedDisplayModule-master/DFRobot_LedDisplayModule.h:163:8: note:   initializing argument 1 of 'void DFRobot_LedDisplayModule::print(const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*)'
  void print(const char *buf1 = "82",const char *buf2 = "82",const char *buf3 = "82",const char *buf4 = "82",const char *buf5 = "82",const char *buf6 = "82",const char *buf7 = "82",const char *buf8 = "82");
       ^~~~~
C:\Documents\Arduino\ledPrint_test2_with_rtc_time\ledPrint_test2_with_rtc_time.ino:58:27: warning: invalid conversion from 'uint8_t {aka unsigned char}' to 'const char*' [-fpermissive]
  LED.print(rtc.hour, rtc.minute);
                      ~~~~^~~~~~
In file included from C:\Documents\Arduino\ledPrint_test2_with_rtc_time\ledPrint_test2_with_rtc_time.ino:1:0:
C:\Users\oakville\Documents\Arduino\libraries\DFRobot_LedDisplayModule-master/DFRobot_LedDisplayModule.h:163:8: note:   initializing argument 2 of 'void DFRobot_LedDisplayModule::print(const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*)'
  void print(const char *buf1 = "82",const char *buf2 = "82",const char *buf3 = "82",const char *buf4 = "82",const char *buf5 = "82",const char *buf6 = "82",const char *buf7 = "82",const char *buf8 = "82");
       ^~~~~ 

 

 

 

Code that flashes hours and minutes

 

# include "DFRobot_LedDisplayModule.h"
# include "Wire.h"
# include "GravityRtc.h"

 

GravityRtc rtc;   
DFRobot_LedDisplayModule LED(&Wire, 0x48);

void setup() 
{
 
 Serial.begin(115200);
 rtc.setup();
 Wire.begin();

 //rtc.adjustRtc(F(__DATE__), F(__TIME__));

}

void loop()

{
 /**
  * Display "HALO"
  * At present, it only supports showing the numbers 0 to 9, capital letters A, B, C, D, E, F, H, L, O, P, U and dash-,
  * and you can also bring decimal points, such as "0." "9." "A." "-."
  */
 
 rtc.read();
 
 //char hours[2];
 //char minutes[2];
 

 //LED.setDisplayArea(1,2,3,4);


 //hours[0,1] = rtc.hour;
 //minutes[0,1] = rtc.minute;
 
 
 //const char hourc = hour;
 //const char minutec = minute;
 
 LED.setBrightness(1);
     
 //LED.print("1","1","1","1");

 LED.setDisplayArea(1,2);
 
 LED.print(rtc.hour);
 delay(1000);
 
 LED.setDisplayArea(3,4);
 
 LED.print(rtc.minute);
 delay(500);
 
 //LED.print(rtc.hour, rtc.minute)
 //delay(500);
 
 Serial.print(rtc.hour);
 Serial.println(rtc.minute);
   
 /**
  * Show a viriable value
  * The viriable could be both integer and decimal
  * Here it can be compatible with the sensor return value, such as temperature, humdity and so on
  */
  
}

 

Any help would be greatly appreciated and I apologize in advance if I didn't format my post correctly.  I'm new to this forum.  

 

Thanks,

 

L

 

2023-01-11 21:12:04

I think the error shown in my first post means that the display is expecting characters rather than two integer values.  I'm not sure how to format the time as constant characters, but I would still like to know how if anyone can help.

Indigo credit login

userHeadPic Catherine.Wil
2023-01-08 07:41:25

All,

 

I figured out a work around for my problem.  I think the error shown in my first post means that the display is expecting characters rather than two integer values.  I'm not sure how to format the time as constant characters, but I would still like to know how if anyone can help.

I had the idea to format the time as a single integer of type double.  I know the display accepts double values as the library example shows.  I added the following lines to my code….

 

double  timetot = 0;

timetot = (rtc.hour*100)+rtc.minute;

 

This worked perfectly, but I also wanted to have the dot flash at 1s intervals between hours and minutes to show the clock is working.  I used the same principle and added the following….

 

double  timetot = 0;double  timedot = 0;

timetot = (rtc.hour*100)+rtc.minute;timedot = timetot/100;

 

LED.print(timetot);delay(1000);LED.print(timedot);delay(1000);

 

Now the clock works perfectly flashing the dot between the HH and MM at 1s intervals.

I would still like to know how to do this the ‘proper way’ by converting to const char but perhaps what I've done can help someone else in the same boat.

 

 

 

userHeadPic Lucas.Barnes