Rockbox Technical Forums

Rockbox Development => Feature Ideas => Topic started by: rbhawaii on November 21, 2012, 06:29:38 PM

Title: day / night mode by hour
Post by: rbhawaii on November 21, 2012, 06:29:38 PM
hello
i made two config files one called DAY and one called NIGHT
one is super bright with white bold font, and one is super dim with thin dark yellow font, this is great for the ipod video in the car

is it possible to have rb activate one at 7pm and activate the other at 6am?

if not is this a feature the developers are interested in looking at?

thanks!
Title: Re: day / night mode by hour
Post by: KiwiCam on December 03, 2012, 10:00:32 PM
Well. That's one way of getting around the day/night issue. It should be possible to set the theme to change all the colours after and before a certain time, but that's a lot work. Especially if you frequently change themes.

http://forums.rockbox.org/index.php/topic,35804.0.html
Title: Re: day / night mode by hour
Post by: rbhawaii on December 04, 2012, 05:59:55 AM
i read the link you posted above where the person requested a auto contrast change, and i think that would be hard considering that my ipod and rb have no contrast settings (only led brightness settings) so i can imagine that a contrast feature would be a lot to code... BUT my feature request seems to be an easier deal. simply have rockbox load a (user created) config file at one time and another (user created) config file at another time. inside the config file are the screen brightness settings the font and colors and anything else you want.

 i have already been doing this manually for about 5 years the real minus of doing it manually is this... when you turn on rb the next day and its still set to super dark "night mode" from the night before its near impossible to see anything on the screen with the sun light out side, so my feature request would solve that problem automatically, it would be so great :)
Title: Re: day / night mode by hour
Post by: KiwiCam on December 04, 2012, 01:05:03 PM
That person was me. What I'm referring to in that thread is Menu/Settings/General Settings/Display/LCD Settings/BRIGHTNESS.

Just replace in your mind the word contrast with brightness (which is actually mentioned i that suggestion). Either way, if there's a way of changing the BRIGHTNESS as a quick toggle, or a preset time period ie evening to morning/Morning to evening, than that's what I'm after.

I too like it bright during the day, but during the night (say I wake up and decide to switch it on) it's way too bright. I have to hold my Clip right up to my face to read the screen (as I'm not wearing my glasses in bed) and a Day/Night toggle or timed toggle would be a great feature.
Title: Re: day / night mode by hour
Post by: whiskers75 on December 31, 2012, 11:39:17 AM
I'll see if I can add this into whiskers75/rockbox.  ;)
Please note that this is NOT stable in any way and may cause your player to explode. Just RoLo the code instead of installing it to be safe!
Updates:
1 - Found the brightness toggle - in apps/settings.c - backlight_set_brightness();
2 - Need a way to access the time, and update accordingly. Devs? :)
3 - If I'm right, I should use 'struct tm *time' 'get_time()' from timefuncs.h.
4 - Commit 3abee1f3f948266f38e7004f240e64060323039a in branch day/night: I've added a little test to see if I can get the hour and minute. If someone could test this, I would be grateful.

https://github.com/whiskers75/rockbox/commit/3abee1f3f948266f38e7004f240e64060323039a

5 - Commit c74f15db9775d8110cc429c7377b916b7d6c2a69 in branch day/night: I've added in THEME_TIME. Could some dev help here? :)

https://github.com/whiskers75/rockbox/commit/c74f15db9775d8110cc429c7377b916b7d6c2a69

