bugfix curve plotter zero drops

This commit is contained in:
cyberman54 2022-02-15 21:58:20 +01:00
parent a1461be403
commit 641b0ad7a2

View File

@ -43,7 +43,6 @@ uint8_t DisplayIsOn = 0;
uint8_t displaybuf[MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8] = {0}; uint8_t displaybuf[MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8] = {0};
static uint8_t plotbuf[MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8] = {0}; static uint8_t plotbuf[MY_DISPLAY_WIDTH * MY_DISPLAY_HEIGHT / 8] = {0};
static int dp_row = 0, dp_col = 0, dp_font = 0; static int dp_row = 0, dp_col = 0, dp_font = 0;
static struct count_payload_t count; // libpax count storage
hw_timer_t *displayIRQ = NULL; hw_timer_t *displayIRQ = NULL;
@ -175,16 +174,10 @@ void dp_init(bool verbose) {
void dp_refresh(bool nextPage) { void dp_refresh(bool nextPage) {
// update counter values from libpax
libpax_counter_count(&count);
#ifndef HAS_BUTTON #ifndef HAS_BUTTON
static uint32_t framecounter = 0; static uint32_t framecounter = 0;
#endif #endif
// update histogram
dp_plotCurve(count.pax, false);
// if display is switched off we don't refresh it to relax cpu // if display is switched off we don't refresh it to relax cpu
if (!DisplayIsOn && (DisplayIsOn == cfg.screenon)) if (!DisplayIsOn && (DisplayIsOn == cfg.screenon))
return; return;
@ -208,7 +201,6 @@ void dp_refresh(bool nextPage) {
#endif #endif
dp_drawPage(nextPage); dp_drawPage(nextPage);
dp_dump(displaybuf);
I2C_MUTEX_UNLOCK(); // release i2c bus access I2C_MUTEX_UNLOCK(); // release i2c bus access
@ -220,6 +212,7 @@ void dp_drawPage(bool nextpage) {
// write display content to display buffer // write display content to display buffer
// nextpage = true -> flip 1 page // nextpage = true -> flip 1 page
struct count_payload_t count; // libpax count storage
static uint8_t DisplayPage = 0; static uint8_t DisplayPage = 0;
char timeState, strftime_buf[64]; char timeState, strftime_buf[64];
time_t now; time_t now;
@ -234,6 +227,9 @@ void dp_drawPage(bool nextpage) {
dp_clear(); dp_clear();
} }
// update counter values from libpax
libpax_counter_count(&count);
// cursor home // cursor home
dp_setTextCursor(0, 0); dp_setTextCursor(0, 0);
@ -345,6 +341,8 @@ void dp_drawPage(bool nextpage) {
dp_printf("%-4s", getSfName(updr2rps(LMIC.datarate))); dp_printf("%-4s", getSfName(updr2rps(LMIC.datarate)));
dp_setFont(MY_FONT_SMALL, 0); dp_setFont(MY_FONT_SMALL, 0);
#endif // HAS_LORA #endif // HAS_LORA
dp_dump(displaybuf);
break; break;
// ---------- page 1: lorawan parameters ---------- // ---------- page 1: lorawan parameters ----------
@ -370,6 +368,8 @@ void dp_drawPage(bool nextpage) {
LMIC.seqnoDn ? LMIC.seqnoDn - 1 : 0); LMIC.seqnoDn ? LMIC.seqnoDn - 1 : 0);
dp_println(); dp_println();
dp_printf("SNR:%-5d RSSI:%-5d", (LMIC.snr + 2) / 4, LMIC.rssi); dp_printf("SNR:%-5d RSSI:%-5d", (LMIC.snr + 2) / 4, LMIC.rssi);
dp_dump(displaybuf);
break; break;
#else // flip page if we are unattended #else // flip page if we are unattended
DisplayPage++; DisplayPage++;
@ -402,6 +402,8 @@ void dp_drawPage(bool nextpage) {
dp_printf("No fix"); dp_printf("No fix");
wasnofix = true; wasnofix = true;
} }
dp_dump(displaybuf);
break; break;
#else // flip page if we are unattended #else // flip page if we are unattended
DisplayPage++; DisplayPage++;
@ -425,10 +427,12 @@ void dp_drawPage(bool nextpage) {
#ifdef HAS_BME680 #ifdef HAS_BME680
// line 6-7: IAQ // line 6-7: IAQ
dp_printf("IAQ:%-3.0f", bme_status.iaq); dp_printf("IAQ:%-3.0f", bme_status.iaq);
#else // is BME280 or BMP180 #else // is BME280 or BMP180
// line 6-7: Pre // line 6-7: Pre
dp_printf("PRE:%-2.1f", bme_status.pressure); dp_printf("PRE:%-2.1f", bme_status.pressure);
#endif // HAS_BME680 #endif // HAS_BME680
dp_dump(displaybuf);
break; // page 3 break; // page 3
#else // flip page if we are unattended #else // flip page if we are unattended
DisplayPage++; DisplayPage++;
@ -443,14 +447,15 @@ void dp_drawPage(bool nextpage) {
localtime_r(&now, &timeinfo); localtime_r(&now, &timeinfo);
strftime(strftime_buf, sizeof(strftime_buf), "%T", &timeinfo); strftime(strftime_buf, sizeof(strftime_buf), "%T", &timeinfo);
dp_printf("%.8s", strftime_buf); dp_printf("%.8s", strftime_buf);
dp_dump(displaybuf);
break; break;
// ---------- page 5: pax graph ---------- // ---------- page 5: pax graph ----------
case 5: case 5:
dp_setFont(MY_FONT_NORMAL); // update histogram
dp_setTextCursor(0, 0); dp_plotCurve(count.pax, false);
dp_printf("Pax graph");
dp_dump(plotbuf); dp_dump(plotbuf);
break; break;