From 9dfd2b4e727ed8eeb88cd8d5789230f37845178e Mon Sep 17 00:00:00 2001 From: logon84 Date: Fri, 29 Dec 2023 19:05:55 +0100 Subject: [PATCH] Update pySVS.py Final fix for the scales I hope --- pySVS.py | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/pySVS.py b/pySVS.py index ebcc2ce..bafdecf 100644 --- a/pySVS.py +++ b/pySVS.py @@ -62,7 +62,7 @@ "STANDBY":{"id":4, "offset":0x4, "limits": [0,1,2], "limits_type":1, "n_bytes":2, "reset_id": 2 }, #discrete "BRIGHTNESS":{"id":4, "offset":0x6, "limits": [0,1,2,3,4,5,6,7], "limits_type":1, "n_bytes":2, "reset_id": 14 }, #discrete "LOW_PASS_FILTER_ALL_SETTINGS":{"id":4, "offset":0x8, "limits": [], "limits_type":"group", "n_bytes":6, "reset_id": 3 }, #group - "LPF_ENABLE":{"id":4, "offset":0x8, "limits": [0,1], "limits_type":1, "n_bytes":2, "reset_id": 3 }, #discrete + "LOW_PASS_FILTER_ENABLE":{"id":4, "offset":0x8, "limits": [0,1], "limits_type":1, "n_bytes":2, "reset_id": 3 }, #discrete "LOW_PASS_FILTER_FREQ":{"id":4, "offset":0xa, "limits": [30, 200], "limits_type":0, "n_bytes":2, "reset_id": 3 }, #continous "LOW_PASS_FILTER_SLOPE":{"id":4, "offset":0xc,"limits": [6, 12, 18, 24], "limits_type":1, "n_bytes":2, "reset_id": 3 }, #discrete "PEQ1_ALL_SETTINGS":{"id":4, "offset":0xe,"limits": [], "limits_type":"group", "n_bytes":8, "reset_id": 5 }, #group @@ -386,7 +386,7 @@ def autoon_combo_changed(self): def lpf_opt_changed(): refresh_widgets() - TX.BUFFER += svs_encode("MEMWRITE","LPF_ENABLE", int(lpf_var.get())) + TX.BUFFER += svs_encode("MEMWRITE","LOW_PASS_FILTER_ENABLE", int(lpf_var.get())) def update_lpfilter_freq(self): if lpf_var.get(): @@ -448,9 +448,27 @@ def room_gain_opt_changed(): refresh_widgets() TX.BUFFER += svs_encode("MEMWRITE","ROOM_GAIN_ENABLE", int(room_gain_var.get())) -def update_room_gain_freq(self): +def update_room_gain_freq(event): if room_gain_var.get(): #as this callback is called when the click is released, be sure only to send svs memwrite only if room_gain = on + current_index = SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"].index(room_gain_slider.get()) + if event.type == "5": #Button1Release + res = (max(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"]) - min(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"]))/room_gain_slider.cget("length") + click_release_value = min(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"]) + res * event.x + if abs(room_gain_slider.get() - click_release_value) > 3: + #going here means we weren't dragging the slider but clicked the scale to move the slider to a new position + if click_release_value > room_gain_slider.get(): + next_index = (current_index + 1) if current_index < (len(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"]) - 1) else len(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"]) - 1 + room_gain_slider.set(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"][next_index]) + else: + next_index = (current_index - 1) if current_index > 0 else 0 + room_gain_slider.set(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"][next_index]) + elif event.keysym == 'Right': #KeyRelease + next_index = (current_index + 1) if current_index < (len(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"]) - 1) else len(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"]) - 1 + room_gain_slider.set(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"][next_index]) + elif event.keysym == 'Left': #KeyRelease + next_index = (current_index - 1) if current_index > 0 else 0 + room_gain_slider.set(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"][next_index]) TX.BUFFER += svs_encode("MEMWRITE","ROOM_GAIN_FREQ", room_gain_slider.get()) def update_room_gain_slope(self): @@ -504,7 +522,7 @@ def refresh_widgets(values_dict={}): for key in values_dict.keys(): if key == "STANDBY": autoon_combo.current(int(values_dict[key])) - elif key == "LPF_ENABLE": + elif key == "LOW_PASS_FILTER_ENABLE": lpf_var.set(bool(values_dict[key])) elif key == "LOW_PASS_FILTER_FREQ": lpfilter_slider.configure(state='normal') @@ -640,7 +658,7 @@ def show_usage(): return if __name__ == "__main__": - VERSION = "v3.32 Beta" + VERSION = "v3.4 Beta" dev="hci0" if len(sys.argv[1:]) > 0: GUI = 0 @@ -678,7 +696,7 @@ def show_usage(): built_frames += svs_encode("SUB_INFO3", "") elif opt in ("-l", "--lpf"): if len(opt_val.split("@")) == 3: - sub_params = ["LPF_ENABLE","LOW_PASS_FILTER_FREQ","LOW_PASS_FILTER_SLOPE"] + sub_params = ["LOW_PASS_FILTER_ENABLE","LOW_PASS_FILTER_FREQ","LOW_PASS_FILTER_SLOPE"] for i in range(0,3): if len(opt_val.split("@")[i]) > 0: built_frames += svs_encode("MEMREAD", sub_params[i]) if opt_val.split("@")[i].upper() == 'A' else svs_encode("MEMWRITE", sub_params[i], int(float(opt_val.split("@")[i]))) @@ -773,18 +791,21 @@ def show_usage(): vol_slider = tk.Scale(tab1, from_=min(SVS_PARAMS["VOLUME"]["limits"]), to=max(SVS_PARAMS["VOLUME"]["limits"]), label = "Volume (dB)", orient=tk.HORIZONTAL, resolution=1 if type(SVS_PARAMS["PHASE"]["limits"][0]) == int else 0.1, length=200, takefocus=1) vol_slider.grid(column=4, row=3, padx = 20, pady = 15) vol_slider.bind("", update_vol) + vol_slider.bind("", update_vol) vol_slider.bind("", update_vol) vol_slider.bind("", update_vol) phase_slider = tk.Scale(tab1, from_=min(SVS_PARAMS["PHASE"]["limits"]), to=max(SVS_PARAMS["PHASE"]["limits"]), label = "Phase (°)", orient=tk.HORIZONTAL, resolution=1 if type(SVS_PARAMS["PHASE"]["limits"][0]) == int else 0.1, length=200, takefocus=1) phase_slider.grid(column=4, row=5, padx = 20, pady = 15) phase_slider.bind("", update_phase) + phase_slider.bind("", update_phase) phase_slider.bind("", update_phase) phase_slider.bind("", update_phase) lpfilter_slider = tk.Scale(tab1, from_=min(SVS_PARAMS["LOW_PASS_FILTER_FREQ"]["limits"]), to=max(SVS_PARAMS["LOW_PASS_FILTER_FREQ"]["limits"]), label = "Low Pass Filter Freq. (Hz)", orient=tk.HORIZONTAL, resolution=1 if type(SVS_PARAMS["LOW_PASS_FILTER_FREQ"]["limits"][0]) == int else 0.1, length=200, takefocus=1) lpfilter_slider.grid(column=4, row=7, padx = 20, pady = 15) lpfilter_slider.bind("", update_lpfilter_freq) + lpfilter_slider.bind("", update_lpfilter_freq) lpfilter_slider.bind("", update_lpfilter_freq) lpfilter_slider.bind("", update_lpfilter_freq) lpfilter_slope_combo=ttk.Combobox(tab1,values=[str(l) + " dB" for l in SVS_PARAMS["LOW_PASS_FILTER_SLOPE"]["limits"]],width=7,state='readonly') @@ -796,6 +817,7 @@ def show_usage(): room_gain_slider = tk.Scale(tab1, from_=min(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"]), to=max(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"]), label = "Room Gain Freq. (Hz)", orient=tk.HORIZONTAL, resolution=1 if type(SVS_PARAMS["ROOM_GAIN_FREQ"]["limits"][0]) == int else 0.1, length=200, takefocus=1, command=make_room_gain_freq_discrete_slider) room_gain_slider.bind("", update_room_gain_freq) + room_gain_slider.bind("", update_room_gain_freq) room_gain_slider.bind("", update_room_gain_freq) room_gain_slider.bind("", update_room_gain_freq) room_gain_slider.grid(column=4, row=9, padx = 20, pady = 15) @@ -820,16 +842,19 @@ def show_usage(): PEQ1_checkbox.place(x=40,y=15) PEQ1_freq_slider = tk.Scale(tab2, from_=min(SVS_PARAMS["PEQ1_FREQ"]["limits"]), to=max(SVS_PARAMS["PEQ1_FREQ"]["limits"]), label = "Freq (Hz)", orient=tk.HORIZONTAL, resolution=1 if type(SVS_PARAMS["PEQ1_FREQ"]["limits"][0]) == int else 0.1, length=100, takefocus=1) PEQ1_freq_slider.bind("", update_peq1_freq) + PEQ1_freq_slider.bind("", update_peq1_freq) PEQ1_freq_slider.bind("", update_peq1_freq) PEQ1_freq_slider.bind("", update_peq1_freq) PEQ1_freq_slider.grid(column=7, row=3, padx = 35, pady = 35) PEQ1_boost_slider = tk.Scale(tab2, from_=min(SVS_PARAMS["PEQ1_BOOST"]["limits"]), to=max(SVS_PARAMS["PEQ1_BOOST"]["limits"]), label = "Boost (dB)", orient=tk.HORIZONTAL, resolution=1 if type(SVS_PARAMS["PEQ1_BOOST"]["limits"][0]) == int else 0.1, length=100, takefocus=1) PEQ1_boost_slider.bind("", update_peq1_boost) + PEQ1_boost_slider.bind("", update_peq1_boost) PEQ1_boost_slider.bind("", update_peq1_boost) PEQ1_boost_slider.bind("", update_peq1_boost) PEQ1_boost_slider.grid(column=7, row=5, padx = 20, pady = 15) PEQ1_qfactor_slider = tk.Scale(tab2, from_=min(SVS_PARAMS["PEQ1_QFACTOR"]["limits"]), to=max(SVS_PARAMS["PEQ1_QFACTOR"]["limits"]), label = "Q-Factor", orient=tk.HORIZONTAL, resolution=1 if type(SVS_PARAMS["PEQ1_QFACTOR"]["limits"][0]) == int else 0.1, length=100, takefocus=1) PEQ1_qfactor_slider.bind("", update_peq1_qfactor) + PEQ1_qfactor_slider.bind("", update_peq1_qfactor) PEQ1_qfactor_slider.bind("", update_peq1_qfactor) PEQ1_qfactor_slider.bind("", update_peq1_qfactor) PEQ1_qfactor_slider.grid(column=7, row=7, padx = 20, pady = 35) @@ -839,16 +864,19 @@ def show_usage(): PEQ2_checkbox.place(x=215,y=15) PEQ2_freq_slider = tk.Scale(tab2, from_=min(SVS_PARAMS["PEQ2_FREQ"]["limits"]), to=max(SVS_PARAMS["PEQ2_FREQ"]["limits"]), label = "Freq (Hz)", orient=tk.HORIZONTAL, resolution=1 if type(SVS_PARAMS["PEQ2_FREQ"]["limits"][0]) == int else 0.1, length=100, takefocus=1) PEQ2_freq_slider.bind("", update_peq2_freq) + PEQ2_freq_slider.bind("", update_peq2_freq) PEQ2_freq_slider.bind("", update_peq2_freq) PEQ2_freq_slider.bind("", update_peq2_freq) PEQ2_freq_slider.grid(column=8, row=3, padx = 35, pady = 35) PEQ2_boost_slider = tk.Scale(tab2, from_=min(SVS_PARAMS["PEQ2_BOOST"]["limits"]), to=max(SVS_PARAMS["PEQ2_BOOST"]["limits"]), label = "Boost (dB)", orient=tk.HORIZONTAL, resolution=1 if type(SVS_PARAMS["PEQ2_BOOST"]["limits"][0]) == int else 0.1, length=100, takefocus=1) PEQ2_boost_slider.bind("", update_peq2_boost) + PEQ2_boost_slider.bind("", update_peq2_boost) PEQ2_boost_slider.bind("", update_peq2_boost) PEQ2_boost_slider.bind("", update_peq2_boost) PEQ2_boost_slider.grid(column=8, row=5, padx = 20, pady = 15) PEQ2_qfactor_slider = tk.Scale(tab2, from_=min(SVS_PARAMS["PEQ2_QFACTOR"]["limits"]), to=max(SVS_PARAMS["PEQ2_QFACTOR"]["limits"]), label = "Q-Factor", orient=tk.HORIZONTAL, resolution=1 if type(SVS_PARAMS["PEQ2_QFACTOR"]["limits"][0]) == int else 0.1, length=100, takefocus=1) PEQ2_qfactor_slider.bind("", update_peq2_qfactor) + PEQ2_qfactor_slider.bind("", update_peq2_qfactor) PEQ2_qfactor_slider.bind("", update_peq2_qfactor) PEQ2_qfactor_slider.bind("", update_peq2_qfactor) PEQ2_qfactor_slider.grid(column=8, row=7, padx = 20, pady = 35) @@ -858,16 +886,19 @@ def show_usage(): PEQ3_checkbox.place(x=390,y=15) PEQ3_freq_slider = tk.Scale(tab2, from_=min(SVS_PARAMS["PEQ3_FREQ"]["limits"]), to=max(SVS_PARAMS["PEQ3_FREQ"]["limits"]), label = "Freq (Hz)", orient=tk.HORIZONTAL, resolution=1 if type(SVS_PARAMS["PEQ3_FREQ"]["limits"][0]) == int else 0.1, length=100, takefocus=1) PEQ3_freq_slider.bind("", update_peq3_freq) + PEQ3_freq_slider.bind("", update_peq3_freq) PEQ3_freq_slider.bind("", update_peq3_freq) PEQ3_freq_slider.bind("", update_peq3_freq) PEQ3_freq_slider.grid(column=9, row=3, padx = 35, pady = 35) PEQ3_boost_slider = tk.Scale(tab2, from_=min(SVS_PARAMS["PEQ3_BOOST"]["limits"]), to=max(SVS_PARAMS["PEQ3_BOOST"]["limits"]), label = "Boost (dB)", orient=tk.HORIZONTAL, resolution=1 if type(SVS_PARAMS["PEQ3_BOOST"]["limits"][0]) == int else 0.1, length=100, takefocus=1) PEQ3_boost_slider.bind("", update_peq3_boost) + PEQ3_boost_slider.bind("", update_peq3_boost) PEQ3_boost_slider.bind("", update_peq3_boost) PEQ3_boost_slider.bind("", update_peq3_boost) PEQ3_boost_slider.grid(column=9, row=5, padx = 20, pady = 15) PEQ3_qfactor_slider = tk.Scale(tab2, from_=min(SVS_PARAMS["PEQ3_QFACTOR"]["limits"]), to=max(SVS_PARAMS["PEQ3_QFACTOR"]["limits"]), label = "Q-Factor", orient=tk.HORIZONTAL, resolution=1 if type(SVS_PARAMS["PEQ3_QFACTOR"]["limits"][0]) == int else 0.1, length=100, takefocus=1) PEQ3_qfactor_slider.bind("", update_peq3_qfactor) + PEQ3_qfactor_slider.bind("", update_peq3_qfactor) PEQ3_qfactor_slider.bind("", update_peq3_qfactor) PEQ3_qfactor_slider.bind("", update_peq3_qfactor) PEQ3_qfactor_slider.grid(column=9, row=7, padx = 20, pady = 35)