state machine (part 3)
This commit is contained in:
		
							parent
							
								
									eefac59030
								
							
						
					
					
						commit
						cbca740792
					
				@ -44,7 +44,8 @@ typedef struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
extern configData_t cfg;
 | 
					extern configData_t cfg;
 | 
				
			||||||
extern uint8_t mydata[];
 | 
					extern uint8_t mydata[];
 | 
				
			||||||
extern uint64_t currentMillis ;
 | 
					extern uint64_t uptimecounter;
 | 
				
			||||||
 | 
					extern uint32_t currentMillis ;
 | 
				
			||||||
extern osjob_t sendjob;
 | 
					extern osjob_t sendjob;
 | 
				
			||||||
extern char display_lora[], display_lmic[];
 | 
					extern char display_lora[], display_lmic[];
 | 
				
			||||||
extern int countermode, screensaver, adrmode, lorasf, txpower, rlim;
 | 
					extern int countermode, screensaver, adrmode, lorasf, txpower, rlim;
 | 
				
			||||||
 | 
				
			|||||||
@ -44,9 +44,9 @@ configData_t cfg; // struct holds current device configuration
 | 
				
			|||||||
osjob_t sendjob, initjob; // LMIC
 | 
					osjob_t sendjob, initjob; // LMIC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Initialize global variables
 | 
					// Initialize global variables
 | 
				
			||||||
#define DISPLAYREFRESH_MS (1 / DISPLAYFPS * (1000/portTICK_PERIOD_MS)) // calculate ms from fps
 | 
					 | 
				
			||||||
char display_lora[16], display_lmic[16]; // display buffers
 | 
					char display_lora[16], display_lmic[16]; // display buffers
 | 
				
			||||||
uint64_t currentMillis  = 0, previousLEDmillis = 0, previousDisplaymillis = 0;
 | 
					uint64_t uptimecounter = 0;
 | 
				
			||||||
 | 
					uint32_t currentMillis = 0, previousLEDmillis = 0, previousDisplaymillis = 0;
 | 
				
			||||||
uint8_t DisplayState, LEDState;
 | 
					uint8_t DisplayState, LEDState;
 | 
				
			||||||
uint16_t LEDBlinkduration = 500, LEDInterval = 1000, color = COLOR_NONE;
 | 
					uint16_t LEDBlinkduration = 500, LEDInterval = 1000, color = COLOR_NONE;
 | 
				
			||||||
uint8_t channel = 0; // wifi channel counter
 | 
					uint8_t channel = 0; // wifi channel counter
 | 
				
			||||||
@ -579,9 +579,11 @@ do_send(&sendjob);
 | 
				
			|||||||
// https://techtutorialsx.com/2017/05/09/esp32-get-task-execution-core/
 | 
					// https://techtutorialsx.com/2017/05/09/esp32-get-task-execution-core/
 | 
				
			||||||
void loop() {
 | 
					void loop() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    uptimecounter = uptime() / 1000; // counts uptime in seconds (64bit)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    // state machine for central control of all timimg based features
 | 
					    // state machine for central control of all timimg based features
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    currentMillis  = uptime() / 1000; // count uptime seconds
 | 
					    currentMillis = millis(); // timebase for state machine in milliseconds (32bit)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    #ifdef HAS_BUTTON
 | 
					    #ifdef HAS_BUTTON
 | 
				
			||||||
        readButton();
 | 
					        readButton();
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// program version - note: increment version after modifications to configData_t struct!!
 | 
					// program version - note: increment version after modifications to configData_t struct!!
 | 
				
			||||||
#define PROGVERSION                     "1.3.01"    // use max 10 chars here!
 | 
					#define PROGVERSION                     "1.3.1"    // use max 10 chars here!
 | 
				
			||||||
#define PROGNAME                        "PAXCNT"
 | 
					#define PROGNAME                        "PAXCNT"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Verbose enables serial output
 | 
					// Verbose enables serial output
 | 
				
			||||||
@ -47,7 +47,7 @@
 | 
				
			|||||||
#define RGBLUMINOSITY                   30      // 30%
 | 
					#define RGBLUMINOSITY                   30      // 30%
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// OLED Display refresh cycle (in Milliseconds)
 | 
					// OLED Display refresh cycle (in Milliseconds)
 | 
				
			||||||
#define DISPLAYFPS                      5       // [fps] -> 5 Frames per second ps = 200ms refreseh cycle
 | 
					#define DISPLAYREFRESH_MS               40       // e.g. 40ms -> 1000/40 = 25 frames per second
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// LMIC settings
 | 
					// LMIC settings
 | 
				
			||||||
// define hardware independent LMIC settings here, settings of standard library in /lmic/config.h will be ignored
 | 
					// define hardware independent LMIC settings here, settings of standard library in /lmic/config.h will be ignored
 | 
				
			||||||
 | 
				
			|||||||
@ -210,9 +210,9 @@ void get_config (int val) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void get_uptime (int val) {
 | 
					void get_uptime (int val) {
 | 
				
			||||||
    ESP_LOGI(TAG, "Remote command: get uptime");
 | 
					    ESP_LOGI(TAG, "Remote command: get uptime");
 | 
				
			||||||
    int size = sizeof(currentMillis );
 | 
					    int size = sizeof(uptimecounter);
 | 
				
			||||||
    unsigned char *sendData = new unsigned char[size];
 | 
					    unsigned char *sendData = new unsigned char[size];
 | 
				
			||||||
    memcpy(sendData, (unsigned char*)¤tMillis , size);
 | 
					    memcpy(sendData, (unsigned char*)&uptimecounter , size);
 | 
				
			||||||
    LMIC_setTxData2(RCMDPORT, sendData, size-1, 0); // send data unconfirmed on RCMD Port
 | 
					    LMIC_setTxData2(RCMDPORT, sendData, size-1, 0); // send data unconfirmed on RCMD Port
 | 
				
			||||||
    delete sendData; // free memory
 | 
					    delete sendData; // free memory
 | 
				
			||||||
    ESP_LOGI(TAG, "%i bytes queued in send queue", size-1);
 | 
					    ESP_LOGI(TAG, "%i bytes queued in send queue", size-1);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user