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 #define PIN_TOUCH 5
long last_touch=0; long last_touch=0;
#define TOUCH_TIMEOUT 300 #define TOUCH_TIMEOUT 100
//command variables //command variables
boolean motorenabled=false; boolean motorenabled=false;
@ -75,8 +75,8 @@ boolean motorenabled=false;
#define PIN_POWERON 7 #define PIN_POWERON 7
#define TRACKPOINT_MAX 70 //value for maximum stick movement #define TRACKPOINT_MAX 70 //value for maximum stick movement
float speedscale=0.7; float speedscale=0.0;
float steerscale=0.3; float steerscale=0.0;
int16_t last_xin=0; int16_t last_xin=0;
int16_t last_yin=0; int16_t last_yin=0;
@ -167,6 +167,8 @@ void setup() {
Serial.print("Voltage="); Serial.print("Voltage=");
Serial.println( voltage, DEC ); Serial.println( voltage, DEC );
setup_updateSpeedmode(); //set speeds
} }
@ -294,10 +296,6 @@ void loop() {
senddata.steer=map(xin_smooth, -1000,1000, 127+(128*steerscale), 127-(127*steerscale) ); //steer 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 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 senddata.commands=0; //reset
if (!radioOk || setupmode!=SETUP_NONE){ //if last transmission failed or in setup mode if (!radioOk || setupmode!=SETUP_NONE){ //if last transmission failed or in setup mode
@ -492,11 +490,11 @@ long readVcc() {
void setup_updateSpeedmode(){ void setup_updateSpeedmode(){
switch(speedmode){ switch(speedmode){
case 0: //slow case 0: //slow
speedscale=0.3; speedscale=0.15;
steerscale=0.2; steerscale=0.2;
break; break;
case 1: //medium case 1: //medium
speedscale=0.6; speedscale=0.4;
steerscale=0.45; steerscale=0.45;
break; break;
case 2: //fast case 2: //fast