make libpax count_payload_t varables local

This commit is contained in:
cyberman54 2022-02-14 21:34:19 +01:00
parent 736d51a142
commit a1461be403
4 changed files with 38 additions and 29 deletions

View File

@ -9,8 +9,6 @@
#include "display.h" #include "display.h"
#include "sdcard.h" #include "sdcard.h"
extern struct count_payload_t count_from_libpax;
void SendPayload(uint8_t port); void SendPayload(uint8_t port);
void sendData(void); void sendData(void);
void checkSendQueues(void); void checkSendQueues(void);

View File

@ -43,6 +43,7 @@ uint8_t DisplayIsOn = 0;
uint8_t displaybuf[MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8] = {0}; uint8_t displaybuf[MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8] = {0};
static uint8_t plotbuf[MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8] = {0}; static uint8_t plotbuf[MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8] = {0};
static int dp_row = 0, dp_col = 0, dp_font = 0; static int dp_row = 0, dp_col = 0, dp_font = 0;
static struct count_payload_t count; // libpax count storage
hw_timer_t *displayIRQ = NULL; hw_timer_t *displayIRQ = NULL;
@ -175,14 +176,14 @@ void dp_init(bool verbose) {
void dp_refresh(bool nextPage) { void dp_refresh(bool nextPage) {
// update counter values from libpax // update counter values from libpax
libpax_counter_count(&count_from_libpax); libpax_counter_count(&count);
#ifndef HAS_BUTTON #ifndef HAS_BUTTON
static uint32_t framecounter = 0; static uint32_t framecounter = 0;
#endif #endif
// update histogram // update histogram
dp_plotCurve(count_from_libpax.pax, false); dp_plotCurve(count.pax, false);
// if display is switched off we don't refresh it to relax cpu // if display is switched off we don't refresh it to relax cpu
if (!DisplayIsOn && (DisplayIsOn == cfg.screenon)) if (!DisplayIsOn && (DisplayIsOn == cfg.screenon))
@ -240,7 +241,7 @@ void dp_drawPage(bool nextpage) {
// display number of unique macs total Wifi + BLE // display number of unique macs total Wifi + BLE
if (DisplayPage < 5) { if (DisplayPage < 5) {
dp_setFont(MY_FONT_STRETCHED); dp_setFont(MY_FONT_STRETCHED);
dp_printf("%-5d", count_from_libpax.pax); dp_printf("%-5d", count.pax);
} }
switch (DisplayPage) { switch (DisplayPage) {
@ -264,21 +265,21 @@ void dp_drawPage(bool nextpage) {
#if ((WIFICOUNTER) && (BLECOUNTER)) #if ((WIFICOUNTER) && (BLECOUNTER))
if (cfg.wifiscan) if (cfg.wifiscan)
dp_printf("WIFI:%-5d", count_from_libpax.wifi_count); dp_printf("WIFI:%-5d", count.wifi_count);
else else
dp_printf("WIFI:off"); dp_printf("WIFI:off");
if (cfg.blescan) if (cfg.blescan)
dp_printf("BLTH:%-5d", count_from_libpax.ble_count); dp_printf("BLTH:%-5d", count.ble_count);
else else
dp_printf(" BLTH:off"); dp_printf(" BLTH:off");
#elif ((WIFICOUNTER) && (!BLECOUNTER)) #elif ((WIFICOUNTER) && (!BLECOUNTER))
if (cfg.wifiscan) if (cfg.wifiscan)
dp_printf("WIFI:%-5d", count_from_libpax.wifi_count); dp_printf("WIFI:%-5d", count.wifi_count);
else else
dp_printf("WIFI:off"); dp_printf("WIFI:off");
#elif ((!WIFICOUNTER) && (BLECOUNTER)) #elif ((!WIFICOUNTER) && (BLECOUNTER))
if (cfg.blescan) if (cfg.blescan)
dp_printf("BLTH:%-5d", count_from_libpax.ble_count); dp_printf("BLTH:%-5d", count.ble_count);
dp_printf("BLTH:off"); dp_printf("BLTH:off");
#else #else
dp_printf("Sniffer disabled"); dp_printf("Sniffer disabled");

View File

@ -13,6 +13,7 @@ uint8_t MatrixDisplayIsOn = 0;
static uint8_t displaybuf[LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT / 8] = {0}; static uint8_t displaybuf[LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT / 8] = {0};
static unsigned long ulLastNumMacs = 0; static unsigned long ulLastNumMacs = 0;
static time_t ulLastTime = time(NULL); static time_t ulLastTime = time(NULL);
static struct count_payload_t count; // libpax count storage
hw_timer_t *matrixDisplayIRQ = NULL; hw_timer_t *matrixDisplayIRQ = NULL;
@ -76,12 +77,12 @@ void refreshTheMatrixDisplay(bool nextPage) {
case 0: case 0:
// update counter values from libpax // update counter values from libpax
libpax_counter_count(&count_from_libpax); libpax_counter_count(&count);
if (cfg.countermode == 1) { if (cfg.countermode == 1) {
// cumulative counter mode -> display total number of pax // cumulative counter mode -> display total number of pax
if (ulLastNumMacs != count_from_libpax.pax) { if (ulLastNumMacs != count.pax) {
ulLastNumMacs = count_from_libpax.pax; ulLastNumMacs = count.pax;
matrix.clear(); matrix.clear();
DrawNumber(String(ulLastNumMacs)); DrawNumber(String(ulLastNumMacs));
} }
@ -89,10 +90,10 @@ void refreshTheMatrixDisplay(bool nextPage) {
else { // cyclic counter mode -> plot a line diagram else { // cyclic counter mode -> plot a line diagram
if (ulLastNumMacs != count_from_libpax.pax) { if (ulLastNumMacs != count.pax) {
// next count cycle? // next count cycle?
if (count_from_libpax.pax == 0) { if (count.pax == 0) {
// matrix full? then scroll left 1 dot, else increment column // matrix full? then scroll left 1 dot, else increment column
if (col < (LED_MATRIX_WIDTH - 1)) if (col < (LED_MATRIX_WIDTH - 1))
@ -104,7 +105,7 @@ void refreshTheMatrixDisplay(bool nextPage) {
matrix.drawPoint(col, row, 0); // clear current dot matrix.drawPoint(col, row, 0); // clear current dot
// scale and set new dot // scale and set new dot
ulLastNumMacs = count_from_libpax.pax; ulLastNumMacs = count.pax;
level = ulLastNumMacs / LINE_DIAGRAM_DIVIDER; level = ulLastNumMacs / LINE_DIAGRAM_DIVIDER;
row = level <= LED_MATRIX_HEIGHT row = level <= LED_MATRIX_HEIGHT
? LED_MATRIX_HEIGHT - 1 - level % LED_MATRIX_HEIGHT ? LED_MATRIX_HEIGHT - 1 - level % LED_MATRIX_HEIGHT

View File

@ -74,16 +74,19 @@ void sendData() {
uint8_t bitmask = cfg.payloadmask; uint8_t bitmask = cfg.payloadmask;
uint8_t mask = 1; uint8_t mask = 1;
#if (HAS_GPS) #if (HAS_GPS)
gpsStatus_t gps_status; gpsStatus_t gps_status;
#endif #endif
#if (HAS_SDS011) #if (HAS_SDS011)
sdsStatus_t sds_status; sdsStatus_t sds_status;
#endif #endif
#if ((WIFICOUNTER) || (BLECOUNTER))
ESP_LOGD(TAG, "Sending count results: pax=%d / wifi=%d / ble=%d", struct count_payload_t count =
count_from_libpax.pax, count_from_libpax.wifi_count, count_from_libpax; // copy values from global libpax var
count_from_libpax.ble_count); ESP_LOGD(TAG, "Sending count results: pax=%d / wifi=%d / ble=%d", count.pax,
count.wifi_count, count.ble_count);
#endif
while (bitmask) { while (bitmask) {
switch (bitmask & mask) { switch (bitmask & mask) {
@ -91,12 +94,14 @@ void sendData() {
#if ((WIFICOUNTER) || (BLECOUNTER)) #if ((WIFICOUNTER) || (BLECOUNTER))
case COUNT_DATA: case COUNT_DATA:
payload.reset(); payload.reset();
#if !(PAYLOAD_OPENSENSEBOX) #if !(PAYLOAD_OPENSENSEBOX)
payload.addCount(count_from_libpax.wifi_count, MAC_SNIFF_WIFI); payload.addCount(count.wifi_count, MAC_SNIFF_WIFI);
if (cfg.blescan) { if (cfg.blescan) {
payload.addCount(count_from_libpax.ble_count, MAC_SNIFF_BLE); payload.addCount(count.ble_count, MAC_SNIFF_BLE);
} }
#endif #endif
#if (HAS_GPS) #if (HAS_GPS)
if (GPSPORT == COUNTERPORT) { if (GPSPORT == COUNTERPORT) {
// send GPS position only if we have a fix // send GPS position only if we have a fix
@ -107,22 +112,24 @@ void sendData() {
ESP_LOGD(TAG, "No valid GPS position"); ESP_LOGD(TAG, "No valid GPS position");
} }
#endif #endif
#if (PAYLOAD_OPENSENSEBOX) #if (PAYLOAD_OPENSENSEBOX)
payload.addCount(count_from_libpax.wifi_count, MAC_SNIFF_WIFI); payload.addCount(count.wifi_count, MAC_SNIFF_WIFI);
if (cfg.blescan) { if (cfg.blescan) {
payload.addCount(count_from_libpax.ble_count, MAC_SNIFF_BLE); payload.addCount(count.ble_count, MAC_SNIFF_BLE);
#endif #endif
#if (HAS_SDS011) #if (HAS_SDS011)
sds011_store(&sds_status); sds011_store(&sds_status);
payload.addSDS(sds_status); payload.addSDS(sds_status);
#endif #endif
SendPayload(COUNTERPORT);
#ifdef HAS_DISPLAY #ifdef HAS_DISPLAY
dp_plotCurve(count_from_libpax.pax, true); dp_plotCurve(count.pax, true);
#endif #endif
#if (HAS_SDCARD) #if (HAS_SDCARD)
sdcardWriteData(count_from_libpax.wifi_count, sdcardWriteData(count.wifi_count, count.ble_count
count_from_libpax.ble_count
#if (defined BAT_MEASURE_ADC || defined HAS_PMU) #if (defined BAT_MEASURE_ADC || defined HAS_PMU)
, ,
read_voltage() read_voltage()
@ -130,8 +137,10 @@ void sendData() {
); );
#endif // HAS_SDCARD #endif // HAS_SDCARD
SendPayload(COUNTERPORT);
break; // case COUNTDATA break; // case COUNTDATA
#endif
#endif // ((WIFICOUNTER) || (BLECOUNTER))
#if (HAS_BME) #if (HAS_BME)
case MEMS_DATA: case MEMS_DATA: