MySensors Library & Examples
2.3.2-62-ge298769
hal
architecture
Linux
drivers
core
Arduino.h
1
/*
2
* The MySensors Arduino library handles the wireless radio link and protocol
3
* between your home built sensors/actuators and HA controller of choice.
4
* The sensors forms a self healing radio network with optional repeaters. Each
5
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
6
* network topology allowing messages to be routed to nodes.
7
*
8
* Created by Henrik Ekblad <
[email protected]
>
9
* Copyright (C) 2013-2022 Sensnology AB
10
* Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
11
*
12
* Documentation: http://www.mysensors.org
13
* Support Forum: http://forum.mysensors.org
14
*
15
* This program is free software; you can redistribute it and/or
16
* modify it under the terms of the GNU General Public License
17
* version 2 as published by the Free Software Foundation.
18
*/
19
20
#ifndef Arduino_h
21
#define Arduino_h
22
23
#include <stdlib.h>
24
#include <stdint.h>
25
#include <stdbool.h>
26
#include <stddef.h>
27
#include <stdarg.h>
28
#include <stdio.h>
29
#include <string.h>
30
#include <math.h>
31
#include <string>
32
#include <algorithm>
33
#include "stdlib_noniso.h"
34
35
#ifdef LINUX_ARCH_RASPBERRYPI
36
#include "RPi.h"
37
#define pinMode(pin, direction) RPi.pinMode(pin, direction)
38
#define digitalWrite(pin, value) RPi.digitalWrite(pin, value)
39
#define digitalRead(pin) RPi.digitalRead(pin)
40
#define digitalPinToInterrupt(pin) RPi.digitalPinToInterrupt(pin)
41
#else
42
#include "GPIO.h"
43
#define pinMode(pin, direction) GPIO.pinMode(pin, direction)
44
#define digitalWrite(pin, value) GPIO.digitalWrite(pin, value)
45
#define digitalRead(pin) GPIO.digitalRead(pin)
46
#define digitalPinToInterrupt(pin) GPIO.digitalPinToInterrupt(pin)
47
#endif
48
49
#include "interrupt.h"
50
51
#undef PSTR
52
#define PSTR(x) (x)
53
#undef F
54
#define F(x) (x)
55
#define PROGMEM __attribute__(( section(".progmem.data") ))
56
#define vsnprintf_P(...) vsnprintf( __VA_ARGS__ )
57
#define snprintf_P(...) snprintf( __VA_ARGS__ )
58
#define memcpy_P memcpy
59
#define pgm_read_byte(p) (*(p))
60
#define pgm_read_dword(p) (*(p))
61
#define pgm_read_byte_near(p) (*(p))
62
63
#define PI 3.1415926535897932384626433832795
64
#define HALF_PI 1.5707963267948966192313216916398
65
#define TWO_PI 6.283185307179586476925286766559
66
#define DEG_TO_RAD 0.017453292519943295769236907684886
67
#define RAD_TO_DEG 57.295779513082320876798154814105
68
#define EULER 2.718281828459045235360287471352
69
70
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
71
#define radians(deg) ((deg)*DEG_TO_RAD)
72
#define degrees(rad) ((rad)*RAD_TO_DEG)
73
#define sq(x) ((x)*(x))
74
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
75
76
#define lowByte(w) ((uint8_t) ((w) & 0xff))
77
#define highByte(w) ((uint8_t) ((w) >> 8))
78
79
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
80
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
81
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
82
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
83
84
#define bit(b) (1UL << (b))
85
86
#define GET_MACRO(_0, _1, _2, NAME, ...) NAME
87
#define random(...) GET_MACRO(_0, ##__VA_ARGS__, randMinMax, randMax, rand)(__VA_ARGS__)
88
89
#ifndef delay
90
#define delay _delay_milliseconds
91
#endif
92
93
#ifndef delayMicroseconds
94
#define delayMicroseconds _delay_microseconds
95
#endif
96
97
using
std::string;
98
using
std::min
;
99
using
std::max
;
100
using
std::abs;
101
102
typedef
uint8_t byte;
103
typedef
string
String;
104
typedef
char
__FlashStringHelper;
105
106
void
yield(
void
);
107
unsigned
long
millis(
void
);
108
unsigned
long
micros(
void
);
109
void
_delay_milliseconds(
unsigned
int
millis);
110
void
_delay_microseconds(
unsigned
int
micro);
111
void
randomSeed(
unsigned
long
seed);
112
long
randMax(
long
howbig);
113
long
randMinMax(
long
howsmall,
long
howbig);
114
115
#endif
min
#define min(a, b)
min
Definition:
MySensors.h:100
max
#define max(a, b)
max
Definition:
MySensors.h:104
Copyright (C) 2013-2019 Sensnology AB. Generated by
doxygen
1.8.17