-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakeDroneCalci.html
More file actions
723 lines (648 loc) · 47.3 KB
/
Copy pathMakeDroneCalci.html
File metadata and controls
723 lines (648 loc) · 47.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Drone Build Calculator</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" />
<style>
:root{
--bg:#0c0e11; --bg-2:#101317; --panel:#15181d; --panel-2:#191d23;
--line:#262b33; --line-2:#333a44; --ink:#eef1f5; --ink-2:#aab1bd;
--ink-3:#6f7783; --hi:#ffffff; --warn-bg:#1c1a17; --warn-line:#4a4436;
--ok-line:#2f3a33; --grid:rgba(255,255,255,0.022); --radius:3px;
}
*{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}
body{
background:var(--bg); color:var(--ink);
font-family:"JetBrains Mono",ui-monospace,monospace; line-height:1.5;
-webkit-font-smoothing:antialiased;
background-image:linear-gradient(var(--grid) 1px,transparent 1px),linear-gradient(90deg,var(--grid) 1px,transparent 1px);
background-size:34px 34px; min-height:100vh;
}
.display{font-family:"Space Grotesk",sans-serif}
.wrap{max-width:1120px;margin:0 auto;padding:0 20px 80px}
header{border-bottom:1px solid var(--line);padding:26px 0 22px;margin-bottom:30px;display:flex;align-items:flex-start;gap:16px;flex-wrap:wrap}
.mark{width:44px;height:44px;flex:0 0 44px;border:1px solid var(--line-2);border-radius:var(--radius);display:grid;place-items:center;background:var(--panel)}
.mark svg{width:24px;height:24px}
.head-txt h1{font-family:"Space Grotesk",sans-serif;font-size:24px;font-weight:700;letter-spacing:-0.01em;line-height:1.1}
.head-txt .sub{color:var(--ink-3);font-size:12px;margin-top:5px;letter-spacing:0.04em;text-transform:uppercase}
.head-spacer{flex:1}
.badge{border:1px solid var(--line);border-radius:var(--radius);padding:7px 12px;font-size:11px;color:var(--ink-2);letter-spacing:0.06em;text-transform:uppercase;white-space:nowrap}
.layout{display:grid;grid-template-columns:1fr 1fr;gap:22px;align-items:start}
@media(max-width:880px){.layout{grid-template-columns:1fr}}
.panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius)}
.panel-h{display:flex;align-items:center;gap:9px;padding:14px 16px;border-bottom:1px solid var(--line)}
.panel-h svg{width:16px;height:16px;color:var(--ink-2)}
.panel-h .t{font-size:12px;letter-spacing:0.1em;text-transform:uppercase;color:var(--ink);font-weight:500}
.panel-h .n{margin-left:auto;font-family:"Space Grotesk",sans-serif;color:var(--ink-3);font-size:12px;font-weight:600}
.panel-b{padding:16px}
.field{margin-bottom:20px}
.field:last-child{margin-bottom:0}
.field > label{display:flex;align-items:center;gap:7px;font-size:11px;letter-spacing:0.08em;text-transform:uppercase;color:var(--ink-2);margin-bottom:9px}
.field > label svg{width:13px;height:13px;color:var(--ink-3)}
.hint{color:var(--ink-3);font-size:10.5px;margin-top:7px;letter-spacing:0.02em;line-height:1.5}
.seg{display:flex;flex-wrap:wrap;gap:6px}
.seg button,.chip{position:relative;font-family:"JetBrains Mono",monospace;background:var(--panel-2);color:var(--ink-2);border:1px solid var(--line);border-radius:var(--radius);padding:8px 11px;font-size:12px;cursor:pointer;transition:border-color .12s,color .12s,background .12s;letter-spacing:0.02em}
.seg button:hover,.chip:hover{border-color:var(--line-2);color:var(--ink)}
.seg button[aria-pressed="true"],.chip[aria-pressed="true"]{background:var(--hi);color:#0c0e11;border-color:var(--hi);font-weight:600;box-shadow:0 0 0 1px var(--hi)}
.seg button[aria-pressed="true"]::before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:#0c0e11;border-radius:2px 0 0 2px}
.seg.grid2{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.seg.grid2 button{text-align:left;padding-left:14px}
.seg .lbl{display:block}
.seg .desc{display:block;font-size:9.5px;color:var(--ink-3);margin-top:2px;letter-spacing:0}
.seg button[aria-pressed="true"] .desc{color:#3a3f47}
input[type="number"]{width:100%;background:var(--panel-2);border:1px solid var(--line);color:var(--ink);border-radius:var(--radius);padding:10px 12px;font-family:"JetBrains Mono",monospace;font-size:14px;-moz-appearance:textfield}
input[type="number"]::-webkit-outer-spin-button,input[type="number"]::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
input[type="number"]:focus{outline:none;border-color:var(--line-2);background:#1c2027}
.inline{display:flex;align-items:center;gap:10px}
.inline .unit{color:var(--ink-3);font-size:12px;white-space:nowrap}
.toggle-link{background:none;border:none;color:var(--ink-3);cursor:pointer;font-family:"JetBrains Mono",monospace;font-size:10.5px;letter-spacing:0.05em;text-transform:uppercase;display:flex;align-items:center;gap:5px;margin-top:10px;padding:0}
.toggle-link:hover{color:var(--ink-2)}
.toggle-link svg{width:11px;height:11px;transition:transform .15s}
.toggle-link[aria-expanded="true"] svg{transform:rotate(90deg)}
.fold{display:none;margin-top:12px;padding-top:14px;border-top:1px dashed var(--line)}
.fold.open{display:block}
.fold.grid{grid-template-columns:1fr 1fr;gap:10px 14px}
.fold.grid.open{display:grid}
.bd-row label{display:block;font-size:10px;color:var(--ink-3);text-transform:uppercase;letter-spacing:0.05em;margin-bottom:5px}
.fold input{padding:7px 9px;font-size:12px}
.readout{position:sticky;top:16px}
.ro-tools{display:flex;gap:8px;padding:12px 16px;border-bottom:1px solid var(--line)}
.btn{flex:1;display:flex;align-items:center;justify-content:center;gap:7px;background:var(--panel-2);border:1px solid var(--line-2);color:var(--ink);border-radius:var(--radius);padding:9px 12px;font-family:"JetBrains Mono",monospace;font-size:11px;letter-spacing:0.06em;text-transform:uppercase;cursor:pointer;transition:background .12s,border-color .12s}
.btn:hover{background:#20252c;border-color:#3f4753}
.btn svg{width:14px;height:14px}
.gauge-wrap{padding:18px 16px 14px}
.gauge-top{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:4px}
.gauge-top .k{font-size:11px;letter-spacing:0.08em;text-transform:uppercase;color:var(--ink-2)}
.twin{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:12px}
.twin .cell{border:1px solid var(--line);border-radius:var(--radius);padding:10px 12px;background:var(--panel-2)}
.twin .cl{font-size:9.5px;letter-spacing:0.08em;text-transform:uppercase;color:var(--ink-3);margin-bottom:4px}
.twin .cv{font-family:"Space Grotesk",sans-serif;font-size:22px;font-weight:700;line-height:1}
.twin .cv small{font-size:12px;color:var(--ink-3);font-weight:500}
.twin .cq{font-size:10px;color:var(--ink-2);margin-top:4px;letter-spacing:0.02em}
.gauge-track{position:relative;height:10px;background:var(--panel-2);border:1px solid var(--line);border-radius:2px;overflow:hidden}
.gauge-fill{position:absolute;left:0;top:0;bottom:0;background:var(--hi);transition:width .25s ease}
.gauge-target{position:absolute;top:-4px;bottom:-4px;width:2px;background:var(--ink-3)}
.gauge-scale{display:flex;justify-content:space-between;font-size:9px;color:var(--ink-3);margin-top:6px;letter-spacing:0.03em}
.gauge-note{font-size:10px;color:var(--ink-3);margin-top:9px;letter-spacing:0.02em;line-height:1.5}
.verdict{display:flex;gap:10px;align-items:flex-start;margin-top:12px;padding:11px 12px;border-radius:var(--radius);font-size:12px;line-height:1.5;border:1px solid var(--line-2);background:var(--panel-2)}
.verdict svg{width:16px;height:16px;flex:0 0 16px;margin-top:1px;color:var(--ink)}
.verdict .vt{font-family:"Space Grotesk",sans-serif;font-weight:600;font-size:13px;color:var(--ink);display:block;margin-bottom:2px}
.verdict .vm{color:var(--ink-2)}
.verdict.bad{border-color:var(--warn-line);background:var(--warn-bg)}
.suggest{margin-top:10px;padding:11px 12px;border:1px dashed var(--line-2);border-radius:var(--radius);display:none}
.suggest.show{display:block}
.suggest .st{font-size:10px;letter-spacing:0.08em;text-transform:uppercase;color:var(--ink-3);margin-bottom:8px}
.suggest ul{list-style:none;margin:0;padding:0}
.suggest li{position:relative;padding-left:16px;font-size:11.5px;color:var(--ink-2);line-height:1.5;margin-bottom:6px}
.suggest li:last-child{margin-bottom:0}
.suggest li strong{color:var(--ink);font-weight:600}
.suggest li::before{content:"";position:absolute;left:0;top:6px;width:6px;height:6px;border:1px solid var(--ink-2);border-radius:1px}
.readout-grid{border-top:1px solid var(--line)}
.ro{display:flex;align-items:flex-start;gap:12px;padding:15px 16px;border-bottom:1px solid var(--line)}
.ro:last-child{border-bottom:none}
.ro-ic{width:30px;height:30px;flex:0 0 30px;border:1px solid var(--line);border-radius:var(--radius);display:grid;place-items:center;background:var(--panel-2)}
.ro-ic svg{width:16px;height:16px;color:var(--ink-2)}
.ro-txt{flex:1;min-width:0}
.ro-txt .k{font-size:10px;letter-spacing:0.09em;text-transform:uppercase;color:var(--ink-3);margin-bottom:3px}
.ro-txt .v{font-family:"Space Grotesk",sans-serif;font-size:19px;font-weight:600;letter-spacing:-0.01em;word-break:break-word}
.ro-txt .v small{font-family:"JetBrains Mono",monospace;font-size:12px;color:var(--ink-2);font-weight:400}
.ro-txt .meta{font-size:10.5px;color:var(--ink-3);margin-top:4px;letter-spacing:0.02em;line-height:1.5}
.specrow{display:grid;grid-template-columns:1fr 1fr;border-top:1px solid var(--line)}
.spec{padding:13px 16px;border-right:1px solid var(--line);border-bottom:1px solid var(--line)}
.spec:nth-child(even){border-right:none}
.spec .k{font-size:9.5px;letter-spacing:0.08em;text-transform:uppercase;color:var(--ink-3);margin-bottom:4px}
.spec .v{font-family:"Space Grotesk",sans-serif;font-size:15px;font-weight:600}
.spec .v small{font-family:"JetBrains Mono",monospace;font-size:11px;color:var(--ink-3);font-weight:400}
.guide{padding:14px 16px;border-top:1px solid var(--line)}
.guide .gt{font-size:10px;letter-spacing:0.09em;text-transform:uppercase;color:var(--ink-3);margin-bottom:10px}
.guide table{width:100%;border-collapse:collapse;font-size:11px}
.guide td{padding:5px 0;color:var(--ink-2);vertical-align:top}
.guide td:first-child{font-family:"Space Grotesk",sans-serif;font-weight:600;color:var(--ink);width:64px;white-space:nowrap}
.guide tr.on td{color:var(--hi)}
.guide tr.on td:first-child{color:var(--hi)}
.warns{margin-top:0}
.warn{display:flex;gap:11px;align-items:flex-start;background:var(--warn-bg);border-top:1px solid var(--warn-line);padding:13px 16px;font-size:11.5px;color:var(--ink-2);line-height:1.5}
.warn svg{width:15px;height:15px;flex:0 0 15px;margin-top:1px;color:var(--ink)}
.warn strong{color:var(--ink);font-weight:600}
.note{display:flex;gap:11px;align-items:flex-start;padding:14px 16px;border-top:1px solid var(--line);font-size:11px;color:var(--ink-3);line-height:1.6}
.note svg{width:15px;height:15px;flex:0 0 15px;margin-top:2px;color:var(--ink-2)}
.note strong{color:var(--ink-2);font-weight:600}
footer{margin-top:34px;border-top:1px solid var(--line);padding-top:18px;display:flex;gap:11px;align-items:flex-start;color:var(--ink-3);font-size:11px;line-height:1.6;letter-spacing:0.01em}
footer svg{width:15px;height:15px;flex:0 0 15px;margin-top:2px;color:var(--ink-2)}
footer strong{color:var(--ink-2);font-weight:600}
:focus-visible{outline:2px solid var(--ink-2);outline-offset:2px}
@media(prefers-reduced-motion:reduce){*{transition:none!important}}
/* ---- Print build sheet ---- */
#printSheet{display:none}
@media print{
body{background:#fff!important;color:#000;background-image:none}
.wrap{max-width:100%;padding:0}
.no-print{display:none!important}
#printSheet{display:block;font-family:"JetBrains Mono",monospace;color:#000;padding:8px}
#printSheet h2{font-family:"Space Grotesk",sans-serif;font-size:20px;margin-bottom:2px}
#printSheet .psub{font-size:11px;color:#444;margin-bottom:16px;border-bottom:2px solid #000;padding-bottom:10px}
#printSheet .pgrid{display:grid;grid-template-columns:1fr 1fr;gap:0;border:1px solid #000;margin-bottom:14px}
#printSheet .pcell{border-right:1px solid #999;border-bottom:1px solid #999;padding:8px 10px}
#printSheet .pcell:nth-child(even){border-right:none}
#printSheet .pk{font-size:9px;text-transform:uppercase;letter-spacing:0.06em;color:#555;margin-bottom:3px}
#printSheet .pv{font-family:"Space Grotesk",sans-serif;font-weight:600;font-size:14px}
#printSheet .psec{font-size:10px;text-transform:uppercase;letter-spacing:0.08em;font-weight:600;margin:14px 0 6px;border-bottom:1px solid #000;padding-bottom:3px}
#printSheet .prow{display:flex;justify-content:space-between;font-size:12px;padding:3px 0;border-bottom:1px dotted #bbb}
#printSheet .pdisc{font-size:9.5px;color:#333;margin-top:16px;line-height:1.5;border-top:2px solid #000;padding-top:8px}
#printSheet .plogo{height:34px;width:auto;display:block;margin-bottom:12px}
#printSheet .pfoot{margin-top:14px;text-align:center;font-family:"Space Grotesk",sans-serif;font-size:12px;font-weight:600;letter-spacing:0.03em;color:#000}
@page{margin:14mm}
}
</style>
</head>
<body>
<div class="wrap">
<header class="no-print">
<div class="mark">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" color="var(--ink)">
<circle cx="6" cy="6" r="2.4"/><circle cx="18" cy="6" r="2.4"/><circle cx="6" cy="18" r="2.4"/><circle cx="18" cy="18" r="2.4"/>
<path d="M7.7 7.7 L16.3 16.3 M16.3 7.7 L7.7 16.3"/><rect x="9.6" y="9.6" width="4.8" height="4.8" rx="1"/>
</svg>
</div>
<div class="head-txt">
<h1 class="display">Drone Build Calculator</h1>
<div class="sub">Motor KV · Battery · Thrust-to-weight</div>
</div>
<div class="head-spacer"></div>
<div class="badge">Best-case estimator</div>
</header>
<div class="layout">
<!-- ============ INPUTS ============ -->
<div class="panel no-print">
<div class="panel-h">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M1 14h6M9 8h6M17 16h6"/></svg>
<span class="t">Build parameters</span><span class="n">INPUT</span>
</div>
<div class="panel-b">
<div class="field">
<label><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 3v18"/></svg>Frame / prop size</label>
<div class="seg" id="frameSeg"></div>
<div class="hint" id="frameHint"></div>
</div>
<div class="field">
<label><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="4.5"/><circle cx="12" cy="12" r="1"/></svg>Flight purpose / mode</label>
<div class="seg grid2" id="purposeSeg"></div>
<div class="hint" id="purposeHint"></div>
</div>
<div class="field">
<label><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="13" r="8"/><path d="M12 9v4l2.5 2.5M9 2h6"/></svg>Target endurance</label>
<div class="seg" id="enduranceSeg"></div>
<div class="inline" style="margin-top:8px"><input type="number" id="enduranceCustom" min="1" step="1" placeholder="Custom minutes" /><span class="unit">min</span></div>
<div class="hint">Flight time you want per charge. Longer targets need heavier packs.</div>
</div>
<div class="field">
<label><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M6 8h12l2 12H4L6 8Z"/><path d="M9 8a3 3 0 0 1 6 0"/></svg>Dry weight (no battery)</label>
<div class="inline"><input type="number" id="dryWeight" min="1" step="1" value="400" /><span class="unit">grams</span></div>
<button class="toggle-link" id="bdToggle" aria-expanded="false"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 6l6 6-6 6"/></svg><span>Build a breakdown instead</span></button>
<div class="fold grid" id="breakdown">
<div class="bd-row"><label>Frame + arms</label><input type="number" class="bd" data-k="frame" min="0" step="1" value="120"/></div>
<div class="bd-row"><label>Motors (all)</label><input type="number" class="bd" data-k="motors" min="0" step="1" value="120"/></div>
<div class="bd-row"><label>ESC / FC / wiring</label><input type="number" class="bd" data-k="elec" min="0" step="1" value="70"/></div>
<div class="bd-row"><label>Camera / VTX / GPS</label><input type="number" class="bd" data-k="fpv" min="0" step="1" value="60"/></div>
<div class="bd-row"><label>Propellers (all)</label><input type="number" class="bd" data-k="props" min="0" step="1" value="30"/></div>
<div class="bd-row"><label>Other fixed</label><input type="number" class="bd" data-k="other" min="0" step="1" value="0"/></div>
</div>
</div>
<div class="field">
<label><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M3 8h14l3 3-3 3H3z"/><path d="M20 11h1"/></svg>Extra add-on weight (headroom test)</label>
<div class="inline"><input type="number" id="miscWeight" min="0" step="1" value="0" /><span class="unit">grams</span></div>
<div class="hint">Optional. Weight you might add later — GoPro, gimbal, cargo. The current thrust-to-weight and safe zone update to show if the craft still handles it.</div>
</div>
<div class="field">
<label><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="3.5"/><path d="M12 2v4M12 18v4M2 12h4M18 12h4M5 5l2.8 2.8M16.2 16.2 19 19M19 5l-2.8 2.8M7.8 16.2 5 19"/></svg>Motor count</label>
<div class="seg" id="motorSeg"></div>
</div>
<div class="field">
<label><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="7" width="17" height="10" rx="2"/><path d="M22 10v4M6 12h3M11 12h3"/></svg>Battery chemistry</label>
<div class="seg" id="chemSeg"></div>
<div class="hint" id="chemHint"></div>
</div>
<div class="field">
<label><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M13 2 4 14h6l-1 8 9-12h-6l1-8Z"/></svg>Cell count · voltage (S)</label>
<div class="seg" id="cellSeg"></div>
<div class="hint" id="cellHint"></div>
</div>
<div class="field" style="margin-bottom:0">
<button class="toggle-link" id="knownToggle" aria-expanded="false" style="margin-top:0"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 6l6 6-6 6"/></svg><span>I already have a battery (enter its specs)</span></button>
<div class="fold grid" id="known">
<div class="bd-row"><label>Known capacity</label><input type="number" id="knownCap" min="0" step="50" placeholder="mAh"/></div>
<div class="bd-row"><label>Known weight</label><input type="number" id="knownWeight" min="0" step="1" placeholder="grams"/></div>
</div>
<div class="hint" id="knownHint" style="display:none">Using your battery. Endurance target becomes a comparison only.</div>
</div>
</div>
</div>
<!-- ============ RESULTS ============ -->
<div class="panel readout">
<div class="panel-h no-print">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3v18h18"/><path d="M7 14l3-4 3 2 4-6"/></svg>
<span class="t">Recommendation</span><span class="n">OUTPUT</span>
</div>
<div class="ro-tools no-print">
<button class="btn" id="printBtn"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M6 9V3h12v6M6 18H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="7"/></svg>Print / Save PDF</button>
</div>
<!-- Expected vs Current TWR (signature) -->
<div class="gauge-wrap no-print">
<div class="gauge-top"><span class="k">Thrust-to-weight (lift power)</span></div>
<div class="twin">
<div class="cell"><div class="cl">By design (no add-ons)</div><div class="cv" id="twrExp">2.0<small>:1</small></div><div class="cq" id="twrExpQ"></div></div>
<div class="cell"><div class="cl">Right now</div><div class="cv" id="twrCur">2.0<small>:1</small></div><div class="cq" id="twrCurQ"></div></div>
</div>
<div class="gauge-track"><div class="gauge-fill" id="twrFill" style="width:33%"></div><div class="gauge-target" id="twrTarget" style="left:33%"></div></div>
<div class="gauge-scale"><span>1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6+</span></div>
<div class="gauge-note" id="twrNote"></div>
<div class="verdict" id="verdict"></div>
<div class="suggest" id="suggest"></div>
</div>
<div class="readout-grid no-print">
<div class="ro">
<div class="ro-ic"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="3.5"/><path d="M12 2v4M12 18v4M2 12h4M18 12h4M5 5l2.8 2.8M16.2 16.2 19 19M19 5l-2.8 2.8M7.8 16.2 5 19"/></svg></div>
<div class="ro-txt"><div class="k">Motor KV</div><div class="v" id="kvVal">—</div><div class="meta" id="kvMeta"></div></div>
</div>
<div class="ro">
<div class="ro-ic"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="8" width="15" height="4" rx="1"/><path d="M6 6v2M12 6v2M20 8v4"/><path d="M4.5 15h12" stroke-dasharray="2 2"/></svg></div>
<div class="ro-txt"><div class="k">Propeller</div><div class="v" id="propVal">—</div><div class="meta" id="propMeta"></div></div>
</div>
<div class="ro">
<div class="ro-ic"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="7" width="17" height="10" rx="2"/><path d="M22 10v4"/><path d="M6.5 12h8" stroke-width="2"/></svg></div>
<div class="ro-txt"><div class="k">Battery composition</div><div class="v" id="battVal">—</div><div class="meta" id="battMeta"></div></div>
</div>
<div class="ro">
<div class="ro-ic"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="13" r="8"/><path d="M12 9v4l2.5 2.5M9 2h6"/></svg></div>
<div class="ro-txt"><div class="k">Estimated flight time</div><div class="v" id="timeVal">—</div><div class="meta" id="timeMeta"></div></div>
</div>
<div class="ro">
<div class="ro-ic"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 3v6M12 3l-3 3M12 3l3 3"/><path d="M4 13h16l-1 8H5z"/><path d="M9 13a3 3 0 0 1 6 0"/></svg></div>
<div class="ro-txt"><div class="k">Safe zone — extra weight you can still add</div><div class="v" id="safeVal">—</div><div class="meta" id="safeMeta"></div></div>
</div>
</div>
<div class="specrow no-print">
<div class="spec"><div class="k">Thrust / motor</div><div class="v" id="thrustVal">—</div></div>
<div class="spec"><div class="k">All-up weight</div><div class="v" id="auwVal">—</div></div>
<div class="spec"><div class="k">Discharge rating</div><div class="v" id="cVal">—</div></div>
<div class="spec"><div class="k">ESC current</div><div class="v" id="escVal">—</div></div>
<div class="spec"><div class="k">Motor stator</div><div class="v" id="statorVal">—</div></div>
<div class="spec"><div class="k">Hover throttle</div><div class="v" id="hoverVal">—</div></div>
</div>
<div class="guide no-print">
<div class="gt">Thrust-to-weight guide</div>
<table id="twrGuide">
<tr data-lo="0" data-hi="1.8"><td>< 2:1</td><td>Underpowered — may struggle to climb or fight wind.</td></tr>
<tr data-lo="1.8" data-hi="2.5"><td>2–2.5:1</td><td>Minimum to fly. Fine for smooth cinematic and heavy lift.</td></tr>
<tr data-lo="2.5" data-hi="3.5"><td>2.5–3.5:1</td><td>Good all-round. Stable with useful power in reserve.</td></tr>
<tr data-lo="3.5" data-hi="5"><td>3.5–5:1</td><td>Strong. Sport flying and freestyle.</td></tr>
<tr data-lo="5" data-hi="8"><td>5–8:1</td><td>Aggressive. Racing and hard acro.</td></tr>
<tr data-lo="8" data-hi="999"><td>8:1 +</td><td>Extreme. Twitchy; needs a smooth throttle hand.</td></tr>
</table>
</div>
<div class="note no-print">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="9"/><path d="M12 8h.01M11 12h1v4h1"/></svg>
<div><strong>These are best-case numbers.</strong> They assume ideal hover efficiency, fresh fully-charged cells, no wind, and smooth flying. In the real world, expect roughly 15–30% less flight time and plan a safety margin on thrust and current.</div>
</div>
<div class="warns no-print" id="warns"></div>
</div>
</div>
<!-- Printable build sheet -->
<div id="printSheet"></div>
<footer class="no-print">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="9"/><path d="M12 8h.01M11 12h1v4h1"/></svg>
<div><strong>Approximate estimates, not exact figures.</strong> Outputs come from generalized propulsion models and do not account for your specific motor, propeller and ESC combination, air density, wind, throttle habits, or wiring losses. Always confirm against real manufacturer thrust-test data before buying parts or flying.</div>
</footer>
</div>
<script>
"use strict";
/* ---------- Reference data ---------- */
const FRAMES = [
{id:"3in", label:'3"', dia:3, cells:4, cat:"Micro / cinewhoop", stator:"1404-1507", prop:'3"'},
{id:"5in", label:'5"', dia:5, cells:6, cat:"Freestyle / racing", stator:"2207-2306", prop:'5"'},
{id:"6in", label:'6"', dia:6, cells:6, cat:"Light long-range", stator:"2506-2507", prop:'6"'},
{id:"7in", label:'7"', dia:7, cells:6, cat:"Long-range cruiser", stator:"2807", prop:'7"'},
{id:"10in", label:'10"', dia:10, cells:6, cat:"Cinelifter / heavy", stator:"2814-3115", prop:'10"'},
{id:"s250", label:"S250", dia:6, cells:4, cat:"250mm quad frame", stator:"2205-2306", prop:'6" (6045)'},
{id:"s450", label:"S450", dia:9.5,cells:4, cat:"450mm quad frame", stator:"2213-2216", prop:'9.5" (9443)'},
{id:"s500", label:"S500", dia:10, cells:4, cat:"500mm quad frame", stator:"2814-2820", prop:'10" (1045)'},
];
const PURPOSES = [
{id:"angle", label:"Angle / Cinematic", desc:"Smooth, self-level", twr:2.0, act:1.0},
{id:"horizon", label:"Horizon / General", desc:"Balanced everyday", twr:3.0, act:1.35},
{id:"acro", label:"Acro / Freestyle", desc:"Full manual, flips", twr:4.5, act:1.9},
{id:"racing", label:"Racing", desc:"Max response", twr:7.0, act:2.6},
{id:"endurance", label:"Efficiency / LR", desc:"Max flight time", twr:2.0, act:0.95},
];
const ENDURANCE = [5,10,15,20,30,45,60,90,120];
const MOTORS = [3,4,6,8];
const CHEM = [
{id:"lipo", label:"LiPo", density:165, cellNom:3.7, cellFull:4.2, usable:0.80, note:"Best power density; standard for FPV. Sold as single packs, so P stays 1.", multiP:false, cell:0},
{id:"lihv", label:"LiHV", density:178, cellNom:3.8, cellFull:4.35,usable:0.80, note:"A little more energy; charged to 4.35V per cell. P stays 1.", multiP:false, cell:0},
{id:"liion", label:"Li-ion", density:245, cellNom:3.6, cellFull:4.2, usable:0.85, note:"Highest energy but low current limit. Long-range only; P is built up from cells.", multiP:true, cell:5000},
];
const CELLS = [3,4,6,8,12];
const SAFE_FLOOR = 2.0; // minimum thrust-to-weight considered flyable
/* ---------- State ---------- */
const state = {frame:"5in",purpose:"angle",endurance:10,endCustom:false,motors:4,chem:"lipo",cells:6,cellAuto:true,useBreakdown:false,useKnown:false};
/* ---------- Helpers ---------- */
const $ = s => document.querySelector(s);
const el = (t,c)=>{const e=document.createElement(t);if(c)e.className=c;return e;};
const frame=()=>FRAMES.find(f=>f.id===state.frame);
const purpose=()=>PURPOSES.find(p=>p.id===state.purpose);
const chem=()=>CHEM.find(c=>c.id===state.chem);
function interp(pts,x){if(x<=pts[0][0])return pts[0][1];if(x>=pts[pts.length-1][0])return pts[pts.length-1][1];for(let i=0;i<pts.length-1;i++){const[x0,y0]=pts[i],[x1,y1]=pts[i+1];if(x>=x0&&x<=x1)return y0+(y1-y0)*(x-x0)/(x1-x0);}return pts[pts.length-1][1];}
function effByDia(d){return interp([[3,3.6],[5,5.6],[7,8.6],[10,11.2],[12,12.5]],d);}
function refKV6S(d){return interp([[3,2800],[5,1850],[6,1500],[7,1350],[10,550],[12,430]],d);}
function roundCap(m){return m<3000?Math.round(m/50)*50:Math.round(m/100)*100;}
function fmt(n,dp=0){return n.toLocaleString(undefined,{minimumFractionDigits:dp,maximumFractionDigits:dp});}
function twrLabel(t){if(t<1.5)return"Won't fly";if(t<2)return"Barely flies";if(t<2.5)return"Minimum OK";if(t<3.5)return"Good";if(t<5)return"Strong";if(t<8)return"Racing";return"Extreme";}
function verdict(t){
if(t<1.5)return{flyable:false,bad:true,title:"Too heavy \u2014 will not fly",msg:"Thrust barely exceeds weight, so it can't lift off with real control. This build needs changes before flying."};
if(t<2.0)return{flyable:false,bad:true,title:"Underpowered \u2014 not recommended",msg:"It may leave the ground, but feels heavy and can't handle wind or quick moves. Treat this as not flyable."};
if(t<2.5)return{flyable:true,bad:false,title:"Yes \u2014 flies with minimum healthy power",msg:"Enough to fly steadily. Good for smooth cinematic and lifting, with little thrust to spare."};
if(t<3.5)return{flyable:true,bad:false,title:"Yes \u2014 flies well",msg:"Solid power with a healthy reserve for maneuvers and wind."};
if(t<5)return{flyable:true,bad:false,title:"Yes \u2014 strong power",msg:"Plenty of thrust for sport and freestyle flying."};
return{flyable:true,bad:false,title:"Yes \u2014 very high power",msg:"Lots of thrust. Responsive but can feel twitchy; a smooth throttle helps."};
}
function propType(p,d){
if(p.id==="endurance")return"2-blade (efficiency), higher pitch";
if(p.id==="racing")return"3-blade, low-pitch racing";
if(p.id==="angle"&&d>=7)return"2-blade or 3-blade, smooth pitch";
return"3-blade (triblade), balanced pitch";
}
function getDryWeight(){
if(state.useBreakdown){let s=0;document.querySelectorAll(".bd").forEach(i=>s+=(parseFloat(i.value)||0));return Math.max(1,s);}
return Math.max(1,parseFloat($("#dryWeight").value)||1);
}
/* ---------- Core calculation ---------- */
function calc(){
const f=frame(),p=purpose(),c=chem();
const S=state.cells, Vnom=S*c.cellNom, Vfull=S*c.cellFull, dia=f.dia;
const eff=effByDia(dia), usable=c.usable, density=c.density, t_h=state.endurance/60;
const W0=getDryWeight();
const misc=Math.max(0,parseFloat($("#miscWeight").value)||0);
const knownCap=state.useKnown?Math.max(0,parseFloat($("#knownCap").value)||0):0;
const knownWt =state.useKnown?Math.max(0,parseFloat($("#knownWeight").value)||0):0;
const measured = knownCap>0 || knownWt>0;
// --- Battery weight & capacity ---
let Wb, capMah, feasible=true, capped=false;
if(measured){
if(knownWt>0){Wb=knownWt;} else {Wb=(knownCap/1000)*Vnom/density*1000;}
if(knownCap>0){capMah=knownCap;} else {capMah=(Wb/1000*density)/Vnom*1000;}
}else{
// solver: battery mass feeds back into hover power
const A=(p.act*t_h)/(eff*usable*density)*1000;
feasible=A>0&&A<1;
Wb=feasible?(W0*A)/(1-A):Infinity;
if(!feasible||Wb>W0*3){capped=Wb>W0*3;Wb=Math.min(Wb,W0*3);if(!feasible)Wb=W0*3;}
capMah=(Wb/1000*density)/Vnom*1000;
}
const baseAUW=W0+Wb; // dry + battery (design weight)
const currentAUW=baseAUW+misc; // with add-ons (real weight)
// --- Battery config SxP ---
let pCount=1,cfg,capDisplay;
if(c.multiP){
pCount=Math.max(1,Math.round(capMah/c.cell));
if(!measured||knownCap<=0)capMah=pCount*c.cell;
cfg=S+"S"+pCount+"P"; capDisplay=fmt(Math.round(capMah))+" mAh";
}else{
if(!measured)capMah=roundCap(capMah);
cfg=S+"S1P"; capDisplay=fmt(Math.round(capMah))+" mAh";
}
// --- Motor KV (reference at 6S, scaled by voltage) ---
const kvCenter=refKV6S(dia)*(6*c.cellNom)/Vnom;
const kvLo=Math.round(kvCenter*0.88/10)*10, kvHi=Math.round(kvCenter*1.15/10)*10;
// --- Thrust sized to expected TWR on the DESIGN weight ---
const expTWR=p.twr;
const totalThrust=expTWR*baseAUW; // total available thrust (g)
const thrustPerMotor=totalThrust/state.motors;
const curTWR=totalThrust/currentAUW; // real TWR with add-ons
// --- Safe headroom: extra grams until TWR hits floor ---
const safeExtra=(totalThrust/SAFE_FLOOR)-currentAUW;
// --- Flight time from actual pack + real weight ---
const capAh=capMah/1000;
const P_hover=currentAUW/eff, P_avg=P_hover*p.act;
const usableWh=capAh*Vnom*usable;
const flightMin=usableWh/P_avg*60;
const hoverThrottlePct=Math.min(99,Math.round(1/curTWR*100));
// --- Current / C-rating ---
const P_full=P_hover*p.twr, I_full=P_full/Vnom;
const cNeeded=I_full/capAh;
const cRec=Math.max(10,Math.ceil(cNeeded*1.3/5)*5);
const escRec=Math.ceil(I_full/state.motors*1.3/5)*5;
return {f,p,c,S,Vnom,Vfull,dia,eff,W0,Wb,misc,baseAUW,currentAUW,capMah,capDisplay,cfg,pCount,
kvLo,kvHi,kvCenter,expTWR,curTWR,totalThrust,thrustPerMotor,safeExtra,cRec,escRec,
flightMin,feasible,capped,measured,P_avg,hoverThrottlePct};
}
/* ---------- Render ---------- */
function render(){
paintSegs();
const r=calc();
// TWR twin + gauge (gauge tracks CURRENT)
$("#twrExp").innerHTML=r.expTWR.toFixed(1)+'<small>:1</small>';
$("#twrExpQ").textContent=twrLabel(r.expTWR);
$("#twrCur").innerHTML=r.curTWR.toFixed(1)+'<small>:1</small>';
$("#twrCurQ").textContent=twrLabel(r.curTWR);
$("#twrFill").style.width=Math.min(100,r.curTWR/6*100)+"%";
$("#twrTarget").style.left=Math.min(100,r.expTWR/6*100)+"%";
$("#twrNote").textContent=r.misc>0
? `The line is your design target. The bar is where you are now, after adding ${fmt(r.misc)} g.`
: `The line is your design target. Add extra weight above to watch the bar (your real lift power) drop.`;
// Clear verdict: will it fly?
const vd=verdict(r.curTWR);
const vEl=$("#verdict");
vEl.className="verdict"+(vd.bad?" bad":"");
const vIcon=vd.bad
? `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3 2 20h20L12 3Z"/><path d="M12 10v4M12 17h.01"/></svg>`
: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>`;
vEl.innerHTML=`${vIcon}<div><span class="vt">${vd.title}</span><span class="vm">${vd.msg}</span></div>`;
// Fix-it suggestions when it can't fly properly
const sEl=$("#suggest");
if(r.curTWR<SAFE_FLOOR){
const removeG=Math.max(0,Math.ceil(r.currentAUW-r.totalThrust/SAFE_FLOOR));
const healthyPer=Math.ceil(2.5*r.currentAUW/state.motors);
const items=[
`Cut about <strong>${fmt(removeG)} g</strong> of weight \u2014 a lighter battery or dropping payload brings it back to a safe ${SAFE_FLOOR.toFixed(1)}:1.`,
`Or use motors + props that each make at least <strong>${fmt(healthyPer)} g</strong> of thrust (higher-KV motors, a larger prop, or one more cell of voltage) for a comfortable 2.5:1.`,
`Or add motors \u2014 going from ${state.motors} to ${state.motors+2} raises total thrust.`
];
sEl.className="suggest show";
sEl.innerHTML=`<div class="st">How to make it fly better</div><ul>${items.map(i=>`<li>${i}</li>`).join("")}</ul>`;
}else{
sEl.className="suggest";sEl.innerHTML="";
}
// Highlight the guide row matching current TWR
document.querySelectorAll("#twrGuide tr").forEach(tr=>{
const lo=+tr.dataset.lo,hi=+tr.dataset.hi;
tr.classList.toggle("on",r.curTWR>=lo&&r.curTWR<hi);
});
// Motor KV
$("#kvVal").innerHTML=fmt(r.kvLo)+"–"+fmt(r.kvHi)+" <small>KV</small>";
$("#kvMeta").textContent=`Center ~${fmt(Math.round(r.kvCenter/10)*10)} KV for ${r.dia}" props on ${r.S}S (${r.Vnom.toFixed(1)}V).`;
// Prop
$("#propVal").innerHTML=r.f.prop;
$("#propMeta").textContent=propType(r.p,r.dia);
// Battery composition
$("#battVal").innerHTML=r.cfg+" · "+r.capDisplay;
let bm=`${r.c.label} · suggest ${r.S}S (${r.Vnom.toFixed(1)}V nom / ${r.Vfull.toFixed(1)}V full) · P stays ${r.pCount} · ~${fmt(Math.round(r.Wb))} g`;
if(r.c.multiP)bm+=` · ${r.pCount}× ${fmt(r.c.cell)}mAh 21700`;
$("#battMeta").innerHTML=bm;
// Flight time
if(r.measured){
$("#timeVal").innerHTML="~"+fmt(r.flightMin,0)+" min";
$("#timeMeta").textContent=`From your pack (${r.capDisplay}). You asked for ${state.endurance} min.`;
}else if(!r.feasible){
$("#timeVal").innerHTML="~"+fmt(r.flightMin,0)+" min <small>max</small>";
$("#timeMeta").textContent=`Target not reachable with ${r.c.label} — this is the practical ceiling.`;
}else{
$("#timeVal").innerHTML="~"+fmt(r.flightMin,0)+" min";
$("#timeMeta").textContent=`At ~${fmt(r.P_avg,0)} W average for this flight mode.`;
}
// Safe zone
if(r.safeExtra>=0){
$("#safeVal").innerHTML="+"+fmt(Math.round(r.safeExtra))+" <small>g</small>";
$("#safeMeta").textContent=`More payload you can add before thrust-to-weight drops to the ${SAFE_FLOOR.toFixed(1)}:1 floor.`;
}else{
$("#safeVal").innerHTML=fmt(Math.round(r.safeExtra))+" <small>g over</small>";
$("#safeMeta").textContent=`Over the safe floor. Remove ~${fmt(Math.round(-r.safeExtra))} g or fit stronger motors.`;
}
// Specs
$("#thrustVal").innerHTML=fmt(r.thrustPerMotor)+" <small>g</small>";
$("#auwVal").innerHTML=fmt(Math.round(r.currentAUW))+" <small>g</small>";
$("#cVal").innerHTML=r.cRec+"C <small>min</small>";
$("#escVal").innerHTML=r.escRec+"A <small>/motor</small>";
$("#statorVal").innerHTML=r.f.stator;
$("#hoverVal").innerHTML=r.hoverThrottlePct+"% <small>thr</small>";
// Warnings
const w=$("#warns");w.innerHTML="";const list=[];
if(!r.measured&&!r.feasible)list.push(`<strong>${state.endurance} min isn't achievable</strong> on a multirotor with ${r.c.label}. Sustained hover has a hard energy limit — beyond ~1 hour usually needs Li-ion, a very efficient build, or a fixed wing.`);
else if(!r.measured&&r.Wb>r.W0*1.6)list.push(`<strong>Battery-dominated build.</strong> The pack (~${fmt(Math.round(r.Wb))} g) outweighs the rest of the craft. Possible, but handling suffers. Try Li-ion and larger, lower-KV props.`);
if(r.curTWR<SAFE_FLOOR)list.push(`<strong>Below the safe floor.</strong> Current thrust-to-weight is ${r.curTWR.toFixed(1)}:1 — under ${SAFE_FLOOR.toFixed(1)}:1 the craft may not climb or fight wind. Cut weight or fit stronger motors.`);
if(r.p.twr>=5&&r.dia>=7)list.push(`<strong>High thrust-to-weight on a large prop.</strong> ${r.p.twr.toFixed(1)}:1 on ${r.dia}" props needs heavy current — check the ESC (${r.escRec}A/motor) and pack C-rating.`);
if(state.chem==="liion"&&r.p.twr>3)list.push(`<strong>Li-ion + aggressive flying don't mix.</strong> Li-ion has low discharge limits; it suits smooth cruising, not acro or racing bursts.`);
list.forEach(t=>{const d=el("div","warn");d.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3 2 20h20L12 3Z"/><path d="M12 10v4M12 17h.01"/></svg><div>${t}</div>`;w.appendChild(d);});
buildPrintSheet(r);
}
/* ---------- Print sheet ---------- */
function buildPrintSheet(r){
const now=new Date().toLocaleString();
const vd=verdict(r.curTWR);
const timeTxt=r.measured?`~${fmt(r.flightMin,0)} min (your pack)`:(!r.feasible?`~${fmt(r.flightMin,0)} min max`:`~${fmt(r.flightMin,0)} min`);
const safeTxt=r.safeExtra>=0?`+${fmt(Math.round(r.safeExtra))} g headroom`:`${fmt(Math.round(-r.safeExtra))} g over floor`;
$("#printSheet").innerHTML=`
<img class="plogo" src="https://beebotix.com/beebotix-logo.svg" alt="BeeBotix" />
<h2>Drone Build Sheet</h2>
<div class="psub">Best-case estimate · generated ${now}</div>
<div class="psec">Inputs</div>
<div class="pgrid">
<div class="pcell"><div class="pk">Frame / prop</div><div class="pv">${r.f.label} · ${r.f.cat}</div></div>
<div class="pcell"><div class="pk">Flight mode</div><div class="pv">${r.p.label}</div></div>
<div class="pcell"><div class="pk">Target endurance</div><div class="pv">${state.endurance} min</div></div>
<div class="pcell"><div class="pk">Motors</div><div class="pv">${state.motors}</div></div>
<div class="pcell"><div class="pk">Dry weight</div><div class="pv">${fmt(r.W0)} g</div></div>
<div class="pcell"><div class="pk">Add-on weight</div><div class="pv">${fmt(r.misc)} g</div></div>
</div>
<div class="psec">Recommendation</div>
<div class="pgrid">
<div class="pcell"><div class="pk">Motor KV</div><div class="pv">${fmt(r.kvLo)}-${fmt(r.kvHi)} KV</div></div>
<div class="pcell"><div class="pk">Motor stator</div><div class="pv">${r.f.stator}</div></div>
<div class="pcell"><div class="pk">Propeller</div><div class="pv">${r.f.prop} · ${propType(r.p,r.dia)}</div></div>
<div class="pcell"><div class="pk">Battery</div><div class="pv">${r.cfg} ${r.c.label} · ${r.capDisplay}</div></div>
<div class="pcell"><div class="pk">Pack voltage</div><div class="pv">${r.Vnom.toFixed(1)}V nom / ${r.Vfull.toFixed(1)}V full</div></div>
<div class="pcell"><div class="pk">Est. pack weight</div><div class="pv">~${fmt(Math.round(r.Wb))} g</div></div>
</div>
<div class="psec">Performance</div>
<div class="prow"><span>Will it fly?</span><strong>${vd.flyable?"YES":"NO"} · ${vd.title.replace(/\u2014/g,"-")}</strong></div>
<div class="prow"><span>Design thrust-to-weight (no add-ons)</span><strong>${r.expTWR.toFixed(1)}:1 · ${twrLabel(r.expTWR)}</strong></div>
<div class="prow"><span>Thrust-to-weight right now (with add-ons)</span><strong>${r.curTWR.toFixed(1)}:1 · ${twrLabel(r.curTWR)}</strong></div>
<div class="prow"><span>Safe zone</span><strong>${safeTxt}</strong></div>
<div class="prow"><span>Thrust per motor</span><strong>${fmt(r.thrustPerMotor)} g</strong></div>
<div class="prow"><span>All-up weight</span><strong>${fmt(Math.round(r.currentAUW))} g</strong></div>
<div class="prow"><span>Estimated flight time</span><strong>${timeTxt}</strong></div>
<div class="prow"><span>Min discharge rating</span><strong>${r.cRec}C</strong></div>
<div class="prow"><span>ESC current</span><strong>${r.escRec}A per motor</strong></div>
<div class="prow"><span>Hover throttle</span><strong>~${r.hoverThrottlePct}%</strong></div>
<div class="pdisc"><strong>Best-case, approximate.</strong> Assumes ideal hover efficiency, fresh cells, no wind, smooth flying. Real flight time is typically 15-30% lower. Verify against manufacturer motor + prop thrust data and keep a safety margin before buying or flying.</div>
<div class="pfoot">Maintained by BeeBotix · Happy and Safe Flight</div>`;
}
/* ---------- Build UI (once) ---------- */
function seg(container,items,group,valOf,labelHTML){
container.innerHTML="";
items.forEach(it=>{
const b=el("button");b.type="button";b.dataset.group=group;b.dataset.val=valOf(it);
b.innerHTML=labelHTML(it);
b.addEventListener("click",()=>onPick(group,valOf(it)));
container.appendChild(b);
});
}
function onPick(group,val){
if(group==="frame"){state.frame=val;if(state.cellAuto)state.cells=frame().cells;$("#frameHint").textContent=`${frame().cat} · typical props ${frame().prop}`;}
else if(group==="purpose"){state.purpose=val;$("#purposeHint").textContent=`Target thrust-to-weight ~${purpose().twr.toFixed(1)}:1`;}
else if(group==="endurance"){state.endurance=+val;state.endCustom=false;$("#enduranceCustom").value="";}
else if(group==="motors"){state.motors=+val;}
else if(group==="chem"){state.chem=val;$("#chemHint").textContent=chem().note;}
else if(group==="cells"){state.cells=+val;state.cellAuto=false;$("#cellHint").textContent=cellHintTxt();}
render();
}
function cellHintTxt(){return `${state.cells}S selected${state.cellAuto?" (auto for this frame)":""}. Higher S = higher voltage, lower KV.`;}
function paintSegs(){
document.querySelectorAll(".seg button").forEach(b=>{
const g=b.dataset.group,v=b.dataset.val;let on=false;
if(g==="frame")on=v===state.frame;
else if(g==="purpose")on=v===state.purpose;
else if(g==="endurance")on=!state.endCustom&&+v===state.endurance;
else if(g==="motors")on=+v===state.motors;
else if(g==="chem")on=v===state.chem;
else if(g==="cells")on=+v===state.cells;
b.setAttribute("aria-pressed",on?"true":"false");
});
}
function buildUI(){
seg($("#frameSeg"),FRAMES,"frame",f=>f.id,f=>f.label);
seg($("#purposeSeg"),PURPOSES,"purpose",p=>p.id,p=>`<span class="lbl">${p.label}</span><span class="desc">${p.desc}</span>`);
seg($("#enduranceSeg"),ENDURANCE,"endurance",v=>v,v=>v>=60?(v/60)+"h":v+"m");
seg($("#motorSeg"),MOTORS,"motors",v=>v,v=>v);
seg($("#chemSeg"),CHEM,"chem",c=>c.id,c=>c.label);
seg($("#cellSeg"),CELLS,"cells",v=>v,v=>v+"S");
$("#frameHint").textContent=`${frame().cat} · typical props ${frame().prop}`;
$("#purposeHint").textContent=`Target thrust-to-weight ~${purpose().twr.toFixed(1)}:1`;
$("#chemHint").textContent=chem().note;
$("#cellHint").textContent=cellHintTxt();
}
/* ---------- Wire inputs ---------- */
function wire(){
$("#enduranceCustom").addEventListener("input",e=>{const v=parseInt(e.target.value,10);if(v>0){state.endurance=v;state.endCustom=true;}render();});
$("#dryWeight").addEventListener("input",()=>{if(!state.useBreakdown)render();});
$("#miscWeight").addEventListener("input",render);
$("#knownCap").addEventListener("input",render);
$("#knownWeight").addEventListener("input",render);
document.querySelectorAll(".bd").forEach(i=>i.addEventListener("input",()=>{if(state.useBreakdown)render();}));
$("#bdToggle").addEventListener("click",()=>{
state.useBreakdown=!state.useBreakdown;
$("#bdToggle").setAttribute("aria-expanded",state.useBreakdown?"true":"false");
$("#breakdown").classList.toggle("open",state.useBreakdown);
$("#bdToggle").querySelector("span").textContent=state.useBreakdown?"Use a single weight instead":"Build a breakdown instead";
if(state.useBreakdown)$("#dryWeight").value=fmt(getDryWeight());
render();
});
$("#knownToggle").addEventListener("click",()=>{
state.useKnown=!state.useKnown;
$("#knownToggle").setAttribute("aria-expanded",state.useKnown?"true":"false");
$("#known").classList.toggle("open",state.useKnown);
$("#knownHint").style.display=state.useKnown?"block":"none";
$("#knownToggle").querySelector("span").textContent=state.useKnown?"Estimate the battery for me instead":"I already have a battery (enter its specs)";
render();
});
$("#printBtn").addEventListener("click",()=>window.print());
}
/* ---------- Init ---------- */
buildUI();wire();render();
</script>
</body>
</html>