Here is the service, source code and installer included: download
Edit: This was updated 1/22/10, fixes: config file was not being read properly, added shortcuts to configuration folder and start/stop commands for service. Remember to read the readme and put your audio device guid's in the config if you want the audio output polling feature to work.
A windows power management event triggers a byte to be sent to the microcontroller, which then sends out an IR code. Optionally, the default sound device is polled via DirectX and any changes detected cause an IR code to be sent to change the input on the amp.
Here is the code for the microcontroller, it simply gets a byte from the serial port and decides what to do based on its value. It sends back a linefeed as an ack. The button is just a simple on/off, totally optional.
/*
* electrosthetics IRremotePowerSave: power saving project - microcontroller side
* info : http://electrosthetics.blogspot.com/2009/11/arduino-universal-remote-and-more.html
* IRremote lib Copyright 2009 Ken Shirriff http://arcfn.com
*
*/
#include
IRsend irsend;
int on = 0;
int BUTTON_PIN = 12;
int STATUS_PIN = 13;
int inByte = 0;
void setup()
{
Serial.begin(9600);
pinMode(BUTTON_PIN, INPUT);
pinMode(STATUS_PIN, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
// get incoming byte:
inByte = Serial.read();
switch (inByte) {
case 0x01:
irsend.sendNEC(0x817E817E, 32); // send on
on = true;
break;
case 0x02:
irsend.sendNEC(0x817E01FE, 32); // send off
on = false;
break;
case 0x10:
irsend.sendNEC(0xA15E1EE1, 32); // send MultiChan
break;
case 0x11:
irsend.sendNEC(0xA15E7C83, 32); // send DVD
break;
}
Serial.write("\n");
digitalWrite(STATUS_PIN, HIGH);
delay(500);
digitalWrite(STATUS_PIN, LOW);
} else {
if (digitalRead(BUTTON_PIN)) {
if (on) {
irsend.sendNEC(0x817E01FE, 32); // send off
on = false;
} else {
irsend.sendNEC(0x817E817E, 32); // send on
on = true;
}
digitalWrite(STATUS_PIN, HIGH);
delay(1000);
digitalWrite(STATUS_PIN, LOW);
}
}
}
h
ReplyDelete