include <../modules/bidirectional_idt.scad>
include <../modules/parameter_text.scad>
include <../modules/wafer.scad>

// ================= README =================
// these are the normal parameters used by
// each one of the layout scripts
// however they do dont directly use them
// and instead have thier own copy
//
// this was done in order to have more control
// over each of the scripts themsevels 
// allowing each to have even more parameters
// and having them show up in the open scad
// parameters window
// ================= README =================

// ================= openscad prams =================
$fa = 1;
$fs = 0.01;
// ================= openscad prams =================

// ================= meta =================
SCRIPT_VERSION="0.0.1";
// this really just need to be any mon font
FONT="Ubuntu Sans Mono:style=Regular";
test_number = 1;
// scale in m
scale_unit = 1e3;
// ================= meta =================


// ================= IDT =================
substrate = "LINBO";
// linbo
c = 3992.0;
// si
// c = 3159.0;
freq = 50.0e6;

// $fs = (c/freq);

// inout distance
distance = 150;

// number of finger
n_fingers = 50;

// should be 50-70
finger_length = 60; 

// for tweaking the design
gap = 0;

// for tweaking the design
thickness = 0;

has_id_number = false;
// ================= IDT =================

// ================= bond pad =================

leg_length = 0.003;
leg_width = 0.00001875;
leg_angle = 10;
size = 0.002;
bond_pad_shape = "square";

// ================= bond pad =================

// ================= text =================

info_block_offset_x=20;
info_block_offset_y=-30;
info_block_scale=0.3;
title_text_size = 4;
prop_text_size = 2.5;
id_text_size = 1;

// ================= text =================

// ================= IDT Pos =================
idt_1_x_offset = 0;
idt_1_y_offset = 0;
idt_2_x_offset = 0;
idt_2_y_offset = 0;
// ================= IDT Pos =================


// ================= wafers =================
wafer_size_inch = 4;
// ================= wafers =================

module params() {
    parameter_text(
        str("IDT ", substrate, "#", test_number),
        [
            str("c          (ms): ", c),
            str("freq       (Hz): ", freq),
            str("distance       : ", distance),
            str("n_fingers      : ", n_fingers),
            str("finger_length  : ", finger_length),
            str("gap            : ", gap),
            str("thickness      : ", thickness),
            str("leg_length     : ", leg_length),
            str("leg_angle      : ", leg_angle),
            str("size           : ", size),
            str("feat. size (mm): ", (c/freq)*1e3),
            str("version        : ", SCRIPT_VERSION)
        ]
    );
}

translate([info_block_offset_x, -info_block_offset_y, 0])
scale([info_block_scale, info_block_scale, info_block_scale])
params();

wafer(wafer_size_inch*25.4);

translate([idt_1_x_offset, idt_1_y_offset, 0])    
rotate([0, 0, 60]) 
bi_directional_idt(
    c, 
    freq, 
    n_fingers, 
    distance, 
    finger_length, 
    gap, 
    thickness, 
    post_scale=scale_unit,
    has_bond_pads = true,
    bond_pad_angle = leg_angle,
    bond_pad_leg_width = leg_width,
    bond_pad_leg_length = leg_length,
    bond_pad_size = size,
    center = true
);

translate([idt_2_x_offset, idt_2_y_offset, 0])    
rotate([0, 0, 120]) 
bi_directional_idt(
    c, 
    freq, 
    n_fingers, 
    distance, 
    finger_length, 
    gap, 
    thickness, 
    post_scale=scale_unit,
    has_bond_pads = true,
    bond_pad_angle = leg_angle,
    bond_pad_leg_width = leg_width,
    bond_pad_leg_length = leg_length,
    bond_pad_size = size,
    center = true
);

translate([idt_2_x_offset, idt_2_y_offset, 0])    
bi_directional_idt(
    c, 
    freq, 
    n_fingers, 
    distance, 
    finger_length, 
    gap, 
    thickness, 
    post_scale=scale_unit,
    has_bond_pads = true,
    bond_pad_angle = leg_angle,
    bond_pad_leg_width = leg_width,
    bond_pad_leg_length = leg_length,
    bond_pad_size = size,
    center = true
);