On 26/08/14 02:56, Don Y wrote:> On 8/25/2014 3:46 PM, ajellis wrote: >>> On 8/25/2014 10:52 AM, ajellis wrote: >>>> I need to plot a pie on an LCD screen as an indicator of time remaing >> for a >>>> process. >>>> >>>> I have searched around alot on this issue, and have found the midpoint >>>> algorithm which I can use to plot a complete circle, both filled and >>>> outlined. But I can't find anything on drawing segments. >>>> >>>> Could someone point to me to information on how to achieve this please. >>> >>> What are you looking for: an algorithm to plot a pie slice? or, >>> an algorithm to *fill* a plotted pie slice? >>> >>> Do you need an algorithm that works given *any* initial conditions >>> (initial orientation of the slice, initial "non-zero" percentage >>> complete, etc.)? >>> >>> Does it have to be able to advance in arbitrary increments (always >>> monotonic?)? >>> >>> Does it need to be reoriented after each update (vs. just "building" >>> on what was complete as of the "previous iteration")? >>> >>> Computer graphics algorithms are notoriously clever -- typically by >>> *not* trying to be "general" (e.g., why redraw the 12% portion of >>> the circle from scratch if you are now at 13%?). > >> I am using an AT32UC3B0512 microcontroller. >> >> I need the algorithm to advance monotonically ie start with a vertical >> line >> from the centre of the circle to the outside edge, then to be able to >> grow >> in steps of 1° until the circle is complete. > > Why 1 degree? Why not 1%? How large is the circle (a very large > diameter requires more finesse than a smaller one)? How quickly > (in calendar time) is the whole process going to happen (i.e., if > the whole thing takes 3 seconds, then why other with 1 degree > increments that the user will never see in the time it takes for > the next update to come along) > > Ask yourself what you know about circles that can make your job > easier! And, how your knowledge of what you have ALREADY DRAWN > can be exploited to draw what needs to be ADDED ;-)Those are questions that occurred to me too. One degree sounds like far too high resolution for a progress indicator. I would be thinking about perhaps 12 steps in total - anything more detailed would be better shown in figures (percentage complete, time remaining, etc., if you are talking about a time of at least several minutes). And with 12 steps, the easiest method is to generate the images on your PC and store them on the micro - just copy them with a bit blit.
Drawing pieslice (segement) on and LCD
Started by ●August 25, 2014
Reply by ●August 26, 20142014-08-26
Reply by ●August 26, 20142014-08-26
Hi David, On 8/26/2014 12:25 AM, David Brown wrote:> On 26/08/14 02:56, Don Y wrote: >> On 8/25/2014 3:46 PM, ajellis wrote: >>>> On 8/25/2014 10:52 AM, ajellis wrote: >>>>> I need to plot a pie on an LCD screen as an indicator of time remaing >>>>> for a process.>>>> What are you looking for: an algorithm to plot a pie slice? or, >>>> an algorithm to *fill* a plotted pie slice? >>>> >>>> Do you need an algorithm that works given *any* initial conditions >>>> (initial orientation of the slice, initial "non-zero" percentage >>>> complete, etc.)? >>>> >>>> Does it have to be able to advance in arbitrary increments (always >>>> monotonic?)? >>>> >>>> Does it need to be reoriented after each update (vs. just "building" >>>> on what was complete as of the "previous iteration")? >>>> >>>> Computer graphics algorithms are notoriously clever -- typically by >>>> *not* trying to be "general" (e.g., why redraw the 12% portion of >>>> the circle from scratch if you are now at 13%?). >> >>> I am using an AT32UC3B0512 microcontroller. >>> >>> I need the algorithm to advance monotonically ie start with a vertical >>> line from the centre of the circle to the outside edge, then to be able >>> to grow in steps of 1° until the circle is complete. >> >> Why 1 degree? Why not 1%? How large is the circle (a very large >> diameter requires more finesse than a smaller one)? How quickly >> (in calendar time) is the whole process going to happen (i.e., if >> the whole thing takes 3 seconds, then why other with 1 degree"other" s.b. "bother" :<>> increments that the user will never see in the time it takes for >> the next update to come along) >> >> Ask yourself what you know about circles that can make your job >> easier! And, how your knowledge of what you have ALREADY DRAWN >> can be exploited to draw what needs to be ADDED ;-) > > Those are questions that occurred to me too. One degree sounds like far > too high resolution for a progress indicator. I would be thinking about > perhaps 12 steps in total - anything more detailed would be better shown > in figures (percentage complete, time remaining, etc., if you are > talking about a time of at least several minutes).If concerned over the display being "static" for long periods, then add some other (mindless) "activity indicator" so a user knows that the device is "still working on the problem" -- even though it hasn't updated the "progress indicator". (i.e., 1 degree *or* 1% wouldn't, by itself, be sufficient if it was a 5 hour process!)> And with 12 steps, the easiest method is to generate the images on your > PC and store them on the micro - just copy them with a bit blit.Or, play games with reflections, etc. Without intending to offend the OP, it sounds like a "young" engineer specifying a "1023.276 ohm" resistor... [Or, a homework problem]
Reply by ●August 26, 20142014-08-26
On 26/08/14 09:32, Don Y wrote:> Hi David, ><snip>>> Those are questions that occurred to me too. One degree sounds like far >> too high resolution for a progress indicator. I would be thinking about >> perhaps 12 steps in total - anything more detailed would be better shown >> in figures (percentage complete, time remaining, etc., if you are >> talking about a time of at least several minutes). > > If concerned over the display being "static" for long periods, then > add some other (mindless) "activity indicator" so a user knows that > the device is "still working on the problem" -- even though it > hasn't updated the "progress indicator". >All electronics needs a blinking LED so that you know it is working!> (i.e., 1 degree *or* 1% wouldn't, by itself, be sufficient if it > was a 5 hour process!)Absolutely. For long periods, a time counter is usually the best choice - counting down if you know how long the task will take, or counting up if you don't know.> >> And with 12 steps, the easiest method is to generate the images on your >> PC and store them on the micro - just copy them with a bit blit. > > Or, play games with reflections, etc.Yes - that makes it more fun too.> > Without intending to offend the OP, it sounds like a "young" > engineer specifying a "1023.276 ohm" resistor... > > [Or, a homework problem]Inexperienced engineer was my impression too. It sounds like someone who has a fixed idea of a solution (or been given a fixed idea of a solution), when they should take a step back and try and figure out the /real/ question.
Reply by ●August 26, 20142014-08-26
Hi David, On 8/26/2014 1:22 AM, David Brown wrote:> On 26/08/14 09:32, Don Y wrote:>>> Those are questions that occurred to me too. One degree sounds like far >>> too high resolution for a progress indicator. I would be thinking about >>> perhaps 12 steps in total - anything more detailed would be better shown >>> in figures (percentage complete, time remaining, etc., if you are >>> talking about a time of at least several minutes). >> >> If concerned over the display being "static" for long periods, then >> add some other (mindless) "activity indicator" so a user knows that >> the device is "still working on the problem" -- even though it >> hasn't updated the "progress indicator". > > All electronics needs a blinking LED so that you know it is working!Unless, of course, it just proves that the *indicator* is working! :< (I recall a solaris "activity indicator" that was a separate process that just sat and twiddled an indicator... without any feedback from the process that it was *presumably* monitoring! Kill the *real* process and the indicator still sits there merrily indicating "activity")>> (i.e., 1 degree *or* 1% wouldn't, by itself, be sufficient if it >> was a 5 hour process!) > > Absolutely. For long periods, a time counter is usually the best choice > - counting down if you know how long the task will take, or counting up > if you don't know.Considering how large the circle (pie) is LIKELY to be (in an embedded system... LESS likely to be using a HUGE display!), will there be any *real* difference (at the pixel level) in the resulting image at X degrees and X+1 degrees?? Shirt-sleeve says you'd need ~100 pixel diameter to *begin* to see any difference (??) -- and, that difference would be so insignificant that a user would probably never notice it!>> Without intending to offend the OP, it sounds like a "young" >> engineer specifying a "1023.276 ohm" resistor... >> >> [Or, a homework problem] > > Inexperienced engineer was my impression too. It sounds like someone > who has a fixed idea of a solution (or been given a fixed idea of a > solution), when they should take a step back and try and figure out the > /real/ question.Exactly. How do you display 1% if you only have 1 degree "resolution"? Or 2%? 3%? 4%? 6%? etc. [the above intended for the OP to consider]
Reply by ●August 26, 20142014-08-26
On Mon, 25 Aug 2014 12:52:25 -0500, "ajellis" <74158@embeddedrelated> wrote:>I need to plot a pie on an LCD screen as an indicator of time remaing for a >process.Have you checked that your LCD has square pixels ? With some rectangular (but non-square) pixels, your circle will look like an ellipse :-)
Reply by ●August 26, 20142014-08-26
> Alternately, fill in the circle by filling in lines that extend radially > from the center outward, and spaced close enough to get full coverage. > Fill in with a for-loop that goes from the minimum angle to be filled up > to the maximum.Still alternately, fill the circle by drawing succesively larger radii, so there's less overlap
Reply by ●August 28, 20142014-08-28
Don Y wrote:> Hi Mel, > > On 8/25/2014 5:03 PM, Mel Wilson wrote: > > On Mon, 25 Aug 2014 17:46:11 -0500, ajellis wrote: > > [ ... ] > >> I am using an AT32UC3B0512 microcontroller. > >> > >> I need the algorithm to advance monotonically ie start with a vertical > >> line from the centre of the circle to the outside edge, then to be able > >> to grow in steps of 1° until the circle is complete. > > > > It might work to use the midpoint algorithm to calculate the next undrawn > > circumferential point. You could guesstimate how much progress that > > would represent, and when you've progressed that much, use Bresenham's > > line algorithm to draw a line from the vertex of the pie to that > > circumferential point. Rinse and repeat. > > Better to draw from the circumference inward. When you hit a pixel > having the color you are drawing, you know you are done -- even if > you haven't reached the center! (hand-waving)Is the extra read and test cost more than overlapped pixel drawing? Probably depends on new arc size. w..
Reply by ●August 28, 20142014-08-28
Hi Walter, On 8/28/2014 6:56 AM, Walter Banks wrote:> Don Y wrote: > >> On 8/25/2014 5:03 PM, Mel Wilson wrote: >>> On Mon, 25 Aug 2014 17:46:11 -0500, ajellis wrote: >>> [ ... ] >>>> I am using an AT32UC3B0512 microcontroller. >>>> >>>> I need the algorithm to advance monotonically ie start with a vertical >>>> line from the centre of the circle to the outside edge, then to be able >>>> to grow in steps of 1° until the circle is complete. >>> >>> It might work to use the midpoint algorithm to calculate the next undrawn >>> circumferential point. You could guesstimate how much progress that >>> would represent, and when you've progressed that much, use Bresenham's >>> line algorithm to draw a line from the vertex of the pie to that >>> circumferential point. Rinse and repeat. >> >> Better to draw from the circumference inward. When you hit a pixel >> having the color you are drawing, you know you are done -- even if >> you haven't reached the center! (hand-waving) > > Is the extra read and test cost more than overlapped pixel drawing? > Probably depends on new arc size.You're moving towards a region where, sooner or later (increments less than 90 degrees) you will encounter a portion that has been previously drawn. Once you've hit that point, you can turn around and implement a flood fill algorithm -- which ALSO requires read-and-test in each iteration. Of course, the smaller the increment, the more readily you will encounter such a point (perhaps condition *how* you run THIS INVOCATION of the algorithm based on the size of the increment... or, unroll the loop a bit and spread the test over several "draw" iterations). I'm sure someone has already tackled a similar problem...
Reply by ●September 3, 20142014-09-03
>"ajellis" <74158@embeddedrelated> writes: >> I need the algorithm to advance monotonically ie start with a vertical >> line from the centre of the circle to the outside edge, then to be >> able to grow in steps of 1° until the circle is complete. > >What is the diameter of the circle in pixels? How many different angles >do you want to be able to show? That cpu has 512KB of flash, which is a >lot. Maybe you can just precompute the coordinates of the circle and >store them in a flash table, and similarly the endpoints of the circular >segments for each angle you want to draw in one quadrant (say 16 of >them) and do some range reduction and reflection for the other >quadrants. So that would let you show the "pie" growing in 64 steps. > >If you want to compute on the fly you can use Bresenham's circle >algorithm, or more generally, possibly CORDIC. Or just use some trig >library if you don't care about speed and space. >Hi Everyone, Thank you for your replies, and I would like to apologise for the delay in responding; I have several irons in the fire at the moment. It hadn't occurred to me to precompute coordinates and store them in a table. That is the solution I'm working on at the moment. Andrew --------------------------------------- Posted through http://www.EmbeddedRelated.com







