Jump to content


Photo

DAB+ with RTL-SDR stick


  • Please log in to reply
87 replies to this topic

#1 serdeliuk

  • Senior Member
  • 333 posts

+18
Neutral

Posted 18 April 2016 - 21:18

Hello,

 

I started to learn Enigma2 and found that out there are so few informations, I thought that will be very good documented, but that was not the case.

So far I was able to dynamically change a label :) but I want to do more, for example to change the button's png dynamically during the plugin execution based on dynamic events, to hide the window border and title bar at window/screen creation, to display two or more windows/screens at once, etc.

 

Could be someone here be so kind to give me right directions or maybe some documentation to read?

 

I was able to stop current service when my plugin starts and restart current service when the plugin exit, but could not find how to pause or start timeshift on the current service and play again where was at exit.

 

I am working on a RTL-SDR radio plugin/interface, i have successfully compiled all required libraries and from command line the RTL-SDR radio is working well, I wonder how complicated could be on your side to add meta-sdr to your repo/nightly builds, for anybody interested to have access on those RTL-SDR libraries along OpenPli package management.

 

I can put a packages feed online somewhere publicly, but will not have enough time to do updates along your updates on those packages.

 

 

Many thanks,

 

 

Marc

 

 


init 2 && init 3


Re: DAB+ with RTL-SDR stick #2 serdeliuk

  • Senior Member
  • 333 posts

+18
Neutral

Posted 18 April 2016 - 23:11

Ok, so far i found how to change the button shape by changing the actual png.

 

<screen.....

        <widget name="test_button" position="550,10" size="185,85" alphatest="on" />

.../screen>

 

....

   self["test_button"] = Pixmap()

   self["test_button"].instance.setPixmapFromFile("/usr/lib/enigma2/python/Plugins/Extensions/MS-SDR/img/btn_mem_pressed.png")

....

and / or

....

   self["test_button"].instance.setPixmapFromFile("/usr/lib/enigma2/python/Plugins/Extensions/MS-SDR/img/btn_mem.png")

....

 

So, funny, if this is possible why the Enigma2 is so boring, it is a lack of design / designers?

 

With above "self_made" pngs i can simulate visually a button when is pressed, with a "beautiful" design

 

btn_up_down.png


init 2 && init 3


Re: DAB+ with RTL-SDR stick #3 gorski

  • Senior Member
  • 1,699 posts

+46
Good

Posted 19 April 2016 - 00:04

New HW has the capacity to make it look much better, for sure...

 

In older ones it was a struggle for efficiency...

 

Now, 1080, 32b, blah-blah...

 

Good luck!


<span style='font-family: comic sans ms,cursive'>"Enlightenment is man's emergence from his self-incurred immaturity. Immaturity is the inability to use one's own understanding without the guidance of another. This immaturity is self-incurred if its cause is not lack of understanding, but lack of resolution and courage to use it without the guidance of another. The motto of enlightenment is therefore: Sapere aude! Have courage to use your own understanding!</span><br /> <br /><span style='font-family: comic sans ms,cursive'>Laziness and cowardice are the reasons why such a large proportion of men, even when nature has long emancipated them from alien guidance..." I. Kant, "Political writings" (1784)</span><br /> <br /><span style='font-family: comic sans ms,cursive'><a class='bbc_url' href='<a class='bbc_url' href='http://eserver.org/p...lightenment.txt'>http://eserver.org/p...ent.txt</a>'><a class='bbc_url' href='http://www.english.upenn.edu/~mgamer/Etexts/kant.html</a>'>http://www.english.upenn.edu/~mgamer/Etexts/kant.html</a></a> - the jolly text on Enlightenment, at the basis of Modernity...</span>

Re: DAB+ with RTL-SDR stick #4 serdeliuk

  • Senior Member
  • 333 posts

+18
Neutral

Posted 19 April 2016 - 00:29

Thanks, understand that, but those are basic functions, supported by any hardware, does not require any intensive processing, i will test them on my old DM800PVR to see if there is any difference, but for sure I will not see any, those functions are used when plugin icon is displayed in the plugin list.

 

