|
|
|
@ -18,6 +18,8 @@ |
|
|
|
#include <WebServer.h>
|
|
|
|
#include <Update.h>
|
|
|
|
|
|
|
|
bool wifi_enable = false; |
|
|
|
bool webserver_setup = false; |
|
|
|
|
|
|
|
// Starting up Web Server
|
|
|
|
WebServer server(80); |
|
|
|
@ -325,12 +327,18 @@ input[type=button] { |
|
|
|
|
|
|
|
|
|
|
|
/*** Index Page ***/ |
|
|
|
const char* index_html PROGMEM = R"rawliteral(<pre><strong>OpenFlightTX v1.0.6</strong> |
|
|
|
const char* index_html PROGMEM = R"rawliteral(<pre><strong>OpenFlightTX v1.0.7</strong> |
|
|
|
)rawliteral"; |
|
|
|
|
|
|
|
// WebPages ----- END
|
|
|
|
|
|
|
|
void unload_webserver(void) { |
|
|
|
// Unload webserver....
|
|
|
|
server.stop(); |
|
|
|
|
|
|
|
// Unload WiFi...
|
|
|
|
WiFi.disconnect(); |
|
|
|
} |
|
|
|
|
|
|
|
void setup_webserver(void) { |
|
|
|
//************ TEMPORARY HARDCODE
|
|
|
|
@ -437,9 +445,10 @@ struct menu_entry_type menu_entry_alpha_list[] = { |
|
|
|
{ u8g2_font_open_iconic_all_2x_t, 224, "RC Controller"}, |
|
|
|
{ u8g2_font_open_iconic_all_2x_t, 94, "Bluetooth"}, |
|
|
|
{ u8g2_font_open_iconic_all_2x_t, 155, "Stick Calibration"}, |
|
|
|
{ u8g2_font_open_iconic_all_2x_t, 246, "Stick Settings"}, |
|
|
|
{ u8g2_font_open_iconic_all_2x_t, 242, "Stick Positions"}, |
|
|
|
{ u8g2_font_open_iconic_all_2x_t, 246, "Trims"}, |
|
|
|
{ u8g2_font_open_iconic_all_2x_t, 281, "WiFi"}, |
|
|
|
{ u8g2_font_open_iconic_all_2x_t, 141, "Frequency"}, |
|
|
|
{ u8g2_font_open_iconic_all_2x_t, 281, "RX Checker"}, |
|
|
|
{ u8g2_font_open_iconic_all_2x_t, 253, "RF Modules"}, |
|
|
|
{ u8g2_font_open_iconic_all_2x_t, 207, "RF Scanners"}, |
|
|
|
{ u8g2_font_open_iconic_all_2x_t, 104, "Debug"}, |
|
|
|
@ -449,22 +458,6 @@ struct menu_entry_type menu_entry_alpha_list[] = { |
|
|
|
{ NULL, 0, NULL } |
|
|
|
}; |
|
|
|
|
|
|
|
struct menu_entry_type menu_entry_alpha_huge_list[] = { |
|
|
|
{ u8g2_font_open_iconic_all_8x_t, 224, "RC Controller"}, |
|
|
|
{ u8g2_font_open_iconic_all_8x_t, 94, "Bluetooth"}, |
|
|
|
{ u8g2_font_open_iconic_all_8x_t, 155, "Stick Calibration"}, |
|
|
|
{ u8g2_font_open_iconic_all_8x_t, 246, "Stick Settings"}, |
|
|
|
{ u8g2_font_open_iconic_all_8x_t, 141, "Frequency"}, |
|
|
|
{ u8g2_font_open_iconic_all_8x_t, 281, "RX Checker"}, |
|
|
|
{ u8g2_font_open_iconic_all_8x_t, 253, "RF Modules"}, |
|
|
|
{ u8g2_font_open_iconic_all_8x_t, 207, "RF Scanners"}, |
|
|
|
{ u8g2_font_open_iconic_all_8x_t, 104, "Debug"}, |
|
|
|
{ u8g2_font_open_iconic_all_8x_t, 90, "Battery"}, |
|
|
|
{ u8g2_font_open_iconic_all_8x_t, 142, "Save Settings"}, |
|
|
|
{ u8g2_font_open_iconic_all_8x_t, 205, "Reset Default"}, |
|
|
|
{ NULL, 0, NULL } |
|
|
|
}; |
|
|
|
|
|
|
|
struct menu_state current_alpha_state = { ICON_BGAP, ICON_BGAP, 0 }; |
|
|
|
struct menu_state destination_alpha_state = { ICON_BGAP, ICON_BGAP, 0 }; |
|
|
|
|
|
|
|
@ -867,7 +860,9 @@ void read_all_voltage() { |
|
|
|
throttle_raw = analogRead(THROTTLE_PIN); |
|
|
|
yaw_raw = analogRead(YAW_PIN); |
|
|
|
pitch_raw = analogRead(PITCH_PIN); |
|
|
|
roll_raw = analogRead(ROLL_PIN); |
|
|
|
// roll_raw = analogRead(ROLL_PIN);
|
|
|
|
// Hardcode to increase the value a bit...
|
|
|
|
roll_raw = analogRead(ROLL_PIN) + 150; |
|
|
|
|
|
|
|
vbat_raw = analogRead(VBAT_PIN); |
|
|
|
|
|
|
|
@ -980,10 +975,6 @@ void setup() { |
|
|
|
/* Start an alarm */ |
|
|
|
timerAlarmEnable(timer); |
|
|
|
|
|
|
|
/* Setting up OTA */ |
|
|
|
setup_webserver(); |
|
|
|
|
|
|
|
|
|
|
|
// u8g2_right.firstPage();
|
|
|
|
// u8g2_right.setFontMode(1);
|
|
|
|
// u8g2_right.setFont(u8g2_font_helvB10_tr);
|
|
|
|
@ -994,8 +985,6 @@ void setup() { |
|
|
|
// u8g2_right.nextPage();
|
|
|
|
} |
|
|
|
|
|
|
|
bool show_ip = false; |
|
|
|
|
|
|
|
void loop() { |
|
|
|
|
|
|
|
// Each seconds tick
|
|
|
|
@ -1007,15 +996,25 @@ void loop() { |
|
|
|
|
|
|
|
last_seconds = millis() + 1000; |
|
|
|
|
|
|
|
|
|
|
|
if(!show_ip) { |
|
|
|
// This is the way to reduce CPU cycles. Only enable it when require
|
|
|
|
if(wifi_enable) { |
|
|
|
if(!webserver_setup) { |
|
|
|
/* Setting up OTA */ |
|
|
|
setup_webserver(); |
|
|
|
webserver_setup = true; |
|
|
|
} else { |
|
|
|
if(WiFi.status() == WL_CONNECTED) { |
|
|
|
Serial.println(WiFi.localIP()); |
|
|
|
show_ip = true; |
|
|
|
server.handleClient(); |
|
|
|
} else { |
|
|
|
Serial.println(F("WiFi not connected")); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if(webserver_setup) { |
|
|
|
unload_webserver(); |
|
|
|
webserver_setup = false; |
|
|
|
} |
|
|
|
} |
|
|
|
// Only try to handles it every 1 seconda
|
|
|
|
server.handleClient(); |
|
|
|
} |
|
|
|
|
|
|
|
read_all_voltage(); |
|
|
|
@ -1094,6 +1093,19 @@ void loop() { |
|
|
|
// Battery
|
|
|
|
show_battery_level(115, 56); |
|
|
|
|
|
|
|
// WiFi (if connected)
|
|
|
|
if(wifi_enable) { |
|
|
|
u8g2_left.setFont(u8g2_font_open_iconic_all_1x_t); |
|
|
|
u8g2_left.drawGlyph(105, 64, 281); |
|
|
|
|
|
|
|
// If connected then print the IP
|
|
|
|
if(WiFi.status() == WL_CONNECTED) { |
|
|
|
u8g2_left.setFont(u8g2_font_5x7_tf); |
|
|
|
u8g2_left.setCursor(0, 55); |
|
|
|
u8g2_left.print(WiFi.localIP()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
u8g2_left.nextPage(); |
|
|
|
|
|
|
|
towards(¤t_alpha_state, &destination_alpha_state); |
|
|
|
@ -1129,12 +1141,15 @@ void loop() { |
|
|
|
} else if(menu_entry_alpha_list[destination_alpha_state.position].name == "Reset Default") { |
|
|
|
require_unlock = false; |
|
|
|
reset_default(); |
|
|
|
} else if(menu_entry_alpha_list[destination_alpha_state.position].name == "Stick Settings") { |
|
|
|
} else if(menu_entry_alpha_list[destination_alpha_state.position].name == "Stick Positions") { |
|
|
|
require_unlock = true; |
|
|
|
stick_position(); |
|
|
|
} else if(menu_entry_alpha_list[destination_alpha_state.position].name == "Trims") { |
|
|
|
require_unlock = true; |
|
|
|
stick_position_and_limit_settings(); |
|
|
|
} else if(menu_entry_alpha_list[destination_alpha_state.position].name == "RX Checker") { |
|
|
|
stick_trims(); |
|
|
|
} else if(menu_entry_alpha_list[destination_alpha_state.position].name == "WiFi") { |
|
|
|
require_unlock = false; |
|
|
|
// rx_checker();
|
|
|
|
wifi_enabler(); |
|
|
|
} else if(menu_entry_alpha_list[destination_alpha_state.position].name == "Frequency") { |
|
|
|
require_unlock = false; |
|
|
|
frequency_settings(); |
|
|
|
@ -1302,7 +1317,169 @@ void rc_controller(void) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void stick_position_and_limit_settings(void) { |
|
|
|
void stick_trims(void) { |
|
|
|
static int8_t stick_position_pointer = 0; |
|
|
|
|
|
|
|
// Data processing
|
|
|
|
if(stick_navigation_position == MENU_LEFT) { |
|
|
|
if(stick_position_pointer == 0) { |
|
|
|
trim_throttle--; |
|
|
|
} else if(stick_position_pointer == 1) { |
|
|
|
trim_yaw--; |
|
|
|
} else if(stick_position_pointer == 2) { |
|
|
|
trim_pitch--; |
|
|
|
} else if(stick_position_pointer == 3) { |
|
|
|
trim_roll--; |
|
|
|
} |
|
|
|
} else if(stick_navigation_position == MENU_RIGHT) { |
|
|
|
if(stick_position_pointer == 0) { |
|
|
|
trim_throttle++; |
|
|
|
} else if(stick_position_pointer == 1) { |
|
|
|
trim_yaw++; |
|
|
|
} else if(stick_position_pointer == 2) { |
|
|
|
trim_pitch++; |
|
|
|
} else if(stick_position_pointer == 3) { |
|
|
|
trim_roll++; |
|
|
|
} |
|
|
|
} else if(stick_navigation_position == MENU_OK) { |
|
|
|
stick_position_pointer++; |
|
|
|
} |
|
|
|
|
|
|
|
// Done...Lets wait for next
|
|
|
|
stick_navigation_position = MENU_NONE; |
|
|
|
|
|
|
|
// Limit counts
|
|
|
|
if(stick_position_pointer > 3) stick_position_pointer = 0; |
|
|
|
|
|
|
|
if(trim_throttle < -15) trim_throttle = -15; |
|
|
|
if(trim_throttle > 15) trim_throttle = 15; |
|
|
|
if(trim_yaw < -15) trim_yaw = -15; |
|
|
|
if(trim_yaw > 15) trim_yaw = 15; |
|
|
|
if(trim_pitch < -15) trim_pitch = -15; |
|
|
|
if(trim_pitch > 15) trim_pitch = 15; |
|
|
|
if(trim_roll < -15) trim_roll = -15; |
|
|
|
if(trim_roll > 15) trim_roll = 15; |
|
|
|
|
|
|
|
// Displaying...
|
|
|
|
u8g2_left.clearBuffer(); |
|
|
|
u8g2_left.firstPage(); |
|
|
|
u8g2_left.setFont(u8g2_font_ImpactBits_tr); |
|
|
|
u8g2_left.setCursor(24, 11); |
|
|
|
u8g2_left.print(F("Stick Trims")); |
|
|
|
u8g2_left.setFont(u8g2_font_5x7_tf); |
|
|
|
u8g2_left.setCursor(0, 25); |
|
|
|
u8g2_left.print(F("THR:")); |
|
|
|
u8g2_left.setCursor(0, 35); |
|
|
|
u8g2_left.print(F("YAW:")); |
|
|
|
u8g2_left.setCursor(0, 45); |
|
|
|
u8g2_left.print(F("PIT:")); |
|
|
|
u8g2_left.setCursor(0, 55); |
|
|
|
u8g2_left.print(F("ROL:")); |
|
|
|
|
|
|
|
// Drawing the Bars
|
|
|
|
// Throttle Trims
|
|
|
|
int8_t trim_values = trim_throttle; |
|
|
|
|
|
|
|
u8g2_left.drawFrame(20, 18, 34, 8); |
|
|
|
if(trim_throttle >= 0) { |
|
|
|
u8g2_left.drawBox(37, 20, trim_throttle, 4); |
|
|
|
} else { |
|
|
|
u8g2_left.drawBox(37 + trim_throttle, 20, -(trim_throttle), 4); |
|
|
|
} |
|
|
|
|
|
|
|
u8g2_left.drawFrame(20, 28, 34, 9); |
|
|
|
if(trim_yaw >= 0) { |
|
|
|
u8g2_left.drawBox(37, 30, trim_yaw, 4); |
|
|
|
} else { |
|
|
|
u8g2_left.drawBox(37 + trim_yaw, 30, -(trim_yaw), 4); |
|
|
|
} |
|
|
|
|
|
|
|
u8g2_left.drawFrame(20, 38, 34, 9); |
|
|
|
if(trim_pitch >= 0) { |
|
|
|
u8g2_left.drawBox(37, 40, trim_pitch, 4); |
|
|
|
} else { |
|
|
|
u8g2_left.drawBox(37 + trim_pitch, 40, -(trim_pitch), 4); |
|
|
|
} |
|
|
|
|
|
|
|
u8g2_left.drawFrame(20, 48, 34, 9); |
|
|
|
if(trim_roll >= 0) { |
|
|
|
u8g2_left.drawBox(37, 50, trim_roll, 4); |
|
|
|
} else { |
|
|
|
u8g2_left.drawBox(37 + trim_roll, 50, -(trim_roll), 4); |
|
|
|
} |
|
|
|
|
|
|
|
// Pointers
|
|
|
|
// u8g2_left.setCursor(25, 25 + (stick_position_pointer * 10));
|
|
|
|
// u8g2_left.print(F("<"));
|
|
|
|
// u8g2_left.setFont(u8g2_font_m2icon_9_tf);
|
|
|
|
// u8g2_left.drawGlyph(38, 27 + (stick_position_pointer * 10), 97); // <- Pointer icon
|
|
|
|
|
|
|
|
/*
|
|
|
|
static char buf[6]; |
|
|
|
strcpy(buf, ltoa(trim_throttle, buf, 10)); |
|
|
|
u8g2_right.drawStr(100, 35,buf); |
|
|
|
|
|
|
|
if(reset_selections) { |
|
|
|
u8g2_left.drawFrame(26, 40, 30, 20); |
|
|
|
} else { |
|
|
|
u8g2_left.drawFrame(62, 40, 30, 20); |
|
|
|
} |
|
|
|
*/ |
|
|
|
draw_gimbalbox(60, 25, 33); |
|
|
|
draw_gimbalbox(95, 25, 33); |
|
|
|
|
|
|
|
uint16_t gimbal_y_raw = throttle_value; |
|
|
|
uint16_t gimbal_x_raw = yaw_value; |
|
|
|
if(gimbal_y_raw < throttle_min) gimbal_y_raw = throttle_min; |
|
|
|
if(gimbal_y_raw > throttle_max) gimbal_y_raw = throttle_max; |
|
|
|
if(gimbal_x_raw < yaw_min) gimbal_x_raw = yaw_min; |
|
|
|
if(gimbal_x_raw > yaw_max) gimbal_x_raw = yaw_max; |
|
|
|
|
|
|
|
uint8_t gimbal_y; |
|
|
|
if(!invert_throttle) |
|
|
|
gimbal_y = map(gimbal_y_raw, throttle_min, throttle_max, 0, 31); // Throttle
|
|
|
|
else |
|
|
|
gimbal_y = map(gimbal_y_raw, throttle_max, throttle_min, 0, 31); // Throttle
|
|
|
|
|
|
|
|
uint8_t gimbal_x; |
|
|
|
if(!invert_yaw) |
|
|
|
gimbal_x = map(gimbal_x_raw, yaw_min, yaw_max, 0, 31); // Yaw
|
|
|
|
else |
|
|
|
gimbal_x = map(gimbal_x_raw, yaw_max, yaw_min, 0, 31); // Yaw
|
|
|
|
|
|
|
|
// u8g2_left.drawFilledEllipse(64 + gimbal_x, gimbal_y, 2, 2, U8G2_DRAW_ALL);
|
|
|
|
u8g2_left.drawFilledEllipse(60 + gimbal_x, 25 + gimbal_y, 2, 2, U8G2_DRAW_ALL); |
|
|
|
|
|
|
|
|
|
|
|
// Mapping based on the live values
|
|
|
|
gimbal_y_raw = pitch_value; |
|
|
|
gimbal_x_raw = roll_value; |
|
|
|
if(gimbal_y_raw < pitch_min) gimbal_y_raw = pitch_min; |
|
|
|
if(gimbal_y_raw > pitch_max) gimbal_y_raw = pitch_max; |
|
|
|
if(gimbal_x_raw < roll_min) gimbal_x_raw = roll_min; |
|
|
|
if(gimbal_x_raw > roll_max) gimbal_x_raw = roll_max; |
|
|
|
|
|
|
|
if(!invert_pitch) |
|
|
|
gimbal_y = map(gimbal_y_raw, pitch_min, pitch_max, 0, 31); // Pitch
|
|
|
|
else |
|
|
|
gimbal_y = map(gimbal_y_raw, pitch_max, pitch_min, 0, 31); // Pitch
|
|
|
|
|
|
|
|
if(!invert_roll) |
|
|
|
gimbal_x = map(gimbal_x_raw, roll_min, roll_max, 0, 31); // Roll
|
|
|
|
else |
|
|
|
gimbal_x = map(gimbal_x_raw, roll_max, roll_min, 0, 31); // Roll
|
|
|
|
|
|
|
|
// u8g2_right.drawFilledEllipse(gimbal_x, gimbal_y, 3, 3, U8G2_DRAW_ALL);
|
|
|
|
u8g2_left.drawFilledEllipse(95 + gimbal_x, 25 + gimbal_y, 2, 2, U8G2_DRAW_ALL); |
|
|
|
|
|
|
|
|
|
|
|
u8g2_left.setFont(u8g2_font_m2icon_9_tf); |
|
|
|
u8g2_left.drawGlyph(60, 27 + (stick_position_pointer * 10), 97); // <- Pointer icon
|
|
|
|
|
|
|
|
u8g2_left.nextPage(); |
|
|
|
} |
|
|
|
|
|
|
|
void stick_position(void) { |
|
|
|
static int8_t stick_position_pointer = 0; |
|
|
|
|
|
|
|
// Data processing
|
|
|
|
@ -1369,73 +1546,43 @@ void stick_position_and_limit_settings(void) { |
|
|
|
u8g2_left.clearBuffer(); |
|
|
|
u8g2_left.firstPage(); |
|
|
|
u8g2_left.setFont(u8g2_font_ImpactBits_tr); |
|
|
|
u8g2_left.setCursor(10, 15); |
|
|
|
u8g2_left.setCursor(10, 11); |
|
|
|
u8g2_left.print(F("Stick Positions")); |
|
|
|
u8g2_left.setFont(u8g2_font_5x7_tf); |
|
|
|
u8g2_left.setCursor(0, 25); |
|
|
|
u8g2_left.print(F("THR:")); |
|
|
|
if(invert_throttle) { |
|
|
|
u8g2_left.print(F("INVERT")); |
|
|
|
u8g2_left.print(F("INV")); |
|
|
|
} else { |
|
|
|
u8g2_left.print(F("NORMAL")); |
|
|
|
u8g2_left.print(F("NOR")); |
|
|
|
} |
|
|
|
u8g2_left.setCursor(0, 35); |
|
|
|
u8g2_left.print(F("YAW:")); |
|
|
|
if(invert_yaw) { |
|
|
|
u8g2_left.print(F("INVERT")); |
|
|
|
u8g2_left.print(F("INV")); |
|
|
|
} else { |
|
|
|
u8g2_left.print(F("NORMAL")); |
|
|
|
u8g2_left.print(F("NOR")); |
|
|
|
} |
|
|
|
u8g2_left.setCursor(0, 45); |
|
|
|
u8g2_left.print(F("PIT:")); |
|
|
|
if(invert_pitch) { |
|
|
|
u8g2_left.print(F("INVERT")); |
|
|
|
u8g2_left.print(F("INV")); |
|
|
|
} else { |
|
|
|
u8g2_left.print(F("NORMAL")); |
|
|
|
u8g2_left.print(F("NOR")); |
|
|
|
} |
|
|
|
u8g2_left.setCursor(0, 55); |
|
|
|
u8g2_left.print(F("ROL:")); |
|
|
|
if(invert_roll) { |
|
|
|
u8g2_left.print(F("INVERT")); |
|
|
|
} else { |
|
|
|
u8g2_left.print(F("NORMAL")); |
|
|
|
} |
|
|
|
|
|
|
|
// Drawing the Bars
|
|
|
|
// Throttle Trims
|
|
|
|
int8_t trim_values = trim_throttle; |
|
|
|
|
|
|
|
u8g2_left.drawFrame(65, 17, 34, 9); |
|
|
|
if(trim_throttle >= 0) { |
|
|
|
u8g2_left.drawBox(82, 19, trim_throttle, 5); |
|
|
|
} else { |
|
|
|
u8g2_left.drawBox(82 + trim_throttle, 19, -(trim_throttle), 5); |
|
|
|
} |
|
|
|
|
|
|
|
u8g2_left.drawFrame(65, 27, 34, 9); |
|
|
|
if(trim_yaw >= 0) { |
|
|
|
u8g2_left.drawBox(82, 29, trim_yaw, 5); |
|
|
|
} else { |
|
|
|
u8g2_left.drawBox(82 + trim_yaw, 29, -(trim_yaw), 5); |
|
|
|
} |
|
|
|
|
|
|
|
u8g2_left.drawFrame(65, 37, 34, 9); |
|
|
|
if(trim_pitch >= 0) { |
|
|
|
u8g2_left.drawBox(82, 39, trim_pitch, 5); |
|
|
|
} else { |
|
|
|
u8g2_left.drawBox(82 + trim_pitch, 39, -(trim_pitch), 5); |
|
|
|
} |
|
|
|
|
|
|
|
u8g2_left.drawFrame(65, 47, 34, 9); |
|
|
|
if(trim_roll >= 0) { |
|
|
|
u8g2_left.drawBox(82, 49, trim_roll, 5); |
|
|
|
u8g2_left.print(F("INV")); |
|
|
|
} else { |
|
|
|
u8g2_left.drawBox(82 + trim_roll, 49, -(trim_roll), 5); |
|
|
|
u8g2_left.print(F("NOR")); |
|
|
|
} |
|
|
|
|
|
|
|
// Pointers
|
|
|
|
u8g2_left.setCursor(110, 25 + (stick_position_pointer * 10)); |
|
|
|
u8g2_left.print(F("<")); |
|
|
|
// u8g2_left.setCursor(25, 25 + (stick_position_pointer * 10));
|
|
|
|
// u8g2_left.print(F("<"));
|
|
|
|
u8g2_left.setFont(u8g2_font_m2icon_9_tf); |
|
|
|
u8g2_left.drawGlyph(38, 27 + (stick_position_pointer * 10), 97); // <- Pointer icon
|
|
|
|
|
|
|
|
/*
|
|
|
|
static char buf[6]; |
|
|
|
@ -1448,16 +1595,9 @@ void stick_position_and_limit_settings(void) { |
|
|
|
u8g2_left.drawFrame(62, 40, 30, 20); |
|
|
|
} |
|
|
|
*/ |
|
|
|
draw_gimbalbox(53, 25, 32); |
|
|
|
draw_gimbalbox(90, 25, 32); |
|
|
|
|
|
|
|
u8g2_left.nextPage(); |
|
|
|
|
|
|
|
// u8g2_right.clearBuffer();
|
|
|
|
// u8g2_right.firstPage();
|
|
|
|
|
|
|
|
draw_gimbalbox(0, 0); |
|
|
|
draw_gimbalbox(64, 0); |
|
|
|
|
|
|
|
// Mapping based on the live values
|
|
|
|
uint16_t gimbal_y_raw = throttle_value; |
|
|
|
uint16_t gimbal_x_raw = yaw_value; |
|
|
|
if(gimbal_y_raw < throttle_min) gimbal_y_raw = throttle_min; |
|
|
|
@ -1467,17 +1607,19 @@ void stick_position_and_limit_settings(void) { |
|
|
|
|
|
|
|
uint8_t gimbal_y; |
|
|
|
if(!invert_throttle) |
|
|
|
gimbal_y = map(gimbal_y_raw, throttle_min, throttle_max, 0, 63); // Throttle
|
|
|
|
gimbal_y = map(gimbal_y_raw, throttle_min, throttle_max, 0, 31); // Throttle
|
|
|
|
else |
|
|
|
gimbal_y = map(gimbal_y_raw, throttle_max, throttle_min, 0, 63); // Throttle
|
|
|
|
gimbal_y = map(gimbal_y_raw, throttle_max, throttle_min, 0, 31); // Throttle
|
|
|
|
|
|
|
|
uint8_t gimbal_x; |
|
|
|
if(!invert_yaw) |
|
|
|
gimbal_x = map(gimbal_x_raw, yaw_min, yaw_max, 0, 63); // Yaw
|
|
|
|
gimbal_x = map(gimbal_x_raw, yaw_min, yaw_max, 0, 31); // Yaw
|
|
|
|
else |
|
|
|
gimbal_x = map(gimbal_x_raw, yaw_max, yaw_min, 0, 63); // Yaw
|
|
|
|
gimbal_x = map(gimbal_x_raw, yaw_max, yaw_min, 0, 31); // Yaw
|
|
|
|
|
|
|
|
// u8g2_left.drawFilledEllipse(64 + gimbal_x, gimbal_y, 2, 2, U8G2_DRAW_ALL);
|
|
|
|
u8g2_left.drawFilledEllipse(53 + gimbal_x, 25 + gimbal_y, 2, 2, U8G2_DRAW_ALL); |
|
|
|
|
|
|
|
// u8g2_right.drawFilledEllipse(gimbal_x, gimbal_y, 3, 3, U8G2_DRAW_ALL);
|
|
|
|
|
|
|
|
// Mapping based on the live values
|
|
|
|
gimbal_y_raw = pitch_value; |
|
|
|
@ -1488,18 +1630,22 @@ void stick_position_and_limit_settings(void) { |
|
|
|
if(gimbal_x_raw > roll_max) gimbal_x_raw = roll_max; |
|
|
|
|
|
|
|
if(!invert_pitch) |
|
|
|
gimbal_y = map(gimbal_y_raw, pitch_min, pitch_max, 0, 63); // Pitch
|
|
|
|
gimbal_y = map(gimbal_y_raw, pitch_min, pitch_max, 0, 31); // Pitch
|
|
|
|
else |
|
|
|
gimbal_y = map(gimbal_y_raw, pitch_max, pitch_min, 0, 63); // Pitch
|
|
|
|
gimbal_y = map(gimbal_y_raw, pitch_max, pitch_min, 0, 31); // Pitch
|
|
|
|
|
|
|
|
if(!invert_roll) |
|
|
|
gimbal_x = map(gimbal_x_raw, roll_min, roll_max, 0, 63); // Roll
|
|
|
|
gimbal_x = map(gimbal_x_raw, roll_min, roll_max, 0, 31); // Roll
|
|
|
|
else |
|
|
|
gimbal_x = map(gimbal_x_raw, roll_max, roll_min, 0, 63); // Roll
|
|
|
|
gimbal_x = map(gimbal_x_raw, roll_max, roll_min, 0, 31); // Roll
|
|
|
|
|
|
|
|
// u8g2_right.drawFilledEllipse(64 + gimbal_x, gimbal_y, 3, 3, U8G2_DRAW_ALL);
|
|
|
|
// u8g2_right.drawFilledEllipse(gimbal_x, gimbal_y, 3, 3, U8G2_DRAW_ALL);
|
|
|
|
u8g2_left.drawFilledEllipse(90 + gimbal_x, 25 + gimbal_y, 2, 2, U8G2_DRAW_ALL); |
|
|
|
|
|
|
|
u8g2_left.nextPage(); |
|
|
|
|
|
|
|
// u8g2_right.nextPage();
|
|
|
|
// u8g2_right.clearBuffer();
|
|
|
|
// u8g2_right.firstPage();
|
|
|
|
} |
|
|
|
|
|
|
|
void read_settings(void) { |
|
|
|
@ -2054,7 +2200,7 @@ void show_battery_level(uint8_t x, uint8_t y) { |
|
|
|
u8g2_left.drawLine(x+12, y+2, x+12, y+5); |
|
|
|
|
|
|
|
// Battery level indicator
|
|
|
|
int vbat_bar_value = ((vbat_value * .0012142857) - 3.2) * 10; |
|
|
|
int vbat_bar_value = ((vbat_value * .0012142857) - 3.2) * 8; |
|
|
|
// int vbat_bar_value = vbat_value * 10 / 4096;
|
|
|
|
uint8_t x1 = 0; |
|
|
|
for(int i = 0; i < vbat_bar_value; i++) { |
|
|
|
@ -2063,6 +2209,61 @@ void show_battery_level(uint8_t x, uint8_t y) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void wifi_enabler(void) { |
|
|
|
/*
|
|
|
|
u8g2_left.clearBuffer(); |
|
|
|
u8g2_left.firstPage(); |
|
|
|
u8g2_left.setFont(menu_entry_alpha_huge_list[destination_alpha_state.position].font); |
|
|
|
u8g2_left.drawGlyph(40, ICONX_Y, menu_entry_alpha_huge_list[destination_alpha_state.position].icon); |
|
|
|
u8g2_left.nextPage(); |
|
|
|
*/ |
|
|
|
|
|
|
|
u8g2_left.clearBuffer(); |
|
|
|
u8g2_left.firstPage(); |
|
|
|
u8g2_left.setFontMode(1); |
|
|
|
u8g2_left.setFont(u8g2_font_VCR_OSD_tr); |
|
|
|
|
|
|
|
static char buf[6]; |
|
|
|
|
|
|
|
// u8g2_left.drawStr(45, 15, buf);
|
|
|
|
// strcpy(buf, ltoa(vbat_value, buf, 10));
|
|
|
|
// u8g2_left.drawStr(0, 30, buf);
|
|
|
|
|
|
|
|
static bool wifi_selections = false; |
|
|
|
|
|
|
|
u8g2_left.setFont(u8g2_font_ImpactBits_tr); |
|
|
|
u8g2_left.setCursor(15, 25); |
|
|
|
u8g2_left.print(F("Enable WiFi?")); |
|
|
|
u8g2_left.setCursor(30, 55); |
|
|
|
u8g2_left.print(F("Yes No")); |
|
|
|
|
|
|
|
// TODO: Working on WiFi. Manually on...
|
|
|
|
if(stick_navigation_position == MENU_LEFT) { |
|
|
|
wifi_selections = true; |
|
|
|
} else if(stick_navigation_position == MENU_RIGHT) { |
|
|
|
wifi_selections = false; |
|
|
|
} else if(stick_navigation_position == MENU_OK) { |
|
|
|
// Wifi...
|
|
|
|
if(wifi_selections) { |
|
|
|
wifi_enable = true; |
|
|
|
} else { |
|
|
|
wifi_enable = false; |
|
|
|
} |
|
|
|
|
|
|
|
// Simulate...so it will return back..
|
|
|
|
menu_entry_alpha_selected = false; |
|
|
|
last_menu_stick_read = millis() + 200; |
|
|
|
} |
|
|
|
|
|
|
|
if(wifi_selections) { |
|
|
|
u8g2_left.drawFrame(26, 40, 30, 20); |
|
|
|
} else { |
|
|
|
u8g2_left.drawFrame(62, 40, 30, 20); |
|
|
|
} |
|
|
|
u8g2_left.nextPage(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void battery_management() { |
|
|
|
/*
|
|
|
|
u8g2_left.clearBuffer(); |
|
|
|
@ -2079,20 +2280,31 @@ void battery_management() { |
|
|
|
|
|
|
|
static char buf[6]; |
|
|
|
|
|
|
|
u8g2_left.setCursor(0,15); |
|
|
|
u8g2_left.print(F("VBAT:")); |
|
|
|
u8g2_left.setFont(u8g2_font_ImpactBits_tr); |
|
|
|
u8g2_left.setCursor(0,12); |
|
|
|
u8g2_left.print(F("Battery LEVEL")); |
|
|
|
// u8g2_left.drawStr(45, 15, buf);
|
|
|
|
// strcpy(buf, ltoa(vbat_value, buf, 10));
|
|
|
|
// u8g2_left.drawStr(0, 30, buf);
|
|
|
|
|
|
|
|
float vbat_real_value = vbat_value * .0012142857; |
|
|
|
//strcpy(buf, ltoa(vbat_real_value, buf, 10));
|
|
|
|
dtostrf(vbat_real_value, 3, 2, buf); |
|
|
|
dtostrf(vbat_real_value, 2, 1, buf); |
|
|
|
|
|
|
|
u8g2_left.drawStr(0, 45, buf); |
|
|
|
u8g2_left.setCursor(48, 45); |
|
|
|
u8g2_left.setFont(u8g2_font_maniac_tf); |
|
|
|
u8g2_left.drawStr(0, 64, buf); |
|
|
|
u8g2_left.setCursor(44, 64); |
|
|
|
u8g2_left.print(F("V")); |
|
|
|
|
|
|
|
// The battery frame
|
|
|
|
u8g2_left.drawFrame(96, 0, 32, 64); |
|
|
|
|
|
|
|
// Bars Calculations
|
|
|
|
uint8_t bars = map(vbat_value, 2650, 3460, 0, 31); |
|
|
|
for(int i = 0; i < bars; i++) { |
|
|
|
u8g2_left.drawHLine(98, 61 - (i*2), 28); |
|
|
|
} |
|
|
|
|
|
|
|
u8g2_left.nextPage(); |
|
|
|
} |
|
|
|
|