Skip to content

Commit 3c021f3

Browse files
authored
Merge pull request #24 from 203Electronics/2.3
2.3
2 parents af9d141 + 50f8bce commit 3c021f3

44 files changed

Lines changed: 623 additions & 1578 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

MatrixOS.code-workspace

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"terminal.integrated.shell.windows" : "cmd.exe",
99
"terminal.integrated.shellArgs.windows" : [
1010
"/k",
11-
"C:/Espressif/frameworks/esp-idf-v4.4.3/export.bat"
11+
"C:/Espressif/frameworks/esp-idf-v5.0/export.bat"
1212
],
1313
"editor.formatOnType": true,
1414
"files.associations": {

applications/Matrix/FactoryMenu/KeyPadSettings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void FactoryMenu::KeyPadSettings() {
5050
(Fract16)(MatrixOS::UIInterface::NumberSelector8x8((uint16_t)Device::KeyPad::keypad_high_threshold.Get() /
5151
256,
5252
0x00FFFF, "Keypad High Threshold",
53-
Device::KeyPad::keypad_low_threshold.Get(), 255) *
53+
1, 255) *
5454
256);
5555
Device::KeyPad::keypad_config.high_threshold = Device::KeyPad::keypad_high_threshold;
5656
}

applications/Setting/Setting.cpp

Lines changed: 61 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -77,63 +77,64 @@ void Setting::Start() {
7777
UI::Start();
7878
}
7979

80-
// bool Setting::KeyEvent(uint16_t KeyID, KeyInfo* keyInfo) {
81-
// Point xy = MatrixOS::KEYPAD::ID2XY(KeyID);
82-
83-
// if (xy && keyInfo->state == RELEASED) // IF XY is vaild, means it's on the main grid
84-
// {
85-
// if ((konami == 0 || konami == 1) && (xy == origin + Point(0, -1) || xy == origin + Point(1, -1)))
86-
// {
87-
// konami++;
88-
// MatrixOS::Logging::LogDebug("Konami", "Up prssed, %d", konami);
89-
// return false;
90-
// }
91-
// else if ((konami == 2 || konami == 3) && (xy == origin + Point(0, 2) || xy == origin + Point(1, 2)))
92-
// {
93-
// konami++;
94-
// MatrixOS::Logging::LogDebug("Konami", "Down prssed, %d", konami);
95-
// return true;
96-
// }
97-
// else if ((konami == 4 || konami == 6) && (xy == origin + Point(-1, 0) || xy == origin + Point(-1, 1)))
98-
// {
99-
// konami++;
100-
// MatrixOS::Logging::LogDebug("Konami", "Left prssed, %d", konami);
101-
// return true;
102-
// }
103-
// else if ((konami == 5 || konami == 7) && (xy == origin + Point(2, 0) || xy == origin + Point(2, 1)))
104-
// {
105-
// konami++;
106-
// MatrixOS::Logging::LogDebug("Konami", "Right prssed, %d", konami);
107-
// if (konami == 8)
108-
// {
109-
// UI ab("A & B", Color(0xFF0000));
110-
111-
// UIButtonLarge aBtn("A", Color(0xFF0000), Dimension(2, 2), [&]() -> void {
112-
// if (konami == 9)
113-
// MatrixOS::SYS::ExecuteAPP("203 Electronics", "REDACTED");
114-
// else
115-
// ab.Exit();
116-
// });
117-
// ab.AddUIComponent(aBtn, origin + Point(-2, 0));
118-
119-
// UIButtonLarge bBtn("B", Color(0xFF0000), Dimension(2, 2), [&]() -> void {
120-
// if (konami == 8)
121-
// konami++;
122-
// else
123-
// ab.Exit();
124-
// });
125-
// ab.AddUIComponent(bBtn, origin + Point(2, 0));
126-
127-
// ab.Start();
128-
// }
129-
// return true;
130-
// }
131-
// else
132-
// {
133-
// MatrixOS::Logging::LogDebug("Konami", "Cleared");
134-
// konami = 0;
135-
// return false;
136-
// }
137-
// }
138-
// return false;
139-
// }
80+
bool Setting::CustomKeyEvent(KeyEvent* keyEvent) {
81+
MatrixOS::Logging::LogDebug("Konami", "Custom key event");
82+
Point xy = MatrixOS::KEYPAD::ID2XY(keyEvent->id);
83+
84+
if (xy && keyEvent->info.state == RELEASED) // IF XY is vaild, means it's on the main grid
85+
{
86+
if ((konami == 0 || konami == 1) && (xy == origin + Point(0, -1) || xy == origin + Point(1, -1)))
87+
{
88+
konami++;
89+
MatrixOS::Logging::LogDebug("Konami", "Up prssed, %d", konami);
90+
return false;
91+
}
92+
else if ((konami == 2 || konami == 3) && (xy == origin + Point(0, 2) || xy == origin + Point(1, 2)))
93+
{
94+
konami++;
95+
MatrixOS::Logging::LogDebug("Konami", "Down prssed, %d", konami);
96+
return true;
97+
}
98+
else if ((konami == 4 || konami == 6) && (xy == origin + Point(-1, 0) || xy == origin + Point(-1, 1)))
99+
{
100+
konami++;
101+
MatrixOS::Logging::LogDebug("Konami", "Left prssed, %d", konami);
102+
return true;
103+
}
104+
else if ((konami == 5 || konami == 7) && (xy == origin + Point(2, 0) || xy == origin + Point(2, 1)))
105+
{
106+
konami++;
107+
MatrixOS::Logging::LogDebug("Konami", "Right prssed, %d", konami);
108+
if (konami == 8)
109+
{
110+
UI ab("A & B", Color(0xFF0000));
111+
112+
UIButtonLarge aBtn("A", Color(0xFF0000), Dimension(2, 2), [&]() -> void {
113+
if (konami == 9)
114+
MatrixOS::SYS::ExecuteAPP("203 Electronics", "REDACTED");
115+
else
116+
ab.Exit();
117+
});
118+
ab.AddUIComponent(aBtn, origin + Point(-2, 0));
119+
120+
UIButtonLarge bBtn("B", Color(0xFF0000), Dimension(2, 2), [&]() -> void {
121+
if (konami == 8)
122+
konami++;
123+
else
124+
ab.Exit();
125+
});
126+
ab.AddUIComponent(bBtn, origin + Point(2, 0));
127+
128+
ab.Start();
129+
}
130+
return true;
131+
}
132+
else
133+
{
134+
MatrixOS::Logging::LogDebug("Konami", "Cleared");
135+
konami = 0;
136+
return false;
137+
}
138+
}
139+
return false;
140+
}

