Skip to content

Commit

Permalink
Add Button effects to simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
julianschill committed May 5, 2024
1 parent abb0dc5 commit 1dcbb29
Show file tree
Hide file tree
Showing 6 changed files with 391 additions and 207 deletions.
431 changes: 235 additions & 196 deletions simulator/poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions simulator/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ readme = "README.md"

[tool.poetry.dependencies]
python = "<3.11,>=3.8"
wxPython = "^4.2.0"
pyinstaller = "^5.4.1"
wxPython = "^4.2.1"
pyinstaller = "^6.4.0"
numpy = ">1.22"

[tool.poetry.group.dev.dependencies]
Expand Down
130 changes: 127 additions & 3 deletions simulator/simgui.fbp

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion simulator/simulator/klippermock.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def load_object(self, config, o):
return self.objects[o]
elif o == "query_adc":
return self
elif o == "buttons":
return self
return None
def register_event_handler(self, event, callback):
pass
Expand All @@ -46,6 +48,8 @@ def register_command(self, cmd, callback, desc):
pass
def register_timer(self, callback, time):
pass
def register_buttons(self, pins, callback):
pass
def get_reactor(self):
return self
def register_timer(self, callback, time):
Expand Down Expand Up @@ -95,7 +99,8 @@ def __init__(self):
"stepper" : "x",
"layers" : """gradient 1 1 top (1, 0.0, 0.0),(0, 1, 0.0),(0.0, 0.0, 1)""",
"leds" : "leds:leds",
"endstops" : "x"
"endstops" : "x",
"button_pins" : "PA0"
}
def set_printer(self, printer):
self.printer=printer
Expand All @@ -111,6 +116,8 @@ def getint(self,key,default,minval,maxval):
return int(self.config[key])
def setint(self,key, value):
self.config[key] = int (value)
def getlist(self,key,default):
return list(self.config[key])
def get_name(self):
return "led_effect simulator"
def get(self, key, default=None ):
Expand Down
17 changes: 13 additions & 4 deletions simulator/simulator/simgui.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

###########################################################################
## Python code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
## Python code generated with wxFormBuilder (version 3.10.1-e2e4764)
## http://www.wxformbuilder.org/
##
## PLEASE DO *NOT* EDIT THIS FILE!
Expand Down Expand Up @@ -168,15 +168,20 @@ def __init__( self, parent ):

bHeaterStepperSizer.Add( ( 20, 0), 1, wx.EXPAND, 5 )

bEndstopSizer = wx.BoxSizer( wx.HORIZONTAL )
bEndstopSizer = wx.BoxSizer( wx.VERTICAL )

self.m_btnEndstop = wx.Button( self.m_panel41, wx.ID_ANY, u"Endstop", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_btnEndstop.SetMinSize( wx.Size( 60,-1 ) )

bEndstopSizer.Add( self.m_btnEndstop, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
bEndstopSizer.Add( self.m_btnEndstop, 0, wx.ALL, 5 )

self.m_btnButton = wx.ToggleButton( self.m_panel41, wx.ID_ANY, u"Button", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_btnButton.SetMinSize( wx.Size( 60,-1 ) )

bHeaterStepperSizer.Add( bEndstopSizer, 1, wx.EXPAND, 5 )
bEndstopSizer.Add( self.m_btnButton, 0, wx.ALL, 5 )


bHeaterStepperSizer.Add( bEndstopSizer, 1, wx.EXPAND|wx.TOP, 5 )


self.m_panel41.SetSizer( bHeaterStepperSizer )
Expand Down Expand Up @@ -390,6 +395,7 @@ def __init__( self, parent ):
self.m_slProgress.Bind( wx.EVT_SLIDER, self.OnProgressSlider )
self.m_slAnalog.Bind( wx.EVT_SLIDER, self.OnAnalogSlider )
self.m_btnEndstop.Bind( wx.EVT_BUTTON, self.OnBtnEndstopClick )
self.m_btnButton.Bind( wx.EVT_TOGGLEBUTTON, self.OnBtnButtonClick )
self.m_cbActive.Bind( wx.EVT_CHECKBOX, self.OnEffectSettingChanged )
self.m_cbEffect.Bind( wx.EVT_COMBOBOX, self.OnEffectSettingChanged )
self.m_spinEffectRate.Bind( wx.EVT_SPINCTRLDOUBLE, self.OnEffectSettingChanged )
Expand Down Expand Up @@ -456,6 +462,9 @@ def OnAnalogSlider( self, event ):
def OnBtnEndstopClick( self, event ):
event.Skip()

def OnBtnButtonClick( self, event ):
event.Skip()

def OnEffectSettingChanged( self, event ):
event.Skip()

Expand Down
7 changes: 6 additions & 1 deletion simulator/simulator/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,12 @@ def OnBtnEndstopClick(self, event):
self.printer.led_effect.handler.homing_end_flag["x"] += 1
else:
self.printer.led_effect.handler.homing_end_flag["x"] = 0


def OnBtnButtonClick( self, event ):
if self.m_btnButton.Value:
self.printer.led_effect.button_state = 1
else:
self.printer.led_effect.button_state = 0

def OnExit(self, event):
self.Close(True)
Expand Down

0 comments on commit 1dcbb29

Please sign in to comment.