forked from 1000io/OregonPi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RCSwitch.h
92 lines (69 loc) · 2.47 KB
/
RCSwitch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
RCSwitch - Arduino libary for remote control outlet switches
Copyright (c) 2011 Suat �zg�r. All right reserved.
* Largely modified and split by disk91 - http://www.disk91.com
Contributors:
- Andre Koehler / info(at)tomate-online(dot)de
- Gordeev Andrey Vladimirovich / gordeev(at)openpyro(dot)com
Project home: http://code.google.com/p/rc-switch/
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 _RCSwitch_h
#define _RCSwitch_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include <stdint.h>
// -- coment by disk91 #define NULL 0
#define CHANGE 1
#ifdef __cplusplus
extern "C"{
#endif
typedef uint8_t boolean;
typedef uint8_t byte;
#if !defined(NULL)
#endif
#ifdef __cplusplus
}
#endif
#endif
// Number of maximum High/Low changes per packet.
// We can handle up to (unsigned long) => 32 bit * 2 H/L changes per bit + 2 for sync
#define RCSWITCH_MAX_CHANGES 67
// Taille max d'un message de type Oregon Scientific
#define RCSWITCH_MAX_MESS_SIZE 128
class RCSwitch {
public:
RCSwitch(int rxpin,int txpin);
void sendTriState(char* Code);
void send(unsigned long Code, unsigned int length);
void send(char* Code);
void enableReceive(int interrupt);
void enableReceive();
void disableReceive();
void enableTransmit(int nTransmitterPin);
void disableTransmit();
static bool OokAvailable();
static bool getOokCode(char * _dest);
static void OokResetAvailable();
void transmit(int nHighPulses, int nLowPulses);
private:
static void handleInterrupt(uint gpio, uint32_t events);
int nReceiverInterrupt;
int nTransmitterPin;
static char OokReceivedCode[RCSWITCH_MAX_MESS_SIZE];
static bool OokAvailableCode;
};
#endif