Sweep-style ECG viewer developed for Android
Custom solution for smooth 256Hz ECG rendering over BLE
1Limitations 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.
2Hardware-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.
3BLE 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.
4Smart 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.
5Timing 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.
6Open-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.