applications/Setting/Setting.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Setting : public UI {
2020
static void RotateClockwise(EDirection rotation);
2121
static void NextBrightness();
2222

23-
bool CustomKeyEvent(uint16_t KeyID, KeyInfo* keyInfo);
23+
bool CustomKeyEvent(KeyEvent* keyEvent);
2424

2525
private:
2626
uint8_t konami = 0;

applications/Shell/Shell.cpp

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,41 @@ void Shell::Loop() {
1010
}
1111

1212
std::vector<UIButton> commonBarBtns; // Because the UI in the common bar need to exist after the function ends
13+
uint8_t tap_counter = 0;
14+
uint32_t last_tap = 0;
15+
1316
void Shell::AddCommonBarInUI(UI* ui) {
1417
commonBarBtns.clear();
1518
commonBarBtns.reserve(2); // Make sure to change this after adding more stuffs, if vector content got relocated, UI
1619
// will not be able to find it and will hardfault!
17-
commonBarBtns.push_back(UIButton("Application Launcher", Color(0x00FFAA), [&]() -> void {
18-
if (current_page != 0)
19-
{
20-
current_page = 0;
21-
ui->Exit();
22-
}
23-
}));
20+
commonBarBtns.push_back(UIButtonDimmable(
21+
"Application Launcher", Color(0x00FFAA), [&]() -> bool { return current_page == 0; },
22+
[&]() -> void {
23+
if (current_page != 0)
24+
{
25+
current_page = 0;
26+
ui->Exit();
27+
}
28+
else
29+
{
30+
// Tap on the application launcher button 10 times to show hidden apps
31+
if (MatrixOS::SYS::Millis() - last_tap < 1000)
32+
{
33+
tap_counter++;
34+
}
35+
36+
last_tap = MatrixOS::SYS::Millis();
37+
38+
// MatrixOS::Logging::LogInfo("Hidden Launcher", "Tap %d", tap_counter);
39+
40+
if (tap_counter >= 10)
41+
{
42+
tap_counter = 0;
43+
MatrixOS::Logging::LogInfo("Hidden Launcher", "Enter");
44+
HiddenApplicationLauncher();
45+
}
46+
}
47+
}));
2448
ui->AddUIComponent(commonBarBtns.back(), Point(0, 7));
2549

2650
#if MATRIXOS_LOG_LEVEL == LOG_LEVEL_DEBUG // Logging Mode Indicator
@@ -81,4 +105,41 @@ void Shell::ApplicationLauncher() {
81105
{ MatrixOS::Logging::LogDebug("Shell", "%s not visible, skip.", applications[i]->name.c_str()); }
82106
}
83107
applicationLauncher.Start();
108+
}
109+
110+
void Shell::HiddenApplicationLauncher() {
111+
UI hiddenApplicationLauncher("Hidden Application Launcher", Color(0xFFFFFF));
112+
113+
uint16_t app_count = MatrixOS::SYS::GetApplicationCount();
114+
MatrixOS::Logging::LogDebug("Shell", "%d apps detected", app_count);
115+
116+
uint16_t invisable_app_count = 0;
117+
for (uint8_t i = 0; i < app_count; i++)
118+
{
119+
if (!applications[i]->visibility)
120+
{ invisable_app_count++; }
121+
}
122+
123+
std::vector<UIButton> appBtns;
124+
appBtns.reserve(invisable_app_count);
125+
for (uint8_t i = 0; i < app_count; i++)
126+
{
127+
if (!applications[i]->visibility)
128+
{
129+
uint8_t x = appBtns.size() % 8;
130+
uint8_t y = appBtns.size() / 8;
131+
132+
uint32_t app_id = applications[i]->id;
133+
string app_name = applications[i]->name;
134+
Color app_color = applications[i]->color;
135+
136+
appBtns.push_back(UIButton(app_name, app_color, [&, app_id]() -> void { MatrixOS::SYS::ExecuteAPP(app_id); }));
137+
hiddenApplicationLauncher.AddUIComponent(appBtns.back(), Point(x, y));
138+
MatrixOS::Logging::LogDebug("Shell", "App #%d %s-%s loaded.", appBtns.size() - 1, applications[i]->author.c_str(),
139+
applications[i]->name.c_str());
140+
}
141+
else
142+
{ MatrixOS::Logging::LogDebug("Shell", "%s is visible, skip.", applications[i]->name.c_str()); }
143+
}
144+
hiddenApplicationLauncher.Start();
84145
}

applications/Shell/Shell.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class Shell : public Application {
2222

2323
void AddCommonBarInUI(UI* ui);
2424
void ApplicationLauncher();
25+
void HiddenApplicationLauncher();
2526
};
2627

2728
#include "applications/RegisterApplication.h"

devices/MatrixBlock6_ESP32S2/DeviceApplications.h

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)