Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions companion/src/wizard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
project(wizard)

set(${PROJECT_NAME}_NAMES
wizarddata
wizarddataair
wizardwizmix
wizarddialog
)

AddHeadersSources()

# AUTOMOC does not detect so manually process
set(${PROJECT_NAME}_MOC
wizarddata.h
wizarddataair.h
wizardwizmix.h
wizarddialog.h
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,36 @@

#include <string.h>
#include "eeprominterface.h"
#include "wizarddata.h"
#include "wizarddataair.h"

Channel::Channel()
Plane::MixerChannel::Channel()
{
clear();
}

void Channel::clear()
void Plane::MixerChannel::clear()
{
page = Page_None;
page = Vehicle::PAGE_NONE;
prebooked = false;
input1 = NO_INPUT;
input2 = NO_INPUT;
input1 = AirVehicle::NO_INPUT;
input2 = AirVehicle::NO_INPUT;
weight1 = 0;
weight2 = 0;
}

WizMix::WizMix(const GeneralSettings & settings, unsigned int modelId, const ModelData & modelData):
Plane::WizMix::WizMix(const GeneralSettings & settings, unsigned int modelId, const ModelData & modelData):
complete(false),
modelId(modelId),
settings(settings),
originalModelData(modelData),
vehicle(NOVEHICLE)
vehicle(Vehicle::TYPE)
{
memset(name, 0, sizeof(name));
memcpy(name, originalModelData.name, sizeof(name) - 1);
name[sizeof(name) - 1] = '\0';
}

void WizMix::maxMixSwitch(char *name, MixData &mix, int channel, int sw, int weight)
void Plane::WizMix::maxMixSwitch(char *name, MixData &mix, int channel, int sw, int weight)
{
memset(mix.name, 0, sizeof(mix.name));
strncpy(mix.name, name, sizeof(mix.name)-1);
Expand All @@ -60,29 +60,29 @@ void WizMix::maxMixSwitch(char *name, MixData &mix, int channel, int sw, int wei
mix.weight = weight;
}

void WizMix::addMix(ModelData &model, Input input, int weight, int channel, int & mixIndex)
void Plane::WizMix::addMix(ModelData &model, int input, int weight, int channel, int & mixIndex)
{
if (input != NO_INPUT) {
if (input >= RUDDER_INPUT && input <= AILERONS_INPUT) {
if (input != AirVehicle::NO_INPUT) {
if (input >= AirVehicle::RUDDER_INPUT && input <= AirVehicle::AILERONS_INPUT) {
MixData & mix = model.mixData[mixIndex++];
mix.destCh = channel + 1;
mix.srcRaw = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, settings.getDefaultChannel(input - 1) + 1);
mix.weight = weight;
}
else if (input==FLAPS_INPUT){
else if (input==AirVehicle::FLAPS_INPUT){
// There ought to be some kind of constants for switches somewhere...
maxMixSwitch((char *)tr("FlapUp").toLatin1().data(), model.mixData[mixIndex++], channel+1, SWITCH_SA0 - 1, weight);
maxMixSwitch((char *)tr("FlapDn").toLatin1().data(), model.mixData[mixIndex++], channel+1, SWITCH_SA2 - 1, -weight);

}
else if (input==AIRBRAKES_INPUT){
else if (input==AirVehicle::AIRBRAKES_INPUT){
maxMixSwitch((char *)tr("ArbkOf").toLatin1().data(), model.mixData[mixIndex++], channel+1, SWITCH_SE0 - 1, -weight);
maxMixSwitch((char *)tr("ArbkOn").toLatin1().data(), model.mixData[mixIndex++], channel+1, SWITCH_SE2 - 1, weight);
}
}
}

WizMix::operator ModelData()
Plane::WizMix::operator ModelData()
{
int throttleChannel = -1;

Expand All @@ -103,14 +103,14 @@ WizMix::operator ModelData()
// Add the channel mixes
for (int i=0; i<WIZ_MAX_CHANNELS; i++ )
{
Channel ch = channel[i];
Plane::MixerChannel ch = channel[i];

addMix(model, ch.input1, ch.weight1, i, mixIndex);
addMix(model, ch.input2, ch.weight2, i, mixIndex);

if (ch.input1 == THROTTLE_INPUT || ch.input2 == THROTTLE_INPUT) {
if (ch.input1 == AirVehicle::THROTTLE_INPUT || ch.input2 == AirVehicle::THROTTLE_INPUT) {
throttleChannel++;
if (options[THROTTLE_CUT_OPTION]) {
if (options[AirVehicle::THROTTLE_CUT_OPTION]) {
// Add the Throttle Cut option
MixData & mix = model.mixData[mixIndex++];
mix.destCh = i+1;
Expand All @@ -120,23 +120,23 @@ WizMix::operator ModelData()
mix.swtch.index = SWITCH_SF0;
mix.mltpx = MLTPX_REP;
memset(mix.name, 0, sizeof(mix.name));
strncpy(mix.name, WizMix::tr("Cut").toLatin1().data(), MIXDATA_NAME_LEN);
strncpy(mix.name, Plane::WizMix::tr("Cut").toLatin1().data(), MIXDATA_NAME_LEN);
}
}
}

// Add the Flight Timer option
if (options[FLIGHT_TIMER_OPTION] && throttleChannel >= 0){
if (options[AirVehicle::FLIGHT_TIMER_OPTION] && throttleChannel >= 0){
memset(model.timers[timerIndex].name, 0, sizeof(model.timers[timerIndex].name));
strncpy(model.timers[timerIndex].name, WizMix::tr("Flt").toLatin1().data(), sizeof(model.timers[timerIndex].name)-1);
strncpy(model.timers[timerIndex].name, Plane::WizMix::tr("Flt").toLatin1().data(), sizeof(model.timers[timerIndex].name)-1);
model.timers[timerIndex].mode = TimerData::TIMERMODE_START;
timerIndex++;
}

// Add the Throttle Timer option
if (options[THROTTLE_TIMER_OPTION] && throttleChannel >= 0){
if (options[AirVehicle::THROTTLE_TIMER_OPTION] && throttleChannel >= 0){
memset(model.timers[timerIndex].name, 0, sizeof(model.timers[timerIndex].name));
strncpy(model.timers[timerIndex].name, WizMix::tr("Thr").toLatin1().data(), sizeof(model.timers[timerIndex].name)-1);
strncpy(model.timers[timerIndex].name, Plane::WizMix::tr("Thr").toLatin1().data(), sizeof(model.timers[timerIndex].name)-1);
model.timers[timerIndex].mode = TimerData::TIMERMODE_THR;
timerIndex++;
}
Expand Down
179 changes: 179 additions & 0 deletions companion/src/wizard/wizarddataair.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#pragma once

#include "eeprominterface.h"
#include "wizardwizmix.h"

#include <QtCore>

#define WIZ_MAX_CHANNELS 8

class Vehicle
{
public:
//unique per vehicle type
// air: 1xx range
// on/off road: 2xx range
// marine: 3xx range
static const int TYPE = 0;

static const int NO_INPUT = 0;

static const int NO_OPTION = 0;

static const int PAGE_NONE = 0;

// ALL BASIC PAGE HAVE 0-9 VALUES
static const int PAGE_CONCLUSION = 1;
static const int PAGE_MODELS = 2;

//
class MixerChannel;
};

class AirVehicle : public Vehicle
{
public:
static const int TYPE = 100;
static const int RUDDER_INPUT = 1;
static const int ELEVATOR_INPUT = 2;
static const int THROTTLE_INPUT = 3;
static const int AILERONS_INPUT = 4;
static const int FLAPS_INPUT = 5;
static const int AIRBRAKES_INPUT = 6;

static const int WIZ_MAX_OPTIONS = 3;
static const int FLIGHT_TIMER_OPTION = 0;
static const int THROTTLE_CUT_OPTION = 1;
static const int THROTTLE_TIMER_OPTION = 2;

// ALL GROUP PAGES HAVE 10-99 VALUES
static const int PAGE_THROTTLE = 10;

// class to hold info for the mixer-page-channels. this (for now) assumes a maximum of 2 inputs being mixed.
// this is specific for AirVehicles at the moment. Plane::MixerChannel could be a shell void in Vehicle class which gets
// overwritten in the AirVehicle class. This allows for a different handling of Plane::MixerChannel in SurfaceVehicle
// or MarineVehicle as well.
class MixerChannel{
public:
int page; // Originating dialog, only of interest for producer
bool prebooked; // Temporary lock variable
int input1;
int input2;
int weight1;
int weight2;

Channel();
void clear();
};

class WizMix;
// {
// Q_OBJECT

// public:
// bool complete;
// char name[MODEL_NAME_LEN + 1];
// unsigned int modelId;
// const GeneralSettings & settings;
// const ModelData & originalModelData;
// int vehicle;
// MixerChannel channel[WIZ_MAX_CHANNELS];
// bool options[AirVehicle::WIZ_MAX_OPTIONS];

// WizMix(const GeneralSettings & settings, unsigned int modelId, const ModelData & modelData);
// operator ModelData();

// private:
// WizMix();
// void addMix(ModelData & model, int input, int weight, int channel, int & mixerIndex);
// void maxMixSwitch(char *name, MixData &mix, int destCh, int sw, int weight);

// };

};



class Plane : public AirVehicle
{
public:
static const int TYPE = 101;

// ALL VEHICLE SPECIFIC PAGES HAVE 100-999 VALUES
static const int PAGE_WINGTYPES = 121;
static const int PAGE_AILERONS = 122;
static const int PAGE_FLAPS = 123;
static const int PAGE_AIRBRAKES = 124;
static const int PAGE_ELEVONS = 125;
static const int PAGE_RUDDER = 126;
static const int PAGE_TAILS = 127;
static const int PAGE_TAIL = 128;
static const int PAGE_VTAIL = 129;
static const int PAGE_SIMPLETAIL = 130;
static const int PAGE_LIGHTS = 131;
static const int PAGE_OPTIONS = 132;


};


class Helicopter : public AirVehicle
{
public:
static const int TYPE = 103;

// ALL VEHICLE SPECIFIC PAGES HAVE 100-999 VALUES
static const int PAGE_CYCLIC = 100;
static const int PAGE_GYRO = 101;
static const int PAGE_FLYBAR = 102;
static const int PAGE_FLYBARLESS = 103;
static const int PAGE_HELICONTROL = 104;
static const int PAGE_LIGHTS = 199;
static const int PAGE_OPTIONS = 200;


};

class MultiRotor : public AirVehicle
{
public:
static const int TYPE = 102;

// ALL VEHICLE SPECIFIC PAGES HAVE 100-999 VALUES
static const int PAGE_MULTIROTOR = 100;
static const int PAGE_LIGHTS = 199;
static const int PAGE_OPTIONS = 200;


};

enum VehicleName {
NOVEHICLE,
PLANE=101,
MULTICOPTER,
HELICOPTER
};



Loading
Loading