Skip to content

Instantly share code, notes, and snippets.

View sp5wwp's full-sized avatar

Wojciech Kaczmarski sp5wwp

View GitHub Profile
@sp5wwp
sp5wwp / weather.sh
Last active July 20, 2021 17:56
Test M17 weather script
#!/bin/sh
airport=$1 #ICAO airport code
callsign=$2 #repeater/beacon callsign
#Example usage:
#./this.sh EPMO SR5MS
#Set correct sound device in line 43!
curl -s "https://www.aviationweather.gov/metar/data?ids="{$airport}"&format=decoded&date=&hours=0" > metar
@sp5wwp
sp5wwp / ax5043.c
Last active January 16, 2022 10:55
//----------------------funcs----------------------
//write 8-bit register at "long", 16-bit address
void AX5043_WriteRegister16(uint16_t addr, uint8_t val)
{
addr |= 0xF000; //MSB set to 1 for writing, 3 further bits has to be set to 1
uint8_t msg[3]={addr>>8, addr&0xFF, val};
HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, 0);
HAL_SPI_Transmit(&hspi1, msg, 3, 100);
@sp5wwp
sp5wwp / SQ_Codec2.m
Last active January 31, 2022 07:47
Scalar Quantizer codebook generator script for Codec 2 delta LSF encoder
%-----------------------------------------------------------------------%
% Scalar Quantizer codebook generator for Codec 2
%
% Wojciech Kaczmarski, SP5WWP
% M17 Project, 28/01/2022
%-----------------------------------------------------------------------%
%consts
SPF=160; % 20ms frame at 8kHz = 160 samples per frame
%---------------------------------------------------------------------------
% This script:
% * loads wave file with the speech corpus
% * extracts LPC coefficients for every 20 ms frame (with 10 ms overlap)
% * converts LPCs to LSFs and builds a training codebook: Nx10 matrix of floats
% * calculates coarse codebook plus additional fine codebooks for split MSVQ
% * dumps codebook data to a text file (codebooks.txt)
%
% In case of convergence error - re-run the script.
%
@sp5wwp
sp5wwp / rnyq_search.m
Created May 6, 2022 14:03
Parks-McClellan method for best root-Nyquist filter search
%Clear all previous variables etc.
clear; clc;
%The excess bandwidth for our reference square root raised cosine filter is
%set to alpha (a), number of taps is _span*sps+1_
%We set the gain of this filter to 1.0 at the passband
%Next, we calculate raised cosine filter based on our reference taps
%and compute the RMS ISI value
global a;
global span;
@sp5wwp
sp5wwp / saleh.py
Created July 5, 2022 11:25
Saleh model GNU Radio python block
"""
Embedded Python Blocks:
Each time this file is saved, GRC will instantiate the first class it finds
to get ports and parameters of your block. The arguments to __init__ will
be the parameters. All of them are required to have default values!
"""
import numpy as np
from gnuradio import gr
@sp5wwp
sp5wwp / openrtx.sh
Last active August 6, 2022 14:11
MD380/Module_17 build'n'flash script
#!/bin/bash
#----MD380 & Module17----
git clone --recursive https://github.com/OpenRTX/OpenRTX.git
cd OpenRTX
#----meson setup, common for both----
meson setup --cross-file cross_arm.txt build_arm
@sp5wwp
sp5wwp / M17_BER.m
Last active October 27, 2022 10:06
clear; clc;
G1=23; %G_1 polynomial in octal notation
G2=35; %G_2 -//-
K=5; %convolutional encoder constraint length
symbols=10000; %test message length in symbols
depth=11; %bit resolution of the soft decoder
head=20; %run-up for the root-nyquist filter in symbols
span=8; %rnyq filter span
sps=10; %samples per symbol
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% root-Nyquist (M) filter design %
% Source: %
% https://my.ece.utah.edu/~farhang/Nyquist_M_r1.pdf %
% Edited by Wojciech SP5WWP to work with rcosdesign() %
% %
% parameters: %
% N: filter order (filter length = N+1) %
% M: number of samples per symbol period %
% alpha: rolloff factor (range 0 to 1) %
@sp5wwp
sp5wwp / interpolate.c
Created November 16, 2022 15:23
24->48kSa/s interpolator
/*
* M17 baseband interpolator
*
* Wojciech Kaczmarski SP5WWP
* M17 Project, Nov 2022
*/
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>