Skip to content

Instantly share code, notes, and snippets.

View GitMoDu's full-sized avatar

André GitMoDu

  • Lisbon
View GitHub Profile
#ifndef FABOOH
#include <Streaming.h>
#include "ringbuffer_simple.h"
#define sizeofs(a) sizeof((a))/sizeof((a[0]))
#else
serial_usart_isr_t<115200, CPU::frequency, TX1_PIN, RX1_PIN> Serial1;
USART_IRQHandler(1, Serial1)
#endif
@niusounds
niusounds / RingBuffer.kt
Last active April 20, 2022 22:53
RingBuffer in Kotlin
class RingBuffer(val capacity: Int) {
private val storage = ByteArray(capacity)
/**
* Convenient version of [read].
* This method allocates new array every time. Do not use this in heavy loop.
*
* @param startPosition Start position. Can be over than capacity.
* @param size Result data size.