Forum

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1]
Author Topic: PG doesnt draw the pixels
itubal
Newbie
Posts: 1
Permalink
Post PG doesnt draw the pixels
on: August 2, 2014, 10:07
Quote

Thankyou all and sorry, my English's not so good.

I'm talking about Polargraph Server A1 (I downloaded it yesterday from Github) , an Arduino UNO and a Adafruit controller.

I've "plotted" some svg and vectors and the PolarGraph works fine. PG draws nice.

But in "image mode" PG doesn't draw the pixels. It makes the test fine, it makes the path between pixels fine but doesn't draw pixels.

I think that the problem is in the pixel module line #68 (aprox.)

density = pixel_scaleDensity(density, 255, pixel_maxDensity(penWidth, size));

The "density" value always returns 0 or 1

Can anybody tell me the correct sentence, the correct pixel_scaleDensity() function ?

Thankyou all!!

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: PG doesnt draw the pixels
on: August 2, 2014, 12:55
Quote

Hello! Great to hear it's mostly working for you 🙂

Those parts of pixel.ino haven't been changed for a long time (you can do a 'git blame' https://github.com/euphy/polargraph_server_a1/blame/master/pixel.ino to check the history) so everyone else has been using that exact code for at least a year and a half, so I believe it works.

Reading back through that code, it's a bit strange (could do with some comments!). The variable called density is given the value of the 4th parameter to the command that it is processing. A command looks something like:

C05,<distance from left motor>,<distance from right motor>,<pixel size>,<pixel brightness>,END

eg:

C05,3222,2864,181,95,END

To draw a pixel, at coordinates 3222, 2864, that is 181 steps wide and has a brightness of 95 (out of 255).

So initially density is brightness, but in pixel_scaleDensity(...), density is re-set to actually be darkness rather than brightness, using this formula:

// Map the brightness to the range available for the pixel
reducedDens = (brightness / 255) * maxWavesForThisPixelSize

// Then invert it
reducedDens = maxWavesForThisPixelSize-reducedDens;

So if brightness is 200 (pretty light), and we're using a big pixel with a small pen that can fit in a maximum of 40 waves,

brightness = 200;
maxWavesForThisPixelSize =40;

mappedBrightness = (brightness  / 255) * maxWavesForThisPixelSize;
// mappedBrightness equal 31, which is still a BRIGHTNESS value.
// Drawing this many waves with black ink would result in a dark pixel 
// rather than a light one.

// Now invert it so it becomes a darkness value
mappedDarkness = maxWavesForThisPixelSize - mappedBrightness;
// so mapped darkness is 40 - 31 = 9.
// Drawing 9 waves with black ink would result in a lighter pixel.

If you are consistently getting density set to 1 or 0, then it means either
- pixel_maxDensity(penWidth, size) is returning a very low value, or
- the density value in your command is very high.

You can check the density value easily by looking in your command queue. If you see a good range of numbers in the fourth parameter of your C05 commands, then that is not your problem. I'd guess that you haven't set the pen size correctly, or you are using very small grid size (very small pixels).

When you say the test works fine, do you mean the pen width test? (The patches of decreasing density?) That pen width test uses the same code as you've highlighted above, so it must be working ok there. Remember that the pen width test does not set the pen width automatically itself. You need to look at the output patch, and then send a "set pen tip size" command yourself. Also remember that pen tip size is volatile - it is NOT saved in the machine when you reset it, so you need to re-send it every time you reset.

good luck
sn

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: PG doesnt draw the pixels
on: August 2, 2014, 23:42
Quote

Secondly, I have just done some work to expose the debugging messages a little more obviously (http://www.polargraph.co.uk/2014/08/feedback-in-the-controller/) to make this kind of thing easier.

It would be great if you could give it a go, and let me know if it makes sense, haha!

sn

Pages: [1]
Mingle Forum by cartpauj
Version: 1.0.34 ; Page loaded in: 0.019 seconds.