Skip to content

Commit ebb13e9

Browse files
committed
stack size fixed
1 parent 2b1a2e3 commit ebb13e9

File tree

3 files changed

+21
-70
lines changed

3 files changed

+21
-70
lines changed

lib/gsm/src/gsm.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ namespace GSM
4242
std::vector<Message> messages;
4343
State state;
4444
uint16_t seconds, minutes, hours, days, months, years = 0;
45+
std::vector<float> battery_voltage_history;
4546
float voltage = -1;
4647
int networkQuality = 0;
4748
bool flightMode = false;
@@ -994,6 +995,19 @@ namespace GSM
994995
try
995996
{
996997
voltage = std::stof(voltage_str);
998+
999+
battery_voltage_history.push_back(voltage);
1000+
if (battery_voltage_history.size() > 24)
1001+
battery_voltage_history.erase(battery_voltage_history.begin());
1002+
1003+
if (battery_voltage_history.size() > 0) {
1004+
double sum = 0;
1005+
for (auto v : battery_voltage_history)
1006+
sum += v;
1007+
voltage = sum / battery_voltage_history.size();
1008+
1009+
std::cout << "Battery voltage average: " << voltage << std::endl;
1010+
}
9971011
}
9981012
catch (std::exception)
9991013
{
@@ -1010,7 +1024,7 @@ namespace GSM
10101024
// Thanks NumWorks for the regression app
10111025
const double batteryLevel = 3.083368 * std::pow(voltage, 3) - 37.21203 * std::pow(voltage, 2) + 150.5735 * voltage - 203.3347;
10121026

1013-
std::cout << "Battery level: " << batteryLevel << std::endl;
1027+
//std::cout << "Battery level: " << batteryLevel << std::endl;
10141028

10151029
return std::clamp(batteryLevel, 0.0, 1.0);
10161030

lib/tasks/src/threads.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
void ThreadManager::init()
2626
{
27-
new_thread(CORE_BACK, &ThreadManager::simcom_thread, 32*1024);
28-
new_thread(CORE_BACK, &ThreadManager::background_thread, 16*1024);
27+
new_thread(CORE_BACK, &ThreadManager::simcom_thread, 8*1024);
28+
new_thread(CORE_BACK, &ThreadManager::background_thread, 8*1024);
2929
}
3030

3131
void ThreadManager::new_thread(bool core, void(*func)(void*), int stackSize)

src/main.cpp

+4-67
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#include <backtrace_saver.hpp>
99
#include <backtrace.hpp>
1010

11+
#include <Arduino.h>
12+
13+
SET_LOOP_TASK_STACK_SIZE(8 * 1024);
14+
1115
#endif
1216

1317
#include <unistd.h>
@@ -141,67 +145,6 @@ void mainLoop(void* data) {
141145

142146
StandbyMode::wait();
143147
}
144-
/*
145-
// Main loop
146-
while (true) {
147-
// Update inputs
148-
hardware::input::update();
149-
std::cout << "Update inputs" << std::endl;
150-
151-
// Update running apps
152-
AppManager::update();
153-
154-
// Don't show anything
155-
if (libsystem::getDeviceMode() == libsystem::SLEEP) {
156-
if (getButtonDown(hardware::input::HOME)) {
157-
setDeviceMode(libsystem::NORMAL);
158-
}
159-
160-
continue;
161-
}
162-
163-
if (AppManager::isAnyVisibleApp()) {
164-
if (getButtonDown(hardware::input::HOME)) {
165-
AppManager::quitApp();
166-
}
167-
} else {
168-
// If home button pressed on the launcher
169-
// Put the device in sleep
170-
if (getButtonDown(hardware::input::HOME)) {
171-
// Free the launcher resources
172-
applications::launcher::free();
173-
174-
setDeviceMode(libsystem::SLEEP);
175-
continue;
176-
}
177-
178-
std::cout << "Update launcher" << std::endl;
179-
180-
// Update, show and allocate launcher
181-
applications::launcher::update();
182-
183-
// Icons interactions
184-
if (applications::launcher::iconTouched()) {
185-
const std::shared_ptr<AppManager::App> app = applications::launcher::getApp();
186-
187-
// Free the launcher resources
188-
applications::launcher::free();
189-
190-
// Launch the app
191-
try {
192-
app->run(false);
193-
} catch (std::runtime_error& e) {
194-
std::cerr << "Erreur: " << e.what() << std::endl;
195-
// Affichage du msg d'erreur
196-
guiManager.showErrorMessage(e.what());
197-
// on kill l'application ?!?
198-
//AppManager::appList[i].kill();
199-
}
200-
}
201-
}
202-
203-
AppManager::loop();
204-
}*/
205148
}
206149

207150
void setup()
@@ -330,13 +273,7 @@ void setup()
330273
*/
331274
AppManager::init();
332275

333-
#ifdef ESP_PLATFORM
334-
// // stack size: >32k = crash due to image decoder in stack
335-
xTaskCreateUniversal(mainLoop,"newloop", 16*1024, NULL, 1, NULL, ARDUINO_RUNNING_CORE);
336-
vTaskDelete(NULL);
337-
#else
338276
mainLoop(NULL);
339-
#endif
340277
}
341278

342279
void loop(){}

0 commit comments

Comments
 (0)