Skip to content

Instantly share code, notes, and snippets.

View ciniml's full-sized avatar
🏠
Working from home

Kenta IDA ciniml

🏠
Working from home
View GitHub Profile
@ciniml
ciniml / RxDeadTime.cs
Last active August 29, 2015 14:22
insert deadtime between items
static IObservable<T> DeadTime<T>(this IObservable<T> source, TimeSpan deadTime)
{
return Observable.Create<T>(o =>
{
var subscriptions = new CompositeDisposable();
var deadTimeTimer = new Subject<IObservable<long>>();
var inDeadTime = false;
subscriptions.Add(
source.Subscribe(
item =>
static IObservable<T> DeadTime<T>(this IObservable<T> source, TimeSpan deadTime)
{
return Observable.Create<T>(o =>
{
var subscriptions = new CompositeDisposable();
var lastTime = DateTimeOffset.MinValue;
return source
.Timestamp()
.Where(timestamped => timestamped.Timestamp - lastTime > deadTime)
@ciniml
ciniml / enum_in_struct.h
Last active October 2, 2015 14:42
enum in struct
struct enum_type
{
enum type
{
one,
two,
three,
};
};
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication17
{
class Program
@ciniml
ciniml / Genuino_IMU_BLE.ino
Created April 19, 2016 16:03
Sends Genuino IMU data via BLE
#include <CurieBLE.h>
#include <CurieIMU.h>
#include <CurieTimerOne.h>
#include <stdint.h>
BLEPeripheral blePeripheral;
BLEService imuService("FFF0");
static constexpr size_t AccelometerCharacteristicSize = sizeof(int) * 3;
static constexpr size_t GyroCharacteristicSize = sizeof(int) * 3;
#include <avr/io.h>
#include <stdint.h>
int main(void)
{
/* Replace with your application code */
while (1)
{
const volatile uint8_t a = 10;
const volatile uint8_t b = 20;
@ciniml
ciniml / ConvertExpressionParts.cs
Last active November 23, 2016 16:15
Deconstructable ConvertExpressionParts
private struct ConvertExpressionParts
{
public Expression[] Prologue { get; }
public Expression[] ValueExpressions { get; }
public int Size { get; }
public ParameterExpression[] Variables { get; }
public ConvertExpressionParts(Expression[] prologue, Expression[] valueExpressions, int size, ParameterExpression[] variables)
{
this.Prologue = prologue;
this.ValueExpressions = valueExpressions;
@ciniml
ciniml / simple_dma.cpp
Created March 16, 2017 14:42
Fails after "Generating RTL" is shown,
#include "simple_dma.hpp"
template<size_t TBurstCount>
static void burstTransfer(const InputData* input, hls::stream<InputData>& stream, TransferCount transferCount)
{
#pragma HLS INLINE off
for(; transferCount >= TBurstCount; transferCount -= TBurstCount) {
for(TransferCount count = 0; count < TBurstCount; ++count) {
#pragma HLS PIPELINE ii=1
stream << *(input++);
@ciniml
ciniml / simple_dma.cpp
Created March 27, 2017 17:27
Vivado HLS AXI master read burst
#include "simple_dma.hpp"
void simpleDma(const InputData* input, hls::stream<OutputStreamData>& outputStream, AddressOffset offset, TransferCount transferCount)
{
#pragma HLS INTERFACE s_axilite port=transferCount bundle=control
#pragma HLS INTERFACE s_axilite port=offset bundle=control
#pragma HLS INTERFACE s_axilite port=return bundle=control
#pragma HLS INTERFACE m_axi depth=TestDataCount port=input offset=off
#pragma HLS INTERFACE axis port=outputStream
@ciniml
ciniml / esp32_ble_advertising.ino
Created May 1, 2017 18:19
ESP32 Advertising example
#include <Esp.h>
#include <esp32-hal-bt.h>
#include "bt.h"
#include "esp_bt_main.h"
#include "esp_gap_ble_api.h"
static void checkResult(esp_err_t err, const __FlashStringHelper* s)
{
if (err != ESP_OK) {
Serial.printf("[ERR %08x] ", err);