Indicator bar.

sidlord:
Blackfin,

Thanks this is exactly what i want!

The bar is now a line, how can i make it solid?

How do you mean solid? A "bar" rising from the bottom?

As a first-order effort, you can try commenting out this line:

            display.drawFastHLine( 0, newBarY, 5, WHITE );

and replacing it with this:

            display.fillRect( 0, newBarY, 5, 64 - newBarY, WHITE );

It fill the bar now but must not start from the bottom the bar.

It must do the same with the line bar, start center.

It must do the same with the line bar, start center.

Can't you try out something by yourself?

Here are some hints:

The function has the following parameters

display.fillRect( startX, [color=red]startY[/color],  width, [color=red]height[/color], Color );

startX and width are known (0 and 5), Color is known (White).

So you need to calculate the startY point and the height of bar
You know you want one side to be center (you know which Y that is) and that newBarY is where the other side should be (just mind that it can be above or below the center if your library does not know how to draw a rectangle with negative height).

it is not rocket science to figure that out. give it a try

here is a quick drawing to make it visual

BELOW CENTER ABOVE CENTER

int startY, height;
if (newBarY > 32) {
  // BELOW CENTER
  startY = .... ;
  height = ... ;
} else {
  // ABOVE CENTER
  startY = .... ;
  height = ... ;
} 
display.fillRect( 0, startY,  5, height, WHITE );

Yes of course i want to try things myself.
That is the way i am learning, but i need to get a push in the direction of what i want.
And i always look back into the code and try to understand the code.
Its not like some one puts a code here and copy pas en then do nothing anymore.

I am really thankful to you all.

Il wil try J-M-L, thanks.

I added a bit of a drawing and some code to fill up once you've done the math figuring out what goes where.

check again my post

Ok,

Now if the caliper is 2.10 it wont center.
But when i go above 2.10 i have a full bar on the upper half.
And when i go under 2.10 i have a full bar at the bottom half.
i understand that you can change the size of the bar.

if (newBarY > 32) {
  
  // BELOW CENTER
  startY = 32;
  height = 64;
} else {
  // ABOVE CENTER
  startY = 0;
  height = 32;
}

The bar is now only go up and down full.
Can y use Y++ to let the bar move like it did with the line bar?

the math is wrong.. the height can't be constant. it needs to vary with where newBarY is (StartY is not correct either)

look at the picture

and try again?

How about this:

Comment out the line I had and add a call:

            //display.drawFastHLine( 0, newBarY, 5, WHITE );
            DrawBar( newBarY );

Add the function:

void DrawBar( uint8_t newBarY )
{
    if( newBarY == 32 )
        display.drawFastHLine( 0, newBarY, 5, WHITE );
    else
    {
        if( newBarY < 32 )
            display.fillRect(1, newBarY, 3, 32 - newBarY, WHITE );    
        else
            display.fillRect(1, 32, 3, newBarY - 32, WHITE );    
            
    }//else
    
}//DrawBar

Blackfin:
How about this...

:confused: you make it too easy for @sidlord...

"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime..."

J-M-L:
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a while..."

"Discover that he's vegan and you've wasted all your time."

You forgot the 3rd verse.

-jim lee

LOL - I did not know that one!!!

Give a man a fish and you feed him for a day. Give a man someone else's fish and he'll vote for you.

The Arduino Forum lament.

The man needs a fish. You have plenty, so that's fine.
Teach the man to fish. But with no license, that's a crime.
Discover that he's vegan. You've wasted all your time.

-jim lee

Don't worry,

J-M-L i will stile try your lesson that you gave me , then i am learning.
De bar works, and i will read the code and try to understand how the code is working.