fix one step east / one step west option
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 26 May 2006 10:44:00 +0000 (10:44 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 26 May 2006 10:44:00 +0000 (10:44 +0000)
add ability to (re)enable rotor limits
add ability to turn rotor to reference position (goto 0)

lib/dvb/frontend.cpp
lib/dvb/frontend.h
lib/dvb/sec.cpp
lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py

index b85fbc2..220d3e8 100644 (file)
@@ -91,6 +91,7 @@ void eDVBDiseqcCommand::setCommandString(const char *str)
                eDebug("invalid diseqc command string length (string is to long)");
                return;
        }
+       eDebugNoNewLine("send diseqc:");
        unsigned char val=0;
        for (int i=0; i < slen; ++i)
        {
@@ -107,11 +108,13 @@ void eDVBDiseqcCommand::setCommandString(const char *str)
                if ( i % 2 )
                {
                        val |= c;
+                       eDebugNoNewLine("%02x", val);
                        data[i/2] = val;
                }
                else
                        val = c << 4;
        }
+       eDebug("");
        len = slen/2;
 }
 
@@ -543,12 +546,16 @@ void eDVBFrontend::feEvent(int w)
 #endif
                {
                        state = stateLock;
+                       m_data[CSW] = m_data[NEW_CSW];
+                       m_data[UCSW] = m_data[NEW_UCSW];
+                       m_data[TONEBURST] = m_data[NEW_TONEBURST];
                } else
                {
                        if (m_tuning)
                                state = stateTuning;
                        else
                        {
+                               eDebug("stateLostLock");
                                state = stateLostLock;
                                m_data[CSW] = m_data[UCSW] = m_data[TONEBURST] = -1; // reset diseqc
                        }
index 3670ceb..abc28d9 100644 (file)
@@ -58,6 +58,9 @@ class eDVBFrontend: public iDVBFrontend, public Object
        eSecCommandList m_sec_sequence;
 
        enum {
+               NEW_CSW,              // new committed switch cmd
+               NEW_UCSW,             // new uncommitted switch cmd
+               NEW_TONEBURST,        // new toneburst switch cmd
                CSW,                  // state of the committed switch
                UCSW,                 // state of the uncommitted switch
                TONEBURST,            // current state of toneburst switch
index 70c742a..e0bf5fd 100644 (file)
@@ -544,8 +544,8 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                        sec_sequence.push_back( eSecCommand(eSecCommand::IF_VOLTAGE_GOTO, compare) );
                                        compare.steps = +3;
                                        sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, compare.voltage) );
-                                       // voltage was disabled..so we wait a longer time .. for normal switches 200ms should be enough
-                                       sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 200) );
+                                       // voltage was disabled..so we wait a longer time .. for normal switches 500ms should be enough
+                                       sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 750) );
 
                                        for (int seq_repeat = 0; seq_repeat < (di_param.m_seq_repeat?2:1); ++seq_repeat)
                                        {
@@ -627,25 +627,28 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                if ( RotorCmd != -1 && RotorCmd != lastRotorCmd )
                                {
                                        eSecCommand::pair compare;
-                                       compare.voltage = iDVBFrontend::voltageOff;
-                                       compare.steps = +4;
-                                       // the next is a check if voltage is switched off.. then we first set a voltage :)
-                                       // else we set voltage after all diseqc stuff..
-                                       sec_sequence.push_back( eSecCommand(eSecCommand::IF_NOT_VOLTAGE_GOTO, compare) );
-
-                                       if (rotor_param.m_inputpower_parameters.m_use)
-                                               sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(13)) ); // in normal mode start turning with 13V
-                                       else
-                                               sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(18)) ); // turn always with 18V
+                                       if (!send_mask)
+                                       {
+                                               compare.voltage = iDVBFrontend::voltageOff;
+                                               compare.steps = +4;
+                                               // the next is a check if voltage is switched off.. then we first set a voltage :)
+                                               // else we set voltage after all diseqc stuff..
+                                               sec_sequence.push_back( eSecCommand(eSecCommand::IF_NOT_VOLTAGE_GOTO, compare) );
 
-                                       // voltage was disabled..so we wait a longer time ..
-                                       sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 500) );
-                                       sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +7) );  // no need to send stop rotor cmd
+                                               if (rotor_param.m_inputpower_parameters.m_use)
+                                                       sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(13)) ); // in normal mode start turning with 13V
+                                               else
+                                                       sec_sequence.push_back( eSecCommand(eSecCommand::SET_VOLTAGE, VOLTAGE(18)) ); // turn always with 18V
 
