Skip to content

Commit

Permalink
Identify the drill symbol inside a T1CPad instance (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwheeler authored Jun 17, 2024
1 parent 55c5df4 commit 0f08290
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/brd_gui/brdview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ void BrdView::drawX0C(const T0CDrillIndicator<kAMax> *inst, QPen *pen) {
int32_t w = inst->coords[2], h = inst->coords[3];
QPointF center = QPointF(inst->coords[0] / factor, inst->coords[1] / factor);

if (inst->backdrill_id != DrillSymbol::NoSymbol) {
if (inst->drill_chart_symbol != DrillSymbol::NoSymbol) {
QTransform t = QTransform()
.translate(center.x(), center.y())
.rotate(inst->rotation / 1000.);
QGraphicsItem *item = nullptr;
if (inst->backdrill_id == DrillSymbol::Circle ||
inst->backdrill_id == DrillSymbol::RoundedRect) {
if (inst->drill_chart_symbol == DrillSymbol::Circle ||
inst->drill_chart_symbol == DrillSymbol::RoundedRect) {
item = scene->addEllipse((-w / 2.) / factor, (-h / 2.) / factor,
w / factor, h / factor, *pen);
} else {
Expand Down
32 changes: 22 additions & 10 deletions src/lib/printing/printers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,9 +803,9 @@ void print_x0C(const void *untyped_inst, File<version> *fs, const int d) {
T0CDrillIndicator<version> inst = fs->get_x0C(k);
printf_d(d,
"x0C: t=0x%04X subtype=%02X layer=%d k=0x%08X "
"label=\x1b[34m\"%s\"\x1b[0m backdrill_id=%08X\n",
"label=\x1b[34m\"%s\"\x1b[0m drill_chart_symbol=%08X\n",
ntohl(inst.t), inst.subtype, inst.layer, ntohl(inst.k), inst.label,
ntohl(inst.backdrill_id));
ntohl(inst.drill_chart_symbol));
if constexpr (!std::is_same_v<decltype(inst.un2), std::monostate>) {
printf_d(d + 1, "un2=%08X un4=%08X\n", ntohl(inst.un2), ntohl(inst.un4));
}
Expand All @@ -814,8 +814,8 @@ void print_x0C(const void *untyped_inst, File<version> *fs, const int d) {
}
printf_d(d + 1, "un1={%08X %08X}, un5=%08X, un6=0x%08X\n", ntohl(inst.un1[0]),
ntohl(inst.un1[1]), ntohl(inst.un5), ntohl(inst.un6));
printf_d(d + 1, "\x1b[2m(%d, %d, %d, %d, %0.1f deg)\x1b[0m\n", inst.coords[0],
inst.coords[1], inst.coords[2], inst.coords[3],
printf_d(d + 1, "\x1b[2m(%d, %d, w=%d, h=%d, %0.1f deg)\x1b[0m\n",
inst.coords[0], inst.coords[1], inst.coords[2], inst.coords[3],
inst.rotation / 1000.);

printf_d(d + 1, "group_ptr:");
Expand Down Expand Up @@ -993,17 +993,22 @@ void print_x11(const void *untyped_inst, File<version> *fs, const int d) {
exit(0);
}

printf_d(d + 1, "ptr3 \x1b[3m(matching footprint pin)\x1b[0m:\n");
if (fs->is_type(inst->ptr3, 0x08)) {
print_struct(inst->ptr3, *fs, d + 2);
printf_d(d + 1, "ptr3 \x1b[3m(matching footprint pin)\x1b[0m:");
if (inst->ptr3 == 0) {
printf(" \x1b[2mnull\x1b[0m\n");
} else {
printf_d(d + 2, "ptr3 unrecognized: 0x%08X\n", ntohl(inst->ptr3));
exit(0);
std::printf("\n");
if (fs->is_type(inst->ptr3, 0x08)) {
print_struct(inst->ptr3, *fs, d + 2);
} else {
printf_d(d + 2, "ptr3 unrecognized: 0x%08X\n", ntohl(inst->ptr3));
exit(0);
}
}

if (inst->un != 0) {
printf_d(d + 1, "expected un to be 0, but = %08X\n", ntohl(inst->un));
exit(1);
// exit(1);
}
}

Expand Down Expand Up @@ -1442,6 +1447,11 @@ void print_x1C(const void *untyped_inst, File<version> *fs, const int d) {
padtype(inst.pad_info.pad_type).c_str(), inst.pad_info.pad_type,
inst.pad_info.a, inst.pad_info.b, inst.pad_info.c, inst.pad_info.d,
ntohl(inst.pad_str), str_lookup(inst.pad_str, *fs));
printf_d(d + 1,
"drill_chart_symbol=%08X label=\x1b[34m\"%s\"\x1b[0m (symbol_w=%d, "
"symbol_h=%d)\n",
ntohl(inst.drill_chart_symbol), inst.drill_label, inst.symbol_w,
inst.symbol_h);

printf_d(d + 1, "layer_count=%d len(parts)=%d\n", inst.layer_count,
inst.parts.size());
Expand Down Expand Up @@ -2443,6 +2453,7 @@ void print_x32(const void *untyped_inst, File<version> *fs, const int d) {
}
}

/*
printf_d(d + 1, "next:\n");
if (fs->is_type(inst.next, 0x32)) {
print_struct(inst.next, *fs, d + 2);
Expand All @@ -2454,6 +2465,7 @@ void print_x32(const void *untyped_inst, File<version> *fs, const int d) {
printf_d(d + 2, "next unrecognized: 0x%08X\n", ntohl(inst.next));
exit(0);
}
*/

printf_d(d + 1, "ptr3 \x1b[3m(placed symbol)\x1b[0m:\n");
if (fs->is_type(inst.ptr3, 0x2D)) {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/structure/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ T0CDrillIndicator<kA160>::operator T0CDrillIndicator<kAMax>() const {
new_inst.next = this->next;
new_inst.un1[0] = this->un1[0];
new_inst.un1[1] = this->un1[1];
new_inst.backdrill_id = this->backdrill_id;
new_inst.drill_chart_symbol = this->drill_chart_symbol;
new_inst.un2 = 0;
for (uint8_t i = 0; i < 4; i++) {
new_inst.label[i] = this->label[i];
Expand All @@ -227,7 +227,7 @@ T0CDrillIndicator<kA172>::operator T0CDrillIndicator<kAMax>() const {
new_inst.next = this->next;
new_inst.un1[0] = this->un1[0];
new_inst.un1[1] = this->un1[1];
new_inst.backdrill_id = this->backdrill_id;
new_inst.drill_chart_symbol = this->drill_chart_symbol;
new_inst.un2 = this->un2;
new_inst.un4 = this->un4;
for (uint8_t i = 0; i < 4; i++) {
Expand All @@ -253,7 +253,7 @@ T0CDrillIndicator<kA174>::operator T0CDrillIndicator<kAMax>() const {
new_inst.next = this->next;
new_inst.un1[0] = this->un1[0];
new_inst.un1[1] = this->un1[1];
new_inst.backdrill_id = this->backdrill_id;
new_inst.drill_chart_symbol = this->drill_chart_symbol;
new_inst.un2 = this->un2;
for (uint8_t i = 0; i < 4; i++) {
new_inst.label[i] = this->label[i];
Expand Down
16 changes: 11 additions & 5 deletions src/lib/structure/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ struct T0ADRC {
static constexpr AllegroVersion versions[2] = {kA172, kA174};
};

enum DrillSymbol : uint8_t {
enum DrillSymbol : uint32_t {
NoSymbol = 0,
Circle = 0x02,
RoundedRect = 0x0B,
Expand All @@ -473,8 +473,8 @@ struct T0CDrillIndicator {
uint8_t layer;
uint32_t k;
uint32_t next;
uint32_t un1[2]; // Typically (always?) null
uint32_t backdrill_id; // Each backdrill depth (e.g. 12-6) gets its own ID
uint32_t un1[2]; // Typically (always?) null
DrillSymbol drill_chart_symbol;
char label[4];
COND_FIELD(version >= kA172, uint32_t, un2);
COND_FIELD(version >= kA172, uint32_t, un4);
Expand Down Expand Up @@ -825,8 +825,13 @@ struct T1CPad {
COND_FIELD(version < kA172, uint16_t, un6);
uint16_t layer_count;
COND_FIELD(version >= kA172, uint16_t, un7);
uint32_t un8[7];
COND_FIELD(version >= kA172, uint32_t[28], un9);
uint32_t un8[3];
COND_FIELD(version >= kA172, uint32_t[8], un9);
uint32_t symbol_w;
uint32_t symbol_h;
DrillSymbol drill_chart_symbol;
char drill_label[4];
COND_FIELD(version >= kA172, uint32_t[20], un11);
COND_FIELD(version == kA165 || version == kA166, uint32_t[8], un10);

uint32_t TAIL;
Expand All @@ -844,6 +849,7 @@ static_assert(offsetof(T1CPad<kA164>, layer_count) == 50);
static_assert(offsetof(T1CPad<kA172>, layer_count) == 44);
static_assert(offsetof(T1CPad<kA164>, pad_info) == 44);
static_assert(offsetof(T1CPad<kA172>, pad_info) == 28);
static_assert(offsetof(T1CPad<kA175>, drill_label) == 104);

template <AllegroVersion version>
struct x1D {
Expand Down

0 comments on commit 0f08290

Please sign in to comment.