Merge remote-tracking branch 'upstream/master'

This commit is contained in:
hallard 2018-04-03 11:15:48 +02:00
commit c7d548a7cc
5 changed files with 35 additions and 38 deletions

View File

@ -19,20 +19,20 @@ esp_err_t err;
// populate cfg vars with factory settings // populate cfg vars with factory settings
void defaultConfig() { void defaultConfig() {
cfg.lorasf = LORASFDEFAULT; // 7-12, initial lora spreadfactor defined in main.h cfg.lorasf = LORASFDEFAULT; // 7-12, initial lora spreadfactor defined in main.h
cfg.txpower = 15; // 2-15, lora tx power cfg.txpower = 15; // 2-15, lora tx power
cfg.adrmode = 1; // 0=disabled, 1=enabled cfg.adrmode = 1; // 0=disabled, 1=enabled
cfg.screensaver = 0; // 0=disabled, 1=enabled cfg.screensaver = 0; // 0=disabled, 1=enabled
cfg.screenon = 1; // 0=disbaled, 1=enabled cfg.screenon = 1; // 0=disbaled, 1=enabled
cfg.countermode = 0; // 0=cyclic, 1=cumulative, 2=cyclic confirmed cfg.countermode = 0; // 0=cyclic, 1=cumulative, 2=cyclic confirmed
cfg.rssilimit = 0; // threshold for rssilimiter, negative value! cfg.rssilimit = 0; // threshold for rssilimiter, negative value!
cfg.wifiscancycle = SEND_SECS; // wifi scan cycle [seconds/2] cfg.wifiscancycle = SEND_SECS; // wifi scan cycle [seconds/2]
cfg.wifichancycle = WIFI_CHANNEL_SWITCH_INTERVAL; // wifi channel switch cycle [seconds/100] cfg.wifichancycle = WIFI_CHANNEL_SWITCH_INTERVAL; // wifi channel switch cycle [seconds/100]
cfg.blescantime = BLESCANTIME; // BLE scan cycle duration [seconds] cfg.blescantime = BLESCANTIME; // BLE scan cycle duration [seconds]
cfg.blescancycle = BLESCANCYCLE; // do a BLE scan after [BLESCANCYCLE] full Wifi scan cycles cfg.blescancycle = BLESCANCYCLE; // do a BLE scan after [BLESCANCYCLE] full Wifi scan cycles
cfg.blescan = 1; // 0=disabled, 1=enabled cfg.blescan = 1; // 0=disabled, 1=enabled
cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4) cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
cfg.rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%) cfg.rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%)
strncpy( cfg.version, PROGVERSION, sizeof(cfg.version)-1 ); strncpy( cfg.version, PROGVERSION, sizeof(cfg.version)-1 );
} }
@ -110,7 +110,7 @@ void saveConfig() {
nvs_set_i8(my_handle, "blescantime", cfg.blescantime); nvs_set_i8(my_handle, "blescantime", cfg.blescantime);
if( nvs_get_i8(my_handle, "blescancycle", &flash8) != ESP_OK || flash8 != cfg.blescancycle ) if( nvs_get_i8(my_handle, "blescancycle", &flash8) != ESP_OK || flash8 != cfg.blescancycle )
nvs_set_i8(my_handle, "blescantime", cfg.blescancycle); nvs_set_i8(my_handle, "blescancycle", cfg.blescancycle);
if( nvs_get_i8(my_handle, "blescanmode", &flash8) != ESP_OK || flash8 != cfg.blescan ) if( nvs_get_i8(my_handle, "blescanmode", &flash8) != ESP_OK || flash8 != cfg.blescan )
nvs_set_i8(my_handle, "blescanmode", cfg.blescan); nvs_set_i8(my_handle, "blescanmode", cfg.blescan);

View File

@ -34,7 +34,7 @@ typedef struct {
int8_t blescancycle; // BLE scan frequency, once after [blescancycle] full wifi scans int8_t blescancycle; // BLE scan frequency, once after [blescancycle] full wifi scans
int8_t blescan; // 0=disabled, 1=enabled int8_t blescan; // 0=disabled, 1=enabled
int8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4) int8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4)
int8_t rgblum; // RGB Led luminosity (0 100%) int8_t rgblum; // RGB Led luminosity (0..100%)
char version[10]; // Firmware version char version[10]; // Firmware version
} configData_t; } configData_t;

View File

