Tuesday, July 12, 2011

Antisocial Adblock List fixed the interwebs

If you hate Facebook as much as I do, or even if you like Facebook, but don't want other websites sites slowed to a crawl by 100's of 'like' and 'share' buttons, subscribe to Hubird's Antisocial AdBlock filter list. It fixes the interwebs.

Adversity Adblock List

Saturday, December 11, 2010

atmega*8 Hardware Sleep-Wake Toggle

While working on some holiday projects, I needed on off switches for some JeeNode based widgets. It took me a while to get it working well, and I learned some stuff while doing it. Here is the software and a explanation of the hardware setup. Enjoy.


/*
SleepWakeToggle

SUMMARY
Toggles an atmega*8 state from running to lowest power sleep
mode using a hardware interrupt, e.g. a switch. Suitable for
Arduino, JeeNode, etc.

WHY
Battery powered devices last double-plus-much-longer if you power
the chip down when not in use.

HOW IT WORKS
Interrupts are a way of having your program flow altered by simple
real world events (e.g. passage of time or activation of switches).

This program demonstrates using a single switch to accomplish two
things: putting the chip in sleep mode and then waking it up. When
a switch is activated, an interrupt is triggered and program
control is shifted to a function you specify (a callback). Two
hardware interrupts are available INT0 and INT1.

Boldly rebinding INT0/INT1 callbacks to the wake and sleep functions
in the callbacks themselves is bad magic, and doesn't seem to work
:-). So the sleep function is called from loop() after a callback
sets a flag. This way the callback which triggers sleep (here:
'toggle') is done before 'void sleep()' actually runs. This is good
because, the interrupt has to be rebound to 'wake' just before going
in to sleep_mode.

HARDWARE SETUP
Lowest power sleep mode, SLEEP_MODE_PWR_DOWN, can only respond to a
pin going from high to low. Hence, tie desired pin (2 or 3) to +
with a resistor (i.e. a "pull-up" resistor), and connect a momentary
switch to ground and the pin.

SOFTWARE SETUP
You will want to provide functions that do something interesting and
that cause the system to be in your desired state before actually
powering down. These are: "void importantThing()" and "void
prepareToSleep()" below. The state that is achieved after power up
or reset is selected by setting the global flag buttonPushed in the
setup function.

Hereby placed in the public domain, December 2010
by Kael Fischer <kael.fischer@gmail.com>

*/

// hardware interrupt stuff
#include <avr/sleep.h>
#define INT0 0
#define INT0_PIN 2
#define INT1 1
#define INT1_PIN 3

// application specific stuff
#define BLINK_PIN 13

// global flags
int buttonPushed;

void importantThing(){
// the 'work' the program does
digitalWrite(BLINK_PIN, HIGH);
delay(1000);
digitalWrite(BLINK_PIN, LOW);
delay(1000);
}

void prepareToSleep(){
// When a button is pushed
// do some prep before sleeping
// to get in the desired state
digitalWrite(BLINK_PIN, LOW);
}

void wake(){

// This is the callback that runs when the
// chip is waking up.
buttonPushed=0;

// Can set variables and check stuff. Cannot do fancy stuff.
// Program flow returns to line after 'sleep_mode()' in sleep.

// No code is required here.
}

void toggle(){
// set a flag telling system to sleep on next loop iteration.
// this is the normal running state callback triggered by the
// switch.
detachInterrupt(1); // this seems to be allowed in callback
if (buttonPushed ==0){ // just in case, ignore switch if already
buttonPushed=1; // doing it
}
}

void sleep(){
prepareToSleep(); //application specific

// YOU ARE GETTING SLEEPY.....
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
attachInterrupt(INT1,wake,LOW); // rebind interrupt
sleep_mode(); // sleeping

// program returns here, after 'wake' callback

// now back to loop
}

void setup() {
// On Off Toggle setup
pinMode(INT1_PIN, INPUT); // set switch pin to input
// to limit current
attachInterrupt(INT1,toggle,LOW);
buttonPushed=1; // set to 1 = sleep after reset
// 0 = run loop after reset

// app specific setup here
pinMode(BLINK_PIN, OUTPUT);
}

void loop() {
if (buttonPushed == 1) {
sleep();
} else {
// reset button events to sleep
attachInterrupt(INT1,toggle,LOW);
}
// do important things
importantThing();
}

Sunday, December 5, 2010

Recent Icicles




The Dork Haus had some great icicles over Thanksgiving and a few days after. It was cold. Click through and check it out at higher resolution: Gallery link.

Thursday, September 30, 2010

Swingin' at Whole Foods?



Whole Foods (inc.) in California always seemed so uptight.

Monday, September 20, 2010

The Meat Eaters - NYTimes.com


Jeff McMahan says: : it would be instrumentally good if predatory animal species were to become extinct and be replaced by new herbivorous species. A very modest proposal, of course.

Tuesday, July 20, 2010

Sunday, July 11, 2010

black raspberry bounty

year 2 for the berries, and they are rocking. this am we got 37 more for a total of 98 so far.

Published with Blogger-droid v1.4.5

Friday, April 9, 2010

Atheist Barbie's going to do science! (stand back)


Atheist Barbie

BONUS Document Friday: Alexander Haig and the Wiretapping of American Citizens « UNREDACTED

Haig totally should have done prison time - for so many things.


Former Secretary of State Alexander M. Haig,who died last week at the age of 85, played a variety of roles in the military and the government, including combat duty in Korea and Vietnam, Army Chief of Staff, White House Chief of Staff, and Supreme Allied Commander Europe. It is worth remembering, however, that when he was military assistant to national security adviser Henry Kissinger and later his deputy, Haig played a central role in a wiretap scandal which was one of the abuses of power that brought down the presidency of Richard M. Nixon. Indeed, the wiretaps were an element of Article 2 of the articles of impeachmentadopted by the House Judiciary Committee on July 27, 1974.
...
When Haig made the formal request for the wiretaps, he told FBI assistant director William Sullivan that the request was “made on the highest authority” and that the matter was “so sensitive it demands handling on a need-to-know basis, with no record maintained.” That was not the way the FBI did business, especially when White House officials were issuing unprecedented requests to wiretap White House aides...


BONUS Document Friday: Alexander Haig and the Wiretapping of American Citizens « UNREDACTED

Sunday, April 4, 2010

How-To: Make Peeps sushi?

The latest from the the good people at Make:


How-To: Make Peeps sushi?:
peepshi-1.jpg


peepshi-2.jpg


Some Peeps, some Rice Krispies treats, and some fruit roll-ups, and you've got delicious 'Peepshi.' (Okay, I think I'll be sick now...)



How to Make Peepshi = Peeps Sushi



More:

Annual Parade o' Peeps



Read more | Permalink | Comments |



Read more articles in Holiday projects |


Digg this!"

Wednesday, March 31, 2010

Tuesday, March 9, 2010

Friday, March 5, 2010