6 - Prototype 1 is coming on! (Sorry for my sucky C code, I'm new to C)

7 - Commit 0b688a3ba0fba9177757fc7e8eb316c424d7b836 in branch day/night: Day/night should be working now! Just configure a few global_settings - .dnenabled, .nighttime, .daybright and .nightbright!

https://github.com/whiskers75/rockbox/commit/0b688a3ba0fba9177757fc7e8eb316c424d7b836
Title: Re: day / night mode by hour
Post by: whiskers75 on December 31, 2012, 12:18:39 PM
If we could get a developer or someone with more knowledge than me in here, that would be good.
Title: Re: day / night mode by hour
Post by: rbhawaii on December 31, 2012, 04:45:34 PM
i dont know if this helps or matters
the day and night config files change this info

font bold/regular
font color
led brightness

i found only those 3 are needed for the change every 12 hours
 
Title: Re: day / night mode by hour
Post by: whiskers75 on January 01, 2013, 03:20:36 AM
i dont know if this helps or matters
the day and night config files change this info

font bolt/regular
font color
led brightness

i found only those 3 are needed for the change every 12 hours
Yes, I am trying to implement LED brightness. Currently, 'night-time' is classified as 22:00 -> 00:00. I'll try to implement a config option for it.
Title: Re: day / night mode by hour
Post by: whiskers75 on January 01, 2013, 05:53:54 AM
What brightness value would you like for day and night?
Title: Re: day / night mode by hour
Post by: JdGordon on January 01, 2013, 09:16:30 PM
I think you are going about this completely wrongly.
Why don't you write a plugin which stays active (like battery_bench) which checks the time against some *configurable* value and runs a day.cfg config if it changes to day and a night.cfg config when it changes to night? then  questions about brightness is up to the user and not randomly/arbitrarily chosen by "someone on the internet"?

edit: If its done in a plugin there is a far bigger chance of it being accepted into mainline
Title: Re: day / night mode by hour
Post by: whiskers75 on January 02, 2013, 03:21:55 AM
Good idea, I'll try that.
EDIT: I think I'd much rather have it in main.c as then it could be configured easier.
Title: Re: day / night mode by hour
Post by: [Saint] on January 02, 2013, 03:00:21 PM
EDIT: I think I'd much rather have it in main.c as then it could be configured easier.

I'm curious what makes you think this.


[Saint]
Title: Re: day / night mode by hour
Post by: rbhawaii on January 02, 2013, 05:21:51 PM
these are my day and night night config settings on the ipod 240gb video

day...
brightness: 22
foreground color: FFFFFF
background color: 000000
line selector start color: FFFFFF    
line selector end color: FFFFFF          
line selector text color: 000000
font: /.rockbox/fonts/24-neep-alt-12x24-bold-L1.fnt



night...
brightness: 2
foreground color: 948A31
background color: 000000
line selector start color: 000000
line selector end color: 000000
line selector text color: FFFFFF
font: /.rockbox/fonts/24-neep-alt-12x24-L1.fnt

Title: Re: day / night mode by hour
Post by: whiskers75 on January 03, 2013, 05:32:28 AM
When I get my code working, you should be able to set 'daybright: 22', 'nightbright: 2', 'dnenabled: 1' to get brightness working.
[Saint], if I were to do it in a plugin, how would I access global_settings?
Current build status:(https://travis-ci.org/whiskers75/rockbox.png?branch=day/night)
Title: Re: day / night mode by hour
Post by: JdGordon on January 03, 2013, 05:50:09 AM
rb->global_settings
Title: Re: day / night mode by hour
Post by: whiskers75 on January 03, 2013, 07:31:03 AM
rb->global_settings
Still think it's easier in main.c. I might want to start up chopper.rock while running day/night - with plugins I can't do that.
Title: Re: day / night mode by hour
Post by: JdGordon on January 03, 2013, 07:32:38 AM
suit yourself, but it is very unlikely to be accepted (if you care) unless its a plugin.
Title: Re: day / night mode by hour
Post by: whiskers75 on January 03, 2013, 08:59:41 AM
suit yourself, but it is very unlikely to be accepted (if you care) unless its a plugin.
I don't.  :)
Title: Re: day / night mode by hour
Post by: AlexP on January 03, 2013, 01:43:54 PM
Why not?  Why not help other people out?
Title: Re: day / night mode by hour
Post by: whiskers75 on January 04, 2013, 04:55:54 AM
OK, I'm doing it in a plugin. My knowledge of Lua is better than my knowledge of C.
Title: Re: day / night mode by hour
Post by: gevaerts on January 04, 2013, 01:45:56 PM
Can you do TSR plugins in lua?
Title: Re: day / night mode by hour
Post by: whiskers75 on January 06, 2013, 04:57:21 AM
Turns out you can't.
Title: Re: day / night mode by hour
Post by: whiskers75 on January 07, 2013, 10:06:45 AM
It's done!
Set dnenabled = 1, night = (24-hour clock hour at which to change brightness eg 22 for 10pm) and nightbright to a brightness value (eg 2) in the config file (? I think that should load such things into global_settings) to enable day/night support. Get the source from whiskers75/rockbox branch day/night.
Open pull request: https://github.com/whiskers75/rockbox/pull/2 - will go through if it works.

PLEASE NOTE THAT THIS IS HIGHLY EXPERIMENTAL AND MAY CAUSE YOUR PLAYER TO EXPLODE. MY ADVICE IS TO RoLo THE UPDATED BINARY FROM YOUR CURRENT VERSION.
Title: Re: day / night mode by hour
Post by: AlexP on January 07, 2013, 02:29:09 PM
We don't use github, so that pull request is pointless.  If you want it considered, upload it to our gerrit.
Title: Re: day / night mode by hour
Post by: bluebrother on January 07, 2013, 04:27:19 PM
PLEASE NOTE THAT THIS IS HIGHLY EXPERIMENTAL AND MAY CAUSE YOUR PLAYER TO EXPLODE. MY ADVICE IS TO RoLo THE UPDATED BINARY FROM YOUR CURRENT VERSION.

Or it might not work at all. I've had a short look at what's in the pull request (not that this is going to get pulled -- as AlexP already said we're not using github). Have you actually tried it? At least the code I've seen will never work. You've mixed up code with preprocessor statements in a way that simply cannot work.
Title: Re: day / night mode by hour
Post by: rbhawaii on January 07, 2013, 11:55:30 PM
i just wanted to thank you all for your time and effort (so far) to making this happen.

if i can help further with anything please let me know how!

i hope the day night settings i provided earlier in the thread helped in some way.

happy new year!

Title: Re: day / night mode by hour
Post by: whiskers75 on January 08, 2013, 02:43:45 AM
(https://travis-ci.org/whiskers75/rockbox.png?branch=day/night)    It builds fine! The pull is from my repo branch day/ night to master, not yours.
rbhawaii: No problem.
Title: Re: day / night mode by hour
Post by: whiskers75 on January 08, 2013, 03:06:02 AM
PLEASE NOTE THAT THIS IS HIGHLY EXPERIMENTAL AND MAY CAUSE YOUR PLAYER TO EXPLODE. MY ADVICE IS TO RoLo THE UPDATED BINARY FROM YOUR CURRENT VERSION.

Or it might not work at all. I've had a short look at what's in the pull request (not that this is going to get pulled -- as AlexP already said we're not using github). Have you actually tried it? At least the code I've seen will never work. You've mixed up code with preprocessor statements in a way that simply cannot work.
Wouldn't that throw an error in the build?
I don't have a player with brightness so I can't test this.
Title: Re: day / night mode by hour
Post by: gevaerts on January 08, 2013, 06:00:39 AM
Wouldn't that throw an error in the build?

You managed to accidentally hit on something without syntax errors.

I'd recommend learning some C first.
Title: Re: day / night mode by hour
Post by: whiskers75 on January 08, 2013, 06:17:40 AM
Moved code into daynight.c to avoid conflict. Now I just need that code to be run every hour.
Title: Re: day / night mode by hour
Post by: bluebrother on January 08, 2013, 07:27:35 AM
Moved code into daynight.c to avoid conflict. Now I just need that code to be run every hour.

Now you need that file to get actually compiled. By simply putting code in a new file you don't get it magically compiled. Furthermore, you need to code to be actually working. And last, simply running it every hour also isn't sufficient -- how is it supposed to behave if you turn off the player during day, then turn it on again at night -- if you're not turning it on at a new hour you'll need to wait until the next hour to change to night mode? That's not how people would expect this to work ...

And code building doesn't tell anything about it working :)
Title: Re: day / night mode by hour
Post by: torne on January 08, 2013, 07:27:55 AM
The problem isn't a "conflict", it's that you don't understand the difference between "if" and "#if" in C. #if is a preprocessor directive that is resolved during compilation. Your code does nothing at all as a result.

We're not trying to deter you from contributing, but it appears that you don't actually know the basics of the C language, and are just copying things from other places. This is unlikely to result in anything that actually works in most cases.
Title: Re: day / night mode by hour
Post by: rbhawaii on January 08, 2013, 07:45:20 AM
hi torne and everyone eles thanks for helping out , would you be able or willing to help bring this code to life, the way you think is best?  I almost get the feeling that whiskers75 is trying hard but is not getting the proper motivation.   i mean everyone wants to see this feature in rock box right? so why not help him out a little more then just telling him how hes doing it wrong. this is a very exciting feature for myself and many many rb users im sure, so lets all help each other as best as we can :)   
i know nothing anyone has said so far was to discourage anything or anyone.  i just get the feeling we can be helping each other "create  something"  and not just keep pointing out what someone did wrong.
i hope my message is not misread as mean or negative since it is not meant to come across that way.
kind regards
Title: Re: day / night mode by hour
Post by: torne on January 08, 2013, 08:04:06 AM
Actually, very few people have expressed a desire to see this feature in Rockbox. :)

Programming is a complicated skill and parts of it have to be re-learnt for every language you use. There's no way to just tell you what the right thing to do here is without just writing the code for you, and nobody will learn anything significant from that. How hard someone is trying is nothing to do with whether they have the required skills to succeed. A book on C programming would be far more helpful than one of us explaining how to accomplish this particular task.
Title: Re: day / night mode by hour
Post by: rbhawaii on January 08, 2013, 08:24:53 AM
Fair enough...
I cant say anything on this topic since i know nothing of it. So i take your word for it.

Im a computer technician and I have always come from a view point where if someone is trying to fix/build something and they need help then help them , and i always do in the most efficient manor and they are always grateful and the results are great. But maybe this does not apply to coding , oh well.

As far as the feature goes... it is a feature for people who drive with rockbox.  The auto day night feature is very popular on almost every gps i have ever seen.   i drive with rock box so much that i removed my car stereo and put 2 half din equalizers in its place.  i dont need the radio nor cds nor tiny usb drives. rockbox is the ultimate mp3 player for me (except for android where GMMP is the best ever so far-sorry but honest)

and not many people requesting it... I dont know if there are statistics out there but how many people who install and use rb are on these threads? my guess is 1%? I still think if they had the feature many would love it and be grateful for it :)
Title: Re: day / night mode by hour
Post by: gevaerts on January 08, 2013, 08:49:21 AM
Im a computer technician and I have always come from a view point where if someone is trying to fix/build something and they need help then help them , and i always do in the most efficient manor and they are always grateful and the results are great. But maybe this does not apply to coding , oh well.

It does apply, and we're willing to help, but this code is not bad C, less than ideal C, or not in the right style. It's not C *at all*. There are much better places than these forums to learn about basic C programming.
Title: Re: day / night mode by hour
Post by: whiskers75 on January 08, 2013, 01:15:20 PM
No, it's my fault, I don't know C.  ;)
What file do I need to edit to get it compiled, and how can I get it to run at boot and at every hour? Sorry for the trouble, I'm learning. This is my first project in C, and I hope to go on and do some more advanced stuff.
By the way, I bet any Rockbox developer on the forums could do this in a day. As I said, I'm a first-timer to C. (JavaScript FTW!)
Title: Re: day / night mode by hour
Post by: AlexP on January 08, 2013, 01:31:18 PM
I think before you worry about what file to edit, you learn enough to know how you are going to edit it.
Title: Re: day / night mode by hour
Post by: whiskers75 on January 08, 2013, 01:33:47 PM
What file is it? C? Shell script?
I know bash.
Title: Re: day / night mode by hour
Post by: AlexP on January 08, 2013, 01:38:19 PM
Rockbox is written in C, with some assembler.
Title: Re: day / night mode by hour
Post by: whiskers75 on January 08, 2013, 01:44:55 PM
OK, let's try '[day/night 8190fe2] Alright, is this C?'.
I call update_dn(); in main.c, should I, or is there a better place to put that?
As always, build thingy:  (https://travis-ci.org/whiskers75/rockbox.png?branch=day/night) (may be inaccurate, I need 32-bit arm-elf-eabi packages and building them is buggy)
(As you said, I'm stabbing about blindly in the dark. I'll read up on C)
Title: Re: day / night mode by hour
Post by: bluebrother on January 08, 2013, 04:29:38 PM
OK, let's try '[day/night 8190fe2] Alright, is this C?'.

No. That's something really weird.

Quote
I need 32-bit arm-elf-eabi packages and building them is buggy)

Huh? Building the toolchain using rockboxdev.sh is working fine since long. How come you consider it "buggy"?
Title: Re: day / night mode by hour
Post by: JdGordon on January 09, 2013, 12:47:19 AM
As I said, I'm a first-timer to C. (JavaScript FTW!)

So first step is to go learn c. Your javascript knowledge will not translate 100% to c. We'll be far more able to help once you actually know how to get things useful working in C. As it is now, any help from us would just be implementing it (which I think it clear we don't really want)
Title: Re: day / night mode by hour
Post by: whiskers75 on January 09, 2013, 02:11:31 AM
OK, let's try '[day/night 8190fe2] Alright, is this C?'.

