Skip to content

Commit

Permalink
fix: reduce logging verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesmitty committed Aug 23, 2024
1 parent 6d5c1f7 commit 68178a5
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions firmware/charger-module/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@


def main():
# logger.setLevel(logging.INFO)
logger.setLevel(logging.DEBUG)
logger.setLevel(logging.INFO)
logger.addHandler(logging.StreamHandler())

set_enable_pin(1)
Expand Down Expand Up @@ -105,7 +104,7 @@ def main():

# No further bytes means it's a reg read request, restart loop to send response
if not data:
logger.info(f"read register: 0x{reg:02x}")
logger.debug(f"read register: 0x{reg:02x}")
reg_pointer = reg
reg_pointer_time = time.monotonic_ns()
continue
Expand All @@ -117,7 +116,7 @@ def main():
logger.error(f"invalid data length to register 0x{reg:02x}")
continue

logger.info(f"writing to reg 0x{reg:02x}: {data}")
logger.debug(f"writing to reg 0x{reg:02x}: {data}")
for i in range(count):
regs[reg + i] = data[i]
handle_reg_writes(reg, count)
Expand Down Expand Up @@ -145,7 +144,7 @@ def main():

# Return the register value
data = handle_reg_reads(reg_pointer)
logger.info(f"returning register 0x{reg_pointer:02x}: {data}")
logger.debug(f"returning register 0x{reg_pointer:02x}: {data}")
i2c_request.write(bytes([data]))

# Increment the register index to allow for multi-byte reads
Expand Down Expand Up @@ -234,7 +233,7 @@ def handle_reg_writes(first_reg, length):
changed_regs = set(range(first_reg, first_reg + length))

if not changed_regs.isdisjoint(pixel_regs):
logger.info(f"updating neopixel: {regs[PIXEL_EFFECT_REG:PIXEL_W_REG+1]}")
logger.debug(f"updating neopixel: {regs[PIXEL_EFFECT_REG:PIXEL_W_REG+1]}")
color = (regs[PIXEL_R_REG], regs[PIXEL_G_REG], regs[PIXEL_B_REG])
led.set_color(color)
led.set_pattern(regs[PIXEL_EFFECT_REG])
Expand All @@ -250,10 +249,10 @@ def set_enable_pin(value=None):
regs[ENABLE_REG] = value

if value > 0:
logger.info("enabling mpq4242")
logger.debug("enabling mpq4242")
enable_pin.value = True
else:
logger.info("disabling mpq4242")
logger.debug("disabling mpq4242")
enable_pin.value = False


Expand All @@ -271,12 +270,12 @@ def __init__(self, brightness=0.1, pixel_num=1, pin=board.GP1):
self.set_pattern(self.SOLID)

def set_color(self, new_color):
logger.info(f"Setting color to {new_color}")
logger.debug(f"Setting color to {new_color}")
self.color = new_color
self._pattern.color = new_color

def set_pattern(self, new_pattern):
logger.info(f"Setting pattern to {new_pattern}")
logger.debug(f"Setting pattern to {new_pattern}")
if new_pattern == self.pattern:
return
if new_pattern == self.SOLID:
Expand Down

0 comments on commit 68178a5

Please sign in to comment.