Skip to content

Instantly share code, notes, and snippets.

@Bouni
Bouni / leaflet.draw store-reload
Last active January 3, 2016 20:58
My solution storing and reloading features on a leaflet map edited with leaflet.draw. The features are written to a hidden text-input exportGeoJson(drawnItems, $("#mapdata")); and also loaded from there importGeoJson(drawnItems, JSON.parse($("#mapdata").val()));
$(function () {
var map = L.map('map').setView([51.505, -0.09], 13);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var drawnItems = new L.FeatureGroup();
map.addLayer(drawnItems);
@Bouni
Bouni / coinchanger
Last active May 31, 2019 01:53
Some tests for an MDB project
// global state variable
unsigned int coinstate;
// structure for storing the coin changer info
struct COIN_INFO {
byte feature_level;
unsigned int country_code;
byte scaling_factor;
byte decimal_places;
byte type_routing;
@Bouni
Bouni / errorlog.txt
Created September 7, 2014 18:00
Arduino IDE 1.5.7 serial errorlog
Serial1 sent 3E, received 3E, OK!
Serial2 sent 3E, received 3E, OK!
Serial3 sent 3E, received 3E, OK!
3455 bytes sent
Serial1 sent 3F, received 3F, OK!
Serial2 sent 3F, received 3F, OK!
Serial3 sent 3F, received 3F, OK!
3456 bytes sent
Test mode 12
Serial1 sent 0, received FFFFFFFF, >>>> FAIL <<<<
@Bouni
Bouni / testsketch.ino
Last active August 29, 2015 14:06
Arduino IDE 1.5.7 serial test sketch
int modes[30] = {
SERIAL_5N1,
SERIAL_5E1,
SERIAL_5O1,
SERIAL_5N2,
SERIAL_5E2,
SERIAL_5O2,
SERIAL_6N1,
SERIAL_6E1,
@Bouni
Bouni / burning-seri.es-api.markdown
Last active December 23, 2015 15:37
burning-seri.es API

Short description of the burning-seri.es JSON API

Fetch a list all available series

GET https://burning-seri.es/api/series

Result (just a fragment):

[
@Bouni
Bouni / modbus.py
Created November 5, 2014 11:56
Modbus connection to SICK FlexiSoft
#!/usr/bin/env python
#---------------------------------------------------------------------------#
# import the various server implementations
#---------------------------------------------------------------------------#
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
from time import sleep
#---------------------------------------------------------------------------#
# configure the client logging
@Bouni
Bouni / matrix.ino
Last active August 29, 2015 14:13
A dot matrix test
int column[8] = {A0,A1,A2,A3,A4,A5,A6,A7};
int row[8] = {A8,A9,A10,A11,A12,A13,A14,A15};
int pattern[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
/*
void writeByte(int byte, int *port) {
for(int i=0; i<8; i++){
if(byte & (1<<i)) {
@Bouni
Bouni / SmoothieSpindle.md
Last active August 29, 2015 14:19
Smothieboard Spindle improvement

Smoothieboard Spindle improvements

Modules

  • SpindleMaker: loads the right spindle module depending on the config, deletes itself after thats done. (Like the ExtruderMaker)
  • SpindleControl: Baseclass for other spindles
  • PWMSpindleControl: For DC spindles that are directly driven by one of the MOSFET outputs (the old spindle module)
  • AnalogSpindleControl: For controlling a VFD driven spindle with an analog 0-10V signal. Some additional electronic is required to convert the 3.3V PWM signal into a 0-10V signal
@Bouni
Bouni / hunayang-rs485-commands.md
Last active January 30, 2022 22:56
Huanyang VFD RS485 commands (pseudo Modbus)

Hunayang RS485 commands

Hunayang inverters claim to be Modbus compatible - they are not :-( So here i try to create a nice list of all commands and their meaning.

I assume the use of the RTU mode.

Parameter settings

  • PD001: 2 (Source of run commands: communication port)
@Bouni
Bouni / main.c
Created May 6, 2015 13:33
Arduino uart AVR-GCC
#ifndef F_CPU
#define F_CPU 16000000UL
#endif
#include <inttypes.h>
#include <avr/io.h>
#include <util/delay.h>
int main(void) {