From 20c0ee5ab429a99f6d52baef73f8758e93278921 Mon Sep 17 00:00:00 2001 From: Bryton Hall Date: Sat, 17 Jun 2023 23:30:49 -0400 Subject: [PATCH] only sent serial output if connected --- CHANGELOG.md | 4 ++++ src/app/services/notes.service.ts | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae19906..090ed97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - filter file uploads by `.mxl` extension +### Fixed + +- serial output no longer sent if cursor has not moved or port isn't connected + ## [0.2.0] - 2023-06-15 ### Changed diff --git a/src/app/services/notes.service.ts b/src/app/services/notes.service.ts index 2ce92ae..c3402ec 100644 --- a/src/app/services/notes.service.ts +++ b/src/app/services/notes.service.ts @@ -100,7 +100,7 @@ export class NotesService { // write number to serial output async serialWrite(note: number) { - await this.writer.write(this.encoder.encode(note.toString() + '\n')); + if (this.port) await this.writer.write(this.encoder.encode(note.toString() + '\n')); } clear(): void { @@ -195,8 +195,10 @@ export class NotesService { key.voice = voice.ParentVoice.VoiceId; key.finger = note.Fingering ? note.Fingering.value : ''; key.grace = note.IsGraceNote; - key.required = true; - this.serialWrite(this.keys.indexOf(key)); + if (!key.required) { + key.required = true; + this.serialWrite(this.keys.indexOf(key)); + } // in case of tie, check that it is a start note if (typeof note.NoteTie === 'undefined' || note === note.NoteTie.StartNote) {