No. That's something really weird.

Quote
I need 32-bit arm-elf-eabi packages and building them is buggy)

Huh? Building the toolchain using rockboxdev.sh is working fine since long. How come you consider it "buggy"?
Since the build system I use can't run rockboxdev.sh as it has a 10 minute timeout per command.
Title: Re: day / night mode by hour
Post by: [Saint] on January 09, 2013, 02:16:22 AM
If your build system cannot run rockboxdev.sh, you're doing it wrong. Fact.

I responded in another thread to your claims that rockboxdev.sh is buggy/broken/otherwise. Using other tools that break this doesn't make it broken in itself. It simply means you shouldn't be using those tools.



[Saint]
Title: Re: day / night mode by hour
Post by: bluebrother on January 09, 2013, 03:40:03 PM
Since the build system I use can't run rockboxdev.sh as it has a 10 minute timeout per command.

That doesn't make rockboxdev.sh "buggy". "buggy" is something completely different. If the system you're trying to run the script on terminates it after a given amount of time it's a limitation of the system you're running it on. It is in no way a problem of rockboxdev.sh. Building the toolchain takes a while. A process requiring some time isn't "buggy" but, depending on what the process does, totally normal and expected behaviour.

Please stop stating such wrong facts.
Title: Re: day / night mode by hour
Post by: torne on January 10, 2013, 06:57:12 AM
Yes; the problem is that the CI system expects build dependencies to either be available in binary form to be installed, or to be able to download and build them in a few seconds. It's a hosted system run by a third party who doesn't want their resources to be wasted compiling gcc from scratch over and over again. :)

