dhiltonp

low voltage test

Feb 1st, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.35 KB | None | 0 0
  1. diff --git a/libraries/hexbright/hexbright.cpp b/libraries/hexbright/hexbright.cpp
  2. index 2cd0511..f28bee1 100755
  3. --- a/libraries/hexbright/hexbright.cpp
  4. +++ b/libraries/hexbright/hexbright.cpp
  5. @@ -1080,7 +1080,7 @@ void hexbright::detect_overheating() {
  6.  ////////////////AVR VOLTAGE////////////////////
  7.  ///////////////////////////////////////////////
  8.  
  9. -int band_gap_reading = 0;
  10. +int band_gap_reading = 1000;
  11.  int lowest_band_gap_reading = 1000;
  12.  
  13.  void hexbright::read_avr_voltage() {
  14. @@ -1093,7 +1093,7 @@ void hexbright::read_avr_voltage() {
  15.  
  16.    // ADC register from source: http://www.sourcecodebrowser.com/avr-libc/1.8.0/iomx8_8h_source.html
  17.    //  it seems that this may be incompatible with assembly code; ADCW should work if that becomes an issue.
  18. -  band_gap_reading = ADC;
  19. +  band_gap_reading = (ADC+band_gap_reading*7)/8;
  20.    lowest_band_gap_reading = band_gap_reading < lowest_band_gap_reading ? band_gap_reading : lowest_band_gap_r
  21.  }
  22.  
  23. @@ -1107,7 +1107,8 @@ BOOL hexbright::low_voltage_state() {
  24.    static BOOL low = false;
  25.    // lower band gap value corresponds to a higher voltage, trigger
  26.    //  low voltage state if band gap value goes too high.
  27. -  if (band_gap_reading > lowest_band_gap_reading+4) {
  28. +  if (get_charge_state()==BATTERY &&
  29. +      band_gap_reading > lowest_band_gap_reading+4) {
  30.      low = true;
  31.    }
  32.    return low;
Advertisement
Add Comment
Please, Sign In to add comment