-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoolbar.py
74 lines (58 loc) · 1.99 KB
/
toolbar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from kivy.properties import NumericProperty, ObjectProperty, StringProperty
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.popup import Popup
from communication import KivySerial
class Toolbar(BoxLayout):
"""
@brief Lateral toolbar widget.
The toolbar widget is used to show some
settings related to the app.
"""
"""
@brief String used to send messages to bottom bar.
"""
message_string = StringProperty("")
def __init__(self, **kwargs):
super(Toolbar, self).__init__(**kwargs)
def sample_rate_dialog(self):
"""
@brief Open popup for wave selection.
"""
self.message_string = "Sample Rate Dialog"
popup = SampleRateDialog()
popup.open()
class SampleRateDialog(Popup):
"""
@brief Popup to allow wave selection
"""
sample_rate_spinner = ObjectProperty(None)
def __init__(self, **kwargs):
self.board = KivySerial()
super(SampleRateDialog, self).__init__(**kwargs)
def on_sample_rate_spinner(self, instance, value):
self.sample_rate_spinner.text = f'{self.board.sample_rate} Hz'
##
# @brief Callback called when update button is pressed.
#
# If the board is connected, update the sample rate.
#
def update_pressed(self):
if (self.board.is_connected()):
self.board.update_sample_rate_on_board(self.sample_rate_spinner.text)
self.dismiss()
class RangeSelectDialog(Popup):
"""
@brief Popup to allow range selection
"""
range_spinner = ObjectProperty(None)
def __init__(self, **kwargs):
super(RangeSelectDialog, self).__init__(**kwargs)
self.board = KivySerial()
def update_pressed(self):
"""
@brief Callback called when update button is pressed.
If the board is connected, update the range selection.
"""
if (self.board.is_connected()):
self.board.select_range(self.range_spinner.text)
self.dismiss()