-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eink status #719
Eink status #719
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my requests are entirely nitpicks, besides the early-return if
statement stuff I'd like to see change into an elif
structure in ctrl.py
as we talked about in person. Also tbf my eyes glaze over a little bit with the eeprom changes, but they looked fine; I also tend to trust these changes if @Lohrer had a hand in it.
Before I review this, can you confirm that:
|
amplipi/ctrl.py
Outdated
def get_state(self) -> models.Status: | ||
""" get the system state """ | ||
self._update_sys_info() | ||
self._update_serial() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it is called every get(). I realize that internally the serial number is cached so that isn't actually what happens. Why isn't this called in reinit instead? That is where we read a similar property set, the firmware versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It didn't work in reinit since other things were trying to reach the EEPROM at the same time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not true, it didn't work in reinit at first because you put it before the preamp's micro was assigned an I2C address, so it couldn't communicate. We didn't realize that until after you had already moved the serial reading to here. There's no reason you couldn't move it back, it just needs to be after the line that calls rt.Rpi()
to setup the micro/firmware.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried moving it back to reinit where the firmware version is and it stopped working on the regular sized amplipi
amplipi/display/einkdisplay.py
Outdated
|
||
SysInfo = namedtuple('SysInfo', ['hostname', 'password', 'ip']) | ||
|
||
SysInfo = namedtuple('SysInfo', ['hostname', 'password', 'ip', 'status_code', "serial_number", "ext_count"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yiou could turn the SysInfo(None, None, None...) into SysInfo() if you use this initialization:
SysInfo = namedtuple('SysInfo', ['hostname', 'password', 'ip', 'status_code', "serial_number", "ext_count"]) | |
_info_fields = ['hostname', 'password', 'ip', 'status_code', "serial_number", "ext_count"] | |
SysInfo = namedtuple('SysInfo', _info_fields, (None,) * len(_info_fields)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mypy does not like this for whatever reason
"""Read data from address in EEPROM.""" | ||
try: | ||
return self._i2c.read_i2c_block_data(self._address, address, length) | ||
if self._bus() == 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add an enumeration for the different i2c bus #'s?
amplipi/eeprom.py
Outdated
self.get_board_type(), | ||
self.get_board_rev()) | ||
|
||
# TODO: Do we need this? If so implement like the _read() function above. If not remove. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we remove this, it probably makes sense to keep this pretty comment somewhere
As discussed: In the future we may want to add a slim barcode that can be scanned to quickly link to our troubleshooting guide when there is an error. |
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #719 +/- ##
==========================================
- Coverage 50.90% 49.81% -1.10%
==========================================
Files 25 26 +1
Lines 5838 6299 +461
==========================================
+ Hits 2972 3138 +166
- Misses 2866 3161 +295
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
amplipi/display/einkdisplay.py
Outdated
return font | ||
except Exception as exc: | ||
raise Exception(f'Failed to load {self.fontname} font') from exc | ||
return ImageFont.truetype(self.fontname, 10) | ||
|
||
|
||
def get_info(iface, default_pass) -> SysInfo: | ||
def update_logs(status) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this? It looks like you're reinventing logging here. All the rest of our logs are captured by journald
(it's just capturing stdout
and stderr
, nothing fancy) and are viewable with journalctl -f
or by going to Settings->About->Logs in the AmpliPi web UI which pulls from the same journal service.
Also I tested it and the only log message I'm seeing in display-logs.json
is "Starting Up". I tried changing the status and no other statuses show in that log file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was one possible path I mentioned on day 2 as a persistent store of statuses to display. It may be vestigial now, particularly if we don't have external things reading or writing status, to this file or elsewhere - everything is simply represented as a state from the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make a lot more sense to move the log file's information to the actual logs. I'm making that change now.
One ask here would be to surface these same statuses on the TFT display; you can borrow the unit on my desk for this if you'd like. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better! One last request would be to add display-status.txt
to the .gitignore
file so that git doesn't try to track it.
I think it would be awesome in the future to define these error codes as a {Short Name, Description} instead of just a number. That way we can display the short name on the display and the description in the logs and maybe webUI?
docs/manual/EINK_ERROR_CODES.md
Outdated
@@ -0,0 +1,14 @@ | |||
# AmpliPro E-Ink Display Error Codes | |||
|
|||
The following numerical codes are displayed on the AmpliPro's E-Ink Display when the corresponding error occurs. Note that these codes do not appear on older AmpliPi/AmpliPro devices that use TFT touchscreen displays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this can be changed since it shows on all displays now? Also there are other references in this doc to just E-Ink displays that should be generalized.
The following numerical codes are displayed on the AmpliPro's E-Ink Display when the corresponding error occurs. Note that these codes do not appear on older AmpliPi/AmpliPro devices that use TFT touchscreen displays. | |
The following numerical codes are displayed on the AmpliPro's Display when the corresponding error occurs. |
amplipi/display/statusinterface.py
Outdated
@@ -0,0 +1,41 @@ | |||
#!/usr/bin/env python3 | |||
"""E-Ink Display Interface""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""E-Ink Display Interface""" | |
"""Display Status Interface""" |
Or something similar, since this shows on all displays now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two nitpicks, but otherwise heck yes 😎
|
||
import netifaces as ni | ||
|
||
from loguru import logger as log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you use logging
pls?
|
||
import netifaces as ni | ||
|
||
from loguru import logger as log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from loguru import logger as log | |
import logging as log |
BOARD_REV_RE = re.compile(r"(\d+)([A-z])") # accept lower or upper case change designator | ||
# we will uppercase later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for future reference, it's normally less than ideal to obscure git history through changes like this that only address stylistic concerns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, what do you feel this is obscuring? I suggested this change in the first place so I'd like to know for my own future reference. I felt that since we were already making changes in this area of the file, since the auto-formatter added a space on this line already, and since in the commit you can clearly see it's just a change in the comment, that it was worth fixing the typo now.
What does this change intend to accomplish?
This adds two new pieces of text to the e-ink display: Serial Number and Status. The serial number is taken off of the EEPROM. The status defaults to showing whether the AmpliPi is playing or not, but a custom status can be sent using a function as well. A numerical status is interpreted as an error code.
Checklist
./scripts/test