added config options for menu

This commit is contained in:
kiu 2011-08-01 23:34:13 +02:00
parent 99f3095b46
commit 21be4195eb
1 changed files with 33 additions and 7 deletions

View File

@ -37,10 +37,20 @@ void ReinvokeISP(void);
/**************************************************************************/ /**************************************************************************/
//TODO SEC move to config
uint8_t flameBrightnessMax = 0xff;
uint8_t flameBrightnessMin = 0x00;
uint8_t flameSpeedUp = 0x01;
uint8_t flameSpeedDown = 0x01;
uint8_t flameWaitUp = 0xff;
uint8_t flameWaitDown = 0x8f;
//TODO SEC move to config
uint8_t flameEnabled = 0; uint8_t flameEnabled = 0;
uint8_t flameMode = FLAME_OFF; uint8_t flameMode = FLAME_OFF;
uint8_t flameI2Cpwm = 0; uint8_t flameI2Cpwm = 0;
uint16_t flameTicks = 0; uint8_t flameTicks = 0;
uint32_t flameSetI2C(uint8_t cr, uint8_t value) { uint32_t flameSetI2C(uint8_t cr, uint8_t value) {
I2CMasterBuffer[0] = FLAME_I2C_WRITE; I2CMasterBuffer[0] = FLAME_I2C_WRITE;
@ -55,9 +65,17 @@ void setFlamePWM() {
flameSetI2C(FLAME_I2C_CR_PWM0, flameI2Cpwm); // set pwm flameSetI2C(FLAME_I2C_CR_PWM0, flameI2Cpwm); // set pwm
} }
void tick_flame(void) { // every 10ms void tick_flame(void) { // every 10ms
flameTicks++; flameTicks++;
if (flameI2Cpwm > flameBrightnessMax) {
flameI2Cpwm = flameBrightnessMax;
}
if (flameI2Cpwm < flameBrightnessMin) {
flameI2Cpwm = flameBrightnessMin;
}
if (flameMode == FLAME_OFF) { if (flameMode == FLAME_OFF) {
if (isNight() && flameEnabled) { if (isNight() && flameEnabled) {
flameTicks = 0; flameTicks = 0;
@ -66,31 +84,39 @@ void tick_flame(void) { // every 10ms
} }
if (flameMode == FLAME_UP) { if (flameMode == FLAME_UP) {
flameI2Cpwm++; if (flameI2Cpwm + flameSpeedUp > flameI2Cpwm ) {
flameI2Cpwm += flameSpeedUp;
} else {
flameI2Cpwm = 0xFF;
}
push_queue(&setFlamePWM); push_queue(&setFlamePWM);
if (flameI2Cpwm == 0xFF) { if (flameI2Cpwm == flameBrightnessMax) {
flameMode = FLAME_UP_WAIT; flameMode = FLAME_UP_WAIT;
flameTicks = 0; flameTicks = 0;
} }
} }
if (flameMode == FLAME_UP_WAIT) { if (flameMode == FLAME_UP_WAIT) {
if (flameTicks > 0xFF) { if (flameTicks >= flameWaitUp) {
flameMode = FLAME_DOWN; flameMode = FLAME_DOWN;
} }
} }
if (flameMode == FLAME_DOWN) { if (flameMode == FLAME_DOWN) {
flameI2Cpwm--; if (flameI2Cpwm - flameSpeedDown < flameI2Cpwm ) {
flameI2Cpwm -= flameSpeedDown;
} else {
flameI2Cpwm = 0x00;
}
push_queue(&setFlamePWM); push_queue(&setFlamePWM);
if (flameI2Cpwm == 0x00) { if (flameI2Cpwm == flameBrightnessMin) {
flameMode = FLAME_DOWN_WAIT; flameMode = FLAME_DOWN_WAIT;
flameTicks = 0; flameTicks = 0;
} }
} }
if (flameMode == FLAME_DOWN_WAIT) { if (flameMode == FLAME_DOWN_WAIT) {
if (flameTicks > 0x8F) { if (flameTicks >= flameWaitDown) {
flameMode = FLAME_OFF; flameMode = FLAME_OFF;
} }
} }