Skip to content

Commit f282df0

Browse files
committed
- adds tooltip to phases widget in Comparator displaying 2nd and 3rd phase bean temperatures (or RoR if ALT/Option key is pressed) limits
- reverts acaia relay-scales back to little endian supporting latest firmware versions
1 parent a1126ab commit f282df0

7 files changed

Lines changed: 169 additions & 33 deletions

File tree

src/artisanlib/acaia.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def parse_info(self, data:bytes) -> None:
355355
def decode_weight(self, payload:bytes) -> Tuple[Optional[float], bool]:
356356
try:
357357
#big_endian = (payload[5] & 0x08) == 0x08 # bit 3 of byte 5 is set if weight is in big endian
358-
big_endian = self.scale_class == SCALE_CLASS.RELAY
358+
big_endian = False # self.scale_class == SCALE_CLASS.RELAY
359359

360360
value:float = 0
361361
if big_endian:
@@ -388,10 +388,10 @@ def decode_weight(self, payload:bytes) -> Tuple[Optional[float], bool]:
388388
elif self.unit == UNIT.OZ:
389389
value = value * 28.3495 # scale set to oz displays 4 decimals
390390

391-
if self.scale_class == SCALE_CLASS.RELAY:
392-
stable = (payload[5] & 0x01) == 0x01
393-
else:
394-
stable = (payload[5] & 0x01) != 0x01
391+
# if big_endian:
392+
# stable = (payload[5] & 0x01) == 0x01
393+
# else:
394+
stable = (payload[5] & 0x01) != 0x01
395395

396396
# if 2nd bit of payload[5] is set, the reading is negative
397397
if (payload[5] & 0x02) == 0x02:
@@ -412,6 +412,7 @@ def update_weight(self, value:Optional[float], stable:Optional[bool] = False) ->
412412
# _log.debug('PRINT new stable weight: %s', self.stable_weight)
413413
self.weight_changed_signal.emit(self.stable_weight, stable)
414414
elif not stable and value_rounded != self.weight:
415+
self.stable_weight = None # non-stable weights invalidate the last stable weight to ensure a sequence of equal stable weights is reported if interleaved with non-stable weights
415416
self.weight = value_rounded
416417
# _log.debug('PRINT new weight: %s', self.weight)
417418
self.weight_changed_signal.emit(self.weight, stable)
@@ -736,11 +737,13 @@ def send_stop(self) -> None: # stop what?
736737

737738
def send_tare(self) -> None:
738739
_log.debug('send tare')
739-
if SCALE_CLASS.RELAY:
740-
self.streaming_notifications()
740+
# not needed any longer as in non-streaming mode the tare weight is always send after tare
741+
# if SCALE_CLASS.RELAY:
742+
# self.streaming_notifications()
741743
self.send_message(MSG.TARE,b'\x00')
742-
if SCALE_CLASS.RELAY:
743-
self.changes_notifications()
744+
# not needed any longer as in non-streaming mode the tare weight is always send after tare
745+
# if SCALE_CLASS.RELAY:
746+
# self.changes_notifications()
744747

