/* file: SwitchComplete.scad * author: Christophe Delannoy * creation: 2019/12/22 */ /* common params */ radius = 3; length = 30; high = 2; /* FZ31-3H */ numPlots = 4; // L/1/2/3 plotNames = ["L", "1", "2", "3"]; /* connections, according to the BT7000 Service Manual */ conData = [ [0, 0, 0, 0], // all-off //(all-off is not in ServiceManual, off course we need it) [1, 0, 1, 1], // L-2-3 [1, 0, 1, 0], // L-2 [1, 0, 0, 1], // L-3 [1, 0, 1, 1], // L-2-3 [1, 1, 1, 0] // L-2-1 ]; numPositions = 6; // sizeoff(conData), including all-off numSegments = numPositions*numPlots; /* microsteps: * we have XX microsteps: * 0: just half-move to the new position; added connections not drawn * 1: just full-move to the new position; added connections not drawn * 2, 3,...: make the added Connection appear, dealing with Alpha (transparency) */ numMicrosteps = 8; theTime = $t; //theTime = 0.4; // if not animating stepTime = round(theTime*360); // [0..360[ // V1 //stepPosition = theTime * numPositions; // [0..numPositions[ //microstep = (theTime * numSegments) % 4; // [0..numMicrosteps[ // V2 stepPosition = floor(stepTime / (360/numPositions) ); // remainder for the division; in [0..(360/numPositions)[, i.e. [0..60[ microstep_Temp = stepTime - stepPosition*(360/numPositions); // low it to [0..numMicrosteps[ microstep = round(microstep_Temp * numMicrosteps / 60); // Draw the microStep value (for DEBUG): /* translate([0, -60, 0]) linear_extrude(high) text(str("microStep: ", stepTime, "->", microstep), size=8, halign = "center"); */ // TEST module testSteps() { numFrames = (numPositions*numMicrosteps); // this paramerter would be the one for Animation render echo("numFrames: ", numFrames); for(timeIndex = [0:numFrames-1]) { stepTime = timeIndex*360/numFrames; stepPosition = floor(stepTime / (360/numPositions) ); // remainder (in [0..(360/numPositions)[) microstep_Temp = stepTime - stepPosition*(360/numPositions); microstep = floor(microstep_Temp * numMicrosteps / 60); echo("Step ([position, micro]: [", stepPosition, microstep, "]"); } } //testSteps(); module drawPlot(angle, plotName, plotColor="Gold") { color(plotColor) rotate([0, 0, 180-45-angle]) { translate([1, 0, 0]) // for the gap difference() { translate([length, -radius, 0]) cube([radius+radius, radius+radius, high]); // hole: add -1/+2 to ensure diff() success translate([length, 0, -1]) cylinder(h=high+2, r=radius); } // draw the plot Name: translate([50, 0, 2]) rotate([0, 0, -180+45+angle]) linear_extrude(high) text(plotName, halign = "center", valign = "center"); } } module drawAllPlots(position) { dataForPosition = conData[position]; echo("dataForPosition: ", dataForPosition); //drawPlot(0, "L"); drawPlot(90, "1"); drawPlot(180, "2"); drawPlot(270, "3"); for(plotIndex = [0:numPlots-1]) { connected = dataForPosition[plotIndex]; plotColor = connected ? "Yellow" : "Goldenrod"; drawPlot(plotIndex*90, plotNames[plotIndex], plotColor); } } module drawSegment(angle, alpha=1.0) { color("DarkRed", alpha) rotate([0, 0, 180-45-angle]) hull(){ // not good drawing if alpha, use union() ? todo spline->extrude // hull(à is OK cylinder(h=high, r=radius); translate([0, -radius, 0]) cube([length, radius+radius, high]); translate([length, 0, 0]) cylinder(h=high, r=radius); } } // param: position is the current rotation for the knob module drawAllSegments(position, microStep) { //for(segment = [0:numSegments-1]) //if(position<=numPositions-1) // maxPos = position; //else // maxPos = numPositions-1; // Draw the Position value: translate([0, -50, 0]) linear_extrude(high) text(str("Position: ",position), size=8, halign = "center"); for(positionIndex = [0:numPositions-1])//:numPositions-1 { dataForPosition = conData[positionIndex]; //echo("dataForPosition :", positionIndex, " => ", dataForPosition); for(plotIndex = [0:numPlots-1])// :numPlots-1] { segmentIndex = -plotIndex*numPositions + positionIndex; //segmentIndex = positionIndex*numPositions + plotIndex; drawable = dataForPosition[plotIndex]; //echo("segmentIndex: ", segmentIndex, "/", numSegments, "->", drawable); segmentAlpha = (positionIndex0) ? angleAtPos0 + position*(360/numSegments) : // move only with the half angle angleAtPos0 + position*(360/numSegments)-180/numSegments; drawSegment(angleWithPos, segmentAlpha); } } } } drawAllPlots(stepPosition); // TODO: drawAllPlots(stepPosition); and show what is connected //drawAllSegments(1, 1); drawAllSegments(stepPosition, microstep);