Skip to content

Commit

Permalink
add factory reset cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Dec 3, 2024
1 parent d5893a2 commit cc8bffc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
20 changes: 17 additions & 3 deletions EPD/EPD_ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ static uint32_t epd_config_load(epd_config_t *cfg)
return pstorage_load((uint8_t *)cfg, &m_flash_handle, sizeof(epd_config_t), 0);
}

static uint32_t epd_config_clear(epd_config_t *cfg)
{
return pstorage_clear(&m_flash_handle, sizeof(epd_config_t));
}

static uint32_t epd_config_save(epd_config_t *cfg)
{
uint32_t err_code;
err_code = pstorage_clear(&m_flash_handle, sizeof(epd_config_t));
if (err_code != NRF_SUCCESS)
uint32_t err_code;
if ((err_code = epd_config_clear(cfg)) != NRF_SUCCESS)
{
return err_code;
}
Expand Down Expand Up @@ -192,6 +196,11 @@ static void epd_service_process(ble_epd_t * p_epd, uint8_t * p_data, uint16_t le
ble_epd_sleep_prepare(p_epd);
sd_power_system_off();
break;

case EPD_CMD_CFG_ERASE:
epd_config_clear(&p_epd->config);
NVIC_SystemReset();
break;

default:
break;
Expand Down Expand Up @@ -357,6 +366,11 @@ static void epd_config_init(ble_epd_t * p_epd)
p_epd->config.driver_id = p_epd->driver->id;
save_config = true;
}
if (p_epd->config.wakeup_pin == 0xFF)
{
p_epd->config.wakeup_pin = 7;
save_config = true;
}
if (save_config)
{
epd_config_save(&p_epd->config);
Expand Down
1 change: 1 addition & 0 deletions EPD/EPD_ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ enum EPD_CMDS
EPD_CMD_SET_CONFIG = 0x90, /**< set full EPD config */
EPD_CMD_SYS_RESET = 0x91, /**< MCU reset */
EPD_CMD_SYS_SLEEP = 0x92, /**< MCU enter sleep mode */
EPD_CMD_CFG_ERASE = 0x99, /**< Erase config and reset */
};

/**< EPD driver IDs. */
Expand Down
1 change: 1 addition & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ <h3>4.2 寸电子墨水屏蓝牙控制器(nRF51)</h3>
<li><code>90</code>+<code>配置</code>: 写入配置信息(重启生效,格式参考源码 <code>epd_config_t</code></li>
<li><code>91</code>: 系统重启</li>
<li><code>92</code>: 系统睡眠</li>
<li><code>99</code>: 恢复默认设置并重启</li>
</ul>
</li>
</ul>
Expand Down

0 comments on commit cc8bffc

Please sign in to comment.