Announcement

Collapse
No announcement yet.

Gfx problems - drawing rectangles

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gfx problems - drawing rectangles

    So I've basically written a program which takes data from a sensor and normalises it between -1000 and 1000. This varying value I then want to define the length of a rectangle, such that it looks like a bar whose length changes with the sensor value and direction changes based on whether the value is positive or negative.[HTML] void loop(){

    xcal = map(XSum/100, XMin, XMax, -1000, 1000);
    ycal = map(YSum/100, YMin, YMax, -1000, 1000);
    zcal = map(ZSum/100, ZMin, ZMax, -1000, 1000);

    float gy1 = 160+(0.14*ycal);
    float gy2 = 160-(0.14*ycal);


    if (ycal>=0.00){
    Display.gfx_RectangleFilled(25,160,75,gy1,GREEN);
    }
    else if (ycal

  • #2


    You need to think of the process as 2 rectangles, one for the bottom coming up (the bar) and one from the top coming down (the whitespace).

    Actually, you could use 1 rectangle, but it would have to be a delta from the last value, the bar (if the delta has increased) and whitespace (if it has decreased). But that's a bit trickier than the first option.
    Mark

    Comment


    • #3


      Thanks! It worked a treat. Another question I had was whether I could align text in landscape mode instead of portrait?

      Comment


      • #4


        If you use the 'screen mode' command you can put it in Landscape mode and then your text will be written in Landscape mode
        Mark

        Comment

        Working...
        X