Unexpected output from code

I am currently coding a ZUMO32U4 to do certain tasks. The problem is relatively tiny compared to the amount of code, yet it still is a major problem when it comes to functionality. The code keeps outputting 0% battery to the lcd display, even on startup (note that this is an imaginary, code defined battery), even though i see no logical reason in my code for it doing so. Expected output should be 100% at the beginning, decreasing as time goes. I get no compile errors. I would also rule out electronics errors seeing as the Polulu ZUMO32U4 is a premade product.

//This function is called on every loop
//the setup is also not important

void update_battery(){

  //if the battery is above 100%, set it to 100% again.
    
  if (battery > 100.00){
    battery = 100.0;
  }
    lcd.clear();
    lcd.print(battery);
    lcd.print("%");

  //beeps if the battery is low.
  battery_low_warning(battery);

  // if the speed is over 0, start the battery drain. ignores stationary drain.
  if (speedMperS > 0) {
    battery -= battery_drain();
  }
  //charges battery if it's going backwards. 
  else if (speedMperS < 0){
    battery += battery_drain()*charge_multiplier; //multiplier if we want faster charging. Can be tuned for a specific purpose.
  }

  charging_cycle();
  five_percent_counter(battery, battery_switch);
  battery_production_error();
  calculate_battery_health(avg_speed, highest_speed, timeCloseMax);
  check_battery_health();
  
}

float battery_drain(){
  //at this point this function only returns the distance.
  //this would mean that 1m of distance is 1% of battery drain.
  //this can be tweaked to our liking/needs easily.
  return distance*0.1;
  
}

void meterDistanceCalc(int leftCount,int rightCount){
  float avgCount = (leftCount + rightCount)/2.0;
  distance = (avgCount/907.0)*oneRotation;
}

void speedMeterPerSecond(){
  if(currentTid - prevTime >= 1000){
    speedMperS = distance - currentDistance;
    update_arrays();
    //arrayIndex is used as a meter to know how many seconds have passed.
    //The array function is not relevant in this part
    arrayIndex++;
    currentDistance = distance;
    prevTime = millis();

  }
}

There's probably a problem in the code you didn't post.

Can't see enough code to tell you why you see that.

Unless you already know what the problem is, don't pretend that you know what I need to see in order to find it. If you do know what the problem is then don't bother us with it.

TheMemberFormerlyKnownAsAWOL:
There's probably a problem in the code you didn't post.

Full code here:

Why not here?

If battery is initially set to zero, where is it assigned any other value?

TheMemberFormerlyKnownAsAWOL:
Why not here?

Character limit.

Also, it's not initially set to zero as far as i can see. Where do you see this?

graaskjegg:
Character limit.

Read "How to use this forum" post. It explains what to do.

Reading the instructions first will save you a LOT of trouble in life. Half the problems we solve here wouldn't be here if people would just take a few minutes to read the docs.

float battery, battery_health = 100.0;Right there

There are reasons for asking for the code etc.

Also dont waste my time with frivolous reports !

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.

TheMemberFormerlyKnownAsAWOL:

float battery, battery_health = 100.0;

Right there

I see that jam up more newbies. One statement per line people. Doing that one thing will save you more trouble than you can imagine.