add remote buttons
This commit is contained in:
parent
a5d4d1ab22
commit
af4aa0946c
|
@ -158,7 +158,7 @@ const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
|
|||
struct nrfdata {
|
||||
uint8_t steer;
|
||||
uint8_t speed;
|
||||
uint8_t commands; //bit 0 set = motor enable
|
||||
uint8_t commands; //bit 0 set = motor enable, 1=left,2=up,3=down,4=right
|
||||
uint8_t checksum;
|
||||
};
|
||||
|
||||
|
@ -174,6 +174,11 @@ boolean radiosendOk=false;
|
|||
|
||||
//command variables
|
||||
boolean motorenabled = false; //set by nrfdata.commands
|
||||
boolean setup_directon_press_left=false;
|
||||
boolean setup_directon_press_up=false;
|
||||
boolean setup_directon_press_down=false;
|
||||
boolean setup_directon_press_right=false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -449,10 +454,44 @@ void loop() {
|
|||
|
||||
//parse commands
|
||||
motorenabled = (lastnrfdata.commands & (1 << 0))>>0; //check bit 0 . Used for safety-off when remote released
|
||||
if ((lastnrfdata.commands & (1 << 1))>>0) { //left
|
||||
setup_directon_press_left = true;
|
||||
Serial.println("RF Button Left");
|
||||
}else if ((lastnrfdata.commands & (1 << 2))>>0) { //up
|
||||
setup_directon_press_up = true;
|
||||
Serial.println("RF Button Up");
|
||||
}else if ((lastnrfdata.commands & (1 << 3))>>0) { //down
|
||||
setup_directon_press_down = true;
|
||||
Serial.println("RF Button Down");
|
||||
}else if ((lastnrfdata.commands & (1 << 4))>>0) { //right
|
||||
setup_directon_press_right = true;
|
||||
Serial.println("RF Button Right");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (abs(set_speed)<10 && abs(set_steer)<10) { //standstill
|
||||
if (setup_directon_press_left) {
|
||||
|
||||
}
|
||||
if (setup_directon_press_up) {
|
||||
|
||||
}
|
||||
if (setup_directon_press_down) {
|
||||
|
||||
}
|
||||
if (setup_directon_press_right) {
|
||||
|
||||
}
|
||||
}
|
||||
setup_directon_press_left=false;
|
||||
setup_directon_press_up=false;
|
||||
setup_directon_press_down=false;
|
||||
setup_directon_press_right=false;
|
||||
|
||||
|
||||
|
||||
if (controlmode == MODE_RADIONRF && nrf_delay >= MAX_NRFDELAY) { //too long since last sucessful nrf receive
|
||||
controlmode = MODE_DISARMED;
|
||||
|
@ -882,6 +921,9 @@ void display_show_stats3() {
|
|||
display.print(F("nrf_delay=")); display.print(last_nrfreceive_delay); display.print(F(" (")); display.print(max_last_nrfreceive_delay);display.println(F(")"));
|
||||
display.print(F("maxdiff=")); display.println(raw_length_maxdiff);
|
||||
|
||||
display.print(F("nrfdata x,y=")); display.print(lastnrfdata.steer); display.print(F(", ")); display.println(lastnrfdata.speed);
|
||||
display.print(F("nrfdata command=")); display.println(lastnrfdata.commands);
|
||||
|
||||
|
||||
display.display(); // Show initial text
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit fe9ff4f27f5730a39c09bd35fb009aa71b386a05
|
||||
Subproject commit a1da44f7c960a7f4bd84c686a5dc0d0f9191618c
|
Loading…
Reference in New Issue