mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 16:25:16 +03:00
Merge pull request #1544 from opentx/projectkk2glider/tx_time_optimization
RTC time related optimizations
This commit is contained in:
commit
77fae410ad
7 changed files with 21 additions and 23 deletions
|
@ -347,9 +347,7 @@ void displayTopBar()
|
|||
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER3);
|
||||
|
||||
/* RTC time */
|
||||
struct gtm t;
|
||||
gettime(&t);
|
||||
putsTime(BAR_TIME_X, BAR_Y+1, t, LEFT|TIMEBLINK);
|
||||
putsRtcTime(BAR_TIME_X, BAR_Y+1, LEFT|TIMEBLINK);
|
||||
|
||||
/* The background */
|
||||
lcd_filled_rect(BAR_X, BAR_Y, BAR_W, BAR_H, SOLID, FILL_WHITE|GREY(12)|ROUND);
|
||||
|
|
|
@ -215,7 +215,7 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
|
|||
#define putstime_t int16_t
|
||||
#endif
|
||||
|
||||
void putsTime(xcoord_t x, uint8_t y, struct gtm t, LcdFlags att);
|
||||
void putsRtcTime(xcoord_t x, uint8_t y, LcdFlags att);
|
||||
void putsTimer(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2);
|
||||
|
||||
#define SOLID 0xff
|
||||
|
|
|
@ -602,9 +602,9 @@ void lcdDrawTelemetryTopBar()
|
|||
#endif
|
||||
|
||||
#if defined(CPUARM) && defined(RTCLOCK)
|
||||
void putsTime(xcoord_t x, uint8_t y, struct gtm t, LcdFlags att)
|
||||
void putsRtcTime(xcoord_t x, uint8_t y, LcdFlags att)
|
||||
{
|
||||
putsTimer(x, y, t.tm_hour*60+t.tm_min, att, att);
|
||||
putsTimer(x, y, getValue(MIXSRC_FIRST_TELEM-1+TELEM_TX_TIME), att, att);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -928,10 +928,7 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
|
|||
#if defined(CPUARM) && defined(RTCLOCK)
|
||||
case TELEM_TX_TIME-1:
|
||||
{
|
||||
gtm t;
|
||||
t.tm_hour = val / 60;
|
||||
t.tm_min = val % 60;
|
||||
putsTime(x, y, t, att);
|
||||
putsRtcTime(x, y, att);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -190,12 +190,19 @@ void writeLogs()
|
|||
}
|
||||
|
||||
#if defined(RTCLOCK)
|
||||
struct gtm utm;
|
||||
{
|
||||
static struct gtm utm;
|
||||
static gtime_t lastRtcTime = 0;
|
||||
if ( g_rtcTime != lastRtcTime )
|
||||
{
|
||||
lastRtcTime = g_rtcTime;
|
||||
gettime(&utm);
|
||||
}
|
||||
f_printf(&g_oLogFile, "%4d-%02d-%02d,%02d:%02d:%02d.%02d0,", utm.tm_year+1900, utm.tm_mon+1, utm.tm_mday, utm.tm_hour, utm.tm_min, utm.tm_sec, g_ms100);
|
||||
#else
|
||||
}
|
||||
#else // #if defined(RTCLOCK)
|
||||
f_printf(&g_oLogFile, "%d,", tmr10ms);
|
||||
#endif
|
||||
#endif // #if defined(RTCLOCK)
|
||||
|
||||
#if defined(FRSKY)
|
||||
#if defined(CPUARM)
|
||||
|
|
|
@ -326,11 +326,7 @@ getvalue_t getValue(uint8_t i)
|
|||
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_TX_VOLTAGE) return g_vbat100mV;
|
||||
#if defined(CPUARM) && defined(RTCLOCK)
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_TX_TIME) {
|
||||
struct gtm t;
|
||||
gettime(&t);
|
||||
return t.tm_hour*60 + t.tm_min;
|
||||
}
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_TX_TIME) return (g_rtcTime % SECS_PER_DAY) / 60; // number of minutes from midnight
|
||||
#endif
|
||||
else if (i<=MIXSRC_FIRST_TELEM-1+TELEM_TIMER2) return timersStates[i-MIXSRC_FIRST_TELEM+1-TELEM_TIMER1].val;
|
||||
#if defined(FRSKY)
|
||||
|
|
|
@ -107,9 +107,6 @@ verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int));
|
|||
#define TM_YEAR_BASE 1900
|
||||
verify (base_year_is_a_multiple_of_100, TM_YEAR_BASE % 100 == 0);
|
||||
|
||||
#define SECS_PER_HOUR 3600ul
|
||||
#define SECS_PER_DAY 86400ul
|
||||
|
||||
/* Return 1 if YEAR + TM_YEAR_BASE is a leap year. */
|
||||
static inline int
|
||||
leapyear (long int year)
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
|
||||
#include <inttypes.h>
|
||||
|
||||
#define SECS_PER_HOUR 3600ul
|
||||
#define SECS_PER_DAY 86400ul
|
||||
|
||||
typedef long int gtime_t;
|
||||
|
||||
struct gtm
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue