feat(mt12): make use of "servo test" port (#6528)
Co-authored-by: 3djc <3djc@gh.com> Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Co-authored-by: Peter Feerick <5500713+pfeerick@users.noreply.github.com>
This commit is contained in:
co-authored by
3djc
raphaelcoeffic
Peter Feerick
parent
559b9a9991
commit
423876b10b
@@ -140,6 +140,7 @@ void menuRadioSpectrumAnalyser(event_t event);
|
||||
void menuRadioPowerMeter(event_t event);
|
||||
void menuRadioCalibration(event_t event);
|
||||
void menuGhostModuleConfig(event_t event);
|
||||
void menuServoPwmTool(event_t event);
|
||||
|
||||
void menuModelSelect(event_t event);
|
||||
void menuModelSetup(event_t event);
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "edgetx.h"
|
||||
#include "os/sleep.h"
|
||||
|
||||
#if defined(SERVO_PWM)
|
||||
|
||||
#if LCD_W >= 212
|
||||
#define HW_SETTINGS_COLUMN1 12*FW
|
||||
#define HW_SETTINGS_COLUMN2 (20*FW - 3)
|
||||
#define HW_SETTINGS_COLUMN3 HW_SETTINGS_COLUMN2
|
||||
#else
|
||||
#define HW_SETTINGS_COLUMN1 30
|
||||
#define HW_SETTINGS_COLUMN2 (HW_SETTINGS_COLUMN1 + 5*FW)
|
||||
#define HW_SETTINGS_COLUMN3 HW_SETTINGS_COLUMN2 + FW
|
||||
#endif
|
||||
|
||||
#if !defined(SIMU)
|
||||
extern void pwmOutputDisable();
|
||||
extern void pwmOutputInit();
|
||||
extern void pwmOutputEnable(uint16_t pulse_width_us);
|
||||
#else
|
||||
void pwmOutputDisable() {}
|
||||
void pwmOutputInit() {}
|
||||
void pwmOutputEnable(uint16_t) {}
|
||||
#endif
|
||||
|
||||
// 1-based output channel number, not a mixsrc_t
|
||||
static constexpr uint8_t PWM_SOURCE_NONE = 0;
|
||||
static uint8_t pwmOutputSource;
|
||||
|
||||
enum {
|
||||
ITEM_PWM_SOURCE,
|
||||
ITEM_SERVO_PWM_MAX,
|
||||
};
|
||||
|
||||
void menuServoPwmTool(event_t event)
|
||||
{
|
||||
SUBMENU(STR_PWM_OUTPUT, 0, {0});
|
||||
|
||||
if (menuEvent == EVT_ENTRY_UP) {
|
||||
TRACE("stopping servo pwm...");
|
||||
pwmOutputDisable();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event == EVT_ENTRY) {
|
||||
TRACE("starting servo pwm...");
|
||||
pwmOutputSource = PWM_SOURCE_NONE;
|
||||
pwmOutputInit();
|
||||
}
|
||||
|
||||
if (pwmOutputSource != PWM_SOURCE_NONE) {
|
||||
mixsrc_t chan = pwmOutputSource - 1;
|
||||
pwmOutputEnable(PPM_CH_CENTER(chan) + channelOutputs[chan] / 2);
|
||||
} else {
|
||||
pwmOutputDisable();
|
||||
}
|
||||
|
||||
for (int i = 0; i < ITEM_SERVO_PWM_MAX; i++) {
|
||||
LcdFlags attr = (menuVerticalPosition == i ? (s_editMode > 0 ? INVERS | BLINK : INVERS) : 0);
|
||||
coord_t y = MENU_HEADER_HEIGHT + 12 + i * FH;
|
||||
|
||||
switch (i) {
|
||||
case ITEM_PWM_SOURCE: {
|
||||
lcdDrawTextAlignedLeft(y, STR_SOURCE);
|
||||
mixsrc_t src = (pwmOutputSource != PWM_SOURCE_NONE)
|
||||
? MIXSRC_FIRST_CH + pwmOutputSource - 1
|
||||
: MIXSRC_NONE;
|
||||
drawSource(HW_SETTINGS_COLUMN2, y, src, attr);
|
||||
if (attr & BLINK)
|
||||
CHECK_INCDEC_GENVAR(event, pwmOutputSource, PWM_SOURCE_NONE,
|
||||
MAX_OUTPUT_CHANNELS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -220,6 +220,10 @@ void menuRadioTools(event_t event)
|
||||
addRadioModuleToolHandler(index++, "Ghost Menu", menuGhostModuleConfig, EXTERNAL_MODULE);
|
||||
#endif
|
||||
|
||||
#if defined(SERVO_PWM)
|
||||
addRadioModuleToolHandler(index++, STR_PWM_OUTPUT, menuServoPwmTool, 0);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
if (index == 0) {
|
||||
|
||||
Reference in New Issue
Block a user