1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-23 12:20:17 +02:00

sch2fig/: better error reporting; add features of Neo900 sheet 2

This commit is contained in:
Werner Almesberger 2016-07-24 01:03:23 -03:00
parent 9f8a09b2d5
commit 8ad734ff39
7 changed files with 59 additions and 10 deletions

View File

@ -34,5 +34,5 @@ sch:
test: $(NAME) test: $(NAME)
./$(NAME) $(NEO900_HW)/neo900.lib \ ./$(NAME) $(NEO900_HW)/neo900.lib \
$(KICAD_LIBS)/powered.lib \ $(KICAD_LIBS)/powered.lib \
$(NEO900_HW)/neo900_SS_1.sch \ $(NEO900_HW)/neo900_SS_2.sch \
>out.fig >out.fig

View File

@ -14,7 +14,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <assert.h>
#include "util.h"
#include "style.h" #include "style.h"
#include "text.h" #include "text.h"
#include "fig.h" #include "fig.h"
@ -96,8 +98,8 @@ void fig_glabel(int x, int y, const char *s, int dir, int dim,
.vert = text_mid, .vert = text_mid,
}; };
int n = 6; int n = 6;
int vx[5]; int vx[7];
int vy[5]; int vy[7];
int half = (dim >> 1) + GLABEL_OFFSET; int half = (dim >> 1) + GLABEL_OFFSET;
switch (dir) { switch (dir) {
@ -106,7 +108,7 @@ void fig_glabel(int x, int y, const char *s, int dir, int dim,
txt.hor = text_max; txt.hor = text_max;
break; break;
default: default:
abort(); assert(0);
} }
switch (shape) { switch (shape) {
@ -136,8 +138,24 @@ void fig_glabel(int x, int y, const char *s, int dir, int dim,
text_rel(&txt, text_min, text_mid, -GLABEL_OFFSET- half, 0, text_rel(&txt, text_min, text_mid, -GLABEL_OFFSET- half, 0,
vx + 5, vy + 5); vx + 5, vy + 5);
break; break;
case fig_bidir:
text_shift(&txt, txt.hor, text_mid, -GLABEL_OFFSET - half, 0);
n = 7;
text_rel(&txt, text_min, text_min,
-GLABEL_OFFSET, GLABEL_OFFSET, vx + 1, vy + 1);
text_rel(&txt, text_max, text_min,
GLABEL_OFFSET, GLABEL_OFFSET, vx + 2, vy + 2);
text_rel(&txt, text_max, text_mid, GLABEL_OFFSET + half, 0,
vx + 3, vy + 3);
text_rel(&txt, text_max, text_max,
GLABEL_OFFSET, -GLABEL_OFFSET, vx + 4, vy + 4);
text_rel(&txt, text_min, text_max,
-GLABEL_OFFSET, -GLABEL_OFFSET, vx + 5, vy + 5);
text_rel(&txt, text_min, text_mid, -GLABEL_OFFSET- half, 0,
vx + 6, vy + 6);
break;
default: default:
abort(); assert(0);
} }
text_fig(&txt, COLOR_GLABEL, LAYER_GLABEL); text_fig(&txt, COLOR_GLABEL, LAYER_GLABEL);
@ -159,6 +177,17 @@ void fig_junction(int x, int y)
} }
void fig_noconn(int x, int y)
{
int vx[2] = { x - NOCONN_LEN, x + NOCONN_LEN };
int vy[2] = { y - NOCONN_LEN, y + NOCONN_LEN };
fig_poly(2, vx, vy, COLOR_NOCONN, LAYER_NOCONN);
swap(vy[0], vy[1]);
fig_poly(2, vx, vy, COLOR_NOCONN, LAYER_NOCONN);
}
void fig_wire(int sx, int sy, int ex, int ey) void fig_wire(int sx, int sy, int ex, int ey)
{ {
// TypeStyle FillCol AreaFil Cap FwdAr // TypeStyle FillCol AreaFil Cap FwdAr

View File

@ -22,6 +22,7 @@ enum fig_shape {
fig_in, // Input fig_in, // Input
fig_out, // Output fig_out, // Output
fig_tri, // 3State fig_tri, // 3State
fig_bidir, // Bidirectional
}; };
@ -35,6 +36,7 @@ void fig_glabel(int x, int y, const char *s, int dir, int dim,
enum fig_shape shape); enum fig_shape shape);
void fig_junction(int x, int y); void fig_junction(int x, int y);
void fig_noconn(int x, int y);
void fig_wire(int sx, int sy, int ex, int ey); void fig_wire(int sx, int sy, int ex, int ey);
void fig_line(int sx, int sy, int ex, int ey); void fig_line(int sx, int sy, int ex, int ey);

