diff --git a/src/Makefile.am b/src/Makefile.am index e1ff768cf..db50c59c1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -155,6 +155,8 @@ neutrino_LDADD += \ endif if BOXTYPE_COOL +bin_PROGRAMS += uncooloff +uncooloff_SOURCES = uncooloff.c if BOXMODEL_APOLLO else noinst_PROGRAMS = uncoolinit diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 10b1a98f4..461c611c9 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -3186,7 +3186,7 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode) g_settings.shutdown_timer_record_type = timer_is_rec; saveSetup(NEUTRINO_SETTINGS_FILE); -#if HAVE_COOL_HARDWARE +#if 0 if(retcode) { #endif puts("[neutrino.cpp] executing " NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT "."); @@ -3198,7 +3198,7 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode) mode = mode_off; //CVFD::getInstance()->ShowText(g_Locale->getText(LOCALE_MAINMENU_SHUTDOWN)); -#if HAVE_COOL_HARDWARE +#if 0 my_system("/etc/init.d/rcK"); sync(); my_system(2,"/bin/umount", "-a"); @@ -3260,13 +3260,42 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode) } } else { #endif - if (timer_minutes) + int leds = 0; + int bright = 0; +#if HAVE_COOL_HARDWARE + if (retcode) { + leds = 0x40; + switch (g_settings.led_deep_mode){ + case 0: + leds = 0x0;//off leds + break; + case 1: + leds = 0x60;//on led1 & 2 + break; + case 2: + leds = 0x20;//led1 on , 2 off + break; + case 3: + leds = 0x40;//led2 off, 2 on + break; + default: + break; + } + if (leds && g_settings.led_blink && timer_minutes) + leds |= 0x80; + } + if (cs_get_revision() != 10) + bright = g_settings.lcd_setting[SNeutrinoSettings::LCD_DEEPSTANDBY_BRIGHTNESS]; +#endif + if (timer_minutes || leds) { FILE *f = fopen("/tmp/.timer", "w"); if (f) { fprintf(stderr, "timer_wakeup: %ld\n", timer_minutes * 60); fprintf(f, "%ld\n", timer_minutes * 60); + fprintf(f, "%d\n", leds); + fprintf(f, "%d\n", bright); fclose(f); } else @@ -3292,7 +3321,7 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode) #else exit(retcode); #endif -#if HAVE_COOL_HARDWARE +#if 0 } #endif } diff --git a/src/uncooloff.c b/src/uncooloff.c new file mode 100644 index 000000000..faddf7c21 --- /dev/null +++ b/src/uncooloff.c @@ -0,0 +1,67 @@ +/* + * uncooloff - switch off the box with a possible timer wakeup + * this is needed because the drivers do not implement a proper + * hwclock interface :-( + * + * (C) 2013 Stefan Seyfried + * + * License: GPLv2+ + */ + +#include +#include +#include +#include + +#include + +int main(int argc, char **argv) +{ + int fd; + int leds; + int brightness; + fp_standby_data_t fp; + time_t timer_seconds; + time_t now = time(NULL); + struct tm *tmnow = localtime(&now); + time_t fp_timer = 0; + + if (argc < 3) { + fprintf(stderr, "need timer_seconds, led and brightness values\n"); + return 1; + } + + timer_seconds = atol(argv[1]); + leds = atoi(argv[2]); + brightness = atoi(argv[3]); + + if (timer_seconds) { + fp_timer = (timer_seconds - now) / 60; + if (fp_timer < 1) { + fprintf(stderr, "warning: interval less than 1 minute (%d s) correcting\n", + (timer_seconds - now)); + fp_timer = 1; + } + } + fprintf(stderr, "now: %ld, timer %ld, FP timer %ldmin\n\n", now / 60, timer_seconds / 60, fp_timer); + + fp.brightness = brightness; + fp.flags = leds; + fp.current_hour = tmnow->tm_hour; + fp.current_minute = tmnow->tm_min; + fp.timer_minutes_hi = fp_timer >> 8;; + fp.timer_minutes_lo = fp_timer & 0xFF; + + fd = open("/dev/display", O_RDONLY); + if (fd < 0) + perror("/dev/display"); + else { + if (ioctl(fd, IOC_FP_STANDBY, (fp_standby_data_t *) &fp)) + perror("IOC_FP_STANDBY"); + else { + while (1) + sleep(1); + } + } + return 1; +}