Skip to content

Instantly share code, notes, and snippets.

View nraynaud's full-sized avatar
🌵
learning new things

Nicolas Raynaud nraynaud

🌵
learning new things
View GitHub Profile
@nraynaud
nraynaud / tim4.c
Last active December 24, 2019 14:51
Connect a rotary encoder to STM32F4. Needs time base initialization on TIM4 but not on TIM8, no idea why
#include "stm32f4_discovery.h"
#include "arm_math.h"
/*
- TIM4_CH1 pin (PB.06)
- TIM4_CH2 pin (PB.07)
*/
void configureEncoder() {
const struct __attribute__((__packed__, aligned (4))) {
uint8_t bLength, bDescriptorType;
uint8_t bcdUSBL, bcdUSBH;
uint8_t bDeviceClass, bDeviceSubClass, bDeviceProtocol, bMaxPacketSize;
uint8_t idVendorL, idVendorH;
uint8_t idProductL, idProductH;
uint8_t bcdDeviceL, bcdDeviceH;
uint8_t iManufacturer, iProduct, iSerialNumber;
uint8_t bNumConfigurations;
} deviceDescriptor = {
test("jsparse number evaluation", function () {
var jp = jsparse;
var number = jp.action(jp.repeat1(jp.range('0', '9')), function (ast) {
return ast.join('');
});
var decimalPart = jp.action(jp.sequence('.', number), function (ast) {
return ast.join('');
});
var integerAndDecimal = jp.action(jp.sequence(number, jp.optional(decimalPart)), function (ast) {
return ast[1] !== false ? ast[0] + ast[1] : ast[0];
@nraynaud
nraynaud / serial.html
Created August 26, 2013 19:17
first test for a Huanyang VFD google chrome extension. broken without reason, the read just says it retrieved one byte.
<!DOCTYPE html>
<html>
<head>
<title>modbus ?</title>
</head>
<body>
modbus ?<br>
<script src="serial.js"></script>
<label>
DCD:
@nraynaud
nraynaud / test_C++.cpp
Created October 7, 2013 06:35
STM32F4 MCU C++ API test.
#include "stm32f4xx_conf.h"
#include "stm32f4_discovery.h"
template<uint32_t GPIO_CLK, intptr_t GPIO_PORT_ADDR> class GPIOPort {
public:
static GPIOPort& port() {
static GPIOPort instance;
return instance;
};
@nraynaud
nraynaud / clipper_unminified.js
Created October 14, 2013 09:05
Testing clipper algo change.
//instrumented by nraynaud for testing purpose
/*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 5.0.2 *
* Date : 30 December 2012 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2012 *
* *
@nraynaud
nraynaud / test_clipper_diff.html
Created January 10, 2014 14:56
testing js clipper float difference.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple Bentley Ottmann with mock underlying structures</title>
<link rel="stylesheet" href="qunit-1.12.0.css">
<style>
.svgTest td {
border: solid 1px green;
}
@nraynaud
nraynaud / Form1.cs
Created February 7, 2014 20:31
clipper C# GUI demo main form cleanup
//#define UsePolyTree
using System;
using System.Diagnostics;
using System.Text;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
@nraynaud
nraynaud / svg.marker.js
Created April 18, 2014 12:20
markers for svg.js
"use strict";
define(['libs/svg'], (function () {
SVG.Marker = SVG.invent({
create: 'marker',
inherit: SVG.Container,
extend: {
getRef: function () {
return 'url(#' + this.attr('id') + ')'
},
update: function (block) {
@nraynaud
nraynaud / registers.ads
Created October 11, 2014 09:38
started reworking Adacore's modeling of registers in STM32F4
--------------------------------------------------------------------
---
-----------
-- --
-- GNAT EXAMPLE --
-- --
-- Copyright (C) 2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --