Loading build.py +3 −3 Original line number Diff line number Diff line Loading @@ -97,11 +97,11 @@ def write_ninja_file(build_dir): writer.openscad("leg_test.stl", "test_pieces/leg_test.scad") writer.openscad("rms_thread.stl", "test_pieces/rms_thread.scad") writer.openscad( "main_body_open_actuators.stl", "test_pieces/main_body_open_actuators.stl", "test_pieces/main_body_open_actuators.scad", {"VERSION_STRING": "Open Bands", "HASH": commit_str} {"VERSION_STRING": version_str, "HASH": commit_str} ) writer.openscad("feet_open_slot.stl","test_pieces/feet_open_slot.scad") writer.openscad("test_pieces/feet_open_slot.stl","test_pieces/feet_open_slot.scad") # Special illumination components writer.openscad("condenser_led_holder.stl", "condenser_led_holder.scad") Loading build_system/util.py +18 −0 Original line number Diff line number Diff line Loading @@ -59,9 +59,12 @@ def version_string(force_clean, check_env=True): The version string for the microscope. """ if check_env: # First check environment vars for CI version string ci_version_string = os.getenv("CI_VERSION_STRING", None) if ci_version_string is not None: return ci_version_string # Set to custom if not clean if not _repo_is_clean(): if force_clean: print("Warning! Git repository is not clean:") Loading @@ -70,10 +73,25 @@ def version_string(force_clean, check_env=True): sys.exit(1) return "Custom" # Next priority is the tag. tag = _get_commit_tag() if _is_release(tag): return tag # Next priority is pipeline ID if in a merged_result pipeline event_type = os.getenv("CI_MERGE_REQUEST_EVENT_TYPE", None) print(f"Merge Event Type: {event_type}") pipeline_id = os.getenv("CI_PIPELINE_ID", None) print(f"Pipeline ID: {pipeline_id}") # If we are in a merged result pipeline then the hash isn't in the repo. if event_type == "merged_result" and pipeline_id is not None: # Pint the pipeline id on the main body if len(pipeline_id) <= 10: return f"Pipeline\\n{pipeline_id}" # With a fallback in case the ids get longer return f"Pipe {pipeline_id[0:2]}-\\n{pipeline_id[2:]}" # Finally use hash (unless it is None) commit_hash = _get_commit_hash() if commit_hash is None: if force_clean: Loading openscad/libs/logo.scad +7 −10 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ // For copyright and authorship information, see the Git history at: // https://gitlab.com/openflexure/openflexure-microscope use <utilities.scad> $fn=64; module oshw_logo(){ Loading Loading @@ -45,30 +47,25 @@ module openflexure_logo_above(h=1){ } } module oshw_logo_and_text(message=""){ module oshw_logo_and_text(message1="", message2=""){ union(){ translate([0,45,0]){ translate_y(45){ oshw_logo(); } mirror([1,0,0]){ linear_extrude(1){ text(message, size=14, font="Calibri", halign="center"); } two_line_text(message1, message2, shift_up=10, size=14, halign="center", font="Liberation Sans"); } } } module oshw_logo_and_text_beside(message=""){ module oshw_logo_and_text_beside(message1="", message2=""){ union(){ translate([25,8,0]){ oshw_logo(); } mirror([1,0,0]){ linear_extrude(1){ text(message, size=14, font="Calibri", halign="left"); } two_line_text(message1, message2, shift_up=12, size=14, halign="left", font="Liberation Sans"); } } } openscad/libs/main_body_structure.scad +19 −5 Original line number Diff line number Diff line use <./utilities.scad> use <./string_utils.scad> use <./compact_nut_seat.scad> use <./logo.scad> use <./z_axis.scad> Loading Loading @@ -701,7 +702,7 @@ module actuator_walls_and_z_casing(params, z_axis=true){ } } module body_logos(params, message){ module body_logos(params, message1, message2){ // The openflexure and opehardware logos. Plus a customisable message. xy_cable_tidies = key_lookup("include_motor_lugs",params); size = xy_cable_tidies? 0.25 : 0.24; Loading Loading @@ -730,10 +731,10 @@ module body_logos(params, message){ mirror([1,0,0]){ scale([size,size,10]){ if (xy_cable_tidies){ oshw_logo_and_text(message); oshw_logo_and_text(message1, message2); } else { oshw_logo_and_text_beside(message); oshw_logo_and_text_beside(message1, message2); } } } Loading @@ -751,8 +752,21 @@ module xy_only_body(params){ } } /*This module creates the main body of the microscope, including the positioning mechanism. :param params: microscope parameters dictionary :param version_string: string of 1 or 2 lines, using \n as "first line\nsecond line". Placed on the outer wall of the main body, under the open hardware logo :param hash: string. placed on the inner wall of the main body */ module main_body(params, version_string, hash){ // This module represents the main body of the microscope, including the positioning mechanism. // Split version_string into a list by line version_string_list = split_string_lines(version_string); // Check the list isn't longer than 2 lines (will produce an empty string if empty) assert(len(version_string_list) <= 2, "Can only have 1 or 2 lines in a version string."); // Get the lines and use "" as a fallback for line 2 if only 1 line is provided. version_line1 = version_string_list[0]; version_line2 = len(version_string_list) == 1 ? "" : version_string_list[1]; difference(){ xy_positioning_system(params); Loading @@ -768,6 +782,6 @@ module main_body(params, version_string, hash){ difference(){ actuator_walls_and_z_casing(params, z_axis=true); body_logos(params, version_string); body_logos(params, version_line1, version_line2); } } openscad/libs/string_utils.scad 0 → 100644 +62 −0 Original line number Diff line number Diff line /* A collection of string utilities for OpenSCAD. These functions provide basic string manipulation features that are not available natively in stable OpenSCAD. */ // SPDX-License-Identifier: CERN-OHL-S-2.0 // For copyright and authorship information, see the Git history at: // https://gitlab.com/openflexure/openflexure-microscope /* Concatenate a list of strings into a single string. This function reduces the list recursively, concatenating pairs of elements until a single string remains. :param input: A list of strings :return: A single string formed by concatenating all elements of `input` */ function str_cat(input) = // Empty list becomes "" len(input) == 0 ? "" : // Single element is coerced into a string and output len(input) == 1 ? str(input[0]) : // 2 elements are concatedated as strings len(input) == 2 ? str(input[0], input[1]) : // Greater then than 2 elements, the first 2 strings in the list are // combined, then recursively recall this function. str_cat( concat( [str(input[0], input[1])], [for (i = [2:len(input)-1]) input[i]] ) ); /* Return a substring using inclusive start and end indices. No bounds checking is performed. Supplying indices outside the valid range may result in undefined behaviour. :param string: The source string :param start: Starting index (inclusive, zero-based) :param end: Ending index (inclusive, zero-based) :return: The substring from `start` to `end` */ function sub_str(string, start, end) = str_cat([ for (i = [start:end]) string[i] ]); /* Split a multi-line string into a list of one-line strings. :param string: The input string :return: A list of strings, one per line */ function split_string_lines(string) = let( // get position of any \n pos = search("\n", string, 0)[0], s_pos = concat([0], [for (p=pos) p+1]), e_pos = concat( [for (p=pos) p-1], len(string)-1) ) [for (i = [0:len(pos)]) sub_str(string, s_pos[i], e_pos[i])]; Loading
build.py +3 −3 Original line number Diff line number Diff line Loading @@ -97,11 +97,11 @@ def write_ninja_file(build_dir): writer.openscad("leg_test.stl", "test_pieces/leg_test.scad") writer.openscad("rms_thread.stl", "test_pieces/rms_thread.scad") writer.openscad( "main_body_open_actuators.stl", "test_pieces/main_body_open_actuators.stl", "test_pieces/main_body_open_actuators.scad", {"VERSION_STRING": "Open Bands", "HASH": commit_str} {"VERSION_STRING": version_str, "HASH": commit_str} ) writer.openscad("feet_open_slot.stl","test_pieces/feet_open_slot.scad") writer.openscad("test_pieces/feet_open_slot.stl","test_pieces/feet_open_slot.scad") # Special illumination components writer.openscad("condenser_led_holder.stl", "condenser_led_holder.scad") Loading
build_system/util.py +18 −0 Original line number Diff line number Diff line Loading @@ -59,9 +59,12 @@ def version_string(force_clean, check_env=True): The version string for the microscope. """ if check_env: # First check environment vars for CI version string ci_version_string = os.getenv("CI_VERSION_STRING", None) if ci_version_string is not None: return ci_version_string # Set to custom if not clean if not _repo_is_clean(): if force_clean: print("Warning! Git repository is not clean:") Loading @@ -70,10 +73,25 @@ def version_string(force_clean, check_env=True): sys.exit(1) return "Custom" # Next priority is the tag. tag = _get_commit_tag() if _is_release(tag): return tag # Next priority is pipeline ID if in a merged_result pipeline event_type = os.getenv("CI_MERGE_REQUEST_EVENT_TYPE", None) print(f"Merge Event Type: {event_type}") pipeline_id = os.getenv("CI_PIPELINE_ID", None) print(f"Pipeline ID: {pipeline_id}") # If we are in a merged result pipeline then the hash isn't in the repo. if event_type == "merged_result" and pipeline_id is not None: # Pint the pipeline id on the main body if len(pipeline_id) <= 10: return f"Pipeline\\n{pipeline_id}" # With a fallback in case the ids get longer return f"Pipe {pipeline_id[0:2]}-\\n{pipeline_id[2:]}" # Finally use hash (unless it is None) commit_hash = _get_commit_hash() if commit_hash is None: if force_clean: Loading
openscad/libs/logo.scad +7 −10 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ // For copyright and authorship information, see the Git history at: // https://gitlab.com/openflexure/openflexure-microscope use <utilities.scad> $fn=64; module oshw_logo(){ Loading Loading @@ -45,30 +47,25 @@ module openflexure_logo_above(h=1){ } } module oshw_logo_and_text(message=""){ module oshw_logo_and_text(message1="", message2=""){ union(){ translate([0,45,0]){ translate_y(45){ oshw_logo(); } mirror([1,0,0]){ linear_extrude(1){ text(message, size=14, font="Calibri", halign="center"); } two_line_text(message1, message2, shift_up=10, size=14, halign="center", font="Liberation Sans"); } } } module oshw_logo_and_text_beside(message=""){ module oshw_logo_and_text_beside(message1="", message2=""){ union(){ translate([25,8,0]){ oshw_logo(); } mirror([1,0,0]){ linear_extrude(1){ text(message, size=14, font="Calibri", halign="left"); } two_line_text(message1, message2, shift_up=12, size=14, halign="left", font="Liberation Sans"); } } }
openscad/libs/main_body_structure.scad +19 −5 Original line number Diff line number Diff line use <./utilities.scad> use <./string_utils.scad> use <./compact_nut_seat.scad> use <./logo.scad> use <./z_axis.scad> Loading Loading @@ -701,7 +702,7 @@ module actuator_walls_and_z_casing(params, z_axis=true){ } } module body_logos(params, message){ module body_logos(params, message1, message2){ // The openflexure and opehardware logos. Plus a customisable message. xy_cable_tidies = key_lookup("include_motor_lugs",params); size = xy_cable_tidies? 0.25 : 0.24; Loading Loading @@ -730,10 +731,10 @@ module body_logos(params, message){ mirror([1,0,0]){ scale([size,size,10]){ if (xy_cable_tidies){ oshw_logo_and_text(message); oshw_logo_and_text(message1, message2); } else { oshw_logo_and_text_beside(message); oshw_logo_and_text_beside(message1, message2); } } } Loading @@ -751,8 +752,21 @@ module xy_only_body(params){ } } /*This module creates the main body of the microscope, including the positioning mechanism. :param params: microscope parameters dictionary :param version_string: string of 1 or 2 lines, using \n as "first line\nsecond line". Placed on the outer wall of the main body, under the open hardware logo :param hash: string. placed on the inner wall of the main body */ module main_body(params, version_string, hash){ // This module represents the main body of the microscope, including the positioning mechanism. // Split version_string into a list by line version_string_list = split_string_lines(version_string); // Check the list isn't longer than 2 lines (will produce an empty string if empty) assert(len(version_string_list) <= 2, "Can only have 1 or 2 lines in a version string."); // Get the lines and use "" as a fallback for line 2 if only 1 line is provided. version_line1 = version_string_list[0]; version_line2 = len(version_string_list) == 1 ? "" : version_string_list[1]; difference(){ xy_positioning_system(params); Loading @@ -768,6 +782,6 @@ module main_body(params, version_string, hash){ difference(){ actuator_walls_and_z_casing(params, z_axis=true); body_logos(params, version_string); body_logos(params, version_line1, version_line2); } }
openscad/libs/string_utils.scad 0 → 100644 +62 −0 Original line number Diff line number Diff line /* A collection of string utilities for OpenSCAD. These functions provide basic string manipulation features that are not available natively in stable OpenSCAD. */ // SPDX-License-Identifier: CERN-OHL-S-2.0 // For copyright and authorship information, see the Git history at: // https://gitlab.com/openflexure/openflexure-microscope /* Concatenate a list of strings into a single string. This function reduces the list recursively, concatenating pairs of elements until a single string remains. :param input: A list of strings :return: A single string formed by concatenating all elements of `input` */ function str_cat(input) = // Empty list becomes "" len(input) == 0 ? "" : // Single element is coerced into a string and output len(input) == 1 ? str(input[0]) : // 2 elements are concatedated as strings len(input) == 2 ? str(input[0], input[1]) : // Greater then than 2 elements, the first 2 strings in the list are // combined, then recursively recall this function. str_cat( concat( [str(input[0], input[1])], [for (i = [2:len(input)-1]) input[i]] ) ); /* Return a substring using inclusive start and end indices. No bounds checking is performed. Supplying indices outside the valid range may result in undefined behaviour. :param string: The source string :param start: Starting index (inclusive, zero-based) :param end: Ending index (inclusive, zero-based) :return: The substring from `start` to `end` */ function sub_str(string, start, end) = str_cat([ for (i = [start:end]) string[i] ]); /* Split a multi-line string into a list of one-line strings. :param string: The input string :return: A list of strings, one per line */ function split_string_lines(string) = let( // get position of any \n pos = search("\n", string, 0)[0], s_pos = concat([0], [for (p=pos) p+1]), e_pos = concat( [for (p=pos) p-1], len(string)-1) ) [for (i = [0:len(pos)]) sub_str(string, s_pos[i], e_pos[i])];