-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
671 lines (574 loc) · 19.4 KB
/
index.html
File metadata and controls
671 lines (574 loc) · 19.4 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bee IMG to INO Converter</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
overflow: hidden;
}
/* Header with Bee Theme */
.header {
background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
padding: 30px;
text-align: center;
border-bottom: 5px solid #ff9a3c;
position: relative;
overflow: hidden;
}
.header::before {
content: "🐝";
font-size: 120px;
position: absolute;
left: 20px;
top: 20px;
opacity: 0.1;
transform: rotate(-15deg);
}
.header::after {
content: "🐝";
font-size: 120px;
position: absolute;
right: 20px;
bottom: 20px;
opacity: 0.1;
transform: rotate(15deg);
}
.header h1 {
font-size: 48px;
color: #fff;
text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
margin-bottom: 10px;
}
.header h1 span {
background: #333;
color: #ffd700;
padding: 5px 15px;
border-radius: 50px;
font-size: 24px;
vertical-align: middle;
margin-left: 10px;
}
.header p {
color: #fff;
font-size: 18px;
opacity: 0.9;
}
/* Info Cards */
.info-section {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
padding: 30px;
background: #f8f9fa;
}
.info-card {
background: white;
border-radius: 15px;
padding: 25px;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
transition: transform 0.3s;
border-left: 5px solid #ff9a3c;
}
.info-card:hover {
transform: translateY(-5px);
}
.info-card h3 {
color: #333;
font-size: 20px;
margin-bottom: 15px;
display: flex;
align-items: center;
gap: 10px;
}
.info-card h3 span {
font-size: 24px;
}
.info-card p {
color: #666;
line-height: 1.6;
margin-bottom: 10px;
}
.info-card ul {
list-style: none;
padding: 0;
}
.info-card li {
padding: 8px 0;
color: #555;
border-bottom: 1px solid #eee;
}
.info-card li:last-child {
border-bottom: none;
}
.info-card li::before {
content: "🐝";
margin-right: 10px;
font-size: 14px;
}
/* Pin Configuration */
.pin-config {
background: white;
padding: 30px;
border-radius: 15px;
margin: 20px 30px;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.pin-config h2 {
color: #333;
margin-bottom: 20px;
display: flex;
align-items: center;
gap: 10px;
}
.pin-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
}
.pin-item {
background: #f8f9fa;
padding: 15px;
border-radius: 10px;
border: 2px solid #eee;
}
.pin-item label {
display: block;
color: #666;
margin-bottom: 5px;
font-weight: bold;
}
.pin-item input {
width: 100%;
padding: 8px;
border: 2px solid #ddd;
border-radius: 5px;
font-size: 16px;
transition: border 0.3s;
}
.pin-item input:focus {
border-color: #ff9a3c;
outline: none;
}
.pin-item .default {
font-size: 12px;
color: #999;
margin-top: 5px;
}
/* Upload Section */
.upload-section {
background: linear-gradient(135deg, #667eea20 0%, #764ba220 100%);
padding: 30px;
margin: 20px 30px;
border-radius: 15px;
text-align: center;
}
.upload-box {
border: 3px dashed #ff9a3c;
border-radius: 15px;
padding: 40px;
background: white;
cursor: pointer;
transition: all 0.3s;
}
.upload-box:hover {
border-color: #f6d365;
background: #fff9f0;
}
.upload-box i {
font-size: 48px;
color: #ff9a3c;
margin-bottom: 10px;
}
.upload-box h3 {
color: #333;
margin-bottom: 10px;
}
.upload-box p {
color: #666;
margin-bottom: 15px;
}
.upload-btn {
background: #ff9a3c;
color: white;
border: none;
padding: 12px 30px;
border-radius: 25px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
transition: background 0.3s;
}
.upload-btn:hover {
background: #f6d365;
}
#imagePreview {
max-width: 120px;
max-height: 120px;
margin: 15px auto;
border-radius: 10px;
border: 3px solid #ff9a3c;
display: none;
}
/* Output Section */
.output-section {
padding: 30px;
background: #2d2d2d;
margin: 20px 30px;
border-radius: 15px;
color: #fff;
}
.output-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.output-header h3 {
color: #ffd700;
}
.output-buttons {
display: flex;
gap: 10px;
}
.output-btn {
background: #ff9a3c;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
transition: all 0.3s;
font-size: 14px;
}
.output-btn:hover {
background: #f6d365;
transform: scale(1.05);
}
.output-btn.copy {
background: #4CAF50;
}
.output-btn.copy:hover {
background: #45a049;
}
.output-btn.download {
background: #2196F3;
}
.output-btn.download:hover {
background: #1e88e5;
}
#outputCode {
background: #1e1e1e;
color: #d4d4d4;
padding: 20px;
border-radius: 10px;
font-family: 'Courier New', monospace;
font-size: 14px;
line-height: 1.5;
max-height: 400px;
overflow-y: auto;
white-space: pre-wrap;
border: 1px solid #444;
margin-top: 15px;
}
/* Footer */
.footer {
background: #333;
color: #fff;
text-align: center;
padding: 20px;
margin-top: 30px;
}
.footer p {
margin: 5px 0;
color: #999;
}
.footer a {
color: #ffd700;
text-decoration: none;
}
/* Loading Spinner */
.spinner {
border: 4px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top: 4px solid #ff9a3c;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
margin: 20px auto;
display: none;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* Responsive */
@media (max-width: 768px) {
.header h1 {
font-size: 32px;
}
.header::before,
.header::after {
font-size: 80px;
}
.info-section {
grid-template-columns: 1fr;
}
.pin-grid {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>Bee IMG to INO Converter <span>🐝</span></h1>
<p>Transform your images into Arduino code for GC9A01A displays!</p>
</div>
<div class="info-section">
<div class="info-card">
<h3><span>📌</span> What is this?</h3>
<p>A specialized tool that converts your images into Arduino code for GC9A01A round displays. Perfect for ESP32 projects!</p>
<ul>
<li>240x240 RGB565 format</li>
<li>Optimized for GC9A01A</li>
<li>ESP32 ready</li>
<li>PROGMEM compatible</li>
</ul>
</div>
<div class="info-card">
<h3><span>📋</span> How to Use</h3>
<ul>
<li>1. Prepare a 240x240 pixel image</li>
<li>2. Configure your pin connections</li>
<li>3. Upload your image below</li>
<li>4. Copy code to clipboard</li>
<li>5. Paste in Arduino IDE</li>
<li>6. Upload to ESP32!</li>
</ul>
</div>
<div class="info-card">
<h3><span>🔌</span> Pin Connections</h3>
<ul>
<li>VCC → 3.3V</li>
<li>GND → GND</li>
<li>SCL → GPIO 18 (Configurable)</li>
<li>SDA → GPIO 23 (Configurable)</li>
<li>CS → GPIO 15 (Configurable)</li>
<li>DC → GPIO 2 (Configurable)</li>
<li>RST → GPIO 4 (Configurable)</li>
</ul>
</div>
</div>
<div class="pin-config">
<h2><span>⚙️</span> Customize Your Pin Configuration</h2>
<div class="pin-grid">
<div class="pin-item">
<label>SCL (Clock)</label>
<input type="number" id="pinSCL" value="18" min="0" max="39">
<div class="default">Default: GPIO 18</div>
</div>
<div class="pin-item">
<label>SDA (MOSI)</label>
<input type="number" id="pinSDA" value="23" min="0" max="39">
<div class="default">Default: GPIO 23</div>
</div>
<div class="pin-item">
<label>CS (Chip Select)</label>
<input type="number" id="pinCS" value="15" min="0" max="39">
<div class="default">Default: GPIO 15</div>
</div>
<div class="pin-item">
<label>DC (Data/Command)</label>
<input type="number" id="pinDC" value="2" min="0" max="39">
<div class="default">Default: GPIO 2</div>
</div>
<div class="pin-item">
<label>RST (Reset)</label>
<input type="number" id="pinRST" value="4" min="0" max="39">
<div class="default">Default: GPIO 4</div>
</div>
</div>
</div>
<div class="upload-section">
<h2 style="margin-bottom: 20px; color: #333;">🐝 Upload Your Image</h2>
<div class="upload-box" onclick="document.getElementById('imageInput').click()">
<div class="spinner" id="spinner"></div>
<i>📸</i>
<h3>Click to upload or drag & drop</h3>
<p>PNG, JPG, JPEG, BMP (240x240 recommended)</p>
<img id="imagePreview" src="#" alt="Preview">
<input type="file" id="imageInput" accept="image/*" style="display: none;" onchange="handleImageUpload(this)">
<button class="upload-btn" onclick="document.getElementById('imageInput').click()">Choose Image</button>
</div>
</div>
<div class="output-section" id="outputSection" style="display: none;">
<div class="output-header">
<h3>📋 Generated Arduino Code</h3>
<div class="output-buttons">
<button class="output-btn copy" onclick="copyToClipboard()">📋 Copy to Clipboard</button>
<button class="output-btn download" onclick="downloadAsINO()">📥 Download .INO</button>
</div>
</div>
<div id="outputCode"></div>
</div>
<div class="footer">
<p>🐝 Bee IMG to INO Converter - Made for GC9A01A Round Display with ESP32</p>
<p>© 2024 - Simple, Fast, Reliable</p>
</div>
</div>
<script>
let currentImageData = null;
let currentFileName = '';
async function handleImageUpload(input) {
const file = input.files[0];
if (!file) return;
currentFileName = file.name.split('.')[0] + '.ino';
// Show preview
const reader = new FileReader();
reader.onload = function(e) {
const img = document.getElementById('imagePreview');
img.src = e.target.result;
img.style.display = 'block';
};
reader.readAsDataURL(file);
// Show loading spinner
document.getElementById('spinner').style.display = 'block';
// Convert image
await convertImage(file);
// Hide spinner
document.getElementById('spinner').style.display = 'none';
// Show output section
document.getElementById('outputSection').style.display = 'block';
}
async function convertImage(file) {
const img = new Image();
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = 240;
canvas.height = 240;
await new Promise((resolve, reject) => {
img.onload = () => {
ctx.drawImage(img, 0, 0, 240, 240);
resolve();
};
img.onerror = reject;
img.src = URL.createObjectURL(file);
});
const imageData = ctx.getImageData(0, 0, 240, 240);
const pixels = imageData.data;
// Convert to RGB565
const rgb565Values = [];
for (let i = 0; i < pixels.length; i += 4) {
const r = pixels[i];
const g = pixels[i + 1];
const b = pixels[i + 2];
const rgb565 = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
rgb565Values.push('0x' + rgb565.toString(16).padStart(4, '0').toUpperCase());
}
// Get pin values
const pinSCL = document.getElementById('pinSCL').value;
const pinSDA = document.getElementById('pinSDA').value;
const pinCS = document.getElementById('pinCS').value;
const pinDC = document.getElementById('pinDC').value;
const pinRST = document.getElementById('pinRST').value;
// Format array
const lines = [];
for (let i = 0; i < rgb565Values.length; i += 16) {
lines.push(' ' + rgb565Values.slice(i, i + 16).join(', '));
}
// Generate complete code
const completeCode = `#include "SPI.h"
#include "Adafruit_GC9A01A.h"
// Custom Pin Configuration
#define TFT_CS ${pinCS}
#define TFT_DC ${pinDC}
#define TFT_RST ${pinRST}
#define TFT_MOSI ${pinSDA}
#define TFT_SCLK ${pinSCL}
Adafruit_GC9A01A tft(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
// Image data for 240x240 display (${rgb565Values.length} pixels)
const uint16_t my_image[240 * 240] PROGMEM = {
${lines.join(',\n')}
};
void setup() {
Serial.begin(115200);
tft.begin();
tft.setRotation(0);
tft.fillScreen(GC9A01A_BLACK);
// Display your image
tft.drawRGBBitmap(0, 0, my_image, 240, 240);
Serial.println("Image displayed successfully!");
}
void loop() {
// Add your animation code here
// The image will remain static
}`;
currentImageData = completeCode;
document.getElementById('outputCode').textContent = completeCode;
}
function copyToClipboard() {
if (!currentImageData) return;
navigator.clipboard.writeText(currentImageData).then(() => {
alert('✅ Code copied to clipboard! Now paste it in Arduino IDE.');
}).catch(err => {
alert('❌ Failed to copy. Please try again.');
});
}
function downloadAsINO() {
if (!currentImageData) return;
const blob = new Blob([currentImageData], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = currentFileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}
// Drag and drop support
const uploadBox = document.querySelector('.upload-box');
uploadBox.addEventListener('dragover', (e) => {
e.preventDefault();
uploadBox.style.borderColor = '#f6d365';
uploadBox.style.background = '#fff9f0';
});
uploadBox.addEventListener('dragleave', (e) => {
e.preventDefault();
uploadBox.style.borderColor = '#ff9a3c';
uploadBox.style.background = 'white';
});
uploadBox.addEventListener('drop', (e) => {
e.preventDefault();
uploadBox.style.borderColor = '#ff9a3c';
uploadBox.style.background = 'white';
const file = e.dataTransfer.files[0];
if (file && file.type.startsWith('image/')) {
document.getElementById('imageInput').files = e.dataTransfer.files;
handleImageUpload(document.getElementById('imageInput'));
} else {
alert('Please drop an image file!');
}
});
</script>
</body>
</html>