Преглед изворни кода

Update for pd-buddy-python 0.5.0

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!
Clara Hobbs пре 6 година
родитељ
комит
6f1d180bea
2 измењених фајлова са 12 додато и 5 уклоњено
  1. 1
    1
      README.md
  2. 11
    4
      pd-buddy-gtk.py

+ 1
- 1
README.md Прегледај датотеку

@@ -10,7 +10,7 @@ but older versions may work.
10 10
 * GTK+ 3.22
11 11
 * Python 3.6
12 12
 * python-gobject 3.22
13
-* pd-buddy-python 0.4.2
13
+* pd-buddy-python 0.5.0
14 14
 
15 15
 ## Usage
16 16
 

+ 11
- 4
pd-buddy-gtk.py Прегледај датотеку

@@ -196,6 +196,8 @@ class PDOListRow(Gtk.ListBoxRow):
196 196
         # Type label
197 197
         if model.pdo.pdo_type == "fixed":
198 198
             type_text = "Fixed"
199
+        elif model.pdo.pdo_type == "pps":
200
+            type_text = "Programmable"
199 201
         elif model.pdo.pdo_type == "unknown":
200 202
             type_text = "Unknown"
201 203
         elif model.pdo.pdo_type == "typec_virtual":
@@ -205,11 +207,15 @@ class PDOListRow(Gtk.ListBoxRow):
205 207
         box.pack_start(type_label, True, True, 0)
206 208
 
207 209
         # Voltage label
208
-        if (model.pdo.pdo_type != "unknown"
209
-                and model.pdo.pdo_type != "typec_virtual"):
210
+        if model.pdo.pdo_type == "fixed":
210 211
             voltage_label = Gtk.Label("{:g} V".format(model.pdo.v / 1000.0))
211 212
             voltage_label.set_halign(Gtk.Align.END)
212 213
             box.pack_start(voltage_label, True, True, 0)
214
+        elif model.pdo.pdo_type == "pps":
215
+            voltage_label = Gtk.Label("{:g}\u2013{:g} V".format(
216
+                    model.pdo.vmin / 1000.0, model.pdo.vmax / 1000.0))
217
+            voltage_label.set_halign(Gtk.Align.END)
218
+            box.pack_start(voltage_label, True, True, 0)
213 219
 
214 220
         # Right box
215 221
         right_box = Gtk.Box(Gtk.Orientation.HORIZONTAL, 6)
@@ -229,7 +235,7 @@ class PDOListRow(Gtk.ListBoxRow):
229 235
                             PDOListRow.oc_tooltips[model.pdo.peak_i])
230 236
                     right_box.pack_end(oc_image, True, False, 0)
231 237
             except AttributeError:
232
-                # If this is a typec_virtual PDO, there's no peak_i attribute.
238
+                # If this isn't a fixed PDO, there's no peak_i attribute.
233 239
                 # Not a problem, so just ignore the error.
234 240
                 pass
235 241
         else:
@@ -300,7 +306,8 @@ class Handler:
300 306
                     # do want to display no configuration though
301 307
                     self.cfg = pdbuddy.SinkConfig(
302 308
                             status=pdbuddy.SinkStatus.VALID,
303
-                            flags=pdbuddy.SinkFlags.NONE, v=0, i=0)
309
+                            flags=pdbuddy.SinkFlags.NONE, v=0, vmin=0, vmax=0,
310
+                            i=0, idim=pdbuddy.SinkDimension.CURRENT)
304 311
                 else:
305 312
                     self.cfg = pdbs.get_tmpcfg()
306 313
         except OSError as e:

Loading…
Откажи
Сачувај