Skip to content

Instantly share code, notes, and snippets.

View rlogiacco's full-sized avatar
💭
I may be slow to respond, be patient...

Roberto Lo Giacco rlogiacco

💭
I may be slow to respond, be patient...
View GitHub Profile
@rlogiacco
rlogiacco / LedDebug.h
Last active August 29, 2015 13:55
Use the built in led to debug your sketch in case you don't have access to the device serial
#ifndef __LED_DEBUG
#define __LED_DEBUG
#if LED_DEBUG
#ifndef LED_DEBUG_PIN
#define LED_DEBUG_PIN LED_BUILTIN
#endif
#ifndef LED_DEBUG_DELAY
@rlogiacco
rlogiacco / SerialDebug.h
Last active August 29, 2015 13:55
Use the serial connection to debug your sketch
#ifndef __SERIAL_DEBUG
#define __SERIAL_DEBUG
#if SERIAL_DEBUG
#ifndef SERIAL_DEBUG_SEPARATOR
#define SERIAL_DEBUG_SEPARATOR " | "
#endif
#define DEBUG_0() Serial.println("### SerialDebug ###")
@rlogiacco
rlogiacco / AnalogAndVoltage.ino
Last active August 29, 2015 14:01
VoltageReference
#include <VoltageReference.h>
VoltageReference vRef;
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("Calibrating voltage reference");
vRef.begin();
}
@rlogiacco
rlogiacco / WaitingWebDriver
Last active August 29, 2015 14:19
Selenium wait for elements
public class WaitingWebDriver {
private SharedWebDriver browser;
private Class<? extends WebDriver> driver;
@Before
public void before() {
driver = ChromeDriver.class;
System.setProperty(SharedWebDriver.SELENIUM_DRIVER_PROPERTY, driver.getName());
@rlogiacco
rlogiacco / Blinker.ino
Created June 3, 2015 12:05
Pseudo Concurrency
#define LED_PIN 13
#define BTN_PIN 2
int volatile prog = 0;
void btnPress() {
// cycle over the available programs
// it can be done in a much compact and simpler way, but I believe this is the most
// simple and clear way to describe it
// some sort of debouncing would be required, but I don't add it here for sake of simplicity
if (prog == 0) {
@rlogiacco
rlogiacco / focus.js
Last active August 29, 2015 14:22
AngularJS UI Utils
angular.module("ui-utils.focus", ['ng'])
.directive('focusMe', function($log) {
return {
link: function(scope, element, attrs) {
scope.$watch(attrs.focusMe, function(value) {
if(value === true) {
$log.debug("value=" + element[0].value);
element[0].focus();
scope[attrs.focusMe] = false;
}
@rlogiacco
rlogiacco / Reset.h
Created September 8, 2015 09:31
Arduino reset via software
#include <avr/io.h>
#include <avr/wdt.h>
#define RESET() wdt_enable(WDTO_30MS); while(1) {}
@rlogiacco
rlogiacco / Plotter.pde
Created November 28, 2013 23:06
Processing scale aware plotter for Arduino usable as coarse oscilloscope. Two Arduino code examples provided.
// Time Aware Plotter
// License: Creative Commons BY-SA
// This program takes ASCII-encoded strings from the serial port at 9600 baud and graphs them.
// It expects up to 6 comma separated values in the range 0 to 1023 followed by a newline.
// Plotting must be started with a mouse click and can be paused with a mouse click as well.
// Please note: while plotting is stopped serial data is discarded!
import processing.serial.*;
@rlogiacco
rlogiacco / PingPong.cpp
Last active January 4, 2016 03:59
PingPong nRF24L01+ example for Spark Core using pins 5 CE and 6 CSN
#ifndef Binary_h
#define Binary_h
#define B0 0
#define B00 0
#define B000 0
#define B0000 0
#define B00000 0
#define B000000 0
#define B0000000 0
@rlogiacco
rlogiacco / templog.sh
Created January 6, 2016 00:13
RPi temperature monitor
#!/bin/bash
LOG_FILE=$1
while :
do
temp=`/opt/vc/bin/vcgencmd measure_temp`
temp=${temp:5:16}
echo $(date '+%F %H:%M:%S') [$temp] >>LOG_FILE
sleep 10
done