Merge pull request #507 from cyberman54/development
v1.9.84 -- dedicated to #36C3
This commit is contained in:
commit
92c4401db4
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Tutorial (in german language): https://www.heise.de/select/make/2019/1/1551099236518668
|
Tutorial (in german language): https://www.heise.de/select/make/2019/1/1551099236518668
|
||||||
|
|
||||||
**IMPORTANT: MUST USE PLATFORMIO V4 (not v3.x)**
|
**#36C3 attendees: i am on site (27th - 30th)! You might contact me via twitter @RecumbentTravel**
|
||||||
|
|
||||||
<img src="img/Paxcounter-title.jpg">
|
<img src="img/Paxcounter-title.jpg">
|
||||||
<img src="img/Paxcounter-ttgo.jpg">
|
<img src="img/Paxcounter-ttgo.jpg">
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "cyclic.h"
|
#include "cyclic.h"
|
||||||
#include "qrcode.h"
|
#include "qrcode.h"
|
||||||
|
|
||||||
extern uint8_t DisplayIsOn;
|
extern uint8_t DisplayIsOn, displaybuf[];
|
||||||
|
|
||||||
void refreshTheDisplay(bool nextPage = false);
|
void refreshTheDisplay(bool nextPage = false);
|
||||||
void init_display(bool verbose = false);
|
void init_display(bool verbose = false);
|
||||||
|
@ -14,5 +14,7 @@
|
|||||||
void i2c_init(void);
|
void i2c_init(void);
|
||||||
void i2c_deinit(void);
|
void i2c_deinit(void);
|
||||||
int i2c_scan(void);
|
int i2c_scan(void);
|
||||||
|
uint8_t i2c_readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len);
|
||||||
|
uint8_t i2c_writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -22,8 +22,6 @@ void AXP192_powerevent_IRQ(void);
|
|||||||
void AXP192_power(pmu_power_t powerlevel);
|
void AXP192_power(pmu_power_t powerlevel);
|
||||||
void AXP192_init(void);
|
void AXP192_init(void);
|
||||||
void AXP192_showstatus(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 // HAS_PMU
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
; ---> SELECT THE TARGET PLATFORM HERE! <---
|
; ---> SELECT THE TARGET PLATFORM HERE! <---
|
||||||
[board]
|
[board]
|
||||||
;halfile = generic.h
|
halfile = generic.h
|
||||||
;halfile = ebox.h
|
;halfile = ebox.h
|
||||||
;halfile = eboxtube.h
|
;halfile = eboxtube.h
|
||||||
;halfile = ecopower.h
|
;halfile = ecopower.h
|
||||||
@ -18,7 +18,7 @@
|
|||||||
;halfile = ttgov21old.h
|
;halfile = ttgov21old.h
|
||||||
;halfile = ttgov21new.h
|
;halfile = ttgov21new.h
|
||||||
;halfile = ttgofox.h
|
;halfile = ttgofox.h
|
||||||
halfile = ttgobeam.h
|
;halfile = ttgobeam.h
|
||||||
;halfile = ttgobeam10.h
|
;halfile = ttgobeam10.h
|
||||||
;halfile = fipy.h
|
;halfile = fipy.h
|
||||||
;halfile = lopy.h
|
;halfile = lopy.h
|
||||||
@ -43,7 +43,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I
|
|||||||
|
|
||||||
[common]
|
[common]
|
||||||
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
|
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
|
||||||
release_version = 1.9.82
|
release_version = 1.9.84
|
||||||
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
|
; 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
|
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
|
||||||
debug_level = 3
|
debug_level = 3
|
||||||
@ -55,13 +55,13 @@ platform_espressif32 = espressif32@1.11.1
|
|||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
upload_speed = 115200
|
upload_speed = 115200
|
||||||
lib_deps_lora =
|
lib_deps_lora =
|
||||||
;MCCI LoRaWAN LMIC library@>=3.1.0
|
;MCCI LoRaWAN LMIC library@>=3.1.0 ; MCCI LMIC by Terrill Moore
|
||||||
https://github.com/mcci-catena/arduino-lmic.git#5322dd1
|
https://github.com/mcci-catena/arduino-lmic.git#8a62487
|
||||||
lib_deps_display =
|
lib_deps_display =
|
||||||
ss_oled@=3.0.0
|
;ss_oled@>=3.1.1 ; simple and small OLED lib by Larry Bank
|
||||||
;https://github.com/bitbank2/ss_oled.git#26f5d40
|
https://github.com/bitbank2/ss_oled.git#246d963
|
||||||
BitBang_I2C@>=1.2.0
|
BitBang_I2C@>=1.2.0
|
||||||
QRCode@>=0.0.1
|
QRCode@>=0.0.1
|
||||||
lib_deps_matrix_display =
|
lib_deps_matrix_display =
|
||||||
https://github.com/Seeed-Studio/Ultrathin_LED_Matrix.git
|
https://github.com/Seeed-Studio/Ultrathin_LED_Matrix.git
|
||||||
lib_deps_rgbled =
|
lib_deps_rgbled =
|
||||||
@ -77,8 +77,7 @@ lib_deps_basic =
|
|||||||
76@>=1.2.2 ; #76 Timezone by Jack Christensen
|
76@>=1.2.2 ; #76 Timezone by Jack Christensen
|
||||||
274@>=2.3.3 ; #274 RTC by Michael Miller
|
274@>=2.3.3 ; #274 RTC by Michael Miller
|
||||||
SimpleButton
|
SimpleButton
|
||||||
https://github.com/lewisxhe/AXP202X_Library.git
|
AXP202X_Library@>=1.1.0 ; AXP202 PMU lib by Lewis He
|
||||||
;AXP202X_Library@>=1.0.1
|
|
||||||
lib_deps_all =
|
lib_deps_all =
|
||||||
${common.lib_deps_basic}
|
${common.lib_deps_basic}
|
||||||
${common.lib_deps_lora}
|
${common.lib_deps_lora}
|
||||||
|
@ -56,7 +56,8 @@ static const char TAG[] = __FILE__;
|
|||||||
const char *printmonth[] = {"xxx", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
const char *printmonth[] = {"xxx", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||||
uint8_t DisplayIsOn = 0;
|
uint8_t DisplayIsOn = 0;
|
||||||
static uint8_t displaybuf[DISPLAY_WIDTH * DISPLAY_HEIGHT / 8] = {0};
|
uint8_t displaybuf[DISPLAY_WIDTH * DISPLAY_HEIGHT / 8] = {0};
|
||||||
|
static uint8_t plotbuf[DISPLAY_WIDTH * DISPLAY_HEIGHT / 8] = {0};
|
||||||
|
|
||||||
QRCode qrcode;
|
QRCode qrcode;
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ void init_display(bool verbose) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// set display buffer
|
// set display buffer
|
||||||
//oledSetBackBuffer(displaybuf);
|
oledSetBackBuffer(displaybuf);
|
||||||
|
|
||||||
// clear display
|
// clear display
|
||||||
oledSetContrast(DISPLAYCONTRAST);
|
oledSetContrast(DISPLAYCONTRAST);
|
||||||
@ -111,7 +112,7 @@ void init_display(bool verbose) {
|
|||||||
: "ext.");
|
: "ext.");
|
||||||
|
|
||||||
// give user some time to read or take picture
|
// give user some time to read or take picture
|
||||||
oledDumpBuffer(NULL);
|
oledDumpBuffer(displaybuf);
|
||||||
delay(2000);
|
delay(2000);
|
||||||
oledFill(0x00, 1);
|
oledFill(0x00, 1);
|
||||||
#endif // VERBOSE
|
#endif // VERBOSE
|
||||||
@ -134,7 +135,7 @@ void init_display(bool verbose) {
|
|||||||
dp_printf(80, i + 3, FONT_NORMAL, 0, "%4.4s", deveui + i * 4);
|
dp_printf(80, i + 3, FONT_NORMAL, 0, "%4.4s", deveui + i * 4);
|
||||||
|
|
||||||
// give user some time to read or take picture
|
// give user some time to read or take picture
|
||||||
oledDumpBuffer(NULL);
|
oledDumpBuffer(displaybuf);
|
||||||
delay(8000);
|
delay(8000);
|
||||||
oledSetContrast(DISPLAYCONTRAST);
|
oledSetContrast(DISPLAYCONTRAST);
|
||||||
oledFill(0x00, 1);
|
oledFill(0x00, 1);
|
||||||
@ -178,7 +179,7 @@ void refreshTheDisplay(bool nextPage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
draw_page(t, DisplayPage);
|
draw_page(t, DisplayPage);
|
||||||
oledDumpBuffer(NULL);
|
oledDumpBuffer(displaybuf);
|
||||||
|
|
||||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||||
|
|
||||||
@ -298,7 +299,7 @@ void draw_page(time_t t, uint8_t page) {
|
|||||||
|
|
||||||
// page 1: pax graph
|
// page 1: pax graph
|
||||||
case 1:
|
case 1:
|
||||||
oledDumpBuffer(displaybuf);
|
oledDumpBuffer(plotbuf);
|
||||||
break; // page1
|
break; // page1
|
||||||
|
|
||||||
// page 2: GPS
|
// page 2: GPS
|
||||||
@ -502,24 +503,22 @@ void oledPlotCurve(uint16_t count, bool reset) {
|
|||||||
if (col < DISPLAY_WIDTH - 1) // matrix not full -> increment column
|
if (col < DISPLAY_WIDTH - 1) // matrix not full -> increment column
|
||||||
col++;
|
col++;
|
||||||
else // matrix full -> scroll left 1 dot
|
else // matrix full -> scroll left 1 dot
|
||||||
oledScrollBufferHorizontal(displaybuf, DISPLAY_WIDTH, DISPLAY_HEIGHT,
|
oledScrollBufferHorizontal(plotbuf, DISPLAY_WIDTH, DISPLAY_HEIGHT, true);
|
||||||
true);
|
|
||||||
|
|
||||||
} else // clear current dot
|
} else // clear current dot
|
||||||
oledDrawPixel(displaybuf, col, row, 0);
|
oledDrawPixel(plotbuf, col, row, 0);
|
||||||
|
|
||||||
// scroll down, if necessary
|
// scroll down, if necessary
|
||||||
while ((count - v_scroll) > DISPLAY_HEIGHT - 1)
|
while ((count - v_scroll) > DISPLAY_HEIGHT - 1)
|
||||||
v_scroll++;
|
v_scroll++;
|
||||||
if (v_scroll)
|
if (v_scroll)
|
||||||
oledScrollBufferVertical(displaybuf, DISPLAY_WIDTH, DISPLAY_HEIGHT,
|
oledScrollBufferVertical(plotbuf, DISPLAY_WIDTH, DISPLAY_HEIGHT, v_scroll);
|
||||||
v_scroll);
|
|
||||||
|
|
||||||
// set new dot
|
// set new dot
|
||||||
// row = DISPLAY_HEIGHT - 1 - (count - v_scroll) % DISPLAY_HEIGHT;
|
// row = DISPLAY_HEIGHT - 1 - (count - v_scroll) % DISPLAY_HEIGHT;
|
||||||
row = DISPLAY_HEIGHT - 1 - count - v_scroll;
|
row = DISPLAY_HEIGHT - 1 - count - v_scroll;
|
||||||
last_count = count;
|
last_count = count;
|
||||||
oledDrawPixel(displaybuf, col, row, 1);
|
oledDrawPixel(plotbuf, col, row, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_DISPLAY
|
#endif // HAS_DISPLAY
|
50
src/i2c.cpp
50
src/i2c.cpp
@ -88,4 +88,52 @@ int i2c_scan(void) {
|
|||||||
ESP_LOGE(TAG, "I2c bus busy - scan error");
|
ESP_LOGE(TAG, "I2c bus busy - scan error");
|
||||||
|
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mutexed functions for i2c r/w access
|
||||||
|
uint8_t i2c_readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) {
|
||||||
|
if (I2C_MUTEX_LOCK()) {
|
||||||
|
|
||||||
|
uint8_t ret = 0;
|
||||||
|
Wire.beginTransmission(addr);
|
||||||
|
Wire.write(reg);
|
||||||
|
Wire.endTransmission(false);
|
||||||
|
uint8_t cnt = Wire.requestFrom(addr, (uint8_t)len, (uint8_t)1);
|
||||||
|
if (!cnt)
|
||||||
|
ret = 0xFF;
|
||||||
|
uint16_t index = 0;
|
||||||
|
while (Wire.available()) {
|
||||||
|
if (index > len) {
|
||||||
|
ret = 0xFF;
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
data[index++] = Wire.read();
|
||||||
|
}
|
||||||
|
|
||||||
|
finish:
|
||||||
|
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
|
ESP_LOGW(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0);
|
||||||
|
return 0xFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t i2c_writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) {
|
||||||
|
if (I2C_MUTEX_LOCK()) {
|
||||||
|
|
||||||
|
uint8_t ret = 0;
|
||||||
|
Wire.beginTransmission(addr);
|
||||||
|
Wire.write(reg);
|
||||||
|
for (uint16_t i = 0; i < len; i++) {
|
||||||
|
Wire.write(data[i]);
|
||||||
|
}
|
||||||
|
ret = Wire.endTransmission();
|
||||||
|
|
||||||
|
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
||||||
|
return ret ? ret : 0xFF;
|
||||||
|
} else {
|
||||||
|
ESP_LOGW(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0);
|
||||||
|
return 0xFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -49,6 +49,10 @@ void start_ota_update() {
|
|||||||
#else
|
#else
|
||||||
oledInit(OLED_128x64, ANGLE_FLIPY, false, -1, -1, 400000L);
|
oledInit(OLED_128x64, ANGLE_FLIPY, false, -1, -1, 400000L);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// set display buffer
|
||||||
|
oledSetBackBuffer(displaybuf);
|
||||||
|
|
||||||
oledFill(0, 1);
|
oledFill(0, 1);
|
||||||
dp_printf(0, 0, 0, 1, "SOFTWARE UPDATE");
|
dp_printf(0, 0, 0, 1, "SOFTWARE UPDATE");
|
||||||
dp_printf(0, 1, 0, 0, "WiFi connect ..");
|
dp_printf(0, 1, 0, 0, "WiFi connect ..");
|
||||||
@ -56,7 +60,7 @@ void start_ota_update() {
|
|||||||
dp_printf(0, 3, 0, 0, "Fetching ..");
|
dp_printf(0, 3, 0, 0, "Fetching ..");
|
||||||
dp_printf(0, 4, 0, 0, "Downloading ..");
|
dp_printf(0, 4, 0, 0, "Downloading ..");
|
||||||
dp_printf(0, 5, 0, 0, "Rebooting ..");
|
dp_printf(0, 5, 0, 0, "Rebooting ..");
|
||||||
oledDumpBuffer(NULL);
|
oledDumpBuffer(displaybuf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Starting Wifi OTA update");
|
ESP_LOGI(TAG, "Starting Wifi OTA update");
|
||||||
@ -309,7 +313,7 @@ void ota_display(const uint8_t row, const std::string status,
|
|||||||
dp_printf(0, 7, 0, 0, " ");
|
dp_printf(0, 7, 0, 0, " ");
|
||||||
dp_printf(0, 7, 0, 0, msg.substr(0, 16).c_str());
|
dp_printf(0, 7, 0, 0, msg.substr(0, 16).c_str());
|
||||||
}
|
}
|
||||||
oledDumpBuffer(NULL);
|
oledDumpBuffer(displaybuf);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,55 +147,6 @@ void AXP192_init(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper functions for mutexing pmu i2c access
|
|
||||||
uint8_t i2c_readBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) {
|
|
||||||
if (I2C_MUTEX_LOCK()) {
|
|
||||||
|
|
||||||
uint8_t ret = 0;
|
|
||||||
Wire.beginTransmission(addr);
|
|
||||||
Wire.write(reg);
|
|
||||||
Wire.endTransmission(false);
|
|
||||||
uint8_t cnt = Wire.requestFrom(addr, (uint8_t)len, (uint8_t)1);
|
|
||||||
if (!cnt)
|
|
||||||
ret = 0xFF;
|
|
||||||
uint16_t index = 0;
|
|
||||||
while (Wire.available()) {
|
|
||||||
if (index > len) {
|
|
||||||
ret = 0xFF;
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
data[index++] = Wire.read();
|
|
||||||
}
|
|
||||||
|
|
||||||
finish:
|
|
||||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
|
||||||
return ret;
|
|
||||||
} else {
|
|
||||||
ESP_LOGW(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0);
|
|
||||||
return 0xFF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t i2c_writeBytes(uint8_t addr, uint8_t reg, uint8_t *data, uint8_t len) {
|
|
||||||
if (I2C_MUTEX_LOCK()) {
|
|
||||||
|
|
||||||
uint8_t ret = 0;
|
|
||||||
Wire.beginTransmission(addr);
|
|
||||||
Wire.write(reg);
|
|
||||||
for (uint16_t i = 0; i < len; i++) {
|
|
||||||
Wire.write(data[i]);
|
|
||||||
}
|
|
||||||
ret = Wire.endTransmission();
|
|
||||||
|
|
||||||
I2C_MUTEX_UNLOCK(); // release i2c bus access
|
|
||||||
// return ret ? 0xFF : ret;
|
|
||||||
return ret ? ret : 0xFF;
|
|
||||||
} else {
|
|
||||||
ESP_LOGW(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0);
|
|
||||||
return 0xFF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // HAS_PMU
|
#endif // HAS_PMU
|
||||||
|
|
||||||
void calibrate_voltage(void) {
|
void calibrate_voltage(void) {
|
||||||
|
Loading…
Reference in New Issue
Block a user