Merge pull request #393 from cyberman54/master

sync master -> dev
This commit is contained in:
Verkehrsrot 2019-07-20 21:22:37 +02:00 committed by GitHub
commit 8826a26c7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 97 additions and 98 deletions

View File

@ -42,8 +42,7 @@
#define SCREEN_MODE (0x80)
// I2C bus access control
#define I2C_MUTEX_LOCK() \
xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(3 * DISPLAYREFRESH_MS)) == pdTRUE
#define I2C_MUTEX_LOCK() xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(10)) == pdTRUE
#define I2C_MUTEX_UNLOCK() xSemaphoreGive(I2Caccess)
// Struct holding devices's runtime configuration

View File

@ -26,6 +26,7 @@ halfile = generic.h
;halfile = lolin32lora.h
;halfile = lolin32lite.h
;halfile = wemos32oled.h
;halfile = wemos32matrix.h
;halfile = octopus32.h
[platformio]
@ -41,7 +42,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I
[common]
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
release_version = 1.7.8
release_version = 1.7.82
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
debug_level = 3
@ -50,8 +51,6 @@ otakeyfile = ota.conf
lorakeyfile = loraconf.h
lmicconfigfile = lmic_config.h
platform_espressif32 = espressif32@1.9.0
board_build.partitions = min_spiffs.csv
board = esp32dev
monitor_speed = 115200
upload_speed = 115200
lib_deps_lora =
@ -97,11 +96,11 @@ build_flags_all =
-mfix-esp32-psram-cache-issue
[env]
board = ${common.board}
framework = arduino
board = esp32dev
board_build.partitions = min_spiffs.csv
upload_speed = ${common.upload_speed}
platform = ${common.platform_espressif32}
framework = arduino
board_build.partitions = ${common.board_build.partitions}
lib_deps = ${common.lib_deps_all}
build_flags = ${common.build_flags_all}
upload_protocol = ${common.upload_protocol}

View File

@ -28,19 +28,12 @@ void button_init(int pin) {
#ifdef HAS_MATRIX_DISPLAY
refreshTheMatrixDisplay(true); // switch to next display page
#endif
#if (!defined HAS_DISPLAY) && (!defined HAS_MATRIX_DISPLAY)
payload.reset();
payload.addButton(0x01);
SendPayload(BUTTONPORT, prio_normal);
#endif
});
b->setOnHolding([]() {
#if (HAS_LORA)
cfg.adrmode = !cfg.adrmode;
LMIC_setAdrMode(cfg.adrmode);
#endif
payload.reset();
payload.addButton(0x01);
SendPayload(BUTTONPORT, prio_normal);
});
// attach interrupt to the button

View File

@ -22,14 +22,14 @@ void defaultConfig() {
WIFI_CHANNEL_SWITCH_INTERVAL; // wifi channel switch cycle [seconds/100]
cfg.blescantime =
BLESCANINTERVAL /
10; // BT channel scan cycle [seconds/100], default 1 (= 10ms)
cfg.blescan = 0; // 0=disabled, 1=enabled
cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
cfg.vendorfilter = 1; // 0=disabled, 1=enabled
cfg.rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%)
cfg.monitormode = 0; // 0=disabled, 1=enabled
cfg.runmode = 0; // 0=normal, 1=update
cfg.payloadmask = 0xFF; // all payload switched on
10; // BT channel scan cycle [seconds/100], default 1 (= 10ms)
cfg.blescan = BLECOUNTER; // 0=disabled, 1=enabled
cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
cfg.vendorfilter = VENDORFILTER; // 0=disabled, 1=enabled
cfg.rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%)
cfg.monitormode = 0; // 0=disabled, 1=enabled
cfg.runmode = 0; // 0=normal, 1=update
cfg.payloadmask = 0xFF; // all payload switched on
cfg.bsecstate[BSEC_MAX_STATE_BLOB_SIZE] = {
0}; // init BSEC state for BME680 sensor

View File

