From c5d12c17c736a8ddc07daec43b0f1fa826e560e9 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 21 Aug 2024 21:18:46 +0200 Subject: [PATCH 1/6] Sending now works --- assets/js/winkey.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/assets/js/winkey.js b/assets/js/winkey.js index 74df8e7d7..c80f79ed1 100644 --- a/assets/js/winkey.js +++ b/assets/js/winkey.js @@ -122,6 +122,7 @@ async function connect() { statusBar.innerText = "Connected"; connectButton.innerText = "Disconnect" + let decoder = new TextDecoderStream(); inputDone = port.readable.pipeTo(decoder.writable); inputStream = decoder.readable; @@ -130,8 +131,10 @@ async function connect() { outputDone = encoder.readable.pipeTo(port.writable); outputStream = encoder.writable; - writeToByte("0x00, 0x02"); - writeToByte("0x02, 0x00"); + // Seems this might not be needed, leaving it for now + // writeToByte("[0x00, 0x02]"); + // writeToByte("[0x02, 0x00]"); + $('#winkey_buttons').show(); @@ -152,7 +155,8 @@ async function writeToStream(line) { var enc = new TextEncoder(); // always utf-8 const writer = outputStream.getWriter(); - writer.write(line); + + writer.write([line.toUpperCase()]); writer.releaseLock(); } @@ -187,11 +191,11 @@ async function disconnect() { //When the send button is pressed function clickSend() { - writeToStream(sendText.value); - writeToStream("\r"); - - //and clear the input field, so it's clear it has been sent - sendText.value = ""; + writeToStream(sendText.value).then(function() { + // writeToStream("\r"); + //and clear the input field, so it's clear it has been sent + $('#sendText').val(''); + }); } From 9fd106356320671ff366a5d124287ff811056e20 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Sat, 24 Aug 2024 14:53:42 +0200 Subject: [PATCH 2/6] Init works. Can now set CW speed. --- application/views/qso/index.php | 25 +++++---- assets/js/winkey.js | 98 +++++++++++++++++++++++++-------- 2 files changed, 90 insertions(+), 33 deletions(-) diff --git a/application/views/qso/index.php b/application/views/qso/index.php index cd3f8c42f..c82e5fd78 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -647,22 +647,25 @@ + -
-
- - - - - -
- - +
+ + + + + + + +
-
+ + + +
diff --git a/assets/js/winkey.js b/assets/js/winkey.js index c80f79ed1..c4bc653f5 100644 --- a/assets/js/winkey.js +++ b/assets/js/winkey.js @@ -28,7 +28,19 @@ ModeSelected.addEventListener('change', (event) => { } }); +$('#winkeycwspeed').change(function (event) { + // Get the value from the input + let speed = parseInt($('#winkeycwspeed').val(), 10); + // Convert to hexadecimal and pad if necessary + let hexspeed = speed.toString(16).padStart(2, '0'); + + // Create the command + let command = `02 ${hexspeed}`; + + // Send the command as hex bytes + sendHexToSerial(command); +}); let function1Name, function1Macro, function2Name, function2Macro, function3Name, function3Macro, function4Name, function4Macro, function5Name, function5Macro; @@ -122,19 +134,16 @@ async function connect() { statusBar.innerText = "Connected"; connectButton.innerText = "Disconnect" - let decoder = new TextDecoderStream(); inputDone = port.readable.pipeTo(decoder.writable); inputStream = decoder.readable; - const encoder = new TextEncoderStream(); - outputDone = encoder.readable.pipeTo(port.writable); - outputStream = encoder.writable; - - // Seems this might not be needed, leaving it for now - // writeToByte("[0x00, 0x02]"); - // writeToByte("[0x02, 0x00]"); - + // Keyer init + sendHexToSerial("00 02"); + await delay(300); // Wait for 300ms + sendHexToSerial("02 00"); + await delay(300); // Wait for 300ms + sendHexToSerial("02 14"); // init 20 wpm $('#winkey_buttons').show(); @@ -150,25 +159,70 @@ async function connect() { } } -//Write to the Serial port -async function writeToStream(line) { - var enc = new TextEncoder(); // always utf-8 - - const writer = outputStream.getWriter(); - - writer.write([line.toUpperCase()]); - writer.releaseLock(); +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); } -async function writeToByte(line) { - const writer = outputStream.getWriter(); - const data = new Uint8Array([line]); - writer.write(data); - writer.releaseLock(); +// Helper function to convert a hex string to a Uint8Array +function hexStringToUint8Array(hexString) { + // Remove any spaces or non-hex characters + hexString = hexString.replace(/[^0-9a-f]/gi, ''); + + // Ensure the string has an even length + if (hexString.length % 2 !== 0) { + console.warn('Hex string has an odd length, padding with a leading zero.'); + hexString = '0' + hexString; + } + + const byteArray = new Uint8Array(hexString.length / 2); + + for (let i = 0; i < hexString.length; i += 2) { + byteArray[i / 2] = parseInt(hexString.substr(i, 2), 16); + } + + return byteArray; +} + +async function sendHexToSerial(hexString) { + if (port && port.writable) { + // Convert the hex string to a Uint8Array + const byteArray = hexStringToUint8Array(hexString); + + // Create a writer from the writable stream + const writer = port.writable.getWriter(); + + try { + // Write the byte array to the serial port + await writer.write(byteArray); + } catch (error) { + console.error('Error writing to serial port:', error); + } finally { + // Release the lock on the writer + writer.releaseLock(); + } + } else { + console.error('Port is not available or writable.'); + } +} + +//Write to the Serial port +async function writeToStream(line) { + const outputStream = port.writable.getWriter(); + + // Convert the text to a Uint8Array + const encoder = new TextEncoder(); + const buffer = encoder.encode(line.toUpperCase()); + + // Write the Uint8Array to the serial port + await outputStream.write(buffer); + + // Release the stream lock + outputStream.releaseLock(); } //Disconnect from the Serial port async function disconnect() { + sendHexToSerial("00 03"); if (reader) { await reader.cancel(); From 5c4e50c231f5bfce11bb6b69401b8f400deecdae Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Sat, 24 Aug 2024 16:01:38 +0200 Subject: [PATCH 3/6] Added button to stop CW sending --- application/views/qso/index.php | 1 + assets/js/winkey.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/application/views/qso/index.php b/application/views/qso/index.php index c82e5fd78..6cc47c1ca 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -653,6 +653,7 @@
+ diff --git a/assets/js/winkey.js b/assets/js/winkey.js index c4bc653f5..6d51550d1 100644 --- a/assets/js/winkey.js +++ b/assets/js/winkey.js @@ -159,6 +159,10 @@ async function connect() { } } +function stop_cw_sending() { + sendHexToSerial("0A"); +} + function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } From bdad632f3645dbbe384819b341b26b1bc222cc19 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Sat, 24 Aug 2024 18:37:32 +0200 Subject: [PATCH 4/6] Added tune button --- application/views/qso/index.php | 2 ++ assets/js/winkey.js | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 6cc47c1ca..cb00380e1 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -654,6 +654,8 @@
+ + diff --git a/assets/js/winkey.js b/assets/js/winkey.js index 6d51550d1..f8bbc0be5 100644 --- a/assets/js/winkey.js +++ b/assets/js/winkey.js @@ -163,6 +163,18 @@ function stop_cw_sending() { sendHexToSerial("0A"); } +function send_carrier() { + sendHexToSerial("0B 01"); + $("#send_carrier").attr("hidden", true); + $("#stop_carrier").attr("hidden", false); +} + +function stop_carrier() { + sendHexToSerial("0B 00"); + $("#send_carrier").attr("hidden", false); + $("#stop_carrier").attr("hidden", true); +} + function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } From 1d16bf50de604f91a7e62898fbdca4a532221867 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Sat, 24 Aug 2024 18:47:20 +0200 Subject: [PATCH 5/6] Hide stop tune button when clicking stop button as well --- assets/js/winkey.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assets/js/winkey.js b/assets/js/winkey.js index f8bbc0be5..7a319beda 100644 --- a/assets/js/winkey.js +++ b/assets/js/winkey.js @@ -161,6 +161,8 @@ async function connect() { function stop_cw_sending() { sendHexToSerial("0A"); + $("#send_carrier").attr("hidden", false); + $("#stop_carrier").attr("hidden", true); } function send_carrier() { From 4563c1d44d1aa680d9f509d258b3a56bca81b258 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 25 Aug 2024 11:18:07 +0000 Subject: [PATCH 6/6] po/mo updates --- .../locale/bg_BG/LC_MESSAGES/messages.po | 28 +++++++++++++++---- application/locale/bs/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/cnr/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/cs_CZ/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/de_DE/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/el_GR/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/es_ES/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/fi_FI/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/fr_FR/LC_MESSAGES/messages.po | 28 +++++++++++++++---- application/locale/hr/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/it_IT/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/nl_NL/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/pl_PL/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/pt_PT/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/ru_RU/LC_MESSAGES/messages.po | 28 +++++++++++++++---- application/locale/sq/LC_MESSAGES/messages.po | 28 +++++++++++++++---- application/locale/sr/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/sv_SE/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/tr_TR/LC_MESSAGES/messages.po | 28 +++++++++++++++---- .../locale/zh_CN/LC_MESSAGES/messages.po | 28 +++++++++++++++---- assets/lang_src/messages.pot | 28 +++++++++++++++---- 21 files changed, 462 insertions(+), 126 deletions(-) diff --git a/application/locale/bg_BG/LC_MESSAGES/messages.po b/application/locale/bg_BG/LC_MESSAGES/messages.po index 69237f908..e10c6c65b 100644 --- a/application/locale/bg_BG/LC_MESSAGES/messages.po +++ b/application/locale/bg_BG/LC_MESSAGES/messages.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: translations@wavelog.org\n" -"POT-Creation-Date: 2024-08-25 10:43+0000\n" +"POT-Creation-Date: 2024-08-25 11:18+0000\n" "PO-Revision-Date: 2024-08-17 10:46+0000\n" "Last-Translator: Anonymous \n" "Language-Team: Bulgarian \n" "Language-Team: Bosnian \n" "Language-Team: Montenegrin \n" "Language-Team: Czech \n" "Language-Team: German \n" "Language-Team: Greek \n" "Language-Team: Spanish \n" "Language-Team: Finnish \n" "Language-Team: French \n" "Language-Team: Croatian \n" "Language-Team: Italian \n" "Language-Team: Dutch \n" "Language-Team: Polish \n" "Language-Team: Portuguese (Portugal) \n" "Language-Team: Russian \n" "Language-Team: Albanian \n" "Language-Team: Serbian \n" "Language-Team: Swedish \n" "Language-Team: Turkish \n" "Language-Team: Chinese (Simplified) \n" "Language-Team: LANGUAGE \n" @@ -8620,7 +8620,7 @@ msgstr "" msgid "TimeOff is less than TimeOn" msgstr "" -#: application/views/qso/index.php:5 application/views/qso/index.php:690 +#: application/views/qso/index.php:5 application/views/qso/index.php:696 msgid "Previous Contacts" msgstr "" @@ -8734,19 +8734,35 @@ msgstr "" msgid "Connect" msgstr "" -#: application/views/qso/index.php:663 +#: application/views/qso/index.php:656 +msgid "Stop" +msgstr "" + +#: application/views/qso/index.php:657 +msgid "Tune" +msgstr "" + +#: application/views/qso/index.php:658 +msgid "Stop Tune" +msgstr "" + +#: application/views/qso/index.php:664 +msgid "CW Speed" +msgstr "" + +#: application/views/qso/index.php:669 msgid "Send" msgstr "" -#: application/views/qso/index.php:673 +#: application/views/qso/index.php:679 msgid "Suggestions" msgstr "" -#: application/views/qso/index.php:680 +#: application/views/qso/index.php:686 msgid "Profile Picture" msgstr "" -#: application/views/qso/index.php:704 +#: application/views/qso/index.php:710 msgid "Max. 5 previous contacts are shown" msgstr ""