Merge pull request #544 from cyberman54/master

sync sds011 with master
This commit is contained in:
Verkehrsrot authored and GitHub committed 2020-02-05 19:43:02 +01:00
commit bc198b722b
56 files changed
+131 -22261

No files matched your search

+1 -1
View File
@@ -180,7 +180,7 @@ void bme_storedata(bmeStatus_t *bme_store) {
iaqSensor.humidity; // humidity in % relative humidity x1000
bme_store->pressure = // pressure in Pascal
(iaqSensor.pressure / 100.0); // conversion Pa -> hPa
bme_store->iaq = iaqSensor.iaqEstimate;
bme_store->iaq = iaqSensor.iaq;
bme_store->iaq_accuracy = iaqSensor.iaqAccuracy;
bme_store->gas = iaqSensor.gasResistance; // gas resistance in ohms
updateState();
+42 -28
View File
@@ -78,9 +78,11 @@ void init_display(bool verbose) {
// init display
#ifndef DISPLAY_FLIP
oledInit(OLED_128x64, false, false, -1, -1, 400000L);
oledInit(OLED_128x64, false, false, -1, -1,
MY_OLED_RST == NOT_A_PIN ? -1 : MY_OLED_RST, 400000L);
#else
oledInit(OLED_128x64, true, false, -1, -1, 400000L);
oledInit(OLED_128x64, true, false, -1, -1,
MY_OLED_RST == NOT_A_PIN ? -1 : MY_OLED_RST, 400000L);
#endif
// set display buffer
@@ -151,9 +153,11 @@ void init_display(bool verbose) {
void refreshTheDisplay(bool nextPage) {
static uint8_t DisplayPage = 0;
#ifndef HAS_BUTTON
static uint32_t framecounter = 0;
#endif
// update histogram if we have a display
// update histogram
oledPlotCurve(macs.size(), false);
// if display is switched off we don't refresh it to relax cpu
@@ -173,12 +177,15 @@ void refreshTheDisplay(bool nextPage) {
oledPower(cfg.screenon);
}
if (nextPage) {
DisplayPage = (DisplayPage >= DISPLAY_PAGES - 1) ? 0 : (DisplayPage + 1);
oledFill(0, 1);
#ifndef HAS_BUTTON
// auto flip page if we are in unattended mode
if ((++framecounter) > (DISPLAYCYCLE * 1000 / DISPLAYREFRESH_MS)) {
framecounter = 0;
nextPage = true;
}
#endif
draw_page(t, DisplayPage);
draw_page(t, nextPage);
oledDumpBuffer(displaybuf);
I2C_MUTEX_UNLOCK(); // release i2c bus access
@@ -198,8 +205,12 @@ void shutdown_display(void) {
}
}
void draw_page(time_t t, uint8_t page) {
void draw_page(time_t t, bool nextpage) {
// write display content to display buffer
// nextpage = true -> flip 1 page
static uint8_t DisplayPage = 0;
char timeState;
#if (HAS_GPS)
static bool wasnofix = true;
@@ -209,7 +220,14 @@ void draw_page(time_t t, uint8_t page) {
dp_printf(0, 0, FONT_STRETCHED, 0, "PAX:%-4d",
macs.size()); // display number of unique macs total Wifi + BLE
switch (page % DISPLAY_PAGES) {
start:
if (nextpage) {
DisplayPage = (DisplayPage >= DISPLAY_PAGES - 1) ? 0 : (DisplayPage + 1);
oledFill(0, 1);
}
switch (DisplayPage) {
// page 0: parameters overview
// page 1: pax graph
@@ -293,8 +311,7 @@ void draw_page(time_t t, uint8_t page) {
// LORA datarate, display inverse if ADR disabled
dp_printf(102, 7, FONT_SMALL, !cfg.adrmode, "%-4s",
getSfName(updr2rps(LMIC.datarate)));
#endif // HAS_LORA
#endif // HAS_LORA
break; // page0
// page 1: pax graph
@@ -323,16 +340,13 @@ void draw_page(time_t t, uint8_t page) {
dp_printf(16, 5, FONT_STRETCHED, 1, "No fix");
wasnofix = true;
}
#else
dp_printf(16, 5, FONT_STRETCHED, 1, "No GPS");
#endif
break; // page2
#else
DisplayPage++; // next page
#endif
// page 3: BME280/680
case 3:
#if (HAS_BME)
// line 2-3: Temp
dp_printf(0, 2, FONT_STRETCHED, 0, "TMP:%-2.1f", bme_status.temperature);
@@ -343,32 +357,32 @@ void draw_page(time_t t, uint8_t page) {
#ifdef HAS_BME680
// line 6-7: IAQ
dp_printf(0, 6, FONT_STRETCHED, 0, "IAQ:%-3.0f", bme_status.iaq);
#else // is BME280 or BMP180
#else // is BME280 or BMP180
// line 6-7: Pre
dp_printf(0, 6, FONT_STRETCHED, 0, "PRE:%-2.1f", bme_status.pressure);
#endif // HAS_BME
#endif // HAS_BME680
break; // page 3
#else
dp_printf(16, 5, FONT_STRETCHED, 1, "No BME");
#endif
break; // page3
DisplayPage++; // next page
#endif // HAS_BME
// page 4: time
case 4:
dp_printf(0, 4, FONT_LARGE, 0, "%02d:%02d:%02d", hour(t), minute(t),
second(t));
break;
// page 5: blank screen
case 5:
#ifdef HAS_BUTTON
oledFill(0, 1);
break;
#else // don't show blank page if we are unattended
DisplayPage++; // next page
#endif
default:
break; // default
goto start; // start over
} // switch
+1 -1
View File
@@ -43,7 +43,7 @@
#define LORA_IRQ DIO0
#define LORA_IO1 DIO1
#define LORA_IO2 DIO2
#define LORA_SCK SCK
#define LORA_SCK GPIO_NUM_5
#define LORA_MISO MISO
#define LORA_MOSI MOSI
#define LORA_RST RST_LoRa
+62
View File
@@ -0,0 +1,62 @@
// clang-format off
// upload_speed 921600
// board M5Stack-Core-ESP32
// EXPERIMENTAL VERSION - NOT TESTED ON M5 HARDWARE YET
#ifndef _M5STACK_H
#define _M5STACK_H
#include <stdint.h>
#define HAS_LORA 1 // comment out if device shall not send data via LoRa or has no M5 RA01 LoRa module
// Pins for LORA chip SPI interface, reset line and interrupt lines
#define LORA_SCK SCK
#define LORA_CS SS
#define LORA_MISO MISO
#define LORA_MOSI MOSI
#define LORA_RST GPIO_NUM_36
#define LORA_IRQ GPIO_NUM_26
#define LORA_IO1 GPIO_NUM_34 // must be externally wired on PCB!
#define LORA_IO2 LMIC_UNUSED_PIN
// enable only if you want to store a local paxcount table on the device
#define HAS_SDCARD 1 // this board has an SD-card-reader/writer
// Pins for SD-card
#define SDCARD_CS GPIO_NUM_4
#define SDCARD_MOSI MOSI
#define SDCARD_MISO MISO
#define SDCARD_SCLK SCK
// user defined sensors
//#define HAS_SENSORS 1 // comment out if device has user defined sensors
#define CFG_sx1276_radio 1 // select LoRa chip
#define BOARD_HAS_PSRAM // use if board has external PSRAM
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
//#define HAS_DISPLAY 1
//#define DISPLAY_FLIP 1 // use if display is rotated
//#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
#define HAS_LED NOT_A_PIN // no on board LED (?)
#define HAS_BUTTON (39) // on board button A
// GPS settings
#define HAS_GPS 1 // use on board GPS
#define GPS_SERIAL 9600, SERIAL_8N1, RXD2, TXD2 // UBlox NEO 6M RX, TX
#define GPS_INT GPIO_NUM_35 // 30ns accurary timepulse, to be external wired on pcb: shorten R12!
// Pins for interface of LC Display
#define MY_OLED_CS GPIO_NUM_14
#define MY_OLED_DC GPIO_NUM_27
#define MY_OLED_CLK GPIO_NUM_18
#define MY_OLED_RST GPIO_NUM_33
#define MY_OLED_BL GPIO_NUM_32
#define MY_OLED_MOSI GPIO_NUM_23
#define MY_OLED_MISO GPIO_NUM_23
#endif
+5 -2
View File
@@ -44,10 +44,13 @@ void start_ota_update() {
// init display
#ifdef HAS_DISPLAY
#ifndef DISPLAY_FLIP
oledInit(OLED_128x64, ANGLE_0, false, -1, -1, 400000L);
oledInit(OLED_128x64, false, false, -1, -1,
MY_OLED_RST == NOT_A_PIN ? -1 : MY_OLED_RST, 400000L);
#else
oledInit(OLED_128x64, ANGLE_FLIPY, false, -1, -1, 400000L);
oledInit(OLED_128x64, true, false, -1, -1,
MY_OLED_RST == NOT_A_PIN ? -1 : MY_OLED_RST, 400000L);
#endif
// set display buffer
+3 -2
View File
@@ -57,6 +57,7 @@
#define RGBLUMINOSITY 30 // RGB LED luminosity [default = 30%]
#define DISPLAYREFRESH_MS 40 // OLED refresh cycle in ms [default = 40] -> 1000/40 = 25 frames per second
#define DISPLAYCONTRAST 80 // 0 .. 255, OLED display contrast [default = 80]
#define DISPLAYCYCLE 3 // Auto page flip delay in sec [default = 2] for devices without button
#define HOMECYCLE 30 // house keeping cycle in seconds [default = 30 secs]
// Settings for BME680 environmental sensor
@@ -76,7 +77,7 @@
#define TIME_SYNC_INTERVAL_RETRY 10 // retry time sync after lost sync each .. minutes [default = 10], 0 means off
#define TIME_SYNC_COMPILEDATE 0 // set to 1 to use compile date to initialize RTC after power outage [default = 0]
#define TIME_SYNC_LORAWAN 0 // set to 1 to use LORA network as time source, 0 means off [default = 0]
#define TIME_SYNC_LORASERVER 0 // set to 1 to use LORA timeserver as time source, 0 means off [default = 0]
#define TIME_SYNC_LORASERVER 1 // set to 1 to use LORA timeserver as time source, 0 means off [default = 0]
// settings for syncing time with timeserver applications
#define TIME_SYNC_SAMPLES 1 // number of time requests for averaging
@@ -93,7 +94,7 @@
#define RCMDPORT 2 // remote commands
#define STATUSPORT 2 // remote command results
#define CONFIGPORT 3 // config query results
#define GPSPORT 4 // gps - set to 1 to send combined GPS+COUNTERPORT payload
#define GPSPORT 1 // gps - set to 1 to send combined GPS+COUNTERPORT payload
#define BUTTONPORT 5 // button pressed signal
#define BEACONPORT 6 // beacon alarms
#define BMEPORT 7 // BME680 sensor