mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-03-23 07:36:54 +01:00
add day/year/month access for scripts so we can script a date display
This commit is contained in:
@@ -252,6 +252,15 @@ float getHour(const char *s) {
|
||||
float getSecond(const char *s) {
|
||||
return NTP_GetSecond();
|
||||
}
|
||||
float getYear(const char *s) {
|
||||
return NTP_GetYear();
|
||||
}
|
||||
float getMonth(const char *s) {
|
||||
return NTP_GetMonth();
|
||||
}
|
||||
float getMDay(const char *s) {
|
||||
return NTP_GetMDay();
|
||||
}
|
||||
|
||||
const constant_t g_constants[] = {
|
||||
//cnstdetail:{"name":"MQTTOn",
|
||||
@@ -375,11 +384,21 @@ const constant_t g_constants[] = {
|
||||
//cnstdetail:"descr":"Current second from NTP",
|
||||
//cnstdetail:"requires":""}
|
||||
{ "$second", &getSecond },
|
||||
////cnstdetail:{"name":"$mday",
|
||||
////cnstdetail:"title":"$mday",
|
||||
////cnstdetail:"descr":"Current mday from NTP",
|
||||
////cnstdetail:"requires":""}
|
||||
{ "$mday", &getMDay },
|
||||
////cnstdetail:{"name":"$month",
|
||||
////cnstdetail:"title":"$month",
|
||||
////cnstdetail:"descr":"Current month from NTP",
|
||||
////cnstdetail:"requires":""}
|
||||
//{ "$month", &getMonth },
|
||||
{ "$month", &getMonth },
|
||||
////cnstdetail:{"name":"$year",
|
||||
////cnstdetail:"title":"$year",
|
||||
////cnstdetail:"descr":"Current Year from NTP",
|
||||
////cnstdetail:"requires":""}
|
||||
{ "$year", &getYear },
|
||||
//cnstdetail:{"name":"$NTPOn",
|
||||
//cnstdetail:"title":"$NTPOn",
|
||||
//cnstdetail:"descr":"Returns 1 if NTP is on and already synced (so device has correct time), otherwise 0.",
|
||||
|
||||
@@ -165,6 +165,42 @@ int NTP_GetSecond() {
|
||||
|
||||
return ltm->tm_sec;
|
||||
}
|
||||
int NTP_GetMDay() {
|
||||
struct tm *ltm;
|
||||
|
||||
// NOTE: on windows, you need _USE_32BIT_TIME_T
|
||||
ltm = localtime((time_t*)&g_ntpTime);
|
||||
|
||||
if (ltm == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ltm->tm_mday;
|
||||
}
|
||||
int NTP_GetMonth() {
|
||||
struct tm *ltm;
|
||||
|
||||
// NOTE: on windows, you need _USE_32BIT_TIME_T
|
||||
ltm = localtime((time_t*)&g_ntpTime);
|
||||
|
||||
if (ltm == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ltm->tm_mon+1;
|
||||
}
|
||||
int NTP_GetYear() {
|
||||
struct tm *ltm;
|
||||
|
||||
// NOTE: on windows, you need _USE_32BIT_TIME_T
|
||||
ltm = localtime((time_t*)&g_ntpTime);
|
||||
|
||||
if (ltm == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ltm->tm_year+1900;
|
||||
}
|
||||
#if WINDOWS
|
||||
bool b_ntp_simulatedTime = false;
|
||||
void NTP_SetSimulatedTime(unsigned int timeNow) {
|
||||
|
||||
@@ -15,6 +15,9 @@ int NTP_GetWeekDay();
|
||||
int NTP_GetHour();
|
||||
int NTP_GetMinute();
|
||||
int NTP_GetSecond();
|
||||
int NTP_GetMDay();
|
||||
int NTP_GetMonth();
|
||||
int NTP_GetYear();
|
||||
// for Simulator only, on Windows, for unit testing
|
||||
void NTP_SetSimulatedTime(unsigned int timeNow);
|
||||
// drv_ntp_events.c
|
||||
|
||||
Reference in New Issue
Block a user