How to sync RTC date and time with OSD

Hi,

I tried OSD example available at GitHub - Ameba-AIoT/ameba-rtos-pro2: Realtek Official IoT Software Development Kit for Ameba Series SoC: (Ameba Pro2)

I found that the date and time are epoch time (1970-01-01 ….) and need to change it, so I called RTC functions as below before calling OSD functions, but still OSD displaying epoch time.

rtc_init();

rtc_write(1256729737);  // Set RTC time to Wed, 28 Oct 2009 11:35:37

I tried by calling below OSD functions also, but still epoch time only apperaring.

void rts_osd_isp_refresh_datetime(void);

enum rts_osd_err_code rts_osd2_set_time(int hour, int minute, int seconds);

enum rts_osd_err_code rts_osd2_set_date(int year, int month, int day);

Is anyone achieved OSD with different time than epoch time?

Thanks,

Yugandhar

Hi @yugandhar

You can consider using NTP Client.

Hi @pammyleong

Thanks for your suggestion, I am not asking about present date and time capture in Ameba board. I will get it from camera NVR and able to set with RTC module and when I read back also getting correct time, but the OSD module not using this time, still the date and time OSDs are showing epoch time. After calling rtc_write() I am calling below functions,but still all date and time OSDs are displayed with epoch time only. How to achieve the RTC module’s date and time in OSDs alos?

void rts_osd_isp_refresh_datetime(void);

enum rts_osd_err_code rts_osd2_set_time(int hour, int minute, int seconds);

enum rts_osd_err_code rts_osd2_set_date(int year, int month, int da

Hi @yugandhar

Sorry for the late reply.

The OSD synchronizes its time with SNTP by default.

You can use rts_osd_sync_from_sntp(0); to disable this behavior. Once SNTP sync is disabled, the OSD will no longer overwrite your date/time with epoch values.

Then you can manually apply your NVR/RTC time using:
enum rts_osd_err_code rts_osd2_set_time(int hour, int minute, int seconds);
enum rts_osd_err_code rts_osd2_set_date(int year, int month, int day);

For testing, I hardcoded the date and time. Below is the result.
For your reference, in example_isp_osd function, added:

rts_osd_sync_from_sntp(0);
rts_osd2_set_date(2025, 1, 15);   // YYYY, MM, DD
rts_osd2_set_time(14, 30, 45);    // HH, MM, SS

using void rts_osd_isp_refresh_datetime(void); will reset it back to 1970-01-01

Hi @pammyleong ,

Thanks for the solution, It is working now.