....hotfix

This commit is contained in:
Wastl Kraus 2021-07-04 21:34:26 +02:00
parent a507871cbd
commit 0d2bf9e117
2 changed files with 21 additions and 25 deletions

View File

@ -1,5 +1,5 @@
//
// Name: ESP32_ESC.ino
// Name: DShotRMT.cpp
// Created: 20.03.2021 00:49:15
// Author: derdoktor667
//
@ -37,10 +37,6 @@ DShotRMT::DShotRMT(DShotRMT const &) {
// ...write me
}
// DShotRMT& DShotRMT::operator=(DShotRMT const&) {
// TODO: hier return-Anweisung eingeben
// }
bool DShotRMT::begin(dshot_mode_t dshot_mode, bool is_bidirectional) {
dshot_config.mode = dshot_mode;
dshot_config.clk_div = DSHOT_CLK_DIVIDER;
@ -147,27 +143,27 @@ rmt_item32_t* DShotRMT::encode_dshot_to_rmt(uint16_t parsed_packet) {
for (int i = 0; i < DSHOT_PAUSE_BIT; i++, parsed_packet <<= 1) {
if (parsed_packet & 0b1000000000000000) {
// set one
dshot_rmt_item[i].duration0 = dshot_config.ticks_one_high;
dshot_rmt_item[i].level0 = 1;
dshot_rmt_item[i].duration1 = dshot_config.ticks_one_low;
dshot_rmt_item[i].level1 = 0;
dshot_tx_rmt_item[i].duration0 = dshot_config.ticks_one_high;
dshot_tx_rmt_item[i].level0 = 1;
dshot_tx_rmt_item[i].duration1 = dshot_config.ticks_one_low;
dshot_tx_rmt_item[i].level1 = 0;
}
else {
// set zero
dshot_rmt_item[i].duration0 = dshot_config.ticks_zero_high;
dshot_rmt_item[i].level0 = 1;
dshot_rmt_item[i].duration1 = dshot_config.ticks_zero_low;
dshot_rmt_item[i].level1 = 0;
dshot_tx_rmt_item[i].duration0 = dshot_config.ticks_zero_high;
dshot_tx_rmt_item[i].level0 = 1;
dshot_tx_rmt_item[i].duration1 = dshot_config.ticks_zero_low;
dshot_tx_rmt_item[i].level1 = 0;
}
}
// ...end marker added to each frame
dshot_rmt_item[DSHOT_PAUSE_BIT].duration0 = DSHOT_PAUSE_BIDIRECTIONAL;
dshot_rmt_item[DSHOT_PAUSE_BIT].level0 = 0;
dshot_rmt_item[DSHOT_PAUSE_BIT].duration1 = 0;
dshot_rmt_item[DSHOT_PAUSE_BIT].level1 = 0;
dshot_tx_rmt_item[DSHOT_PAUSE_BIT].duration0 = DSHOT_PAUSE_BIDIRECTIONAL;
dshot_tx_rmt_item[DSHOT_PAUSE_BIT].level0 = 0;
dshot_tx_rmt_item[DSHOT_PAUSE_BIT].duration1 = 0;
dshot_tx_rmt_item[DSHOT_PAUSE_BIT].level1 = 0;
return dshot_rmt_item;
return dshot_tx_rmt_item;
}
// ...just returns the checksum
@ -210,5 +206,5 @@ void DShotRMT::output_rmt_data(const dshot_packet_t& dshot_packet) {
encode_dshot_to_rmt(prepare_rmt_data(dshot_packet));
//
rmt_write_items(rmt_dshot_config.channel, dshot_rmt_item, DSHOT_PACKET_LENGTH, false);
rmt_write_items(rmt_dshot_config.channel, dshot_tx_rmt_item, DSHOT_PACKET_LENGTH, false);
}

View File

@ -1,13 +1,13 @@
//
// Name: ESP32_ESC.ino
// Name: DShotRMT.h
// Created: 20.03.2021 00:49:15
// Author: derdoktor667
//
#pragma once
#include "BlheliCmdMap.h"
#include <Arduino.h>
#include "BlheliCmdMap.h"
#include <driver/rmt.h>
#include <string>
@ -21,7 +21,7 @@ constexpr auto DSHOT_THROTTLE_MIN = 48;
constexpr auto DSHOT_THROTTLE_MAX = 2047;
constexpr auto DSHOT_NULL_PACKET = 0b0000000000000000;
constexpr auto DSHOT_PAUSE = DSHOT_PACKET_LENGTH * DSHOT_CLK_DIVIDER; // ...21bit is recommended, but to be sure
constexpr auto DSHOT_PAUSE = 21; // ...21bit is recommended, but to be sure
constexpr auto DSHOT_PAUSE_BIDIRECTIONAL = DSHOT_PAUSE;
constexpr auto DSHOT_PAUSE_BIT = 16;
@ -81,8 +81,8 @@ class DShotRMT {
DShotRMT(uint8_t pin, uint8_t channel);
~DShotRMT();
DShotRMT(DShotRMT const&);
// DShotRMT& operator=(DShotRMT const&);
// ...safety first ...no parameters, no DShot
bool begin(dshot_mode_t dshot_mode = DSHOT_OFF, bool is_bidirectional = false);
void send_dshot_value(uint16_t throttle_value, telemetric_request_t telemetric_request = NO_TELEMETRIC);
@ -90,7 +90,7 @@ class DShotRMT {
uint8_t* get_dshot_clock_div();
private:
rmt_item32_t dshot_rmt_item[DSHOT_PACKET_LENGTH] = { };
rmt_item32_t dshot_tx_rmt_item[DSHOT_PACKET_LENGTH] = { };
dshot_config_t dshot_config = { };
rmt_config_t rmt_dshot_config = { };