Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FWXV 246] Added Files for Review #242

Merged
merged 2 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions bps_indicator.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "bps_indicator.h"

#define BPS_FAULT_INDICATOR_PERIOD_MS 375
mitchellostler marked this conversation as resolved.
Show resolved Hide resolved

static SoftTimer s_bps_indicator_timer;
static bool s_bps_fault_enabled;
static OutputState s_output_state;

static void prv_callback() {
if (s_bps_fault_enabled) {
// ternary statement: sets s_output_state to opposite of current state
s_output_state = (s_output_state == OUPUT_STATE_OFF) ? OUTPUT_STATE_ON : OUTPUT_STATE_OFF;
// set OUTPUT_GROUP_BPS_FAULT to s_output_state
pd_set_output_group(OUTPUT_GROUP_BPS_FAULT, s_output_state);
// add s_bps_indicator_timer - 375 ms before running, run prv_callback after
soft_timer_start(BPS_FAULT_INDICATOR_PERIOD_MS, prv_callback, &s_bps_indicator_timer);
} else {
// set OUTPUT_GROUP_BPS_FAULT to OUPUT_STATE_OFF
// function terminates
pd_set_output_group(OUTPUT_GROUP_BPS_FAULT, OUPUT_STATE_OFF);
}
}

void start_bps_fault_indicator() {
s_bps_fault_enabled = true;
soft_timer_start(BPS_FAULT_INDICATOR_PERIOD_MS, prv_callback, &s_bps_indicator_timer);
}

void stop_bps_fault_indicator() {
s_bps_fault_enabled = false;
}
9 changes: 9 additions & 0 deletions bps_indicator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include <stdio.h>
#include "soft_timer.h"
#include "outputs.h"

// functions to start/stop bps fault indicator
void start_bps_fault_indicator(void);
void stop_bps_fault_indicator(void);