Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/create wheel page #89

Open
wants to merge 11 commits into
base: development
Choose a base branch
from
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### Changes this version:
- Added TMC debug openloop test mode

### Changes in 1.15.x:
- Added permanent inertia and friction effect sliders
- Added position save toggle for ODrive
1 change: 1 addition & 0 deletions base_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, parent: PyQt6.QtWidgets.QWidget = None, ui_form: str = ""):
self.tech_log = logging.getLogger(ui_form)
if ui_form:
PyQt6.uic.loadUi(helper.res_path(ui_form), self)
# print(f"UI file loaded : {ui_form}")

def init_ui(self):
"""Prototype of init_ui to manage this status in subclass."""
Expand Down
8 changes: 5 additions & 3 deletions encoderconf_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def onshown(self):
def apply(self):
val = self.spinBox_cpr.value()
self.send_value("localenc","cpr",val=val)
self.send_value("localenc","index",val = 1 if self.checkBox_index.checkState() else 0)
self.send_value("localenc","index",val = 1 if self.checkBox_index.isChecked() else 0)


class MtEncoderConf(EncoderOption,CommunicationHandler):
Expand Down Expand Up @@ -144,20 +144,22 @@ def initUI(self):
layout = QFormLayout()
layout.setContentsMargins(0,0,0,0)

self.spinBox_cs = QSpinBox()
self.spinBox_cs.setRange(1,3)
self.checkBox_direction = QCheckBox("Reverse direction (default)")
self.spinBox_bits = QSpinBox()
self.spinBox_bits.setRange(1,32)
layout.addWidget(QLabel("SPI3 extension port"))
layout.addRow(QLabel("Bits"),self.spinBox_bits)
layout.addWidget(self.checkBox_direction)
layout.addWidget(QLabel("Port is used exclusively!"))
self.setLayout(layout)

def onshown(self):
self.get_value_async("bissenc","bits",self.spinBox_bits.setValue,0,int)
self.get_value_async("bissenc","dir",self.checkBox_direction.setChecked,0,int)

def apply(self):
self.send_value("bissenc","bits",val=self.spinBox_bits.value())
self.send_value("bissenc","dir",val= 1 if self.checkBox_direction.isChecked() else 0)

class SsiEncoderConf(EncoderOption,CommunicationHandler):
def __init__(self,parent,main):
Expand Down
40 changes: 19 additions & 21 deletions ffb_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PyQt6.QtWidgets import QWidget,QToolButton
from PyQt6.QtWidgets import QMessageBox,QVBoxLayout,QCheckBox,QButtonGroup,QGridLayout,QSpinBox
from PyQt6 import uic
from helper import res_path,classlistToIds,splitListReply,throttle
from helper import res_path,classlistToIds,splitListReply,throttle,qtBlockAndCall
from PyQt6.QtCore import QTimer,QEvent, pyqtSignal
import main
import buttonconf_ui
Expand Down Expand Up @@ -130,9 +130,7 @@ def init_ui(self):

self.send_command("main","lsain",0,'?') # get analog types
self.send_command("main","aintypes",0,'?') # get active analog


self.updateSliders()

self.send_command("main","hidsendspd",0,'!') # get speed

except:
Expand All @@ -141,12 +139,12 @@ def init_ui(self):
return True

# Tab is currently shown
# def showEvent(self,event):
# self.timer.start(500)
def showEvent(self,event):
self.updateSliders()

# # Tab is hidden
# def hideEvent(self,event):
# self.timer.stop()
# Tab is hidden
def hideEvent(self,event):
pass

def startTimer(self):
self.timer.start(500)
Expand Down Expand Up @@ -177,11 +175,17 @@ def updateTimer(self):
def sliderChangedUpdateSpinbox(self,val,spinbox,factor,command=None):
newVal = val * factor
if(spinbox.value != newVal):
spinbox.blockSignals(True)
spinbox.setValue(newVal)
spinbox.blockSignals(False)
qtBlockAndCall(spinbox, spinbox.setValue,newVal)
if(command):
self.send_value("fx",command,val)

def refresh_limit(self, slider : QSlider) :
if slider == self.horizontalSlider_damper :
self.display_speed_cutoff_damper(slider.value())
elif slider == self.horizontalSlider_friction :
self.display_speed_cutoff_friction(slider.value())
elif slider == self.horizontalSlider_inertia :
self.display_accel_cutoff_inertia(slider.value())

def display_speed_cutoff_damper(self, gain):
"""Update the max rpm speed cutoff"""
Expand All @@ -204,10 +208,10 @@ def display_accel_cutoff_inertia(self, gain):
max_accel = 32767 / inertia_accel
self.label_accel.setText(f"{max_accel:.0f}")

def updateSpinboxAndSlider(self,val,spinbox : QSlider,slider,factor):
slider.setValue(val)
def updateSpinboxAndSlider(self,val,spinbox,slider : QSlider,factor):
qtBlockAndCall(slider, slider.setValue, val)
self.sliderChangedUpdateSpinbox(val,spinbox,factor)

self.refresh_limit(slider)

def hidreportrate_cb(self,modes):
self.comboBox_reportrate.blockSignals(True)
Expand Down Expand Up @@ -358,12 +362,6 @@ def cffilter_changed(self,v,send=True):
self.doubleSpinBox_CFq.setEnabled(qOn)
self.label_cffilter.setText(lbl)

def extract_scaler(self, gain_default, repl) :
infos = {key:value for (key,value) in [entry.split(":") for entry in repl.split(",")]}
if "scale" in infos:
gain_default = float(infos["scale"]) if float(infos["scale"]) > 0 else gain_default
return gain_default

def updateGainScaler(self,slider : QSlider,spinbox : QSpinBox, gain):
spinbox.setMaximum(gain)
self.sliderChangedUpdateSpinbox(slider.value(),spinbox,gain)
Expand Down
Loading
Loading