From 4c1d83d373b4a0737da668945d1ddb3278b6c3b7 Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Fri, 20 May 2005 19:41:31 +0000 Subject: [PATCH] work on rotor support, add usals stuff (rotor stuff not completed yet), only send diseqc when needed --- acinclude.m4 | 180 +++++++++++++++++++--------------- config.h.in | 18 +++- configure.ac | 2 +- lib/dvb/Makefile.am | 4 +- lib/dvb/frontend.cpp | 4 +- lib/dvb/frontend.h | 5 +- lib/dvb/rotor_calc.cpp | 257 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/dvb/rotor_calc.h | 4 + lib/dvb/sec.cpp | 112 ++++++++++++++++++++- lib/dvb/sec.h | 7 +- lib/gdi/Makefile.am | 2 +- lib/gdi/gfbdc.cpp | 4 +- lib/gdi/sdl.cpp | 2 + main/Makefile.am | 5 +- main/enigma-gdi.cpp | 2 +- main/enigma-gui.cpp | 2 +- main/enigma.cpp | 5 +- 17 files changed, 515 insertions(+), 100 deletions(-) create mode 100644 lib/dvb/rotor_calc.cpp create mode 100644 lib/dvb/rotor_calc.h diff --git a/acinclude.m4 b/acinclude.m4 index 074e1a0..b92d02f 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -2,6 +2,8 @@ AC_DEFUN(TUXBOX_APPS,[ AM_CONFIG_HEADER(config.h) AM_MAINTAINER_MODE +INSTALL="$INSTALL -p" + AC_GNU_SOURCE AC_SYS_LARGEFILE @@ -10,7 +12,7 @@ AC_ARG_WITH(target, [TARGET="$withval"],[TARGET="native"]) AC_ARG_WITH(targetprefix, - [ --with-targetprefix=PATH prefix relative to target root [[PREFIX[for native], /[for cdk]]]], + [ --with-targetprefix=PATH prefix relative to target root (only applicable in cdk mode)], [targetprefix="$withval"],[targetprefix="NONE"]) AC_ARG_WITH(debug, @@ -22,7 +24,11 @@ if test "$DEBUG" = "yes"; then AC_DEFINE(DEBUG,1,[Enable debug messages]) fi +AC_MSG_CHECKING(target) + if test "$TARGET" = "native"; then + AC_MSG_RESULT(native) + if test "$CFLAGS" = "" -a "$CXXFLAGS" = ""; then CFLAGS="-Wall -O2 -pipe $DEBUG_CFLAGS" CXXFLAGS="-Wall -O2 -pipe $DEBUG_CFLAGS" @@ -30,13 +36,10 @@ if test "$TARGET" = "native"; then if test "$prefix" = "NONE"; then prefix=/usr/local fi - if test "$targetprefix" = "NONE"; then - targetprefix="\${prefix}" - _targetprefix="${prefix}" - else - _targetprefix="$targetprefix" - fi + targetprefix=$prefix elif test "$TARGET" = "cdk"; then + AC_MSG_RESULT(cdk) + if test "$CC" = "" -a "$CXX" = ""; then CC=powerpc-tuxbox-linux-gnu-gcc CXX=powerpc-tuxbox-linux-gnu-g++ fi @@ -45,99 +48,127 @@ elif test "$TARGET" = "cdk"; then CXXFLAGS="-Wall -Os -mcpu=823 -pipe $DEBUG_CFLAGS" fi if test "$prefix" = "NONE"; then - prefix=/dbox2/cdkroot + AC_MSG_ERROR(invalid prefix, you need to specify one in cdk mode) fi if test "$targetprefix" = "NONE"; then targetprefix="" - _targetprefix="" - else - _targetprefix="$targetprefix" fi if test "$host_alias" = ""; then cross_compiling=yes host_alias=powerpc-tuxbox-linux-gnu fi else + AC_MSG_RESULT(none) AC_MSG_ERROR([invalid target $TARGET, choose on from native,cdk]); fi AC_CANONICAL_BUILD AC_CANONICAL_HOST -targetdatadir="\${targetprefix}/share" -_targetdatadir="${_targetprefix}/share" -targetsysconfdir="\${targetprefix}/etc" -_targetsysconfdir="${_targetprefix}/etc" -targetlocalstatedir="\${targetprefix}/var" -_targetlocalstatedir="${_targetprefix}/var" -targetlibdir="\${targetprefix}/lib" -_targetlibdir="${_targetprefix}/lib" -AC_SUBST(targetprefix) -AC_SUBST(targetdatadir) -AC_SUBST(targetsysconfdir) -AC_SUBST(targetlocalstatedir) - check_path () { return $(perl -e "if(\"$1\"=~m#^/usr/(local/)?bin#){print \"0\"}else{print \"1\";}") } ]) +AC_DEFUN(TUXBOX_APPS_DIRECTORY_ONE,[ +AC_ARG_WITH($1,[ $6$7 [[PREFIX$4$5]]],[ + _$2=$withval + if test "$TARGET" = "cdk"; then + $2=`eval echo "${targetprefix}$withval"` + else + $2=$withval + fi +],[ + $2="\${$3}$5" + if test "$TARGET" = "cdk"; then + _$2=`eval echo "${target$3}$5"` + else + _$2=`eval echo "${$3}$5"` + fi +]) + +dnl automake <= 1.6 don't support this +dnl AC_SUBST($2) +AC_DEFINE_UNQUOTED($2,"$_$2",$7) +]) + AC_DEFUN(TUXBOX_APPS_DIRECTORY,[ AC_REQUIRE([TUXBOX_APPS]) -CONFIGDIR="\${localstatedir}/tuxbox/config" -_CONFIGDIR="${_targetlocalstatedir}/tuxbox/config" -AC_SUBST(CONFIGDIR) -AC_DEFINE_UNQUOTED(CONFIGDIR,"$_CONFIGDIR",[where to find the config files]) +if test "$TARGET" = "cdk"; then + datadir="\${prefix}/share" + tuxboxdatadir="\${prefix}/share/tuxbox" + zoneinfodir="\${datadir}/zoneinfo" + sysconfdir="\${prefix}/etc" + localstatedir="\${prefix}/var" + localedir="\${prefix}/var" + libdir="\${prefix}/lib" + targetdatadir="\${targetprefix}/share" + targetsysconfdir="\${targetprefix}/etc" + targetlocalstatedir="\${targetprefix}/var" + targetlibdir="\${targetprefix}/lib" +fi -DATADIR="\${datadir}/tuxbox" -_DATADIR="${_targetdatadir}/tuxbox" -AC_SUBST(DATADIR) -AC_DEFINE_UNQUOTED(DATADIR,"$_DATADIR",[where to find data like icons]) +TUXBOX_APPS_DIRECTORY_ONE(configdir,CONFIGDIR,sysconfdir,/etc,, + [--with-configdir=PATH ],[where to find the config files]) -FONTDIR="\${datadir}/fonts" -_FONTDIR="${_targetdatadir}/fonts" -AC_SUBST(FONTDIR) -AC_DEFINE_UNQUOTED(FONTDIR,"$_FONTDIR",[where to find the fonts]) +TUXBOX_APPS_DIRECTORY_ONE(datadir,DATADIR,datadir,/share,, + [--with-datadir=PATH ],[where to find data]) -GAMESDIR="\${localstatedir}/tuxbox/games" -_GAMESDIR="${_targetlocalstatedir}/tuxbox/games" -AC_SUBST(GAMESDIR) -AC_DEFINE_UNQUOTED(GAMESDIR,"$_GAMESDIR",[where games data is stored]) +TUXBOX_APPS_DIRECTORY_ONE(localedir,LOCALEDIR,datadir,/share,/locale, + [--with-localedir=PATH ],[where to find locales]) -LIBDIR="\${libdir}/tuxbox" -_LIBDIR="${_targetlibdir}/tuxbox" -AC_SUBST(LIBDIR) -AC_SUBST(_LIBDIR) -AC_DEFINE_UNQUOTED(LIBDIR,"$_LIBDIR",[where to find the internal libs]) +TUXBOX_APPS_DIRECTORY_ONE(fontdir,FONTDIR,datadir,/share,/fonts, + [--with-fontdir=PATH ],[where to find the fonts]) -PLUGINDIR="\${libdir}/tuxbox/plugins" -_PLUGINDIR="${_targetlibdir}/tuxbox/plugins" -AC_SUBST(PLUGINDIR) -AC_DEFINE_UNQUOTED(PLUGINDIR,"$_PLUGINDIR",[where to find the plugins]) +TUXBOX_APPS_DIRECTORY_ONE(gamesdir,GAMESDIR,localstatedir,/var,/tuxbox/games, + [--with-gamesdir=PATH ],[where games data is stored]) + +TUXBOX_APPS_DIRECTORY_ONE(libdir,LIBDIR,libdir,/lib,/tuxbox, + [--with-libdir=PATH ],[where to find the internal libs]) -UCODEDIR="\${localstatedir}/tuxbox/ucodes" -_UCODEDIR="${_targetlocalstatedir}/tuxbox/ucodes" -AC_SUBST(UCODEDIR) -AC_DEFINE_UNQUOTED(UCODEDIR,"$_UCODEDIR",[where to find the ucodes (firmware)]) +TUXBOX_APPS_DIRECTORY_ONE(plugindir,PLUGINDIR,libdir,/lib,/tuxbox/plugins, + [--with-plugindir=PATH ],[where to find the plugins]) + +TUXBOX_APPS_DIRECTORY_ONE(tuxboxdatadir,TUXBOXDATADIR,datadir,/share,/tuxbox, + [--with-tuxboxdatadir=PATH],[where to find tuxbox data]) + +TUXBOX_APPS_DIRECTORY_ONE(zoneinfodir,ZONEINFODIR,datadir,/share,/zoneinfo, + [--with-zoneinfodir=PATH ],[where to find zoneinfo db]) ]) +dnl automake <= 1.6 needs this specifications +AC_SUBST(CONFIGDIR) +AC_SUBST(DATADIR) +AC_SUBST(ZONEINFODIR) +AC_SUBST(FONTDIR) +AC_SUBST(GAMESDIR) +AC_SUBST(LIBDIR) +AC_SUBST(LOCALEDIR) +AC_SUBST(PLUGINDIR) +AC_SUBST(TUXBOXDATADIR) +dnl end workaround + AC_DEFUN(TUXBOX_APPS_ENDIAN,[ AC_CHECK_HEADERS(endian.h) AC_C_BIGENDIAN ]) AC_DEFUN(TUXBOX_APPS_DRIVER,[ -AC_ARG_WITH(driver, - [ --with-driver=PATH path for driver sources[[NONE]]], - [DRIVER="$withval"],[DRIVER=""]) - -if test -z "$DRIVER"; then - AC_MSG_ERROR([can't find driver sources]) -fi -CPPFLAGS="$CPPFLAGS -I$DRIVER/include" -AC_SUBST(DRIVER) +#AC_ARG_WITH(driver, +# [ --with-driver=PATH path for driver sources [[NONE]]], +# [DRIVER="$withval"],[DRIVER=""]) +# +#if test -d "$DRIVER/include"; then +# AC_DEFINE(HAVE_DBOX2_DRIVER,1,[Define to 1 if you have the dbox2 driver sources]) +#else +# AC_MSG_ERROR([can't find driver sources]) +#fi + +#AC_SUBST(DRIVER) + +#CPPFLAGS="$CPPFLAGS -I$DRIVER/include" ]) AC_DEFUN([TUXBOX_APPS_DVB],[ @@ -177,7 +208,6 @@ else fi ]) - AC_DEFUN(_TUXBOX_APPS_LIB_CONFIG,[ AC_PATH_PROG($1_CONFIG,$2,no) if test "$$1_CONFIG" != "no"; then @@ -212,16 +242,7 @@ fi ]) AC_DEFUN(_TUXBOX_APPS_LIB_PKGCONFIG,[ -AC_REQUIRE([TUXBOX_APPS_PKGCONFIG]) -AC_MSG_CHECKING(for package $2) -if PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" $PKG_CONFIG --exists "$2" ; then - AC_MSG_RESULT(yes) - $1_CFLAGS=$(PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" $PKG_CONFIG --cflags "$2") - $1_LIBS=$(PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" $PKG_CONFIG --libs "$2") -else - AC_MSG_RESULT(no) -fi - +PKG_CHECK_MODULES($1,$2) AC_SUBST($1_CFLAGS) AC_SUBST($1_LIBS) ]) @@ -348,8 +369,7 @@ AC_SUBST(DUMMYPOFILES) AC_SUBST(CATALOGS) ]) - - +dnl backward compatiblity AC_DEFUN([AC_GNU_SOURCE], [AH_VERBATIM([_GNU_SOURCE], [/* Enable GNU extensions on systems that have them. */ @@ -361,3 +381,13 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl AC_DEFINE([_GNU_SOURCE]) ]) +AC_DEFUN([AC_PROG_EGREP], +[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep], + [if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi]) + EGREP=$ac_cv_prog_egrep + AC_SUBST([EGREP]) +]) + diff --git a/config.h.in b/config.h.in index 3224a09..ceee826 100644 --- a/config.h.in +++ b/config.h.in @@ -3,7 +3,7 @@ /* where to find the config files */ #undef CONFIGDIR -/* where to find data like icons */ +/* where to find data */ #undef DATADIR /* Enable debug messages */ @@ -19,6 +19,12 @@ /* where games data is stored */ #undef GAMESDIR +/* Define to 1 if you have the dvb includes */ +#undef HAVE_DVB + +/* Define to the version of the dvb api */ +#undef HAVE_DVB_API_VERSION + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H @@ -55,6 +61,9 @@ /* where to find the internal libs */ #undef LIBDIR +/* where to find locales */ +#undef LOCALEDIR + /* Name of package */ #undef PACKAGE @@ -79,12 +88,15 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS -/* where to find the ucodes (firmware) */ -#undef UCODEDIR +/* where to find tuxbox data */ +#undef TUXBOXDATADIR /* Version number of package */ #undef VERSION +/* where to find zoneinfo db */ +#undef ZONEINFODIR + /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS diff --git a/configure.ac b/configure.ac index 3372c80..8afbada 100644 --- a/configure.ac +++ b/configure.ac @@ -19,7 +19,7 @@ TUXBOX_APPS_LIB_PKGCONFIG(MAD,mad) TUXBOX_APPS_LIB_PKGCONFIG(PNG,libpng) TUXBOX_APPS_LIB_PKGCONFIG(SIGC,sigc++-1.2) #TUXBOX_APPS_LIB_PKGCONFIG(XMLTREE,tuxbox-xmltree) -TUXBOX_APPS_LIB_CONFIG(SDL,sdl-config) +#TUXBOX_APPS_LIB_CONFIG(SDL,sdl-config) # fixme: decent python stuff CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS $FRIBIDI_CFLAGS $ID3TAG_CFLAGS $MAD_CFLAGS $PLUGINS_CFLAGS $PNG_CFLAGS $SIGC_CFLAGS $XMLTREE_CFLAGS $SDL_CFLAGS -I/usr/include/python2.3 -DHAVE_CPP_FILT -DMEMLEAK_CHECK" diff --git a/lib/dvb/Makefile.am b/lib/dvb/Makefile.am index 41ce174..2a1402b 100644 --- a/lib/dvb/Makefile.am +++ b/lib/dvb/Makefile.am @@ -4,5 +4,5 @@ INCLUDES = \ noinst_LIBRARIES = libenigma_dvb.a libenigma_dvb_a_SOURCES = dvb.cpp demux.cpp frontend.cpp esection.cpp db.cpp \ - sec.cpp scan.cpp crc32.cpp pmt.cpp decoder.cpp eit.cpp - \ No newline at end of file + sec.cpp scan.cpp crc32.cpp pmt.cpp decoder.cpp eit.cpp rotor_calc.cpp + diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp index a273096..1136d9d 100644 --- a/lib/dvb/frontend.cpp +++ b/lib/dvb/frontend.cpp @@ -710,7 +710,7 @@ RESULT eDVBFrontend::setSecSequence(const eSecCommandList &list) RESULT eDVBFrontend::getData(int num, int &data) { - if ( num < 4 ) + if ( num < 5 ) { data = m_data[num]; return 0; @@ -720,7 +720,7 @@ RESULT eDVBFrontend::getData(int num, int &data) RESULT eDVBFrontend::setData(int num, int val) { - if ( num < 4 ) + if ( num < 5 ) { m_data[num] = val; return 0; diff --git a/lib/dvb/frontend.h b/lib/dvb/frontend.h index fce94e5..e6beb68 100644 --- a/lib/dvb/frontend.h +++ b/lib/dvb/frontend.h @@ -53,11 +53,12 @@ class eDVBFrontend: public iDVBFrontend, public Object eSecCommandList m_sec_sequence; - int m_data[4]; /* when satellite frontend then + int m_data[5]; /* when satellite frontend then data[0] = lastcsw -> state of the committed switch data[1] = lastucsw -> state of the uncommitted switch data[2] = lastToneburst -> current state of toneburst switch - data[3] = prevRotorPos -> current Rotor Position */ + data[3] = lastRotorCmd -> last sent rotor cmd + data[4] = curRotorPos -> current Rotor Position */ void feEvent(int); void timeout(); diff --git a/lib/dvb/rotor_calc.cpp b/lib/dvb/rotor_calc.cpp new file mode 100644 index 0000000..4132236 --- /dev/null +++ b/lib/dvb/rotor_calc.cpp @@ -0,0 +1,257 @@ +#include + +/*----------------------------------------------------------------------------*/ +double factorial_div( double value, int x) +{ + if(!x) + return 1; + else + { + while( x > 1) + { + value = value / x--; + } + } + return value; +} + +/*----------------------------------------------------------------------------*/ +double powerd( double x, int y) +{ + int i=0; + double ans=1.0; + + if(!y) + return 1.000; + else + { + while( i < y) + { + i++; + ans = ans * x; + } + } + return ans; +} + +/*----------------------------------------------------------------------------*/ +double SIN( double x) +{ + int i=0; + int j=1; + int sign=1; + double y1 = 0.0; + double diff = 1000.0; + + if (x < 0.0) + { + x = -1 * x; + sign = -1; + } + + while ( x > 360.0*M_PI/180) + { + x = x - 360*M_PI/180; + } + + if( x > (270.0 * M_PI / 180) ) + { + sign = sign * -1; + x = 360.0*M_PI/180 - x; + } + else if ( x > (180.0 * M_PI / 180) ) + { + sign = sign * -1; + x = x - 180.0 *M_PI / 180; + } + else if ( x > (90.0 * M_PI / 180) ) + { + x = 180.0 *M_PI / 180 - x; + } + + while( powerd( diff, 2) > 1.0E-16 ) + { + i++; + diff = j * factorial_div( powerd( x, (2*i -1)) ,(2*i -1)); + y1 = y1 + diff; + j = -1 * j; + } + return ( sign * y1 ); +} + +/*----------------------------------------------------------------------------*/ +double COS(double x) +{ + return SIN(90 * M_PI / 180 - x); +} + +/*----------------------------------------------------------------------------*/ +double ATAN( double x) +{ + int i=0; /* counter for terms in binomial series */ + int j=1; /* sign of nth term in series */ + int k=0; + int sign = 1; /* sign of the input x */ + double y = 0.0; /* the output */ + double deltay = 1.0; /* the value of the next term in the series */ + double addangle = 0.0; /* used if arctan > 22.5 degrees */ + + if (x < 0.0) + { + x = -1 * x; + sign = -1; + } + + while( x > 0.3249196962 ) + { + k++; + x = (x - 0.3249196962) / (1 + x * 0.3249196962); + } + + addangle = k * 18.0 *M_PI/180; + + while( powerd( deltay, 2) > 1.0E-16 ) + { + i++; + deltay = j * powerd( x, (2*i -1)) / (2*i -1); + y = y + deltay; + j = -1 * j; + } + return (sign * (y + addangle) ); +} + +double ASIN(double x) +{ + return 2 * ATAN( x / (1 + std::sqrt(1.0 - x*x))); +} + +double Radians( double number ) +{ + return number*M_PI/180; +} + +double Deg( double number ) +{ + return number*180/M_PI; +} + +double Rev( double number ) +{ + return number - std::floor( number / 360.0 ) * 360; +} + +double calcElevation( double SatLon, double SiteLat, double SiteLon, int Height_over_ocean = 0 ) +{ + double a0=0.58804392, + a1=-0.17941557, + a2=0.29906946E-1, + a3=-0.25187400E-2, + a4=0.82622101E-4, + + f = 1.00 / 298.257, // Earth flattning factor + + r_sat=42164.57, // Distance from earth centre to satellite + + r_eq=6378.14, // Earth radius + + sinRadSiteLat=SIN(Radians(SiteLat)), + cosRadSiteLat=COS(Radians(SiteLat)), + + Rstation = r_eq / ( std::sqrt( 1.00 - f*(2.00-f)*sinRadSiteLat*sinRadSiteLat ) ), + + Ra = (Rstation+Height_over_ocean)*cosRadSiteLat, + Rz= Rstation*(1.00-f)*(1.00-f)*sinRadSiteLat, + + alfa_rx=r_sat*COS(Radians(SatLon-SiteLon)) - Ra, + alfa_ry=r_sat*SIN(Radians(SatLon-SiteLon)), + alfa_rz=-Rz, + + alfa_r_north=-alfa_rx*sinRadSiteLat + alfa_rz*cosRadSiteLat, + alfa_r_zenith=alfa_rx*cosRadSiteLat + alfa_rz*sinRadSiteLat, + + El_geometric=Deg(ATAN( alfa_r_zenith/std::sqrt(alfa_r_north*alfa_r_north+alfa_ry*alfa_ry))), + + x = std::fabs(El_geometric+0.589), + refraction=std::fabs(a0+a1*x+a2*x*x+a3*x*x*x+a4*x*x*x*x), + + El_observed = 0.00; + + if (El_geometric > 10.2) + El_observed = El_geometric+0.01617*(COS(Radians(std::fabs(El_geometric)))/SIN(Radians(std::fabs(El_geometric))) ); + else + El_observed = El_geometric+refraction; + + if (alfa_r_zenith < -3000) + El_observed=-99; + + return El_observed; +} + +double calcAzimuth(double SatLon, double SiteLat, double SiteLon, int Height_over_ocean=0) +{ + double f = 1.00 / 298.257, // Earth flattning factor + + r_sat=42164.57, // Distance from earth centre to satellite + + r_eq=6378.14, // Earth radius + + sinRadSiteLat=SIN(Radians(SiteLat)), + cosRadSiteLat=COS(Radians(SiteLat)), + + Rstation = r_eq / ( std::sqrt( 1 - f*(2-f)*sinRadSiteLat*sinRadSiteLat ) ), + Ra = (Rstation+Height_over_ocean)*cosRadSiteLat, + Rz = Rstation*(1-f)*(1-f)*sinRadSiteLat, + + alfa_rx = r_sat*COS(Radians(SatLon-SiteLon)) - Ra, + alfa_ry = r_sat*SIN(Radians(SatLon-SiteLon)), + alfa_rz = -Rz, + + alfa_r_north = -alfa_rx*sinRadSiteLat + alfa_rz*cosRadSiteLat, + + Azimuth = 0.00; + + if (alfa_r_north < 0) + Azimuth = 180+Deg(ATAN(alfa_ry/alfa_r_north)); + else + Azimuth = Rev(360+Deg(ATAN(alfa_ry/alfa_r_north))); + + return Azimuth; +} + +double calcDeclination( double SiteLat, double Azimuth, double Elevation) +{ + return Deg( ASIN(SIN(Radians(Elevation)) * + SIN(Radians(SiteLat)) + + COS(Radians(Elevation)) * + COS(Radians(SiteLat)) + + COS(Radians(Azimuth)) + ) + ); +} + +double calcSatHourangle( double SatLon, double SiteLat, double SiteLon ) +{ + double Azimuth=calcAzimuth(SatLon, SiteLat, SiteLon ), + Elevation=calcElevation( SatLon, SiteLat, SiteLon ), + + a = - COS(Radians(Elevation)) * SIN(Radians(Azimuth)), + + b = SIN(Radians(Elevation)) * COS(Radians(SiteLat)) + - + COS(Radians(Elevation)) * SIN(Radians(SiteLat)) * COS(Radians(Azimuth)), + +// Works for all azimuths (northern & southern hemisphere) + returnvalue = 180 + Deg(ATAN(a/b)); + + if ( Azimuth > 270 ) + { + returnvalue = ( (returnvalue-180) + 360 ); + if (returnvalue>360) + returnvalue = 360 - (returnvalue-360); + } + + if ( Azimuth < 90 ) + returnvalue = ( 180 - returnvalue ); + + return returnvalue; +} diff --git a/lib/dvb/rotor_calc.h b/lib/dvb/rotor_calc.h new file mode 100644 index 0000000..dde45d2 --- /dev/null +++ b/lib/dvb/rotor_calc.h @@ -0,0 +1,4 @@ +#ifndef __LIB_ROTOR_CALC_H__ +#define __LIB_ROTOR_CALC_H__ +double calcSatHourangle( double SatLon, double SiteLat, double SiteLon ); +#endif // __LIB_ROTOR_CALC_H__ \ No newline at end of file diff --git a/lib/dvb/sec.cpp b/lib/dvb/sec.cpp index 475739f..98b00cf 100644 --- a/lib/dvb/sec.cpp +++ b/lib/dvb/sec.cpp @@ -1,5 +1,7 @@ #include #include +#include + #if HAVE_DVB_API_VERSION < 3 #define INVERSION Inversion #define FREQUENCY Frequency @@ -23,7 +25,7 @@ eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl() eDVBSatelliteDiseqcParameters &diseqc_ref = astra1.m_diseqc_parameters; eDVBSatelliteSwitchParameters &switch_ref = astra1.m_switch_parameters; - lnb_ref.m_lof_hi = 10607000; + lnb_ref.m_lof_hi = 10600000; lnb_ref.m_lof_lo = 9750000; lnb_ref.m_lof_threshold = 11700000; @@ -52,6 +54,7 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA { eDVBSatelliteDiseqcParameters &di_param = sit->second.m_diseqc_parameters; eDVBSatelliteSwitchParameters &sw_param = sit->second.m_switch_parameters; + eDVBSatelliteRotorParameters &rotor_param = sit->second.m_rotor_parameters; int hi=0, voltage = iDVBFrontend::voltageOff, tone = iDVBFrontend::toneOff, @@ -61,12 +64,14 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA lastcsw = -1, lastucsw = -1, lastToneburst = -1, + lastRotorCmd = -1, curRotorPos = -1; frontend.getData(0, lastcsw); frontend.getData(1, lastucsw); frontend.getData(2, lastToneburst); - frontend.getData(3, curRotorPos); + frontend.getData(3, lastRotorCmd); + frontend.getData(4, curRotorPos); if ( sat.frequency > lnb_param.m_lof_threshold ) hi = 1; @@ -220,15 +225,112 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA } else sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 30) ); + + frontend.setData(0, csw); + frontend.setData(1, ucsw); } } - if ( di_param.m_diseqc_mode == eDVBSatelliteDiseqcParameters::V1_2 && curRotorPos != sat.orbital_position ) - { - } if ( (changed_burst || send_diseqc) && di_param.m_toneburst_param != eDVBSatelliteDiseqcParameters::NO ) { sec_sequence.push_back( eSecCommand(eSecCommand::SEND_TONEBURST, di_param.m_toneburst_param) ); sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 30) ); + frontend.setData(2, di_param.m_toneburst_param); + } + if ( di_param.m_diseqc_mode == eDVBSatelliteDiseqcParameters::V1_2 ) + { + int RotorCmd=0; + bool useGotoXX = false; + + std::map::iterator it = + rotor_param.m_rotor_position_table.find( sat.orbital_position ); + + if (it != rotor_param.m_rotor_position_table.end()) // position for selected sat found ? + RotorCmd=it->second; + else // entry not in table found + { + eDebug("Entry for %d,%d° not in Rotor Table found... i try gotoXX°", sat.orbital_position / 10, sat.orbital_position % 10 ); + useGotoXX = true; + + int satDir = sat.orbital_position < 0 ? + eDVBSatelliteRotorParameters::WEST : + eDVBSatelliteRotorParameters::EAST; + + double SatLon = abs(sat.orbital_position)/10.00, + SiteLat = rotor_param.m_gotoxx_parameters.m_latitude, + SiteLon = rotor_param.m_gotoxx_parameters.m_longitude; + + if ( rotor_param.m_gotoxx_parameters.m_la_direction == eDVBSatelliteRotorParameters::SOUTH ) + SiteLat = -SiteLat; + + if ( rotor_param.m_gotoxx_parameters.m_lo_direction == eDVBSatelliteRotorParameters::WEST ) + SiteLon = 360 - SiteLon; + + if (satDir == eDVBSatelliteRotorParameters::WEST ) + SatLon = 360 - SatLon; + + eDebug("siteLatitude = %lf, siteLongitude = %lf, %lf degrees", SiteLat, SiteLon, SatLon ); + double satHourAngle = + calcSatHourangle( SatLon, SiteLat, SiteLon ); + eDebug("PolarmountHourAngle=%lf", satHourAngle ); + + static int gotoXTable[10] = + { 0x00, 0x02, 0x03, 0x05, 0x06, 0x08, 0x0A, 0x0B, 0x0D, 0x0E }; + + if (SiteLat >= 0) // Northern Hemisphere + { + int tmp=(int)round( fabs( 180 - satHourAngle ) * 10.0 ); + RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ]; + + if (satHourAngle < 180) // the east + RotorCmd |= 0xE000; + else // west + RotorCmd |= 0xD000; + } + else // Southern Hemisphere + { + if (satHourAngle < 180) // the east + { + int tmp=(int)round( fabs( satHourAngle ) * 10.0 ); + RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ]; + RotorCmd |= 0xD000; + } + else // west + { + int tmp=(int)round( fabs( 360 - satHourAngle ) * 10.0 ); + RotorCmd = (tmp/10)*0x10 + gotoXTable[ tmp % 10 ]; + RotorCmd |= 0xE000; + } + } + eDebug("RotorCmd = %04x", RotorCmd); + } + if ( RotorCmd != lastRotorCmd ) + { + eDVBDiseqcCommand diseqc; + diseqc.data[0] = 0xE0; + diseqc.data[1] = 0x31; // positioner + if ( useGotoXX ) + { + diseqc.len = 5; + diseqc.data[2] = 0x6E; // drive to angular position + diseqc.data[3] = ((RotorCmd & 0xFF00) / 0x100); + diseqc.data[4] = RotorCmd & 0xFF; + } + else + { + diseqc.len = 4; + diseqc.data[2] = 0x6B; // goto stored sat position + diseqc.data[3] = RotorCmd; + } + if ( rotor_param.m_inputpower_parameters.m_use ) + { // use measure rotor input power to detect rotor state + sec_sequence.push_back( eSecCommand(eSecCommand::MEASURE_IDLE_INPUTPOWER) ); + sec_sequence.push_back( eSecCommand(eSecCommand::SEND_DISEQC, diseqc) ); + frontend.setData(3, RotorCmd); + frontend.setData(4, sat.orbital_position); + } + else + eFatal("rotor turning without inputpowermeasure not implemented yet"); + } } } else diff --git a/lib/dvb/sec.h b/lib/dvb/sec.h index 7b5e5b2..645f8b1 100644 --- a/lib/dvb/sec.h +++ b/lib/dvb/sec.h @@ -9,7 +9,9 @@ class eSecCommand { public: enum { - NONE, SLEEP, SET_VOLTAGE, SET_TONE, SEND_DISEQC, SEND_TONEBURST, IF_LOCK_GOTO, IF_NOT_LOCK_GOTO, SET_FRONTEND + NONE, SLEEP, SET_VOLTAGE, SET_TONE, + SEND_DISEQC, SEND_TONEBURST, IF_LOCK_GOTO, IF_NOT_LOCK_GOTO, + MEASURE_IDLE_INPUTPOWER, SET_FRONTEND }; int cmd; union @@ -20,6 +22,9 @@ public: int msec; eDVBDiseqcCommand diseqc; }; + eSecCommand( int cmd ) + :cmd(cmd) + {} eSecCommand( int cmd, int val ) :cmd(cmd), voltage(val) {} diff --git a/lib/gdi/Makefile.am b/lib/gdi/Makefile.am index abb75b7..c3fc655 100644 --- a/lib/gdi/Makefile.am +++ b/lib/gdi/Makefile.am @@ -5,4 +5,4 @@ noinst_LIBRARIES = libenigma_gdi.a libenigma_gdi_a_SOURCES = \ region.cpp grc.cpp epng.cpp erect.cpp fb.cpp font.cpp font_arabic.cpp gfbdc.cpp \ - glcddc.cpp gpixmap.cpp lcd.cpp sdl.cpp gfont.cpp + glcddc.cpp gpixmap.cpp lcd.cpp gfont.cpp diff --git a/lib/gdi/gfbdc.cpp b/lib/gdi/gfbdc.cpp index 83ffed2..164258d 100644 --- a/lib/gdi/gfbdc.cpp +++ b/lib/gdi/gfbdc.cpp @@ -157,4 +157,6 @@ void gFBDC::reloadSettings() setPalette(); } -// eAutoInitPtr init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC"); +#ifndef SDLDC +eAutoInitPtr init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC"); +#endif \ No newline at end of file diff --git a/lib/gdi/sdl.cpp b/lib/gdi/sdl.cpp index 591487f..bf2b585 100644 --- a/lib/gdi/sdl.cpp +++ b/lib/gdi/sdl.cpp @@ -82,4 +82,6 @@ void gSDLDC::exec(gOpcode *o) } } +#ifdef SDLDC eAutoInitPtr init_gSDLDC(eAutoInitNumbers::graphic-1, "gSDLDC"); +#endif diff --git a/main/Makefile.am b/main/Makefile.am index ad838f5..39efea2 100644 --- a/main/Makefile.am +++ b/main/Makefile.am @@ -27,10 +27,9 @@ enigma2_LDADD = \ @MAD_LIBS@ \ @PNG_LIBS@ \ @SIGC_LIBS@ \ - @SDL_LIBS@ \ -ldl -lpthread -lcrypt -lresolv -lpython2.3 enigma2$(EXEEXT): $(enigma2_OBJECTS) $(enigma2_DEPENDENCIES) $(enigma2_LDADD_WHOLE) @rm -f enigma2$(EXEEXT) -# $(CXXLINK) $(enigma2_LDFLAGS) $(enigma2_OBJECTS) -Wl,--export-dynamic -Wl,--whole-archive $(enigma2_LDADD_WHOLE) -Wl,--no-whole-archive $(enigma2_LDADD) $(LIBS) - g++ -o enigma2$(EXEEXT) $(enigma2_LDFLAGS) $(enigma2_OBJECTS) -Wl,--export-dynamic -Wl,--whole-archive $(enigma2_LDADD_WHOLE) -Wl,--no-whole-archive $(enigma2_LDADD) $(LIBS) + $(CXXLINK) $(enigma2_LDFLAGS) $(enigma2_OBJECTS) -Wl,--export-dynamic -Wl,--whole-archive $(enigma2_LDADD_WHOLE) -Wl,--no-whole-archive $(enigma2_LDADD) $(LIBS) +# g++ -o enigma2$(EXEEXT) $(enigma2_LDFLAGS) $(enigma2_OBJECTS) -Wl,--export-dynamic -Wl,--whole-archive $(enigma2_LDADD_WHOLE) -Wl,--no-whole-archive $(enigma2_LDADD) $(LIBS) diff --git a/main/enigma-gdi.cpp b/main/enigma-gdi.cpp index d0010ad..003a3cc 100644 --- a/main/enigma-gdi.cpp +++ b/main/enigma-gdi.cpp @@ -68,7 +68,7 @@ int main() pal[a | 0x10] = (0x111111 * a) | 0xFF; p.setPalette(pal, 0, 256); - fontRenderClass::getInstance()->AddFont("/dbox2/cdkroot/share/fonts/arial.ttf", "Arial", 100); + fontRenderClass::getInstance()->AddFont("/usr/share/fonts/arial.ttf", "Arial", 100); p.resetClip(gRegion(eRect(0, 0, 720, 576))); diff --git a/main/enigma-gui.cpp b/main/enigma-gui.cpp index 475a453..31da7a5 100644 --- a/main/enigma-gui.cpp +++ b/main/enigma-gui.cpp @@ -67,7 +67,7 @@ int main() pal[a | 0x10] = (0x111111 * a) | 0xFF; p.setPalette(pal, 0, 256); - fontRenderClass::getInstance()->AddFont("/dbox2/cdkroot/share/fonts/arial.ttf", "Arial", 100); + fontRenderClass::getInstance()->AddFont("/usr/share/fonts/arial.ttf", "Arial", 100); eWidgetDesktop dsk(eSize(720, 576)); dsk.setDC(my_dc); diff --git a/main/enigma.cpp b/main/enigma.cpp index 156964c..4f3287f 100644 --- a/main/enigma.cpp +++ b/main/enigma.cpp @@ -1,4 +1,3 @@ -#define SDLDC #include #include #include @@ -10,7 +9,9 @@ #include #include +#ifdef SDLDC #include +#endif #include #include @@ -144,7 +145,7 @@ int main(int argc, char **argv) gFBDC::getInstance(my_dc); #endif - fontRenderClass::getInstance()->AddFont("/home/tmbinc/enigma2/fonts/arial.ttf", "Arial", 100); + fontRenderClass::getInstance()->AddFont("/usr/share/fonts/arial.ttf", "Arial", 100); eWidgetDesktop dsk(eSize(720, 576)); -- 2.7.4