1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 00:35:18 +03:00

Merge pull request #1544 from opentx/projectkk2glider/tx_time_optimization

RTC time related optimizations
This commit is contained in:
Bertrand Songis 2014-08-14 21:39:35 +02:00
commit 77fae410ad
7 changed files with 21 additions and 23 deletions

View file

@ -347,9 +347,7 @@ void displayTopBar()
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER3); LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER3);
/* RTC time */ /* RTC time */
struct gtm t; putsRtcTime(BAR_TIME_X, BAR_Y+1, LEFT|TIMEBLINK);
gettime(&t);
putsTime(BAR_TIME_X, BAR_Y+1, t, LEFT|TIMEBLINK);
/* The background */ /* The background */
lcd_filled_rect(BAR_X, BAR_Y, BAR_W, BAR_H, SOLID, FILL_WHITE|GREY(12)|ROUND); lcd_filled_rect(BAR_X, BAR_Y, BAR_W, BAR_H, SOLID, FILL_WHITE|GREY(12)|ROUND);

View file

@ -215,7 +215,7 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
#define putstime_t int16_t #define putstime_t int16_t
#endif #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); void putsTimer(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2);
#define SOLID 0xff #define SOLID 0xff

View file

@ -602,9 +602,9 @@ void lcdDrawTelemetryTopBar()
#endif #endif
#if defined(CPUARM) && defined(RTCLOCK) #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 #endif
@ -928,10 +928,7 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
#if defined(CPUARM) && defined(RTCLOCK) #if defined(CPUARM) && defined(RTCLOCK)
case TELEM_TX_TIME-1: case TELEM_TX_TIME-1:
{ {
gtm t; putsRtcTime(x, y, att);
t.tm_hour = val / 60;
t.tm_min = val % 60;
putsTime(x, y, t, att);
break; break;
} }
#endif #endif

View file

@ -190,12 +190,19 @@ void writeLogs()
} }
#if defined(RTCLOCK) #if defined(RTCLOCK)
struct gtm utm; {
static struct gtm utm;
static gtime_t lastRtcTime = 0;
if ( g_rtcTime != lastRtcTime )
{
lastRtcTime = g_rtcTime;
gettime(&utm); 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); 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); f_printf(&g_oLogFile, "%d,", tmr10ms);
#endif #endif // #if defined(RTCLOCK)
#if defined(FRSKY) #if defined(FRSKY)
#if defined(CPUARM) #if defined(CPUARM)

View file

@ -326,11 +326,7 @@ getvalue_t getValue(uint8_t i)
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_TX_VOLTAGE) return g_vbat100mV; else if (i==MIXSRC_FIRST_TELEM-1+TELEM_TX_VOLTAGE) return g_vbat100mV;
#if defined(CPUARM) && defined(RTCLOCK) #if defined(CPUARM) && defined(RTCLOCK)
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_TX_TIME) { else if (i==MIXSRC_FIRST_TELEM-1+TELEM_TX_TIME) return (g_rtcTime % SECS_PER_DAY) / 60; // number of minutes from midnight
struct gtm t;
gettime(&t);
return t.tm_hour*60 + t.tm_min;
}
#endif #endif
else if (i<=MIXSRC_FIRST_TELEM-1+TELEM_TIMER2) return timersStates[i-MIXSRC_FIRST_TELEM+1-TELEM_TIMER1].val; else if (i<=MIXSRC_FIRST_TELEM-1+TELEM_TIMER2) return timersStates[i-MIXSRC_FIRST_TELEM+1-TELEM_TIMER1].val;
#if defined(FRSKY) #if defined(FRSKY)

View file

@ -107,9 +107,6 @@ verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int));
#define TM_YEAR_BASE 1900 #define TM_YEAR_BASE 1900
verify (base_year_is_a_multiple_of_100, TM_YEAR_BASE % 100 == 0); 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. */ /* Return 1 if YEAR + TM_YEAR_BASE is a leap year. */
static inline int static inline int
leapyear (long int year) leapyear (long int year)

View file

@ -39,6 +39,9 @@
#include <inttypes.h> #include <inttypes.h>
#define SECS_PER_HOUR 3600ul
#define SECS_PER_DAY 86400ul
typedef long int gtime_t; typedef long int gtime_t;
struct gtm struct gtm