If you want to use this system then it's your problem to work out how to create suitable packages for it to use; there is nothing wrong with rockboxdev.sh - it's not intended for this, is all.
Title: Re: day / night mode by hour
Post by: rbhawaii on January 10, 2013, 07:44:19 AM
would any developers be willing to code this?

it runs a cgf file at a predefined hour thats all

instead of giving him so much beef for trying cant one of you just write it?

or tell him exactly where to look so that he can get it done himself much-faster.

do you guys feel all the advice you have given him so far is helping him get this done? i dont
im sorry


Title: Re: day / night mode by hour
Post by: wodz on January 10, 2013, 10:22:40 AM
Look, he decided to use external service we do not support - it is his choice but at the same time he screams that our tool (rockboxdev.sh) designed to cope with our way of building is broken. If he wants to use our tool with external service it is his duty to glue it all together.
Title: Re: day / night mode by hour
Post by: [Saint] on January 10, 2013, 11:37:54 AM
do you guys feel all the advice you have given him so far is helping him get this done?


Yes. I do.

But, as you've seen, giving advice has absolutely no bearing on whether or not that advice is followed or not. If a decision is made to ignore that advice, what would you have us do? We cannot force anyone to do our will.

The solution isn't to do it for him.


[Saint]
Title: Re: day / night mode by hour
Post by: torne on January 10, 2013, 11:40:47 AM
instead of giving him so much beef for trying cant one of you just write it?
The way this project (like many open source projects) works is that people write things they want/care about/are interested in. If someone else wanted to do it they'd've done it already, so it looks like the answer is no, nobody else wants to.

