You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.0 KiB
63 lines
1.0 KiB
#include "pwm.h" |
|
#include <math.h> |
|
|
|
unsigned char pwm_val_right =0; |
|
unsigned char push_val_right=0; |
|
unsigned char pwm_value=0; |
|
|
|
extern uint Seep_model; |
|
extern struct UserInfo usr; |
|
extern uchar model; |
|
extern uint mileage; |
|
|
|
bit Right_moto_stop = 0; |
|
|
|
void delay(unsigned int k) |
|
{ |
|
unsigned int x,y; |
|
for(x=0;x<k;x++) |
|
for(y=0;y<2000;y++); |
|
} |
|
|
|
void run(void) |
|
{ |
|
if(model){ |
|
Seep_model = usr.Seep_model; |
|
usr.Remaining_mileage = usr.target_mileage - mileage; |
|
if(usr.Remaining_mileage < 0) usr.Remaining_mileage = 0; |
|
if(usr.Remaining_mileage == 0) Seep_model = 0; |
|
}else{ |
|
usr.Remaining_mileage = 0; |
|
} |
|
|
|
|
|
if(Seep_model == 0) pwm_value = 0; |
|
else if(Seep_model == 1) pwm_value = 2; |
|
else if(Seep_model == 2) pwm_value = 5; |
|
else pwm_value = 7; |
|
push_val_right=pwm_value; |
|
Right_moto_back; |
|
} |
|
|
|
void pwm_out_right_moto(void) |
|
{ |
|
pwm_val_right++; |
|
if(~Right_moto_stop){ |
|
if(pwm_val_right <= push_val_right) |
|
{ |
|
Right_moto_pwm=1; |
|
} |
|
else{ |
|
Right_moto_pwm=0; |
|
} |
|
if(pwm_val_right>=20) pwm_val_right=0; |
|
} |
|
else{ |
|
Right_moto_pwm=0; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|