Skip to content
Snippets Groups Projects
Commit 5e160d42 authored by Niccolò Betto's avatar Niccolò Betto
Browse files

[Nokia] Start Pyxis telemetry send test on user button press too

parent fe1218ba
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <drivers/timer/TimestampTimer.h> #include <drivers/timer/TimestampTimer.h>
#include <radio/SX1278/SX1278Frontends.h> #include <radio/SX1278/SX1278Frontends.h>
#include <radio/SX1278/SX1278Fsk.h> #include <radio/SX1278/SX1278Fsk.h>
#include <utils/ButtonHandler/ButtonHandler.h>
#include <utils/collections/CircularBuffer.h> #include <utils/collections/CircularBuffer.h>
#include <thread> #include <thread>
...@@ -158,6 +159,22 @@ struct PendingAck ...@@ -158,6 +159,22 @@ struct PendingAck
int seq; int seq;
}; };
void startBlinking()
{
std::thread(
[]
{
while (1)
{
ledOn();
Thread::sleep(100);
ledOff();
Thread::sleep(100);
}
})
.detach();
}
bool launched = false; bool launched = false;
CircularBuffer<PendingAck, 10> pending_acks; CircularBuffer<PendingAck, 10> pending_acks;
FastMutex mutex; FastMutex mutex;
...@@ -181,6 +198,7 @@ void onReceive(Mav* channel, const mavlink_message_t& msg) ...@@ -181,6 +198,7 @@ void onReceive(Mav* channel, const mavlink_message_t& msg)
if (commandId == MAV_CMD_FORCE_LAUNCH) if (commandId == MAV_CMD_FORCE_LAUNCH)
{ {
launched = true; launched = true;
startBlinking();
} }
} }
} }
...@@ -231,7 +249,7 @@ void flightTmLoop() ...@@ -231,7 +249,7 @@ void flightTmLoop()
channel->enqueueMsg(msg); channel->enqueueMsg(msg);
Thread::sleepUntil(start + FLIGHT_TM_PERIOD); Thread::sleepUntil(start + FLIGHT_TM_PERIOD);
if (launched && i < sizeof(nasState) / sizeof(nasState[0])) if (launched && i < (sizeof(nasState) / sizeof(nasState[0])) - 1)
{ {
i++; i++;
} }
...@@ -278,6 +296,17 @@ int main() ...@@ -278,6 +296,17 @@ int main()
channel = new Mav(sx1278, &onReceive, 0, MAV_OUT_BUFFER_MAX_AGE); channel = new Mav(sx1278, &onReceive, 0, MAV_OUT_BUFFER_MAX_AGE);
channel->start(); channel->start();
ButtonHandler::getInstance().registerButtonCallback(
GpioPin(GPIOA_BASE, 0),
[](auto event)
{
if (event == ButtonEvent::LONG_PRESS)
{
launched = true;
startBlinking();
}
});
flightTmLoop(); flightTmLoop();
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment