linuxdvb: rotor - try to fix the grace calculation routine for USALS and negative longtitudes

This commit is contained in:
Jaroslav Kysela 2014-09-18 10:35:42 +02:00
parent 34cb8509d1
commit 03af723216
2 changed files with 17 additions and 4 deletions

View file

@ -134,16 +134,28 @@ linuxdvb_rotor_grace
( linuxdvb_diseqc_t *ld, dvb_mux_t *lm )
{
linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld;
linuxdvb_satconf_t *ls = ld->ld_satconf->lse_parent;
int newpos, curpos, delta;
if (!ld->ld_satconf->lse_parent->ls_orbital_dir || lr->lr_rate == 0)
if (!ls->ls_orbital_dir || lr->lr_rate == 0)
return 120;
int curpos = ld->ld_satconf->lse_parent->ls_orbital_pos;
if (idnode_is_instance(&lr->ld_id, &linuxdvb_rotor_gotox_class))
newpos = lr->lr_position; /* GotoX */
else
newpos = (lr->lr_sat_lon + 0.005) * 100; /* USALS */
if (ld->ld_satconf->lse_parent->ls_orbital_dir == 'W')
curpos = ls->ls_orbital_pos;
if (ls->ls_orbital_dir == 'W')
curpos = -(curpos);
delta = abs(deltaI32(curpos, newpos));
return (lr->lr_rate*(deltaU32(curpos, lr->lr_position))+999)/1000;
/* ignore very small movements like 0.8W and 1W */
if (delta <= 2)
return 0;
/* add one extra second, because of the rounding issue */
return ((lr->lr_rate*delta+999)/1000) + 1;
}
static int

View file

@ -708,6 +708,7 @@ int rmtree ( const char *path );
char *regexp_escape ( const char *str );
static inline int32_t deltaI32(int32_t a, int32_t b) { return (a > b) ? (a - b) : (b - a); }
static inline uint32_t deltaU32(uint32_t a, uint32_t b) { return (a > b) ? (a - b) : (b - a); }
#define SKEL_DECLARE(name, type) type *name;