Skip to content

Commit

Permalink
Merge pull request #469 from cyberman54/development
Browse files Browse the repository at this point in the history
v1.9.6
  • Loading branch information
cyberman54 authored Oct 13, 2019
2 parents 921d377 + 0bc368c commit 825520a
Show file tree
Hide file tree
Showing 44 changed files with 1,390 additions and 1,176 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,16 @@ Paxcounter generates identifiers for sniffed MAC adresses and collects them temp

# Display

If you're using a device with OLED display, or if you add such one to the I2C bus, the device shows live data on the display. You can flip between pages showing pax, time, GPS and BME sensor data by pressing the button of the device.
If you're using a device with OLED display, or if you add such one to the I2C bus, the device shows live data on the display. You can flip display pages showing

- recent count of pax
- histogram
- GPS data
- BME sensor data
- time of day
- blank page

by pressing the button of the device.

# Sensors and Peripherals

Expand Down Expand Up @@ -312,8 +321,8 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
Example for EU868:

DataRate Configuration Bit/s
0 LoRa: SF12 / 125 kHz 250
1 LoRa: SF11 / 125 kHz 440
0 LoRa: SF12 / 125 kHz 250
1 LoRa: SF11 / 125 kHz 440
2 LoRa: SF10 / 125 kHz 980
3 LoRa: SF9 / 125 kHz 1760
4 LoRa: SF8 / 125 kHz 3125
Expand Down
5 changes: 5 additions & 0 deletions include/cyclic.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "senddata.h"
#include "rcommand.h"
#include "spislave.h"

#if(HAS_LORA)
#include <lmic.h>
#endif
Expand All @@ -13,6 +14,10 @@
#include "bmesensor.h"
#endif

#ifdef HAS_DISPLAY
#include "display.h"
#endif

extern Ticker housekeeper;

void housekeeping(void);
Expand Down
20 changes: 15 additions & 5 deletions include/display.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
#ifndef _DISPLAY_H
#define _DISPLAY_H

#include <U8x8lib.h>
#include "cyclic.h"
#include "qrcode.h"

extern uint8_t DisplayIsOn;

extern HAS_DISPLAY u8x8;

void init_display(const char *Productname, const char *Version);
void refreshTheDisplay(bool nextPage = false);
void init_display(uint8_t verbose = 0);
void draw_page(time_t t, uint8_t page);
void DisplayKey(const uint8_t *key, uint8_t len, bool lsb);
void dp_printf(uint16_t x, uint16_t y, uint8_t font, uint8_t inv,
const char *format, ...);
void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message);
void oledfillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
uint8_t bRender);
void oledScrollBufferHorizontal(uint8_t *buf, const uint16_t width,
const uint16_t height, bool left = true);
void oledScrollBufferVertical(uint8_t *buf, const uint16_t width,
const uint16_t height, int offset = 0);
int oledDrawPixel(uint8_t *buf, const uint16_t x, const uint16_t y,
const uint8_t dot);
void oledPlotCurve(uint16_t count, bool reset);
void oledRescaleBuffer(uint8_t *buf, const int factor);

#endif
11 changes: 7 additions & 4 deletions include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@
#define BLE_MODE (0x40)
#define SCREEN_MODE (0x80)

// length of display buffer for lmic event messages
#define LMIC_EVENTMSG_LEN 17

// I2C bus access control
#define I2C_MUTEX_LOCK() \
(xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(10)) == pdTRUE)
(xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(DISPLAYREFRESH_MS)) == pdTRUE)
#define I2C_MUTEX_UNLOCK() (xSemaphoreGive(I2Caccess))

enum sendprio_t { prio_low, prio_normal, prio_high };
Expand Down Expand Up @@ -104,9 +107,9 @@ extern std::set<uint16_t, std::less<uint16_t>, Mallocator<uint16_t>> macs;
extern std::array<uint64_t, 0xff>::iterator it;
extern std::array<uint64_t, 0xff> beacons;

extern configData_t cfg; // current device configuration
extern char lmic_event_msg[]; // display buffer
extern uint8_t volatile channel; // wifi channel rotation counter
extern configData_t cfg; // current device configuration
extern char lmic_event_msg[LMIC_EVENTMSG_LEN]; // display buffer
extern uint8_t volatile channel; // wifi channel rotation counter
extern uint16_t volatile macs_total, macs_wifi, macs_ble,
batt_voltage; // display values
extern bool volatile TimePulseTick; // 1sec pps flag set by GPS or RTC
Expand Down
2 changes: 1 addition & 1 deletion include/ledmatrixdisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ void refreshTheMatrixDisplay(bool nextPage = false);
void DrawNumber(String strNum, uint8_t iDotPos = 0);
uint8_t GetCharFromFont(char cChar);
uint8_t GetCharWidth(char cChar);
void ScrollLeft(uint8_t *buf, const uint16_t cols, const uint16_t rows);
void ScrollMatrixLeft(uint8_t *buf, const uint16_t cols, const uint16_t rows);

#endif
4 changes: 2 additions & 2 deletions include/lorawan.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <Wire.h>
#endif

extern QueueHandle_t LoraSendQueue;
extern TaskHandle_t lmicTask, lorasendTask;

