summaryrefslogtreecommitdiffstats
path: root/app/meteotime.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/meteotime.c')
-rw-r--r--app/meteotime.c67
1 files changed, 34 insertions, 33 deletions
diff --git a/app/meteotime.c b/app/meteotime.c
index 5734a0b..e18220f 100644
--- a/app/meteotime.c
+++ b/app/meteotime.c
@@ -8,7 +8,7 @@
#define BITS_PER_WORD 32
-#define N_WORDS (((N_BITS)+(BITS_PER_WORD-1))/(BITS_PER_WORD))
+#define N_WORDS (((N_BITS)+(BITS_PER_WORD-1))/(BITS_PER_WORD))
#define M1 (~0UL)
@@ -16,50 +16,51 @@
uint32_t meteotime_data[N_WORDS];
-void meteotime_save(UTC *u, uint8_t *bits)
+void meteotime_save (UTC *u, uint8_t *bits)
{
-uint32_t c;
-uint32_t d1;
-uint32_t d2;
+ uint32_t c;
+ uint32_t d1;
+ uint32_t d2;
-unsigned i;
-unsigned word;
-unsigned bit;
-unsigned ibit;
+ unsigned i;
+ unsigned word;
+ unsigned bit;
+ unsigned ibit;
-//0-13
-for (d1=0,c=1,i=1;i<15;++i,c<<=1)
- if (bits[i]) d1|=c;
+ //0-13
+ for (d1 = 0, c = 1, i = 1; i < 15; ++i, c <<= 1)
+ if (bits[i]) d1 |= c;
-//14
-if (bits[17]) d1|=c;
-c<<=1;
+ //14
+ if (bits[17]) d1 |= c;
-//15-31
-for (i=36;i<53;++i,c<<=1)
- if (bits[i]) d1|=c;
+ c <<= 1;
-//0-4
-for (d2=0,c=1,i=53;i<58;++i,c<<=1)
- if (bits[i]) d2|=c;
+ //15-31
+ for (i = 36; i < 53; ++i, c <<= 1)
+ if (bits[i]) d1 |= c;
-bit=u->hour;
-bit*=60;
-bit+=u->minute;
-bit*=BITS_PER_MIN;
+ //0-4
+ for (d2 = 0, c = 1, i = 53; i < 58; ++i, c <<= 1)
+ if (bits[i]) d2 |= c;
-word=bit/BITS_PER_WORD;
-bit=bit & (BITS_PER_WORD -1);
-ibit=BITS_PER_WORD-bit;
+ bit = u->hour;
+ bit *= 60;
+ bit += u->minute;
+ bit *= BITS_PER_MIN;
+ word = bit / BITS_PER_WORD;
+ bit = bit & (BITS_PER_WORD - 1);
+ ibit = BITS_PER_WORD - bit;
-meteotime_data[word] &=~(M1 << bit);
-meteotime_data[word] |=(d1 << bit);
-word++;
+ meteotime_data[word] &= ~ (M1 << bit);
+ meteotime_data[word] |= (d1 << bit);
-meteotime_data[word] &=~((M1 >> ibit) |(M2 <<bit));
-meteotime_data[word] |=(d1 >> ibit) | (d2 <<bit);
+ word++;
+
+ meteotime_data[word] &= ~ ((M1 >> ibit) | (M2 << bit));
+ meteotime_data[word] |= (d1 >> ibit) | (d2 << bit);
}