Skip to content

Commit

Permalink
Cosmetics.
Browse files Browse the repository at this point in the history
  • Loading branch information
Onwrikbaar committed Oct 19, 2024
1 parent dd141e7 commit 3612903
Show file tree
Hide file tree
Showing 8 changed files with 1,322 additions and 1,304 deletions.
2 changes: 1 addition & 1 deletion Design.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ 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 400 lines long.
- All C modules, with the exception of the BSP, are less than 500 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.
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ This project is intended for experienced electronics hobbyists and professionals
- a pulse-based device that can store and play user-created routines (planned for 2025).

### Caveat
NeoDK is _NOT_ a ready-for-play e-stim box. It is a minimal viable design (MVD) of a powerful and highly efficient electrostimulation device that is not limited by 2-pole 'channels' or strictly TENS-like waveforms. Schematic and board CAD files are included, but to get a working device involves soldering as well as programming.
NeoDK is _NOT_ a ready-for-play e-stim box. It is a minimal viable design (MVD) of a powerful and highly efficient electrostimulation device that is not limited by 2-pole 'channels' or strictly TENS-like waveforms. Schematic and board CAD files are included, but to get a working device involves soldering. To get more than the basic functionality requires programming in C.

### How to get a working NeoDK
By far the easiest way to build NeoDK, is to order the SMD-populated PCB from JLCPCB (using the files in directory JLCPCB_prod) and buy the six through hole components separately. Soldering the through hole components onto the board is quite easy.

### Licensing
NeoDK's electronics and firmware can do things no commercially available e-stim box comes close to. If this appeals to you but you would like to have more features than NeoDK offers, by all means use NeoDK as the foundation for your own design - while observing this project's [Licence](LICENSE.txt). Regarding licensing for commercial / non-open source purposes, please contact the author.
Expand Down
2,585 changes: 1,295 additions & 1,290 deletions firmware/build/neodk_g071.hex

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion firmware/maolib/inc/bsp_dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Created on: 27 Mar 2021
* Author: mark
* Copyright 2021..2024 Neostim
* Copyright 2021..2024 Neostim
*/

#ifndef INC_BSP_DBG_H_
Expand Down
Binary file modified firmware/maolib/libmao.a
Binary file not shown.
2 changes: 1 addition & 1 deletion firmware/src/attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ static Subscription const *findSubForId(AttributeId ai)

SubscriptionId Attribute_subscribe(AttributeId ai, AttrNotifier notify, void *target)
{
// BSP_logf("%s for id=%hu\n", __func__, ai);
if (nr_of_subs == M_DIM(subscriptions)) return 0;

BSP_logf("%s for id=%hu\n", __func__, ai);
Subscription *sub = &subscriptions[nr_of_subs];
sub->ai = ai;
sub->notify = notify;
Expand Down
28 changes: 19 additions & 9 deletions firmware/src/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ typedef struct {

typedef struct {
uint16_t transaction_id;
uint8_t opcode;
uint8_t reserved;
uint8_t opcode;
uint8_t reserved;
uint16_t attribute_id;
uint8_t data[0];
uint8_t data[0];
} AttributeAction;


typedef void *(*StateFunc)(Controller *, AOEvent const *);

struct _Controller {
EventQueue event_queue; // This MUST be the first member.
uint8_t event_storage[400];
StateFunc state;
uint8_t event_storage[400];
StateFunc state;
Sequencer *sequencer;
DataLink *datalink;
DataLink *datalink;
};


Expand Down Expand Up @@ -163,13 +163,22 @@ static void handleWriteRequest(Controller *me, AttributeAction const *aa)
static void handleSubscribeRequest(Controller *me, AttributeAction const *aa)
{
Attribute_subscribe(aa->attribute_id, (AttrNotifier)&attributeChanged, me);
handleReadRequest(me, aa);
}


static void handleInvokeRequest(Controller *me, AttributeAction const *aa)
{
BSP_logf("%s not implemented yet\n", __func__);
switch (aa->attribute_id)
{
case AI_CURRENT_PATTERN_NAME:
if (aa->data[0] == EE_UTF8_1LEN) {
EventQueue_postEvent((EventQueue *)me->sequencer, ET_SELECT_PATTERN_BY_NAME, aa->data + 2, aa->data[1]);
}
break;
default:
BSP_logf("%s: unknown attribute id=%hu\n", __func__, aa->attribute_id);
// TODO Respond with NOT_FOUND code.
}
}


Expand All @@ -188,6 +197,7 @@ static void handleRequest(Controller *me, AttributeAction const *aa)
case OC_SUBSCRIBE_REQUEST:
BSP_logf("Transaction %hu: subscribe to attribute %hu\n", aa->transaction_id, aa->attribute_id);
handleSubscribeRequest(me, aa);
handleReadRequest(me, aa);
break;
case OC_INVOKE_REQUEST:
BSP_logf("Transaction %hu: invoke %hu\n", aa->transaction_id, aa->attribute_id);
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 @@ -101,7 +101,7 @@ static void interpretCommand(CmndInterp *me, char ch)
changeIntensity(me, +2);
break;
case 'v':
CLI_logf("Firmware v0.34-beta\n");
CLI_logf("Firmware v0.35-beta\n");
break;
case 'w': // Allow rediscovery by Dweeb.
DataLink_waitForSync(me->datalink);
Expand Down

0 comments on commit 3612903

Please sign in to comment.