-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decrease allocations for RF encoding + transmitting
- Loading branch information
Showing
13 changed files
with
186 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
#pragma once | ||
|
||
#include "RmtSequence.h" | ||
#include "ShockerCommandType.h" | ||
|
||
#include <esp32-hal-rmt.h> | ||
|
||
#include <cstdint> | ||
|
||
namespace OpenShock::Rmt::CaiXianlinEncoder { | ||
RmtSequence GetSequence(uint16_t shockerId, uint8_t channelId, OpenShock::ShockerCommandType type, uint8_t intensity); | ||
size_t GetBufferSize(); | ||
bool FillBuffer(rmt_data_t* data, uint16_t shockerId, uint8_t channelId, ShockerCommandType type, uint8_t intensity); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,70 @@ | ||
#pragma once | ||
|
||
#include "RmtSequence.h" | ||
#include "Common.h" | ||
#include "ShockerCommandType.h" | ||
#include "ShockerModelType.h" | ||
|
||
#include <esp32-hal-rmt.h> | ||
|
||
#include <cstdint> | ||
|
||
namespace OpenShock::Rmt { | ||
RmtSequence GetSequence(ShockerModelType model, uint16_t shockerId, OpenShock::ShockerCommandType type, uint8_t intensity); | ||
class MainEncoder { | ||
DISABLE_COPY(MainEncoder); | ||
|
||
public: | ||
MainEncoder() | ||
: m_data(nullptr) | ||
, m_size(0) | ||
, m_shockerModel() | ||
, m_shockerId(0) | ||
{ | ||
} | ||
MainEncoder(ShockerModelType shockerModel, uint16_t shockerId); | ||
MainEncoder(MainEncoder&& other) noexcept | ||
: m_data(other.m_data) | ||
, m_size(other.m_size) | ||
, m_shockerModel(other.m_shockerModel) | ||
, m_shockerId(other.m_shockerId) | ||
{ | ||
other.m_data = nullptr; | ||
other.m_size = 0; | ||
other.m_shockerId = 0; | ||
} | ||
~MainEncoder() { free(m_data); } | ||
|
||
inline bool is_valid() const noexcept { return m_data != nullptr && m_size > 0; } | ||
|
||
inline ShockerModelType shockerModel() const noexcept { return m_shockerModel; } | ||
inline uint16_t shockerId() const noexcept { return m_shockerId; } | ||
|
||
inline rmt_data_t* payload() noexcept { return m_data; } | ||
inline const rmt_data_t* payload() const noexcept { return m_data; } | ||
inline rmt_data_t* terminator() noexcept { return m_data + m_size; } | ||
inline const rmt_data_t* terminator() const noexcept { return m_data + m_size; } | ||
inline size_t size() const noexcept { return m_size; } | ||
|
||
bool fillSequence(ShockerCommandType commandType, uint8_t intensity); | ||
|
||
MainEncoder& operator=(MainEncoder&& other) | ||
{ | ||
if (this == &other) return *this; | ||
|
||
free(m_data); | ||
|
||
m_data = other.m_data; | ||
m_size = other.m_size; | ||
|
||
other.m_data = nullptr; | ||
other.m_size = 0; | ||
|
||
return *this; | ||
} | ||
|
||
private: | ||
rmt_data_t* m_data; | ||
size_t m_size; | ||
ShockerModelType m_shockerModel; | ||
uint16_t m_shockerId; | ||
}; | ||
} // namespace OpenShock::Rmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
#pragma once | ||
|
||
#include "RmtSequence.h" | ||
#include "ShockerCommandType.h" | ||
|
||
#include <esp32-hal-rmt.h> | ||
|
||
#include <cstdint> | ||
|
||
namespace OpenShock::Rmt::Petrainer998DREncoder { | ||
RmtSequence GetSequence(uint16_t shockerId, OpenShock::ShockerCommandType type, uint8_t intensity); | ||
size_t GetBufferSize(); | ||
bool FillBuffer(rmt_data_t* data, uint16_t shockerId, ShockerCommandType type, uint8_t intensity); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
#pragma once | ||
|
||
#include "RmtSequence.h" | ||
#include "ShockerCommandType.h" | ||
|
||
#include <esp32-hal-rmt.h> | ||
|
||
#include <cstdint> | ||
|
||
namespace OpenShock::Rmt::PetrainerEncoder { | ||
RmtSequence GetSequence(uint16_t shockerId, OpenShock::ShockerCommandType type, uint8_t intensity); | ||
size_t GetBufferSize(); | ||
bool FillBuffer(rmt_data_t* data, uint16_t shockerId, ShockerCommandType type, uint8_t intensity); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
#pragma once | ||
|
||
#include "RmtSequence.h" | ||
#include "ShockerCommandType.h" | ||
|
||
#include <esp32-hal-rmt.h> | ||
|
||
#include <cstdint> | ||
|
||
namespace OpenShock::Rmt::T330Encoder { | ||
RmtSequence GetSequence(uint16_t shockerId, OpenShock::ShockerCommandType type, uint8_t intensity); | ||
size_t GetBufferSize(); | ||
bool FillBuffer(rmt_data_t* data, uint16_t shockerId, ShockerCommandType type, uint8_t intensity); | ||
} |
Oops, something went wrong.