Skip to content

Instantly share code, notes, and snippets.

<html>
<head>
<style>
body {
background: #141414;
}
</style>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
@lithium
lithium / ringbuffer.c
Created May 27, 2015 14:46
locking circular buffer for parallax propeller
#include "ringbuffer.h"
int RingBuffer_init(RingBuffer *rbuf, void *buffer, uint8_t entry_size, uint8_t buffer_capacity)
{
rbuf->buffer = buffer;
rbuf->entry_size = entry_size;
rbuf->buffer_capacity = buffer_capacity;
rbuf->in = rbuf->out = 0;
@lithium
lithium / .vimrc
Created May 27, 2015 02:40
.vimrc
set ts=2 sw=2
set ai
set et
set aw
retab
syntax on
map <F8> :make<CR><CR>:botright cwindow<CR>
map ^N :cn<CR>
HUB75 -> Name = Pin#
================
R0 GPIO5
B0 GPIO6
G0 GPIO13
R1 GPIO16
B1 GPIO26
G1 GPIO12
A GPIO19
B GPIO20
@lithium
lithium / gist:663ce5a255d8e1a4f2db
Created April 7, 2015 20:22
asterisk auto attendant
[main_menu]
exten => s,1, Verbose(1, Caller ${CALLERID(all)} has entered main menu)
same => n, Answer()
same => n, Set(TIMEOUT(digit)=2)
same => n, Wait(1)
same => n(greeting), Background(main-greeting) ; play greeting
same => n(menuprompt), Background(main-menu) ; play menu prompt
@lithium
lithium / gist:5c7499fb515cba4dd651
Created April 7, 2015 15:00
Asterisk with twilio as SIP trunk. Incoming calls are rejected

Log messsage:

 Call from "user" (external.sip:port) to extension "+1XXXXXXXXXX" rejected because extension not found in context 'incoming'.

sip.conf:

[Twilio]
type=peer
secret=

username=user

@lithium
lithium / gist:8741396
Last active August 29, 2015 13:55
12-bit risc
11 10 9 8 7 6 5 4 3 2 1 0
Op Op Op Op x x x x x x x x
0000 - NOP
0000 0000 0000
@lithium
lithium / 1opcodes.md
Last active January 4, 2016 21:39
8 bit risc
MOV Rd, Rr
BinaryMneumonicInstructionExpression
00dddrrr

Overview

  • 16x 8-bit registers.
  • R0 .. R10 = General Purpose
  •   R11 = Page Address
    
  • [R12:R13] = SP (Stack Pointer)
  • [R14:R15] = PC (Program Counter)
  • Load/Store architecture.
  • Von-neuman architecture.
BOOT_UP
* clear leds
lastState = <storage | SLOW_FADE>
currentColor = <storage | 0>
targetColor = Colors[currentColor + 1]
-> SLEEP
SLOW_FADE