You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
578 lines
16 KiB
578 lines
16 KiB
#include "flyHunterWidget.h"
|
|
#include "../../components/object/objectFlyHunter.h"
|
|
#include "OSDWidget.h"
|
|
|
|
CSTR c_comName = NULL;
|
|
bool a_bg = false;
|
|
void reconnect(void) {
|
|
mHNT->connectVia(c_comName);
|
|
//a_bg = !a_bg;
|
|
//classGUI_SDL::getInstance()->alterateBackground(a_bg);
|
|
};
|
|
static CSTR basic_mode_names[8] = {
|
|
(CSTR)"CUSTOM",
|
|
(CSTR)"TEST",
|
|
(CSTR)"AUTO",
|
|
(CSTR)"GUIDED",
|
|
(CSTR)"STABIL",
|
|
(CSTR)"HIL",
|
|
(CSTR)"MANUAL",
|
|
(CSTR)"ARMED"
|
|
};
|
|
sdlFlyHunterWidget::sdlFlyHunterWidget(int x, int y, int w, int h, sdlCoreWidget* pParent):sdlCoreWidget(x,y,w,h,false,pParent){
|
|
m_pFH = NULL;
|
|
m_pCtrlTex = NULL;
|
|
m_pName = NULL;
|
|
m_pType = NULL;
|
|
m_pMode = NULL;
|
|
m_pCustomMode = NULL;
|
|
m_bBlinkingLVL = false;
|
|
m_bBasicModeActual = false;
|
|
m_pOSD = NULL;
|
|
if (c_comName == NULL) {
|
|
c_comName = (CSTR)malloc(20);
|
|
if (c_comName != NULL) {
|
|
memset(c_comName, 0, 20);
|
|
};
|
|
};
|
|
m_bBlinkingTO = getMilliseconds() + 500;
|
|
m_bStatusCheckerCnt = 5;
|
|
m_bStatusFH = 0;
|
|
m_bStatusRadio = 0;
|
|
m_bStatusDrone = 0;
|
|
m_bStatusGPS = 0;
|
|
|
|
m_pComPorts = new sdlScrollListWidget(0, 43, 200, 60, 15, true, this);
|
|
m_pComPorts->addItem((CSTR)"COM1");
|
|
m_pComPorts->addItem((CSTR)"COM2");
|
|
m_pComPorts->addItem((CSTR)"COM3");
|
|
m_pComPorts->addItem((CSTR)"COM4");
|
|
m_pComPorts->addItem((CSTR)"COM5");
|
|
m_pComPorts->addItem((CSTR)"COM6");
|
|
m_pComPorts->addItem((CSTR)"COM7");
|
|
m_pComPorts->addItem((CSTR)"COM8");
|
|
m_pComPorts->setParamPtr(c_comName);
|
|
m_pComPorts->selectItem(3);
|
|
|
|
|
|
m_pReconnect = new sdlSimpleButtonWidget((CSTR)"RECONNECT", 202, 43, 80, 60, this);
|
|
m_pReconnect->Pushed = reconnect;
|
|
|
|
//General Info Panel
|
|
m_pFHNfoPanel = new sdlSimplePanel(284, 43, 200, 60, true, this);
|
|
m_pNameLabel = new sdlLabel((CSTR)"Noname", 0, 0, 200, 12, m_pFHNfoPanel, 10);
|
|
m_pNameLabel->setAlign(ALIGN_LEFT);
|
|
m_pNameLabel->setColor(0, 0, 0);
|
|
m_pTypeLabel = new sdlLabel((CSTR)"Unknown", 0, 12, 200, 12, m_pFHNfoPanel, 10);
|
|
m_pTypeLabel->setAlign(ALIGN_LEFT);
|
|
m_pTypeLabel->setColor(0, 0, 0);
|
|
m_pModeLabel = new sdlLabel((CSTR)"Unknown", 0, 24, 200, 12, m_pFHNfoPanel, 10);
|
|
m_pModeLabel->setAlign(ALIGN_LEFT);
|
|
m_pModeLabel->setColor(0, 0, 0);
|
|
m_pCustomModeLabel = new sdlLabel((CSTR)"Unknown", 0, 36, 200, 12, m_pFHNfoPanel, 10);
|
|
m_pCustomModeLabel->setAlign(ALIGN_LEFT);
|
|
m_pCustomModeLabel->setColor(0, 0, 0);
|
|
//GpsSat-Power Info Panel
|
|
//m_pFHBasicModePanel = new sdlSimplePanel(0, 105, 300, 60, true, this);
|
|
for (int i = 0; i < 8; i++) {
|
|
m_pActualModeFlag[i] = new sdlSimpleButtonWidget(basic_mode_names[i], i*75, 105, 70, 17, this);
|
|
m_pActualModeFlag[i]->setToggle(true);
|
|
m_pActualModeFlag[i]->setReadOnly(true);
|
|
};
|
|
m_pSetModeButton = new sdlSimpleButtonWidget((CSTR)"SET BASIC MODE", 0, 125, m_sGeometry.w, 20, this);
|
|
//for (int i = 0; i < 8; i++) {
|
|
// m_pNewModeFlag[i] = new sdlSimpleButtonWidget(basic_mode_names[i], i * 75, 125, 70, 17, this);
|
|
// m_pNewModeFlag[i]->setToggle(true);
|
|
//};
|
|
//m_pSetModeButton = new sdlSimpleButtonWidget((CSTR)"SET BASIC MODE", 0, 145, m_sGeometry.w, 20, this);
|
|
//BigButtons
|
|
int z = 170;
|
|
m_pArmMode = new sdlButtonWidget((CSTR)"ARM", 0, z, w, 40, this);
|
|
m_pArmMode->setToggle(true);
|
|
z += 45;
|
|
m_pLandNow = new sdlButtonWidget((CSTR)"Land Now!", 0, z, 200, 40, this);
|
|
m_pTakeOff = new sdlButtonWidget((CSTR)"Take Off", 205, z, 200, 40, this);
|
|
z += 45;
|
|
m_pFlyHome = new sdlButtonWidget((CSTR)"Fly Home", 0, z, 200, 40, this);
|
|
m_pSetHome = new sdlButtonWidget((CSTR)"Set Home", 205, z, 200, 40, this);
|
|
z += 45;
|
|
m_pLockXY = new sdlButtonWidget((CSTR)"Lock X-Y", 0, z, 200, 40, this);
|
|
m_pLockXY->setToggle(true);
|
|
m_pLockYZ = new sdlButtonWidget((CSTR)"Lock Y-Z", 205, z, 200, 40, this);
|
|
m_pLockYZ->setToggle(true);
|
|
z += 45;
|
|
m_pHoldPosition = new sdlButtonWidget((CSTR)"Hold Position", 0, z, w, 40, this);
|
|
m_pHoldPosition->setToggle(true);
|
|
|
|
m_pArmMode->setDisabled();
|
|
m_pLandNow->setDisabled();
|
|
m_pTakeOff->setDisabled();
|
|
m_pFlyHome->setDisabled();
|
|
m_pSetHome->setDisabled();
|
|
m_pLockXY->setDisabled();
|
|
m_pLockYZ->setDisabled();
|
|
m_pHoldPosition->setDisabled();
|
|
|
|
|
|
|
|
sdlGraphicElement::setType(GEL_PANEL);
|
|
m_pGUI->registerGEL(this);
|
|
};
|
|
|
|
sdlFlyHunterWidget::~sdlFlyHunterWidget() {
|
|
if (m_pNameLabel != NULL)delete(m_pNameLabel);
|
|
if (m_pTypeLabel != NULL)delete(m_pTypeLabel);
|
|
if (m_pTypeLabel != NULL)delete(m_pTypeLabel);
|
|
if (m_pTypeLabel != NULL)delete(m_pTypeLabel);
|
|
if (m_pTypeLabel != NULL)delete(m_pTypeLabel);
|
|
if (m_pTypeLabel != NULL)delete(m_pTypeLabel);
|
|
if (m_pTypeLabel != NULL)delete(m_pTypeLabel);
|
|
};
|
|
|
|
void sdlFlyHunterWidget::drawBefore(SDL_Renderer* pRenderer) {
|
|
//Update Video
|
|
if (m_bStatusDrone == 3) {
|
|
if (m_pOSD != NULL) {
|
|
//m_pOSD->setPitch(m_pFH->getBodyPitch());
|
|
m_pOSD->setRoll(m_pFH->getBodyRoll());
|
|
//m_pOSD->setYaw(m_pFH->getBodyYaw());
|
|
mavlink_vfr_hud_t* tVals;
|
|
tVals = m_pFH->getVFRData();
|
|
if (tVals != NULL) {
|
|
m_pOSD->setAlt(tVals->alt);
|
|
m_pOSD->setAirSpeed(tVals->airspeed);
|
|
m_pOSD->setClimbRate(tVals->climb);
|
|
m_pOSD->setGroundSpeed(tVals->groundspeed);
|
|
m_pOSD->setMagHeading(tVals->heading);
|
|
m_pOSD->setThrottle(tVals->throttle);
|
|
};
|
|
mavlink_power_status_t* tPow;
|
|
tPow = m_pFH->getPowerStatusData();
|
|
if (tPow != NULL) {
|
|
m_pOSD->setVoltage(tPow->Vcc/1000.f);
|
|
}
|
|
};
|
|
}
|
|
if (m_bBlinkingTO < getMilliseconds()) {
|
|
m_bBlinkingTO = getMilliseconds() + 500;
|
|
m_bBlinkingLVL = !m_bBlinkingLVL;
|
|
if (m_bStatusCheckerCnt) {
|
|
m_bStatusCheckerCnt--;
|
|
} else {
|
|
m_bStatusCheckerCnt = 5;
|
|
if (m_pFH) {
|
|
if (m_bStatusFH == 1) {
|
|
if (m_pFH->isRadiosConnected()) { // Com port is OK
|
|
m_bStatusFH = 3;
|
|
m_bStatusRadio = 1;
|
|
m_bStatusDrone = 0;
|
|
} else {
|
|
m_bStatusFH = 2;
|
|
m_bStatusRadio = 0;
|
|
m_bStatusDrone = 0;
|
|
m_bStatusGPS = 0;
|
|
};
|
|
} else if (m_bStatusFH == 2 ) {
|
|
// Check if reconnected
|
|
if ( m_pFH->isRadiosConnected() ) m_bStatusFH = 1;
|
|
} else {
|
|
if ( m_pFH->isRadiosConnected()) { // Com port is OK
|
|
if (m_bStatusRadio == 1) {
|
|
if (m_pFH->isVehicleAttached()) {
|
|
m_bStatusRadio = 3;
|
|
m_bStatusDrone = 1;
|
|
};
|
|
};
|
|
if ( m_bStatusDrone ) {
|
|
//Check if Pairing Done amd check for GPS!
|
|
if (m_pFH->isGpsPresent()) {
|
|
m_bStatusDrone = 3;
|
|
m_bStatusGPS = 1;
|
|
m_pArmMode->setEnabled();
|
|
m_pLandNow->setEnabled();
|
|
m_pTakeOff->setEnabled();
|
|
m_pFlyHome->setEnabled();
|
|
m_pSetHome->setEnabled();
|
|
m_pLockXY->setEnabled();
|
|
m_pLockYZ->setEnabled();
|
|
m_pHoldPosition->setEnabled();
|
|
if (!m_bBasicModeActual) {
|
|
uint8_t cs = m_pFH->getVehicleSystemMode();
|
|
for (int i = 0; i < 8; i++) {
|
|
m_pActualModeFlag[i]->setReadOnly(false);
|
|
if ((cs & (1 << i)) == (1 << i)) {
|
|
m_pActualModeFlag[i]->setToggled(true);
|
|
} else {
|
|
m_pActualModeFlag[i]->setToggled(false);
|
|
};
|
|
};
|
|
m_bBasicModeActual = true;
|
|
};
|
|
};
|
|
};
|
|
} else {
|
|
m_bStatusFH = 2;
|
|
m_bStatusRadio = 0;
|
|
m_bStatusDrone = 0;
|
|
m_bStatusGPS = 0;
|
|
m_pArmMode->setDisabled();
|
|
m_pLandNow->setDisabled();
|
|
m_pTakeOff->setDisabled();
|
|
m_pFlyHome->setDisabled();
|
|
m_pSetHome->setDisabled();
|
|
m_pLockXY->setDisabled();
|
|
m_pLockYZ->setDisabled();
|
|
m_pHoldPosition->setDisabled();
|
|
uint8_t cs = 0;
|
|
for (int i = 0; i < 8; i++) {
|
|
m_pActualModeFlag[i]->setToggled(false);
|
|
m_pActualModeFlag[i]->setReadOnly(true);
|
|
};
|
|
m_bBasicModeActual = false;
|
|
};
|
|
};
|
|
if (m_bStatusFH == 0)m_bStatusFH = 1;
|
|
};
|
|
};
|
|
};
|
|
if (m_pFH) {
|
|
if (m_pCtrlTex != NULL) {
|
|
int z = ( m_sGeometry.w - 108 ) >> 2;
|
|
SDL_Rect tS, tD;
|
|
tS.x = 0; tS.y = 40;
|
|
tS.w = 6; tS.h = 40;
|
|
tD = tS;
|
|
tD.y = 0;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tS.x = 6; tS.y = 40;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = 6; tD.w = z;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
if (m_bStatusRadio == 0) {
|
|
tS.x = 110; tS.y = 40;
|
|
tS.w = 32; tS.h = 40;
|
|
tD.x = z + 6; tD.w = 32;
|
|
} else {
|
|
tS.x = 110; tS.y = 80;
|
|
tS.w = 32; tS.h = 40;
|
|
tD.x = z + 6; tD.w = 32;
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
if (m_bStatusRadio == 0) {
|
|
tS.x = 6; tS.y = 0;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = z + 6 + 32; tD.w = z;
|
|
} else {
|
|
tS.x = 6; tS.y = 40;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = z + 6 + 32; tD.w = z;
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
if (m_bStatusRadio == 0) {
|
|
tS.x = 110; tS.y = 0;
|
|
tS.w = 32; tS.h = 40;
|
|
tD.x = (z << 1) + 6 + 32; tD.w = 32;
|
|
} else {
|
|
if (m_bStatusDrone == 0) {
|
|
tS.x = 110; tS.y = 40;
|
|
tS.w = 32; tS.h = 40;
|
|
tD.x = (z << 1) + 6 + 32; tD.w = 32;
|
|
} else {
|
|
tS.x = 110; tS.y = 80;
|
|
tS.w = 32; tS.h = 40;
|
|
tD.x = (z << 1) + 6 + 32; tD.w = 32;
|
|
};
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
if (m_bStatusDrone == 0) {
|
|
tS.x = 6; tS.y = 0;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = (z << 1) + 6 + 64; tD.w = z;
|
|
} else {
|
|
tS.x = 6; tS.y = 40;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = (z << 1) + 6 + 64; tD.w = z;
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
if (m_bStatusDrone == 0) {
|
|
tS.x = 110; tS.y = 0;
|
|
tS.w = 32; tS.h = 40;
|
|
tD.x = (z * 3) + 6 + 64; tD.w = 32;
|
|
} else {
|
|
if (m_bStatusGPS == 0) {
|
|
tS.x = 110; tS.y = 40;
|
|
tS.w = 32; tS.h = 40;
|
|
tD.x = (z * 3) + 6 + 64; tD.w = 32;
|
|
} else {
|
|
tS.x = 110; tS.y = 80;
|
|
tS.w = 32; tS.h = 40;
|
|
tD.x = (z * 3) + 6 + 64; tD.w = 32;
|
|
};
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
if (m_bStatusGPS == 0) {
|
|
tS.x = 6; tS.y = 0;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = (z * 3) + 6 + 96; tD.w = z;
|
|
} else {
|
|
tS.x = 6; tS.y = 40;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = (z * 3) + 6 + 96; tD.w = z;
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
if (m_bStatusGPS == 0) {
|
|
tS.x = 280; tS.y = 0;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = (z << 2) + 6 + 96; tD.w = 6;
|
|
} else {
|
|
tS.x = 280; tS.y = 80;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = (z << 2) + 6 + 96; tD.w = 6;
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
|
|
tS.y = 122;
|
|
tD.y = tD.h = tD.w = tS.w = tS.h = 13;
|
|
tD.x = z;
|
|
if (m_bStatusFH == 0) {
|
|
tS.x = 16;
|
|
} else if (m_bStatusFH == 1) {
|
|
if (m_bBlinkingLVL) {
|
|
tS.x = 30;
|
|
} else {
|
|
tS.x = 16;
|
|
};
|
|
} else if (m_bStatusFH == 2) {
|
|
tS.x = 2;
|
|
} else {
|
|
tS.x = 30;
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tD.x = (z << 1) + 32;
|
|
if (m_bStatusRadio == 0) {
|
|
tS.x = 16;
|
|
} else if (m_bStatusRadio == 1) {
|
|
if (m_bBlinkingLVL) {
|
|
tS.x = 30;
|
|
} else {
|
|
tS.x = 16;
|
|
};
|
|
} else if (m_bStatusRadio == 2) {
|
|
tS.x = 2;
|
|
} else {
|
|
tS.x = 30;
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tD.x = (z * 3) + 64;
|
|
if (m_bStatusDrone == 0) {
|
|
tS.x = 16;
|
|
} else if (m_bStatusDrone == 1) {
|
|
if (m_bBlinkingLVL) {
|
|
tS.x = 30;
|
|
} else {
|
|
tS.x = 16;
|
|
};
|
|
} else if (m_bStatusDrone == 2) {
|
|
tS.x = 2;
|
|
} else {
|
|
tS.x = 30;
|
|
};
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
|
|
tS.x = 6; tS.y = 174;
|
|
tD.h = tD.w = tS.w = tS.h = 35;
|
|
tD.x = 6 + (z - 35) >> 1; tD.y = 4;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
|
|
if (m_bStatusRadio == 0) {
|
|
tS.y = 137;
|
|
} else {
|
|
tS.y = 174;
|
|
};
|
|
tS.x = 152; tD.h = tD.w = tS.w = tS.h = 35; tD.x = 6 + 2 * z + 64 + (z - 35) >> 1; tD.y = 4;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
if (m_bStatusDrone == 0) {
|
|
tS.y = 137;
|
|
} else {
|
|
tS.y = 174;
|
|
};
|
|
tS.x = 88;
|
|
tD.w = tS.w = 58; tD.h = tS.h = 35;
|
|
tD.x = 6 + 4 * z + 105 + (z - 35) >> 1; tD.y = 4;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
if (m_bStatusGPS == 0) {
|
|
tS.y = 137;
|
|
} else {
|
|
tS.y = 174;
|
|
};
|
|
tS.x = 51;
|
|
tD.h = tD.w = tS.w = tS.h = 35;
|
|
tD.x = 6 + 6 * z + 192 + (z - 35) >> 1; tD.y = 4;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
};
|
|
CSTR tPtr;
|
|
if ( m_bStatusDrone == 3 ) {
|
|
tPtr = m_pFH->getVehicleName();
|
|
if (tPtr != m_pName) {
|
|
m_pName = tPtr;
|
|
m_pNameLabel->setText(m_pName);
|
|
m_pNameLabel->setBgColor(255, 255, 0, 255);
|
|
};
|
|
tPtr = m_pFH->getCtrlName();
|
|
if (tPtr != m_pType) {
|
|
m_pType = tPtr;
|
|
m_pTypeLabel->setText(m_pType);
|
|
m_pTypeLabel->setBgColor(255, 255, 0, 255);
|
|
};
|
|
tPtr = m_pFH->getVehicleSystemModeName();
|
|
if (tPtr != m_pMode) {
|
|
m_pMode = tPtr;
|
|
m_pModeLabel->setText(m_pMode);
|
|
m_pModeLabel->setBgColor(255, 255, 0, 255);
|
|
};
|
|
tPtr = m_pFH->getVehicleAutoPilotModeName();
|
|
if (tPtr != m_pCustomMode) {
|
|
m_pCustomMode = tPtr;
|
|
m_pCustomModeLabel->setText(m_pCustomMode);
|
|
m_pCustomModeLabel->setBgColor(255, 255, 0, 255);
|
|
};
|
|
} else {
|
|
if (m_pName || m_pType) {
|
|
m_pName = NULL;
|
|
m_pType = NULL;
|
|
m_pMode = NULL;
|
|
m_pCustomMode = NULL;
|
|
m_pNameLabel->setText((CSTR)"Noname");
|
|
m_pTypeLabel->setText((CSTR)"Unknown");
|
|
m_pModeLabel->setText((CSTR)"Unknown");
|
|
m_pCustomModeLabel->setText((CSTR)"Unknown");
|
|
m_pNameLabel->setBgColor(255, 255, 0, 50);
|
|
m_pTypeLabel->setBgColor(255, 255, 0, 50);
|
|
};
|
|
};
|
|
} else {
|
|
if (m_pCtrlTex != NULL) {
|
|
int z = (m_sGeometry.w - 108) >> 2;
|
|
SDL_Rect tS, tD;
|
|
tS.x = 0; tS.y = 0;
|
|
tS.w = 6; tS.h = 40;
|
|
tD = tS;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tS.x = 6; tS.y = 0;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = 6; tD.w = z;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tS.x = 110; tS.y = 0;
|
|
tS.w = 32; tS.h = 40;
|
|
tD.x = z + 6; tD.w = 32;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tS.x = 6; tS.y = 0;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = z + 6 + 32; tD.w = z;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tS.x = 110; tS.y = 0;
|
|
tS.w = 32; tS.h = 40;
|
|
tD.x = (z << 1) + 6 + 32; tD.w = 32;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tS.x = 6; tS.y = 0;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = (z << 1) + 6 + 64; tD.w = z;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tS.x = 110; tS.y = 0;
|
|
tS.w = 32; tS.h = 40;
|
|
tD.x = (z * 3) + 6 + 64; tD.w = 32;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tS.x = 6; tS.y = 0;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = (z * 3) + 6 + 96; tD.w = z;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tS.x = 280; tS.y = 0;
|
|
tS.w = 6; tS.h = 40;
|
|
tD.x = (z << 2) + 6 + 96; tD.w = 6;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
|
|
tS.x = 16; tS.y = 122;
|
|
tD.y = tD.h = tD.w = tS.w = tS.h = 13;
|
|
tD.x = z;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tD.x = (z << 1) + 32;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tD.x = (z * 3) + 64;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
|
|
tS.x = 6; tS.y = 137;
|
|
tD.h = tD.w = tS.w = tS.h = 35;
|
|
tD.x = 6 + (z - 35) >> 1; tD.y = 4;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tS.x = 152; tS.y = 137;
|
|
tD.h = tD.w = tS.w = tS.h = 35;
|
|
tD.x = 6 + 2 * z + 64 + (z - 35) >> 1; tD.y = 4;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tS.x = 88; tS.y = 137;
|
|
tD.w = tS.w = 58; tD.h = tS.h = 35;
|
|
tD.x = 6 + 4 * z + 105 + (z - 35) >> 1; tD.y = 4;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
tS.x = 51; tS.y = 137;
|
|
tD.h = tD.w = tS.w = tS.h = 35;
|
|
tD.x = 6 + 6 * z + 192 + (z - 35) >> 1; tD.y = 4;
|
|
SDL_RenderCopy(pRenderer, m_pCtrlTex->texture, &tS, &tD);
|
|
};
|
|
};
|
|
};
|
|
|
|
void sdlFlyHunterWidget::drawAfter(SDL_Renderer* pRenderer) {
|
|
};
|
|
|
|
bool sdlFlyHunterWidget::create(void) {
|
|
m_pCtrlTex = m_pGUI->loadTexture((CSTR)"fhctrl.png");
|
|
return sdlCoreWidget::create();
|
|
};
|
|
|
|
void tutulik1(void) {
|
|
if (mHNT == NULL) return;
|
|
mHNT->forceArm();
|
|
};
|
|
void tutulik2(void) {
|
|
if (mHNT == NULL) return;
|
|
mHNT->disarm();
|
|
};
|
|
void tutulik3(void) {
|
|
if (mHNT == NULL) return;
|
|
mHNT->takeOff();
|
|
};
|
|
void tutulik4(void) {
|
|
if (mHNT == NULL) return;
|
|
mHNT->land();
|
|
};
|
|
void tutulik5(void) {
|
|
if (mHNT == NULL) return;
|
|
mHNT->reset();
|
|
};
|
|
|
|
static uint8_t basic_mode = 0;
|
|
|
|
void setBasicMode(void) {
|
|
basic_mode = 0;
|
|
};
|
|
|
|
void sdlFlyHunterWidget::attachFlyHunter(objectFlyHunter* ptr) {
|
|
if (ptr == NULL) {
|
|
m_pFH = NULL;
|
|
m_pArmMode->Pushed = NULL;
|
|
} else {
|
|
m_pFH = ptr;
|
|
m_pArmMode->Toggled = &tutulik1;
|
|
m_pArmMode->UnToggled = &tutulik2;
|
|
m_pTakeOff->Pushed = &tutulik3;
|
|
m_pLandNow->Pushed = &tutulik4;
|
|
m_pHoldPosition->Pushed = &tutulik5;
|
|
};
|
|
};
|
|
|
|
void sdlFlyHunterWidget::attachOSD(sdlOsdVideoWidget* ptr) {
|
|
if (ptr == NULL) {
|
|
m_pOSD = NULL;
|
|
} else {
|
|
m_pOSD = ptr;
|
|
};
|
|
};
|