Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions src/apps/launcher/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ void LauncherApp::run() {
ITEM::MENU(K_S_LAUNCHER_SD_SPEED, [this]() { this->setSpiSDSpeed(); }),
}
),
ITEM::SUBMENU(
K_S_LAUNCHER_DISPLAY,
{
ITEM::MENU(K_S_LAUNCHER_DISPLAY_SPEED, [this]() { this->setDisplaySpeed(); }),
ITEM::MENU(K_S_LAUNCHER_DISPLAY_SPI_MODE, [this]() { this->setDisplaySpiMode(); }),
}
),
ITEM::MENU(K_S_LAUNCHER_SOUND, [this]() { this->runApp<SoundConfigApp>(); }),
ITEM::SUBMENU(
K_S_LAUNCHER_SERVICES,
Expand Down Expand Up @@ -804,6 +811,79 @@ void LauncherApp::setSpiSDSpeed() {
alert("", K_S_CHANGE_ON_NEXT_BOOT);
}

void LauncherApp::setDisplaySpeed() {
uint32_t displayFrequencies[] = {
10000000, // 10 MHz
20000000, // 20 MHz
40000000, // 40 MHz
80000000 // 80 MHz
};

lilka::Menu setDisplaySpeedMenu;
setDisplaySpeedMenu.setTitle(K_S_LAUNCHER_DISPLAY_SPEED);
setDisplaySpeedMenu.addActivationButton(K_BTN_BACK); // Exit

// Add frequencies to menu
for (auto i = 0; i < sizeof(displayFrequencies) / sizeof(displayFrequencies[0]); i++)
setDisplaySpeedMenu.addItem(StringFormat("%d MHz", displayFrequencies[i] / 1000000));

// Perform draw
while (!setDisplaySpeedMenu.isFinished()) {
setDisplaySpeedMenu.update();
setDisplaySpeedMenu.draw(canvas);
queueDraw();
}
auto button = setDisplaySpeedMenu.getButton();

if (button == K_BTN_BACK) return;

auto index = setDisplaySpeedMenu.getCursor();

// store new frequency to NVS
NVS_LOCK;
Preferences prefs;
prefs.begin(LILKA_SPI_NVS_NAMESPACE, false);
prefs.putUInt(LILKA_SPI_NVS_DISPLAY_FREQUENCY_KEY, displayFrequencies[index]);
prefs.end();
NVS_UNLOCK;

alert("", K_S_CHANGE_ON_NEXT_BOOT);
}

void LauncherApp::setDisplaySpiMode() {
uint8_t spiModes[] = {SPI_MODE0, SPI_MODE1, SPI_MODE2, SPI_MODE3};

lilka::Menu setDisplaySpiModeMenu;
setDisplaySpiModeMenu.setTitle(K_S_LAUNCHER_DISPLAY_SPI_MODE);
setDisplaySpiModeMenu.addActivationButton(K_BTN_BACK); // Exit

// Add SPI modes to menu
for (auto i = 0; i < sizeof(spiModes) / sizeof(spiModes[0]); i++)
setDisplaySpiModeMenu.addItem(StringFormat("SPI_MODE%d", spiModes[i]));

// Perform draw
while (!setDisplaySpiModeMenu.isFinished()) {
setDisplaySpiModeMenu.update();
setDisplaySpiModeMenu.draw(canvas);
queueDraw();
}
auto button = setDisplaySpiModeMenu.getButton();

if (button == K_BTN_BACK) return;

auto index = setDisplaySpiModeMenu.getCursor();

// store new SPI mode to NVS
NVS_LOCK;
Preferences prefs;
prefs.begin(LILKA_SPI_NVS_NAMESPACE, false);
prefs.putUChar(LILKA_SPI_NVS_DISPLAY_MODE_KEY, spiModes[index]);
prefs.end();
NVS_UNLOCK;

alert("", K_S_CHANGE_ON_NEXT_BOOT);
}

void LauncherApp::wifiToggle() {
NetworkService* networkService = static_cast<NetworkService*>(ksystem.services["network"]);
networkService->setEnabled(!networkService->getEnabled());
Expand Down
2 changes: 2 additions & 0 deletions src/apps/launcher/launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class LauncherApp : public App {
void wifiToggle();
void wifiManager();
void setSpiSDSpeed();
void setDisplaySpeed();
void setDisplaySpiMode();
void setMDNSHostname();
void about();
void info();
Expand Down
3 changes: 3 additions & 0 deletions src/keira/localizations/lang_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
#define K_S_LAUNCHER_SD "SD"
#define K_S_LAUNCHER_SD_FORMAT "Format SD"
#define K_S_LAUNCHER_SD_SPEED "SD card frequency"
#define K_S_LAUNCHER_DISPLAY "Display"
#define K_S_LAUNCHER_DISPLAY_SPEED "Display frequency"
#define K_S_LAUNCHER_DISPLAY_SPI_MODE "Display SPI mode"
#define K_S_LAUNCHER_SOUND "Sound"
#define K_S_LAUNCHER_SERVICES K_S_SERVICES
#define K_S_LAUNCHER_WEB K_S_WEB
Expand Down
3 changes: 3 additions & 0 deletions src/keira/localizations/lang_uk.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
#define K_S_LAUNCHER_SD "SD"
#define K_S_LAUNCHER_SD_FORMAT "Форматування SD-карти"
#define K_S_LAUNCHER_SD_SPEED "Частота SD картки"
#define K_S_LAUNCHER_DISPLAY "Дисплей"
#define K_S_LAUNCHER_DISPLAY_SPEED "Частота дисплея"
#define K_S_LAUNCHER_DISPLAY_SPI_MODE "Режим SPI дисплея"
#define K_S_LAUNCHER_SOUND "Звук"
#define K_S_LAUNCHER_SERVICES K_S_SERVICES
#define K_S_LAUNCHER_WEB K_S_WEB
Expand Down
Loading