Screenshot 2024-09-28 203903.png

// Parameters for dimensions of the enclosure
enclosure_width = 150;
enclosure_depth = 100;
enclosure_height = 70;
wall_thickness = 3;
mount_hole_diameter = 5;
screen_width = 40;
screen_height = 20;
engraving_depth = 2;
text_size = 10;

// Motherboard dimensions
motherboard_width = 80;
motherboard_depth = 60;
motherboard_thickness = 2;

// Complex components for motherboard
cpu_size = [12, 12, 3];
ram_size = [15, 3, 2];
chip_size = [5, 5, 2];
sensor_box_size = [12, 12, 10];  // Sensor box size for amplified sensors

// Create the enclosure (a box)
module enclosure() {
    color("lightgray")  // Color the enclosure light gray
    difference() {
        // Outer box
        cube([enclosure_width, enclosure_depth, enclosure_height], true);
        
        // Hollow interior for components
        translate([0, 0, wall_thickness])
            cube([enclosure_width - 2*wall_thickness, enclosure_depth - 2*wall_thickness, enclosure_height - wall_thickness], true);
    }
}

// Create ventilation slots
module ventilation_slots() {
    color("darkgray")  // Color the ventilation slots dark gray
    for (x = [-50:25:50]) {
        translate([x, -enclosure_depth/2 + wall_thickness, enclosure_height/3])
            cube([15, wall_thickness, 5], true);
    }
}

// Create more complex sensor slots for CO₂, NO₂, CO, VOC
module sensor_slots() {
    color("green")  // Color the sensor slots green
    for (i = [-30, -10, 10, 30]) {
        translate([i, enclosure_depth/2 - wall_thickness - 25, enclosure_height/2])
            sensor_box();
    }
}

// Create a screen slot for displaying data
module screen() {
    color("blue")  // Color the screen blue
    translate([0, -enclosure_depth/2 + wall_thickness + 10, enclosure_height/4])
        difference() {
            cube([screen_width, wall_thickness, screen_height], true);
            // Hollow out the screen slot
            translate([2, -wall_thickness, 2])
                cube([screen_width - 4, wall_thickness + 5, screen_height - 4], true);
        }
}

// Create an engraving for the text "LYFE"
module text_engraving() {
    color("black")  // Color the engraving black
    translate([-enclosure_width/2 + 15, enclosure_depth/4, enclosure_height - wall_thickness - 1])
        linear_extrude(height = engraving_depth)
            text("LYFE", size = text_size, halign = "center", valign = "center");
}

// Create mounting holes for attaching to a wall
module mounting_holes() {
    color("red")  // Color the mounting holes red
    for (x = [-enclosure_width/2 + 20, enclosure_width/2 - 20]) {
        translate([x, enclosure_depth/2, -enclosure_height/2 + 10])
            cylinder(h = wall_thickness, d = mount_hole_diameter, $fn = 50);
    }
}

// Create motherboard compartment
module motherboard_compartment() {
    color("lightgreen")  // Color the motherboard compartment light green
    translate([-enclosure_width/4, -enclosure_depth/4, enclosure_height/4])
        cube([motherboard_width, motherboard_depth, 20], true);
}

// Create a more complex motherboard and components

    // Add complex components on the motherboard
    // Example: CPU block
    color("orange")  // Color the CPU block orange
    translate([0, 0, -enclosure_height/2 + 10 + motherboard_thickness])
        cube(cpu_size, true);

    // Example: RAM slots
    color("blue")
    for (i = [-motherboard_width/4 + 10, motherboard_width/4 - 10]) {
        translate([i, motherboard_depth/3, -enclosure_height/2 + 12])
            cube(ram_size, true);
    }

    // Example: Chips on the motherboard
    color("gray")
    for (x = [-motherboard_width/3, motherboard_width/3]) {
        for (y = [-motherboard_depth/3, motherboard_depth/3]) {
            translate([x, y, -enclosure_height/2 + 12])
                cube(chip_size, true);
        }
    }

    // Example: Capacitors
    color("cyan")  // Color the capacitors cyan
    for (i = [-motherboard_width/3, motherboard_width/3]) {
        translate([i, motherboard_depth/2 - 5, -enclosure_height/2 + 12])
            cylinder(h = 5, r = 2, $fn = 50);
  
}

// Create amplified sensors for CO₂, NO₂, CO, and VOC
module sensor_box() {
    color("purple")  // Amplified sensors in purple
    cube(sensor_box_size, true);
}

// Assembly of all parts
module sensor_enclosure() {
    enclosure();
    ventilation_slots();
    sensor_slots();
    screen();
    text_engraving();
    mounting_holes();
    motherboard_compartment();
    motherboard();  // Add the complex motherboard and components here
}

// Render the 3D model
sensor_enclosure();