Skip to content

Commit

Permalink
Updates to High Power Relay code
Browse files Browse the repository at this point in the history
  • Loading branch information
emmabaird committed Jun 3, 2024
1 parent cf1104e commit 028f791
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
29 changes: 28 additions & 1 deletion lib/sensors/high_power_relay.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
#include "high_power_relay.hpp"
#include "high_power_relay.hpp"

namespace hyped::sensors {

std::optional<HpRelay> HpRelay::create(core::ILogger &logger,
std::shared_ptr<io::IGpio> gpio,
const std::uint8_t new_pin)
{
const auto reader = gpio->getReader(new_pin, io::Edge::kNone);
if (!reader) {
logger.log(core::LogLevel::kFatal, "Failed to create HpRelay instance");
return std::nullopt;
}
logger.log(core::LogLevel::kDebug, "Successfully created HpRelay instance");
return Keyence(logger, *reader);
}

HpRelay::HpRelay(core::ILogger &logger, std::shared_ptr<io::IGpioReader> gpio_reader)
: gpio_reader_(gpio_reader),
logger_(logger)
{
}

HpRelay::~HpRelay()
{
}

} // namespace hyped::sensors
13 changes: 7 additions & 6 deletions lib/sensors/high_power_relay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@

namespace hyped::sensors {
class HpRelay {
public:
public:
static std::optional<HpRelay> create(core::ILogger &logger,
std::shared_ptr<io::IGpio> gpio,
const std::uint8_t new_pin);
std::shared_ptr<io::IGpio> gpio,
const std::uint8_t new_pin);

~HpRelay();
};
} // namespace::sensors

} // namespace hyped::sensors

0 comments on commit 028f791

Please sign in to comment.