|
| 1 | +<!-- |
| 2 | +SPDX-FileCopyrightText: Copyright (c) 2025 Tim C for Adafruit Industries |
| 3 | +SPDX-License-Identifier: MIT |
| 4 | +--> |
| 5 | +<!DOCTYPE html> |
| 6 | +<html lang="en"> |
| 7 | +<head> |
| 8 | + <meta charset="UTF-8"> |
| 9 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 10 | + <title>OPT4048 CIE Color Plotter</title> |
| 11 | + <style> |
| 12 | + body { |
| 13 | + font-family: Arial, sans-serif; |
| 14 | + max-width: 100%; |
| 15 | + margin: 0 auto; |
| 16 | + padding: 8px; |
| 17 | + height: 100vh; |
| 18 | + display: flex; |
| 19 | + flex-direction: column; |
| 20 | + } |
| 21 | + .container { |
| 22 | + display: flex; |
| 23 | + flex-wrap: wrap; |
| 24 | + gap: 10px; |
| 25 | + justify-content: center; |
| 26 | + flex: 1; |
| 27 | + } |
| 28 | + .controls { |
| 29 | + flex: 1; |
| 30 | + min-width: 230px; |
| 31 | + max-width: 100%; |
| 32 | + display: flex; |
| 33 | + flex-direction: column; |
| 34 | + overflow: hidden; |
| 35 | + } |
| 36 | + .visualization { |
| 37 | + flex: 2; |
| 38 | + min-width: 280px; |
| 39 | + max-width: 100%; |
| 40 | + display: flex; |
| 41 | + flex-direction: column; |
| 42 | + } |
| 43 | + #cie-diagram { |
| 44 | + position: relative; |
| 45 | + width: 100%; |
| 46 | + max-width: 450px; |
| 47 | + margin: 0 auto 10px auto; |
| 48 | + flex: 1; |
| 49 | + display: flex; |
| 50 | + align-items: center; |
| 51 | + justify-content: center; |
| 52 | + } |
| 53 | + #cie-diagram img { |
| 54 | + width: 100%; |
| 55 | + max-height: 100%; |
| 56 | + object-fit: contain; |
| 57 | + display: block; |
| 58 | + } |
| 59 | + #data-point { |
| 60 | + position: absolute; |
| 61 | + width: 16px; |
| 62 | + height: 16px; |
| 63 | + background-color: white; |
| 64 | + border-radius: 50%; |
| 65 | + border: 3px solid black; |
| 66 | + transform: translate(-50%, -50%); |
| 67 | + pointer-events: none; |
| 68 | + box-shadow: 0 0 8px rgba(0, 0, 0, 0.9); |
| 69 | + z-index: 10; |
| 70 | + } |
| 71 | + #color-sample { |
| 72 | + width: 30px; |
| 73 | + height: 30px; |
| 74 | + border: 1px solid #ccc; |
| 75 | + margin: 0 auto; |
| 76 | + border-radius: 50%; |
| 77 | + } |
| 78 | + #serial-log { |
| 79 | + flex: 1; |
| 80 | + min-height: 80px; |
| 81 | + max-height: 150px; |
| 82 | + overflow-y: auto; |
| 83 | + background-color: #f5f5f5; |
| 84 | + padding: 8px; |
| 85 | + border: 1px solid #ddd; |
| 86 | + font-family: monospace; |
| 87 | + font-size: 12px; |
| 88 | + margin-bottom: 5px; |
| 89 | + } |
| 90 | + button { |
| 91 | + padding: 8px 12px; |
| 92 | + margin: 4px 4px 4px 0; |
| 93 | + background-color: #4CAF50; |
| 94 | + color: white; |
| 95 | + border: none; |
| 96 | + border-radius: 4px; |
| 97 | + cursor: pointer; |
| 98 | + font-size: 14px; |
| 99 | + } |
| 100 | + button:hover { |
| 101 | + background-color: #45a049; |
| 102 | + } |
| 103 | + button:disabled { |
| 104 | + background-color: #cccccc; |
| 105 | + cursor: not-allowed; |
| 106 | + } |
| 107 | + .data-display { |
| 108 | + display: flex; |
| 109 | + flex-wrap: wrap; |
| 110 | + justify-content: center; |
| 111 | + gap: 8px; |
| 112 | + margin-top: 10px; |
| 113 | + } |
| 114 | + .data-box { |
| 115 | + flex: 1; |
| 116 | + min-width: 100px; |
| 117 | + margin: 0; |
| 118 | + padding: 10px; |
| 119 | + background-color: #f9f9f9; |
| 120 | + border: 1px solid #ddd; |
| 121 | + border-radius: 4px; |
| 122 | + text-align: center; |
| 123 | + } |
| 124 | + .data-box h3 { |
| 125 | + margin: 0 0 5px 0; |
| 126 | + font-size: 14px; |
| 127 | + } |
| 128 | + .data-value { |
| 129 | + font-size: 18px; |
| 130 | + font-weight: bold; |
| 131 | + } |
| 132 | + |
| 133 | + /* Responsive adjustments for very small screens */ |
| 134 | + @media (max-height: 600px) { |
| 135 | + h1 { font-size: 20px !important; margin: 5px 0 !important; } |
| 136 | + h2 { font-size: 16px; margin: 8px 0 5px 0; } |
| 137 | + p { font-size: 12px !important; margin: 5px 0 !important; } |
| 138 | + .data-box { padding: 5px; } |
| 139 | + .data-box h3 { font-size: 12px; margin: 0 0 3px 0; } |
| 140 | + .data-value { font-size: 14px; } |
| 141 | + #serial-log { min-height: 60px; max-height: 100px; } |
| 142 | + button { padding: 6px 10px; font-size: 12px; } |
| 143 | + } |
| 144 | + </style> |
| 145 | +</head> |
| 146 | +<body> |
| 147 | + |
| 148 | + |
| 149 | + <div class="container"> |
| 150 | + <div class="controls"> |
| 151 | + <h2 style="margin: 10px 0; font-size: 24px;">OPT4048 CIE Color Plotter</h2> |
| 152 | + <p style="margin: 8px 0; font-size: 14px;">Connect your Arduino with OPT4048 sensor to visualize color measurements on a CIE diagram.</p> |
| 153 | + |
| 154 | + <button id="clear-button">Clear Log</button> |
| 155 | + <button id="test-plot-button" style="display: none;">Test Plot Point</button> |
| 156 | + |
| 157 | + <h2>Connection Status</h2> |
| 158 | + <p id="status">Not connected</p> |
| 159 | + |
| 160 | + <h2 style="margin-bottom: 5px;">Serial Monitor</h2> |
| 161 | + <div id="serial-log"></div> |
| 162 | + </div> |
| 163 | + |
| 164 | + <div class="visualization"> |
| 165 | + <h2 style="margin: 10px 0; font-size: 24px;">CIE 1931 Chromaticity Diagram</h2> |
| 166 | + <div id="cie-diagram"> |
| 167 | + <img src="cie1931_diagram.svg" alt="CIE 1931 Chromaticity Diagram"> |
| 168 | + <div id="data-point" style="display: none;"></div> |
| 169 | + <!-- Debug info: will show exact location of measured color --> |
| 170 | + <div id="debug-coordinates" style="position: absolute; bottom: 3px; right: 3px; font-size: 10px; background: rgba(255,255,255,0.7); padding: 2px; border: 1px solid #ccc; display: block;"></div> |
| 171 | + </div> |
| 172 | + |
| 173 | + <div class="data-display"> |
| 174 | + <div class="data-box"> |
| 175 | + <h3>CIE x</h3> |
| 176 | + <div id="cie-x" class="data-value">-</div> |
| 177 | + </div> |
| 178 | + <div class="data-box"> |
| 179 | + <h3>CIE y</h3> |
| 180 | + <div id="cie-y" class="data-value">-</div> |
| 181 | + </div> |
| 182 | + <div class="data-box"> |
| 183 | + <h3>Lux</h3> |
| 184 | + <div id="lux" class="data-value">-</div> |
| 185 | + </div> |
| 186 | + <div class="data-box"> |
| 187 | + <h3>CCT (K)</h3> |
| 188 | + <div id="cct" class="data-value">-</div> |
| 189 | + </div> |
| 190 | + </div> |
| 191 | + |
| 192 | + <div class="data-box"> |
| 193 | + <h3>Color Approximation</h3> |
| 194 | + <div id="color-sample"></div> |
| 195 | + <small>(Note: This is a rough approximation)</small> |
| 196 | + </div> |
| 197 | + </div> |
| 198 | + </div> |
| 199 | + |
| 200 | + <script src="script.js"></script> |
| 201 | +</body> |
| 202 | +</html> |
0 commit comments