This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#define BUF_SIZE 10 // usually how ever many ADC channels you want to filter | |
#define DATA_TYPE uint16_t | |
typedef struct{ | |
unsigned int alpha; // filter constant |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from IPython.display import HTML | |
HTML('''<script> | |
code_show=true; | |
function code_toggle() { | |
if (code_show){ | |
$('div.input').hide(); | |
} else { | |
$('div.input').show(); | |
} | |
code_show = !code_show |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pylab as plt | |
# Graphing helper function | |
def setup_graph(title='',x_label='', y_label='', fig_size=None): | |
fig = plt.figure() | |
if fig_size != None: | |
fig.set_size_inches(fig_size[0], | |
fig_size[1]) | |
ax = fig.add_subplot(111) | |
ax.set_title(title) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
Proof of concept code for using function pointers to handle | |
byte encoded commands for an embedded system. | |
This is useful for using something such as CAN to communicate with an embedded system | |
Programmed by William Harrington | |
https://github.com/wrh2 | |
*******************************************************************************/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
# good for about 1ms timing | |
def has_ms_elapsed(start_timestamp, num_of_ms): | |
return (time.clock() - start_timestamp)*1e3 > num_of_ms | |
# example use | |
def main(): | |
# we'll wait 75ms in this example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Working with 2D arrays and bit manipulation in C | |
* | |
* Helpful for working with image processing in C | |
* | |
* For instance, let's say you have a 2D array in memory that | |
* represents a monochrome bitmap and you need to manipulate | |
* specific bits within that 2D array | |
* | |
* Programmed by William Harrington |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def binary(num, length=32): | |
return format(num, '#0{}b'.format(length+2)) | |
def hexadecimal(num, length=8): | |
return format(num, '#0{}x'.format(length+2)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* states */ | |
typedef enum{ | |
IDLE, | |
BEGIN, | |
WAIT, | |
FINISH, | |
END, | |
}state_name_t; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
*Finite State Machine (FSM) Example in C | |
* that makes use of function pointers | |
* | |
* Programmed by wrh2 (github.com/wrh2) | |
*/ | |
#include <stdio.h> | |
/* declare struct for FSM */ | |
struct fsm; |