Project

General

Profile

Revision 277

more cleanup

View differences:

battery.c
82 82
int battery(void)
83 83
{
84 84
  /* 5 volts is the max, 255 is the max 8bit number , *2 for the divider */
85
        return analog8(BATT_PORT) * 500 >>7;
85
  return analog8(BATT_PORT) * 500 >>7;
86 86
}
87 87

  
88 88

  
......
103 103
  int batt_reading = battery8();
104 104

  
105 105
  if(next_read == 0) {
106
    if(batt_reading > BATTERY_LOWV)
107
    {
108
        ret = 0;
106
    if(batt_reading > BATTERY_LOWV) {
107
      ret = 0;
108
      battery_low_count = 0;
109
    } else {
110
      battery_low_count++;
111
      if( battery_low_count >= MAX_LOW_COUNT) {
112
        ret = 1;
109 113
        battery_low_count = 0;
114
      }
110 115
    }
111
    else
112
    {
113
        battery_low_count++;
114
        if( battery_low_count >= MAX_LOW_COUNT )
115
        {
116
            ret = 1;
117
            battery_low_count = 0;
118
        }
119
    }
120 116

  
121 117
    next_read = BATTERY_NEXT_READ_PRESCALAR;
118
  } else {
119
    next_read--;
122 120
  }
123
  else next_read--;
124 121

  
125 122
  return ret;
126 123
}
......
151 148
}
152 149

  
153 150
/** @} **/ //end defgroup
154

  

Also available in: Unified diff