digitaltrails / vdu_controls

VDU controls - a control panel for monitor brightness/contrast/...
GNU General Public License v3.0
103 stars 4 forks source link

[Bug] Error: ValueError: math domain error #83

Closed Milor123 closed 2 months ago

Milor123 commented 3 months ago

Hello brother, I'm here again. I take this opportunity to tell you that I have been very happy with the implementation of the physical sensor + VDU, it works great.

Today at the end of the afternoon something curious happened to me, suddenly my VDU threw the following error (I will leave the log at the end). It's a little strange, but I think that at the time it happened I had programmed some light mode change (in the presets), I'm not sure. However, now that I tried to open my VDU again, I still get this error.

Details: Traceback (most recent call last):
  File "/home/noe/bin/vdu_controls", line 8451, in <module>
    main()
  File "/home/noe/bin/vdu_controls", line 8373, in main
    VduAppWindow(main_config, app, main_controller)  # may need to assign this to a variable to prevent garbage collection?
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/bin/vdu_controls", line 7840, in __init__
    self.main_controller.configure_application(self)
  File "/home/noe/bin/vdu_controls", line 7247, in configure_application
    self.main_window.create_main_control_panel()
  File "/home/noe/bin/vdu_controls", line 7954, in create_main_control_panel
    if lux_manual_input := self.main_controller.lux_auto_controller.create_manual_input_control():
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/bin/vdu_controls", line 6716, in create_manual_input_control
    self.lux_slider = LuxAmbientSlider()
                      ^^^^^^^^^^^^^^^^^^
  File "/home/noe/bin/vdu_controls", line 6987, in __init__
    self.set_current_value(round(LuxMeterManualDevice.get_stored_value()))  # trigger side-effects.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/bin/vdu_controls", line 7004, in set_current_value
    self.lux_slider.setValue(round(math.log10(value) * 1000))
                                   ^^^^^^^^^^^^^^^^^
ValueError: math domain error

what should i do for fix it?

digitaltrails commented 3 months ago

It appears that value was zero or negative. That's normally what would cause math.log10() to throw a math domain error. I'll take a look at the code add a check for this.

My guess is the sensor returned a zero or a negative number and the UI tried to show it, so if that happens I should boost the value up to 1 so the slider won't error.

digitaltrails commented 3 months ago

I've checked in a fix. The code immediately above was already checking for this, but then went on to use the unchecked original value - boom!

Milor123 commented 3 months ago

I've checked in a fix. The code immediately above was already checking for this, but then went on to use the unchecked original value - boom!

Thank you very much bro !!! I've pulled and now my vdu works again !!! Thankssss 😄 ❤️