-                                       if (send_mask)
-                                               sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 750) ); // wait 750ms after send switch cmd
+                                               // voltage was disabled..so we wait a longer time ..
+                                               sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 750) );
+                                               sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +8) );  // no need to send stop rotor cmd and recheck voltage
+                                       }
                                        else
-                                               sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +1) );
+                                       {
+                                               sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, 750) ); // wait 750ms after send switch cmd
+                                               sec_sequence.push_back( eSecCommand(eSecCommand::GOTO, +8) );  // no need to send stop rotor cmd and recheck voltage
+                                       }
 
                                        eDVBDiseqcCommand diseqc;
                                        diseqc.len = 3;
@@ -771,9 +774,9 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                        else
                                csw = band;
 
-                       frontend.setData(eDVBFrontend::CSW, csw);
-                       frontend.setData(eDVBFrontend::UCSW, ucsw);
-                       frontend.setData(eDVBFrontend::TONEBURST, di_param.m_toneburst_param);
+                       frontend.setData(eDVBFrontend::NEW_CSW, csw);
+                       frontend.setData(eDVBFrontend::NEW_UCSW, ucsw);
+                       frontend.setData(eDVBFrontend::NEW_TONEBURST, di_param.m_toneburst_param);
 
                        if (!linked && doSetVoltageToneFrontend)
                        {
index 087838a..76e4bee 100644 (file)
@@ -15,31 +15,31 @@ from Components.config import config, ConfigSubsection, configElement_nonSave, c
 class PositionerSetup(Screen):
        skin = """
                <screen position="100,100" size="560,400" title="Positioner setup..." >
-                       <widget name="list" position="100,0" size="350,130" />
+                       <widget name="list" position="100,0" size="350,155" />
 
-                       <widget name="red" position="0,130" size="140,80" backgroundColor="red" halign="center" valign="center" font="Regular;21" />
-                       <widget name="green" position="140,130" size="140,80" backgroundColor="green" halign="center" valign="center" font="Regular;21" />
-                       <widget name="yellow" position="280,130" size="140,80" backgroundColor="yellow" halign="center" valign="center" font="Regular;21" />
-                       <widget name="blue" position="420,130" size="140,80" backgroundColor="blue" halign="center" valign="center" font="Regular;21" />
+                       <widget name="red" position="0,155" size="140,80" backgroundColor="red" halign="center" valign="center" font="Regular;21" />
+                       <widget name="green" position="140,155" size="140,80" backgroundColor="green" halign="center" valign="center" font="Regular;21" />
+                       <widget name="yellow" position="280,155" size="140,80" backgroundColor="yellow" halign="center" valign="center" font="Regular;21" />
+                       <widget name="blue" position="420,155" size="140,80" backgroundColor="blue" halign="center" valign="center" font="Regular;21" />
                        
-                       <widget name="snr" text="SNR:" position="0,220" size="60,22" font="Regular;21" />
-                       <widget name="agc" text="AGC:" position="0,245" size="60,22" font="Regular;21" />
-                       <widget name="ber" text="BER:" position="0,270" size="60,22" font="Regular;21" />
-                       <widget name="lock" text="Lock:" position="0,295" size="60,22" font="Regular;21" />
-                       <widget name="snr_percentage" position="220,220" size="60,22" font="Regular;21" />
-                       <widget name="agc_percentage" position="220,245" size="60,22" font="Regular;21" />
-                       <widget name="ber_value" position="220,270" size="60,22" font="Regular;21" />
-                       <widget name="lock_state" position="60,295" size="150,22" font="Regular;21" />
-                       <widget name="snr_bar" position="60,220" size="150,22" />
-                       <widget name="agc_bar" position="60,245" size="150,22" />
-                       <widget name="ber_bar" position="60,270" size="150,22" />
+                       <widget name="snr" text="SNR:" position="0,245" size="60,22" font="Regular;21" />
+                       <widget name="agc" text="AGC:" position="0,270" size="60,22" font="Regular;21" />
+                       <widget name="ber" text="BER:" position="0,295" size="60,22" font="Regular;21" />
+                       <widget name="lock" text="Lock:" position="0,320" size="60,22" font="Regular;21" />
+                       <widget name="snr_percentage" position="220,245" size="60,22" font="Regular;21" />
+                       <widget name="agc_percentage" position="220,270" size="60,22" font="Regular;21" />
+                       <widget name="ber_value" position="220,295" size="60,22" font="Regular;21" />
+                       <widget name="lock_state" position="60,320" size="150,22" font="Regular;21" />
+                       <widget name="snr_bar" position="60,245" size="150,22" />
+                       <widget name="agc_bar" position="60,270" size="150,22" />
+                       <widget name="ber_bar" position="60,295" size="150,22" />
 
-                       <widget name="frequency" text="Frequency:" position="300,220" size="120,22" font="Regular;21" />
-                       <widget name="symbolrate" text="Symbolrate:" position="300,245" size="120,22" font="Regular;21" />
-                       <widget name="fec" text="FEC:" position="300,270" size="120,22" font="Regular;21" />
-                       <widget name="frequency_value" position="420,220" size="120,22" font="Regular;21" />
-                       <widget name="symbolrate_value" position="420,245" size="120,22" font="Regular;21" />
-                       <widget name="fec_value" position="420,270" size="120,22" font="Regular;21" />
+                       <widget name="frequency" text="Frequency:" position="300,245" size="120,22" font="Regular;21" />
+                       <widget name="symbolrate" text="Symbolrate:" position="300,270" size="120,22" font="Regular;21" />
+                       <widget name="fec" text="FEC:" position="300,295" size="120,22" font="Regular;21" />
+                       <widget name="frequency_value" position="420,245" size="120,22" font="Regular;21" />
+                       <widget name="symbolrate_value" position="420,270" size="120,22" font="Regular;21" />
+                       <widget name="fec_value" position="420,295" size="120,22" font="Regular;21" />
                </screen>"""
        def __init__(self, session, feid):
                self.skin = PositionerSetup.skin
@@ -119,8 +119,9 @@ class PositionerSetup(Screen):
                config.positioner.move = configElement_nonSave("move", configNothing, 0, None)
                config.positioner.finemove = configElement_nonSave("finemove", configNothing, 0, None)
                config.positioner.limits = configElement_nonSave("limits", configNothing, 0, None)
+               config.positioner.goto0 = configElement_nonSave("goto0", configNothing, 0, None)
                storepos = []
-               for x in range(255):
+               for x in range(1,255):
                        storepos.append(str(x))
                config.positioner.storage = configElement_nonSave("storage", configSelection, 0, storepos)
        
@@ -130,7 +131,7 @@ class PositionerSetup(Screen):
                self.list.append(getConfigListEntry(_("Positioner fine movement"), config.positioner.finemove))
                self.list.append(getConfigListEntry(_("Set limits"), config.positioner.limits))
                self.list.append(getConfigListEntry(_("Positioner storage"), config.positioner.storage))
-               
+               self.list.append(getConfigListEntry(_("Goto 0"), config.positioner.goto0))
                self["list"].l.setList(self.list)
                
        def go(self):
@@ -181,12 +182,17 @@ class PositionerSetup(Screen):
                        self.red.setText(_("Limits off"))
                        self.green.setText(_("Limit west"))
                        self.yellow.setText(_("Limit east"))
-                       self.blue.setText("")
+                       self.blue.setText(_("Limits on"))
                elif entry == "storage":
                        self.red.setText("")
                        self.green.setText(_("Store position"))
                        self.yellow.setText(_("Goto position"))
                        self.blue.setText("")
+               elif entry == "goto0":
+                       self.red.setText(_("Goto 0"))
+                       self.green.setText("")
+                       self.yellow.setText("")
+                       self.blue.setText("")
                else:
                        self.red.setText("")
                        self.green.setText("")
@@ -208,7 +214,10 @@ class PositionerSetup(Screen):
                        self.diseqccommand("limitOff")
                elif entry == "tune":
                        self.session.openWithCallback(self.tune, TunerScreen, self.feid)
-                               
+               elif entry == "goto0":
+                       print "move to position 0"
+                       self.diseqccommand("moveTo", 0)
+
        def greenKey(self):
                entry = self.getCurrentConfigPath()
                if entry == "move":
@@ -223,7 +232,7 @@ class PositionerSetup(Screen):
                        self.updateColors("move")
                elif entry == "finemove":
                        print "stepping west"
-                       self.diseqccommand("moveWest", 1)
+                       self.diseqccommand("moveWest", 0xFF) # one step
                elif entry == "storage":
                        print "store at position", (config.positioner.storage.value + 1)
                        self.diseqccommand("store", config.positioner.storage.value + 1)
@@ -244,7 +253,7 @@ class PositionerSetup(Screen):
                        self.updateColors("move")
                elif entry == "finemove":
                        print "stepping east"
-                       self.diseqccommand("moveEast", 1)
+                       self.diseqccommand("moveEast", 0xFF) # one step
                elif entry == "storage":
                        print "move to position", (config.positioner.storage.value + 1)
                        self.diseqccommand("moveTo", config.positioner.storage.value + 1)
@@ -263,7 +272,9 @@ class PositionerSetup(Screen):
                                self.isMoving = True
                        self.updateColors("move")
                        print "moving east"
-                       
+               elif entry == "limits":
+                       self.diseqccommand("limitOn")
+
        def diseqccommand(self, cmd, param = 0):
                self.diseqc.command(cmd, param)
                self.tuner.retune()
@@ -322,6 +333,8 @@ class Diseqc:
                                string = 'e0316b' + ("%02x" % param)
                        elif what == "store":
                                string = 'e0316a' + ("%02x" % param)
+                       elif what == "limitOn":
+                               string = 'e0316a00'
                        elif what == "limitOff":
                                string = 'e03163'
                        elif what == "limitEast":
@@ -452,7 +465,7 @@ class TunerScreen(ScanSetup):
                        returnvalue = (config.scan.sat.frequency.value[0], config.scan.sat.symbolrate.value[0], config.scan.sat.polarization.value, config.scan.sat.fec.value, config.scan.sat.inversion.value, satpos)
                elif currentConfigSelectionElement(config.tuning.type) == "predefined_transponder":
                        transponder = nimmanager.getTransponders(config.tuning.sat.vals[config.tuning.sat.value][1])[config.tuning.transponder.value]
-                       returnvalue = (int(transponder[1] / 100), int(transponder[2] / 1000), transponder[3], transponder[4], 2, config.tuning.sat.vals[config.tuning.sat.value][1], satpos)
+                       returnvalue = (int(transponder[1] / 1000), int(transponder[2] / 1000), transponder[3], transponder[4], 2, config.tuning.sat.vals[config.tuning.sat.value][1], satpos)
                self.close(returnvalue)
 
        def keyCancel(self):