mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-13 10:09:30 +00:00
Add power off command to I2cDev_PPmod class (#3152)
This commit is contained in:
@@ -242,4 +242,12 @@ std::vector<uint8_t> I2cDev_PPmod::downloadStandaloneApp(uint32_t index, size_t
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool I2cDev_PPmod::send_poweroff_command() {
|
||||||
|
if (isLocked()) return false; // device is busy
|
||||||
|
Command cmd = Command::COMMAND_POWER_OFF;
|
||||||
|
uint8_t tmp = 0; // result of the ack. 0 = no, 1 = ok
|
||||||
|
i2c_read((uint8_t*)&cmd, 2, &tmp, 1);
|
||||||
|
return (tmp == 1);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace i2cdev
|
} // namespace i2cdev
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ class I2cDev_PPmod : public I2cDev {
|
|||||||
COMMAND_SHELL_PPTOMOD_DATA, // pp shell to esp. size not defined
|
COMMAND_SHELL_PPTOMOD_DATA, // pp shell to esp. size not defined
|
||||||
COMMAND_SHELL_MODTOPP_DATA_SIZE, // how many bytes the esp has to send to pp's shell
|
COMMAND_SHELL_MODTOPP_DATA_SIZE, // how many bytes the esp has to send to pp's shell
|
||||||
COMMAND_SHELL_MODTOPP_DATA, // the actual bytes sent by esp. 1st byte's 1st bit is the "hasmore" flag, the remaining 7 bits are the size of the data. exactly 64 byte follows.
|
COMMAND_SHELL_MODTOPP_DATA, // the actual bytes sent by esp. 1st byte's 1st bit is the "hasmore" flag, the remaining 7 bits are the size of the data. exactly 64 byte follows.
|
||||||
|
// poweroff command
|
||||||
|
COMMAND_POWER_OFF, // requests power off from the esp, and after it needs a full power cycle to get it back again
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -92,6 +93,8 @@ class I2cDev_PPmod : public I2cDev {
|
|||||||
uint16_t get_shell_buffer_bytes();
|
uint16_t get_shell_buffer_bytes();
|
||||||
bool get_shell_get_buffer_data(uint8_t* buff, size_t len);
|
bool get_shell_get_buffer_data(uint8_t* buff, size_t len);
|
||||||
|
|
||||||
|
bool send_poweroff_command(); // sends the command to power off the device. Restarting the esp needs a full power cycle!
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t self_timer = 0;
|
uint8_t self_timer = 0;
|
||||||
uint64_t mask = 0; // feauture mask, that indicates what the device can do. this will determinate what we will query from the device
|
uint64_t mask = 0; // feauture mask, that indicates what the device can do. this will determinate what we will query from the device
|
||||||
|
|||||||
Reference in New Issue
Block a user