Skip to content

Commit 7e418fc

Browse files
committed
0.1.0 TinyKT0803
1 parent ff35f01 commit 7e418fc

File tree

16 files changed

+986
-0
lines changed

16 files changed

+986
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
platforms:
2+
rpipico:
3+
board: rp2040:rp2040:rpipico
4+
package: rp2040:rp2040
5+
gcc:
6+
features:
7+
defines:
8+
- ARDUINO_ARCH_RP2040
9+
warnings:
10+
flags:
11+
12+
packages:
13+
rp2040:rp2040:
14+
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
15+
16+
compile:
17+
# Choosing to run compilation tests on 2 different Arduino platforms
18+
platforms:
19+
# - uno
20+
# - due
21+
# - zero
22+
# - leonardo
23+
# - m4
24+
# - esp32
25+
# - esp8266
26+
# - mega2560
27+
# - rpipico
28+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# These are supported funding model platforms
2+
3+
github: RobTillaart
4+
custom: "https://www.paypal.me/robtillaart"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
name: Arduino-lint
3+
4+
on: [push, pull_request]
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
timeout-minutes: 5
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: arduino/arduino-lint-action@v1
12+
with:
13+
library-manager: update
14+
compliance: strict
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Arduino CI
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
runTest:
8+
runs-on: ubuntu-latest
9+
timeout-minutes: 20
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: ruby/setup-ruby@v1
14+
with:
15+
ruby-version: 2.6
16+
- run: |
17+
# sudo sysctl vm.mmap_rnd_bits=28
18+
gem install arduino_ci
19+
arduino_ci.rb
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: JSON check
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.json'
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 5
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: json-syntax-check
16+
uses: limitusus/json-syntax-check@v2
17+
with:
18+
pattern: "\\.json$"
19+

libraries/TinyKT0803/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Change Log TinyKT0803
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/).
7+
8+
9+
10+
## [0.1.0] - 2024-03-26
11+
- initial version based upon KT0803

libraries/TinyKT0803/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023-2024 Rob Tillaart
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

libraries/TinyKT0803/README.md

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
2+
[![Arduino CI](https://github.com/RobTillaart/TinyKT0803/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
3+
[![Arduino-lint](https://github.com/RobTillaart/TinyKT0803/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/TinyKT0803/actions/workflows/arduino-lint.yml)
4+
[![JSON check](https://github.com/RobTillaart/TinyKT0803/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/TinyKT0803/actions/workflows/jsoncheck.yml)
5+
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/TinyKT0803.svg)](https://github.com/RobTillaart/TinyKT0803/issues)
6+
7+
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/TinyKT0803/blob/master/LICENSE)
8+
[![GitHub release](https://img.shields.io/github/release/RobTillaart/TinyKT0803.svg?maxAge=3600)](https://github.com/RobTillaart/TinyKT0803/releases)
9+
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/TinyKT0803.svg)](https://registry.platformio.org/libraries/robtillaart/TinyKT0803)
10+
11+
12+
13+
# TinyKT0803
14+
15+
Arduino Library for KT0803 and KT0803K FM transmitter. Tiny85 edition.
16+
17+
18+
### Legal point of attention
19+
20+
In different countries there are different laws with respect to using transmitting devices
21+
and their range.
22+
Please inform yourself of the local rules and laws if and how you may or may not use a
23+
device like the KT0803 in your projects, either hobby, commercial or otherwise.
24+
25+
26+
## Description
27+
28+
This is an **EXPERIMENTAL** port to the Tiny85/45/25 processor of - https://github.com/RobTillaart/KT0803
29+
30+
The library is verified to work - See issue #2
31+
There are two points of attention:
32+
33+
- ATTiny85 needs a 500 ms delay to initialize I2C to communicate properly (assuming 1 MHz clock)
34+
- ATTiny85 needs a decoupling capacitor 100-300 nF between RESET and GND and a 10K resistor between VDC and RESET
35+
36+
Note: The KT0803 library will be leading in development and this one will follow.
37+
The interface section below is identical except for the constructor.
38+
39+
40+
## Interface
41+
42+
```cpp
43+
#include "TinyKT0803.h"
44+
```
45+
46+
#### Constructor
47+
48+
- **TinyKT0803()** constructor.
49+
- **TinyKT0803K()** constructor.
50+
- **bool begin(float freq = 90.0, bool mute = true)** initializes the library.
51+
Furthermore it checks if the deviceAddress is available on the I2C bus.
52+
Default it sets the frequency to 90 MHz and **mutes the signal**.
53+
Returns true if deviceAddress is found on the bus, false otherwise.
54+
- **bool isConnected()** test to see if deviceAddress is found on the I2C-bus.
55+
56+
57+
#### Frequency
58+
59+
- **bool setFrequency(float MHz)** converts the frequency in MHz to
60+
call **setChannel(channel)**. The value of channel is rounded off depending
61+
on the resolution of the device.
62+
Returns false if MHz is out of range or **setChannel()** fails.
63+
- **float getFrequency()** returns the current frequency in MHz, can be slightly different
64+
from the set value due to rounding math mentioned above.
65+
The return value is derived from a call to **getChannel()**
66+
- **bool setChannel(uint16_t channel)** writes the channel to broadcast on to the device.
67+
This involves two or three writes to different device registers.
68+
- **uint16_t getChannel()** reads the selected channel from the device and
69+
returns it.
70+
71+
72+
#### PGA
73+
74+
Read Datasheet.
75+
76+
The KT0803K has a **PGA_LSB** (2 bits) setting, which allows setting the gain
77+
with single (1) dB steps. This is not yet implemented in the library.
78+
79+
- **bool setPGA(uint8_t pga)** sets gain according to table below.
80+
Returns false if pga is out of range (0..7).
81+
- **uint8_t getPGA()** returns 0..7, default 0.
82+
83+
84+
| PGA | gain | notes |
85+
|:-----:|:-------:|:-------:|
86+
| 111 | 12dB |
87+
| 110 | 8dB |
88+
| 101 | 4dB |
89+
| 100 | 0dB |
90+
| 000 | 0dB | default
91+
| 001 | -4dB |
92+
| 010 | -8dB |
93+
| 011 | -12dB |
94+
95+
96+
#### RFGain
97+
98+
Read Datasheet.
99+
100+
Note: the RFGain value (4 bits) is distributed over three registers.
101+
PA_BIAS (register 0x05) is only supported in the KT0803K device.
102+
It is not yet supported in the library.
103+
104+
- **bool setRFGain(uint8_t rfgain)** sets rfgain according to table below.
105+
Returns false if rfgain is out of range (0..15).
106+
- **uint8_t getRFgain()** returns 0..15, default 15.
107+
108+
109+
| RFGAIN | RFout | PA_BIAS = 1 | notes |
110+
|:--------:|:------------:|:------------:|:-------:|
111+
| 0000 | 95.5 dBuV | - |
112+
| 0001 | 96.5 dBuV | - |
113+
| 0010 | 97.5 dBuV | - |
114+
| 0011 | 98.2 dBuV | - |
115+
| 0100 | 98.9 dBuV | - |
116+
| 0101 | 100.0 dBuV | - |
117+
| 0110 | 101.5 dBuV | - |
118+
| 0111 | 102.8 dBuV | - |
119+
| 1000 | 105.1 dBuV | 107.2 dBuV |
120+
| 1001 | 105.6 dBuV | 108.0 dBuV |
121+
| 1010 | 106.2 dBuV | 108.7 dBuV |
122+
| 1011 | 106.5 dBuV | 109.5 dBuV |
123+
| 1100 | 107.0 dBuV | 110.3 dBuV |
124+
| 1101 | 107.4 dBuV | 111.0 dBuV |
125+
| 1110 | 107.7 dBuV | 111.7 dBuV |
126+
| 1111 | 108.0 dBuV | 112.5 dBuV | default
127+
128+
129+
#### Region selection
130+
131+
Read datasheet for details.
132+
133+
Note that not all frequencies are allowed in all regions / countries!
134+
135+
The first four are convenience wrappers for **setPHTCNST()**
136+
If some region is missing please let me know the details and I can add
137+
a wrapper for it.
138+
139+
- **void setEurope()**
140+
- **void setAustralia()**
141+
- **void setUSA()**
142+
- **void setJapan()**
143+
- **bool setPHTCNST(bool on)** See table below.
144+
- **bool getPHTCNST()** returns set value.
145+
146+
| PHTCNST | time | Region |
147+
|:---------:|:-------:|:--------:|
148+
| 0 | 75 μs | USA, Japan, (default)
149+
| 1 | 50 μs | Europe, Australia
150+
151+
152+
#### PilotToneAdjust
153+
154+
Read datasheet.
155+
156+
- **bool setPilotToneAdjust(uint8_t mode)** HIGH = 1 LOW = 0
157+
- **uint8_t getPilotToneAdjust()**
158+
159+
160+
#### Mute
161+
162+
Default the device is not muted, but **begin()** will default mute it.
163+
See interface section above.
164+
165+
- **bool setMute(bool mute)** enables or disables the transmitting
166+
by muting the signal.
167+
- **bool getMute()** returns the current state of muting.
168+
169+
170+
## Preference channels
171+
172+
The device and library do not implement the persistant store of user
173+
selectable preferences (frequencies or channels).
174+
This can be implemented by the user in EEPROM or another persistent medium.
175+
176+
Think of a class that holds an array of channels and optional descriptions.
177+
A minimal hardcoded preset sketch is in the examples.
178+
179+
180+
## Derived classes
181+
182+
A derived class TinyKT0803K class is created, with some extended
183+
functions.
184+
185+
The KT0803L will work as it is backwards compatible with KT0803K.
186+
It has far more registers in use than the KT0803/K.
187+
188+
The KT0803M is identical to the KT0803K (no new registers), so
189+
a derived class is straightforward.
190+
191+
192+
## Interface KT0803K
193+
194+
(not tested), check datasheet.
195+
196+
#### Mono Stereo
197+
198+
- **bool setMono()** idem
199+
- **bool setStereo()** idem
200+
- **bool isStereo()** idem
201+
202+
#### Bass
203+
204+
- **bool setBass(uint8_t bass); // 0..3 = 0, 5, 11, 17 dB
205+
- **uint8_t getBass()** idem
206+
207+
#### Misc
208+
209+
- **bool powerOK()** idem
210+
- **bool silenceDetected()** idem
211+
212+
213+
## Future
214+
215+
See - https://github.com/RobTillaart/KT0803
216+
217+
218+
## Support
219+
220+
If you appreciate my libraries, you can support the development and maintenance.
221+
Improve the quality of the libraries by providing issues and Pull Requests, or
222+
donate through PayPal or GitHub sponsors.
223+
224+
Thank you,
225+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// FILE: KT0803_minimal.ino
3+
// AUTHOR: Rob Tillaart
4+
// PURPOSE: minimal demo
5+
// URL: https://github.com/RobTillaart/TinyKT0803
6+
7+
8+
#include "TinyKT0803.h"
9+
10+
11+
TinyKT0803 FM_SEND;
12+
13+
14+
void setup()
15+
{
16+
// Tiny only supports SWSerial
17+
// Serial.begin(115200);
18+
// while(!Serial);
19+
20+
TinyWireM.begin();
21+
// give I2C time to initialize
22+
delay(500);
23+
24+
FM_SEND.begin();
25+
FM_SEND.setChannel(2000); // * 0.05 = 100.00 MHz
26+
FM_SEND.setMute(false);
27+
}
28+
29+
void loop()
30+
{
31+
}
32+
33+
34+
// -- END OF FILE --

0 commit comments

Comments
 (0)