1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-21 07:15:12 +03:00

Optimization: removed usage of gettime() where possible

This commit is contained in:
Damjan Adamic 2014-07-21 14:45:14 +02:00
parent 3ada9f7cf5
commit 43598fb6df
6 changed files with 9 additions and 18 deletions

View file

@ -316,9 +316,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

@ -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