Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
strandstring
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Strand
strandstring
Commits
7799b2e0
Commit
7799b2e0
authored
6 years ago
by
Erik Strand
Browse files
Options
Downloads
Patches
Plain Diff
Draw SOIC pads
parent
bec7c7e4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
node_board/main.cpp
+38
-9
38 additions, 9 deletions
node_board/main.cpp
with
38 additions
and
9 deletions
node_board/main.cpp
+
38
−
9
View file @
7799b2e0
...
...
@@ -2,26 +2,55 @@
#include
<iostream>
//--------------------------------------------------------------------------------------------------
// All length measurements are in mm.
int
main
()
{
// All length measurements are in mm.
double
width
=
6
;
double
height
=
14
;
double
ppmm
=
50
;
auto
const
to_px
=
[
ppmm
](
double
x
)
{
return
static_cast
<
uint32_t
>
(
ppmm
*
x
);
};
uint32_t
width_px
=
to_px
(
width
);
uint32_t
height_px
=
to_px
(
height
);
// overall board dims
double
const
width
=
6
;
double
const
height
=
14
;
uint32_t
const
width_px
=
to_px
(
width
);
uint32_t
const
height_px
=
to_px
(
height
);
PngWriter
png_writer
;
png_writer
.
allocate
(
width_px
,
height_px
);
png_writer
.
set_all_pixels_black
();
for
(
uint32_t
y
=
0
;
y
<
10
;
++
y
)
{
for
(
uint32_t
x
=
0
;
x
<
10
;
++
x
)
{
png_writer
.
set_pixel
(
x
,
y
,
255
);
auto
const
set_pixel
=
[
&
png_writer
,
height_px
](
uint32_t
x
,
uint32_t
y
)
{
png_writer
.
set_pixel
(
x
,
height_px
-
y
-
1
,
255
);
};
// SOIC dims
double
const
pad_width
=
0.5
;
double
const
pad_height
=
2.4
;
//double const soic_width = 5;
double
const
soic_height
=
7
;
double
const
soic_pitch
=
1.27
;
// Draw the SOIC pads
double
const
soic_pos_x
=
0.5
*
(
width
-
3
*
soic_pitch
-
pad_width
);
double
const
soic_pos_y
=
0.5
*
(
height
-
soic_height
);
for
(
uint32_t
i
=
0
;
i
<
4
;
++
i
)
{
double
const
pad_x_min
=
soic_pos_x
+
i
*
soic_pitch
;
double
const
pad_x_max
=
pad_x_min
+
pad_width
;
double
pad_y_min
=
soic_pos_y
;
double
pad_y_max
=
pad_y_min
+
pad_height
;
for
(
uint32_t
x
=
to_px
(
pad_x_min
);
x
<
to_px
(
pad_x_max
);
++
x
)
{
for
(
uint32_t
y
=
to_px
(
pad_y_min
);
y
<
to_px
(
pad_y_max
);
++
y
)
{
set_pixel
(
x
,
y
);
}
}
pad_y_min
=
height
-
pad_y_max
;
pad_y_max
=
pad_y_min
+
pad_height
;
for
(
uint32_t
x
=
to_px
(
pad_x_min
);
x
<
to_px
(
pad_x_max
);
++
x
)
{
for
(
uint32_t
y
=
to_px
(
pad_y_min
);
y
<
to_px
(
pad_y_max
);
++
y
)
{
set_pixel
(
x
,
y
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment