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 datetime import datetime, timedelta | |
import time | |
def check_sleep(func, amt): | |
start = datetime.now() | |
func(amt) | |
end = datetime.now() | |
delta = end-start | |
return abs(delta.seconds + delta.microseconds/1000000.0 - amt) |
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
typedef void (*command_handler)(char*); | |
struct command_t { | |
char *command; | |
command_handler handler; | |
} commands[] = { | |
{"command1", func1}, | |
{"command2", func2}, | |
{NULL, NULL} | |
}; |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import codecs | |
import csv | |
import itertools | |
import sys | |
country_codes = { | |
"AF": "AFGHANISTAN", |
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
class MessageHeader(object): | |
def __init__(self, priority, protocol): | |
self.priority = priority | |
self.protocol = protocol | |
self.sender = None | |
def decode(bits): | |
priority = bits.read('uint:2') | |
broadcast = bits.read('bool') |
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 bitstring | |
class StructValueError(Exception): pass | |
class Member(object): | |
creation_counter = 0 | |
abstract = False |
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
/* | |
* uCAN.h | |
* | |
* Created on: Dec 1, 2013 | |
* Author: nick | |
*/ | |
#ifndef UCAN_H_ | |
#define UCAN_H_ |
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
uint8_t row_counts[4]; | |
for(int row = 0; row < NUM_ROWS; row++) | |
for(int col = 0; col < NUM_COLUMNS; col++) | |
row_counts[row] += (scan[col] >> row) & 1; | |
for(int col = 0; col < NUM_COLUMNS; col++) { | |
uint8_t column_count = set_bits[scan[col]]; | |
for(int row = 0; row < NUM_ROWS; row++) { | |
if(row_counts[row] > 1 && column_count > 1) |
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
void CyBtldrCommStart(void) { | |
UART_Start(); | |
} | |
void CyBtldrCommStop (void) { | |
UART_Stop(); | |
} | |
void CyBtldrCommReset(void) { | |
UART_SpiUartClearRxBuffer(); |
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
void main() | |
{ | |
int i; | |
if(Bootloader_GET_RUN_TYPE == Bootloader_START_BTLDR) | |
Bootloader_Start(); | |
for(i = 0; i < 2000; i++) { | |
uint8 status = Button_Read(); | |
if(status) |
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
// Maps current state (index) to next state for a forward transition. | |
const int8 quadrature_states[] = {0x1, 0x3, 0x0, 0x2}; | |
CY_ISR(quadrature_event_isr) { | |
static int8 last_levels = 3; | |
static int8 count = 0; | |
int levels = Quadrature_Read(); | |
Quadrature_ClearInterrupt(); |