// Howdy 👋.
//
// This is where you can create powerful part automations like resistors that tell you when too much current is flowing through them
// You can also create your own flexible parts, like generics (https://docs.flux.ai/Introduction/generic-parts)
//
// If you are new to writing code in Flux make sure to check out our get started docs: https://docs.flux.ai/reference/introduction
//
// We also have a Flux Slack Community in case you need help: https://join.slack.com/t/fluxcommunity/shared_invite/zt-2ouyf80w6-7Wp81YlNEsuDFFdED9UQMA
//
// To infinity and beyond 🚀
import schemdraw
import schemdraw.elements as elm
# Initialize the schematic
with schemdraw.Drawing() as d:
# USB - C connector
d += (usb_c:= elm.Block(size = (3, 2), label = "USB-C Receptacle"))
d += elm.Resistor().down().label("5.1kΩ").at(usb_c.center_left - (1.5, 0.5))
d += elm.Resistor().down().label("5.1kΩ").at(usb_c.center_left + (1.5, 0.5))
# ESD protection
d += (esd:= elm.Block(size = (2, 1), label = "ESD Protection\nTPD4E05U06")).right(usb_c)
d += elm.Line().right().at(esd.center_right).length(1)
# Reverse polarity protection
d += (mosfet:= elm.Block(size = (2, 1), label = "P-MOSFET\nIRF9540")).right(esd)
d += elm.Arrow().down().at(mosfet.center_bottom).label("VBUS")
# Battery charging circuit
d += (battery_ic:= elm.Block(size = (3, 2), label = "Battery Charger\nMCP73871")).down(mosfet)