| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  Arduino.h - Main include file for the Arduino SDK | 
					
						
							|  |  |  |  Copyright (c) 2005-2013 Arduino Team.  All right reserved. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  This library is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  modify it under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  |  License as published by the Free Software Foundation; either | 
					
						
							|  |  |  |  version 2.1 of the License, or (at your option) any later version. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  This library is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
					
						
							|  |  |  |  Lesser General Public License for more details. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  You should have received a copy of the GNU Lesser General Public | 
					
						
							|  |  |  |  License along with this library; if not, write to the Free Software | 
					
						
							|  |  |  |  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef Arduino_h
 | 
					
						
							|  |  |  | #define Arduino_h
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdbool.h>
 | 
					
						
							|  |  |  | #include <stdint.h>
 | 
					
						
							|  |  |  | #include <stdarg.h>
 | 
					
						
							|  |  |  | #include <stddef.h>
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | #include <inttypes.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-26 02:00:39 +03:00
										 |  |  | #include "freertos/FreeRTOS.h"
 | 
					
						
							|  |  |  | #include "freertos/task.h"
 | 
					
						
							|  |  |  | #include "freertos/semphr.h"
 | 
					
						
							|  |  |  | #include "esp32-hal.h"
 | 
					
						
							| 
									
										
										
										
											2017-10-30 07:27:26 -02:00
										 |  |  | #include "esp8266-compat.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-26 02:00:39 +03:00
										 |  |  | #include "soc/gpio_reg.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-26 02:13:00 +03:00
										 |  |  | #include "stdlib_noniso.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | #include "binary.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-26 02:00:39 +03:00
										 |  |  | #define PI 3.1415926535897932384626433832795
 | 
					
						
							|  |  |  | #define HALF_PI 1.5707963267948966192313216916398
 | 
					
						
							|  |  |  | #define TWO_PI 6.283185307179586476925286766559
 | 
					
						
							|  |  |  | #define DEG_TO_RAD 0.017453292519943295769236907684886
 | 
					
						
							|  |  |  | #define RAD_TO_DEG 57.295779513082320876798154814105
 | 
					
						
							|  |  |  | #define EULER 2.718281828459045235360287471352
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define SERIAL  0x0
 | 
					
						
							|  |  |  | #define DISPLAY 0x1
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define LSBFIRST 0
 | 
					
						
							|  |  |  | #define MSBFIRST 1
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //Interrupt Modes
 | 
					
						
							|  |  |  | #define RISING    0x01
 | 
					
						
							|  |  |  | #define FALLING   0x02
 | 
					
						
							|  |  |  | #define CHANGE    0x03
 | 
					
						
							|  |  |  | #define ONLOW     0x04
 | 
					
						
							|  |  |  | #define ONHIGH    0x05
 | 
					
						
							|  |  |  | #define ONLOW_WE  0x0C
 | 
					
						
							|  |  |  | #define ONHIGH_WE 0x0D
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define DEFAULT 1
 | 
					
						
							|  |  |  | #define EXTERNAL 0
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __STRINGIFY
 | 
					
						
							|  |  |  | #define __STRINGIFY(a) #a
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // undefine stdlib's abs if encountered
 | 
					
						
							|  |  |  | #ifdef abs
 | 
					
						
							|  |  |  | #undef abs
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define abs(x) ((x)>0?(x):-(x))
 | 
					
						
							|  |  |  | #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
 | 
					
						
							|  |  |  | #define radians(deg) ((deg)*DEG_TO_RAD)
 | 
					
						
							|  |  |  | #define degrees(rad) ((rad)*RAD_TO_DEG)
 | 
					
						
							|  |  |  | #define sq(x) ((x)*(x))
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define sei()
 | 
					
						
							|  |  |  | #define cli()
 | 
					
						
							|  |  |  | #define interrupts() sei()
 | 
					
						
							|  |  |  | #define noInterrupts() cli()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
 | 
					
						
							|  |  |  | #define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
 | 
					
						
							|  |  |  | #define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define lowByte(w) ((uint8_t) ((w) & 0xff))
 | 
					
						
							|  |  |  | #define highByte(w) ((uint8_t) ((w) >> 8))
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define bitRead(value, bit) (((value) >> (bit)) & 0x01)
 | 
					
						
							|  |  |  | #define bitSet(value, bit) ((value) |= (1UL << (bit)))
 | 
					
						
							|  |  |  | #define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
 | 
					
						
							|  |  |  | #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-12 02:12:13 +02:00
										 |  |  | // avr-libc defines _NOP() since 1.6.2
 | 
					
						
							|  |  |  | #ifndef _NOP
 | 
					
						
							|  |  |  | #define _NOP() do { __asm__ volatile ("nop"); } while (0)
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-26 02:00:39 +03:00
										 |  |  | #define bit(b) (1UL << (b))
 | 
					
						
							|  |  |  | #define _BV(b) (1UL << (b))
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define digitalPinToPort(pin)       (((pin)>31)?1:0)
 | 
					
						
							| 
									
										
										
										
											2017-03-03 14:42:14 +02:00
										 |  |  | #define digitalPinToBitMask(pin)    (1UL << (((pin)>31)?((pin)-32):(pin)))
 | 
					
						
							| 
									
										
										
										
											2016-10-26 02:00:39 +03:00
										 |  |  | #define digitalPinToTimer(pin)      (0)
 | 
					
						
							| 
									
										
										
										
											2016-12-12 02:12:13 +02:00
										 |  |  | #define analogInPinToBit(P)         (P)
 | 
					
						
							| 
									
										
										
										
											2016-10-26 02:00:39 +03:00
										 |  |  | #define portOutputRegister(port)    ((volatile uint32_t*)((port)?GPIO_OUT1_REG:GPIO_OUT_REG))
 | 
					
						
							|  |  |  | #define portInputRegister(port)     ((volatile uint32_t*)((port)?GPIO_IN1_REG:GPIO_IN_REG))
 | 
					
						
							|  |  |  | #define portModeRegister(port)      ((volatile uint32_t*)((port)?GPIO_ENABLE1_REG:GPIO_ENABLE_REG))
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define NOT_A_PIN -1
 | 
					
						
							|  |  |  | #define NOT_A_PORT -1
 | 
					
						
							|  |  |  | #define NOT_AN_INTERRUPT -1
 | 
					
						
							|  |  |  | #define NOT_ON_TIMER 0
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef bool boolean; | 
					
						
							|  |  |  | typedef uint8_t byte; | 
					
						
							| 
									
										
										
										
											2017-02-20 15:06:22 +02:00
										 |  |  | typedef unsigned int word; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void setup(void); | 
					
						
							|  |  |  | void loop(void); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | long random(long, long); | 
					
						
							|  |  |  | void randomSeed(unsigned long); | 
					
						
							|  |  |  | long map(long, long, long, long, long); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-10-26 02:00:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-12 02:12:13 +02:00
										 |  |  | void init(void); | 
					
						
							|  |  |  | void initVariant(void); | 
					
						
							|  |  |  | void initArduino(void); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-20 13:49:17 -06:00
										 |  |  | unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); | 
					
						
							|  |  |  | unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-13 16:53:56 +02:00
										 |  |  | uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); | 
					
						
							|  |  |  | void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-10-26 02:00:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-17 15:33:01 -04:00
										 |  |  | #include <algorithm>
 | 
					
						
							|  |  |  | #include <cmath>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | #include "WCharacter.h"
 | 
					
						
							|  |  |  | #include "WString.h"
 | 
					
						
							|  |  |  | #include "Stream.h"
 | 
					
						
							|  |  |  | #include "Printable.h"
 | 
					
						
							|  |  |  | #include "Print.h"
 | 
					
						
							|  |  |  | #include "IPAddress.h"
 | 
					
						
							|  |  |  | #include "Client.h"
 | 
					
						
							|  |  |  | #include "Server.h"
 | 
					
						
							|  |  |  | #include "Udp.h"
 | 
					
						
							|  |  |  | #include "HardwareSerial.h"
 | 
					
						
							|  |  |  | #include "Esp.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-17 15:33:01 -04:00
										 |  |  | using std::isinf; | 
					
						
							|  |  |  | using std::isnan; | 
					
						
							|  |  |  | using std::max; | 
					
						
							|  |  |  | using std::min; | 
					
						
							|  |  |  | using ::round; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-05 22:53:04 +02:00
										 |  |  | uint16_t makeWord(uint16_t w); | 
					
						
							|  |  |  | uint16_t makeWord(byte h, byte l); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define word(...) makeWord(__VA_ARGS__)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-20 13:49:17 -06:00
										 |  |  | unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); | 
					
						
							|  |  |  | unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-24 04:07:27 +02:00
										 |  |  | extern "C" bool getLocalTime(struct tm * info, uint32_t ms = 5000); | 
					
						
							|  |  |  | extern "C" void configTime(long gmtOffset_sec, int daylightOffset_sec, | 
					
						
							|  |  |  |         const char* server1, const char* server2 = nullptr, const char* server3 = nullptr); | 
					
						
							| 
									
										
										
										
											2017-09-05 04:15:55 -04:00
										 |  |  | extern "C" void configTzTime(const char* tz, | 
					
						
							|  |  |  |         const char* server1, const char* server2 = nullptr, const char* server3 = nullptr); | 
					
						
							| 
									
										
										
										
											2017-01-24 04:07:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-13 13:23:44 +02:00
										 |  |  | // WMath prototypes
 | 
					
						
							|  |  |  | long random(long); | 
					
						
							| 
									
										
										
										
											2016-10-26 04:07:52 +03:00
										 |  |  | #endif /* __cplusplus */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define _min(a,b) ((a)<(b)?(a):(b))
 | 
					
						
							|  |  |  | #define _max(a,b) ((a)>(b)?(a):(b))
 | 
					
						
							| 
									
										
										
										
											2017-02-20 15:06:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-26 02:00:39 +03:00
										 |  |  | #include "pins_arduino.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | #endif /* _ESP32_CORE_ARDUINO_H_ */
 |