Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies = [
"minimalmodbus>=2.1.1",
"nmcli>=1.5.0",
"pydantic>=2.10.3",
"pygame>=2.0.0",
"pyyaml>=6.0.2",
"aiohttp>=3.9.0",
"sentry-sdk>=2.32.0",
Expand Down
18 changes: 15 additions & 3 deletions rcp/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os

import pygame

import sentry_sdk
from kivy.app import App
from kivy.config import Config
Expand Down Expand Up @@ -58,16 +60,18 @@ class MainApp(App):

manager = ObjectProperty()

sound = ObjectProperty()

version = StringProperty()

def __init__(self, **kv):
super().__init__(**kv)


def beep(self, *args, **kv):
pass
# self.sound.volume = self.formats.volume
# self.sound.play()
if self.sound and hasattr(self, "formats"):
self.sound.set_volume(self.formats.volume)
self.sound.play()

@staticmethod
def load_help(help_file_name):
Expand Down Expand Up @@ -95,6 +99,14 @@ def build(self):
self.formats = FormatsDispatcher(id_override="0")
self.board = Board(formats=self.formats, offset_provider=self)

# Load beep sound
sound_path = os.path.join(os.path.dirname(__file__), "sounds", "beep.mp3")
pygame.mixer.pre_init(frequency=44100, size=-16, channels=1, buffer=512)
pygame.init()
self.sound = pygame.mixer.Sound(sound_path)
if self.sound is None:
log.warning(f"Failed to load sound from {sound_path}")

if not self.formats.disable_error_reporting:
log.info("Error reporting is enabled, configuring Sentry")
sentry_sdk.init(
Expand Down
7 changes: 6 additions & 1 deletion rcp/components/home/coordbar.kv
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
text: root.axis.axis_name if root.axis else "?"
font_size: min(self.height / 1.5, self.width/1.5)
background_color: [0.2, 1, 0.2, 1] if (root.axis and root.axis.syncEnable) else [0.3, 0.3, 0.3, 1]
on_press: app.beep()
on_release: root.toggle_sync()

BoxLayout:
Expand Down Expand Up @@ -84,6 +85,7 @@
text_size: self.size
halign: 'center'
valign: 'middle'
on_press: app.beep()
on_release: Factory.Keypad(integer=True).show(root.axis, 'syncRatioNum') if root.axis else None

BoxLayout:
Expand All @@ -108,6 +110,7 @@
text_size: self.size
halign: 'center'
valign: 'middle'
on_press: app.beep()
on_release: Factory.Keypad(integer=True).show(root.axis, 'syncRatioDen') if root.axis else None

Button:
Expand All @@ -117,5 +120,7 @@
background_color: [0.5, 0.5, 0.5, 1]
width: self.height
size_hint_x: None
on_press: root.on_zero_press()
on_press:
app.beep()
root.on_zero_press()
on_release: root.on_zero_release()
4 changes: 3 additions & 1 deletion rcp/components/home/dro_coordbar.kv
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,7 @@
background_color: [0.5, 0.5, 0.5, 1]
width: self.height
size_hint_x: None
on_press: root.on_zero_press()
on_press:
app.beep()
root.on_zero_press()
on_release: root.on_zero_release()
4 changes: 3 additions & 1 deletion rcp/components/home/els_mode_layout.kv
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@
background_color: [0.5, 0.5, 0.5, 1]
width: self.height
size_hint_x: None
on_press: root.on_zero_press()
on_press:
app.beep()
root.on_zero_press()
on_release: root.on_zero_release()
4 changes: 4 additions & 0 deletions rcp/components/home/elsbar.kv
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
font_size: self.height / 1.5
font_style: "bold"
background_color: [0.2, 1, 0.2, 1] if app.servo.servoEnable else [0.3, 0.3, 0.3, 1]
on_press: app.beep()
on_release: app.servo.toggle_enable()

BoxLayout:
Expand Down Expand Up @@ -55,6 +56,7 @@
font_size: self.height / 4
font_style: "bold"
halign: "center"
on_press: app.beep()
on_release: root.previous_feed()

BoxLayout:
Expand All @@ -79,6 +81,7 @@
text_size: self.size
halign: 'center'
valign: 'middle'
on_press: app.beep()
on_release: Factory.FeedsTablePopup().show_with_callback(root.set_feed_ratio)

Button:
Expand All @@ -90,4 +93,5 @@
font_size: self.height / 4
font_style: "bold"
halign: "center"
on_press: app.beep()
on_release: root.next_feed()
11 changes: 9 additions & 2 deletions rcp/components/home/jogbar.kv
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
font_size: self.height / 1.5
font_style: "bold"
background_color: [0.2, 1, 0.2, 1] if app.servo.servoEnable else [0.3, 0.3, 0.3, 1]
on_press: app.beep()
on_release: app.servo.toggle_enable()
disabled: root.enable_jog

Expand All @@ -36,6 +37,7 @@
text_size: self.size
halign: 'center'
valign: 'middle'
on_press: app.beep()
on_release: Factory.Keypad().show(root, 'desired_speed')
Label:
text: "Max: {}".format(app.servo.maxSpeed)
Expand Down Expand Up @@ -105,7 +107,9 @@
font_style: "bold"
halign: "center"
disabled: not app.servo.servoEnable
on_press: root.enable_jog_reverse = True
on_press:
app.beep()
root.enable_jog_reverse = True
on_release: root.enable_jog_reverse = False

Button:
Expand All @@ -118,6 +122,7 @@
halign: "center"
background_color: app.formats.cancel_color if root.enable_jog else app.formats.accept_color
disabled: not app.servo.servoEnable
on_press: app.beep()
on_release: root.enable_jog = not root.enable_jog

Button:
Expand All @@ -129,5 +134,7 @@
font_style: "bold"
halign: "center"
disabled: not app.servo.servoEnable
on_press: root.enable_jog = True
on_press:
app.beep()
root.enable_jog = True
on_release: root.enable_jog = False
6 changes: 6 additions & 0 deletions rcp/components/home/servobar.kv
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
font_size: min(self.height / 1.5, self.width/1.5)
font_style: "bold"
background_color: [0.2, 1, 0.2, 1] if app.servo.servoEnable else [0.3, 0.3, 0.3, 1]
on_press: app.beep()
on_release: app.servo.toggle_enable()
BoxLayout:
orientation: "vertical"
Expand Down Expand Up @@ -66,6 +67,7 @@
halign: 'center'
valign: 'middle'
disabled: app.servo.disableControls
on_press: app.beep()
on_release: Factory.Keypad().show(app.servo, 'offset')

Label:
Expand All @@ -88,6 +90,7 @@
halign: 'center'
valign: 'middle'
disabled: app.servo.disableControls
on_press: app.beep()
on_release: Factory.Keypad(integer=True).show(app.servo, 'divisions')

BoxLayout:
Expand All @@ -102,13 +105,15 @@
font_name: "fonts/Font Awesome 6 Free-Solid-900.otf"
text: "\uf060"
disabled: app.servo.disableControls
on_press: app.beep()
on_release: app.servo.go_previous()
Button:
font_size: 24
font_style: "bold"
font_name: "fonts/Font Awesome 6 Free-Solid-900.otf"
text: "\uf061"
disabled: app.servo.disableControls
on_press: app.beep()
on_release: app.servo.go_next()
BoxLayout:
orientation: "vertical"
Expand All @@ -132,4 +137,5 @@
halign: 'center'
valign: 'middle'
disabled: app.servo.disableControls
on_press: app.beep()
on_release: Factory.Keypad(integer=True).show(app.servo, 'index')
1 change: 1 addition & 0 deletions rcp/components/plot/circle_popup.kv
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@
font_name: "fonts/Font Awesome 6 Free-Solid-900.otf"
text: "\uf00c"
background_color: "#349e65"
on_press: app.beep()
on_release: root.dismiss()
1 change: 1 addition & 0 deletions rcp/components/plot/line_popup.kv
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@
font_name: "fonts/Font Awesome 6 Free-Solid-900.otf"
text: "\uf00c"
background_color: "#349e65"
on_press: app.beep()
on_release: root.dismiss()
1 change: 1 addition & 0 deletions rcp/components/plot/rect_popup.kv
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@
font_name: "fonts/Font Awesome 6 Free-Solid-900.otf"
text: "\uf00c"
background_color: "#349e65"
on_press: app.beep()
on_release: root.dismiss()
7 changes: 2 additions & 5 deletions rcp/components/popups/feeds_table_popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem

from rcp import feeds
from rcp.components.widgets.beep_mixin import BeepMixin

log = Logger.getChild(__name__)


class FeedButton(Button):
class FeedButton(BeepMixin, Button):
text_halign = "center"
font_style = "bold"
font_name = StringProperty("fonts/Manrope-Bold.ttf")
Expand Down Expand Up @@ -54,10 +55,6 @@ def __init__(self, **kwargs):
self.callback_fn = None
self.current_value = None

def on_touch_down(self, touch):
self.app.beep()
return super().on_touch_down(touch)

def show_with_callback(self, callback_fn, current_value=None):
if current_value is not None:
# Use the specified current value if passed
Expand Down
1 change: 1 addition & 0 deletions rcp/components/popups/help_popup.kv
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
size_hint_y: None
height: 50
text: "Close"
on_press: app.beep()
on_release: root.dismiss()
4 changes: 0 additions & 4 deletions rcp/components/popups/keypad.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ def __init__(self, **kwargs):
def on_current_value(self, instance, value):
self.title = f"Old Value: {value}"

def on_touch_down(self, touch):
self.app.beep()
return super().on_touch_down(touch)

def _keyboard_closed(self):
self._keyboard.unbind(on_key_down=self._on_keyboard_down)
self._keyboard = None
Expand Down
4 changes: 0 additions & 4 deletions rcp/components/popups/mode_popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ def __init__(self, **kwargs):
self.add_widget(buttons)
self.callback_fn = None

def on_touch_down(self, touch):
self.app.beep()
return super().on_touch_down(touch)

def show_with_callback(self, callback_fn, current_value=None):
if current_value is not None:
# Use the specified current value if passed
Expand Down
3 changes: 3 additions & 0 deletions rcp/components/popups/ssid_popup.kv
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
size_hint_x: 0.3
text: "Scan"
disabled: root.scanning
on_press: app.beep()
on_release: root.schedule_scan()

ScrollView:
Expand All @@ -44,10 +45,12 @@
text: "Cancel"
font_size: app.formats.font_size
back_layer_color: app.formats.cancel_color
on_press: app.beep()
on_release: root.dismiss()

Button:
text: "Apply"
font_size: app.formats.font_size
back_layer_color: app.formats.accept_color
on_press: app.beep()
on_release: root.apply()
2 changes: 2 additions & 0 deletions rcp/components/screens/axis_screen.kv
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@
text: "Apply Transform"
font_size: app.formats.font_size
background_color: [0.2, 0.6, 0.2, 1]
on_press: app.beep()
on_release: root.apply_transform()
Button:
text: "Remove Axis"
font_size: app.formats.font_size
background_color: [0.8, 0.2, 0.2, 1]
on_press: app.beep()
on_release: root.remove_axis()
2 changes: 2 additions & 0 deletions rcp/components/screens/color_picker_screen.kv
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
text: "Cancel"
font_size: app.formats.font_size
background_color: app.formats.cancel_color
on_press: app.beep()
on_release: app.manager.back()

Button:
text: "Apply"
font_size: app.formats.font_size
background_color: app.formats.accept_color
on_press: app.beep()
on_release:
root.callback(root.color)
app.manager.back()
2 changes: 2 additions & 0 deletions rcp/components/screens/font_picker_screen.kv
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
text: "Cancel"
font_size: app.formats.font_size
background_color: app.formats.cancel_color
on_press: app.beep()
on_release: app.manager.back()

Button:
text: "Apply"
font_size: app.formats.font_size
background_color: app.formats.accept_color
on_press: app.beep()
on_release:
root.callback(root.font_path)
app.manager.back()
2 changes: 1 addition & 1 deletion rcp/components/screens/formats_screen.kv
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
Button:
size_hint_x: 0.2
text: "Test"
on_release: app.beep()
on_press: app.beep()
Slider:
size_hint_x: 0.7
min: 0
Expand Down
4 changes: 0 additions & 4 deletions rcp/components/screens/home_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ def change_mode_speed_check(self, instance):
if self.current_layout is not None:
self.bars_container.add_widget(self.current_layout)

def on_touch_down(self, touch):
self.app.beep()
return super().on_touch_down(touch)

def _keyboard_closed(self):
self._keyboard.unbind(on_key_down=self._on_keyboard_down)
self._keyboard = None
Expand Down
1 change: 1 addition & 0 deletions rcp/components/screens/setup_screen.kv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<SetupButton@Button>:
font_size: app.formats.font_size
on_press: app.beep()

<SetupScreen>:
BoxLayout:
Expand Down
Loading