Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Rockbox Ports are now being developed for various digital audio players!

+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Theming and Appearance Customization
| | |-+  Make icon blink?
« previous next »
  • Print
Pages: [1]

Author Topic: Make icon blink?  (Read 2801 times)

Offline Elaphe

  • Member
  • *
  • Posts: 23
Make icon blink?
« on: July 28, 2014, 05:47:25 PM »
I have this code to display different icons depeding if the music is being played, paused, stoped, etc. Can you please modify so that the play icon (b) blinks when active?

Code: [Select]
# Play Mode
%V(1,0,11,6,3)
%xl(C,playmode.bmp,0,0,6)
%?mp<%xd(Ca)|%xd(Cb)|%xd(Cc)|%xd(Cd)|%xd(Ce)||||>
Logged

Offline [Saint]

  • Rockbox Expert
  • Member
  • *
  • Posts: 1662
  • Hayden Pearce
    • Google+
Re: Make icon blink?
« Reply #1 on: July 28, 2014, 09:08:09 PM »
There's (at least) two ways to do this:

This method requires no additional imagery, but has the (debateable) disadvantage of a lot of needless code duplication and the potential to suffer from drawing issues.
If we don't draw over top of the image we are replacing conditionally, parts of it may remain, causing nasty visual artefacts.
Code: [Select]
# Play Mode
%V(1,0,11,6,3)
%xl(C,playmode.bmp,0,0,6)
%t(1.0)%?mp<%xd(Ca)|%xd(Cb)|%xd(Cc)|%xd(Cd)|%xd(Ce)||||>;%t(1.0)%?mp<%xd(Ca)||%xd(Cc)|%xd(Cd)|%xd(Ce)||||>


The following method requires an additional bitmap to be added to the "C" bitmap strip. This bitmap image should be entirely blank. We'll append it to the very end of the strip, this keeps the addition as minimally invasive as possible. In my example it will be using the sub-image identifier "n".

Remember that this will also require you to adjust the preload (%xl) declaration for the play state icon bitmap strip ("C") to make it aware that it is now handling an additional sub-image

The syntax for bitmap preloads is as follows:
Code: [Select]
%xl(IDENTIFIER,bitmap_asset_file_name.bmp,x-pos,x-pos,N)
Where "N" is the number of subimages contained in the bitmap strip.

Example follows:
Code: [Select]
# Play Mode
%V(1,0,11,6,3)
%xl(C,playmode.bmp,0,0,6)
%?mp<%xd(Ca)|%xd(Cb)|%t(1.0)%xd(Cc);%t(1.0)%xd(Cn)|%xd(Cd)|%xd(Ce)||||>


I would also like to point out that this theme is using the antiquated, virtually impossible to read, sub-image and identifier syntax.
Rockbox has been capable of using descriptive identifiers for a rather long period of time now, but I understand that this is rarely used as most themes seem to be copy-and-paste variants of someone else's (ancient) work.

The current syntax is as follows:
Code: [Select]
# Play Mode
%V(1,0,11,6,3)
%xl(PLAY_MODE,playmode.bmp,0,0,6)
%?mp<%xd(PLAY_MODE,1)|%xd(PLAY_MODE,2)|%t(1.0)%xd(PLAY_MODE,3);%t(1.0)%xd(PLAY_MODE,N)|%xd(PLAY_MODE,4)|%xd(PLAY_MODE,5)||||>
Where "N" is the value of the appended bitmap subimage (your example leads me to believe this value would be 7, as the declaration states playmode.bmp has 6 subimages, yet I only see 5 images being called...).

This can potentially make for longer code, but it makes the code a lot easier to read.

It is somewhat important to explain that in both examples, we are using "alternating sublines" to govern the blinking of our state icon.

This is achieved by first specifying the %t tag, and then dividing the alternating sections with a semicolon. The timeout tag (%t) accepts an optional parameter in tenths of a second to govern the length of time a section is displayed. Alternating sublines will loop back to the first segment after all subline segments have been displayed.

Each alternating subline section can have a unique timeout. If no timeout parameter is given, it will default to 1 second timeout:

