....hotfix
This commit is contained in:
parent
a507871cbd
commit
0d2bf9e117
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// Name: ESP32_ESC.ino
|
// Name: DShotRMT.cpp
|
||||||
// Created: 20.03.2021 00:49:15
|
// Created: 20.03.2021 00:49:15
|
||||||
// Author: derdoktor667
|
// Author: derdoktor667
|
||||||
//
|
//
|
||||||
|
|
@ -37,10 +37,6 @@ DShotRMT::DShotRMT(DShotRMT const &) {
|
||||||
// ...write me
|
// ...write me
|
||||||
}
|
}
|
||||||
|
|
||||||
// DShotRMT& DShotRMT::operator=(DShotRMT const&) {
|
|
||||||
// TODO: hier return-Anweisung eingeben
|
|
||||||
// }
|
|
||||||
|
|
||||||
bool DShotRMT::begin(dshot_mode_t dshot_mode, bool is_bidirectional) {
|
bool DShotRMT::begin(dshot_mode_t dshot_mode, bool is_bidirectional) {
|
||||||
dshot_config.mode = dshot_mode;
|
dshot_config.mode = dshot_mode;
|
||||||
dshot_config.clk_div = DSHOT_CLK_DIVIDER;
|
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) {
|
for (int i = 0; i < DSHOT_PAUSE_BIT; i++, parsed_packet <<= 1) {
|
||||||
if (parsed_packet & 0b1000000000000000) {
|
if (parsed_packet & 0b1000000000000000) {
|
||||||
// set one
|
// set one
|
||||||
dshot_rmt_item[i].duration0 = dshot_config.ticks_one_high;
|
dshot_tx_rmt_item[i].duration0 = dshot_config.ticks_one_high;
|
||||||
dshot_rmt_item[i].level0 = 1;
|
dshot_tx_rmt_item[i].level0 = 1;
|
||||||
dshot_rmt_item[i].duration1 = dshot_config.ticks_one_low;
|
dshot_tx_rmt_item[i].duration1 = dshot_config.ticks_one_low;
|
||||||
dshot_rmt_item[i].level1 = 0;
|
dshot_tx_rmt_item[i].level1 = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// set zero
|
// set zero
|
||||||
dshot_rmt_item[i].duration0 = dshot_config.ticks_zero_high;
|
dshot_tx_rmt_item[i].duration0 = dshot_config.ticks_zero_high;
|
||||||
dshot_rmt_item[i].level0 = 1;
|
dshot_tx_rmt_item[i].level0 = 1;
|
||||||
dshot_rmt_item[i].duration1 = dshot_config.ticks_zero_low;
|
dshot_tx_rmt_item[i].duration1 = dshot_config.ticks_zero_low;
|
||||||
dshot_rmt_item[i].level1 = 0;
|
dshot_tx_rmt_item[i].level1 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...end marker added to each frame
|
// ...end marker added to each frame
|
||||||
dshot_rmt_item[DSHOT_PAUSE_BIT].duration0 = DSHOT_PAUSE_BIDIRECTIONAL;
|
dshot_tx_rmt_item[DSHOT_PAUSE_BIT].duration0 = DSHOT_PAUSE_BIDIRECTIONAL;
|
||||||
dshot_rmt_item[DSHOT_PAUSE_BIT].level0 = 0;
|
dshot_tx_rmt_item[DSHOT_PAUSE_BIT].level0 = 0;
|
||||||
dshot_rmt_item[DSHOT_PAUSE_BIT].duration1 = 0;
|
dshot_tx_rmt_item[DSHOT_PAUSE_BIT].duration1 = 0;
|
||||||
dshot_rmt_item[DSHOT_PAUSE_BIT].level1 = 0;
|
dshot_tx_rmt_item[DSHOT_PAUSE_BIT].level1 = 0;
|
||||||
|
|
||||||
return dshot_rmt_item;
|
return dshot_tx_rmt_item;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...just returns the checksum
|
// ...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));
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
//
|
//
|
||||||
// Name: ESP32_ESC.ino
|
// Name: DShotRMT.h
|
||||||
// Created: 20.03.2021 00:49:15
|
// Created: 20.03.2021 00:49:15
|
||||||
// Author: derdoktor667
|
// Author: derdoktor667
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlheliCmdMap.h"
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include "BlheliCmdMap.h"
|
||||||
|
|
||||||
#include <driver/rmt.h>
|
#include <driver/rmt.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
@ -21,7 +21,7 @@ constexpr auto DSHOT_THROTTLE_MIN = 48;
|
||||||
constexpr auto DSHOT_THROTTLE_MAX = 2047;
|
constexpr auto DSHOT_THROTTLE_MAX = 2047;
|
||||||
constexpr auto DSHOT_NULL_PACKET = 0b0000000000000000;
|
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_BIDIRECTIONAL = DSHOT_PAUSE;
|
||||||
constexpr auto DSHOT_PAUSE_BIT = 16;
|
constexpr auto DSHOT_PAUSE_BIT = 16;
|
||||||
|
|
||||||
|
|
@ -81,8 +81,8 @@ class DShotRMT {
|
||||||
DShotRMT(uint8_t pin, uint8_t channel);
|
DShotRMT(uint8_t pin, uint8_t channel);
|
||||||
~DShotRMT();
|
~DShotRMT();
|
||||||
DShotRMT(DShotRMT const&);
|
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);
|
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);
|
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();
|
uint8_t* get_dshot_clock_div();
|
||||||
|
|
||||||
private:
|
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 = { };
|
dshot_config_t dshot_config = { };
|
||||||
rmt_config_t rmt_dshot_config = { };
|
rmt_config_t rmt_dshot_config = { };
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue