|
|
@ -47,6 +47,14 @@ uint8_t vtx_channel = 0; |
|
|
|
|
|
|
|
uint32_t last_display = 0; |
|
|
|
|
|
|
|
/* Timing to switch */ |
|
|
|
// uint32_t diversity_next_switch = 0;
|
|
|
|
int diversity_stable_count = 0; |
|
|
|
uint8_t current_receiver = 0; |
|
|
|
|
|
|
|
// Pinning the video to core 0
|
|
|
|
TaskHandle_t VideoCoreTask; |
|
|
|
|
|
|
|
// Starting up WebServer
|
|
|
|
WebServer server(80); |
|
|
|
|
|
|
@ -626,6 +634,14 @@ void setup_rx5808() { |
|
|
|
RX5808::begin(); |
|
|
|
} |
|
|
|
|
|
|
|
// Video core priority to process....
|
|
|
|
void VideoCoreProcessing(void *pvParameters) { |
|
|
|
// Forever loop ....
|
|
|
|
for(;;) { |
|
|
|
if(display_output_state) display_output(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void setup() { |
|
|
|
// Preparing Timer Hardware
|
|
|
|
/* 1 Aick take 1/(80MHZ/80) = 1us so we set divider 80 and count up */ |
|
|
@ -664,6 +680,18 @@ void setup() { |
|
|
|
/* Setup Finish Routine */ |
|
|
|
setup_done(); |
|
|
|
|
|
|
|
/* Setting up Video on Core 0 */ |
|
|
|
/**
|
|
|
|
xTaskCreatePinnedToCore( |
|
|
|
VideoCoreProcessing, |
|
|
|
"VideoCoreTask", |
|
|
|
8192, |
|
|
|
NULL, |
|
|
|
255, |
|
|
|
&VideoCoreTask, |
|
|
|
0); |
|
|
|
**/ |
|
|
|
|
|
|
|
/* Cool down a bit... */ |
|
|
|
delay(500); |
|
|
|
osd(1); |
|
|
@ -712,7 +740,7 @@ bool touchpad(uint8_t touch_id) { |
|
|
|
else |
|
|
|
return false; |
|
|
|
} else if(touch_id == TOUCH_DOWN) { |
|
|
|
Serial.println(average_reads); |
|
|
|
// Serial.println(average_reads);
|
|
|
|
if(average_reads < THRESHOLD_DOWN) |
|
|
|
return true; |
|
|
|
else |
|
|
@ -730,6 +758,20 @@ bool touchpad(uint8_t touch_id) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void receiverSelector(uint8_t id) { |
|
|
|
if(id == 0) { |
|
|
|
digitalWrite(VIDEO_SELECTOR, LOW); |
|
|
|
digitalWrite(INDICATOR_V1, HIGH); |
|
|
|
digitalWrite(INDICATOR_V2, LOW); |
|
|
|
current_receiver = 0; |
|
|
|
} else if(id == 1) { |
|
|
|
digitalWrite(VIDEO_SELECTOR, HIGH); |
|
|
|
digitalWrite(INDICATOR_V1, LOW); |
|
|
|
digitalWrite(INDICATOR_V2, HIGH); |
|
|
|
current_receiver = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void loop() { |
|
|
|
// Get readings from both RX5808 module
|
|
|
|
if(millis() > last_rssi_read) { |
|
|
@ -741,6 +783,26 @@ void loop() { |
|
|
|
rssi2 = rssi2 >> 2; // Faster way to divide 4
|
|
|
|
rssi1 = (rssi1 > MAX_RSSI) ? MAX_RSSI : rssi1; |
|
|
|
rssi2 = (rssi2 > MAX_RSSI) ? MAX_RSSI : rssi2; |
|
|
|
|
|
|
|
|
|
|
|
if(rssi1 > rssi2) { |
|
|
|
diversity_stable_count--; |
|
|
|
} else if(rssi2 > rssi1) { |
|
|
|
diversity_stable_count++; |
|
|
|
} |
|
|
|
|
|
|
|
if(diversity_stable_count < -5) { |
|
|
|
receiverSelector(0); |
|
|
|
|
|
|
|
// Reset counter
|
|
|
|
diversity_stable_count = 0; |
|
|
|
} else if(diversity_stable_count > 5) { |
|
|
|
receiverSelector(1); |
|
|
|
|
|
|
|
// Reset counter
|
|
|
|
diversity_stable_count = 0; |
|
|
|
} |
|
|
|
|
|
|
|
last_rssi_read = millis() + 10; |
|
|
|
} |
|
|
|
|
|
|
|