key-worker.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "key-worker.h"
  2. #include <callback-connector.h>
  3. #include <maxim_crc.h>
  4. extern COMP_HandleTypeDef hcomp1;
  5. KeyReader::Error KeyWorker::read(iButtonKey* key) {
  6. KeyReader::Error result = key_reader.read(key);
  7. return result;
  8. }
  9. void KeyWorker::start_read() {
  10. key_reader.start();
  11. }
  12. void KeyWorker::stop_read() {
  13. key_reader.stop();
  14. }
  15. bool KeyWorker::emulated() {
  16. return key_emulator.emulated();
  17. }
  18. void KeyWorker::start_emulate(iButtonKey* key) {
  19. key_emulator.start(key);
  20. }
  21. void KeyWorker::stop_emulate() {
  22. key_emulator.stop();
  23. }
  24. KeyWriter::Error KeyWorker::write(iButtonKey* key) {
  25. return key_writer.write(key);
  26. }
  27. void KeyWorker::start_write() {
  28. key_writer.start();
  29. }
  30. void KeyWorker::stop_write() {
  31. key_writer.stop();
  32. }
  33. KeyWorker::KeyWorker(const GpioPin* one_wire_gpio)
  34. : onewire_master{one_wire_gpio}
  35. , onewire_slave{one_wire_gpio}
  36. , key_reader{&onewire_master}
  37. , key_emulator{&onewire_slave}
  38. , key_writer{&onewire_master} {
  39. }
  40. KeyWorker::~KeyWorker() {
  41. }