View File

@ -262,7 +262,7 @@ static enum text_style decode_style(const char *s)
{ {
if (!strcmp(s, "Normal")) if (!strcmp(s, "Normal"))
return text_normal; return text_normal;
abort(); assert(0);
} }

View File

@ -16,6 +16,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include "util.h" #include "util.h"
#include "misc.h" #include "misc.h"
@ -38,6 +39,8 @@ static enum fig_shape do_decode_shape(const char *s)
return fig_out; return fig_out;
if (!strcmp(s, "3State")) if (!strcmp(s, "3State"))
return fig_tri; return fig_tri;
if (!strcmp(s, "BiDi"))
return fig_bidir;
fprintf(stderr, "unknown shape: \"%s\"\n", s); fprintf(stderr, "unknown shape: \"%s\"\n", s);
exit(1); exit(1);
} }
@ -110,7 +113,7 @@ static bool parse_field(struct sch_ctx *ctx, const char *line)
txt->rot = 90; txt->rot = 90;
break; break;
default: default:
abort(); assert(0);
} }
switch (hor) { switch (hor) {
@ -124,7 +127,7 @@ static bool parse_field(struct sch_ctx *ctx, const char *line)
txt->hor = text_max; txt->hor = text_max;
break; break;
default: default:
abort(); assert(0);
} }
switch (vert) { switch (vert) {
@ -138,7 +141,7 @@ static bool parse_field(struct sch_ctx *ctx, const char *line)
txt->vert = text_max; txt->vert = text_max;
break; break;
default: default:
abort(); assert(0);
} }
// @@@ decode font // @@@ decode font
@ -249,6 +252,13 @@ bool sch_parse(struct sch_ctx *ctx, const char *line)
return 1; return 1;
} }
/* NoConn */
if (sscanf(line, "NoConn ~ %d %d", &x, &y) == 2) {
fig_noconn(x, y);
return 1;
}
/* Wire */ /* Wire */
if (sscanf(line, "Wire Wire Line%n", &n) == 0 && n) { if (sscanf(line, "Wire Wire Line%n", &n) == 0 && n) {
@ -347,5 +357,5 @@ bool sch_parse(struct sch_ctx *ctx, const char *line)
void sch_init(struct sch_ctx *ctx) void sch_init(struct sch_ctx *ctx)
{ {
ctx->state = sch_descr; ctx->state = sch_descr;
ctx->lineno++; ctx->lineno = 0;
} }

View File

@ -24,6 +24,7 @@
#define COLOR_SHEET_DWG COLOR_BLUE #define COLOR_SHEET_DWG COLOR_BLUE
#define COLOR_TEXT COLOR_BLUE #define COLOR_TEXT COLOR_BLUE
#define COLOR_WIRE COLOR_GREEN4 #define COLOR_WIRE COLOR_GREEN4
#define COLOR_NOCONN COLOR_BLUE
#define COLOR_GLABEL COLOR_RED4 #define COLOR_GLABEL COLOR_RED4
#define COLOR_FIELD COLOR_CYAN3 #define COLOR_FIELD COLOR_CYAN3
#define COLOR_PIN_NAME COLOR_FIELD #define COLOR_PIN_NAME COLOR_FIELD
@ -33,6 +34,7 @@
#define LAYER_GLABEL 20 #define LAYER_GLABEL 20
#define LAYER_TEXT 30 #define LAYER_TEXT 30
#define LAYER_NOCONN 40
#define LAYER_WIRES 50 #define LAYER_WIRES 50
#define LAYER_FIELD 60 #define LAYER_FIELD 60
#define LAYER_PIN_NAME LAYER_FIELD #define LAYER_PIN_NAME LAYER_FIELD
@ -46,6 +48,8 @@
#define JUNCTION_R 40 #define JUNCTION_R 40
#define NOCONN_LEN 25
#define GLABEL_OFFSET 20 #define GLABEL_OFFSET 20
#endif /* !STYLE_H */ #endif /* !STYLE_H */

View File

@ -38,6 +38,10 @@
stralloc_tmp; }) stralloc_tmp; })
#define swap(a, b) \
({ typeof(a) _tmp = (a); a = (b); b = _tmp; })
#define unsupported(s) \ #define unsupported(s) \
fprintf(stderr, __FILE__ ":%d: unsupported: " s "\n", __LINE__) fprintf(stderr, __FILE__ ":%d: unsupported: " s "\n", __LINE__)