display line6 code sanitized

This commit is contained in:
Verkehrsrot 2019-09-20 19:45:37 +02:00
parent f8a115ac17
commit af9d2150bf
6 changed files with 23 additions and 38 deletions

View File

@ -42,7 +42,8 @@
#define SCREEN_MODE (0x80) #define SCREEN_MODE (0x80)
// I2C bus access control // I2C bus access control
#define I2C_MUTEX_LOCK() (xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(10)) == pdTRUE) #define I2C_MUTEX_LOCK() \
(xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(10)) == pdTRUE)
#define I2C_MUTEX_UNLOCK() (xSemaphoreGive(I2Caccess)) #define I2C_MUTEX_UNLOCK() (xSemaphoreGive(I2Caccess))
enum sendprio_t { prio_low, prio_normal, prio_high }; enum sendprio_t { prio_low, prio_normal, prio_high };
@ -104,7 +105,7 @@ extern std::array<uint64_t, 0xff>::iterator it;
extern std::array<uint64_t, 0xff> beacons; extern std::array<uint64_t, 0xff> beacons;
extern configData_t cfg; // current device configuration extern configData_t cfg; // current device configuration
extern char display_line6[], display_line7[]; // screen buffers extern char lmic_event_msg[]; // display buffer
extern uint8_t volatile channel; // wifi channel rotation counter extern uint8_t volatile channel; // wifi channel rotation counter
extern uint16_t volatile macs_total, macs_wifi, macs_ble, extern uint16_t volatile macs_total, macs_wifi, macs_ble,
batt_voltage; // display values batt_voltage; // display values

View File

@ -13,12 +13,13 @@ Display-Mask (128 x 64 pixel):
3|BLTH:abcde SF:ab 3|BLTH:abcde SF:ab
4|WIFI:abcde ch:ab 4|WIFI:abcde ch:ab
5|RLIM:abcd abcdKB 5|RLIM:abcd abcdKB
6|xxxxxxxxxxxxxxxx
6|20:27:00* 27.Feb 6|20:27:00* 27.Feb
7|yyyyyyyyyyyyyyab 7|yyyyyyyyyyyyyyab
line 6: x = Text for LORA status OR time/date line 6: * = time source indicator: L|G|R|?,
line 7: y = Text for LMIC status; ab = payload queue inverse = clock controller is active,
pulsed = pps input signal is active
line 7: y = LMIC event message; ab = payload queue length
*/ */
@ -239,17 +240,13 @@ void draw_page(time_t t, uint8_t page) {
#endif // HAS_DCF77 || HAS_IF482 #endif // HAS_DCF77 || HAS_IF482
if (timeSource != _unsynced) if (timeSource != _unsynced)
u8x8.printf(" %2d.%3s", day(t), printmonth[month(t)]); u8x8.printf(" %2d.%3s", day(t), printmonth[month(t)]);
#else // update LoRa status display
#if (HAS_LORA)
u8x8.printf("%-16s", display_line6);
#endif
#endif // TIME_SYNC_INTERVAL #endif // TIME_SYNC_INTERVAL
#if (HAS_LORA) #if (HAS_LORA)
// line 7: update LMiC event display // line 7: update LMiC event display
u8x8.setCursor(0, 7); u8x8.setCursor(0, 7);
u8x8.printf("%-14s", display_line7); u8x8.printf("%-14s", lmic_event_msg);
// update LoRa send queue display // update LoRa send queue display
msgWaiting = uxQueueMessagesWaiting(LoraSendQueue); msgWaiting = uxQueueMessagesWaiting(LoraSendQueue);
@ -259,7 +256,6 @@ void draw_page(time_t t, uint8_t page) {
u8x8.printf("%-2s", msgWaiting == SEND_QUEUE_SIZE ? "<>" : buff); u8x8.printf("%-2s", msgWaiting == SEND_QUEUE_SIZE ? "<>" : buff);
} else } else
u8x8.printf(" "); u8x8.printf(" ");
#endif // HAS_LORA #endif // HAS_LORA
break; // page0 break; // page0

View File

