From: Jan "Yenya" Kasprzak Date: Thu, 4 Jul 2013 22:59:21 +0000 (+0200) Subject: ambient.c: user-settable ambient light zone X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=b235c2cde53066ab6afd280ccddacd866778c252;p=bike-lights.git 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. --- 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();