From 72182dc78062a0b499cbdb817858787a6c805805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Mon, 14 Oct 2013 20:45:08 +0200 Subject: [PATCH] basic action handling inplemented --- src/main.c | 54 ++++++++++++++++++++++++++++++++++++++++++------------ src/main.h | 3 ++- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/main.c b/src/main.c index cafa080..ef17547 100644 --- a/src/main.c +++ b/src/main.c @@ -78,6 +78,10 @@ ISR(TIMER2_OVF_vect) { /* timer 2 overflow interrupt vector */ timer2_ovf++; /* increase tachometer counter */ } else { tachometer = 0; /* indicate no speed can be measured */ + if (pwr_ok) { /* warn the fan is dead while the power in on */ + power_flag = true; + } + timer2_ovf = 0; } } @@ -171,44 +175,56 @@ int main(void) ioinit(); /* initialize IOs */ uint8_t command_i = 0; /* command index */ + struct nec ir_data; /* last IR data */ + ir_data.valid = false; + ir_data.repeat = false; + ir_data.address = 0; + ir_data.command = 0; + uint8_t ir_repeat = 0; /* number of times the IR data has been repeated */ puts("LED dimmer up & running"); while (true) { /* handle user input */ while (input_flag) { - input_flag = false; /* echo back */ char c = 0; while (command_i3) { + ir_action(ir_data.address,ir_data.command); } } pulse = 0; /* reset burst */ @@ -218,8 +234,7 @@ int main(void) return 0; } - -static void action(char c) +static void uart_action(char c) { switch (c) { case 'l': @@ -369,3 +384,18 @@ static void action(char c) break; } } + +static void ir_action(uint8_t address, uint8_t command) +{ + if (0==address && 72==command) { + printf("switching power supply "); + if (PINB&(1<