Re: [PATCH v15 1/2] leds: core: Introduce LED pattern trigger

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed 2018-10-24 21:17:25, Jacek Anaszewski wrote:
> On 10/24/2018 10:31 AM, Pavel Machek wrote:
> > Hi!
> > 
> >>> +
> >>> +		The gradual dimming format of the software pattern values should be:
> >>> +		"brightness_1 duration_1 brightness_2 duration_2 brightness_3
> >>> +		duration_3 ...". For example:
> >>> +
> >>> +		echo 0 1000 255 2000 > pattern
> >>> +
> >>> +		It will make the LED go gradually from zero-intensity to max (255)
> >>> +		intensity in 1000 milliseconds, then back to zero intensity in 2000
> >>> +		milliseconds:
> >>> +
> >>> +		LED brightness
> >>> +		    ^
> >>> +		255-|       / \            / \            /
> >>> +		    |      /    \         /    \         /
> >>> +		    |     /       \      /       \      /
> >>> +		    |    /          \   /          \   /
> >>> +		  0-|   /             \/             \/
> >>> +		    +---0----1----2----3----4----5----6------------> time (s)
> >>> +
> > 
> > Ok, so I got around to testing this.
> > 
> > echo "0 1000 10 2550 0 1000 0 100" > pattern
> > 
> > makes expected pattern [  .-xXx-.  ].
> > 
> > But when I do
> > 
> > echo "0 1000 10 2550 0 1000" > pattern
> > 
> > I only get expected pattern on the first iteration, then I get
> > [    Xx-.   ].
> 
> This is because the tuples are processed in a loop, without
> discerning between start and end of the sequence.
> 
> So this sequence ends up being squashed, because of the
> comparison:
> 
> if (data->curr->brightness == data->next->brightness) {
> 	//step change od brightness
> 	...
> 	/* Skip the tuple with zero duration */
> 
> Here we actually only assume that this is zero duration since it
> is not checked. Possibly needs fixing.
> 
> 	pattern_trig_update_patterns(data);
> 	/* Select next tuple */
> 	pattern_trig_update_patterns(data);

I came up with this (untested).

diff --git a/drivers/leds/trigger/ledtrig-pattern.c b/drivers/leds/trigger/ledtrig-pattern.c
index ce7acd1..174a298 100644
--- a/drivers/leds/trigger/ledtrig-pattern.c
+++ b/drivers/leds/trigger/ledtrig-pattern.c
@@ -87,9 +87,10 @@ static void pattern_trig_timer_function(struct timer_list *t)
 					   data->curr->brightness);
 			mod_timer(&data->timer,
 				  jiffies + msecs_to_jiffies(data->curr->delta_t));
-
-			/* Skip the tuple with zero duration */
-			pattern_trig_update_patterns(data);
+			if (!data->next->delta_t) {
+				/* Skip the tuple with zero duration */
+				pattern_trig_update_patterns(data);
+			}
 			/* Select next tuple */
 			pattern_trig_update_patterns(data);
 		} else {



> In effect we have:
> 
> 0 -> 10    // dimming
> 10 -> 0    // dimming
> 0 skipped  // step
> 10 -> 0    // dimming
> 0 skipped  // step
> 10 -> 0    // dimming
> ...
> 
> In order to get "rise - fall - rise - fall" sequence you need
> only two tuples:

Well, I wanted "rise - fall - delay - rise - fall - delay"
sequence. Let me test the patch...

Thanks,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux