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: 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) + -
-
- - - - - -
- - +
+ + + + + + + + + + +
-
+ + + +
diff --git a/assets/js/winkey.js b/assets/js/winkey.js index 74df8e7d7..7a319beda 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; @@ -126,12 +138,12 @@ async function connect() { inputDone = port.readable.pipeTo(decoder.writable); inputStream = decoder.readable; - const encoder = new TextEncoderStream(); - outputDone = encoder.readable.pipeTo(port.writable); - outputStream = encoder.writable; - - 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(); @@ -147,24 +159,88 @@ 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); - writer.releaseLock(); +function stop_cw_sending() { + sendHexToSerial("0A"); + $("#send_carrier").attr("hidden", false); + $("#stop_carrier").attr("hidden", true); } -async function writeToByte(line) { - const writer = outputStream.getWriter(); - const data = new Uint8Array([line]); - writer.write(data); - writer.releaseLock(); +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)); +} + +// 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(); @@ -187,11 +263,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(''); + }); } diff --git a/assets/lang_src/messages.pot b/assets/lang_src/messages.pot index a8e4e9b06..79980c4ec 100644 --- a/assets/lang_src/messages.pot +++ b/assets/lang_src/messages.pot @@ -6,7 +6,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: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \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 ""