Update to the morse encoder.py
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
import microbit
|
import microbit
|
||||||
|
|
||||||
|
microbit.uart.write()
|
||||||
4
log/logging.md
Normal file
4
log/logging.md
Normal 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.
|
||||||
Reference in New Issue
Block a user