Skip to content

Commit

Permalink
Added (default) pattern for mixed impedance electrodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Onwrikbaar committed Oct 5, 2024
1 parent 9c17496 commit 8307f0d
Show file tree
Hide file tree
Showing 8 changed files with 946 additions and 924 deletions.
3 changes: 2 additions & 1 deletion Design.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ Conceptually, the firmware consists of two layers:
2. The hardware-independent application logic, implementing the _policies_.

### About the code
- All C modules, with the exception of the BSP, are less than 300 lines long.
- All C modules, with the exception of the BSP, are less than 400 lines long.
- Functions are short, or have low cyclomatic complexity.
- Functions are _pure_ whenever possible.
- There are no global variables, preventing unwanted coupling between modules and violation of invariants.
- Most 'plumbing' is done through dependency injection.
- Object types are opaque where possible.
1,839 changes: 921 additions & 918 deletions firmware/build/neodk_g071.hex

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions firmware/inc/sequencer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include <stdint.h>

#define DEFAULT_PRIMARY_VOLTAGE_mV 1500

typedef struct _Sequencer Sequencer; // Opaque type.


Expand Down
Binary file modified firmware/maolib/libmao.a
Binary file not shown.
2 changes: 1 addition & 1 deletion firmware/src/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void Controller_start(Controller *me)
{
BSP_logf("Starting NeoDK!\n");
BSP_logf("Push the button to play or pause :-)\n");
BSP_setPrimaryVoltage_mV(2500);
BSP_setPrimaryVoltage_mV(DEFAULT_PRIMARY_VOLTAGE_mV);
BSP_primaryVoltageEnable(true);
}

Expand Down
2 changes: 1 addition & 1 deletion firmware/src/debug_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static void interpretCommand(CmndInterp *me, char ch)
BSP_changePrimaryVoltage_mV(+200);
break;
case 'v':
CLI_logf("Firmware V0.25-beta\n");
CLI_logf("Firmware v0.26-beta\n");
break;
default:
CLI_logf("Unknown command '/%c'\n", ch);
Expand Down
2 changes: 1 addition & 1 deletion firmware/src/pattern_iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void PatternIterator_init(PatternIterator *me, PatternDescr const *pd)
me->nr_of_reps = pd->nr_of_reps;
me->nr_of_steps = pd->nr_of_steps; // Length of a transition.

me->pulse_width_micros = 80;
me->pulse_width_micros = 120;
me->elcon_nr = 0;
M_ASSERT(me->nr_of_steps != 0);
me->step_nr = 0;
Expand Down
20 changes: 18 additions & 2 deletions firmware/src/sequencer.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ static uint8_t const pattern_toggle[][2] =
{EL_D, EL_C},
};

static uint8_t const pattern_cross_toggle[][2] =
{
{EL_A, EL_D},
{EL_B, EL_C},
{EL_C, EL_B},
{EL_D, EL_A},
};

static uint8_t const pattern_circle[][2] =
{
{EL_A, EL_B},
Expand Down Expand Up @@ -95,6 +103,14 @@ static PatternDescr const pattern_descr[] =
.nr_of_steps = 5,
.nr_of_reps = 300,
},
{
.name = "CrossToggle",
.pattern = pattern_cross_toggle,
.nr_of_elcons = M_DIM(pattern_cross_toggle),
.pace_ms = 20,
.nr_of_steps = 5,
.nr_of_reps = 200,
},
{
.name = "Circle",
.pattern = pattern_circle,
Expand All @@ -108,7 +124,7 @@ static PatternDescr const pattern_descr[] =

static void selectNextRoutine(Sequencer *me)
{
BSP_setPrimaryVoltage_mV(2500);
BSP_setPrimaryVoltage_mV(DEFAULT_PRIMARY_VOLTAGE_mV);
if (++me->pattern_index == M_DIM(pattern_descr)) me->pattern_index = 0;
PatternDescr const *pd = &pattern_descr[me->pattern_index];
CLI_logf("Switching to pattern '%s'\n", pd->name);
Expand Down Expand Up @@ -280,7 +296,7 @@ Sequencer *Sequencer_new()
Sequencer *me = (Sequencer *)malloc(sizeof(Sequencer));
EventQueue_init(&me->event_queue, me->event_storage, sizeof me->event_storage);
me->state = &stateNop;
me->pattern_index = 0;
me->pattern_index = 2;
BSP_registerPulseDelegate(&me->event_queue);
return me;
}
Expand Down

0 comments on commit 8307f0d

Please sign in to comment.