Compare commits
	
		
			2 Commits
		
	
	
		
			f1117bf925
			...
			makeItPret
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						18ebebdcb7
	
				 | 
					
					
						|||
| 
						
						
							
						
						94fd41e424
	
				 | 
					
					
						
@ -16,7 +16,7 @@
 | 
				
			|||||||
    <main>
 | 
					    <main>
 | 
				
			||||||
        <section class="visualization-canvas">
 | 
					        <section class="visualization-canvas">
 | 
				
			||||||
            <h2>Robot Visualization</h2>
 | 
					            <h2>Robot Visualization</h2>
 | 
				
			||||||
            <canvas id="swerve-canvas" width="600" height="600"></canvas>
 | 
					            <canvas id="swerve-canvas" width="800" height="800"></canvas>
 | 
				
			||||||
        </section>
 | 
					        </section>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <section class="control-panel">
 | 
					        <section class="control-panel">
 | 
				
			||||||
@ -78,6 +78,7 @@
 | 
				
			|||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <button id="generate-inputs-btn" type="button">Generate Position Inputs</button>
 | 
					                <button id="generate-inputs-btn" type="button">Generate Position Inputs</button>
 | 
				
			||||||
 | 
					                <button id="delete-inputs-btn" type="button">Remove Position Inputs</button>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <div id="module-position-inputs" class="position-inputs">
 | 
					                <div id="module-position-inputs" class="position-inputs">
 | 
				
			||||||
                    <!-- Dynamically generated position inputs will appear here -->
 | 
					                    <!-- Dynamically generated position inputs will appear here -->
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										67
									
								
								script.js
									
									
									
									
									
								
							
							
						
						
									
										67
									
								
								script.js
									
									
									
									
									
								
							@ -171,6 +171,7 @@ const maxSpeedOutput = document.getElementById('max-speed-value');
 | 
				
			|||||||
// Get button elements
 | 
					// Get button elements
 | 
				
			||||||
const resetBtn = document.getElementById('reset-btn');
 | 
					const resetBtn = document.getElementById('reset-btn');
 | 
				
			||||||
const generateInputsBtn = document.getElementById('generate-inputs-btn');
 | 
					const generateInputsBtn = document.getElementById('generate-inputs-btn');
 | 
				
			||||||
 | 
					const clearInputsBtn = document.getElementById('delete-inputs-btn');
 | 
				
			||||||
const applyCustomBtn = document.getElementById('apply-custom-btn');
 | 
					const applyCustomBtn = document.getElementById('apply-custom-btn');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Preset buttons
 | 
					// Preset buttons
 | 
				
			||||||
