Skip to content

Instantly share code, notes, and snippets.

View sourceperl's full-sized avatar

l.lefebvre sourceperl

  • Hauts-de-France
View GitHub Profile
*.o
*.elf
@sourceperl
sourceperl / gist:5658900
Last active December 17, 2015 19:10
Set MSP430 for low power mode
// set XTAL 32768 Hz on the board
void main(void) {
// Stop Watchdog
WDTCTL = WDTPW + WDTHOLD;
// MCLK:LFXT1CLK/8
// SMCLK:LFXT1CLK
BCSCTL2 = 0xF8;
// IO setup
P1DIR = 0xFF;
@sourceperl
sourceperl / main.c
Last active May 2, 2024 20:43
Test code MSP430 I2C LCD
#include <msp430g2211.h>
#define I2C_SDA BIT0 // Serial Data line
#define I2C_SCL BIT6 // Serial Clock line
/* A crude delay function. Tune by changing the counter value. */
void delay( unsigned int n ) {
volatile int i;
for( ; n; n-- ) {
@sourceperl
sourceperl / low_bread.ino
Last active December 19, 2015 18:38
Lowpower Arduino test. An ATmega328P on a breadboard powered under 3.3v. Arduino bootloader at 8 MHz internal RC clock.
/*
An ATmega328P on a breadboard powered under 3.3v (2x AA battery)
Arduino bootloader at 8 MHz internal RC clock.
This example code is in the public domain.
Share it's happiness !!!
*/
#include <SPI.h>
@sourceperl
sourceperl / th_pinger.py
Last active April 12, 2024 18:56
Python script for do multi-threaded ping
#!/usr/bin/env python
# ping a list of host with threads for increase speed
# use standard linux /bin/ping utility
from threading import Thread
import subprocess
try:
import queue
except ImportError:
import Queue as queue
@sourceperl
sourceperl / relay_class.py
Created December 5, 2014 15:06
Simple Python class for relay (manage edge front, toggle)
class Relay:
def __init__(self):
self.value = False
self._value = False
@property
def state(self):
"""Get the current relay state."""
return self.value
@sourceperl
sourceperl / rrd_peak_find.py
Created December 11, 2014 08:42
Find peak in value of an RRDtool base.
import rrdtool
import datetime
# retrieve RRD data (3 days past from now)
rrd = rrdtool.fetch('/home/pi/rrd/flow.rrd', 'AVERAGE', '-s -3d')
# timestamp start/end
start = rrd[0][0]
end = rrd[0][1]
step = rrd[0][2]
@sourceperl
sourceperl / fft_paper.pdf
Last active August 29, 2015 14:25
FFT sample in Python2.7
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sourceperl
sourceperl / thingspeak-install.sh
Last active December 7, 2016 19:24 — forked from abythell/thingspeak-install.sh
Bash script to install a Thingspeak server on Debian Jessie
#!/bin/bash
# Automatic install of Thingspeak server on Debian jessie
# Updated to use ruby 2.1.4
## check root level
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
@sourceperl
sourceperl / weather_math.py
Last active November 3, 2023 11:54
Compute frost and dew point (Python function)
import math
def get_frost_point_c(t_air_c, dew_point_c):
"""Compute the frost point in degrees Celsius
:param t_air_c: current ambient temperature in degrees Celsius
:type t_air_c: float
:param dew_point_c: current dew point in degrees Celsius
:type dew_point_c: float