-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring & smaller pulse train descriptor.
- Loading branch information
1 parent
6f70bc4
commit 4135404
Showing
11 changed files
with
1,668 additions
and
1,612 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* burst.c | ||
* | ||
* NOTICE (do not remove): | ||
* This file is part of project NeoDK (https://github.com/Onwrikbaar/NeoDK). | ||
* See https://github.com/Onwrikbaar/NeoDK/blob/main/LICENSE.txt for full license details. | ||
* | ||
* Created on: 9 Jan 2025 | ||
* Author: mark | ||
* Copyright 2025 Neostim™ | ||
*/ | ||
|
||
#include "burst.h" | ||
|
||
|
||
bool Burst_isValid(Burst const *me) | ||
{ | ||
// Pulse repetition rate must be in [16..200] Hz. | ||
if (me->pace_µs < (MIN_PULSE_PACE_µs)) return false; | ||
if (me->pace_µs > (MAX_PULSE_PACE_µs)) return false; | ||
if (me->pulse_width_¼_µs < MIN_PULSE_WIDTH_¼_µs) return false; | ||
if (me->nr_of_pulses == 0) return false; | ||
return true; | ||
} | ||
|
||
|
||
uint32_t Burst_duration_µs(Burst const *burst) | ||
{ | ||
return burst->nr_of_pulses * burst->pace_µs; | ||
} | ||
|
||
|
||
void Burst_applyDeltas(Burst *me, Deltas const *deltas) | ||
{ | ||
int32_t new_pw = me->pulse_width_¼_µs + deltas->delta_width_¼_µs; | ||
if (new_pw < MIN_PULSE_WIDTH_¼_µs) new_pw = MIN_PULSE_WIDTH_¼_µs; | ||
if (new_pw > MAX_PULSE_WIDTH_¼_µs) new_pw = MAX_PULSE_WIDTH_¼_µs; | ||
me->pulse_width_¼_µs = new_pw; | ||
|
||
int32_t new_pace = me->pace_µs + deltas->delta_pace_µs; | ||
if (new_pace < MIN_PULSE_PACE_µs) new_pace = MIN_PULSE_PACE_µs; | ||
else if (new_pace > MAX_PULSE_PACE_µs) new_pace = MAX_PULSE_PACE_µs; | ||
me->pace_µs = new_pace; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.