@ -136,12 +136,12 @@ static void lora_init (osjob_t* j) {
LMIC_startJoining(); LMIC_startJoining();
} }
// LMIC Task // LMIC FreeRTos Task
void lorawan_loop(void * pvParameters) { void lorawan_loop(void * pvParameters) {
configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check
static bool led_state ; static bool led_state;
bool new_led_state ; bool new_led_state;
while(1) { while(1) {
uint16_t color; uint16_t color;
@ -152,24 +152,25 @@ void lorawan_loop(void * pvParameters) {
// is prior to send because joining state send data // is prior to send because joining state send data
if ( LMIC.opmode & (OP_JOINING | OP_REJOIN) ) { if ( LMIC.opmode & (OP_JOINING | OP_REJOIN) ) {
color = COLOR_YELLOW; color = COLOR_YELLOW;
// Joining Quick blink 20ms on each 1/5 second // quick blink 20ms on each 1/5 second
new_led_state = ((millis() % 200) < 20) ? HIGH : LOW; new_led_state = ((millis() % 200) < 20) ? HIGH : LOW;
// Small blink 10ms on each 1/2sec (not when joining) // TX data pending
} else if (LMIC.opmode & (OP_TXDATA | OP_TXRXPEND)) { } else if (LMIC.opmode & (OP_TXDATA | OP_TXRXPEND)) {
color = COLOR_BLUE; color = COLOR_BLUE;
// small blink 10ms on each 1/2sec (not when joining)
new_led_state = ((millis() % 500) < 20) ? HIGH : LOW; new_led_state = ((millis() % 500) < 20) ? HIGH : LOW;
// This should not happen so indicate a pb // This should not happen so indicate a problem
} else if ( LMIC.opmode & (OP_TXDATA | OP_TXRXPEND | OP_JOINING | OP_REJOIN) == 0 ) { } else if ( LMIC.opmode & (OP_TXDATA | OP_TXRXPEND | OP_JOINING | OP_REJOIN) == 0 ) {
color = COLOR_RED; color = COLOR_RED;
// Heartbeat long blink 200ms on each 2 seconds // heartbeat long blink 200ms on each 2 seconds
new_led_state = ((millis() % 2000) < 200) ? HIGH : LOW; new_led_state = ((millis() % 2000) < 200) ? HIGH : LOW;
} else { } else {
rgb_set_color(COLOR_NONE); // led off
rgb_set_color(COLOR_NONE);
} }
// led need to change state ? // led need to change state? avoid digitalWrite() for nothing
// avoid digitalWrite() for nothing
if (led_state != new_led_state) { if (led_state != new_led_state) {
if (new_led_state == HIGH) { if (new_led_state == HIGH) {
set_onboard_led(1); set_onboard_led(1);
@ -302,18 +303,17 @@ void wifi_sniffer_loop(void * pvParameters) {
u8x8.clearLine(6); u8x8.clearLine(6);
if (cfg.screenon && cfg.screensaver) { if (cfg.screenon && cfg.screensaver) {
vTaskDelay(2000/portTICK_PERIOD_MS); // pause for displaying results vTaskDelay(2000/portTICK_PERIOD_MS); // pause for displaying results
} }
yield(); yield();
u8x8.setPowerSave(1 && cfg.screensaver); // set display off if screensaver is enabled u8x8.setPowerSave(1 && cfg.screensaver); // set display off if screensaver is enabled
} // end of send data cycle } // end of send data cycle
else { else {
#ifdef BLECOUNTER // execute BLE count if BLE function is enabled #ifdef BLECOUNTER
if (nloop % (WIFI_CHANNEL_MAX * cfg.blescancycle) == 0 ) { // once after cfg.blescancycle Wifi scans, do a BLE scan if (nloop % (WIFI_CHANNEL_MAX * cfg.blescancycle) == 0 ) // once after cfg.blescancycle Wifi scans, do a BLE scan
if (cfg.blescan) // execute BLE count if BLE function is enabled if (cfg.blescan) // execute BLE count if BLE function is enabled
BLECount(); BLECount();
} #endif
#endif
} // end of channel rotation loop } // end of channel rotation loop
} // end of infinite wifi scan loop } // end of infinite wifi scan loop
} }

View File

@ -1,5 +1,5 @@
// program version // program version - note: increment version after modifications to configData_t struct!!
#define PROGVERSION "1.2.85" // use max 10 chars here! #define PROGVERSION "1.2.87" // use max 10 chars here!
#define PROGNAME "PAXCNT" #define PROGNAME "PAXCNT"
// Verbose enables serial output // Verbose enables serial output

View File

@ -7,9 +7,6 @@
// RGB Led instance // RGB Led instance
SmartLed rgb_led(LED_WS2812, 1, HAS_RGB_LED); SmartLed rgb_led(LED_WS2812, 1, HAS_RGB_LED);
// Luminosity from 0 to 100%
uint8_t rgb_luminosity = 50 ;
float rgb_CalcColor(float p, float q, float t) float rgb_CalcColor(float p, float q, float t)
{ {
if (t < 0.0f) if (t < 0.0f)
@ -70,7 +67,7 @@ void rgb_set_color(uint16_t hue) {
// H (is color from 0..360) should be between 0.0 and 1.0 // H (is color from 0..360) should be between 0.0 and 1.0
// S is saturation keep it to 1 // S is saturation keep it to 1
// L is brightness should be between 0.0 and 0.5 // L is brightness should be between 0.0 and 0.5
// rgb_luminosity is between 0 and 100 (percent) // cfg.rgblum is between 0 and 100 (percent)
RGBColor target = rgb_hsl2rgb( hue / 360.0f, 1.0f, 0.005f * cfg.rgblum); RGBColor target = rgb_hsl2rgb( hue / 360.0f, 1.0f, 0.005f * cfg.rgblum);
//uint32_t color = target.R<<16 | target.G<<8 | target.B; //uint32_t color = target.R<<16 | target.G<<8 | target.B;
rgb_led[0] = Rgb(target.R, target.G, target.B); rgb_led[0] = Rgb(target.R, target.G, target.B);