Browse Source

Added charging mode and also update station

master
Englebert 7 months ago
parent
commit
f26a8aff68
  1. 97
      src/main.cpp
  2. 2
      src/main.h

97
src/main.cpp

@ -105,6 +105,7 @@ int16_t sent_counter = 0;
int16_t ruby_pitch = 0;
int16_t ruby_roll = 0;
int16_t ruby_yaw = 0;
uint32_t last_seconds = 0;
uint32_t last_updated = 0;
@ -756,7 +757,7 @@ void load_rcsettings(void) {
sprite.drawString(strbuf, 150, 8);
sprite.fillRoundRect(0, 60, 320, 50, 10, 0x090A);
sprintf(strbuf, "UPDATE VEHICLE");
sprintf(strbuf, "UPDATE STATION");
sprite.drawString(strbuf, 8, 70);
sprite.fillRoundRect(0, 0, 50, 50, 10, 0x090A);
@ -887,6 +888,74 @@ void load_rcsettings(void) {
}
void load_charging(void) {
char strbuf[255];
sprite.setTextDatum(TL_DATUM);
sprite.fillSprite(TFT_BLACK);
sprite.setSwapBytes(false);
sprite.setTextSize(2);
sprite.setTextColor(TFT_ORANGE);
sprintf(strbuf, "### CHARGING MODE ###");
sprite.drawString(strbuf, 0, 150);
sprintf(strbuf, "B: %dmV R: %d BT: %d", batt_volt, profile_gimbal_rate, ble_counter);
sprite.drawString(strbuf, 0, 134);
sprite.unloadFont();
sprite.pushSprite(0, 0);
// Reading input from the touch screen
if(touch.read()) {
TP_Point t = touch.getPoint(0);
// Since the watch design is horizontally, the touch x position needs to invert
int x = map(t.y, 0, 320, 320, 0);
int y = t.x;
display_touch_count++;
if(!touch_state) {
last_touch = millis();
last_x = x;
last_y = y;
touch_state = true;
} else {
if(
(uint32_t)(millis() - last_touch) > 250
) {
if((uint32_t)(millis() - last_toggle) > 500) {
// Switch Screen Locations
if(
x > 0 && y > 140 &&
x < 30 && y < 170
) {
current_screen--;
// Transmission mode back to ESPNOW for enabling back...
transmission_mode = MODE_ESPNOW;
// Switch Screen Locations
} else if(
x > 290 && y > 140 &&
x < 320 && y < 170
) {
current_screen++;
}
}
touch_gestures(x, y);
// Reset state for next cycle to detect
touch_state = false;
}
}
} // End of Touch Read
}
void load_mainscreen(void) {
char strbuf[255];
@ -1652,6 +1721,12 @@ void taskDisplay(void *pvParameters) {
load_rcsettings();
break;
case SCREEN_CHARGING:
// Transmission mode to NONE for more juice to battery
transmission_mode = MODE_NONE;
load_charging();
break;
/****
case SCREEN_GPS:
screen_gps();
@ -1700,6 +1775,7 @@ void taskESPNow(void *pvParameters) {
// Roll Right: MENU/OK
ruby_pitch = pitch_val;
ruby_roll = roll_val;
ruby_yaw = yaw_val;
// UP
if(ruby_pitch > 1750) {
@ -1731,6 +1807,25 @@ void taskESPNow(void *pvParameters) {
rubybutton_state[1] = 0;
rubybutton_state[0] = 0;
}
// YAW LEFT
// QA2
if(ruby_yaw > 1750) {
rubybutton_state[4] = 0;
rubybutton_state[5] = 1;
// YAW RIGHT
// QA1
} else if(ruby_yaw < 1250) {
rubybutton_state[4] = 1;
rubybutton_state[5] = 0;
// RESET QA1 and QA2
} else if(ruby_yaw > 1250 && ruby_yaw < 1750) {
rubybutton_state[4] = 1;
rubybutton_state[5] = 0;
}
}
// Converting Ruby Button state to send.

2
src/main.h

@ -110,6 +110,7 @@ enum screen_names {
SCREEN_MAINSCREEN,
SCREEN_RCCONTROLLER,
SCREEN_SETTINGS,
SCREEN_CHARGING,
SCREEN_LAST,
};
@ -198,6 +199,7 @@ void screen_system(void);
void load_mainscreen(void);
void load_rccontroller(void);
void load_rcsettings(void);
void load_charging(void);
void draw_gimbal_huge(uint16_t x, uint16_t y);
int16_t get_median(uint8_t gimbal);

Loading…
Cancel
Save