# Sweep-style ECG viewer developed for Android

Custom solution for smooth 256Hz ECG rendering over BLE

- **Source:** [Developing Android Apps](https://brifing.si/source/aa76b6c1-28c1-49f8-967e-b6a0eeadfa86)
- **Published:** 2026-07-23
- **Topic:** [Software & Engineering](https://brifing.si/c/engineering)
- **Original article:** <https://www.reddit.com/r/androiddev/comments/1v3ylh9/i_couldnt_get_256_hz_ecg_to_render_smoothly_over/>
- **On Brifing:** https://brifing.si/s/c285f613-51ae-4405-820a-b85b4eff5ea2

## Limitations of traditional solutions

Standard charting libraries used scrolling window models, differing from the sweep effect in real patient monitors. Tools like MPAndroidChart caused performance issues with high-frequency ECG data due to main-thread rendering.

## Hardware-accelerated solution

A custom renderer was developed using SurfaceView and lockHardwareCanvas(). This allows smooth rendering of 256Hz ECG data on a separate thread, accurately mimicking the sweep effect of medical devices.

## BLE data transmission challenges

Bluetooth Low Energy delivered data in irregular bursts - sometimes no data for 300ms followed by 20 samples at once. This caused freezing and jumping in the display, requiring a specialized buffering solution.

## Smart buffering mechanism

A leaky bucket algorithm was implemented to balance irregular data flow. Bursts are metered out smoothly, while an adaptive display delay keeps multiple traces synchronized for consistent visualization.

## Timing synchronization

An NTP-inspired clock alignment algorithm was developed. Using minimum observed latency as the true offset reference, it slews at 2ms/s to track drift without reacting to jitter, maintaining stable timing for medical data streams.

## Open-source contribution

This MIT-licensed project provides a foundational component for biomedical signal visualization (ECG/PPG/RESP). The demo app enables testing with real data, offering potential as a critical infrastructure element for mobile health applications.

## Sources covering this story

- https://www.reddit.com/r/androiddev/comments/1v3ylh9/i_couldnt_get_256_hz_ecg_to_render_smoothly_over/ — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
