Each led 1-4 corresponds to a temp (cpu,gpu,eerom,mb) on my modded freestyle.
configured as green <= 40C, orange <= 50C, red >50C.
these are good ranges for my box, but then again i'm not running a xenon.
smc_constants.h
CODE
//Thanks to www.free60.org/SMC for helping me get front LEDs right
#pragma once
#ifndef _SMC_CONSTANTS_H
#define _SMC_CONSTANTS_H
//sorry for the extreme amount of constants trying to make functions
//easier to use
//Power LED
#define POWER_LED_BLINK 0x10
#define POWER_LED_DEFAULT 0x02
#define POWER_LED_ON 0x01
#define POWER_LED_OFF 0X03
//Quadrant LEDs
//NOTE: LED constants are determined with console laying down
// with LED color bits being, starting from tope left 1, 2, 4, 8
//Thanks to unknown v2 for the following
typedef enum _LEDState
{
OFF = 0x00,
RED = 0x08,
GREEN = 0x80,
ORANGE = 0x88
}LEDState;
#endif
smc.h
CODE
//Thanks to tmbinc for smc.c
#pragma once
#ifndef _SMC_H
#define _SMC_H
#include
#include "smc_constants.h"
//Call to SMC message function in xboxkrnl.lib
extern "C" void __stdcall HalSendSMCMessage(LPVOID input, LPVOID output); //thanks to cory1492
class smc
{
public:
void SetPowerLED(unsigned char command, bool animate);
void SetLEDS(LEDState s1, LEDState s2, LEDState s3, LEDState s4); //Thanks unknown v2
void GetTemps(float *temps, bool celsius);
private:
};
#endif
smc.cpp
CODE
#include "smc.h"
#include
//Usage: command is one of the POWER_LED constants from smc_constant.h
// animate is true for ring LED startup light sequence
void smc::SetPowerLED(unsigned char command, bool animate)
{
unsigned char msg[0x10];
memset(msg, 0x00, 0x10);
msg[0] = 0x8c;
msg[1] = command;
msg[2] = (animate ? 0x01 : 0x00);
HalSendSMCMessage(msg, NULL);
}
//Usage: color is one of LED constants from smc_constant.h
void smc::SetLEDS(LEDState s1, LEDState s2, LEDState s3, LEDState s4)
{
unsigned char msg[0x10];
msg[0] = 0x99;
msg[1] = 0x01;
msg[2] = ((s1>>3) | (s2>>2) | (s3>>1) | (s4)); //Thanks unknown v2
HalSendSMCMessage(msg, NULL);
}
//Usage: temps contains the returned temperature values
// temps[0] = CPU
// temps[1] = GPU
// temps[2] = EDRAM
// temps[3] = MB
void smc::GetTemps(float *temps, bool celsius)
{
unsigned char msg[0x10];
unsigned char values[0x10];
int i;
memset(msg, 0x00, 0x10);
memset(values, 0x00, 0x10);
msg[0] = 0x07;
HalSendSMCMessage(msg, values);
for(i=0; i<4; i++)
temps = (values[i * 2 + 1] | (values[i * 2 +2] <<8)) / 256.0;
if(!celsius)
for(i=0; i<4; i++)
temps = (9/5) * temps + 32;
}