Skip to content

Commit

Permalink
fix logger usage error, see #31
Browse files Browse the repository at this point in the history
  • Loading branch information
brainelectronics committed May 13, 2023
1 parent cd13e50 commit 2face41
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
7 changes: 6 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ r"^\#\# \[\d{1,}[.]\d{1,}[.]\d{1,}\] \- \d{4}\-\d{2}-\d{2}$"
-->

## Released
## [0.15.1] - 2023-05-13
### Fixed
- Logger import fixed, see #31

## [0.15.0] - 2023-05-13
### Added
- `package.json` for `mip` installation with MicroPython v1.19.1 or newer, see #27
Expand Down Expand Up @@ -215,8 +219,9 @@ r"^\#\# \[\d{1,}[.]\d{1,}[.]\d{1,}\] \- \d{4}\-\d{2}-\d{2}$"
- [Example HMI file](examples/everything.HMI) to be used for all examples

<!-- Links -->
[Unreleased]: https://github.com/brainelectronics/micropython-nextion/compare/0.15.0...develop
[Unreleased]: https://github.com/brainelectronics/micropython-nextion/compare/0.15.1...develop

[0.15.1]: https://github.com/brainelectronics/micropython-nextion/tree/0.15.1
[0.15.0]: https://github.com/brainelectronics/micropython-nextion/tree/0.15.0
[0.14.0]: https://github.com/brainelectronics/micropython-nextion/tree/0.14.0
[0.13.0]: https://github.com/brainelectronics/micropython-nextion/tree/0.13.0
Expand Down
7 changes: 4 additions & 3 deletions nextion/nextion_rtc.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ def write_rtc_time(self, *args, **kwargs) -> bool:
format("2016,11,25,12,34,50",
[2016, 11, 25, 12, 34, 50]))

self._logger.debug("Timestamp (ISO8601): {}-{}-{}T{}:{}:{}".
format(year, month, day, hour, minute, second))
self._nh._logger.debug(
"Timestamp (ISO8601): {}-{}-{}T{}:{}:{}".format(
year, month, day, hour, minute, second))

cmd = "rtc0={}".format(year)
self._nh.sendCommand(cmd)
Expand Down Expand Up @@ -121,7 +122,7 @@ def write_rtc_time(self, *args, **kwargs) -> bool:
else:
raise NexRtcError("Either use keyword or positional args")

self._logger.debug("Set '{}' to '{}'".format(time_type, time))
self._nh._logger.debug("Set '{}' to '{}'".format(time_type, time))
rtc_index = self.time_types.index(time_type.lower())

cmd = "rtc{}={}".format(rtc_index, time)
Expand Down
34 changes: 17 additions & 17 deletions nextion/nextion_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def upload(self) -> bool:
if not self._downloadTftFile():
raise NexUploadError("Download file error")

self._logger.debug("Download ok")
self._nh._logger.debug("Download ok")
return True

def _checkFile(self) -> bool:
Expand All @@ -127,13 +127,13 @@ def _checkFile(self) -> bool:
# https://docs.python.org/3/library/os.html#os.stat
info = stat(self.file_name)
self.file_size = info[6]
self._logger.debug("TFT file size is '{}' bytes".
format(self.file_size))
self._logger.debug("File check ok")
self._nh._logger.debug("TFT file size is '{}' bytes".
format(self.file_size))
self._nh._logger.debug("File check ok")
result = True
else:
self._logger.debug("File '{}' does not exist".
format(self.file_name))
self._nh._logger.debug("File '{}' does not exist".
format(self.file_name))
return result

def _getBaudrate(self) -> int:
Expand All @@ -147,13 +147,13 @@ def _getBaudrate(self) -> int:
_baudrate = 0

for baudrate in baudrate_array:
self._logger.debug("Checking connection with '{}' baud".
format(baudrate))
self._nh._logger.debug("Checking connection with '{}' baud".
format(baudrate))

if self._searchBaudrate(baudrate):
_baudrate = baudrate
self._logger.debug("Success, baudrate set to '{}' baud".
format(_baudrate))
self._nh._logger.debug("Success, baudrate set to '{}' baud".
format(_baudrate))
return _baudrate

return _baudrate
Expand All @@ -174,8 +174,8 @@ def _searchBaudrate(self, baudrate: int) -> bool:
self._nh.sendCommand("connect")
sleep(0.1) # necessary, data might not be available otherwise
response = self._recvRetString()
self._logger.debug("_searchBaudrate response for '{}' baud: {}".
format(baudrate, response))
self._nh._logger.debug("_searchBaudrate response for '{}' baud: {}".
format(baudrate, response))

if "comok" in response:
return True
Expand All @@ -193,16 +193,16 @@ def _setDownloadBaudrate(self, baudrate: int) -> bool:
:rtype: bool
"""
cmd = "whmi-wri {},{},0".format(self.file_size, baudrate)
self._logger.debug("Set download baudrate cmd: '{}'".format(cmd))
self._nh._logger.debug("Set download baudrate cmd: '{}'".format(cmd))

self._nh.sendCommand("")
self._nh.sendCommand(cmd)
sleep(0.05)
self._nh._baudrate = baudrate
self._nh._uart_init()
response = self._recvRetString(500)
self._logger.debug("Set download baudrate response: '{}'".
format(response))
self._nh._logger.debug(
"Set download baudrate response: '{}'".format(response))
if (0x05).to_bytes(1, 'little') in response:
return True
return False
Expand All @@ -222,13 +222,13 @@ def _downloadTftFile(self) -> bool:
data_size = update_file.readinto(file_content)

if not data_size:
self._logger.debug("Reached EOF, update finished")
self._nh._logger.debug("Reached EOF, update finished")
break

self._nh._uart.write(file_content)

response = self._recvRetString(500)
# self._logger.debug("File download response: '{}'".
# self._nh._logger.debug("File download response: '{}'".
# format(response))

if (0x05).to_bytes(1, 'little') in response:
Expand Down
6 changes: 3 additions & 3 deletions nextion/nextion_waveform.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def addValue(self, ch: int, number: int) -> bool:
:rtype: bool
"""
if ch > 3:
self._logger.debug("Only channels (0-3) supported by waveform")
self._nh._logger.debug("Only channels (0-3) supported by waveform")
return False

cmd = "add {},{},{}".format(self.cid, ch, number)
Expand All @@ -67,8 +67,8 @@ def clearChannel(self, ch: int) -> bool:
:rtype: bool
"""
if (ch > 3) and (ch != 255):
self._logger.debug("Only the channels (0-3) or all channels at "
"once (255) can be cleared")
self._nh._logger.debug("Only the channels (0-3) or all channels "
"at once (255) can be cleared")
return False

cmd = "cle {},{}".format(self.cid, ch)
Expand Down

0 comments on commit 2face41

Please sign in to comment.