@ -306,12 +306,12 @@ void draw_page(time_t t, uint8_t page) {
wasnofix = false;
}
// line 3-4: GPS latitude
snprintf(buff, sizeof(buff), "%c%-07.4f",
snprintf(buff, sizeof(buff), "%c%07.4f",
gps.location.rawLat().negative ? 'S' : 'N', gps.location.lat());
u8x8.draw2x2String(0, 3, buff);
// line 6-7: GPS longitude
snprintf(buff, sizeof(buff), "%c%-07.4f",
snprintf(buff, sizeof(buff), "%c%07.4f",
gps.location.rawLat().negative ? 'W' : 'E', gps.location.lng());
u8x8.draw2x2String(0, 6, buff);
@ -334,7 +334,7 @@ void draw_page(time_t t, uint8_t page) {
#if (HAS_BME)
// line 2-3: Temp
snprintf(buff, sizeof(buff), "TMP:%--4.1f", bme_status.temperature);
snprintf(buff, sizeof(buff), "TMP:%-4.1f", bme_status.temperature);
u8x8.draw2x2String(0, 2, buff);
// line 4-5: Hum

View File

@ -79,13 +79,12 @@ void IRAM_ATTR gps_storetime(gpsStatus_t &gps_store) {
if (gps.time.isUpdated() && gps.date.isValid() && (gps.time.age() < 1000)) {
/* nmea telegram serial delay compensation; not sure if we need this?
// nmea telegram serial delay compensation; not sure if we need this?
if (gps.time.age() > nmea_txDelay_ms)
gps_store.timedate.Second = gps.time.second() + 1;
else
gps_store.timedate.Second = gps.time.second();
*/
if (gps.time.age() > nmea_txDelay_ms)
gps_store.timedate.Second = gps.time.second() + 1;
else
gps_store.timedate.Second = gps.time.second();
gps_store.timedate.Second = gps.time.second();
gps_store.timedate.Minute = gps.time.minute();

47
src/hal/wemos32matrix.h Normal file
View File

@ -0,0 +1,47 @@
// clang-format off
// upload_speed 921600
// board lolin32
#ifndef _WEMOS32MATRIX_H
#define _WEMOS32MATRIX_H
#include <stdint.h>
#define HAS_LED NOT_A_PIN // no LED
// LED Matrix display settings
#define HAS_MATRIX_DISPLAY 1 // Uncomment to enable LED matrix display output
#define LED_MATRIX_WIDTH 64 // Width in pixels (LEDs) of your display
#define LED_MATRIX_HEIGHT 16 // Height in pixels (LEDs ) of your display
// Pin numbers work fine for Wemos Lolin32 board (all used pins are on 1 side of the board)
// Explanation of pin signals see https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/new-wiring
#define MATRIX_DISPLAY_SCAN_US 500 // Matrix display scan rate in microseconds (1ms is about 'acceptable')
#define LED_MATRIX_LATCHPIN 13 // LAT (or STB = Strobe)
#define LED_MATRIX_CLOCKPIN 32 // CLK
#define LED_MATRIX_EN_74138 12 // EN (or OE)
#define LED_MATRIX_LA_74138 14 // LA (or A)
#define LED_MATRIX_LB_74138 27 // LB (or B)
#define LED_MATRIX_LC_74138 25 // LC (or C)
#define LED_MATRIX_LD_74138 26 // LD (or D)
#define LED_MATRIX_DATA_R1 33 // R1 (or R0)
// CLK: The clock signal moves the data bits from pin R1 ("red") in the shift registers
// LAT: The latch signal enables LEDs according to the shift register's contents
// Line Selects: LA, LB, LC, LD select which rows of the display are currently lit (0 .. 15)
// OE: Output enable switches the LEDs on/off while transitioning from one row to the next
/*
How it works:
1. clock out 8 bytes for columns via R1 and CLK (8 * 8 bit -> 64 columns)
2. OE disable (LEDs off)
3. select line to lit with LA/LB/LC/LD hex coded (4 bit -> 16 rows)
4. latch data from shift registers to columns
5. OE enable (LEDs on)
6. repeat with step1 for next line
*/
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
#endif

View File

@ -7,41 +7,14 @@
#include <stdint.h>
// Hardware related definitions for TTGO T-Beam board
// (only) for older T-Beam version T22_V05 eternal wiring LORA_IO1 to GPIO33 is needed!
//
// pinouts taken from http://tinymicros.com/wiki/TTGO_T-Beam
#define HAS_LED NOT_A_PIN // no LED
//#define HAS_LORA 1 // comment out if device shall not send data via LoRa
//#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
//#define BOARD_HAS_PSRAM // use extra 4MB external RAM
//#define HAS_BUTTON GPIO_NUM_39 // on board button (next to reset)
//#define BAT_MEASURE_ADC ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
//#define BAT_VOLTAGE_DIVIDER 2 // voltage divider 100k/100k on board
// GPS settings
//#define HAS_GPS 1 // use on board GPS
//#define GPS_SERIAL 9600, SERIAL_8N1, GPIO_NUM_12, GPIO_NUM_15 // UBlox NEO 6M
//#define GPS_INT GPIO_NUM_34 // 30ns accurary timepulse, to be external wired on pcb: NEO 6M Pin#3 -> GPIO34
// enable only if device has these sensors, otherwise comment these lines
// BME680 sensor on I2C bus
//#define HAS_BME 1 // Enable BME sensors in general
//#define HAS_BME680 SDA, SCL
//#define BME680_ADDR BME680_I2C_ADDR_PRIMARY // !! connect SDIO of BME680 to GND !!
// display (if connected)
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
#define MY_OLED_SDA (5)
#define MY_OLED_SCL (4)
#define MY_OLED_RST U8X8_PIN_NONE
#define DISPLAY_FLIP 1 // use if display is rotated
// user defined sensors (if connected)
//#define HAS_SENSORS 1 // comment out if device has user defined sensors
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
#endif

View File

@ -121,13 +121,16 @@ void IRAM_ATTR GpsIRQ() {
int mask_user_IRQ() {
// begin of time critical section: lock I2C bus to ensure accurate timing
if (!I2C_MUTEX_LOCK())
if (I2C_MUTEX_LOCK()) {
xTaskNotify(irqHandlerTask, MASK_IRQ, eSetBits);
return 0;
} else
return 1; // failure
xTaskNotify(irqHandlerTask, MASK_IRQ, eSetBits);
}
int unmask_user_IRQ() {
// end of time critical section: release I2C bus
I2C_MUTEX_UNLOCK();
xTaskNotify(irqHandlerTask, UNMASK_IRQ, eSetBits);
return 0;
}

View File

@ -21,9 +21,9 @@ uint8_t displaybuf[LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT / NUMCHARS];
// --- SELECT YOUR FONT HERE ---
const FONT_INFO *ActiveFontInfo = &digital7_18ptFontInfo;
//const FONT_INFO *ActiveFontInfo = &arialNarrow_17ptFontInfo;
//const FONT_INFO *ActiveFontInfo = &gillSansMTCondensed_18ptFontInfo;
//const FONT_INFO *ActiveFontInfo = &gillSansMTCondensed_16ptFontInfo;
// const FONT_INFO *ActiveFontInfo = &arialNarrow_17ptFontInfo;
// const FONT_INFO *ActiveFontInfo = &gillSansMTCondensed_18ptFontInfo;
// const FONT_INFO *ActiveFontInfo = &gillSansMTCondensed_16ptFontInfo;
const uint8_t *iaActiveFont = ActiveFontInfo->Bitmap;
const FONT_CHAR_INFO *ActiveFontCharInfo = ActiveFontInfo->Descriptors;
@ -68,6 +68,7 @@ void refreshTheMatrixDisplay(bool nextPage) {
matrix.clear();
DrawNumber(String(ulLastNumMacs));
}
break;
case 1:
@ -79,6 +80,7 @@ void refreshTheMatrixDisplay(bool nextPage) {
second(t));
DrawNumber(String(buff));
}
break;
} // switch page

View File

@ -183,7 +183,6 @@ void showLoraKeys(void) {
void onEvent(ev_t ev) {
char buff[24] = "";
uint32_t now_micros = 0;
switch (ev) {
@ -421,7 +420,7 @@ esp_err_t lora_stack_init() {
return ESP_FAIL;
}
ESP_LOGI(TAG, "LORA send queue created, size %d Bytes",
SEND_QUEUE_SIZE * PAYLOAD_BUFFER_SIZE);
SEND_QUEUE_SIZE * sizeof(MessageBuffer_t));
ESP_LOGI(TAG, "Starting LMIC...");
@ -460,7 +459,7 @@ void lora_enqueuedata(MessageBuffer_t *message, sendprio_t prio) {
switch (prio) {
case prio_high:
// clear space in queue if full, then fallthrough to normal
if (uxQueueSpacesAvailable == 0)
if (uxQueueSpacesAvailable(LoraSendQueue) == 0)
xQueueReceive(LoraSendQueue, &DummyBuffer, (TickType_t)0);
case prio_normal:
ret = xQueueSendToFront(LoraSendQueue, (void *)message, (TickType_t)0);

View File

@ -107,20 +107,3 @@
#define CAYENNE_DEVICECONFIG 11 // device period configuration
#define CAYENNE_SENSORREAD 13 // sensor period configuration
#define CAYENNE_SENSORENABLE 14 // sensor enable configuration
// LED Matrix display settings.
// Note: LED Matrix will only show number of found devices, no other information will be shown for now
//#define HAS_MATRIX_DISPLAY 1 // Uncomment to enable LED matrix display output
#define LED_MATRIX_WIDTH 64 // Width in pixels (LEDs) of your display
#define LED_MATRIX_HEIGHT 16 // Height in pixels (LEDs ) of your display
// Pin numbers work fine for Wemos Lolin32 board (all used pins are on 1 side of the board)
#define MATRIX_DISPLAY_SCAN_US 500 // Matrix display scan rate in microseconds (1ms is about 'acceptable')
#define LED_MATRIX_LATCHPIN 13 // Connects to LAT pin on display
#define LED_MATRIX_CLOCKPIN 32 // Connects to CLK pin on display
#define LED_MATRIX_EN_74138 12 // Connects to OE pin on display
#define LED_MATRIX_LA_74138 14 // Connects to LA pin on display
#define LED_MATRIX_LB_74138 27 // Connects to LB pin on display
#define LED_MATRIX_LC_74138 25 // Connects to LC pin on display
#define LED_MATRIX_LD_74138 26 // Connects to LD pin on display
#define LED_MATRIX_DATA_R1 33 // Connects to R1 pin on display

View File

@ -47,21 +47,23 @@ IRAM_ATTR void wifi_sniffer_packet_handler(void *buff,
// Software-timer driven Wifi channel rotation callback function
void switchWifiChannel(TimerHandle_t xTimer) {
channel =
(channel % WIFI_CHANNEL_MAX) + 1; // rotate channel 1..WIFI_CHANNEL_MAX
esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
}
channel =
(channel % WIFI_CHANNEL_MAX) + 1; // rotate channel 1..WIFI_CHANNEL_MAX
esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
}
void wifi_sniffer_init(void) {
wifi_init_config_t wificfg = WIFI_INIT_CONFIG_DEFAULT();
wificfg.nvs_enable = 0; // we don't need any wifi settings from NVRAM
wificfg.wifi_task_core_id = 0; // we want wifi task running on core 0
wifi_promiscuous_filter_t filter = {
// .filter_mask = WIFI_PROMIS_FILTER_MASK_MGMT}; // only MGMT frames
.filter_mask = WIFI_PROMIS_FILTER_MASK_ALL}; // we use all frames
ESP_ERROR_CHECK(esp_coex_preference_set(
ESP_COEX_PREFER_BALANCE)); // configure Wifi/BT coexist lib
// wifi_promiscuous_filter_t filter = {
// .filter_mask = WIFI_PROMIS_FILTER_MASK_MGMT}; // only MGMT frames
// .filter_mask = WIFI_PROMIS_FILTER_MASK_ALL}; // we use all frames
wifi_promiscuous_filter_t filter = {.filter_mask =
WIFI_PROMIS_FILTER_MASK_MGMT |
WIFI_PROMIS_FILTER_MASK_DATA};
ESP_ERROR_CHECK(esp_wifi_init(&wificfg)); // configure Wifi with cfg
ESP_ERROR_CHECK(