-
-
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.
- Loading branch information
1 parent
fe11fd0
commit 2d7c368
Showing
14 changed files
with
1,651 additions
and
1,573 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* attributes.h | ||
* | ||
* 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: 15 Oct 2024 | ||
* Author: mark | ||
* Copyright 2024 Neostim™ | ||
*/ | ||
|
||
#ifndef INC_ATTRIBUTES_H_ | ||
#define INC_ATTRIBUTES_H_ | ||
|
||
#include "matter.h" | ||
|
||
|
||
typedef enum { | ||
AI_ALL_PATTERN_NAMES = 5, AI_CURRENT_PATTERN_NAME, AI_INTENSITY_PERCENT, AI_PLAY_PAUSE_STOP | ||
} AttributeId; | ||
|
||
typedef void (*AttrNotifier)(void *target, AttributeId, ElementEncoding, uint8_t const *data, uint16_t size); | ||
|
||
|
||
bool Attribute_subscribe(AttributeId, ElementEncoding, AttrNotifier, void *target); | ||
void Attribute_changed(AttributeId, uint8_t const *data, uint16_t size); | ||
|
||
#endif |
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
Binary file not shown.
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,66 @@ | ||
/* | ||
* attributes.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: 15 Oct 2024 | ||
* Author: mark | ||
* Copyright 2024 Neostim™ | ||
*/ | ||
|
||
#include "bsp_dbg.h" | ||
#include "convenience.h" | ||
|
||
// This module implements: | ||
#include "attributes.h" | ||
|
||
|
||
typedef struct { | ||
AttributeId ai; // Key. | ||
ElementEncoding encoding; | ||
AttrNotifier notify; | ||
void *target; | ||
} Subscription; | ||
|
||
|
||
static Subscription subscriptions[4]; | ||
static uint8_t nr_of_subs = 0; | ||
|
||
|
||
static Subscription const *findSubForId(AttributeId ai) | ||
{ | ||
for (uint8_t i = 0; i < M_DIM(subscriptions); i++) { | ||
Subscription const *sub = &subscriptions[i]; | ||
if (ai == sub->ai) return sub; | ||
} | ||
return NULL; | ||
} | ||
|
||
/* | ||
* Below are the functions implementing this module's interface. | ||
*/ | ||
|
||
bool Attribute_subscribe(AttributeId ai, ElementEncoding enc, AttrNotifier notify, void *target) | ||
{ | ||
BSP_logf("%s for id=%hu\n", __func__, ai); | ||
if (nr_of_subs == M_DIM(subscriptions)) return false; | ||
|
||
Subscription *sub = &subscriptions[nr_of_subs++]; | ||
sub->ai = ai; | ||
sub->encoding = enc; | ||
sub->notify = notify; | ||
sub->target = target; | ||
return true; | ||
} | ||
|
||
|
||
void Attribute_changed(AttributeId ai, uint8_t const *data, uint16_t size) | ||
{ | ||
// BSP_logf("%s(%hu)\n", __func__, ai); | ||
Subscription const *sub = findSubForId(ai); | ||
if (sub != NULL) { | ||
sub->notify(sub->target, ai, sub->encoding, data, size); | ||
} | ||
} |
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.