Merge branch 'development' into master
This commit is contained in:
		
						commit
						441863109f
					
				| @ -1,6 +1,9 @@ | |||||||
| #ifndef _BUTTON_H | #ifndef _BUTTON_H | ||||||
| #define _BUTTON_H | #define _BUTTON_H | ||||||
| 
 | 
 | ||||||
|  | #include <SimpleButton.h> | ||||||
|  | 
 | ||||||
|  | void button_init(int pin); | ||||||
| void readButton(); | void readButton(); | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
| @ -32,7 +32,7 @@ description = Paxcounter is a proof-of-concept ESP32 device for metering passeng | |||||||
| 
 | 
 | ||||||
| [common] | [common] | ||||||
| ; for release_version use max. 10 chars total, use any decimal format like "a.b.c" | ; for release_version use max. 10 chars total, use any decimal format like "a.b.c" | ||||||
| release_version = 1.7.55 | release_version = 1.7.6 | ||||||
| ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! | ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! | ||||||
| ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose | ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose | ||||||
| debug_level = 3 | debug_level = 3 | ||||||
| @ -63,6 +63,7 @@ lib_deps_basic = | |||||||
|     ArduinoJson@^5.13.1 |     ArduinoJson@^5.13.1 | ||||||
|     Timezone@^1.2.2 |     Timezone@^1.2.2 | ||||||
|     RTC@^2.3.0 |     RTC@^2.3.0 | ||||||
|  |     SimpleButton | ||||||
| lib_deps_all = | lib_deps_all = | ||||||
|     ${common.lib_deps_basic} |     ${common.lib_deps_basic} | ||||||
|     ${common.lib_deps_lora} |     ${common.lib_deps_lora} | ||||||
|  | |||||||
| @ -3,11 +3,25 @@ | |||||||
| #include "globals.h" | #include "globals.h" | ||||||
| #include "button.h" | #include "button.h" | ||||||
| 
 | 
 | ||||||
|  | using namespace simplebutton; | ||||||
|  | 
 | ||||||
| // Local logging tag
 | // Local logging tag
 | ||||||
| static const char TAG[] = __FILE__; | static const char TAG[] = __FILE__; | ||||||
| 
 | 
 | ||||||
| void readButton() { | static Button *b = NULL; | ||||||
|   ESP_LOGI(TAG, "Button pressed"); | 
 | ||||||
|  | void button_init(int pin) { | ||||||
|  | #ifdef BUTTON_PULLDOWN | ||||||
|  |   b = new Button(pin); | ||||||
|  | #else | ||||||
|  |   b = new ButtonPullup(pin); | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  |   // attach events to the button
 | ||||||
|  | 
 | ||||||
|  |   b->setOnDoubleClicked([]() {}); | ||||||
|  | 
 | ||||||
|  |   b->setOnClicked([]() { | ||||||
| #ifdef HAS_DISPLAY | #ifdef HAS_DISPLAY | ||||||
|     refreshtheDisplay(true); // switch to next display page
 |     refreshtheDisplay(true); // switch to next display page
 | ||||||
| #else | #else | ||||||
| @ -15,5 +29,18 @@ void readButton() { | |||||||
|     payload.addButton(0x01); |     payload.addButton(0x01); | ||||||
|     SendPayload(BUTTONPORT, prio_normal); |     SendPayload(BUTTONPORT, prio_normal); | ||||||
| #endif | #endif | ||||||
| } |   }); | ||||||
|  | 
 | ||||||
|  |   b->setOnHolding([]() { | ||||||
|  | #if (HAS_LORA) | ||||||
|  |     cfg.adrmode = !cfg.adrmode; | ||||||
|  |     LMIC_setAdrMode(cfg.adrmode); | ||||||
|  | #endif | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   // attach interrupt to the button
 | ||||||
|  |   attachInterrupt(digitalPinToInterrupt(pin), ButtonIRQ, CHANGE); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void readButton() { b->update(); } | ||||||
| #endif | #endif | ||||||
							
								
								
									
										40
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								src/main.cpp
									
									
									
									
									
								
							| @ -266,20 +266,6 @@ void setup() { | |||||||
|       esp_coex_prefer_t)ESP_COEX_PREFER_WIFI)); // configure Wifi/BT coexist lib
 |       esp_coex_prefer_t)ESP_COEX_PREFER_WIFI)); // configure Wifi/BT coexist lib
 | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| // initialize button
 |  | ||||||
| #ifdef HAS_BUTTON |  | ||||||
|   strcat_P(features, " BTN_"); |  | ||||||
| #ifdef BUTTON_PULLUP |  | ||||||
|   strcat_P(features, "PU"); |  | ||||||
|   // install button interrupt (pullup mode)
 |  | ||||||
