From b235c2cde53066ab6afd280ccddacd866778c252 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Fri, 5 Jul 2013 00:59:21 +0200 Subject: [PATCH] ambient.c: user-settable ambient light zone User-settable parameter 0 is now the ambient light zone: Value 0 means to use the ambient light sensor, values 1 .. N_AMBIENT_ZONES represent the manually set light level. --- firmware/ambient.c | 8 ++++++-- firmware/buttons.c | 4 +++- firmware/lights.h | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/firmware/ambient.c b/firmware/ambient.c index caeca14..19b7a13 100644 --- a/firmware/ambient.c +++ b/firmware/ambient.c @@ -23,13 +23,12 @@ typedef struct { * Note: these have to be sorted, starting with 0, ending with 0xFFFF * and having small overlaps in order to provide a bit of hysteresis. */ -static ambient_zone_t ambient_zones[] = { +static ambient_zone_t ambient_zones[N_AMBIENT_ZONES] = { { 0x0000 , 0x0270< 0) + ambient_zone = byte_val - 1; + if (old_zone != ambient_zone) { #if 0 log_byte(0xab); diff --git a/firmware/buttons.c b/firmware/buttons.c index d839e8d..c3cdc52 100644 --- a/firmware/buttons.c +++ b/firmware/buttons.c @@ -52,7 +52,9 @@ union { * mode. */ static unsigned char user_params[N_USER_PARAMS] = { 0, 0, 0 }; -static unsigned char user_params_max[N_USER_PARAMS] = { 3, 2, 2 }; +static unsigned char user_params_max[N_USER_PARAMS] = { + N_AMBIENT_ZONES+1, 2, 2 +}; static unsigned char user_params_state = 0; /* diff --git a/firmware/lights.h b/firmware/lights.h index 081237b..71051e9 100644 --- a/firmware/lights.h +++ b/firmware/lights.h @@ -77,6 +77,7 @@ void gpio_set(unsigned char n, unsigned char on); /* ambient.c */ #define AMBIENT_ADC_SHIFT 0 /* 1 measurement per callback */ +#define N_AMBIENT_ZONES 4 void init_ambient(); void susp_ambient(); void ambient_log_min_max(); -- 2.39.3