Skip to content

Commit d072823

Browse files
committed
Paramètres de luminosité et temps de veille paramétrable dans les settings
1 parent 4bf55d7 commit d072823

File tree

9 files changed

+87
-42
lines changed

9 files changed

+87
-42
lines changed

lib/applications/src/app.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,6 @@ namespace AppManager {
353353
// Get the currently running app
354354
App* app = appStack.back();
355355

356-
if (app->background) {
357-
return;
358-
}
359-
360356
// Kill the app
361357
app->kill();
362358
}

lib/lua/src/lua_file.cpp

+51-3
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,8 @@ void LuaFile::load()
617617
lua.set("COLOR_LIGHT_GREY", COLOR_LIGHT_GREY);
618618

619619
lua.set_function("launch", sol::overload([&](std::string name, std::vector<std::string> arg)
620-
{
620+
{
621+
std::cerr << "launch is deprecated, use system.app:launch instead" << std::endl;
621622
try{
622623
AppManager::get(name)->run(arg);
623624
}
@@ -728,6 +729,53 @@ void LuaFile::load()
728729

729730
app.set_function("quit", [&]()
730731
{ m_commandQueue.push(QUIT); });
732+
733+
app.set_function("launch", sol::overload([&](std::string name, std::vector<std::string> arg)
734+
{
735+
try{
736+
AppManager::get(name)->run(arg);
737+
}
738+
catch(std::runtime_error &e) {
739+
std::cerr << "Erreur: " << e.what() << std::endl;
740+
// Ajout message d'erreur
741+
GuiManager &guiManager = GuiManager::getInstance();
742+
guiManager.showErrorMessage(e.what());
743+
}
744+
745+
return true; },
746+
[&](std::string name)
747+
{
748+
try
749+
{
750+
AppManager::get(name)->run({});
751+
}
752+
catch (std::runtime_error &e)
753+
{
754+
std::cerr << "Erreur: " << e.what() << std::endl;
755+
// Ajout message d'erreur
756+
GuiManager &guiManager = GuiManager::getInstance();
757+
guiManager.showErrorMessage(e.what());
758+
}
759+
760+
return true;
761+
}));
762+
763+
app.set_function("stopApp", sol::overload([&](std::string name)
764+
{
765+
try{
766+
auto app = AppManager::get(name);
767+
if(app->luaInstance != nullptr && app->luaInstance.get() != this)
768+
app->kill();
769+
}
770+
catch(std::runtime_error &e) {
771+
std::cerr << "Erreur: " << e.what() << std::endl;
772+
// Ajout message d'erreur
773+
GuiManager &guiManager = GuiManager::getInstance();
774+
guiManager.showErrorMessage(e.what());
775+
}
776+
777+
return true; }
778+
));
731779
}
732780

733781
/**
@@ -855,7 +903,7 @@ void LuaFile::wakeup(std::vector<std::string> arg)
855903
void LuaFile::stop(std::vector<std::string> arg)
856904
{
857905
const sol::protected_function func = lua.get<sol::protected_function>("quit");
858-
;
906+
859907
if (!func.valid())
860908
return;
861909

@@ -871,7 +919,7 @@ void LuaFile::loop()
871919
{
872920
case QUIT:
873921
// Quit lua app OUTSIDE of lua
874-
AppManager::quitApp();
922+
AppManager::get(this)->kill();
875923
break;
876924
}
877925

src/main.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ void setup()
219219
systemConfig.write();
220220
}
221221

222+
if (!systemConfig.has("settings.sleeptime")) {
223+
systemConfig.set<uint64_t>("settings.sleeptime", 30000);
224+
systemConfig.write();
225+
}
226+
222227
libsystem::log("settings.brightness: " + std::to_string(systemConfig.get<uint8_t>("settings.brightness")));
223228

224229
graphics::setBrightness(systemConfig.get<uint8_t>("settings.brightness"));

storage/sys_apps/.oobe/app.lua

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ function run(arg)
88
title:setFontSize(42)
99

1010
title = gui:label(win, 0, 210, 320, 40)
11-
title:setText("Running on PaxOS 9")
11+
title:setText("Utilise le PaxOS 9")
1212
title:setTextColor(100, 100, 100)
1313
title:setHorizontalAlignment(CENTER_ALIGNMENT)
1414
title:setFontSize(20)
1515

1616
button = gui:button(win, 100, 380, 120, 40)
1717
button:setIcon("sys_apps/.oobe/resources/images/arrow_forward_ios_64px.png")
18-
button:setText("Welcome")
18+
button:setText("Bienvenu !")
1919
button:onClick(function ()
20-
paxo.system.config.set("oobe", true)
21-
paxo.system.config.write()
20+
system.config.set("oobe", true)
21+
system.config.write()
2222

23-
paxo.app.quit()
23+
system.app.quit()
2424
end)
2525

2626
gui:setWindow(win)

storage/sys_apps/settings/app.lua

+16-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,22 @@ function systemSettings()
147147
textBrightness:setVerticalAlignment(CENTER_ALIGNMENT)
148148
textBrightness:setText("Luminosité")
149149

150-
local brightnessSlider = gui:slider(brightnessBox, 15, 53, 230, 10, 5, 255, system.config.getInt("settings.brightness"))
150+
local brightnessSlider = gui:slider(brightnessBox, 15, 53, 230, 10, 5, 255, settings.getBrightness())
151+
brightnessSlider:onChange(function()
152+
settings.setBrightness(brightnessSlider:getValue(), false)
153+
end)
154+
155+
local sleepTimeBox = createBox(win2, 100, 73)
156+
local textsleepTime = gui:label(sleepTimeBox, 16, 0, 177, 55)
157+
textsleepTime:setFontSize(24)
158+
textsleepTime:setVerticalAlignment(CENTER_ALIGNMENT)
159+
textsleepTime:setText("Veille: " .. int(settings.getStandBySleepTime()/1000) .. "s")
160+
print("sleep time: " .. settings.getStandBySleepTime())
161+
local sleepTimeSlider = gui:slider(sleepTimeBox, 15, 53, 230, 10, 20, 120, int(settings.getStandBySleepTime()/1000))
162+
sleepTimeSlider:onChange(function()
163+
settings.setStandBySleepTime(sleepTimeSlider:getValue()*1000, true)
164+
textsleepTime:setText("Veille: " .. int(sleepTimeSlider:getValue()) .. "s")
165+
end)
151166

152167
gui:setWindow(win2)
153168
end

storage/sys_apps/testbc/app.lua

+3-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
function run()
2-
print("run baground testbc app, no displayed: show conter to 10 and run settings app")
3-
print(time)
4-
-- local counter = 0
2+
print("this app in not in the background, will launch sub1 app for 5 seconds")
53

6-
-- local function printCounter()
7-
-- counter = counter + 1
8-
-- print("Counter: " .. counter .. " sec")
9-
-- if(counter == 10) then
10-
-- launch("settings")
11-
-- end
12-
-- end
13-
14-
-- time:setInterval(printCounter, 1000)
15-
16-
launch("testbc.sub1")
4+
window = gui:window()
5+
gui:setWindow(window)
176
end
+5-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
function run()
2-
print("run sub1 app in background: will display counter2 to 10 then run the settings app")
3-
local counter = 0
4-
5-
local function printCounter()
6-
counter = counter + 1
7-
print("Counter 2: " .. counter .. " sec")
8-
if(counter == 10) then
9-
launch("settings")
10-
end
11-
end
12-
13-
time:setInterval(printCounter, 1000)
14-
end
2+
time:setTimeout(function()
3+
launch("testbc")
4+
system.app:quit()
5+
end, 1000)
6+
end

storage/sys_apps/testbc/sub/.sub1/manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"files",
55
"time"
66
],
7-
"background": true,
8-
"autorun": false
7+
"background": false,
8+
"autorun": true
99
}

storage/system/config.bfc

20 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)