- Unlock device - Hold both volume buttons - Lock device - Unlock devicecustom
parent
a69b95187b
commit
934b1484b2
@ -0,0 +1,50 @@ |
||||
/*
|
||||
* Copyright 2025 jacqueline <me@jacqueline.id.au> |
||||
* |
||||
* SPDX-License-Identifier: GPL-3.0-only |
||||
*/ |
||||
|
||||
#include "input/input_hard_reset.hpp" |
||||
|
||||
#include "drivers/gpios.hpp" |
||||
#include "esp_system.h" |
||||
#include "input/input_hook_actions.hpp" |
||||
|
||||
namespace input { |
||||
|
||||
HardReset::HardReset(drivers::IGpios& gpios) : gpios_(gpios) {} |
||||
|
||||
auto HardReset::read(lv_indev_data_t* data) -> void { |
||||
bool buttons_pressed = !gpios_.Get(drivers::IGpios::Pin::kKeyUp) && |
||||
!gpios_.Get(drivers::IGpios::Pin::kKeyDown); |
||||
if (!buttons_pressed) { |
||||
stage_ = 0; |
||||
return; |
||||
} |
||||
|
||||
bool locked = gpios_.IsLocked(); |
||||
|
||||
if (stage_ == 0 && !locked) { |
||||
stage_++; |
||||
return; |
||||
} |
||||
if (stage_ == 1 && locked) { |
||||
stage_++; |
||||
return; |
||||
} |
||||
if (stage_ == 2 && !locked) { |
||||
// Bye!
|
||||
esp_restart(); |
||||
} |
||||
} |
||||
|
||||
auto HardReset::name() -> std::string { |
||||
return "hard_reset"; |
||||
} |
||||
|
||||
auto HardReset::triggers() |
||||
-> std::vector<std::reference_wrapper<TriggerHooks>> { |
||||
return {}; |
||||
} |
||||
|
||||
} // namespace input
|
@ -0,0 +1,34 @@ |
||||
/*
|
||||
* Copyright 2025 jacqueline <me@jacqueline.id.au> |
||||
* |
||||
* SPDX-License-Identifier: GPL-3.0-only |
||||
*/ |
||||
|
||||
#pragma once |
||||
|
||||
#include <cstdint> |
||||
|
||||
#include "indev/lv_indev.h" |
||||
|
||||
#include "drivers/gpios.hpp" |
||||
#include "input/input_device.hpp" |
||||
#include "input/input_hook.hpp" |
||||
|
||||
namespace input { |
||||
|
||||
class HardReset : public IInputDevice { |
||||
public: |
||||
HardReset(drivers::IGpios&); |
||||
|
||||
auto read(lv_indev_data_t* data) -> void override; |
||||
|
||||
auto name() -> std::string override; |
||||
auto triggers() -> std::vector<std::reference_wrapper<TriggerHooks>> override; |
||||
|
||||
private: |
||||
drivers::IGpios& gpios_; |
||||
|
||||
int stage_; |
||||
}; |
||||
|
||||
} // namespace input
|
Loading…
Reference in new issue