Skip to content

Instantly share code, notes, and snippets.

View 46bit's full-sized avatar
🏳️‍🌈

Miki Mokrysz 46bit

🏳️‍🌈
View GitHub Profile
@46bit
46bit / 4seg.c
Last active August 29, 2015 13:56
Show a digital clock on a 4-digit 7-segment display (http://r.46b.it/4seg.jpg), when running on an LPC1760 MBED. Use push buttons to set hour and minute. Not openly licensed, may not be mine to give away.
// Serial code
#include "stdhapr.h" // https://gist.github.com/46bit/8890761
#include "lpc17xx_timer.h"
TIM_TIMERCFG_Type TIM_ConfigStruct;
TIM_MATCHCFG_Type TIM_MatchConfigStruct;
#define SEG7_0 0b11111100
#define SEG7_1 0b01100000
#define SEG7_2 0b11011010
@46bit
46bit / stdhapr.h
Created February 8, 2014 21:41
Library to make using LPC17xx easier. Not freely licensed, may not be mine to give away. Here for https://gist.github.com/46bit/8890681
#include "lpc17xx_i2c.h"
#include "lpc17xx_pinsel.h"
#include "lpc17xx_uart.h"
#include "lpc17xx_gpio.h"
#include "lpc17xx_nvic.h"
#include "lpc17xx_gpdma.h"
#include "lpc17xx_adc.h"
#include "lpc17xx_dac.h"
#include <math.h>
#include <string.h>

Keybase proof

I hereby claim:

  • I am 46bit on github.
  • I am 46bit (https://keybase.io/46bit) on keybase.
  • I have a public key whose fingerprint is 8866 3A0E CFCF 0786 D478 1D9D 8DA9 2997 13A7 9B14

To claim this, I am signing this object:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include "postman.h"
int main(int argc, char *argv[], char **envp)
{
// Parse AIs from stdin or command-line arguments.
int i, ai_count = argc - 1;
struct game {
struct character *characters_head, *characters_tail;
struct player *players_head, *players_tail;
struct round *rounds_head, *current_round, *rounds_tail;
};
struct round {
struct card *cards_head, *current_card, *cards_tail;
struct player *start_player, *current_player;
struct move *current_move;
match "posts/*.md" $ do
route $ metadataRoute (\m ->
constRoute $
(fromMaybe "year" $ Data.Map.lookup "year" m) ++
"/" ++
(fromMaybe "title" $ Data.Map.lookup "title" m) ++
".html")
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls
data State = State { name :: Int
, transitions :: [Transition]
, accepting :: Bool
} deriving (Show)
data Transition = Transition { input :: Char
, next :: State} deriving (Show)
accept :: String -> Maybe State -> Bool
accept _ Nothing = False
accept [] (Just State {accepting = a}) = a
@46bit
46bit / tm.hs
Last active August 29, 2015 14:02
Turing Machine in Haskell.
module TM (
State,
Symbol,
Direction(..),
Transition,
ZipTape,
TM,
prettyTransition,
prettyZipTape,
prettyTM,
@46bit
46bit / test.hs
Last active August 29, 2015 14:02
Tiny demo of my Haskell Turing Machine (https://gist.github.com/46bit/46fba4b32db68a5f47c9)
import TM
import Data.Maybe
main :: IO ()
main = print . TM.prettyTM . TM.executeTM $
TM.createTM "bbc" [(0, 'a', 'b', TM.Idle, 1), (1, 'b', 'c', TM.Right, 1)]
@46bit
46bit / uarm-issues.md
Last active August 29, 2015 14:03
Issues experienced with µArm, for use when designing improved firmware and hardware.

µArm issues

Firmware

  1. Resets unpredictable during movement series (such as hanoi.c).
  2. Pushes servos into mechanically limited positions.
  3. No collision detection despite servo position feedback, sucker contact button.
  4. No state display on LEDs.
  5. Servos move at high speed, stressing mechanism and overcoming base friction.
  6. Position based around servo settings rather than head position. Stretch and height coordinates are not independent.
  7. Many serial libraries don't function (eg RubySerial), forced to use specialised arduino-serial library.