scalefactor for curve plotter
This commit is contained in:
parent
be01760c32
commit
0440e536dd
@ -5,6 +5,7 @@
|
||||
#include "senddata.h"
|
||||
#include "rcommand.h"
|
||||
#include "spislave.h"
|
||||
|
||||
#if(HAS_LORA)
|
||||
#include <lmic.h>
|
||||
#endif
|
||||
@ -13,6 +14,10 @@
|
||||
#include "bmesensor.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAS_DISPLAY
|
||||
#include "display.h"
|
||||
#endif
|
||||
|
||||
extern Ticker housekeeper;
|
||||
|
||||
void housekeeping(void);
|
||||
|
@ -18,6 +18,6 @@ void oledScrollBufferLeft(uint8_t *buf, const uint16_t width,
|
||||
const uint16_t height);
|
||||
int oledDrawPixel(uint8_t *buf, const uint16_t x, const uint16_t y,
|
||||
const uint8_t dot);
|
||||
void oledPlotCurve(uint16_t count);
|
||||
void oledPlotCurve(uint16_t count, bool reset);
|
||||
|
||||
#endif
|
@ -2,10 +2,15 @@
|
||||
#define _SENDDATA_H
|
||||
|
||||
#include "spislave.h"
|
||||
#include "cyclic.h"
|
||||
|
||||
#if(HAS_LORA)
|
||||
#include "lorawan.h"
|
||||
#endif
|
||||
#include "cyclic.h"
|
||||
|
||||
#ifdef HAS_DISPLAY
|
||||
#include "display.h"
|
||||
#endif
|
||||
|
||||
extern Ticker sendcycler;
|
||||
|
||||
|
@ -128,5 +128,9 @@ void reset_counters() {
|
||||
macs_total = 0; // reset all counters
|
||||
macs_wifi = 0;
|
||||
macs_ble = 0;
|
||||
#ifdef HAS_DISPLAY
|
||||
oledPlotCurve(0, true);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
@ -47,9 +47,8 @@ static const char TAG[] = __FILE__;
|
||||
#define QR_SCALEFACTOR 2 // 29 -> 58x < 64px
|
||||
|
||||
// settings for curve plotter
|
||||
#define PLOT_SCALEFACTOR 1 // downscales pax numbers to display rows
|
||||
#define DISPLAY_WIDTH 128 // Width in pixels of OLED-display, must be 32X
|
||||
#define DISPLAY_HEIGHT 64 // Height in pixels of OLED-display, must be 16X
|
||||
#define DISPLAY_WIDTH 128 // Width in pixels of OLED-display, must be 32X
|
||||
#define DISPLAY_HEIGHT 64 // Height in pixels of OLED-display, must be 16X
|
||||
|
||||
// helper array for converting month values to text
|
||||
const char *printmonth[] = {"xxx", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
@ -185,7 +184,7 @@ void draw_page(time_t t, uint8_t page) {
|
||||
macs.size()); // display number of unique macs total Wifi + BLE
|
||||
|
||||
// update histogram if we have a display
|
||||
oledPlotCurve(macs.size());
|
||||
oledPlotCurve(macs.size(), false);
|
||||
|
||||
switch (page % DISPLAY_PAGES) {
|
||||
|
||||
@ -424,31 +423,33 @@ void oledScrollBufferLeft(uint8_t *buf, const uint16_t width,
|
||||
}
|
||||
}
|
||||
|
||||
void oledPlotCurve(uint16_t count) {
|
||||
void oledPlotCurve(uint16_t count, bool reset) {
|
||||
|
||||
uint8_t level;
|
||||
static uint16_t last_count = 0, col = 0, row = 0;
|
||||
static uint16_t last_count = 0, col = 0, row = 0, scalefactor = 1;
|
||||
|
||||
if (last_count == count)
|
||||
if ((last_count == count) && !reset)
|
||||
return;
|
||||
|
||||
// next count cycle?
|
||||
if (count == 0) {
|
||||
|
||||
// matrix full? then scroll left 1 dot, else increment column
|
||||
if (col < DISPLAY_WIDTH - 1)
|
||||
if (reset) { // next count cycle?
|
||||
if (col < DISPLAY_WIDTH - 1) // matrix not full -> increment column
|
||||
col++;
|
||||
else
|
||||
else // matrix full -> scroll left 1 dot
|
||||
oledScrollBufferLeft(displaybuf, DISPLAY_WIDTH, DISPLAY_HEIGHT);
|
||||
|
||||
} else
|
||||
oledDrawPixel(displaybuf, col, row, 0); // clear current dot
|
||||
} else // clear current dot
|
||||
oledDrawPixel(displaybuf, col, row, 0);
|
||||
|
||||
// scale and set new dot
|
||||
// re-scale, if necessary
|
||||
while (((count / scalefactor) <= DISPLAY_HEIGHT) && (scalefactor > 1)) {
|
||||
scalefactor--;
|
||||
}
|
||||
while ((count / scalefactor) > DISPLAY_HEIGHT) {
|
||||
scalefactor++;
|
||||
}
|
||||
|
||||
// set new dot
|
||||
row = DISPLAY_HEIGHT - 1 - (count / scalefactor) % DISPLAY_HEIGHT;
|
||||
last_count = count;
|
||||
level = count / PLOT_SCALEFACTOR;
|
||||
row =
|
||||
level <= DISPLAY_HEIGHT ? DISPLAY_HEIGHT - 1 - level % DISPLAY_HEIGHT : 0;
|
||||
oledDrawPixel(displaybuf, col, row, 1);
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,10 @@ void sendData() {
|
||||
get_salt(); // get new salt for salting hashes
|
||||
ESP_LOGI(TAG, "Counter cleared");
|
||||
}
|
||||
#ifdef HAS_DISPLAY
|
||||
else
|
||||
oledPlotCurve(macs.size(), true);
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user