auto page flip mode

This commit is contained in:
Verkehrsrot 2020-01-20 11:41:31 +01:00
parent 5cb51b2ff0
commit f960627910
3 changed files with 23 additions and 19 deletions

View File

@ -6,10 +6,10 @@
extern uint8_t DisplayIsOn, displaybuf[]; extern uint8_t DisplayIsOn, displaybuf[];
void refreshTheDisplay(bool nextPage = false, bool toggle_screencycle = false); void refreshTheDisplay(bool nextPage = false);
void init_display(bool verbose = false); void init_display(bool verbose = false);
void shutdown_display(void); void shutdown_display(void);
void draw_page(time_t t, bool nextpage, bool cyclescreen); void draw_page(time_t t, bool nextpage);
void dp_printf(uint16_t x, uint16_t y, uint8_t font, uint8_t inv, void dp_printf(uint16_t x, uint16_t y, uint8_t font, uint8_t inv,
const char *format, ...); const char *format, ...);
void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message); void dp_printqr(uint16_t offset_x, uint16_t offset_y, const char *Message);

View File

@ -149,12 +149,9 @@ void init_display(bool verbose) {
} // mutex } // mutex
} // init_display } // init_display
void refreshTheDisplay(bool nextPage, bool toggle_screencycle) { void refreshTheDisplay(bool nextPage) {
static bool screencycle = false; static uint32_t framecounter = 0;
if (toggle_screencycle)
screencycle = !screencycle;
// update histogram // update histogram
oledPlotCurve(macs.size(), false); oledPlotCurve(macs.size(), false);
@ -176,7 +173,15 @@ void refreshTheDisplay(bool nextPage, bool toggle_screencycle) {
oledPower(cfg.screenon); oledPower(cfg.screenon);
} }
draw_page(t, nextPage, screencycle); #ifndef HAS_BUTTON
// auto flip page if we are in unattended mode
if ((++framecounter) > (DISPLAYCYCLE * 1000 / DISPLAYREFRESH_MS)) {
framecounter = 0;
nextPage = true;
}
#endif
draw_page(t, nextPage);
oledDumpBuffer(displaybuf); oledDumpBuffer(displaybuf);
I2C_MUTEX_UNLOCK(); // release i2c bus access I2C_MUTEX_UNLOCK(); // release i2c bus access
@ -196,11 +201,10 @@ void shutdown_display(void) {
} }
} }
void draw_page(time_t t, bool nextpage, bool cyclescreen) { void draw_page(time_t t, bool nextpage) {
// write display content to display buffer // write display content to display buffer
// nextpage = true -> flip 1 page // nextpage = true -> flip 1 page
// cyclescreen = true -> page cycling mode
static uint8_t DisplayPage = 0; static uint8_t DisplayPage = 0;
char timeState; char timeState;
@ -366,13 +370,12 @@ start:
// page 5: blank screen // page 5: blank screen
case 5: case 5:
if (cyclescreen) #ifdef HAS_BUTTON
DisplayPage++; // next page oledFill(0, 1);
else // show blank page only if we are not in screencycle mode break;
{ #else // don't show blank page if we are unattended
oledFill(0, 1); DisplayPage++; // next page
break; #endif
}
default: default:
goto start; // start over goto start; // start over

View File

@ -57,6 +57,7 @@
#define RGBLUMINOSITY 30 // RGB LED luminosity [default = 30%] #define RGBLUMINOSITY 30 // RGB LED luminosity [default = 30%]
#define DISPLAYREFRESH_MS 40 // OLED refresh cycle in ms [default = 40] -> 1000/40 = 25 frames per second #define DISPLAYREFRESH_MS 40 // OLED refresh cycle in ms [default = 40] -> 1000/40 = 25 frames per second
#define DISPLAYCONTRAST 80 // 0 .. 255, OLED display contrast [default = 80] #define DISPLAYCONTRAST 80 // 0 .. 255, OLED display contrast [default = 80]
#define DISPLAYCYCLE 3 // Auto page flip delay in sec [default = 2] for devices without button
#define HOMECYCLE 30 // house keeping cycle in seconds [default = 30 secs] #define HOMECYCLE 30 // house keeping cycle in seconds [default = 30 secs]
// Settings for BME680 environmental sensor // Settings for BME680 environmental sensor
@ -76,7 +77,7 @@
#define TIME_SYNC_INTERVAL_RETRY 10 // retry time sync after lost sync each .. minutes [default = 10], 0 means off #define TIME_SYNC_INTERVAL_RETRY 10 // retry time sync after lost sync each .. minutes [default = 10], 0 means off
#define TIME_SYNC_COMPILEDATE 0 // set to 1 to use compile date to initialize RTC after power outage [default = 0] #define TIME_SYNC_COMPILEDATE 0 // set to 1 to use compile date to initialize RTC after power outage [default = 0]
#define TIME_SYNC_LORAWAN 0 // set to 1 to use LORA network as time source, 0 means off [default = 0] #define TIME_SYNC_LORAWAN 0 // set to 1 to use LORA network as time source, 0 means off [default = 0]
#define TIME_SYNC_LORASERVER 0 // set to 1 to use LORA timeserver as time source, 0 means off [default = 0] #define TIME_SYNC_LORASERVER 1 // set to 1 to use LORA timeserver as time source, 0 means off [default = 0]
// settings for syncing time with timeserver applications // settings for syncing time with timeserver applications
#define TIME_SYNC_SAMPLES 1 // number of time requests for averaging #define TIME_SYNC_SAMPLES 1 // number of time requests for averaging
@ -93,7 +94,7 @@
#define RCMDPORT 2 // remote commands #define RCMDPORT 2 // remote commands
#define STATUSPORT 2 // remote command results #define STATUSPORT 2 // remote command results
#define CONFIGPORT 3 // config query results #define CONFIGPORT 3 // config query results
#define GPSPORT 4 // gps - set to 1 to send combined GPS+COUNTERPORT payload #define GPSPORT 1 // gps - set to 1 to send combined GPS+COUNTERPORT payload
#define BUTTONPORT 5 // button pressed signal #define BUTTONPORT 5 // button pressed signal
#define BEACONPORT 6 // beacon alarms #define BEACONPORT 6 // beacon alarms
#define BMEPORT 7 // BME680 sensor #define BMEPORT 7 // BME680 sensor