@ -266,11 +267,77 @@ preset8WheelBtn.addEventListener('click', () => {
 | 
				
			|||||||
    updateModuleDisplays(robot);
 | 
					    updateModuleDisplays(robot);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					generateInputsBtn.addEventListener('click', () => {
 | 
				
			||||||
 | 
					    const count = parseInt(moduleCountInput.value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (isNaN(count) || count < 2) {
 | 
				
			||||||
 | 
					        alert('Please enter a valid number of modules between 2 and 12.');
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    generateModuleInputs(count);
 | 
				
			||||||
 | 
					    applyCustomBtn.style.display = 'block';
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					clearInputsBtn.addEventListener('click', () => {
 | 
				
			||||||
 | 
					    generateModuleInputs(0);
 | 
				
			||||||
 | 
					    applyCustomBtn.style.display = 'none';
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					applyCustomBtn.addEventListener('click', () => {
 | 
				
			||||||
 | 
					    const container = document.getElementById('module-position-inputs');
 | 
				
			||||||
 | 
					    const moduleElements = container.childNodes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const customModules = [];
 | 
				
			||||||
 | 
					    for (let i = 0; i < moduleElements.length; i++) {
 | 
				
			||||||
 | 
					        const xInput = document.getElementById(`module-${i}-x`);
 | 
				
			||||||
 | 
					        const yInput = document.getElementById(`module-${i}-y`);
 | 
				
			||||||
 | 
					        const nameInput = document.getElementById(`module-${i}-name`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const x = parseFloat(xInput.value);
 | 
				
			||||||
 | 
					        const y = parseFloat(yInput.value);
 | 
				
			||||||
 | 
					        const name = nameInput.value.trim();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        customModules.push({ x, y, name });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    robot.setModules(customModules);
 | 
				
			||||||
 | 
					    robot.setName("Custom Configuration");
 | 
				
			||||||
 | 
					    createModuleDisplays(robot);
 | 
				
			||||||
 | 
					    updateModuleDisplays(robot);
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
* END LISTENER CODE
 | 
					* END LISTENER CODE
 | 
				
			||||||
* BEGIN DYNAMIC DOM FUNCTIONS
 | 
					* BEGIN DYNAMIC DOM FUNCTIONS
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function generateModuleInputs(count) {
 | 
				
			||||||
 | 
					    const container = document.getElementById('module-position-inputs');
 | 
				
			||||||
 | 
					    container.innerHTML = ''; // Clear existing inputs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (let i = 0; i < count; i++) {
 | 
				
			||||||
 | 
					        const moduleFieldset = document.createElement('fieldset');
 | 
				
			||||||
 | 
					        moduleFieldset.className = 'module-input-group';
 | 
				
			||||||
 | 
					        moduleFieldset.innerHTML = `
 | 
				
			||||||
 | 
					        <legend>Module ${i + 1}</legend>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <div class="control-group">
 | 
				
			||||||
 | 
					            <label for="module-${i}-name">Module Name</label>
 | 
				
			||||||
 | 
					            <input type="text" id="module-${i}-name" value="Module ${i + 1}" required>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					        <div class="control-group">
 | 
				
			||||||
 | 
					            <label for="module-${i}-x">X Position (pixels)</label>
 | 
				
			||||||
 | 
					            <input type="number" id="module-${i}-x" step="1" value="0" required>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					        <div class="control-group">
 | 
				
			||||||
 | 
					            <label for="module-${i}-y">Y Position (pixels)</label>
 | 
				
			||||||
 | 
					            <input type="number" id="module-${i}-y" step="0.1" value="0" required>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					        `;
 | 
				
			||||||
 | 
					        container.appendChild(moduleFieldset);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function createModuleDisplays(robot) {
 | 
					function createModuleDisplays(robot) {
 | 
				
			||||||
    const grid = document.getElementById('module-grid');
 | 
					    const grid = document.getElementById('module-grid');
 | 
				
			||||||
    grid.innerHTML = ''; // Delete any pre-existing elements before creating new ones
 | 
					    grid.innerHTML = ''; // Delete any pre-existing elements before creating new ones
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										40
									
								
								styles.css
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								styles.css
									
									
									
									
									
								
							@ -322,3 +322,43 @@ button:hover {
 | 
				
			|||||||
  margin-bottom: var(--spacing-small);
 | 
					  margin-bottom: var(--spacing-small);
 | 
				
			||||||
  color: var(--text-secondary);
 | 
					  color: var(--text-secondary);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.control-group {
 | 
				
			||||||
 | 
					  margin-bottom: var(--spacing-small);
 | 
				
			||||||
 | 
					  display: flex;
 | 
				
			||||||
 | 
					  flex-direction: column;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.position-inputs {
 | 
				
			||||||
 | 
					  max-height: 400px;
 | 
				
			||||||
 | 
					  overflow-y: auto;
 | 
				
			||||||
 | 
					  padding: var(--spacing-small);
 | 
				
			||||||
 | 
					  background-color: var(--background-dark);
 | 
				
			||||||
 | 
					  border-radius: var(--border-radius-sm);
 | 
				
			||||||
 | 
					  margin-top: var(--spacing-small);
 | 
				
			||||||
 | 
					  display: grid;
 | 
				
			||||||
 | 
					  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.preset-buttons {
 | 
				
			||||||
 | 
					  display: grid;
 | 
				
			||||||
 | 
					  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.module-display {
 | 
				
			||||||
 | 
					  background-color: var(--background-dark);
 | 
				
			||||||
 | 
					  border: 2px solid var(--border-color);
 | 
				
			||||||
 | 
					  border-radius: var(--border-radius-sm);
 | 
				
			||||||
 | 
					  padding: var(--spacing-small);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.readout {
 | 
				
			||||||
 | 
					  display: flex;
 | 
				
			||||||
 | 
					  justify-content: space-between;
 | 
				
			||||||
 | 
					  margin-bottom: calc(var(--spacing-small) / 2);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.readout .value {
 | 
				
			||||||
 | 
					  color: var(--text-light);
 | 
				
			||||||
 | 
					  font-weight: bold;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user