move magic values to defines
This commit is contained in:
parent
82fd0d1138
commit
4202fb9fc5
@ -58,6 +58,12 @@
|
|||||||
#define MOD_CHARGING 0x01
|
#define MOD_CHARGING 0x01
|
||||||
#define MOD_READY 0x02
|
#define MOD_READY 0x02
|
||||||
|
|
||||||
|
#define VOLTAGE_CONNECT 9000
|
||||||
|
#define VOLTAGE_CHARGE 12450
|
||||||
|
#define CURRENT_CHARGE 16000
|
||||||
|
#define CURRENT_READY 2000
|
||||||
|
#define VOLTAGE_REMOVE 1000
|
||||||
|
|
||||||
static void lcd_wait_busy(void)
|
static void lcd_wait_busy(void)
|
||||||
{
|
{
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
@ -222,11 +228,11 @@ ISR(TIMER0_OVF_vect)
|
|||||||
* and a current limit of 1.6A
|
* and a current limit of 1.6A
|
||||||
*/
|
*/
|
||||||
if (mode == MOD_CHARGING) {
|
if (mode == MOD_CHARGING) {
|
||||||
if (voltage < 12425 && current < 15500)
|
if (voltage < (VOLTAGE_CHARGE -25) && current < (CURRENT_CHARGE -500))
|
||||||
if (pwm < 0xff)
|
if (pwm < 0xff)
|
||||||
pwm++;
|
pwm++;
|
||||||
|
|
||||||
if (voltage > 12450 || current > 16000)
|
if (voltage > VOLTAGE_CHARGE || current > CURRENT_CHARGE)
|
||||||
if (pwm > 0x00)
|
if (pwm > 0x00)
|
||||||
pwm--;
|
pwm--;
|
||||||
|
|
||||||
@ -240,19 +246,19 @@ ISR(TIMER0_OVF_vect)
|
|||||||
switch (mode) {
|
switch (mode) {
|
||||||
case MOD_WAITING:
|
case MOD_WAITING:
|
||||||
/* start charging when a voltage > 9V is detected (lipo connected) */
|
/* start charging when a voltage > 9V is detected (lipo connected) */
|
||||||
if (voltage > 9000)
|
if (voltage > VOLTAGE_CONNECT)
|
||||||
mode = MOD_CHARGING;
|
mode = MOD_CHARGING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MOD_CHARGING:
|
case MOD_CHARGING:
|
||||||
/* end charging if voltage > 12.42V and current < 200mA */
|
/* end charging if voltage > 12.45V and current < 200mA */
|
||||||
if (voltage > 12425 && current < 2000)
|
if (voltage >= VOLTAGE_CHARGE && current < CURRENT_READY)
|
||||||
mode = MOD_READY;
|
mode = MOD_READY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MOD_READY:
|
case MOD_READY:
|
||||||
/* wait for lipo disconnect */
|
/* wait for lipo disconnect */
|
||||||
if (voltage < 1000)
|
if (voltage < VOLTAGE_REMOVE)
|
||||||
mode = MOD_WAITING;
|
mode = MOD_WAITING;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user