code sanitizations
This commit is contained in:
parent
c9303e916d
commit
5327f17237
@ -87,7 +87,6 @@ byte CFG_CFG[] = {
|
|||||||
// helper functions to send UBX commands to ublox gps chip
|
// helper functions to send UBX commands to ublox gps chip
|
||||||
|
|
||||||
void sendPacket(byte *packet, byte len) {
|
void sendPacket(byte *packet, byte len) {
|
||||||
|
|
||||||
uint8_t CK_A = 0;
|
uint8_t CK_A = 0;
|
||||||
uint8_t CK_B = 0;
|
uint8_t CK_B = 0;
|
||||||
|
|
||||||
@ -107,7 +106,6 @@ void restoreDefaults() { sendPacket(CFG_CFG, sizeof(CFG_CFG)); }
|
|||||||
void changeBaudrate() { sendPacket(CFG_PRT, sizeof(CFG_PRT)); }
|
void changeBaudrate() { sendPacket(CFG_PRT, sizeof(CFG_PRT)); }
|
||||||
|
|
||||||
void disableNmea() {
|
void disableNmea() {
|
||||||
|
|
||||||
// tinygps++ processes only $GPGGA/$GNGGA and $GPRMC/$GNRMC
|
// tinygps++ processes only $GPGGA/$GNGGA and $GPRMC/$GNRMC
|
||||||
// thus, we disable all other NMEA messages
|
// thus, we disable all other NMEA messages
|
||||||
|
|
||||||
@ -128,7 +126,6 @@ void disableNmea() {
|
|||||||
|
|
||||||
// initialize and configure GPS
|
// initialize and configure GPS
|
||||||
int gps_init(void) {
|
int gps_init(void) {
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Opening serial GPS");
|
ESP_LOGI(TAG, "Opening serial GPS");
|
||||||
|
|
||||||
GPS_Serial.begin(GPS_SERIAL);
|
GPS_Serial.begin(GPS_SERIAL);
|
||||||
@ -144,7 +141,6 @@ int gps_init(void) {
|
|||||||
disableNmea();
|
disableNmea();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
} // gps_init()
|
} // gps_init()
|
||||||
|
|
||||||
// store current GPS location data in struct
|
// store current GPS location data in struct
|
||||||
@ -170,13 +166,11 @@ bool gps_hasfix() {
|
|||||||
|
|
||||||
// function to poll UTC time from GPS NMEA data; note: this is costly
|
// function to poll UTC time from GPS NMEA data; note: this is costly
|
||||||
time_t get_gpstime(uint16_t *msec = 0) {
|
time_t get_gpstime(uint16_t *msec = 0) {
|
||||||
|
|
||||||
const uint16_t txDelay =
|
const uint16_t txDelay =
|
||||||
70U * 1000 / (GPS_BAUDRATE / 9); // serial tx of 70 NMEA chars
|
70U * 1000 / (GPS_BAUDRATE / 9); // serial tx of 70 NMEA chars
|
||||||
|
|
||||||
// did we get a current date & time?
|
// did we get a current date & time?
|
||||||
if (gps.time.age() < 1000) {
|
if (gps.time.age() < 1000) {
|
||||||
|
|
||||||
// convert tinygps time format to struct tm format
|
// convert tinygps time format to struct tm format
|
||||||
struct tm gps_tm = {0};
|
struct tm gps_tm = {0};
|
||||||
gps_tm.tm_sec = gps.time.second();
|
gps_tm.tm_sec = gps.time.second();
|
||||||
@ -209,18 +203,15 @@ time_t get_gpstime(uint16_t *msec = 0) {
|
|||||||
|
|
||||||
ESP_LOGD(TAG, "no valid GPS time");
|
ESP_LOGD(TAG, "no valid GPS time");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
} // get_gpstime()
|
} // get_gpstime()
|
||||||
|
|
||||||
// GPS serial feed FreeRTos Task
|
// GPS serial feed FreeRTos Task
|
||||||
void gps_loop(void *pvParameters) {
|
void gps_loop(void *pvParameters) {
|
||||||
|
|
||||||
_ASSERT((uint32_t)pvParameters == 1); // FreeRTOS check
|
_ASSERT((uint32_t)pvParameters == 1); // FreeRTOS check
|
||||||
|
|
||||||
// feed GPS decoder with serial NMEA data from GPS device
|
// feed GPS decoder with serial NMEA data from GPS device
|
||||||
while (1) {
|
while (1) {
|
||||||
while (cfg.payloadmask & GPS_DATA) {
|
while (cfg.payloadmask & GPS_DATA) {
|
||||||
|
|
||||||
while (GPS_Serial.available())
|
while (GPS_Serial.available())
|
||||||
gps.encode(GPS_Serial.read());
|
gps.encode(GPS_Serial.read());
|
||||||
|
|
||||||
@ -228,7 +219,6 @@ void gps_loop(void *pvParameters) {
|
|||||||
}
|
}
|
||||||
delay(1000);
|
delay(1000);
|
||||||
} // infinite while loop
|
} // infinite while loop
|
||||||
|
|
||||||
} // gps_loop()
|
} // gps_loop()
|
||||||
|
|
||||||
#endif // HAS_GPS
|
#endif // HAS_GPS
|
||||||
|
@ -70,7 +70,6 @@ void refreshTheMatrixDisplay(bool nextPage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (DisplayPage % MATRIX_DISPLAY_PAGES) {
|
switch (DisplayPage % MATRIX_DISPLAY_PAGES) {
|
||||||
|
|
||||||
// page 0: number of current pax OR footfall line diagram
|
// page 0: number of current pax OR footfall line diagram
|
||||||
// page 1: time of day
|
// page 1: time of day
|
||||||
|
|
||||||
@ -89,18 +88,14 @@ void refreshTheMatrixDisplay(bool nextPage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else { // cyclic counter mode -> plot a line diagram
|
else { // cyclic counter mode -> plot a line diagram
|
||||||
|
|
||||||
if (ulLastNumMacs != count.pax) {
|
if (ulLastNumMacs != count.pax) {
|
||||||
|
|
||||||
// next count cycle?
|
// next count cycle?
|
||||||
if (count.pax == 0) {
|
if (count.pax == 0) {
|
||||||
|
|
||||||
// matrix full? then scroll left 1 dot, else increment column
|
// matrix full? then scroll left 1 dot, else increment column
|
||||||
if (col < (LED_MATRIX_WIDTH - 1))
|
if (col < (LED_MATRIX_WIDTH - 1))
|
||||||
col++;
|
col++;
|
||||||
else
|
else
|
||||||
ScrollMatrixLeft(displaybuf, LED_MATRIX_WIDTH, LED_MATRIX_HEIGHT);
|
ScrollMatrixLeft(displaybuf, LED_MATRIX_WIDTH, LED_MATRIX_HEIGHT);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
matrix.drawPoint(col, row, 0); // clear current dot
|
matrix.drawPoint(col, row, 0); // clear current dot
|
||||||
|
|
||||||
@ -124,7 +119,6 @@ void refreshTheMatrixDisplay(bool nextPage) {
|
|||||||
// DrawNumber(myTZ.dateTime("H:i:s").c_str());
|
// DrawNumber(myTZ.dateTime("H:i:s").c_str());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} // switch page
|
} // switch page
|
||||||
|
|
||||||
matrix.scan();
|
matrix.scan();
|
||||||
|
@ -41,7 +41,6 @@ inline String getHeaderValue(String header, String headerName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void start_ota_update() {
|
void start_ota_update() {
|
||||||
|
|
||||||
const char *host = clientId;
|
const char *host = clientId;
|
||||||
|
|
||||||
switch_LED(LED_ON);
|
switch_LED(LED_ON);
|
||||||
@ -121,13 +120,11 @@ end:
|
|||||||
ota_display(5, "**", ""); // mark line rebooting
|
ota_display(5, "**", ""); // mark line rebooting
|
||||||
delay(5000);
|
delay(5000);
|
||||||
do_reset(false);
|
do_reset(false);
|
||||||
|
|
||||||
} // start_ota_update
|
} // start_ota_update
|
||||||
|
|
||||||
// Reads data vom wifi client and flashes it to ota partition
|
// Reads data vom wifi client and flashes it to ota partition
|
||||||
// returns: 0 = finished, 1 = retry, -1 = abort
|
// returns: 0 = finished, 1 = retry, -1 = abort
|
||||||
int do_ota_update() {
|
int do_ota_update() {
|
||||||
|
|
||||||
char buf[17];
|
char buf[17];
|
||||||
bool redirect = true;
|
bool redirect = true;
|
||||||
size_t written = 0;
|
size_t written = 0;
|
||||||
@ -319,7 +316,6 @@ abort:
|
|||||||
|
|
||||||
retry:
|
retry:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
} // do_ota_update
|
} // do_ota_update
|
||||||
|
|
||||||
void ota_display(const uint8_t row, const std::string status,
|
void ota_display(const uint8_t row, const std::string status,
|
||||||
|
@ -26,7 +26,6 @@ static const adc_unit_t unit = ADC_UNIT_1;
|
|||||||
AXP20X_Class pmu;
|
AXP20X_Class pmu;
|
||||||
|
|
||||||
void AXP192_powerevent_IRQ(void) {
|
void AXP192_powerevent_IRQ(void) {
|
||||||
|
|
||||||
pmu.readIRQ();
|
pmu.readIRQ();
|
||||||
|
|
||||||
if (pmu.isVbusOverVoltageIRQ())
|
if (pmu.isVbusOverVoltageIRQ())
|
||||||
@ -83,9 +82,7 @@ void AXP192_powerevent_IRQ(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AXP192_power(pmu_power_t powerlevel) {
|
void AXP192_power(pmu_power_t powerlevel) {
|
||||||
|
|
||||||
switch (powerlevel) {
|
switch (powerlevel) {
|
||||||
|
|
||||||
case pmu_power_off:
|
case pmu_power_off:
|
||||||
pmu.shutdown();
|
pmu.shutdown();
|
||||||
break;
|
break;
|
||||||
@ -119,7 +116,6 @@ void AXP192_power(pmu_power_t powerlevel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AXP192_showstatus(void) {
|
void AXP192_showstatus(void) {
|
||||||
|
|
||||||
if (pmu.isBatteryConnect())
|
if (pmu.isBatteryConnect())
|
||||||
if (pmu.isChargeing())
|
if (pmu.isChargeing())
|
||||||
ESP_LOGI(TAG, "Battery charging, %.2fV @ %.0fmAh",
|
ESP_LOGI(TAG, "Battery charging, %.2fV @ %.0fmAh",
|
||||||
@ -137,12 +133,10 @@ void AXP192_showstatus(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AXP192_init(void) {
|
void AXP192_init(void) {
|
||||||
|
|
||||||
if (pmu.begin(i2c_readBytes, i2c_writeBytes, AXP192_PRIMARY_ADDRESS) ==
|
if (pmu.begin(i2c_readBytes, i2c_writeBytes, AXP192_PRIMARY_ADDRESS) ==
|
||||||
AXP_FAIL)
|
AXP_FAIL)
|
||||||
ESP_LOGI(TAG, "AXP192 PMU initialization failed");
|
ESP_LOGI(TAG, "AXP192 PMU initialization failed");
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// configure voltages
|
// configure voltages
|
||||||
pmu.setDCDC1Voltage(3300); // for external OLED display
|
pmu.setDCDC1Voltage(3300); // for external OLED display
|
||||||
pmu.setLDO2Voltage(3300); // LORA VDD 3v3
|
pmu.setLDO2Voltage(3300); // LORA VDD 3v3
|
||||||
|
Loading…
Reference in New Issue
Block a user