Merge pull request #618 from EdgeTX/DiagnoseFlySkyShowRaw

Show true raw info on radio analogs diagnose screen (FlySky hall gimbal only)
This commit is contained in:
Raphael Coeffic
2021-09-13 15:22:21 +02:00
committed by GitHub
3 changed files with 182 additions and 124 deletions
+39 -5
View File
@@ -26,6 +26,10 @@
#include "imu_lsm6ds33.h"
#endif
#if defined (FLYSKY_HALL_STICKS) || defined (FLYSKY_HALL_STICKS_REVERSE)
#include "../../targets/horus/flyskyHallStick_driver.h"
#endif
constexpr coord_t ANA_OFFSET = 150;
class RadioAnalogsDiagsWindow: public Window {
@@ -43,19 +47,49 @@ class RadioAnalogsDiagsWindow: public Window {
void paint(BitmapBuffer * dc) override
{
#if !defined(SIMU) && (defined (FLYSKY_HALL_STICKS) || defined (FLYSKY_HALL_STICKS_REVERSE))
for (uint8_t i = 0; i < FLYSKY_HALL_CHANNEL_COUNT; i++) {
#if LCD_W > LCD_H
coord_t y = 1 + (i / 2) * FH;
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
#else
coord_t y = 1 + i * FH;
uint8_t x = 10;
#endif
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT, 2);
dc->drawText(x + 2 * 15 - 2, y, ":");
dc->drawNumber(x + 3 * 15 - 1, y, hall_raw_values[i], LEFT);
dc->drawNumber(x + ANA_OFFSET, y, hall_adc_values[i], RIGHT);
}
for (uint8_t i = FLYSKY_HALL_CHANNEL_COUNT; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
#if LCD_W > LCD_H
coord_t y = 1 + (i / 2) * FH;
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
#else
coord_t y = 1 + i * FH;
uint8_t x = 10;
#endif
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT, 2);
dc->drawText(x + 2 * 15 - 2, y, ":");
dc->drawNumber(x + 3 * 15 -1, y, anaIn(i), LEFT);
dc->drawNumber(x + ANA_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT);
}
#else
for (uint8_t i = 0; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
#if LCD_W > LCD_H
coord_t y = 1 + (i / 2) * FH;
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
coord_t y = 1 + (i / 2) * FH;
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
#else
coord_t y = 1 + i * FH;
uint8_t x = 10;
coord_t y = 1 + i * FH;
uint8_t x = 10;
#endif
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT, 2);
dc->drawText(x + 2 * 15 - 2, y, ":");
drawHexNumber(dc, x + 3 * 15 - 1, y, anaIn(i));
dc->drawNumber(x + 3 * 15 -1, y, anaIn(i), LEFT);
dc->drawNumber(x + ANA_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT);
}
#endif
#if !defined(SIMU) && defined(IMU_LSM6DS33)
coord_t yimu = MENU_CONTENT_TOP + 3 * FH;
@@ -1,7 +1,8 @@
/*
* Copyright (C) OpenTX
* 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
@@ -19,124 +20,7 @@
*/
#include "opentx.h"
#define HALLSTICK_BUFF_SIZE ( 512 )
#define FLYSKY_HALL_BAUDRATE ( 921600 )
#define FLYSKY_HALL_CHANNEL_COUNT ( 4 )
#define MAX_ADC_CHANNEL_VALUE ( 4095 )
#define MIN_ADC_CHANNLE_VALUE ( 0 )
#define MIDDLE_ADC_CHANNLE_VALUE ( 2047 )
#define FLYSKY_HALL_PROTOLO_HEAD 0x55
#define FLYSKY_HALL_RESP_TYPE_CALIB 0x0e
#define FLYSKY_HALL_RESP_TYPE_VALUES 0x0c
#define FLYSKY_HALL_ERROR_OFFSET 10
typedef struct
{
signed short min;
signed short mid;
signed short max;
} STRUCT_STICK_CALIBRATION;
typedef struct
{
STRUCT_STICK_CALIBRATION sticksCalibration[4];
unsigned char reststate;
unsigned short CRC16;
} STRUCT_STICK_CALIBRATION_PACK;
typedef struct
{
signed short channel[4];
unsigned char stickState;
unsigned short CRC16;
} STRUCT_CHANNEL_PACK;
typedef union
{
STRUCT_STICK_CALIBRATION_PACK channelPack;
STRUCT_CHANNEL_PACK sticksCalibrationPack;
} UNION_DATA;
typedef struct
{
unsigned char start;
unsigned char senderID:2;
unsigned char receiverID:2;
unsigned char packetID:4;
unsigned char length;
UNION_DATA payload;
} STRUCT_HALLDATA;
typedef struct
{
unsigned char senderID:2;
unsigned char receiverID:2;
unsigned char packetID:4;
} STRUCT_HALLID;
typedef union
{
STRUCT_HALLID hall_Id;
unsigned char ID;
} STRUCT_ID;
typedef union
{
STRUCT_HALLDATA halldat;
unsigned char buffer[30];
} UNION_HALLDATA;
typedef struct
{
unsigned char head;
STRUCT_ID hallID;
unsigned char length;
unsigned char data[HALLSTICK_BUFF_SIZE];
unsigned char reserved[15];
unsigned short checkSum;
unsigned char stickState;
unsigned char startIndex;
unsigned char endIndex;
unsigned char index;
unsigned char dataIndex;
unsigned char deindex;
unsigned char completeFlg;
unsigned char status;
unsigned char recevied;
unsigned char msg_OK;
} STRUCT_HALL;
enum
{
GET_START = 0,
GET_ID,
GET_LENGTH,
GET_DATA,
GET_STATE,
GET_CHECKSUM,
CHECKSUM,
};
enum HALLSTICK_SEND_STATE_E {
HALLSTICK_SEND_STATE_IDLE,
HALLSTICK_STATE_SEND_RESET,
HALLSTICK_STATE_GET_CONFIG,
HALLSTICK_STATE_GET_FIRMWARE,
HALLSTICK_STATE_UPDATE_FW
};
enum TRANSFER_DIR_E {
TRANSFER_DIR_HALLSTICK,
TRANSFER_DIR_TXMCU,
TRANSFER_DIR_HOSTPC,
TRANSFER_DIR_RFMODULE,
};
#include "flyskyHallStick_driver.h"
DMAFifo<HALLSTICK_BUFF_SIZE> hallDMAFifo __DMA (FLYSKY_HALL_DMA_Stream_RX);
Fifo<uint8_t, HALLSTICK_BUFF_SIZE> hallStickTxFifo;
@@ -0,0 +1,140 @@
/*
* 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.
*/
#define HALLSTICK_BUFF_SIZE ( 512 )
#define FLYSKY_HALL_BAUDRATE ( 921600 )
#define FLYSKY_HALL_CHANNEL_COUNT ( 4 )
#define MAX_ADC_CHANNEL_VALUE ( 4095 )
#define MIN_ADC_CHANNLE_VALUE ( 0 )
#define MIDDLE_ADC_CHANNLE_VALUE ( 2047 )
#define FLYSKY_HALL_PROTOLO_HEAD 0x55
#define FLYSKY_HALL_RESP_TYPE_CALIB 0x0e
#define FLYSKY_HALL_RESP_TYPE_VALUES 0x0c
#define FLYSKY_HALL_ERROR_OFFSET 10
typedef struct
{
signed short min;
signed short mid;
signed short max;
} STRUCT_STICK_CALIBRATION;
typedef struct
{
STRUCT_STICK_CALIBRATION sticksCalibration[4];
unsigned char reststate;
unsigned short CRC16;
} STRUCT_STICK_CALIBRATION_PACK;
typedef struct
{
signed short channel[4];
unsigned char stickState;
unsigned short CRC16;
} STRUCT_CHANNEL_PACK;
typedef union
{
STRUCT_STICK_CALIBRATION_PACK channelPack;
STRUCT_CHANNEL_PACK sticksCalibrationPack;
} UNION_DATA;
typedef struct
{
unsigned char start;
unsigned char senderID:2;
unsigned char receiverID:2;
unsigned char packetID:4;
unsigned char length;
UNION_DATA payload;
} STRUCT_HALLDATA;
typedef struct
{
unsigned char senderID:2;
unsigned char receiverID:2;
unsigned char packetID:4;
} STRUCT_HALLID;
typedef union
{
STRUCT_HALLID hall_Id;
unsigned char ID;
} STRUCT_ID;
typedef union
{
STRUCT_HALLDATA halldat;
unsigned char buffer[30];
} UNION_HALLDATA;
typedef struct
{
unsigned char head;
STRUCT_ID hallID;
unsigned char length;
unsigned char data[HALLSTICK_BUFF_SIZE];
unsigned char reserved[15];
unsigned short checkSum;
unsigned char stickState;
unsigned char startIndex;
unsigned char endIndex;
unsigned char index;
unsigned char dataIndex;
unsigned char deindex;
unsigned char completeFlg;
unsigned char status;
unsigned char recevied;
unsigned char msg_OK;
} STRUCT_HALL;
enum
{
GET_START = 0,
GET_ID,
GET_LENGTH,
GET_DATA,
GET_STATE,
GET_CHECKSUM,
CHECKSUM,
};
enum HALLSTICK_SEND_STATE_E {
HALLSTICK_SEND_STATE_IDLE,
HALLSTICK_STATE_SEND_RESET,
HALLSTICK_STATE_GET_CONFIG,
HALLSTICK_STATE_GET_FIRMWARE,
HALLSTICK_STATE_UPDATE_FW
};
enum TRANSFER_DIR_E {
TRANSFER_DIR_HALLSTICK,
TRANSFER_DIR_TXMCU,
TRANSFER_DIR_HOSTPC,
TRANSFER_DIR_RFMODULE,
};
extern signed short hall_raw_values[FLYSKY_HALL_CHANNEL_COUNT];
extern unsigned short hall_adc_values[FLYSKY_HALL_CHANNEL_COUNT];