|
|
@ -68,6 +68,7 @@ void ESPNowRC::show(TFT_eSprite *m) { |
|
|
|
m->printf("B:%.1fV %.0fmA", voltage, current); |
|
|
|
// m->printf(String(voltage) + "V " + String(current) + "mA");
|
|
|
|
|
|
|
|
/***
|
|
|
|
// Draw the gimbal box
|
|
|
|
draw_gimbal(m, 69, 150); |
|
|
|
draw_gimbal(m, 161, 150); |
|
|
@ -75,52 +76,92 @@ void ESPNowRC::show(TFT_eSprite *m) { |
|
|
|
// Convert the throttle and raw to x and y
|
|
|
|
// Temporary assume 4096 = max
|
|
|
|
uint16_t left_gimbal_y = map(inputs.throttle, stickcalibration.throttle_min, stickcalibration.throttle_max, 90, 0); |
|
|
|
uint16_t left_gimbal_x = map(inputs.yaw, stickcalibration.yaw_min, stickcalibration.yaw_max, 90, 0); |
|
|
|
// uint16_t left_gimbal_x = map(inputs.yaw, stickcalibration.yaw_min, stickcalibration.yaw_max, 90, 0);
|
|
|
|
uint16_t left_gimbal_x = map(inputs.yaw, stickcalibration.yaw_min, stickcalibration.yaw_max + inputs.trim_yaw, 90, 0); |
|
|
|
m->fillCircle(left_gimbal_x + 69, left_gimbal_y + 150, 5, TFT_YELLOW); |
|
|
|
uint16_t right_gimbal_y = map(inputs.pitch, stickcalibration.pitch_min, stickcalibration.pitch_max, 0, 90); |
|
|
|
uint16_t right_gimbal_x = map(inputs.roll, stickcalibration.roll_min, stickcalibration.roll_max, 0, 90); |
|
|
|
m->fillCircle(right_gimbal_x + 161, right_gimbal_y + 150, 5, TFT_YELLOW); |
|
|
|
***/ |
|
|
|
|
|
|
|
// Draw the switches
|
|
|
|
uint32_t last_millis = millis(); |
|
|
|
|
|
|
|
if(!espnow2.data_to_send.aux[0]) { |
|
|
|
if(!espnow2.aux_state[0]) { |
|
|
|
m->drawRect(0, 40, 60, 60, TFT_BLUE); // Button 1 - OFF
|
|
|
|
} else { |
|
|
|
m->drawRect(0, 40, 60, 60, TFT_BLUE); // Button 1 - ON
|
|
|
|
m->fillRect(1, 41, 60, 60, TFT_BLUE); |
|
|
|
} |
|
|
|
|
|
|
|
if(!espnow2.data_to_send.aux[1]) { |
|
|
|
if(!espnow2.aux_state[1]) { |
|
|
|
m->drawRect(65, 40, 60, 60, TFT_BLUE); // Button 2
|
|
|
|
} else { |
|
|
|
m->drawRect(65, 40, 60, 60, TFT_BLUE); // Button 2
|
|
|
|
m->fillRect(66, 41, 60, 60, TFT_BLUE); |
|
|
|
} |
|
|
|
|
|
|
|
if(!espnow2.data_to_send.aux[2]) { |
|
|
|
if(!espnow2.aux_state[2]) { |
|
|
|
m->drawRect(130, 40, 60, 60, TFT_BLUE); // Button 3
|
|
|
|
} else { |
|
|
|
m->drawRect(130, 40, 60, 60, TFT_BLUE); // Button 3
|
|
|
|
m->fillRect(131, 41, 60, 60, TFT_BLUE); |
|
|
|
} |
|
|
|
|
|
|
|
if(!espnow2.data_to_send.aux[3]) { |
|
|
|
if(!espnow2.aux_state[3]) { |
|
|
|
m->drawRect(195, 40, 60, 60, TFT_BLUE); // Button 4
|
|
|
|
} else { |
|
|
|
m->drawRect(195, 40, 60, 60, TFT_BLUE); // Button 4
|
|
|
|
m->fillRect(196, 41, 60, 60, TFT_BLUE); |
|
|
|
} |
|
|
|
|
|
|
|
if(!espnow2.data_to_send.aux[4]) { |
|
|
|
if(!espnow2.aux_state[4]) { |
|
|
|
////if(!espnow2.rubybutton_state[0]) {
|
|
|
|
m->drawRect(260, 40, 60, 60, TFT_BLUE); // Button 5
|
|
|
|
} else { |
|
|
|
m->drawRect(260, 40, 60, 60, TFT_BLUE); // Button 5
|
|
|
|
m->fillRect(261, 41, 60, 60, TFT_BLUE); |
|
|
|
} |
|
|
|
|
|
|
|
m->setCursor(90, 130); |
|
|
|
m->print("ESPNowRC"); |
|
|
|
//// m->setCursor(90, 130);
|
|
|
|
//// m->print("ESPNowRC");
|
|
|
|
|
|
|
|
// Temporary RubyFPV Buttons
|
|
|
|
if(!espnow2.rubybutton_state[0]) { |
|
|
|
m->drawRect(0, 120, 60, 60, TFT_BLUE); // Button 1 - OFF
|
|
|
|
} else { |
|
|
|
m->drawRect(0, 120, 60, 60, TFT_BLUE); // Button 1 - ON
|
|
|
|
m->fillRect(1, 121, 60, 60, TFT_BLUE); |
|
|
|
} |
|
|
|
|
|
|
|
if(!espnow2.rubybutton_state[1]) { |
|
|
|
m->drawRect(65, 120, 60, 60, TFT_BLUE); // Button 2
|
|
|
|
} else { |
|
|
|
m->drawRect(65, 120, 60, 60, TFT_BLUE); // Button 2
|
|
|
|
m->fillRect(66, 121, 60, 60, TFT_BLUE); |
|
|
|
} |
|
|
|
|
|
|
|
if(!espnow2.rubybutton_state[2]) { |
|
|
|
m->drawRect(130, 120, 60, 60, TFT_BLUE); // Button 3
|
|
|
|
} else { |
|
|
|
m->drawRect(130, 120, 60, 60, TFT_BLUE); // Button 3
|
|
|
|
m->fillRect(131, 121, 60, 60, TFT_BLUE); |
|
|
|
} |
|
|
|
|
|
|
|
if(!espnow2.rubybutton_state[3]) { |
|
|
|
m->drawRect(195, 120, 60, 60, TFT_BLUE); // Button 4
|
|
|
|
} else { |
|
|
|
m->drawRect(195, 120, 60, 60, TFT_BLUE); // Button 4
|
|
|
|
m->fillRect(196, 121, 60, 60, TFT_BLUE); |
|
|
|
} |
|
|
|
|
|
|
|
if(!espnow2.rubybutton_state[4]) { |
|
|
|
////if(!espnow2.rubybutton_state[0]) {
|
|
|
|
m->drawRect(260, 120, 60, 60, TFT_BLUE); // Button 5
|
|
|
|
} else { |
|
|
|
m->drawRect(260, 120, 60, 60, TFT_BLUE); // Button 5
|
|
|
|
m->fillRect(261, 121, 60, 60, TFT_BLUE); |
|
|
|
} |
|
|
|
|
|
|
|
m->pushSprite(0,0); |
|
|
|
|
|
|
@ -175,52 +216,71 @@ void ESPNowRC::show(TFT_eSprite *m) { |
|
|
|
// - MinY: 150
|
|
|
|
// - MaxX: 160
|
|
|
|
// - MaxY: 190
|
|
|
|
|
|
|
|
|
|
|
|
/****
|
|
|
|
if(e.to.x >= 110 && e.to.x <= 120 && e.to.y >= 140 && e.to.y <= 180) { |
|
|
|
// Minus throttle
|
|
|
|
// Serial.printf("Left: TOP\n");
|
|
|
|
inputs.trim_throttle-=20; |
|
|
|
inputs.trim_throttle-=10; |
|
|
|
//// speak.speak_trim_word = TRIM_THROTTLE_INCREASE;
|
|
|
|
//// speak.speak_now_trim = true;
|
|
|
|
} else if(e.to.x >= 110 && e.to.x <= 170 && e.to.y >= 200 && e.to.y <= 220) { |
|
|
|
// Add throttle
|
|
|
|
// Serial.printf("Left: BOTTOM\n");
|
|
|
|
inputs.trim_throttle+=20; |
|
|
|
inputs.trim_throttle+=10; |
|
|
|
//// speak.speak_trim_word = TRIM_THROTTLE_DECREASE;
|
|
|
|
//// speak.speak_now_trim = true;
|
|
|
|
} else if(e.to.x >= 60 && e.to.x <= 105 && e.to.y >= 180 && e.to.y <= 210) { |
|
|
|
// Minus Yaw
|
|
|
|
// Serial.printf("Left: LEFT\n");
|
|
|
|
inputs.trim_yaw-=20; |
|
|
|
inputs.trim_yaw+=10; |
|
|
|
//// speak.speak_trim_word = TRIM_YAW_DECREASE;
|
|
|
|
//// speak.speak_now_trim = true;
|
|
|
|
Serial.printf("Trim Yaw: %d\n", inputs.trim_yaw); |
|
|
|
} else if(e.to.x >= 110 && e.to.x <= 160 && e.to.y >= 150 && e.to.y <= 190) { |
|
|
|
// Add Yaw
|
|
|
|
// Serial.printf("Left: RIGHT\n");
|
|
|
|
inputs.trim_yaw+=20; |
|
|
|
inputs.trim_yaw-=10; |
|
|
|
//// speak.speak_trim_word = TRIM_YAW_INCREASE;
|
|
|
|
//// speak.speak_now_trim = true;
|
|
|
|
} else if(e.to.x >= 250 && e.to.x <= 230 && e.to.y >= 187 && e.to.y <= 197) { |
|
|
|
Serial.printf("Trim Yaw: %d\n", inputs.trim_yaw); |
|
|
|
} else if(e.to.x >= 214 && e.to.x <= 245 && e.to.y >= 148 && e.to.y <= 181) { |
|
|
|
// Add Row
|
|
|
|
inputs.trim_roll+=20; |
|
|
|
inputs.trim_roll+=10; |
|
|
|
//// speak.speak_trim_word = TRIM_ROLL_INCREASE;
|
|
|
|
//// speak.speak_now_trim = true;
|
|
|
|
} else if(e.to.x >= 180 && e.to.x <= 175 && e.to.y >= 187 && e.to.y <= 197) { |
|
|
|
Serial.printf("Trim Roll: %d\n", inputs.trim_yaw); |
|
|
|
} else if(e.to.x >= 170 && e.to.x <= 180 && e.to.y >= 148 && e.to.y <= 181) { |
|
|
|
// Minus Row
|
|
|
|
inputs.trim_roll+=20; |
|
|
|
inputs.trim_roll-=10; |
|
|
|
//// speak.speak_trim_word = TRIM_ROLL_DECREASE;
|
|
|
|
//// speak.speak_now_trim = true;
|
|
|
|
// TODO: Continue the rest.....
|
|
|
|
} else if(e.to.x >= 0 && e.to.x <= 60 && e.to.y >= 40 && e.to.y <= 100) { |
|
|
|
espnow2.data_to_send.aux[0] = !espnow2.data_to_send.aux[0]; // Flip Switch 0
|
|
|
|
Serial.printf("Trim Roll: %d\n", inputs.trim_yaw); |
|
|
|
} else ****/ |
|
|
|
if(e.to.x >= 0 && e.to.x <= 60 && e.to.y >= 40 && e.to.y <= 100) { |
|
|
|
espnow2.aux_state[0] = !espnow2.aux_state[0]; // Flip Switch 0
|
|
|
|
} else if(e.to.x >= 65 && e.to.x <= 125 && e.to.y >= 40 && e.to.y <= 100) { |
|
|
|
espnow2.data_to_send.aux[1] = !espnow2.data_to_send.aux[1]; // Flip Switch 1
|
|
|
|
espnow2.aux_state[1] = !espnow2.aux_state[1]; // Flip Switch 1
|
|
|
|
} else if(e.to.x >= 130 && e.to.x <= 190 && e.to.y >= 40 && e.to.y <= 100) { |
|
|
|
espnow2.data_to_send.aux[2] = !espnow2.data_to_send.aux[2]; // Flip Switch 2
|
|
|
|
espnow2.aux_state[2] = !espnow2.aux_state[2]; // Flip Switch 2
|
|
|
|
} else if(e.to.x >= 195 && e.to.x <= 255 && e.to.y >= 40 && e.to.y <= 100) { |
|
|
|
espnow2.data_to_send.aux[3] = !espnow2.data_to_send.aux[3]; // Flip Switch 3
|
|
|
|
espnow2.aux_state[3] = !espnow2.aux_state[3]; // Flip Switch 3
|
|
|
|
} else if(e.to.x >= 260 && e.to.x <= 310 && e.to.y >= 40 && e.to.y <= 100) { |
|
|
|
espnow2.data_to_send.aux[4] = !espnow2.data_to_send.aux[4]; // Flip Switch 4
|
|
|
|
espnow2.aux_state[4] = !espnow2.aux_state[4]; // Flip Switch 4
|
|
|
|
} else if(e.to.x >= 0 && e.to.x <= 60 && e.to.y >= 120 && e.to.y <= 180) { |
|
|
|
espnow2.rubybutton_state[0] = true; |
|
|
|
espnow2.last_rubybutton[0] = millis(); |
|
|
|
} else if(e.to.x >= 65 && e.to.x <= 125 && e.to.y >= 120 && e.to.y <= 180) { |
|
|
|
espnow2.rubybutton_state[1] = true; |
|
|
|
espnow2.last_rubybutton[1] = millis(); |
|
|
|
} else if(e.to.x >= 130 && e.to.x <= 190 && e.to.y >= 120 && e.to.y <= 180) { |
|
|
|
espnow2.rubybutton_state[2] = true; |
|
|
|
espnow2.last_rubybutton[2] = millis(); |
|
|
|
} else if(e.to.x >= 195 && e.to.x <= 255 && e.to.y >= 120 && e.to.y <= 180) { |
|
|
|
espnow2.rubybutton_state[3] = true; |
|
|
|
espnow2.last_rubybutton[3] = millis(); |
|
|
|
} |
|
|
|
touch_time = millis(); |
|
|
|
} |
|
|
|