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:

Thank You for your continued support and contributions!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Changing background color
« previous next »
  • Print
Pages: [1]

Author Topic: Changing background color  (Read 2758 times)

Offline jonashn

  • Member
  • *
  • Posts: 29
Changing background color
« on: February 21, 2007, 12:11:53 PM »
Not sure if this is the right forum..

I've just begun to experiment with plugin-writing, and i've tried to change the background color like this:

Code: [Select]
unsigned int a,b,c=0;
 Â   for(a=0;a<=255;a++)
 Â   {
 Â       for(b=0;b<=255;b++)
 Â       {
 Â           for(c=0;c<=255;c++)
 Â           {
 Â                   rb->lcd_set_background(LCD_RGBPACK(a,b,c));
 Â                   rb->lcd_clear_display();
 Â                   rb->lcd_update();
 Â           }
 Â       }
 Â   
 Â   }    

BUT it doesn't work. What is wrong?
« Last Edit: February 22, 2007, 02:51:58 AM by jonashn »
Logged

Offline Job Van Dam

  • Member
  • *
  • Posts: 167
Re: Changing background color
« Reply #1 on: February 21, 2007, 05:44:44 PM »
I know absolutely no C, I know PHP though. ;D

Shouldn't you clear_display then set_background? It seems like your setting the background then clearing it therefore getting rid of what you just did.

Aren't the loops just going to make the screen white?

You're also going to be updating the screen 255 times, is that normal?

Something tells me I'm in way over my head here...... I'm sorry. :-[
Logged

Offline stripwax

  • Developer
  • Member
  • *
  • Posts: 84
Re: Changing background color
« Reply #2 on: February 21, 2007, 06:04:58 PM »
jonashn - are you running this in the sim or the real target?  if in the sim, it's (possible) that it executes the nested loops so quickly you don't actually see the background colour changing - as prev post says you just end up with white.  You could try doing an  rb->sleep(HZ/10)  to put a 1/10 sec pause in there each time round.

Logged

Offline stripwax

  • Developer
  • Member
  • *
  • Posts: 84
Re: Changing background color
« Reply #3 on: February 21, 2007, 06:11:02 PM »
other alternative of course is that it's so slow you don't see it doing anything  ..  to loop through all colours would take 16million lcd updates and at 50fps that's nearly 4 days   ;D
If you do += 32 instead of ++ you ought to see something happen.
What target by the way?
Logged

Offline jonashn

  • Member
  • *
  • Posts: 29
Re: Changing background color
« Reply #4 on: February 22, 2007, 02:03:41 AM »
Quote from: stripwax on February 21, 2007, 06:11:02 PM
What target by the way?

Ipod Video.

And first i tried without clear_display, but that didn't worked.

And in the wiki it's quite unclear about _when_ it is required to lcd_update().

Job Van Dam> http://www.rockbox.org/twiki/bin/view/Main/HowtoWritePlugins says:  
Quote
rb->lcd_clear_display();
This will clear the display, writing the background colour to the entire screen. Again, no input required, so it can just be called as is.

So when playing with background color like this i surely have to clear_display.

And for example
Code: [Select]
    rb->lcd_set_backdrop(NULL);
 Â   rb->lcd_clear_display();
 Â   unsigned int a,b,c=0;
 Â   for(a=0;a<=255;a+=32)
 Â   {
 Â       for(b=0;b<=255;b+=32)
 Â       {
 Â           for(c=0;c<=255;c+=32)
 Â           {
 Â                   rb->lcd_set_background(LCD_RGBPACK(a,b,c));
 Â                   rb->lcd_clear_display();
 Â                   rb->sleep(HZ/10);
 Â           }
 Â       }
 Â   
 Â   }

Also won't work. It even don't clear the backdrop, altrough my rb->lcd_set_backdrop(NULL);
« Last Edit: February 22, 2007, 02:58:04 AM by jonashn »
Logged

Offline linuxstb

  • Developer
  • Member
  • *
  • Posts: 1163
Re: Changing background color
« Reply #5 on: February 22, 2007, 04:48:36 AM »
Your first attempt looks correct to me, but as others have said, looping through all 14 million colours will take a while...

Can you post the entire source to your plugin?  Maybe something else is causing it to fail.
Logged

Offline jonashn

  • Member
  • *
  • Posts: 29
Re: Changing background color
« Reply #6 on: February 22, 2007, 06:14:56 AM »
It's just the helloworld plugin with the background-changer code added:
Code: [Select]
#include "plugin.h"

PLUGIN_HEADER
static struct plugin_api* rb;


enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
    (void)parameter;
    rb = api;

    rb->lcd_set_backdrop(NULL);
    rb->lcd_clear_display();
    unsigned int a,b,c=0;
    for(a=0;a<=255;a+=32)
    {
        for(b=0;b<=255;b+=32)
        {
            for(c=0;c<=255;c+=32)
            {
                    rb->lcd_set_background(LCD_RGBPACK(a,b,c));
                    rb->lcd_clear_display();
                    rb->sleep(HZ/10);
            }
        }
   
    }

    return PLUGIN_OK;
}
Logged

Offline linuxstb

  • Developer
  • Member
  • *
  • Posts: 1163
Re: Changing background color
« Reply #7 on: February 22, 2007, 06:19:31 AM »
You need a call to rb->lcd_update() in there (e.g. just before the rb->sleep() call).
Logged

Offline jonashn

  • Member
  • *
  • Posts: 29
Re: Changing background color
« Reply #8 on: February 22, 2007, 10:52:40 AM »
Thanks linuxstb! That works.
Logged

Offline stripwax

  • Developer
  • Member
  • *
  • Posts: 84
Re: Changing background color
« Reply #9 on: March 06, 2007, 05:09:19 PM »
Quote from: jonashn on February 22, 2007, 10:52:40 AM
Thanks linuxstb! That works.
Wait .. what?  The original code did have the lcd_update  ..   so how come the original post complained it didn't work?   ???
Logged

Offline jonashn

  • Member
  • *
  • Posts: 29
Re: Changing background color
« Reply #10 on: March 28, 2007, 08:02:00 PM »
No idea:D
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Changing background color
 

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

Page created in 0.084 seconds with 18 queries.