Flesh out onboarding a little, and add a way to get into it
This commit is contained in:
@@ -43,6 +43,9 @@ class NvsStorage {
|
||||
auto AmpCurrentVolume() -> std::future<uint16_t>;
|
||||
auto AmpCurrentVolume(uint16_t) -> std::future<bool>;
|
||||
|
||||
auto HasShownOnboarding() -> std::future<bool>;
|
||||
auto HasShownOnboarding(bool) -> std::future<bool>;
|
||||
|
||||
explicit NvsStorage(std::unique_ptr<tasks::Worker>, nvs_handle_t);
|
||||
~NvsStorage();
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ static constexpr char kKeyOutput[] = "out";
|
||||
static constexpr char kKeyBrightness[] = "bright";
|
||||
static constexpr char kKeyAmpMaxVolume[] = "hp_vol_max";
|
||||
static constexpr char kKeyAmpCurrentVolume[] = "hp_vol";
|
||||
static constexpr char kKeyOnboarded[] = "intro";
|
||||
|
||||
auto NvsStorage::OpenSync() -> NvsStorage* {
|
||||
esp_err_t err = nvs_flash_init();
|
||||
@@ -187,4 +188,19 @@ auto NvsStorage::AmpCurrentVolume(uint16_t val) -> std::future<bool> {
|
||||
});
|
||||
}
|
||||
|
||||
auto NvsStorage::HasShownOnboarding() -> std::future<bool> {
|
||||
return writer_->Dispatch<bool>([&]() -> bool {
|
||||
uint8_t out = true;
|
||||
nvs_get_u8(handle_, kKeyOnboarded, &out);
|
||||
return out;
|
||||
});
|
||||
}
|
||||
|
||||
auto NvsStorage::HasShownOnboarding(bool val) -> std::future<bool> {
|
||||
return writer_->Dispatch<bool>([&]() {
|
||||
nvs_set_u8(handle_, kKeyOnboarded, val);
|
||||
return nvs_commit(handle_) == ESP_OK;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace drivers
|
||||
|
||||
@@ -33,14 +33,17 @@ class Onboarding : public Screen {
|
||||
namespace onboarding {
|
||||
|
||||
class LinkToManual : public Onboarding {
|
||||
public:
|
||||
LinkToManual();
|
||||
};
|
||||
|
||||
class Controls : public Onboarding {
|
||||
public:
|
||||
Controls();
|
||||
};
|
||||
|
||||
class FormatSdCard : public Onboarding {
|
||||
public:
|
||||
FormatSdCard();
|
||||
};
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
|
||||
@@ -101,6 +102,9 @@ class Onboarding : public UiState {
|
||||
void entry() override;
|
||||
|
||||
using UiState::react;
|
||||
|
||||
private:
|
||||
uint8_t progress_;
|
||||
};
|
||||
|
||||
class Browse : public UiState {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "screen_onboarding.hpp"
|
||||
|
||||
#include "core/lv_obj_pos.h"
|
||||
#include "draw/lv_draw_rect.h"
|
||||
#include "extra/libs/qrcode/lv_qrcode.h"
|
||||
#include "extra/widgets/win/lv_win.h"
|
||||
@@ -26,23 +27,31 @@ Onboarding::Onboarding(const std::string& title,
|
||||
window_ = lv_win_create(root_, 18);
|
||||
if (show_prev) {
|
||||
prev_button_ = lv_win_add_btn(window_, LV_SYMBOL_LEFT, 20);
|
||||
lv_group_add_obj(group_, prev_button_);
|
||||
}
|
||||
title_ = lv_win_add_title(window_, title.c_str());
|
||||
if (show_next) {
|
||||
next_button_ = lv_win_add_btn(window_, LV_SYMBOL_RIGHT, 20);
|
||||
lv_group_add_obj(group_, next_button_);
|
||||
}
|
||||
|
||||
content_ = lv_win_get_content(window_);
|
||||
lv_obj_set_layout(content_, LV_LAYOUT_FLEX);
|
||||
lv_obj_set_flex_flow(content_, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(content_, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER,
|
||||
LV_FLEX_ALIGN_CENTER);
|
||||
}
|
||||
|
||||
namespace onboarding {
|
||||
|
||||
LinkToManual::LinkToManual() : Onboarding("Welcome!", false, true) {
|
||||
lv_obj_t* intro = lv_label_create(content_);
|
||||
lv_label_set_text(intro, "this screen links you to better instructions");
|
||||
lv_label_set_text(intro, "For full instructions, see the manual:");
|
||||
lv_label_set_long_mode(intro, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_set_size(intro, lv_pct(100), LV_SIZE_CONTENT);
|
||||
|
||||
lv_obj_t* qr =
|
||||
lv_qrcode_create(content_, 100, lv_color_black(), lv_color_white());
|
||||
lv_qrcode_create(content_, 80, lv_color_black(), lv_color_white());
|
||||
lv_qrcode_update(qr, kManualUrl, sizeof(kManualUrl));
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "relative_wheel.hpp"
|
||||
#include "screen.hpp"
|
||||
#include "screen_menu.hpp"
|
||||
#include "screen_onboarding.hpp"
|
||||
#include "screen_playing.hpp"
|
||||
#include "screen_settings.hpp"
|
||||
#include "screen_splash.hpp"
|
||||
@@ -150,7 +151,15 @@ void Splash::react(const system_fsm::BootComplete& ev) {
|
||||
ESP_LOGE(kTag, "no input devices initialised!");
|
||||
}
|
||||
|
||||
if (sServices->nvs().HasShownOnboarding().get()) {
|
||||
transit<Browse>();
|
||||
} else {
|
||||
transit<Onboarding>();
|
||||
}
|
||||
}
|
||||
|
||||
void Onboarding::entry() {
|
||||
sCurrentScreen.reset(new screens::onboarding::LinkToManual());
|
||||
}
|
||||
|
||||
void Browse::entry() {}
|
||||
|
||||
Reference in New Issue
Block a user