Skip to content

Instantly share code, notes, and snippets.

View davidji's full-sized avatar

David Ireland davidji

  • London
View GitHub Profile
@davidji
davidji / enum_value_traits.cpp
Created October 26, 2018 18:02
This just shows how you can specify traits for enumeration values, including types.
/*
This is a rather contrived example where one option
expressed as an enum leads to a second set of options
that's different for each initial option.
What I really have in mind is configuration of a peripheral on microcontroller.
E.g. you first choose serial port 1, and then that gives you some options for
the TX and RX pins which are specific to serial port 1.
*/
@davidji
davidji / main.cpp
Created September 23, 2018 13:18
Driving a bipolar stepper motor using an ATTiny85
#include <Arduino.h>
constexpr int DRV_IN1 = PIN_B0;
constexpr int DRV_IN2 = PIN_B1;
constexpr int DRV_IN3 = PIN_B2;
constexpr int DRV_IN4 = PIN_B5;
class Winding {
public:
const int pin1, pin2;
@davidji
davidji / c_cpp_properties.py
Created January 28, 2018 22:06
Use the output from Chibios build to generate a VSCode configuration file
import subprocess, argparse, sys, pprint, json
from os import path
# Read the output of Chibios build to generate .vscode/c_cpp_properties.json
# E.g. make | python c_cpp_properties.py -C arm-none-eabi-g++ > .vscode/c_cpp_properties.json
parser = argparse.ArgumentParser()
parser.add_argument('-C', '--compiler', dest='compiler', default='gcc')