Quote
or tell him exactly where to look so that he can get it done himself much-faster.
Telling someone exactly where to look in this case is analogous to explaining the library filing system to someone who can't read the language the books are written in.
Title: Re: day / night mode by hour
Post by: Reece on January 10, 2013, 03:11:54 PM
      The beauty of RockBox is the customization. You don't have to be restricted by what Rockbox currently offers... You can modify it to your liking, and if its lacking something you want, then you can add it! :). And if that modification is good enough, it can even be added to the official build.
But for those of you who don't know anything about coding, (kinda like me) that can be a draw back. But there is always time to learn, and there is no better time then now.
I think the best place to start is theming. Its a great way to get to know your way around the ".rockbox" files. I have learned ALLOT from looking at other peoples themes. The best way to learn is to fallow the leader.
Title: Re: day / night mode by hour
Post by: [Saint] on January 10, 2013, 11:48:00 PM
For what it's worth, I'm not entirely sure that learning our proprietary skin engine language would be beneficial in any way to learning C or ASM.
It certainly couldn't hurt, but I don't think it would help. There are no similarities in these languages.


[Saint]
Title: Re: day / night mode by hour
Post by: AlexP on January 11, 2013, 01:58:15 PM
I'll go further, it'll be of no use at all :)
Title: Re: day / night mode by hour
Post by: whiskers75 on January 12, 2013, 02:48:27 AM
You're right, I don't know C, and shouldn't be doing this. Therefore, I won't.
Title: Re: day / night mode by hour
Post by: [Saint] on January 12, 2013, 04:14:42 AM
I don't know C, and shouldn't be doing this. Therefore, I won't.

