Example #1
0
    def __init__(self, app, parent=None):
        ''' Окно для воспроизведения импульсов
        '''
        super(TestApp, self).__init__(parent)

        # Создаём аудио-интерфейс
        self.audio = AudioInterface()


        cntr = QtCore.Qt.AlignHCenter

        self.layout = QVBoxLayout()

        self.layout.addWidget(QLabel(u'Форма импульса', alignment=cntr))
        self.add_impulse_layout()

        self.layout.addWidget(QLabel(u'Количество импульсов', alignment=cntr))
        self.add_impulse_condition()

        self.layout.addWidget(QLabel(u'Управление импульсами', alignment=cntr))
        self.add_control_buttons(u'Левый: ', 0)
        self.add_control_buttons(u'Правый: ', 1)

        self.add_reset_btn()


        self.setLayout(self.layout)


        # Выставляем заголовок
        self.setWindowTitle(u'SAE тестовое приложение')
Example #2
0
 def initialise():
     GpioInterface.initialise()
     Peripherals.motion_sensor = MotionSensor(14)
     Peripherals.laser = Laser(4)
     Peripherals.laser.turnOff()
     Peripherals.gimbal = Gimbal(3, 2)
     Peripherals.audio = AudioInterface()
     Peripherals.button = Button(15)
Example #3
0
class TestApp(QDialog):

    RATE = 44100
    CHUNK = 44100
    CHANNELS = 2
    WIDTH = 2

    def __init__(self, app, parent=None):
        ''' Окно для воспроизведения импульсов
        '''
        super(TestApp, self).__init__(parent)

        # Создаём аудио-интерфейс
        self.audio = AudioInterface()


        cntr = QtCore.Qt.AlignHCenter

        self.layout = QVBoxLayout()

        self.layout.addWidget(QLabel(u'Форма импульса', alignment=cntr))
        self.add_impulse_layout()

        self.layout.addWidget(QLabel(u'Количество импульсов', alignment=cntr))
        self.add_impulse_condition()

        self.layout.addWidget(QLabel(u'Управление импульсами', alignment=cntr))
        self.add_control_buttons(u'Левый: ', 0)
        self.add_control_buttons(u'Правый: ', 1)

        self.add_reset_btn()


        self.setLayout(self.layout)


        # Выставляем заголовок
        self.setWindowTitle(u'SAE тестовое приложение')





    def add_impulse_layout(self):
        def on_change(v):
            value = (
                int(input_neg.value()),
                int(input_pos.value()),
                int(input_zer.value()),
            )
            self.audio.impulse_form = value

        lt = QHBoxLayout()
        self.layout.addLayout(lt)

        lt.addWidget(QLabel('-'))
        input_neg = QDoubleSpinBox(value=100, maximum=10**6, decimals=0)
        input_neg.valueChanged.connect(on_change)
        lt.addWidget(input_neg)

        lt.addWidget(QLabel('+'))
        input_pos = QDoubleSpinBox(value=100, maximum=10**6, decimals=0)
        input_pos.valueChanged.connect(on_change)
        lt.addWidget(input_pos)

        lt.addWidget(QLabel('0'))
        input_zer = QDoubleSpinBox(value=100, maximum=10**6, decimals=0)
        input_zer.valueChanged.connect(on_change)
        lt.addWidget(input_zer)

        on_change(None)

    def add_impulse_condition(self):
        lt = QHBoxLayout()
        self.layout.addLayout(lt)

        lt.addWidget(QLabel(u'Левый канал: '))
        self.left_impulses_label = QLabel('0')
        lt.addWidget(self.left_impulses_label)

        lt.addWidget(QLabel(u'Правый канал: '))
        self.right_impulses_label = QLabel('0')
        lt.addWidget(self.right_impulses_label)

    def add_control_buttons(self, label, channel):

        def add_impulses():
            count = inp.value()
            self.audio.add_impulses(channel, count)

        lt = QHBoxLayout()
        self.layout.addLayout(lt)

        lt.addWidget(QLabel(label))
        inp = QDoubleSpinBox(value=100, maximum=10**6, decimals=0)
        lt.addWidget(inp)

        btn = QPushButton(u'Добавить')
        btn.clicked.connect(add_impulses)
        lt.addWidget(btn)

        btn_rst = QPushButton(u'Сбросить')
        btn_rst.clicked.connect(lambda: self.audio.reset_impulses(channel))
        lt.addWidget(btn_rst)

    def add_reset_btn(self):
        btn = QPushButton(u'Подать импульс на оба канала')
        btn.clicked.connect(self.audio.make_double_impulse)
        self.layout.addWidget(btn)




    def closeEvent(self, event):
        self.audio.close()