@ -231,7 +231,6 @@ void onEvent(ev_t ev) {
case EV_JOINED: case EV_JOINED:
strcpy_P(buff, PSTR("JOINED")); strcpy_P(buff, PSTR("JOINED"));
sprintf(display_line6, " "); // clear previous lmic status
// set data rate adaptation according to saved setting // set data rate adaptation according to saved setting
LMIC_setAdrMode(cfg.adrmode); LMIC_setAdrMode(cfg.adrmode);
// set data rate and transmit power to defaults only if we have no ADR // set data rate and transmit power to defaults only if we have no ADR
@ -258,16 +257,7 @@ void onEvent(ev_t ev) {
break; break;
case EV_TXCOMPLETE: case EV_TXCOMPLETE:
strcpy_P(buff, PSTR("TX COMPLETE"));
#if (TIME_SYNC_LORASERVER)
// if last packet sent was a timesync request, store TX timestamp
if (LMIC.pendTxPort == TIMEPORT)
store_time_sync_req(osticks2ms(LMIC.txend)); // milliseconds
#endif
strcpy_P(buff, (LMIC.txrxFlags & TXRX_ACK) ? PSTR("RECEIVED ACK")
: PSTR("TX COMPLETE"));
sprintf(display_line6, " "); // clear previous lmic status
break; break;
case EV_LOST_TSYNC: case EV_LOST_TSYNC:
@ -321,7 +311,7 @@ void onEvent(ev_t ev) {
// Log & Display if asked // Log & Display if asked
if (*buff) { if (*buff) {
ESP_LOGI(TAG, "%s", buff); ESP_LOGI(TAG, "%s", buff);
sprintf(display_line7, buff); sprintf(lmic_event_msg, buff);
} }
} }
@ -585,7 +575,12 @@ void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg,
// transmit complete message handler // transmit complete message handler
void myTxCallback(void *pUserData, int fSuccess) { void myTxCallback(void *pUserData, int fSuccess) {
/* currently no code here */
#if (TIME_SYNC_LORASERVER)
// if last packet sent was a timesync request, store TX timestamp
if (LMIC.pendTxPort == TIMEPORT)
store_time_sync_req(osticks2ms(LMIC.txend)); // milliseconds
#endif
} }
// decode LORAWAN MAC message // decode LORAWAN MAC message

View File

@ -77,7 +77,7 @@ triggers pps 1 sec impulse
#include "main.h" #include "main.h"
configData_t cfg; // struct holds current device configuration configData_t cfg; // struct holds current device configuration
char display_line6[16], display_line7[16]; // display buffers char lmic_event_msg[16]; // display buffer for LMIC event message
uint8_t volatile channel = 0; // channel rotation counter uint8_t volatile channel = 0; // channel rotation counter
uint16_t volatile macs_total = 0, macs_wifi = 0, macs_ble = 0, uint16_t volatile macs_total = 0, macs_wifi = 0, macs_ble = 0,
batt_voltage = 0; // globals for display batt_voltage = 0; // globals for display

View File

@ -19,32 +19,25 @@ void do_reset() {
void set_reset(uint8_t val[]) { void set_reset(uint8_t val[]) {
switch (val[0]) { switch (val[0]) {
case 0: // restart device case 0: // restart device
sprintf(display_line6, "Reset pending");
do_reset(); do_reset();
break; break;
case 1: // reset MAC counter case 1: // reset MAC counter
ESP_LOGI(TAG, "Remote command: reset MAC counter"); ESP_LOGI(TAG, "Remote command: reset MAC counter");
reset_counters(); // clear macs reset_counters(); // clear macs
get_salt(); // get new salt get_salt(); // get new salt
sprintf(display_line6, "Reset counter");
break; break;
case 2: // reset device to factory settings case 2: // reset device to factory settings
ESP_LOGI(TAG, "Remote command: reset device to factory settings"); ESP_LOGI(TAG, "Remote command: reset device to factory settings");
sprintf(display_line6, "Factory reset");
eraseConfig(); eraseConfig();
break; break;
case 3: // reset send queues case 3: // reset send queues
ESP_LOGI(TAG, "Remote command: flush send queue"); ESP_LOGI(TAG, "Remote command: flush send queue");
sprintf(display_line6, "Queue reset");
flushQueues(); flushQueues();
break; break;
case 9: // reset and ask for software update via Wifi OTA case 9: // reset and ask for software update via Wifi OTA
ESP_LOGI(TAG, "Remote command: software update via Wifi"); ESP_LOGI(TAG, "Remote command: software update via Wifi");
#if (USE_OTA) #if (USE_OTA)
sprintf(display_line6, "Software update");
cfg.runmode = 1; cfg.runmode = 1;
#else
sprintf(display_line6, "Software update not implemented");
#endif // USE_OTA #endif // USE_OTA
break; break;