Skip to content

Commit

Permalink
fix: disable classifier events when aggregate_all
Browse files Browse the repository at this point in the history
  • Loading branch information
iomz committed Aug 10, 2023
1 parent ce71e7a commit 0313c5c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
9 changes: 8 additions & 1 deletion examples/sample_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def main(args: argparse.Namespace):
await sc.start()

# receive notifications for 5 seconds
await asyncio.sleep(5)
await asyncio.sleep(args.seconds)

# stop the indicate/notify
await sc.stop()
Expand All @@ -90,6 +90,13 @@ async def main(args: argparse.Namespace):
help="the mac address to connect to",
metavar="<mac-address>",
)
parser.add_argument(
"--seconds",
default=10,
help="seconds to read data",
metavar="<seconds>",
type=int,
)

args = parser.parse_args()

Expand Down
17 changes: 8 additions & 9 deletions myo/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,16 +441,15 @@ async def setup(
# never sleep
await self.set_sleep_mode(SleepMode.NEVER_SLEEP)
# setup modes
self.emg_mode = emg_mode
self.imu_mode = imu_mode
self.classifier_mode = classifier_mode

# enforce the modes when aggregate_all
if self.aggregate_all and (
self.emg_mode != EMGMode.SEND_FILT or self.imu_mode in (IMUMode.NONE, IMUMode.SEND_EVENTS, IMUMode.SEND_RAW)
):
if self.aggregate_all:
# enforce the modes when aggregate_all
self.classifier_mode = ClassifierMode.DISABLED
self.emg_mode = EMGMode.SEND_FILT
self.imu_mode = IMUMode.SEND_ALL
self.imu_mode = IMUMode.SEND_DATA
else:
self.classifier_mode = classifier_mode
self.emg_mode = emg_mode
self.imu_mode = imu_mode

await self.set_mode(
classifier_mode=self.classifier_mode,
Expand Down

0 comments on commit 0313c5c

Please sign in to comment.