improved for higher speed

This commit is contained in:
interfisch 2019-04-09 21:30:58 +02:00
parent 4cad7ab867
commit dc81636839
1 changed files with 7 additions and 9 deletions

View File

@ -63,7 +63,7 @@ long last_sendNRF=0;
#define PIN_TOUCH 5
long last_touch=0;
#define TOUCH_TIMEOUT 300
#define TOUCH_TIMEOUT 100
//command variables
boolean motorenabled=false;
@ -75,8 +75,8 @@ boolean motorenabled=false;
#define PIN_POWERON 7
#define TRACKPOINT_MAX 70 //value for maximum stick movement
float speedscale=0.7;
float steerscale=0.3;
float speedscale=0.0;
float steerscale=0.0;
int16_t last_xin=0;
int16_t last_yin=0;
@ -166,6 +166,8 @@ void setup() {
voltage=readVcc();
Serial.print("Voltage=");
Serial.println( voltage, DEC );
setup_updateSpeedmode(); //set speeds
}
@ -293,10 +295,6 @@ void loop() {
senddata.steer=map(xin_smooth, -1000,1000, 127+(128*steerscale), 127-(127*steerscale) ); //steer
senddata.speed=map(yin_smooth, -1000,1000, 127-(127*speedscale), 127+(128*speedscale) ); //speed
Serial.print(senddata.steer);
Serial.print(", ");
Serial.println(senddata.speed);
senddata.commands=0; //reset
@ -492,11 +490,11 @@ long readVcc() {
void setup_updateSpeedmode(){
switch(speedmode){
case 0: //slow
speedscale=0.3;
speedscale=0.15;
steerscale=0.2;
break;
case 1: //medium
speedscale=0.6;
speedscale=0.4;
steerscale=0.45;
break;
case 2: //fast