Skip to content

Instantly share code, notes, and snippets.

View turbinenreiter's full-sized avatar

Sebastian Plamauer turbinenreiter

View GitHub Profile
#lang racket
(require markdown)
(require web-server/servlet)
(provide/contract (start (request? . -> . response?)))
(define (article-fnames path-to-articles)
(directory-list (string->path path-to-articles)))
(define (article-paths path-to-articles article-fnames)
This file has been truncated, but you can view the full file.
warning: IMPORTANT: the library format is unstable now. It can change with any new git commit without warning!
package platform.zephyr.stm32f4_disco {
class ADC_AnalogWDGConfTypeDef (rawPtr: NativePtr) : CStructVar {
var Channel: Int
var HighThreshold: Int
var ITMode: Int
var LowThreshold: Int
var WatchdogMode: Int
var WatchdogNumber: Int
companion object : Type
+ BOARD=stm32f4_disco
+ export ZEPHYR_BASE=/home/plam/Projects/zephyr
+ ZEPHYR_BASE=/home/plam/Projects/zephyr
+ '[' /home/plam/Projects/zephyr == PLEASE_SET_ZEPHYR_BASE ']'
+++ dirname build.sh
++ cd .
++ pwd
+ DIR=/home/plam/Projects/kotlin-native/samples/zephyr
+ source /home/plam/Projects/kotlin-native/samples/zephyr/../konan.sh
++ '[' -z '' ']'
"""
Micro Python driver for SD cards using SPI bus.
Requires an SPI bus and a CS pin. Provides readblocks and writeblocks
methods so the device can be mounted as a filesystem.
Example usage on pyboard:
import pyb, sdcard, os
sd = sdcard.SDCard(pyb.SPI(1), pyb.Pin.board.X5)
import time
class RangeSensor:
def __init__(self):
pass
def make_generator(self):
t_end = time.time() + 0.1
# tell sensor to start measurement
@turbinenreiter
turbinenreiter / micropython-html-slides.py
Created April 3, 2016 18:05
a small presentation about MicroPython including a 'webserver' to serve it from a microcontroller
import socket, machine
# This is the HTML, CSS and js to deliver to the client.
# You can (should) store this in another file and read from there,
# but I am lazy.
# The CSS and HTML to display pretty code is from pygments.
upy = """<!DOCTYPE html>
<html>
<head>
<title>I'm a website running on a Microcontroller.</title>
@turbinenreiter
turbinenreiter / serialplot2
Created March 5, 2014 19:20
plotting data from serial port with matplotlib
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import serial
fig, ax = plt.subplots()
line, = ax.plot(np.random.rand(10))
ax.set_ylim(-5000, 5000)
xdata, ydata = [0]*100, [0]*100
raw = serial.Serial("/dev/ttyUSB1",9600)
@turbinenreiter
turbinenreiter / serialplot
Created December 10, 2013 20:43
Code to read data from the serial port and plot it.
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
from pyqtgraph.ptime import time
import serial
app = QtGui.QApplication([])
@turbinenreiter
turbinenreiter / writeserial
Created December 10, 2013 20:41
Arduino code to send acceleration data to serial port.
#include <MPU6050.h>
#include <I2Cdev.h>
#include <Wire.h>
MPU6050 accelgyro;
int ax, ay, az;
int gx, gy, gz;
int led = 13;
@turbinenreiter
turbinenreiter / visualization
Created June 15, 2013 14:39
Python script to visualize the data from the MPU6050.
import numpy as np
from pylab import *
acc = []
with open('data') as f:
data = f.readlines()
for value in data:
value_acc = ((int(value))-128)/30.0