Then the question remain, if it is possible, why is so ugly enigma2 and nobody tried to fix the ugliness :)

Even it is a graphical display it's menus show alike text menus, but are graphical, well, the difference between graphical and text interfaces are the differences between ms-windows and ms-dos, why to not create windows when it is possible and create simple dos interfaces, when use windows??? Seems silly.... :)

All skins are made on the same blueprints, and seems that all use the same "text" pattern, why? Nobody creative there?

 

Best regards,

 

Marc


init 2 && init 3


Re: DAB+ with RTL-SDR stick #5 serdeliuk

  • Senior Member
  • 333 posts

+18
Neutral

Posted 19 April 2016 - 04:21

Just to let you know the first stage of the memory/preset menu :) here is a gif

 

buttons.gif

 
I wonder if is there any trick to remove the title bar and borders.... are ugly

Edited by serdeliuk, 19 April 2016 - 04:21.

init 2 && init 3


Re: DAB+ with RTL-SDR stick #6 serdeliuk

  • Senior Member
  • 333 posts

+18
Neutral

Posted 19 April 2016 - 04:28

This is actually an working plugin, pressing 0 through 9 on the remote control and taking screenshots, with grab, after every key press...   :)

 

The screenshots where modified, cropped and exported with ffmpeg, as following

 

### create movie from image0.jpg to image9.jpg

ffmpeg -framerate 1/0.5 -i image%d.jpg -c:v libx264 -r 30 -pix_fmt yuv420p buttons.mp4
 
### detect crop, output crop=1024:128:448:572
ffmpeg -i buttons.mp4 -vf "cropdetect=24:16:0" dummy.avi
 
### crop blackness, based on the previous output, look for crop after each frame
ffmpeg -i buttons.mp4 -vf "crop=1080:150:425:558" buttons_cropped.mp4
 
### convert to gif
ffmpeg -i buttons_cropped.mp4 buttons.gif

Edited by serdeliuk, 19 April 2016 - 04:31.

init 2 && init 3


Re: DAB+ with RTL-SDR stick #7 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 19 April 2016 - 15:52

To remove border and titlebar

<screen name ="Screen1" position="0,0" size="1280,720" backgroundColor="#080000" flags="wfNoBorder" > 


Re: DAB+ with RTL-SDR stick #8 serdeliuk

  • Senior Member
  • 333 posts

+18
Neutral

Posted 19 April 2016 - 18:16

Yhuuuuu, many thanks, it's worked now i have a "beautiful" design without borders and title bar.


init 2 && init 3


Re: DAB+ with RTL-SDR stick #9 serdeliuk

  • Senior Member
  • 333 posts

+18
Neutral

Posted 25 April 2016 - 23:33

Hello,

 

Is there any way to have custom fonts in plugins, ie. to not install the font system wide?

I have added the custom font to the skin_default.xml file, but any update will remove my lines.

Tried to add the font to the section "skin" from plugin, but does not work.

 

Thanks,

 

 

Marc


init 2 && init 3


Re: DAB+ with RTL-SDR stick #10 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 26 April 2016 - 13:39

add this code to main plugin.py

try:
     from enigma import addFont
     font_shortname="lcd.otf"
     fontpath = '/usr/share/fonts'
     font_fullpath = fontpath + '/' + font_shortname
     addFont(font_fullpath, 'Customfont', 100, 1)
except:
    print "failed to add font"

 in skin_default.xml

        <screen name ="Screen4" position="0,0" size="1280,720" backgroundColor="#080000" flags="wfNoBorder" title="Playlist" > 
		
                <widget name="text" position="30,580" size="760,84" backgroundColor="#080000" transparent="1" font="Customfont;20" valign="top" halign="center" zPosition="1" />                 
                <widget name="info" position="820,580" zPosition="4" size="440,84" font="Customfont;20" foregroundColor="yellow" transparent="1" halign="center" valign="top" />
                

        </screen>        
                
              
        

