The GiveBack flag now has a dedicated row with a switch, rather than a
toggle button the row labeled "Flags". That GiveBack is one of several
flags seems like an implementation detail from the high level of a GUI.
There is now a combo box to select the dimension of the current-setting
value. Changing this combo box automatically changes the value to keep
the current the same at the present voltage. The correct item is
selected when a Sink is chosen from the list, and the unit label always
updates to match the dimension.
With the new API changes in pd-buddy-python 0.5.0, a few fixes were
necessary to make the GUI work without errors again. Among these were
creating a SinkConfig object with the new attributes, and adding list
rows for PPS APDOs. Coming up next: voltage range support!
Now that the firmware is able to make requests from programmable power
supplies, it's important that the GUI allows setting arbitrary voltages.
This commit makes it do that.
When there's a single typec_virtual PDO returned by the get_source_cap
command, the GUI now handles it wonderfully. It shows the available
power and the advertised Type-C Current just like it's the regular info
from Power Delivery. There's no voltage listed in a Type-C Current row
in the Source Capabilities dialog, since it's just a maximum current,
with no voltage information.
If there are no capabilities to show, it doesn't make sense to let the
user try to open the Source Capabilities dialog. Now we don't, and we
say "None" instead of "0 W".
The new Source Capabilities dialog is done, so it's time to merge it
into master. Before now it would've been a mistake to merge it since it
would've caused a regression in functionality.
Back when there was a Save icon on the Sink page's HeaderBar, it made
sense to keep the separator around in the other pages. Now there's
never a separator there, so we shouldn't force one to exist in some
pages anymore.
Now when there's a violation of the USB PD power rules, an icon appears
to alert the user to their charger's noncompliance. The icon has a
tooltip explaining its meaning.
Assuming the power supply follows the Power Rules, it's a lot more
informative to show its PDP than the number of PDOs it advertises. This
is the first step towards implementing the new design for showing the
Source_Capabilities.
It's a simple GtkMessageDialog with the text returned by the
`get_source_cap` command. Nothing fancy, but it works great.
Great, that is, except for the bug I found in the Python library. Off
to go fix that!
To add support for the new features in firmware 1.1.0, I decided to
split the Sink screen into two sections: Configuration and Power
Delivery. The Configuration section contains all the things the Sink
screen had before, with some layout changes (notably the Save button is
part of the Configuration section, not in the HeaderBar). The Power
Delivery section has the new features: an Output switch, which works
perfectly, and a currently half-baked Source Capabilities list item
which will eventually open a window to show the capabilities, but for
now just prints them.
Since SinkConfig is a kind of tuple now, it's immutable. This means
everything that changes it has to create a new one, so the "clean"
configuration object doesn't need to be a whole copy of the original
one. This commit makes it just another pointer to the same object.
Before, we showed the contents of tmpcfg when the device had no
configuration. This caused some problems when the device was erased,
then opened in the GUI: the contents of tmpcfg were still displayed
despite the device having no configuration, which was confusing. Now
empty configuration is shown in this case.
When a device is selected from the list, its configuration is loaded
into the tmpcfg buffer. When this failed due to there being no
configuration in the device, the ensuing exception prevented the device
from being configured by the GUI.
Now we explicitly silence the KeyError when loading configuration. The
tmpcfg is still valid, so it can be read and manipulated just as always.
Since I was clever enough to implement equality testing for SinkConfig,
the Save button's visibility can now be checked with a single comparison
of two SinkConfig objects. Wonderful!
Now instead of editing configuration on the device, we keep a SinkConfig
locally and manipulate it there. Much less error-prone, and things can
still get even better than they are now.
There was a bug where a device could end up being programmed with 0
current if the device was disconnected and reconnected while editing its
configuration. I thought of several solutions for this, but concluded
that the right one would really be to go ahead with my original plan to
kick the user out of the configuration screen when the device was
unplugged. As usual, the implementation could be better, but it works.
Previously, we updated the Save button before sending the commands.
This meant that if the command failed, the save button was still updated
before the error dialog appeared, which was a bit odd. Now that's
fixed.
Before now, if an error occurred when sending a command, it passed
silently. This is a Bad Thing™, so it's been fixed. Now if there's an
error, an error dialog appears with some information about what
happened. If the error occurred on the Sink page, the program goes back
to the device list after the error dialog is closed.
Before now, the Save button appeared when the voltage and current
widgets changed their value. If they were then changed back to the
original values, the Save button was still visible, allowing unnecessary
wear on the flash. (the sarcastic horror!)
Now, the Save button is only shown when the voltage and current are not
both at their saved values. A minor tweak, but we're closer to the
original design now.
Previously, the SelectListStore directly modified the GUI in its
update_items method, which was really just poor form.
This has been corrected by creating a new SelectList to encapsulate all
the GUI elements from the select-stack downward. This handles showing
the select-none or select-frame elements as appropriate, as well as
adding the list item separators. It's much nicer than the old way, if I
do say so myself.
Previously, we refreshed the list by completely erasing it and building
a new one. While simple, it caused some obnoxious visual glitches, and
I could imagine some more serious problems it might have caused as well.
Now we remove only the devices that don't exist any more, and add only
those that we don't already know about. Much better for the user
interface, but O(n^2). Oh well, I doubt anyone will have enough PD
Buddies connected at once for that to matter much.
Previously, the device list only loaded once on startup. This was poor
behaviour, as devices can be attached and detached at any time.
Now the attached devices are polled once per second, and the list is
updated accordingly. The code behind it is a bit messy because the
list model interacts directly with parts of the GUI, but it works
pretty well nevertheless. There's no mechanism to kick us out of the
configuration screen if the device we're configuring is detached, but
this can be addressed later. For now, I'm reasonably happy with this
new feature.
It had been stretched vertically due to the two text labels stretching
the whole grid. Now the button is square, because it's set to align
center rather than fill.
It's by no means wonderful internally, but to a large extent it works.
The list functionality is still untested, since I won't be able to have
two PDB Sinks connected to my computer at once until tomorrow. But for
now, a neat little GUI.