Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with script #5

Open
lillekillen opened this issue Apr 19, 2018 · 1 comment
Open

Help with script #5

lillekillen opened this issue Apr 19, 2018 · 1 comment

Comments

@lillekillen
Copy link

Hi my friend!
I wonder if you can help me when I'm a beginner in the python language?
I have a raspberry 3b (Rune) with 2X16 LCD And everything works well with your script.
But I would like to have play / pause / stop shown temperately in the display just like showing shuffle mode .
I've tried but do not get it to work.
Would you like to help me with this?
Best regards Magnus

@RandyCupic
Copy link
Owner

Hello!

Sorry for my late reply. My laptop is broken currently so I was not much active here. Also, a lot time has passed since I last worked with this code, so I had to remember how did it work. Also, I don't have an Raspberry Pi here currently so I'm not able to test, but I will try to give you some advices which could help you.

Most changes you will have to do in display.py. As you can see, each temporary screen has it's own method, eg. show_volume, show_play_mode etc. You can copy one of them and call it, for example, show_state. You can use the same principle for custom characters, if you want to to display an icon. If you need help/advice about creating custom characters, let me know. You can use the same logic for skipping lines or you can just simply skip it, since you're using 2x16 LCD. The most important thing is that you set self.display_data[0] (the text/characters which will be displayed in the first row) and self.display_data[1] (the second row). Also you can reuse the last part of the method for updating the screen. And the most important thing: to get current state (playing, stopped, paused), use self.mpd.getData()['state'] Let me know if you need further details about the method.

The second step is to define the method which will be called when something gets changes. For example, there are volume_changed and play_mode_changed methods. You can create a new one, similar to play_mode_changed and call it, for example state_changed. You will have to use one new variable to indicate whether the "state screen" is currently active or not. Eg. state_screen. Of course, you have to initialize it at the beginning (the __init__ method), similar as for volume_screen - set it to False. Your new state_changed method will simply set this variable to True. We don't need any value, since we will fetch it directly from MPD.

Then, in the main_function you have to check if your newly created state_screen' command is set to Trueand then call theshow_state` method and all other required methods (just copy from other temporary screens).

Now when we have everything ready for the display, we just have to call our new method state_changed from MPD. Now open mpd_client.py. You will find there a method called update_data. At the end of this method, you will see a code which checks what has been updated. It fetches, for example, current player repeat status (whether it's on or off) and compares to the last known state. You can use the same principe: fetch temp = self.client.status()['random'] and compare with self.data['shuffle'] and then return eg changed = 3. Last, in the method mpdMain you check what update_data has returned and if it is == 3, you call self.LCD_client.state_changed().

Best regards,
Randy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants