Skip to content

Commit

Permalink
Feature/call tone 2 (#3)
Browse files Browse the repository at this point in the history
* added 1750Hz call-tone option
* bumped version to 0.2.0
* Updated README.md
  • Loading branch information
zarath authored Sep 19, 2023
1 parent 83d8865 commit 77f7e28
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 79 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,29 @@ jobs:
- name: Cache Rust packages
uses: actions/cache@v3
with:
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
key: ${{ runner.os }}-build-${{ hashFiles('Cargo.lock') }}
path: |
~/.cargo
- name: Build
run: cargo build --verbose --release
- name: Install elf2uf2-rs
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev
sudo apt-get install -y libudev-dev
cargo install elf2uf2-rs
- name: Generate uf2 file
run: elf2uf2-rs -v target/thumbv6m-none-eabi/release/subtone
- name: Build
run: |
cargo build --verbose --release --features call-tone
mv target/thumbv6m-none-eabi/release/subtone target/thumbv6m-none-eabi/release/subtone-calltone
cargo build --verbose --release
- name: Generate uf2 files
run: |
elf2uf2-rs -v target/thumbv6m-none-eabi/release/subtone-calltone
elf2uf2-rs -v target/thumbv6m-none-eabi/release/subtone
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: firmware-binaries
path: |
target/thumbv6m-none-eabi/release/subtone
target/thumbv6m-none-eabi/release/subtone.uf2
target/thumbv6m-none-eabi/release/subtone-calltone
target/thumbv6m-none-eabi/release/subtone-calltone.uf2
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "subtone"
version = "0.1.0"
version = "0.2.0"
license = "MIT"
resolver = "2"

Expand Down Expand Up @@ -100,3 +100,7 @@ debug-assertions = false
incremental = false
lto = 'fat'
opt-level = 's'

[features]
default = []
call-tone = []
3 changes: 3 additions & 0 deletions Oscilloscope.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ An embedded rust project to generate
[CTCSS](https://en.wikipedia.org/wiki/Continuous_Tone-Coded_Squelch_System)-Tones
via [PDM](https://en.wikipedia.org/wiki/Pulse-density_modulation) on a cheap
[RP2040](https://en.wikipedia.org/wiki/RP2040) board.
Due to PDM (aka Delta-Modulation) a simple rc-filter is sufficient for
DA-conversation.
(eg. 100Ω/3.3µF if not using 1750Hz option or 100Ω/470nF otherwise)
Prefer tantalum caps for better switching supression.

![prototype](Prototype.jpg "Prototype attached to 23cm tranciever")

Waveform Example
----------------

![waveform](Oscilloscope.png "Waveform example on oscilloscope")

Schematics
----------

Expand All @@ -21,4 +30,6 @@ Usage

* Use rotary encoder to select wanted frequency.
* Press button short for on/off toggling.
* Press long to store current setting.
* Press long to store current setting.
* With 1750Hz call-tone option on this frequency short button push just emmits
a one second sine pulse and is quiet otherwise.
8 changes: 5 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn bmp2bitstr(s: &str) -> String {

fn fontset(p: PathBuf) {
let sources = [
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "space", "dash", "dot", "off", "mem",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "space", "tone", "dot", "off", "mem",
];
let mut bitmaps = "".to_string();
for filename in sources {
Expand Down Expand Up @@ -139,22 +139,24 @@ fn main() {

let pdm = pdm_table(1 << PDM_BITS, i_sine);
// 8 cycles in one table for higher frequencies
let pdm_8 = pdm_table(1 << PDM_BITS, |i, s| i_sine(i * 8, s));
let pdm_8 = pdm_table(1 << PDM_BITS, |i, s| i_sine(i << 3, s));
let clk_div_1hz = 125_000_000.0 / 2.0f32.powi(PDM_BITS as i32);
write(
out.join("pdm_table.rs"),
format!(
"\
const PDM_TABLE: [u32; {}] = {:?};\n\
#[allow(dead_code)]\n\
const PDM8_TABLE: [u32; {}] = {:?};\n\
const CLK_DIV_1HZ: f32 = {};\n\
#[allow(dead_code)]\n\
const CLK_DIV_8HZ: f32 = {};\n\
",
pdm.len(),
pdm,
pdm_8.len(),
pdm_8,
clk_div_1hz,
clk_div_1hz * 8.0,
),
)
.unwrap();
Expand Down
Binary file added font/tone.bmp
Binary file not shown.
Loading

0 comments on commit 77f7e28

Please sign in to comment.