Update to the morse encoder.py

This commit is contained in:
janis
2022-05-19 15:29:54 +02:00
parent ac376880b1
commit 62c69b8f70
4 changed files with 25 additions and 1 deletions

View File

View File

@@ -1,4 +1,6 @@
# create class that encodes plain text into morse # create class that encodes plain text into morse
import microbit
class Encoder: class Encoder:
# init class # init class
@@ -24,6 +26,7 @@ class Encoder:
self.__input_raw = "" self.__input_raw = ""
self.__output = [] self.__output = []
self.__pos = 0 self.__pos = 0
self.check = 0
def encode(self): def encode(self):
self.__input_raw = self.get_input() self.__input_raw = self.get_input()
@@ -33,4 +36,20 @@ class Encoder:
return self.__output return self.__output
def get_input(self): def get_input(self):
return input("please input some text here to transmit: ").upper() self.str_input = "Please type the text to be morsed. "
microbit.uart.write(self.str_input.encode())
self.input = ""
while self.input == "":
self.input = microbit.uart.read(1)
self.ouput = ""
self.check = 0
while self.check < 3:
self.input = microbit.uart.read(1)
if self.input == "":
self.output += self.input
self.check += 1
else:
self.ouput += self.input
return self.ouput

View File

@@ -1,2 +1,3 @@
import microbit import microbit
microbit.uart.write()

4
log/logging.md Normal file
View File

@@ -0,0 +1,4 @@
# LOGGING in this Program.
The log files that are created during the execution of this program are **__NOT__** shared with anybody automatically.
If you wish to do a bugreport, we encourage you to include the log of the program. You can obviously take a look at the log file before sending it.