Code: [Select]
%t(2)displayed for 2 seconds;%t(0.1)displayed for one tenth of a second;(%t)displayed for one second - no timeout parameter given



[Saint]
« Last Edit: July 29, 2014, 05:31:18 PM by [Saint] »
Logged
Using PMs to annoy devs about bugs/patches is not a good way to have the issue looked at.

Offline Elaphe

  • Member
  • *
  • Posts: 23
Re: Make icon blink?
« Reply #2 on: July 29, 2014, 08:22:44 AM »
Thanks a lot. It's working! However, I have a problem.

With this code:

Code: [Select]
# Play Mode
%V(1,0,11,6,3)
%xl(PLAY_MODE,playmode.bmp,0,0,7)
%?mp<%xd(PLAY_MODE,1)|%xd(PLAY_MODE,2);%t(1.0)%xd(PLAY_MODE,7)|%t(1.0)%xd(PLAY_MODE,3)|%xd(PLAY_MODE,4)|%xd(PLAY_MODE,5)||||>

I have the play icon blink (1 second on, 1 second off).

However, if I try this, for 0.2 seconds on, and 0.2 seconds off, only the latter works:

Code: [Select]
# Play Mode
%V(1,0,11,6,3)
%xl(PLAY_MODE,playmode.bmp,0,0,7)
%?mp<%xd(PLAY_MODE,1)|%xd(PLAY_MODE,2);%t(0.2)%xd(PLAY_MODE,7)|%t(0.2)%xd(PLAY_MODE,3)|%xd(PLAY_MODE,4)|%xd(PLAY_MODE,5)||||>

So, the icon stays visible for 1 seconds, and invisible for 0.2 seconds.

Any mistake in my code?

This is the image I'm working with:


Logged

Offline [Saint]

  • Rockbox Expert
  • Member
  • *
  • Posts: 1662
  • Hayden Pearce
    • Google+
Re: Make icon blink?
« Reply #3 on: July 29, 2014, 05:42:23 PM »
Assuming you only want the play state icon to blink, at a rate of .2s, you would want:
Code: [Select]
%?mp<%xd(PLAY_MODE,1)|%t(0.2)%xd(PLAY_MODE,2);%t(0.2(PLAY_MODE,7)|%xd(PLAY_MODE,3)|%xd(PLAY_MODE,4)|%xd(PLAY_MODE,5)||||>


[Saint]
Logged
Using PMs to annoy devs about bugs/patches is not a good way to have the issue looked at.

Offline Elaphe

  • Member
  • *
  • Posts: 23
Re: Make icon blink?
« Reply #4 on: July 29, 2014, 06:31:27 PM »
Sorry, it's not working here. I get the default ugly white status bar in the simulator.
Logged

Offline Elaphe

  • Member
  • *
  • Posts: 23
Re: Make icon blink?
« Reply #5 on: July 31, 2014, 04:39:32 AM »
Finally! After many tests, this works. I don't know if all the code is right tough.

Code: [Select]
%?mp<%xd(PLAY_MODE,1)|;%t(0.3)%xd(PLAY_MODE,2);%t(0.3)|%xd(PLAY_MODE,3)|%xd(PLAY_MODE,4)|%xd(PLAY_MODE,5)||||>
Logged

Offline [Saint]

  • Rockbox Expert
  • Member
  • *
  • Posts: 1662
  • Hayden Pearce
    • Google+
Re: Make icon blink?
« Reply #6 on: July 31, 2014, 01:53:15 PM »
The syntax I gave is adequate.

I feel like things might go a lot smoother for you if you took notice of the information given in the manual and/or CustomWPS wiki page.

Cutting and pasting snippets other people write for you, without understanding what changed, or why, isn't going to be terribly productive in the long run.

It might not seem like a huge difference, but most people are more receptive to:

"I am trying to do <blah>. I have read your documentation, but I do not understand <blah>. I have tried <blah>, <blah>, and <blah>."

vs.

"can someone do <blah> for me."

I don't mean to offend.


[Saint]
Logged
Using PMs to annoy devs about bugs/patches is not a good way to have the issue looked at.

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Theming and Appearance Customization
| | |-+  Make icon blink?
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.068 seconds with 15 queries.