update some deisng parameters and add new cases
This commit is contained in:
@@ -5,7 +5,7 @@ module FeatherCaseWizard
|
||||
attr_reader :ui
|
||||
|
||||
def initialize(ui: HighLine.new)
|
||||
@ui = ui
|
||||
@ui = PromptingUI.wrap(ui)
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -15,14 +15,14 @@ module FeatherCaseWizard
|
||||
end
|
||||
|
||||
def edit(config)
|
||||
ui.say("\nEditing #{config.name} (`#{config.slug}`)")
|
||||
ui.say("Editing #{config.name} (`#{config.slug}`)")
|
||||
config.data["name"] = text("Case name", config.name)
|
||||
configure(config, new_case: false)
|
||||
end
|
||||
|
||||
def confirm_build(config)
|
||||
dims = config.dimensions
|
||||
ui.say("\n#{ui.color("Build summary", :bold)}")
|
||||
ui.say(ui.color("Build summary", :bold))
|
||||
ui.say(" Case: #{config.name} (#{config.slug})")
|
||||
ui.say(" Profile: #{config.parameters["top_profile"]}")
|
||||
ui.say(" Wings: #{config.parameters["wing_count"]}")
|
||||
@@ -42,6 +42,7 @@ module FeatherCaseWizard
|
||||
choose_formats(config)
|
||||
choose_profile(config)
|
||||
choose_stack(config)
|
||||
choose_end_clearance(config)
|
||||
choose_features(config)
|
||||
manage_cutouts(config)
|
||||
choose_coupons(config)
|
||||
@@ -63,7 +64,7 @@ module FeatherCaseWizard
|
||||
menu.choice("3MF") { ["3mf"] }
|
||||
menu.choice("STL") { ["stl"] }
|
||||
menu.choice("Both 3MF and STL") { %w[3mf stl] }
|
||||
menu.default = label == "both" ? 3 : (label == "stl" ? 2 : 1)
|
||||
menu.default = (label == "both" ? 3 : (label == "stl" ? 2 : 1)).to_s
|
||||
end
|
||||
config.outputs["formats"] = selected
|
||||
end
|
||||
@@ -74,7 +75,7 @@ module FeatherCaseWizard
|
||||
menu.choice("Generic / other") { "generic" }
|
||||
menu.choice("GPS") { "gps" }
|
||||
menu.choice("128×64 OLED") { "oled128x64" }
|
||||
menu.default = {"generic" => 1, "gps" => 2, "oled128x64" => 3}.fetch(current)
|
||||
menu.default = {"generic" => 1, "gps" => 2, "oled128x64" => 3}.fetch(current).to_s
|
||||
end
|
||||
end
|
||||
|
||||
@@ -82,11 +83,11 @@ module FeatherCaseWizard
|
||||
p = config.parameters
|
||||
p["wing_count"] = integer("Number of FeatherWings", p["wing_count"], 1..8)
|
||||
measured = p["stack_height_override"].positive?
|
||||
if ui.agree("Use a measured board-to-top-PCB stack height? (y/n) ") do |question|
|
||||
if ui.agree("Use a measured Feather-PCB-top to top-Wing-PCB stack height? (y/n) ") do |question|
|
||||
question.default = measured ? "yes" : "no"
|
||||
end
|
||||
p["stack_height_override"] = number(
|
||||
"Measured height in mm", measured ? p["stack_height_override"] :
|
||||
"PCB-top to PCB-top height in mm", measured ? p["stack_height_override"] :
|
||||
p["wing_count"] * p["wing_pitch"], min: 0.1
|
||||
)
|
||||
else
|
||||
@@ -96,22 +97,55 @@ module FeatherCaseWizard
|
||||
|
||||
def choose_features(config)
|
||||
p = config.parameters
|
||||
p["usb_opening_enabled"] = agreement(
|
||||
"Include front USB-C programming opening?", p["usb_opening_enabled"]
|
||||
)
|
||||
p["usb_guide_enabled"] = if p["usb_opening_enabled"]
|
||||
agreement("Include inward USB plug guide?",
|
||||
p["usb_guide_enabled"])
|
||||
else
|
||||
false
|
||||
end
|
||||
p["battery_enabled"] = agreement("Include 18650 battery compartment and switch?",
|
||||
p["battery_enabled"])
|
||||
p["tripod_insert_enabled"] = agreement("Include centered 1/4-20 insert?",
|
||||
p["tripod_insert_enabled"])
|
||||
return unless p["top_profile"] == "oled128x64"
|
||||
|
||||
ui.say("\nOLED captive buttons")
|
||||
ui.say("OLED captive buttons")
|
||||
p["button_a"] = agreement("Enable button A?", p["button_a"])
|
||||
p["button_b"] = agreement("Enable button B?", p["button_b"])
|
||||
p["button_c"] = agreement("Enable button C?", p["button_c"])
|
||||
p["button_reset"] = agreement("Enable reset button?", p["button_reset"])
|
||||
end
|
||||
|
||||
def choose_end_clearance(config)
|
||||
p = config.parameters
|
||||
defaults = Config::DEFAULT_PARAMETERS
|
||||
custom = p["usb_board_wall_gap"] != defaults["usb_board_wall_gap"] ||
|
||||
p["board_rear_clearance"] != defaults["board_rear_clearance"]
|
||||
enabled = ui.agree("Use extra clearance beyond the Feather PCB ends? (y/n) ") do |question|
|
||||
question.default = custom ? "yes" : "no"
|
||||
end
|
||||
unless enabled
|
||||
p["usb_board_wall_gap"] = defaults["usb_board_wall_gap"]
|
||||
p["board_rear_clearance"] = defaults["board_rear_clearance"]
|
||||
return
|
||||
end
|
||||
|
||||
p["usb_board_wall_gap"] = number(
|
||||
"USB/front PCB-edge to inner-wall clearance (mm)",
|
||||
p["usb_board_wall_gap"], min: 0.1
|
||||
)
|
||||
p["board_rear_clearance"] = number(
|
||||
"Rear PCB-edge to inner-wall clearance (mm)",
|
||||
p["board_rear_clearance"], min: 0.1
|
||||
)
|
||||
end
|
||||
|
||||
def manage_cutouts(config)
|
||||
loop do
|
||||
ui.say("\nCustom cable cutouts: #{config.cutouts.empty? ? "none" :
|
||||
ui.say("Custom cable cutouts: #{config.cutouts.empty? ? "none" :
|
||||
config.cutouts.map { |cutout| cutout["name"] }.join(", ")}")
|
||||
action = ui.choose("Cable cutouts") do |menu|
|
||||
menu.choice("Done") { :done }
|
||||
@@ -141,12 +175,15 @@ module FeatherCaseWizard
|
||||
dims = config.dimensions
|
||||
name = text("Cutout name", existing["name"] || "cable")
|
||||
face = ui.choose("Wall") do |menu|
|
||||
Config::FACES.each { |item| menu.choice(item) { item } }
|
||||
menu.default = Config::FACES.index(existing["face"]).to_i + 1 if existing["face"]
|
||||
menu.choice("Front — USB-C short wall") { "front" }
|
||||
menu.choice("Rear — opposite short wall") { "rear" }
|
||||
menu.choice("Left — plain/non-JST long wall") { "left" }
|
||||
menu.choice("Right — JST/battery long wall") { "right" }
|
||||
menu.default = (Config::FACES.index(existing["face"]).to_i + 1).to_s if existing["face"]
|
||||
end
|
||||
shape = ui.choose("Shape") do |menu|
|
||||
Config::SHAPES.each { |item| menu.choice(item) { item } }
|
||||
menu.default = Config::SHAPES.index(existing["shape"]).to_i + 1 if existing["shape"]
|
||||
menu.default = (Config::SHAPES.index(existing["shape"]).to_i + 1).to_s if existing["shape"]
|
||||
end
|
||||
wall_width = %w[front rear].include?(face) ? dims["width"] : dims["length"]
|
||||
ui.say("Viewing the #{face} wall from outside: width #{format("%.1f", wall_width)} mm; " \
|
||||
@@ -209,7 +246,7 @@ module FeatherCaseWizard
|
||||
Config::ADVANCED_FIELDS.each do |section, fields|
|
||||
next unless ui.agree("Adjust #{section.downcase}? (y/n) ") { |q| q.default = "no" }
|
||||
|
||||
ui.say("\n#{section}")
|
||||
ui.say(section)
|
||||
fields.each do |field|
|
||||
config.parameters[field] = number(field.tr("_", " "), config.parameters[field],
|
||||
min: field == "usb_vertical_offset" ? nil : 0.01)
|
||||
@@ -286,4 +323,3 @@ module FeatherCaseWizard
|
||||
def yes_no(value) = value ? "yes" : "no"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user