Black brick's power level

2 replies [Last post]
Millburn1
Title: NooBot
Joined: 02/04/2013
Posts:
BotPoints: 22
User offline. Last seen 10 years 4 weeks ago.

  1. int main()
  2. {
  3. float power = power_level();
  4. printf("power level %d \n", power);
  5.  
  6. //test running for 2 minutes
  7. int i=0;
  8. int clawPort = 0;
  9. int clawMin = 660;
  10. int clawMax = 1000;
  11. enable_servos();
  12. //open claws to start
  13. set_servo_position(clawPort, clawMin);
  14. msleep(500);
  15.  
  16. for(i=0;i<1;i++){
  17. drive(50);
  18. s(1);
  19. drive(-50);
  20. s(1);
  21. drive(0);
  22.  
  23. movePipe(1,1);
  24.  
  25. //close claws
  26. set_servo_position(clawPort, clawMax);
  27. msleep(500);
  28.  
  29. //open claws
  30. set_servo_position(clawPort, clawMin);
  31. msleep(500);
  32.  
  33. //close claws
  34. set_servo_position(clawPort, clawMax);
  35. msleep(500);
  36.  
  37. movePipe(1,-1);
  38. }
  39.  
  40.  
  41. disable_servos();
  42. ao();
  43.  
  44. //end test for 2 minutes
  45. power = power_level();
  46. printf("power level now %d \n", power);
  47. printf("done\n");
  48. return 0;
  49. }

side methods not listed

when this program runs (mainly to check battery level), the level actually goes up.. and it's in a huge number range.

what's the best way to get the brick's battery level? the 'home page' of the brick is very weird, when we plug in the charger the level just bumps up like 20%

KCotrone
Title: NooBot
Joined: 01/29/2013
Posts:
BotPoints: 38
User offline. Last seen 9 years 31 weeks ago.

To print out a floating type you need to use %f and not %d. I think that's the issue.

KCotrone
Title: NooBot
Joined: 01/29/2013
Posts:
BotPoints: 38
User offline. Last seen 9 years 31 weeks ago.

You need to use %f instead of %d when using a float. I think that's the issue.