745748
def send_get_settings(self) -> None:
746749
_log.debug('send get settings')
@@ -789,7 +792,7 @@ def slow_notifications(self) -> None:
789792
self.send_event(
790793
bytes([ # pairs of key/setting
791794
0, # weight id
792-
(1 if SCALE_CLASS.RELAY # 0: only weight changes are reported; 1: streaming weight changes at 1/10
795+
(0 if SCALE_CLASS.RELAY # 0: only weight changes are reported; 1: streaming weight changes at 1/10
793796
else 3), # 0, 1, 3, 5, 7, 15, 31, 63, 127 # weight argument (speed of notifications in 1/10 sec; 0: report changes in weight every 1/10)
794797
# 5 or 7 seems to be good values for this app in Artisan
795798
# 1, # battery id

src/artisanlib/comparator.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,20 +2069,40 @@ def getTopProfileVisualOrder(self) -> Optional[RoastProfile]:
20692069
return p
20702070
return None
20712071

2072-
def getPhasesData(self) -> List[Tuple[str, float, Tuple[float,float,float], bool, bool, str]]:
2073-
data :List[Tuple[str, float, Tuple[float,float,float], bool, bool, str]]= []
2072+
def getPhasesData(self) -> List[Tuple[str, float, Tuple[float,float,float], bool, bool, str,
2073+
Tuple[float,float,float], Tuple[float,float,float]]]:
2074+
data :List[Tuple[str, float, Tuple[float,float,float], bool, bool, str,
2075+
Tuple[float,float,float], Tuple[float,float,float]]]= []
20742076
profiles:List[RoastProfile] = self.getProfilesVisualOrder()
20752077
for p in reversed(profiles):
20762078
if p.visible:
2077-
start:float = p.timex[p.timeindex[0]] if p.timeindex[0] != -1 else p.timex[0]
2079+
start_idx = p.timeindex[0] if p.timeindex[0] != -1 else 0
2080+
start:float = p.timex[start_idx]
20782081
total:float = p.timex[p.timeindex[6]] - start if p.timeindex[6] != 0 else p.timex[-1]
20792082
dry:float = p.timex[p.timeindex[1]] - start if p.timeindex[1] != 0 else 0
20802083
fcs:float = p.timex[p.timeindex[2]] - start if p.timeindex[2] != 0 else 0
20812084
p1:float = dry
20822085
p3:float = total - fcs if fcs != 0 else 0
20832086
p2:float = total - p1 - p3 if p1 != 0 and p3 != 0 else 0
20842087
c:QColor = QColor.fromRgbF(*p.color) # ty:ignore[missing-argument]
2085-
data.append((p.label, total, (p1, p2, p3), p.active, p.aligned, c.name()))
2088+
t1:float = p.temp2[p.timeindex[1]] if p.timeindex[1] != 0 and len(p.temp2) > p.timeindex[1] else -1
2089+
t2:float = p.temp2[p.timeindex[2]] if p.timeindex[2] != 0 and len(p.temp2) > p.timeindex[2] else -1
2090+
t3:float = p.temp2[p.timeindex[6]] if p.timeindex[6] != 0 and len(p.temp2) > p.timeindex[6] else (p.temp2[-1] if len(p.temp2)>0 else -1)
2091+
r1:float = -1
2092+
r2:float = -1
2093+
r3:float = -1
2094+
if p.delta2 is not None:
2095+
r:Optional[float] = p.delta2[p.timeindex[1]] if p.timeindex[1] != 0 and len(p.delta2) > p.timeindex[1] else -1
2096+
if r is not None:
2097+
r1 = float(r)
2098+
r = p.delta2[p.timeindex[2]] if p.timeindex[2] != 0 and len(p.delta2) > p.timeindex[2] else -1
2099+
if r is not None:
2100+
r2 = float(r)
2101+
r = p.delta2[p.timeindex[6]] if p.timeindex[6] != 0 and len(p.delta2) > p.timeindex[6] else (p.delta2[-1] if len(p.delta2)>0 else -1)
2102+
if r is not None:
2103+
r3 = float(r)
2104+
data.append((p.label, total, (p1, p2, p3), p.active, p.aligned, c.name(),
2105+
(t1, t2, t3), (r1, r2, r3)))
20862106
return data
20872107

20882108
def getProfilesVisualOrder(self) -> List[RoastProfile]:

src/artisanlib/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,8 +1549,8 @@ class ApplicationWindow(QMainWindow): # pyright: ignore [reportGeneralTypeIssue
15491549
'mark_last_button_pressed_default', 'mark_last_button_pressed', 'show_extrabutton_tooltips_default', 'show_extrabutton_tooltips',
15501550
'buttonpalette_buttonsize', 'buttonpalette_mark_last_button_pressed', 'buttonpalette_tooltips', 'buttonpalette_slider_alternative_layout', 'eventbuttontablecolumnwidths',
15511551
'lowerbuttondialogLayout', 'lowerbuttondialog', 'lowerbuttondialogLayout', 'e1buttonbarLayout', 'e1buttondialog', 'e2buttonbarLayout', 'e2buttondialog',
1552-
'e3buttonbarLayout', 'e3buttondialog', 'e4buttonbarLayout', 'e4buttondialog','e5buttonbarLayout', 'e5buttondialog', 'e6buttonbarLayout', 'e6buttondialog',
1553-
'e7buttonbarLayout', 'e7buttondialog', 'e8buttonbarLayout', 'e8buttondialog', 'e9buttonbarLayout', 'e9buttondialog', 'e10buttonbarLayout', 'e10buttondialog',
1552+
'e3buttonbarLayout', 'e3buttondialog', 'e4buttonbarLayout', 'e4buttondialog','e5buttonbarLayout', 'e5buttondialog', 'e6buttonbarLayout', 'e6buttondialog',
1553+
'e7buttonbarLayout', 'e7buttondialog', 'e8buttonbarLayout', 'e8buttondialog', 'e9buttonbarLayout', 'e9buttondialog', 'e10buttonbarLayout', 'e10buttondialog',
15541554
'keyboardmove', 'keyboardButtonList', 'keyboardmoveindex',
15551555
'keyboardmoveflag', 'lastkeyboardcmd', 'error_dlg', 'serial_dlg', 'message_dlg', 'ETname', 'BTname', 'level1frame', 'level1layout', 'qpc', 'splitter', 'scroller', 'EventsGroupLayout',
15561556
'LCD2frame', 'LCD3frame', 'LCD4frame', 'LCD5frame', 'LCD6frame', 'LCD7frame', 'TPlabel', 'TPlcd', 'TPlcdFrame', 'TP2DRYlabel', 'TP2DRYframe',
@@ -3965,7 +3965,7 @@ def __init__(self, parent:Optional[QWidget] = None, *, locale:str, WebEngineSupp
39653965
#level 3
39663966
level3layout.addLayout(pidbuttonLayout,0)
39673967

3968-
self.qpc: tphasescanvas = tphasescanvas(self.dpi, self)
3968+
self.qpc:tphasescanvas = tphasescanvas(self.dpi, self)
39693969
self.qpc.mpl_connect('scroll_event', self.scrollingPhases)
39703970

39713971
self.scroller: QScrollArea = QScrollArea()
@@ -26106,7 +26106,7 @@ def realignbuttons(self) -> None:
2610626106
if self.extraeventsvisibility[i]:
2610726107
first_visible_idx = i
2610826108
break
26109-
26109+
2611026110
for i, eet in enumerate(self.extraeventstypes):
2611126111
# next button in this group is hidden
2611226112
next_hidden = ((i - first_visible_idx)%self.buttonlistmaxlen < self.buttonlistmaxlen -1 and # at least one more places in the group

0 commit comments

Comments
 (0)