diff --git a/bin/log/logging.md b/bin/log/logging.md new file mode 100644 index 0000000..e69de29 diff --git a/bin/micro_bit/micro_bit_soft.py b/bin/micro_bit/micro_bit_soft.py deleted file mode 100644 index 0724caa..0000000 --- a/bin/micro_bit/micro_bit_soft.py +++ /dev/null @@ -1,3 +0,0 @@ -import microbit - -microbit.uart.write() \ No newline at end of file diff --git a/bin/micro_bit/micro_bit_soft/decoder/decoder.py b/bin/micro_bit/micro_bit_soft/decoder/decoder.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/micro_bit/micro_bit_soft/decoder/encoder.py b/bin/micro_bit/micro_bit_soft/decoder/encoder.py new file mode 100644 index 0000000..507cac9 --- /dev/null +++ b/bin/micro_bit/micro_bit_soft/decoder/encoder.py @@ -0,0 +1,36 @@ +# create class that encodes plain text into morse + +class Encoder: + # init class + def __init__(self): + # Morse code dict + self.morse_code = {'A': '.-', 'B': '-...', + 'C': '-.-.', 'D': '-..', 'E': '.', + 'F': '..-.', 'G': '--.', 'H': '....', + 'I': '..', 'J': '.---', 'K': '-.-', + 'L': '.-..', 'M': '--', 'N': '-.', + 'O': '---', 'P': '.--.', 'Q': '--.-', + 'R': '.-.', 'S': '...', 'T': '-', + 'U': '..-', 'V': '...-', 'W': '.--', + 'X': '-..-', 'Y': '-.--', 'Z': '--..', + '1': '.----', '2': '..---', '3': '...--', + '4': '....-', '5': '.....', '6': '-....', + '7': '--...', '8': '---..', '9': '----.', + '0': '-----', 'Ä': '.-.-', 'Ö': '---.', + 'Ü': '..--', ',': '--..--', '.': '.-.-.-', + '?': '..--..', '/': '-..-.', '-': '-....-', + '(': '-.--.', ')': '-.--.-', ':': '---...', + '!': '-.-.--', ' ': '@'} + self.__input_raw = "" + self.__output = [] + self.__pos = 0 + + def encode(self): + self.__input_raw = self.get_input() + for self.item in self.__input_raw: + self.__code = self.morse_code.get(self.item) + self.__output.append(self.__code) + return self.__output + + def get_input(self): + return input("please input some text here to transmit: ").upper() diff --git a/bin/micro_bit/micro_bit_soft/decoder/exec.py b/bin/micro_bit/micro_bit_soft/decoder/exec.py new file mode 100644 index 0000000..ebc65fc --- /dev/null +++ b/bin/micro_bit/micro_bit_soft/decoder/exec.py @@ -0,0 +1,5 @@ +import run + +m = run.Morse() + +m.run() diff --git a/bin/micro_bit/micro_bit_soft/decoder/log_generator.py b/bin/micro_bit/micro_bit_soft/decoder/log_generator.py new file mode 100644 index 0000000..2dc16c3 --- /dev/null +++ b/bin/micro_bit/micro_bit_soft/decoder/log_generator.py @@ -0,0 +1,3 @@ +class LogGenerator: + def __init__(self): + pass \ No newline at end of file diff --git a/bin/micro_bit/micro_bit_soft/decoder/run.py b/bin/micro_bit/micro_bit_soft/decoder/run.py new file mode 100644 index 0000000..e0d2854 --- /dev/null +++ b/bin/micro_bit/micro_bit_soft/decoder/run.py @@ -0,0 +1,28 @@ +import music + +import encoder +import music + + +mdc = encoder.Encoder() + + +class Morse: + def __init__(self): + self.__encoded = [] + self.__sound_duration = 50 + + def run(self): + self.__encoded = mdc.encode() + self.output_gen() + + def output_gen(self): + for self.item in self.__encoded: + for self.ec in self.item: + if self.ec == ".": + music.pitch(440, self.__sound_duration) + elif self.ec == "-": + music.pitch(440, self.__sound_duration * 3) + + +Morse().run() diff --git a/bin/micro_bit/micro_bit_soft/full_duplex.py b/bin/micro_bit/micro_bit_soft/full_duplex.py new file mode 100644 index 0000000..eff0173 --- /dev/null +++ b/bin/micro_bit/micro_bit_soft/full_duplex.py @@ -0,0 +1,11 @@ +from microbit import * +import music + +while True: + if button_a.is_pressed(): + pin1.write_digital(True) + elif pin2.read_digital() == 1: + music.pitch(440, 50, wait=False) + else: + music.stop() + pin1.write_digital(False) diff --git a/bin/micro_bit/micro_bit_soft/half_duplex.py b/bin/micro_bit/micro_bit_soft/half_duplex.py new file mode 100644 index 0000000..2096200 --- /dev/null +++ b/bin/micro_bit/micro_bit_soft/half_duplex.py @@ -0,0 +1,16 @@ +from microbit import * +import music + +while True: + if button_a.is_pressed() is True: + if pin1.read_digital() == 1: + display.show(Image.NO) + else: + pin1.write_digital(1) + else: + music.stop() + pin1.write_digital(0) + if pin1.read_digital() == 1: + music.pitch(440, 50, wait=False) + else: + music.stop() diff --git a/bin/micro_bit/micro_bit_soft/listen.py b/bin/micro_bit/micro_bit_soft/listen.py new file mode 100644 index 0000000..ff13d00 --- /dev/null +++ b/bin/micro_bit/micro_bit_soft/listen.py @@ -0,0 +1,10 @@ +from microbit import * +import music + +while True: + if pin1.read_digital() == 1: + music.pitch(440, 50, wait=False) + display.set_pixel(2, 2, 9) + else: + display.clear() + music.stop() diff --git a/bin/micro_bit/micro_bit_soft/micro_bit_soft.py b/bin/micro_bit/micro_bit_soft/micro_bit_soft.py new file mode 100644 index 0000000..afa3941 --- /dev/null +++ b/bin/micro_bit/micro_bit_soft/micro_bit_soft.py @@ -0,0 +1,2 @@ +import microbit + diff --git a/bin/micro_bit/micro_bit_soft/sender.py b/bin/micro_bit/micro_bit_soft/sender.py new file mode 100644 index 0000000..bd3f0bf --- /dev/null +++ b/bin/micro_bit/micro_bit_soft/sender.py @@ -0,0 +1,11 @@ +import music +from microbit import * + +while True: + if button_a.is_pressed() is True: + pin1.write_digital(1) + music.pitch(440, 50, wait=False) + else: + music.stop() + pin1.write_digital(0) +