Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7706743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:11:26+00:00 2026-06-01T00:11:26+00:00

i’m trying to implement kind of speedometer. i’m getting informations about rounds per minute,

  • 0

i’m trying to implement kind of speedometer. i’m getting informations about rounds per minute, boost and load of an engine over bluetooth and i try to display them on the screen witch 3 arrows witch should point in the right direktion. i tried to use a rotate animation evry time i get data(10-100ms) to setup the arrows. but that makes my ui extremly slow. 500ms to react on a buttonclick. Doese someone know how to make it work better?

source code:

public void setTacho()
{


//rotate Tachonadel
Rpmcurrentdegree=Rpmcurrentdegree+Rpmdegree;
Rpmdegree=((rpms-lastrpm)*RPMtoDegree);

RpmAnim=new RotateAnimation((float)Rpmcurrentdegree, (float)Rpmdegree,       ivNadel.getWidth()/2, ivNadel.getHeight()/2);
RpmAnim.setFillEnabled(true);
RpmAnim.setFillAfter(true);
ivNadel.setAnimation(RpmAnim);
RpmAnim.start();


//rotate Boostbalken
currentBoostDegree=currentBoostDegree+BoostDegree;
BoostDegree=(boost-lastBoost)*BOOSTtoDegree;

//rotate Loadbalken
currentLoadDegree=currentLoadDegree+LoadDegree;
LoadDegree=(load-lastLoad)*LOADtoDegree;


BoostAnim=new RotateAnimation((float)-currentBoostDegree, (float)-BoostDegree,     ivBoost.getWidth()/2, ivBoost.getHeight()/2);
BoostAnim.setFillEnabled(true);
BoostAnim.setFillAfter(true);
ivBoost.setAnimation(BoostAnim);
BoostAnim.start();

LoadAnim=new RotateAnimation((float)currentLoadDegree, (float)LoadDegree,     ivLoad.getWidth()/2, ivLoad.getHeight()/2);
LoadAnim.setFillEnabled(true);
LoadAnim.setFillAfter(true);
ivLoad.setAnimation(LoadAnim);
LoadAnim.start();

}

when i try to make the rotation only if the values have changed then it works only while they are changing but if they aren’t the arrows jump back to the zero position. isnt setfillafter to tell the image that it should hold the new position?

code:

public void setTacho()

{
//rotate Tachonadel
Rpmcurrentdegree=Rpmcurrentdegree+Rpmdegree;
Rpmdegree=((rpms-lastrpm)*RPMtoDegree);


if(Rpmdegree!=0)
{
RpmAnim=new RotateAnimation((float)Rpmcurrentdegree, (float)Rpmdegree,     ivNadel.getWidth()/2, ivNadel.getHeight()/2);
RpmAnim.setFillEnabled(true);
RpmAnim.setFillAfter(true);
ivNadel.setAnimation(RpmAnim);
RpmAnim.start();
}

//rotate Boostbalken
currentBoostDegree=currentBoostDegree+BoostDegree;
BoostDegree=(boost-lastBoost)*BOOSTtoDegree;
//rotate Loadbalken
currentLoadDegree=currentLoadDegree+LoadDegree;
LoadDegree=(load-lastLoad)*LOADtoDegree;

if(BoostDegree!=0)
{
BoostAnim=new RotateAnimation((float)-currentBoostDegree, (float)-BoostDegree,     ivBoost.getWidth()/2, ivBoost.getHeight()/2);
BoostAnim.setFillEnabled(true);
BoostAnim.setFillAfter(true);
ivBoost.setAnimation(BoostAnim);
BoostAnim.start();
}




if(LoadDegree!=0)
{
LoadAnim=new RotateAnimation((float)currentLoadDegree, (float)LoadDegree,     ivLoad.getWidth()/2, ivLoad.getHeight()/2);
LoadAnim.setFillEnabled(true);
LoadAnim.setFillAfter(true);
ivLoad.setAnimation(LoadAnim);
LoadAnim.start();
}
}

i don’t get it =(

thx 4 help

EDIT:

part of the bluetooth Thread that calls the callback

while (run) {
                try {

                    bytes = mmInStream.read(buffer);

                    if (connection.btCallback != null)
                    {
                            connection.btCallback.getData(buffer,bytes);
                    }

                } catch (IOException e) {

                    break;
                }

the callback methode of the bluetooth thread:

public void getData(byte[] bytes, int len)
        {
           setTacho(); 
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:11:27+00:00Added an answer on June 1, 2026 at 12:11 am

    Run your rotations code in a separate thread, so you may set the animation to your ImageViews as below:

    //for example
    ivNadel.post(new Runnable() {   
        @Override
        public void run() {
            ivNadel.setAnimation(RpmAnim);
        }
    });
    

    see if it helps for you

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.