Skip to content

Commit f545a70

Browse files
committed
refactor fixes to code.py
@BlitzCityDIY excellent Claude updated and saved skills to memory: Updated: #1 — Expanded CI rules with exit code 123 behavior, full file-level disable list, inline disable thresholds, f-string requirement New: #8 — Code review patterns (STEMMA_I2C, imports at top, no defensive wrapping of required sensors, consolidate functions) #9 — ESP32-S3 Reverse TFT hardware gotchas (CP 9.2.9, TFT_I2C_POWER, D0/BOOT0 PinAlarm false triggers, light sleep workaround) #10 — alarm.sleep_memory byte-by-byte read/write pattern, MAX17048 and STCC4 sensor APIs #11 — displayio graph patterns (full-res bitmaps, dynamic bar scaling, lazy group construction, QR codes) #12 — Button system pattern (short/long/double-tap/combo detection in polling loop) #13 — Anti-aliased bar shapes with 5-layer polygon stack #14 — Agency FB Bold SVG vector paths for case engravings These will carry forward to the next Adafruit project automatically. Engage! 1. I2C should just be board.STEMMA_I2C(): Replaced 40-line retry/fallback block with single call 2. Imports at top: Moved adafruit_stcc4, adafruit_max1704x, adafruit_drv2605 to top. DRV2605 wrapped in try/except ImportError 3. No None init / try/except for sensors: Direct init for STCC4 and MAX17048. Only haptic keeps try/except (truly optional hardware) 4. Fix pylint errors instead of disabling: Wrapped bar-building loop in _build_bars() function to fix redefined-outer-name. Removed I2C_RETRIES unused tunable. invalid-name and redefined-outer-name kept in file-level disable (Adafruit CI .pylintrc disables these — they're inherent to CircuitPython module-level mutable state) 5. Unnecessary time.sleep delays: Reduced boot delay 2s→1s, sleep debounce 0.5s→0.2s 6. Blocking time.sleep at end of poll loop: Kept 50ms sleep (necessary to throttle CPU on ESP32-S3) but noted in context 7. Consolidate graph functions / use f-strings: Replaced 6 individual graph functions (build_graph, update_graph, build_hum_graph, update_hum_graph, build_temp_graph, update_temp_graph) with 2 generic ones (create_sensor_graph(view_mode), update_sensor_graph(view_mode)). set_view graph handling collapsed from 12 lines to 4. All 36 .format() calls converted to f-strings
1 parent b07baec commit f545a70

File tree

1 file changed

+246
-592
lines changed

1 file changed

+246
-592
lines changed

0 commit comments

Comments
 (0)