兼职项目 智能自行车
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.

64 lines
1.0 KiB

3 years ago
#include "pwm.h"
#include <math.h>
3 years ago
unsigned char pwm_val_right =0;
unsigned char push_val_right=0;
unsigned char pwm_value=0;
3 years ago
extern uint Seep_model;
extern struct UserInfo usr;
extern uchar model;
extern uint mileage;
bit Right_moto_stop = 0;
void delay(unsigned int k)
3 years ago
{
unsigned int x,y;
3 years ago
for(x=0;x<k;x++)
for(y=0;y<2000;y++);
}
void run(void)
3 years ago
{
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;
3 years ago
}
void pwm_out_right_moto(void)
3 years ago
{
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;
}
3 years ago
}
3 years ago