Skip to content

Commit

Permalink
Sensortask 12ms
Browse files Browse the repository at this point in the history
  • Loading branch information
motino101 committed May 26, 2023
1 parent e343659 commit c96a6e4
Show file tree
Hide file tree
Showing 5 changed files with 566 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/chovy/System.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class System
const bool silent = false;

Poster<bool> armed = Poster<bool>(false);
Poster<bool> timeExceeded = Poster<bool>(false); // If time between Sensortask exceed 15ms, use var to produce warning sound

This comment has been minimized.

Copy link
@Timvrakas

Timvrakas May 29, 2023

Member

FYI, the CI builds are failing because you only added this line to the /chovy/System.hpp, you should probably add it to the /guppy/System.hpp and /salmon/System.hpp to fix those targets.


class Sensors
{
Expand Down
24 changes: 18 additions & 6 deletions src/fc/BuzzerTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ BuzzerTask::BuzzerTask(uint8_t priority) : Task(priority, "Buzzer"){};

void BuzzerTask::activity()
{
if(sys.silent){
if(sys.silent){
vTaskSuspend(getTaskHandle());
}

uint32_t timer = 0;
while (true)
uint32_t timer = 0; // use for timing delays
while (true) // main activity loop
{
vTaskDelayUntil(&timer, 5000);
vTaskDelayUntil(&timer, 5000); // a delay of 5 seconds

bool pyroA = sys.pyro.getStatus(Pyro::SquibA);
bool pyroB = sys.pyro.getStatus(Pyro::SquibB);
Expand All @@ -22,9 +22,21 @@ void BuzzerTask::activity()
sys.buzzer.set(2500);
vTaskDelay(300);
sys.buzzer.set(0);

vTaskDelay(500);

// If time exceeded, scary beep
bool timeExceeded;
sys.timeExceeded.get(timeExceeded);
if (timeExceeded) {
for (int i = 0; i< 20; i++) {
sys.buzzer.set(3500);
vTaskDelay(100);
sys.buzzer.set(0);
vTaskDelay(100);
}

}

switch (state)
{
case Waiting:
Expand Down Expand Up @@ -65,7 +77,7 @@ void BuzzerTask::activity()

vTaskDelay(500);

if (pyroA)
if (pyroA) // true if actual pyros connected to board
{
sys.buzzer.set(5000);
vTaskDelay(100);
Expand Down
19 changes: 18 additions & 1 deletion src/fc/SensorTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ SensorTask::SensorTask(uint8_t priority) : Task(priority, "Sensor") {}

void SensorTask::activity()
{



if (sys.shitl)
{
vTaskSuspend(getTaskHandle());
Expand Down Expand Up @@ -114,10 +117,24 @@ void SensorTask::activity()

TickType_t lastSensorTime = xTaskGetTickCount();

while (true)
int prevTickCount = 0;
while (true) // Start repeating functions here
{

// Throw warning if over 12ms runs Sensortask
int curTickCount = xTaskGetTickCount();
if (curTickCount - prevTickCount > 12)
{
sys.tasks.logger.log("You're fucked!");
sys.timeExceeded.post(true);
} else {
sys.timeExceeded.post(false); // not needed?
}
prevTickCount = curTickCount;

vTaskDelayUntil(&lastSensorTime, 10);


digitalWrite(SENSOR_LED, true);

StaticJsonDocument<1024> sensor_json;
Expand Down

0 comments on commit c96a6e4

Please sign in to comment.