Skip to content

Commit

Permalink
Merge pull request #24 from OpenShock/feature/implement-flatbuffers
Browse files Browse the repository at this point in the history
Implement flatbuffers
  • Loading branch information
hhvrc authored Oct 6, 2023
2 parents 31ed932 + 9e7fdcd commit 4d425c9
Show file tree
Hide file tree
Showing 15 changed files with 442 additions and 28 deletions.
4 changes: 3 additions & 1 deletion include/CommandHandler.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#pragma once

#include "ShockerCommandType.h"

#include <cstdint>

// TODO: This is bad architecture. Fix it.

namespace OpenShock::CommandHandler {
void Init();
bool HandleCommand(std::uint16_t shockerId,
std::uint8_t method,
OpenShock::ShockerCommandType type,
std::uint8_t intensity,
unsigned int duration,
std::uint8_t shockerModel);
Expand Down
4 changes: 3 additions & 1 deletion include/RFTransmitter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "ShockerCommandType.h"

#include <cstdint>

// Forward definitions to remove clutter
Expand All @@ -19,7 +21,7 @@ namespace OpenShock {

bool SendCommand(std::uint8_t shockerModel,
std::uint16_t shockerId,
std::uint8_t method,
OpenShock::ShockerCommandType type,
std::uint8_t intensity,
unsigned int duration);
void ClearPendingCommands();
Expand Down
4 changes: 3 additions & 1 deletion include/Rmt/MainEncoder.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "ShockerCommandType.h"

#include <esp32-hal.h>

#include <cstdint>
Expand All @@ -8,6 +10,6 @@

namespace OpenShock::Rmt {
std::vector<rmt_data_t>
GetSequence(std::uint16_t shockerId, std::uint8_t method, std::uint8_t intensity, std::uint8_t shockerModel);
GetSequence(std::uint16_t shockerId, OpenShock::ShockerCommandType type, std::uint8_t intensity, std::uint8_t shockerModel);
std::shared_ptr<std::vector<rmt_data_t>> GetZeroSequence(std::uint16_t shockerId, std::uint8_t shockerModel);
}
4 changes: 3 additions & 1 deletion include/Rmt/PetTrainerEncoder.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#pragma once

#include "ShockerCommandType.h"

#include <esp32-hal.h>

#include <cstdint>
#include <vector>

namespace OpenShock::Rmt::PetTrainerEncoder {
std::vector<rmt_data_t> GetSequence(std::uint16_t shockerId, std::uint8_t method, std::uint8_t intensity);
std::vector<rmt_data_t> GetSequence(std::uint16_t shockerId, OpenShock::ShockerCommandType type, std::uint8_t intensity);
}
8 changes: 6 additions & 2 deletions include/Rmt/XlcEncoder.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#pragma once

#include "ShockerCommandType.h"

#include <esp32-hal.h>

#include <cstdint>
#include <vector>

namespace OpenShock::Rmt::XlcEncoder {
std::vector<rmt_data_t>
GetSequence(std::uint16_t transmitterId, std::uint8_t channelId, std::uint8_t method, std::uint8_t intensity);
std::vector<rmt_data_t> GetSequence(std::uint16_t transmitterId,
std::uint8_t channelId,
OpenShock::ShockerCommandType type,
std::uint8_t intensity);
}
14 changes: 14 additions & 0 deletions include/ShockerCommandType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <cstdint>

namespace OpenShock {

enum ShockerCommandType : std::uint8_t {
Stop = 0,
Shock = 1,
Vibrate = 2,
Sound = 3,
};

} // namespace OpenShock
Loading

0 comments on commit 4d425c9

Please sign in to comment.