Edited by mfaraj57, 26 April 2016 - 13:39.


Re: DAB+ with RTL-SDR stick #11 MiLo

  • PLi® Core member
  • 14,055 posts

+298
Excellent

Posted 26 April 2016 - 14:40

Use os.path.join() instead of string manipulation (... + '/' + ...) to merge path names in Python.
Real musicians never die - they just decompose

Re: DAB+ with RTL-SDR stick #12 serdeliuk

  • Senior Member
  • 333 posts

+18
Neutral

Posted 26 April 2016 - 18:20

Thanks, it worked like a charm.


init 2 && init 3


Re: DAB+ with RTL-SDR stick #13 serdeliuk

  • Senior Member
  • 333 posts

+18
Neutral

Posted 26 April 2016 - 18:33

Here is the first stage of my first Enigma2 UI :)

 

enigma2-dinamic-ui.png


init 2 && init 3


Re: DAB+ with RTL-SDR stick #14 serdeliuk

  • Senior Member
  • 333 posts

+18
Neutral

Posted 5 May 2016 - 03:33

Hi,

 

I wonder how i can pause current service before i start my plugin and play again that service when plugin stops, is there any way to achieve that?

 

Currently i use following code to stop and start current service, but i want to pause/play current service instead, if it is on tv to pause current tv channel or if it is on movie player to pause the movie.

 

# when start the plugin 

self.oldService = session.nav.getCurrentlyPlayingServiceReference()
session.nav.stopService()
 
# when exit plugin
self.session.nav.playService(self.oldService)

 

 

Best regards,

 

 

Marc


init 2 && init 3


Re: DAB+ with RTL-SDR stick #15 littlesat

  • PLi® Core member
  • 57,062 posts

+698
Excellent

Posted 5 May 2016 - 07:47

Look at standby.py

WaveFrontier 28.2E | 23.5E | 19.2E | 16E | 13E | 10/9E | 7E | 5E | 1W | 4/5W | 15W


Re: DAB+ with RTL-SDR stick #16 serdeliuk

  • Senior Member
  • 333 posts

+18
Neutral

Posted 5 May 2016 - 14:28

Thanks, provided solution solve the pause only when i am watching a movie or a ts stream.

It is there any other way to pause the live tv? Mean alike timeshit, to pause the live tv.

 

Also, is there any way to play a ts stream from a plugin.

 

Many thanks,

 

 

Marc


init 2 && init 3


Re: DAB+ with RTL-SDR stick #17 gorski

  • Senior Member
  • 1,699 posts

+46
Good

Posted 5 May 2016 - 16:23

Video or List or some such button takes you to DVD player, I think...
<span style='font-family: comic sans ms,cursive'>"Enlightenment is man's emergence from his self-incurred immaturity. Immaturity is the inability to use one's own understanding without the guidance of another. This immaturity is self-incurred if its cause is not lack of understanding, but lack of resolution and courage to use it without the guidance of another. The motto of enlightenment is therefore: Sapere aude! Have courage to use your own understanding!</span><br /> <br /><span style='font-family: comic sans ms,cursive'>Laziness and cowardice are the reasons why such a large proportion of men, even when nature has long emancipated them from alien guidance..." I. Kant, "Political writings" (1784)</span><br /> <br /><span style='font-family: comic sans ms,cursive'><a class='bbc_url' href='<a class='bbc_url' href='http://eserver.org/p...lightenment.txt'>http://eserver.org/p...ent.txt</a>'><a class='bbc_url' href='http://www.english.upenn.edu/~mgamer/Etexts/kant.html</a>'>http://www.english.upenn.edu/~mgamer/Etexts/kant.html</a></a> - the jolly text on Enlightenment, at the basis of Modernity...</span>

Re: DAB+ with RTL-SDR stick #18 serdeliuk

  • Senior Member
  • 333 posts

+18
Neutral

Posted 5 May 2016 - 17:14

Well some functions, yes.

 