|   pinMode(HAS_BUTTON, INPUT_PULLUP); |  | ||||||
| #else |  | ||||||
|   strcat_P(features, "PD"); |  | ||||||
|   // install button interrupt (pulldown mode)
 |  | ||||||
|   pinMode(HAS_BUTTON, INPUT_PULLDOWN); |  | ||||||
| #endif // BUTTON_PULLUP
 |  | ||||||
| #endif // HAS_BUTTON
 |  | ||||||
| 
 |  | ||||||
| // initialize gps
 | // initialize gps
 | ||||||
| #if (HAS_GPS) | #if (HAS_GPS) | ||||||
|   strcat_P(features, " GPS"); |   strcat_P(features, " GPS"); | ||||||
| @ -372,9 +358,6 @@ void setup() { | |||||||
|   esp_wifi_deinit(); |   esp_wifi_deinit(); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|   // show compiled features
 |  | ||||||
|   ESP_LOGI(TAG, "Features:%s", features); |  | ||||||
| 
 |  | ||||||
|   // start state machine
 |   // start state machine
 | ||||||
|   ESP_LOGI(TAG, "Starting Interrupt Handler..."); |   ESP_LOGI(TAG, "Starting Interrupt Handler..."); | ||||||
|   xTaskCreatePinnedToCore(irqHandler,      // task function
 |   xTaskCreatePinnedToCore(irqHandler,      // task function
 | ||||||
| @ -428,6 +411,17 @@ void setup() { | |||||||
|   timerAlarmEnable(matrixDisplayIRQ); |   timerAlarmEnable(matrixDisplayIRQ); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|  |   // initialize button
 | ||||||
|  | #ifdef HAS_BUTTON | ||||||
|  |   strcat_P(features, " BTN_"); | ||||||
|  | #ifdef BUTTON_PULLUP | ||||||
|  |   strcat_P(features, "PU"); | ||||||
|  | #else | ||||||
|  |   strcat_P(features, "PD"); | ||||||
|  | #endif // BUTTON_PULLUP
 | ||||||
|  |   button_init(HAS_BUTTON); | ||||||
|  | #endif // HAS_BUTTON
 | ||||||
|  | 
 | ||||||
|   // gps buffer read interrupt
 |   // gps buffer read interrupt
 | ||||||
| #if (HAS_GPS) | #if (HAS_GPS) | ||||||
|   gpsIRQ = timerBegin(2, 80, true); |   gpsIRQ = timerBegin(2, 80, true); | ||||||
| @ -440,15 +434,6 @@ void setup() { | |||||||
|   sendcycler.attach(SENDCYCLE * 2, sendcycle); |   sendcycler.attach(SENDCYCLE * 2, sendcycle); | ||||||
|   housekeeper.attach(HOMECYCLE, housekeeping); |   housekeeper.attach(HOMECYCLE, housekeeping); | ||||||
| 
 | 
 | ||||||
| // button interrupt
 |  | ||||||
| #ifdef HAS_BUTTON |  | ||||||
| #ifdef BUTTON_PULLUP |  | ||||||
|   attachInterrupt(digitalPinToInterrupt(HAS_BUTTON), ButtonIRQ, RISING); |  | ||||||
| #else |  | ||||||
|   attachInterrupt(digitalPinToInterrupt(HAS_BUTTON), ButtonIRQ, FALLING); |  | ||||||
| #endif |  | ||||||
| #endif // HAS_BUTTON
 |  | ||||||
| 
 |  | ||||||
| #if (TIME_SYNC_INTERVAL) | #if (TIME_SYNC_INTERVAL) | ||||||
| 
 | 
 | ||||||
| #if (!(TIME_SYNC_LORAWAN) && !(TIME_SYNC_LORASERVER) && !defined HAS_GPS &&    \ | #if (!(TIME_SYNC_LORAWAN) && !(TIME_SYNC_LORASERVER) && !defined HAS_GPS &&    \ | ||||||
| @ -471,6 +456,9 @@ void setup() { | |||||||
| 
 | 
 | ||||||
| #endif // TIME_SYNC_INTERVAL
 | #endif // TIME_SYNC_INTERVAL
 | ||||||
| 
 | 
 | ||||||
|  |   // show compiled features
 | ||||||
|  |   ESP_LOGI(TAG, "Features:%s", features); | ||||||
|  | 
 | ||||||
| } // setup()
 | } // setup()
 | ||||||
| 
 | 
 | ||||||
| void loop() { | void loop() { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user