[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181024195529.GA23069@amd>
Date: Wed, 24 Oct 2018 21:55:29 +0200
From: Pavel Machek <pavel@....cz>
To: Jacek Anaszewski <jacek.anaszewski@...il.com>
Cc: Baolin Wang <baolin.wang@...aro.org>, rteysseyre@...il.com,
bjorn.andersson@...aro.org, broonie@...nel.org,
linus.walleij@...aro.org, linux-leds@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v15 1/2] leds: core: Introduce LED pattern trigger
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
Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)
Powered by blists - more mailing lists