Currently I am building and SDR (Software Defined Radio), it is almost ready, but i want to add some features, it have assigned a hotkey and when it is pressed the main screen pop out and i want to pause current video service, to play in background a video stream without sound and as audio source will be the SDR.

After a while, if no button pressed, or any kind of activity the main screen will fade and on the screen will remain only the video stream, as "screen saver" and with tuned frequency as audio, if any kind of activity will happen and require user attention the main screen will pop. For example if the radio is set to CB scanning and an event happen and require user attention, the main screen will pop from background.

After plugin is closed the previous service should start play as where before.

 

Best regards,

 

 

Marc

 

P.S.

The video stream will be NASA's ISS live HD stream.... :)


Edited by serdeliuk, 5 May 2016 - 17:15.

init 2 && init 3


Re: DAB+ with RTL-SDR stick #19 Mouneer

  • Member
  • 13 posts

0
Neutral

Posted 11 June 2016 - 03:20

Hi,

I'm trying tp update an image loaded from a URL. I use method editMyImage to update it. For some reasons, method DecodePicture called only at the first image load causing it not to be updated any more.

 

Your help would be very very apreciated.

 

My Current Code:

# -*- coding: utf-8 -*-
import time
from threading import Thread
from Components.ActionMap import ActionMap
from Components.config import config, ConfigInteger, ConfigSubsection, ConfigYesNo
from Components.MenuList import MenuList
from Plugins.Plugin import PluginDescriptor
from Screens.Screen import Screen
from Components.Pixmap import Pixmap
from Components.AVSwitch import AVSwitch
from enigma import ePicLoad
from twisted.web.client import downloadPage
from Screens.MessageBox import MessageBox


config.plugins.Satat = ConfigSubsection()
config.plugins.Satat.enabled = ConfigYesNo(default=True)
config.plugins.Satat.position_x = ConfigInteger(default=590)
config.plugins.Satat.position_y = ConfigInteger(default=590)


##############################################################################


SKIN = """
<screen position="0,0" size="300,300" zPosition="10" backgroundColor="#ff000000"
        title="My Sat" flags="wfNoBorder">
    <widget name="myPic" position="20,40" size="100,100" zPosition="1" />
</screen>
"""


##############################################################################


class SatatScreen(Screen):
    def __init__(self, session, picPath = None):
        picPath = "http://www.i-have-a-dreambox.com/images/ihad.jpg"
        Screen.__init__(self, session)
        self.skin = SKIN
        self.session = session
        downloaded_image = getPicfromUrl(session, picPath, "/tmp/myPic.tmp")
        picPath = downloaded_image.path
        self.picPath = picPath
        self.Scale = AVSwitch().getFramebufferScale()
        self.PicLoad = ePicLoad()
        self["myPic"] = Pixmap()
        self.PicLoad.PictureData.get().append(self.DecodePicture)
        self.onLayoutFinish.append(self.ShowPicture)


    def ShowPicture(self):
        if self.picPath is not None:
            self.PicLoad.setPara([
            self["myPic"].instance.size().width(),
            self["myPic"].instance.size().height(),
            self.Scale[0],
            self.Scale[1],
            0,
            1,
            "#002C2C39"])
            self.PicLoad.startDecode(self.picPath)


    def DecodePicture(self, PicInfo = ""):
        if self.picPath is not None:
            ptr = self.PicLoad.getData()
            self["myPic"].instance.setPixmap(ptr)


    def editMyImage(self, path):
        downloaded_image = getPicfromUrl(self.session, path, "/tmp/myPic.tmp")
        picPath = downloaded_image.path
        self.picPath = picPath
        self.PicLoad.PictureData.get().append(self.DecodePicture)


##############################################################################
class getPicfromUrl(object):
    def __init__(self, session, url=None, path=None):
        self.path = path
        self.session = session
        self.download(url, path)
    def download(self, url, path):
        downloadPage(url,
        path).addCallback(self.downloadDone).addErrback(self.downloadError)
    def downloadError(self, raw):
        print "[e2Fetcher.fetchPage]: download Error", raw


    def downloadDone(self,raw):
        print "[e2Fetcher.fetchPage]: download done", raw


##############################################################################
def print_sat(my_sat):
    global COUNTER
    while not my_sat.stop:
        my_sat.dialog.show()
        time.sleep(5)
        my_sat.dialog.hide()
        time.sleep(1)
        my_sat.dialog.editMyImage("http://www.python-course.eu/images/arrow.png")


class Satat:
    def __init__(self):
        self.dialog = None
        self.stop = False


    def got_session(self, session):
        self.dialog = session.instantiateDialog(SatatScreen)
        self.show_hide()


    def change_visibility(self):
        if config.plugins.Satat.enabled.value:
            config.plugins.Satat.enabled.value = False
        else:
            config.plugins.Satat.enabled.value = True
        config.plugins.Satat.enabled.save()
        self.show_hide()


    def show_hide(self):
        if config.plugins.Satat.enabled.value:
            self.stop = False
            sat_thread = Thread(target=print_sat, args=(self,))
            sat_thread.start()
        else:
            self.stop = True
            self.dialog.hide()




satat = Satat()


##############################################################################


class SatatMenu(Screen):
    skin = """
            <screen position="center,center" size="420,105" title="Satat">
                <widget name="list" position="10,10" size="400,85" />
            </screen>
            """


    def __init__(self, session):
        Screen.__init__(self, session)
        self.session = session
        self["list"] = MenuList([])
        self["actions"] = ActionMap(["OkCancelActions"], {"ok": self.ok_clicked, "cancel": self.close}, -1)
        self.onLayoutFinish.append(self.show_menu)


    def show_menu(self):
        my_list = []
        if config.plugins.Satat.enabled.value:
            my_list.append("Deactivate Satat")
        else:
            my_list.append("Activate Satat")
        self["list"].setList(my_list)


    def ok_clicked(self):
        sel = self["list"].getCurrent()
        if Satat.dialog is None:
            Satat.got_session(self.session)
        if sel == "Deactivate Satat" or sel == "Activate Satat":
            satat.change_visibility()
            self.show_menu()




##############################################################################


def session_start(reason, **kwargs):
    if reason == 0:
        satat.got_session(kwargs["session"])




def start_config(session, **kwargs):
    session.open(SatatMenu)




def main(menu_id):
    if menu_id != "system":
        return []
    return [("Sat", start_config, "sat", None)]




##############################################################################


def Plugins(**kwargs):
    return [
        PluginDescriptor(
            where=[PluginDescriptor.WHERE_SESSIONSTART],
            fnc=session_start
        ),
        PluginDescriptor(
            name="Sat",
            description="Sat screen",
            where=PluginDescriptor.WHERE_MENU,
            fnc=main
        ),
    ]


Re: DAB+ with RTL-SDR stick #20 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 11 June 2016 - 09:41

I did not test your code and what is the problem but i am using this code to show any picture successfuly:

        def downloadimage(self,PicUrl)
                   from twisted.web.client import downloadPage
		   downloadPage(PicUrl, "/tmp/Icon.jpg").addCallback(self.ShowCover)
			
	def ShowCover(self, picData):
	        if picData is None:
	           return
                if fileExists("/tmp/Icon.jpg"):
		 try: 
			self['imagebox'].instance.setPixmap(gPixmapPtr())
			self.scale = AVSwitch().getFramebufferScale()
			self.picload = ePicLoad()
			size = self['imagebox'].instance.size()
			self.picload.setPara((size.width(), size.height(), self.scale[0], self.scale[1], False, 1, "#FF000000"))
			if self.picload.startDecode("/tmp/Icon.jpg", 0, 0, False) == 0:
				ptr = self.picload.getData()
				if ptr != None:
					self['imagebox'].instance.setPixmap(ptr)
					self['imagebox'].show()
					del self.picload

	
                 except:
                           print "failed to update image



6 user(s) are reading this topic

0 members, 6 guests, 0 anonymous users