That seems rather defeatist. One would think the answer would be to learn C.

I hope you haven't come to the conclusion that anyone is trying to drive you away from the project or discourage you from contributing.

To put it as simply as I can, one can either give a man a fish, or teach a man to fish. If you are going to teach a man to fish, one should first make sure that they are using a fishing rod, instead of a shovel.


[Saint]
Title: Re: day / night mode by hour
Post by: whiskers75 on January 13, 2013, 02:56:48 AM
I don't know C, and shouldn't be doing this. Therefore, I won't.

That seems rather defeatist. One would think the answer would be to learn C.

I hope you haven't come to the conclusion that anyone is trying to drive you away from the project or discourage you from contributing.

To put it as simply as I can, one can either give a man a fish, or teach a man to fish. If you are going to teach a man to fish, one should first make sure that they are using a fishing rod, instead of a shovel.


[Saint]

What I'm saying is, I shouldn't be doing C while I'm in the middle of JS stuff.
Title: Re: day / night mode by hour
Post by: whiskers75 on February 01, 2013, 01:53:01 PM
This is being worked on.
After reading up on C, I know more about how to do it.
(FYI, the CI system is now working using rockboxdev.sh)

Create a function:
Code: [Select]
void update_dn() {
}
Save it in daynight.h
Require it in main.c:
Code: [Select]
#include "daynight.h"Call the function (every second/minute/hour):
Code: [Select]
update_dn()
Profit!
Title: Re: day / night mode by hour
Post by: bluebrother on February 01, 2013, 03:46:59 PM
Save it in daynight.h

You shouldn't put functions in header files. There are a few cases where this is necessary but this isn't one of them.

Quote
Profit!

That function is empty, i.e. does nothing. How is that going to profit?
Title: Re: day / night mode by hour
Post by: whiskers75 on February 02, 2013, 05:35:49 AM
I left out the bits inside the function.
OK, fine, I'll put it in daynight.c.
Update: Here: Day/night prototype 1, commit 26a4a3b55e. Include daynight.c and run daynight() when you want to update day/night status. Build Status (https://travis-ci.org/whiskers75/rockbox/jobs/4533154)

(https://travis-ci.org/whiskers75/rockbox.png?branch=day/night)