// table of LORAWAN MAC commands
Expand All @@ -31,8 +30,8 @@ typedef struct {
} mac_t;

esp_err_t lora_stack_init();
void lora_setupForNetwork(bool preJoin);
void lmictask(void *pvParameters);
void onEvent(ev_t ev);
void gen_lora_deveui(uint8_t *pdeveui);
void RevBytes(unsigned char *b, size_t c);
void get_hard_deveui(uint8_t *pdeveui);
Expand All @@ -43,6 +42,7 @@ void showLoraKeys(void);
void lora_send(void *pvParameters);
void lora_enqueuedata(MessageBuffer_t *message);
void lora_queuereset(void);
void myEventCallback(void *pUserData, ev_t ev);
void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg,
size_t nMsg);
void myTxCallback(void *pUserData, int fSuccess);
Expand Down
7 changes: 3 additions & 4 deletions include/ota.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifdef USE_OTA

#include "globals.h"
#include <ss_oled.h>
#include <Update.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
Expand All @@ -14,11 +15,9 @@
int do_ota_update();
void start_ota_update();
int version_compare(const String v1, const String v2);
void display(const uint8_t row, const std::string status,
const std::string msg);
#ifdef HAS_DISPLAY
void ota_display(const uint8_t row, const std::string status,
const std::string msg);
void show_progress(unsigned long current, unsigned long size);
#endif

#endif // USE_OTA

Expand Down
2 changes: 2 additions & 0 deletions include/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ void power_event_IRQ(void);
void AXP192_power(bool on);
void AXP192_init(void);
void AXP192_showstatus(void);
uint8_t i2c_writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len);
uint8_t i2c_readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len);
#endif // HAS_PMU

#endif
7 changes: 6 additions & 1 deletion include/senddata.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
#define _SENDDATA_H

#include "spislave.h"
#include "cyclic.h"

#if(HAS_LORA)
#include "lorawan.h"
#endif
#include "cyclic.h"

#ifdef HAS_DISPLAY
#include "display.h"
#endif

extern Ticker sendcycler;

Expand Down
9 changes: 6 additions & 3 deletions include/timesync.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
#include "timekeeper.h"

//#define TIME_SYNC_TRIGGER 100 // threshold for time sync [milliseconds]
#define TIME_SYNC_FRAME_LENGTH 0x05 // timeserver answer frame length [bytes]
#define TIME_SYNC_FRAME_LENGTH 0x07 // timeserver answer frame length [bytes]
#define TIME_SYNC_FIXUP 4 // calibration to fixup processing time [milliseconds]
#define TIMEREQUEST_MAX_SEQNO 0xf0 // threshold for wrap around seqno

void timesync_init(void);
void send_timesync_req(void);
int recv_timesync_ans(const uint8_t seq_no, const uint8_t buf[], const uint8_t buf_len);

int recv_timesync_ans(const uint8_t buf[], uint8_t buf_len);

void process_timesync_req(void *taskparameter);
void store_time_sync_req(uint32_t t_millisec);

#endif
#endif
23 changes: 13 additions & 10 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,40 @@ 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.8.34
release_version = 1.9.6
; 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
extra_scripts = pre:build.py
otakeyfile = ota.conf
lorakeyfile = loraconf.h
lmicconfigfile = lmic_config.h
platform_espressif32 = espressif32@1.9.0
platform_espressif32 = espressif32@1.11.0
monitor_speed = 115200
upload_speed = 115200
lib_deps_lora =
MCCI LoRaWAN LMIC library@>=3.0.99
;MCCI LoRaWAN LMIC library@>=3.1.0
https://github.com/mcci-catena/arduino-lmic.git#5322dd1
lib_deps_display =
U8g2@>=2.26.13
ss_oled@>=3.0.0
BitBang_I2C@>=1.2.0
QRCode@>=0.0.1
lib_deps_matrix_display =
https://github.com/Seeed-Studio/Ultrathin_LED_Matrix.git
lib_deps_rgbled =
SmartLeds@>=1.1.6
lib_deps_gps =
1655@>=1.0.2 ;TinyGPSPlus by Mikal Hart
1655@>=1.0.2 ; #1655 TinyGPSPlus by Mikal Hart
lib_deps_sensors =
Adafruit Unified Sensor@>=1.0.3
Adafruit BME280 Library@>=1.0.9
Adafruit BME280 Library@>=1.0.10
lib_deps_basic =
ArduinoJson@^5.13.1
76@>=1.2.2 ;Timezone by Jack Christensen
274@>=2.3.3 ;RTC by Michael Miller
76@>=1.2.2 ; #76 Timezone by Jack Christensen
274@>=2.3.3 ; #274 RTC by Michael Miller
SimpleButton
;AXP202X_Library@^1.0.1
https://github.com/lewisxhe/AXP202X_Library.git#8045ddf
https://github.com/lewisxhe/AXP202X_Library.git
;AXP202X_Library@>=1.0.1
lib_deps_all =
${common.lib_deps_basic}
${common.lib_deps_lora}
Expand Down
Loading

0 comments on commit 825520a

Please sign in to comment.