Skip to content

Commit

Permalink
Merge pull request #412 from cyberman54/development
Browse files Browse the repository at this point in the history
v1.7.93
  • Loading branch information
cyberman54 authored Aug 18, 2019
2 parents 81bfea7 + 0a970f3 commit 737df71
Show file tree
Hide file tree
Showing 39 changed files with 669 additions and 551 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ LoLin32lite + [LoraNode32-Lite shield](https://github.com/hallard/LoLin32-Lite-L

- Pyom: WiPy
- WeMos: LoLin32, LoLin32 Lite, WeMos D32, [Wemos32 Oled](https://www.instructables.com/id/ESP32-With-Integrated-OLED-WEMOSLolin-Getting-Star/)
- Crowdsupply: [TinyPICO](https://www.crowdsupply.com/unexpected-maker/tinypico)
- Generic ESP32

Depending on board hardware following features are supported:
Expand All @@ -58,7 +59,7 @@ Depending on board hardware following features are supported:
- Real Time Clock (Maxim DS3231 I2C)
- IF482 (serial) and DCF77 (gpio) time telegram generator
- Switch external power / battery
- 64x16 pixel LED Matrix display (similar to [this model](https://www.instructables.com/id/64x16-RED-LED-Marquee/), can be ordered on [Aliexpress](https://www.aliexpress.com/item/P3-75-dot-matrix-led-module-3-75mm-high-clear-top1-for-text-display-304-60mm/32616683948.html))
- LED Matrix display (similar to [this 64x16 model](https://www.instructables.com/id/64x16-RED-LED-Marquee/), can be ordered on [Aliexpress](https://www.aliexpress.com/item/P3-75-dot-matrix-led-module-3-75mm-high-clear-top1-for-text-display-304-60mm/32616683948.html))

Target platform must be selected in [platformio.ini](https://github.com/cyberman54/ESP32-Paxcounter/blob/master/platformio.ini).<br>
Hardware dependent settings (pinout etc.) are stored in board files in /hal directory. If you want to use a ESP32 board which is not yet supported, use hal file generic.h and tailor pin mappings to your needs. Pull requests for new boards welcome.<br>
Expand Down Expand Up @@ -405,11 +406,11 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
bytes 1..4 = time/date in UTC epoch seconds (LSB)
byte 5 = time source & status, see below

bits 0..3 time source
bits 0..3 last seen time source
0x00 = GPS
0x01 = RTC
0x02 = LORA
0x03 = unsynched
0x03 = unsynched (never synched)

bits 4..7 time status
0x00 = timeNotSet (never synched)
Expand Down
7 changes: 5 additions & 2 deletions include/bmesensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
#include <Adafruit_BME280.h>
#endif

extern Ticker bmecycler;

extern bmeStatus_t
bme_status; // Make struct for storing gps data globally available
extern TaskHandle_t BmeTask;

// --- Bosch BSEC v1.4.7.4 library configuration ---
// 3,3V supply voltage; 3s max time between sensor_control calls; 4 days
// calibration. Change this const if not applicable for your application (see
// BME680 datasheet)
// Note: 3s max time not exceed BMECYCLE frequency set in paxcounter.conf!
const uint8_t bsec_config_iaq[454] = {
4, 7, 4, 1, 61, 0, 0, 0, 0, 0, 0, 0, 174, 1, 0,
0, 48, 0, 1, 0, 0, 192, 168, 71, 64, 49, 119, 76, 0, 0,
Expand Down Expand Up @@ -54,7 +56,8 @@ const uint8_t bsec_config_iaq[454] = {

// Helper functions declarations
int bme_init();
void bme_loop(void *pvParameters);
void bmecycle(void);
void bme_storedata(bmeStatus_t *bme_store);
int checkIaqSensorStatus(void);
void loadState(void);
void updateState(void);
Expand Down
6 changes: 1 addition & 5 deletions include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ typedef struct {
uint8_t satellites;
uint16_t hdop;
int16_t altitude;
uint32_t time_age;
tmElements_t timedate;
} gpsStatus_t;

typedef struct {
Expand All @@ -99,7 +97,6 @@ typedef struct {

enum sendprio_t { prio_low, prio_normal, prio_high };
enum timesource_t { _gps, _rtc, _lora, _unsynced };
enum mutexselect_t { no_mutex, do_mutex };

extern std::set<uint16_t, std::less<uint16_t>, Mallocator<uint16_t>> macs;
extern std::array<uint64_t, 0xff>::iterator it;
Expand All @@ -112,13 +109,12 @@ 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
extern timesource_t timeSource;
extern hw_timer_t *displayIRQ, *matrixDisplayIRQ, *ppsIRQ, *gpsIRQ;
extern hw_timer_t *displayIRQ, *matrixDisplayIRQ, *ppsIRQ;
extern SemaphoreHandle_t I2Caccess;
extern TaskHandle_t irqHandlerTask, ClockTask;
extern TimerHandle_t WifiChanTimer;
extern Timezone myTZ;
extern time_t userUTCTime;
extern time_t volatile gps_pps_time;

// application includes
#include "led.h"
Expand Down
10 changes: 4 additions & 6 deletions include/gpsread.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@
#endif

#define NMEA_FRAME_SIZE 82 // NEMA has a maxium of 82 bytes per record
#define NMEA_BUFFERTIME 50 // 50ms safety time regardless
#define NMEA_COMPENSATION_FACTOR 480 // empiric for Ublox Neo 6M

extern TinyGPSPlus gps; // Make TinyGPS++ instance globally availabe
extern gpsStatus_t
gps_status; // Make struct for storing gps data globally available
extern TaskHandle_t GpsTask;

int gps_init(void);
void IRAM_ATTR gps_storetime(gpsStatus_t *gps_store);
int gps_config();
void gps_storelocation(gpsStatus_t *gps_store);
void gps_loop(void *pvParameters);
time_t fetch_gpsTime(gpsStatus_t value);
int gps_config();
time_t fetch_gpsTime(uint16_t *msec);
time_t fetch_gpsTime(void);

#endif
6 changes: 2 additions & 4 deletions include/irqhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
#define TIMESYNC_IRQ 0x010
#define MASK_IRQ 0x020
#define UNMASK_IRQ 0x040
#define GPS_IRQ 0x080
#define BME_IRQ 0x080
#define MATRIX_DISPLAY_IRQ 0x100

#include "globals.h"
#include "cyclic.h"
#include "senddata.h"
#include "timekeeper.h"
#include "bmesensor.h"

void irqHandler(void *pvParameters);
void mask_user_IRQ();
Expand All @@ -32,8 +33,5 @@ void IRAM_ATTR MatrixDisplayIRQ();
void IRAM_ATTR ButtonIRQ();
#endif

#if (HAS_GPS)
void IRAM_ATTR GpsIRQ();
#endif

#endif
1 change: 1 addition & 0 deletions include/ledmatrixdisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +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 ShiftLeft(uint8_t *arr, uint32_t len);

#endif
3 changes: 2 additions & 1 deletion include/lorawan.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
#endif

extern QueueHandle_t LoraSendQueue;
extern TaskHandle_t lmicTask;

esp_err_t lora_stack_init();
void lmictask(void *pvParameters);
void onEvent(ev_t ev);
void gen_lora_deveui(uint8_t *pdeveui);
void RevBytes(unsigned char *b, size_t c);
Expand All @@ -35,7 +37,6 @@ void switch_lora(uint8_t sf, uint8_t tx);
void lora_send(osjob_t *job);
void lora_enqueuedata(MessageBuffer_t *message, sendprio_t prio);
void lora_queuereset(void);
void lora_housekeeping(void);
#if (TIME_SYNC_LORAWAN)
void user_request_network_time_callback(void *pVoidUserUTCTime,
int flagSuccess);
Expand Down
2 changes: 1 addition & 1 deletion include/rtctime.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
extern RtcDS3231<TwoWire> Rtc; // make RTC instance globally available

uint8_t rtc_init(void);
uint8_t set_rtctime(time_t t, mutexselect_t mutex);
uint8_t set_rtctime(time_t t);
void sync_rtctime(void);
time_t get_rtctime(void);
float get_rtctemp(void);
Expand Down
2 changes: 0 additions & 2 deletions include/spislave.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ esp_err_t spi_init();
void spi_enqueuedata(MessageBuffer_t *message, sendprio_t prio);
void spi_queuereset();

void spi_housekeeping();

#endif // _SPISLAVE_H
3 changes: 2 additions & 1 deletion include/timekeeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ void timepulse_start(void);
void timeSync(void);
uint8_t timepulse_init(void);
time_t timeIsValid(time_t const t);
time_t timeProvider(void);
void calibrateTime(void);
void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec, timesource_t mytimesource);
time_t compiledUTC(void);
TickType_t tx_Ticks(uint32_t framesize, unsigned long baud, uint32_t config,
int8_t rxPin, int8_t txPins);
Expand Down
1 change: 0 additions & 1 deletion include/timesync.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ void send_timesync_req(void);
int recv_timesync_ans(uint8_t seq_no, uint8_t buf[], uint8_t buf_len);
void process_timesync_req(void *taskparameter);
void store_time_sync_req(uint32_t t_millisec);
void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec);

#endif
Loading

0 comments on commit 737df71

Please sign in to comment.