Skip to content

Instantly share code, notes, and snippets.

View AlexanderBrevig's full-sized avatar

Alexander Brevig AlexanderBrevig

View GitHub Profile
@AlexanderBrevig
AlexanderBrevig / snake.py
Last active November 2, 2017 11:49 — forked from sanchitgangwar/snake.py
Snakes Game using Python
# SNAKES GAME FOR WINDOWS
# Be sure to download http://gnuwin32.sourceforge.net/downlinks/pdcurses-bin-zip.php
# I add the pdcurses.dll to the project folder and off you go!
# Use ARROW KEYS to play, SPACE BAR for pausing/resuming and Esc Key for exiting
import unicurses
from unicurses import *
from random import randint
@AlexanderBrevig
AlexanderBrevig / Oryng wishes and ideas.md
Last active June 7, 2017 10:41
Just some thoughts from a former library author

IDE

I've got a few wishes for the next IDE so I'll just summarize them here as bullet points. These are my personal "nice to have" and not at all meant as "must have". Here goes:

  • A very clean canvas for writing code, I like tabs for handling multiple files in the sketch
  • Some kind of intellisense and a good auto format / smart insert
  • Based on https://electron.atom.io/
  • I would like to see a left side simple "explorer" with the following: [sample image below]
  • Entry for an attached schematic if any is included in the project folder
class ONOFF_ {}; typedef const ONOFF_ * const ONOFF;
class BLINKSPEED_ {}; typedef const BLINKSPEED_ * const BLINKSPEED;
class ON_ : public ONOFF_ {}; const ON_ on_; const ON_ * const ON = &on_;
class SLOW_ : public BLINKSPEED_ {}; const SLOW_ slow_; const SLOW_ * const SLOW = &slow_;
class OFF_ : public ONOFF_, public BLINKSPEED_ {}; const OFF_ off_; const OFF_ * const OFF = &off_;
class FAST_ : public BLINKSPEED_ {}; const FAST_ fast_; const FAST_ * const FAST = &fast_;
class MED_ : public BLINKSPEED_ {}; const MED_ med_; const MED_ * const MED = &med_;
/* void setFan(ONOFF onOrOff) {}*/// would only accept either ON or OFF
// http://www.stmicroelectronics.com.cn/content/ccc/resource/technical/document/errata_sheet/7d/02/75/64/17/fc/4d/fd/CD00190234.pdf/files/CD00190234.pdf/jcr:content/translations/en.CD00190234.pdf
// ERRATA 2.13.7
// disable I2C1
CLEAR_BIT(hi2c1.Instance->CR1, I2C_CR1_PE);
// make output open drain
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
@AlexanderBrevig
AlexanderBrevig / LightMIDI.cpp
Last active January 31, 2017 14:50
LightMIDI
#include <iostream> // std::cout
#include <fstream> // std::ifstream
#include <chrono>
#include <thread>
#define MIDI_DEBUG(s) (s);
using namespace std;
//expect total size and current size to be available
class fileinfo {
#pragma once
#include <string>
#include <cmath>
#include <fstream>
#include <iostream>
using namespace std;
class WAVfile
{
@AlexanderBrevig
AlexanderBrevig / BraccioDance.ino
Created May 26, 2016 09:32
For dancing to a song at a live concert
#include <Servo.h>
#include <Braccio2.h>
Servo base;
Servo shoulder;
Servo elbow;
Servo wrist;
Servo rotate;
Servo gripper;
#include <Braccio.h>
Braccio robot;
void setup() {
robot.useShield();
robot.home();
}
void loop() { //DANCE!
@AlexanderBrevig
AlexanderBrevig / Braccio.h
Last active May 3, 2016 04:42
A new Braccio library
/*
Braccio.h - Library for controlling the Arduino Robotic Arm; Braccio!
Copyright (c) 2016 - Alexander Brevig
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@AlexanderBrevig
AlexanderBrevig / HelloCustomBraccio.ino
Last active April 21, 2016 12:14
An example using a new Braccio library
#include <Braccio.h>
#include <Servo.h>
Servo base;
Servo shoulder;
Servo elbow;
Servo wristRotate;
Servo wristVertical;
Servo gripper;