def main():

    if not len(sys.argv) == 2:
        usage()

    port_name = sys.argv[1]  # str: serial port name

    serial_reader_obj = serial_reader.SerialReader(port_name,
                                                   handle_incoming_messages)
    serial_reader_thread = serial_reader_obj.read_data()
Beispiel #2
0
    def start_recording(self):
        """ Start recording audio from the microphone nd classify the audio. Note we use a background thread to
        process the audio and we setup a UI animation function to draw the sliding spectrogram image, this way
        the UI update doesn't interfere with the smoothness of the microphone readings """

        self.stop()

        input_channel = None

        if self.serial_port:
            import serial_reader
            self.serial = serial_reader.SerialReader(0.001)
            self.serial.open(self.featurizer.input_size, self.serial_port)
            input_channel = self.serial
        else:
            if self.microphone is None:
                self.microphone = microphone.Microphone(
                    auto_scale=self.auto_scale, console=False)

            num_channels = 1
            self.microphone.open(self.featurizer.input_size, self.sample_rate,
                                 num_channels, self.input_device)
            input_channel = self.microphone

        def update_func(frame_index):
            # this is an animation callback to update the UI every 33 milliseconds.
            self.process_output()
            self.set_spectrogram_image()
            if not self.reading_input:
                self.after(1, self.on_stopped)
            return (self.spectrogram_image, )

        if self.animation:
            self.animation.event_source.stop()

        self.reading_input = True
        # Start animation timer for updating the UI (e.g. spectrogram image) (30 fps is usually fine)
        self.animation = animation.FuncAnimation(self.features_figure,
                                                 update_func,
                                                 interval=33,
                                                 blit=True)

        # start background thread to read and classify the recorded audio.
        self.featurizer.open(input_channel)
        self.read_input_thread = Thread(target=self.on_read_features, args=())
        self.read_input_thread.daemon = True
        self.read_input_thread.start()
Beispiel #3
0
    def start_recording(self):
        """ Start recording audio from the microphone nd classify the audio. Note we use a background thread to
        process the audio and we setup a UI animation function to draw the sliding spectrogram image, this way
        the UI update doesn't interfere with the smoothness of the microphone readings """

        self.stop()

        input_channel = None

        if self.serial_port:
            import serial_reader
            self.serial = serial_reader.SerialReader(0.001)
            self.serial.open(self.featurizer.input_size, self.serial_port)
            input_channel = self.serial
        else:
            if self.microphone is None:
                self.microphone = microphone.Microphone(
                    auto_scale=self.auto_scale, console=False)

            num_channels = 1
            self.microphone.open(self.featurizer.input_size, self.sample_rate,
                                 num_channels, self.input_device)
            input_channel = self.microphone

        def update_func(frame_index):
            return self.on_ui_update()

        if self.animation:
            self.animation.event_source.stop()

        self.reading_input = True
        # Start animation timer for updating the UI (e.g. spectrogram image)
        self.animation = self.spectrogram_widget.begin_animation(update_func)

        # start background thread to read and classify the recorded audio.
        self.featurizer.open(input_channel)
        self.read_input_thread = Thread(target=self.on_read_features, args=())
        self.read_input_thread.daemon = True
        self.read_input_thread.start()
Beispiel #4
0
import serial_reader
from threading import Thread, Event
from time import sleep
import tkinter as tk
from tkinter import scrolledtext
from tkinter import ttk

reader = serial_reader.SerialReader('COM8')
# reader = serial_reader.SerialReader(None)

max_ra_as = 1296000
min_ra_as = 0
max_dec_as = 324000
min_dec_as = -324000
new_string = None
is_moving = False

root = tk.Tk()
ra_hours_var = tk.StringVar(value=23)
ra_minutes_var = tk.StringVar(value=59)
ra_seconds_var = tk.StringVar(value=59)
optics_f_var = tk.StringVar(value=650)
optics_pixel_var = tk.StringVar(value=2.9)
ra_precise_var = tk.StringVar(value=0)
dec_precise_var = tk.StringVar(value=0)
dec_degrees_var = tk.StringVar(value=-89)
dec_minutes_var = tk.StringVar(value=59)
dec_seconds_var = tk.StringVar(value=59)
dec_drift_var = tk.StringVar(value=0)

possible_units = ["steps", "arcsec", "pixels"]