mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 12:24:58 +10:00
Update NRF24L01Transceiver.java
This commit is contained in:
+106
-59
@@ -32,11 +32,8 @@ import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import org.diylc.awt.StringUtils;
|
||||
import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractMakerBoard;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -60,14 +57,17 @@ public class NRF24L01Transceiver extends AbstractMakerBoard {
|
||||
|
||||
public static Color NRF_PCB = Color.decode("#111111");
|
||||
public static Color ANTENNA_GOLD = Color.decode("#D4AC0D");
|
||||
public static Color CRYSTAL_BODY = Color.decode("#BDC3C7");
|
||||
public static Color CRYSTAL_BORDER = Color.decode("#7F8C8D");
|
||||
public static Color HEADER_SHROUD = Color.decode("#1C1C1C");
|
||||
public static Color HEADER_BORDER = Color.decode("#333333");
|
||||
public static Color CRYSTAL_BODY = Color.decode("#85929E");
|
||||
public static Color CRYSTAL_BORDER = Color.decode("#BDC3C7");
|
||||
public static Color SILK_LINE_COLOR = Color.WHITE;
|
||||
|
||||
public static Size BOARD_WIDTH = new Size(29.0d, SizeUnit.mm);
|
||||
public static Size BOARD_HEIGHT = new Size(15.2d, SizeUnit.mm);
|
||||
|
||||
// Pin offsets: pins start right at the top-left edge
|
||||
private static final double LEFT_PIN_OFFSET_X = 14.0;
|
||||
private static final double TOP_PIN_OFFSET_Y = 14.0;
|
||||
|
||||
private static final String[] PIN_NAMES = {"GND", "VCC", "CE", "CSN", "SCK", "MOSI", "MISO", "IRQ"};
|
||||
|
||||
public NRF24L01Transceiver() {
|
||||
@@ -89,7 +89,7 @@ public class NRF24L01Transceiver extends AbstractMakerBoard {
|
||||
Point2D firstPoint = controlPoints[0];
|
||||
double spacing = PIN_SPACING.convertToPixels();
|
||||
|
||||
// 4x2 Header (8 pins) — 4 rows, 2 columns:
|
||||
// 4x2 Header (8 pins) — 4 rows, 2 columns positioned directly on top-left edge:
|
||||
// Row 0: 0 = GND, 1 = VCC (3.3V)
|
||||
// Row 1: 2 = CE, 3 = CSN
|
||||
// Row 2: 4 = SCK, 5 = MOSI
|
||||
@@ -115,9 +115,8 @@ public class NRF24L01Transceiver extends AbstractMakerBoard {
|
||||
double y = p0.getY();
|
||||
double boardW = BOARD_WIDTH.convertToPixels();
|
||||
double boardH = BOARD_HEIGHT.convertToPixels();
|
||||
double spacing = PIN_SPACING.convertToPixels();
|
||||
double boardX = x - 15;
|
||||
double boardY = y - (boardH - 3 * spacing) / 2.0;
|
||||
double boardX = x - LEFT_PIN_OFFSET_X;
|
||||
double boardY = y - TOP_PIN_OFFSET_Y;
|
||||
return new RoundRectangle2D.Double(boardX, boardY, boardW, boardH, 4, 4);
|
||||
}
|
||||
|
||||
@@ -140,8 +139,8 @@ public class NRF24L01Transceiver extends AbstractMakerBoard {
|
||||
double spacing = PIN_SPACING.convertToPixels();
|
||||
double boardW = BOARD_WIDTH.convertToPixels();
|
||||
double boardH = BOARD_HEIGHT.convertToPixels();
|
||||
double boardX = x - 15;
|
||||
double boardY = y - (boardH - 3 * spacing) / 2.0;
|
||||
double boardX = x - LEFT_PIN_OFFSET_X;
|
||||
double boardY = y - TOP_PIN_OFFSET_Y;
|
||||
|
||||
Shape boardShape = getBodyShape();
|
||||
|
||||
@@ -157,58 +156,105 @@ public class NRF24L01Transceiver extends AbstractMakerBoard {
|
||||
g2d.draw(boardShape);
|
||||
|
||||
if (!outlineMode) {
|
||||
// Serpentine PCB Trace Antenna (right side, extending beyond board)
|
||||
g2d.setColor(ANTENNA_GOLD);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2.0f));
|
||||
Path2D antenna = new Path2D.Double();
|
||||
double ax = boardX + boardW - 50;
|
||||
double ay = boardY + 12;
|
||||
antenna.moveTo(ax, ay);
|
||||
antenna.lineTo(ax + 35, ay);
|
||||
antenna.lineTo(ax + 35, ay + 16);
|
||||
antenna.lineTo(ax + 8, ay + 16);
|
||||
antenna.lineTo(ax + 8, ay + 32);
|
||||
antenna.lineTo(ax + 35, ay + 32);
|
||||
antenna.lineTo(ax + 35, ay + 48);
|
||||
antenna.lineTo(ax + 8, ay + 48);
|
||||
antenna.lineTo(ax + 8, ay + 64);
|
||||
antenna.lineTo(ax + 35, ay + 64);
|
||||
g2d.draw(antenna);
|
||||
// 2x4 Header silkscreen box on top-left edge
|
||||
g2d.setColor(SILK_LINE_COLOR);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1.2f));
|
||||
g2d.draw(new Rectangle2D.Double(boardX + 4.0, boardY + 4.0, spacing * 2 + 3.0, spacing * 4 + 3.0));
|
||||
// Pin 1 square marker around top-left pin
|
||||
g2d.draw(new Rectangle2D.Double(boardX + 4.0, boardY + 4.0, spacing + 1.0, spacing + 1.0));
|
||||
|
||||
// NRF24L01+ QFN IC (Center)
|
||||
drawChip(g2d, boardX + 50, boardY + boardH / 2.0 - 18, 30, 36, "NRF");
|
||||
// NRF24L01+ QFN-20 IC (Center Upper)
|
||||
double icX = boardX + 88.0;
|
||||
double icY = boardY + 20.0;
|
||||
double icSize = 32.0;
|
||||
drawChip(g2d, icX, icY, icSize, icSize, "nRF24");
|
||||
|
||||
// 16.000 MHz Crystal (Silver can)
|
||||
// White corner silkscreen brackets around IC
|
||||
g2d.setColor(SILK_LINE_COLOR);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1.2f));
|
||||
// Top-left bracket
|
||||
g2d.drawLine((int) (icX - 3), (int) (icY + 4), (int) (icX - 3), (int) (icY - 3));
|
||||
g2d.drawLine((int) (icX - 3), (int) (icY - 3), (int) (icX + 4), (int) (icY - 3));
|
||||
// Top-right bracket
|
||||
g2d.drawLine((int) (icX + icSize - 4), (int) (icY - 3), (int) (icX + icSize + 3), (int) (icY - 3));
|
||||
g2d.drawLine((int) (icX + icSize + 3), (int) (icY - 3), (int) (icX + icSize + 3), (int) (icY + 4));
|
||||
// Bottom-left bracket
|
||||
g2d.drawLine((int) (icX - 3), (int) (icY + icSize - 4), (int) (icX - 3), (int) (icY + icSize + 3));
|
||||
g2d.drawLine((int) (icX - 3), (int) (icY + icSize + 3), (int) (icX + 4), (int) (icY + icSize + 3));
|
||||
// Bottom-right bracket
|
||||
g2d.drawLine((int) (icX + icSize - 4), (int) (icY + icSize + 3), (int) (icX + icSize + 3), (int) (icY + icSize + 3));
|
||||
g2d.drawLine((int) (icX + icSize + 3), (int) (icY + icSize + 3), (int) (icX + icSize + 3), (int) (icY + icSize - 4));
|
||||
|
||||
// 16.000 MHz Metal Can Crystal (Bottom Center)
|
||||
double xtalW = 74.0;
|
||||
double xtalH = 24.0;
|
||||
double xtalX = boardX + 68.0;
|
||||
double xtalY = boardY + boardH - 30.0;
|
||||
RoundRectangle2D xtal = new RoundRectangle2D.Double(xtalX, xtalY, xtalW, xtalH, 12, 12);
|
||||
g2d.setColor(CRYSTAL_BODY);
|
||||
g2d.fill(new RoundRectangle2D.Double(boardX + 88, boardY + boardH / 2.0 - 10, 22, 20, 4, 4));
|
||||
g2d.fill(xtal);
|
||||
g2d.setColor(CRYSTAL_BORDER);
|
||||
g2d.draw(new RoundRectangle2D.Double(boardX + 88, boardY + boardH / 2.0 - 10, 22, 20, 4, 4));
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1.5f));
|
||||
g2d.draw(xtal);
|
||||
|
||||
// 2x4 Header Body (Black Shroud) — now 2-wide × 4-tall
|
||||
g2d.setColor(HEADER_SHROUD);
|
||||
g2d.fill(new RoundRectangle2D.Double(x - 6, y - 6, spacing + 12, spacing * 3 + 12, 3, 3));
|
||||
g2d.setColor(HEADER_BORDER);
|
||||
g2d.draw(new RoundRectangle2D.Double(x - 6, y - 6, spacing + 12, spacing * 3 + 12, 3, 3));
|
||||
// Exact 2.4GHz MIFA (Meandered Inverted-F Antenna) trace on right side
|
||||
double antLeftX = boardX + 150.0;
|
||||
double stubX = boardX + 164.0;
|
||||
double rightX = boardX + boardW - 6.0;
|
||||
double meanderLeftX = stubX + 12.0;
|
||||
double topY = boardY + 10.0;
|
||||
double bottomY = boardY + boardH - 10.0;
|
||||
double feedY = topY + 16.0;
|
||||
double stubBottomY = bottomY - 12.0;
|
||||
|
||||
// Silk Screen Pin Labels
|
||||
g2d.setColor(Color.WHITE);
|
||||
g2d.setFont(SILK_FONT_SMALL);
|
||||
for (int row = 0; row < 4; row++) {
|
||||
StringUtils.drawCenteredText(g2d, PIN_NAMES[row * 2], x - 12, y + row * spacing,
|
||||
HorizontalAlignment.RIGHT, VerticalAlignment.CENTER);
|
||||
StringUtils.drawCenteredText(g2d, PIN_NAMES[row * 2 + 1], x + spacing + 12, y + row * spacing,
|
||||
HorizontalAlignment.LEFT, VerticalAlignment.CENTER);
|
||||
}
|
||||
g2d.setColor(ANTENNA_GOLD);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(3.5f));
|
||||
|
||||
// Board label
|
||||
g2d.setFont(SILK_FONT);
|
||||
StringUtils.drawCenteredText(g2d, "NRF24L01+", boardX + boardW / 2.0, boardY + 12,
|
||||
HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||
Path2D mifa = new Path2D.Double();
|
||||
|
||||
// Continuous Meander Track:
|
||||
// Starts at stubX, topY -> goes across top rail to right edge
|
||||
mifa.moveTo(stubX, topY);
|
||||
mifa.lineTo(rightX, topY);
|
||||
|
||||
// Meander Loop 1
|
||||
mifa.lineTo(rightX, topY + 14.0);
|
||||
mifa.lineTo(meanderLeftX, topY + 14.0);
|
||||
mifa.lineTo(meanderLeftX, topY + 28.0);
|
||||
mifa.lineTo(rightX, topY + 28.0);
|
||||
|
||||
// Meander Loop 2
|
||||
mifa.lineTo(rightX, topY + 42.0);
|
||||
mifa.lineTo(meanderLeftX, topY + 42.0);
|
||||
mifa.lineTo(meanderLeftX, topY + 56.0);
|
||||
mifa.lineTo(rightX, topY + 56.0);
|
||||
|
||||
// Meander Loop 3
|
||||
mifa.lineTo(rightX, topY + 70.0);
|
||||
mifa.lineTo(meanderLeftX, topY + 70.0);
|
||||
mifa.lineTo(meanderLeftX, topY + 84.0);
|
||||
mifa.lineTo(rightX, topY + 84.0);
|
||||
|
||||
// Final drop to bottom-right corner
|
||||
mifa.lineTo(rightX, bottomY);
|
||||
|
||||
// Horizontal RF Feed line (from RF network into the vertical stub)
|
||||
mifa.moveTo(antLeftX, feedY);
|
||||
mifa.lineTo(stubX, feedY);
|
||||
|
||||
// Left Vertical Ground Shunt Stub (runs from top rail down past feed line)
|
||||
mifa.moveTo(stubX, topY);
|
||||
mifa.lineTo(stubX, stubBottomY);
|
||||
|
||||
g2d.draw(mifa);
|
||||
|
||||
// Small gold ground via dot near bottom-right
|
||||
g2d.fill(new Ellipse2D.Double(stubX + 20.0, bottomY - 6.0, 3.5, 3.5));
|
||||
}
|
||||
|
||||
g2d.setTransform(oldTx);
|
||||
|
||||
// Draw 8 header pins
|
||||
// Draw 8 header pins on top-left edge
|
||||
drawPins(g2d, 0, controlPoints.length, false, outlineMode, drawingObserver);
|
||||
|
||||
g2d.setComposite(oldComposite);
|
||||
@@ -219,10 +265,11 @@ public class NRF24L01Transceiver extends AbstractMakerBoard {
|
||||
g2d.setColor(NRF_PCB);
|
||||
g2d.fill(new RoundRectangle2D.Double(2, 4, width - 4, height - 8, 3, 3));
|
||||
g2d.setColor(ANTENNA_GOLD);
|
||||
g2d.drawLine(4, 8, 12, 8);
|
||||
g2d.drawLine(12, 8, 12, 14);
|
||||
g2d.drawLine(12, 14, 4, 14);
|
||||
g2d.setColor(Color.GRAY);
|
||||
g2d.fillRect(width - 12, height / 2 - 4, 8, 8);
|
||||
g2d.drawLine(width - 6, 8, width - 6, height - 8);
|
||||
g2d.drawLine(width - 6, 8, width - 12, 8);
|
||||
g2d.drawLine(width - 6, 14, width - 12, 14);
|
||||
g2d.drawLine(width - 6, 20, width - 12, 20);
|
||||
g2d.setColor(CRYSTAL_BODY);
|
||||
g2d.fillRoundRect(6, height - 12, 16, 6, 3, 3);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user