| 3493 | } |
| 3494 | |
| 3495 | function drawOledCircle(ctx, cx, cy, r, color, filled) { |
| 3496 | ctx.fillStyle = color; |
| 3497 | let x = r; |
| 3498 | let y = 0; |
| 3499 | let err = 0; |
| 3500 | while (x >= y) { |
| 3501 | if (filled) { |
| 3502 | ctx.fillRect(cx - x, cy + y, x * 2 + 1, 1); |
| 3503 | ctx.fillRect(cx - x, cy - y, x * 2 + 1, 1); |
| 3504 | ctx.fillRect(cx - y, cy + x, y * 2 + 1, 1); |
| 3505 | ctx.fillRect(cx - y, cy - x, y * 2 + 1, 1); |
| 3506 | } else { |
| 3507 | ctx.fillRect(cx + x, cy + y, 1, 1); |
| 3508 | ctx.fillRect(cx + y, cy + x, 1, 1); |
| 3509 | ctx.fillRect(cx - y, cy + x, 1, 1); |
| 3510 | ctx.fillRect(cx - x, cy + y, 1, 1); |
| 3511 | ctx.fillRect(cx - x, cy - y, 1, 1); |
| 3512 | ctx.fillRect(cx - y, cy - x, 1, 1); |
| 3513 | ctx.fillRect(cx + y, cy - x, 1, 1); |
| 3514 | ctx.fillRect(cx + x, cy - y, 1, 1); |
| 3515 | } |
| 3516 | y++; |
| 3517 | if (err <= 0) { |
| 3518 | err += 2 * y + 1; |
| 3519 | } else { |
| 3520 | x--; |
| 3521 | err += 2 * (y - x) + 1; |
| 3522 | } |
| 3523 | } |
| 3524 | } |
| 3525 | |
| 3526 | // 5x7 bitmap font (ASCII 0x20..0x7F), derived from the classic Adafruit GFX glcdfont. |
| 3527 | // Each character is 5 columns wide, stored as 5 bytes (LSB at top). Add 1px spacing. |