-
Notifications
You must be signed in to change notification settings - Fork 0
/
TinyRFModulator.h
198 lines (162 loc) · 8.18 KB
/
TinyRFModulator.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
Driver for I2C MBS74T1AEF controlled RF-Modulator
Easy to use and very straight forward class to control RF-modulator modules
via I2C with build-in MBS74T1AEF controller, such as:
- Shenzhen Tena TNF0170U722
- Samsung RMUP74055AD
CopyLight (c) 2019 codebeat, Erwin Haantjes, http://codebeat.nl
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copylight notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
ATTENTION:
---------
THIS SOFTWARE IS PROVIDED BY THE COPYLIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
VERSION history:
- Date : 04-sep-2019 (v1.00)
updated : 18-sep-2018
- Optimize some code to make it compile smaller
FEATURES:
---------
o Converts composite video and audio to a RF (aerial) signal;
o Configurable I2C address;
o Set channel/frequency (48 Channels - 471 to 855 Mhz UHF)
o Set sound carrier (5.5 to 6.5 Mhz);
o Set test-mode (test signal with black background and two white
stripes and 1Khz test-tone);
o begin() (turn on) and end() (turn off) function;
o Easy next and previous set functions with rollover protection;
o Get status (not working).
USAGE EXAMPLE:
--------------
rfmod.begin();
rfmod.setChannel(72);
rfmod.end();
PINOUT:
-------
I2C RF-Modulator, I2C address 0x65
Shenzhen Tena TNF0170U722:
LEFT SIDE VIEW FRONT VIEW
____________________ ____________________
| _ _ |____ |IN ___ ___ OUT|
|____| |____| |_____| | |__ / \__ / \___|
| | | PINS ON | | (@) | | o | |
| _______________ |____| THIS SIDE | \___/ \___/ |
| | o o o o o o | | ---------|___________________|
-----|-|-|-|-|-|----| |___________________|
| | | | | |
| | | | | |_______ +5V
| | | | |_________ VIDEO-IN -------[TRIMPOT 10K]--| VIDEO-IN
| | | |___________ AUDIO-IN -------[TRIMPOT 10K]--| AUDIO-IN
| | |_____________ B+ 5V |-----------------------|
| |_______________ SDA ____________|_o SDA ANY ARDUINO |
|__________________SCL ______________o SCL |
|_______________________|
NOTICE:
o Be aware that competitor Samsung RMUP74055AD (or equavalent) have another order
pinout comparing to the Shenzhen Tena TNF0170U722. Refer to datasheet for
more details;
o Pull-up resistor on both I2C lines ----[ 4K7 ]---- +5V required. Without these
it will not function!
o [TRIMPOT 10K] is an adjustment potentiometer, trimpot for input. These pots needs
to set first (calibration) to be able to get decent quality video and audio.
However, the audio trimpot is optional (didn't notice any distortion);
o Older TV equipment (analog tuning) can handle only one of the lower frequencies
(5.5 or lower). Using a non supported frequency will result in poor picture quality
and audio quality (noise or no audio);
o TV equipment with a digital tuner (and auto-scan) can handle almost all frequencies
(highest = best quality). However, once the channel is discovered by TV equipment,
changing the sound carrier will result in poor picture quality and sound quality.
In order to change the sound carrier, you need to set the sound carrier first on
the device and after this perform an auto-scan on TV equipment.
o At default the sound carrier is set to 5.5Mhz to cover most TV equipment and
to provide maximum compatibility.
SUPPORT
-------
Love this software? Consider a donation (in future),
grateful for any kind of support.
codebeat channels (maybe work in progress):
- http://www.codebeat.nl ; Main website
- http://blog.codebeat.nl ; Blog website (projects and more)
- http://youtube.codebeat.nl ; YouTube channel (shortcut)
- http://patreon.codebeat.nl ; Patreon support channel (shortcut)
- http://github.codebeat.nl ; Github (projects)
*/
#ifndef TINYRFMODULATORLIB_H
#define TINYRFMODULATORLIB_H
#define TRFM_DEF_I2C_ADDRESS 0x65 // Default slave address
// Sound Carrier Ids for setSoundCarrierId() function
#define TRFM_SOUND_CARRIER_MIN 0x00
#define TRFM_SOUND_CARRIER_4_5MHZ 0x00
#define TRFM_SOUND_CARRIER_5_5MHZ 0x01
#define TRFM_SOUND_CARRIER_6_0MHZ 0x02
#define TRFM_SOUND_CARRIER_6_5MHZ 0x03
#define TRFM_SOUND_CARRIER_MAX 0x03
#define TRFM_SOUND_CARRIER_MULTIPLIER 0x08
#define TRFM_SOUND_CARRIER_CURRENT 0x40
#define TRFM_SOUND_CARRIER_NEXT 0x41
#define TRFM_SOUND_CARRIER_PREV 0x42
#define TRFM_STATUS_OFF 0x00
#define TRFM_STATUS_ON 0x01
#define TRFM_STATUS_ERROR -0x01
#define TRFM_CHANNEL_MIN 21
#define TRFM_CHANNEL_MAX 69
#define TRFM_CHANNEL_CURRENT 0x80
#define TRFM_CHANNEL_NEXT 0x81
#define TRFM_CHANNEL_PREV 0x82
// ----------------------------------------------------------------------------
class MBS74T1AEFDevice
{
private:
uint8_t addr = TRFM_DEF_I2C_ADDRESS;
uint8_t channel = TRFM_CHANNEL_MIN;
uint8_t soundCarrierId = TRFM_SOUND_CARRIER_5_5MHZ;
bool enabled = false;
uint8_t getFreqBytes( uint8_t &fm,
uint8_t &fl,
uint8_t iChannel = TRFM_CHANNEL_CURRENT,
bool testMode = false
);
public:
MBS74T1AEFDevice();
// getters (with self explaining function names)
uint8_t getChannel( uint8_t iChannel = TRFM_CHANNEL_CURRENT );
uint8_t getSoundCarrierId( int8_t iSoundCarrierId = TRFM_SOUND_CARRIER_CURRENT );
int8_t getStatus(); // <- Not working
uint16_t getChannelFrequencyBits( uint8_t iChannel = TRFM_CHANNEL_CURRENT );
uint32_t getChannelFrequency( uint8_t iChannel = TRFM_CHANNEL_CURRENT ); // In kHz
// setters (with self explaining function names)
void setI2CAddress( uint8_t iAddr );
void setChannel(uint8_t iChannel, bool testMode = false );
void setNextChannel( bool testMode = false );
void setPrevChannel( bool testMode = false );
void setSoundCarrierId(uint8_t iSoundCarrierId = TRFM_SOUND_CARRIER_6_5MHZ );
void setNextSoundCarrierId();
void setPrevSoundCarrierId();
void setTestMode( bool testMode = true );
void setWord( uint8_t v1, uint8_t v2 );
void beginTransmission();
void endTransmission();
// default functions
void begin( uint8_t iChannel = TRFM_CHANNEL_CURRENT,
int8_t iSoundCarrierId = TRFM_SOUND_CARRIER_CURRENT,
bool bTestMode = false
);
void reset( bool bTestMode = false );
void end();
};
extern MBS74T1AEFDevice rfmod;
// ----------------------------------------------------------------------------
#endif