4 Commits

Author SHA1 Message Date
Casey Halverson
4f7db1d561 revised lib properties 2017-05-09 13:43:19 -04:00
Casey Halverson
d8d97789d7 Fixed critical define
Fixed a critical define
2017-05-09 13:40:54 -04:00
spaceneedle
d232424bb4 Library properties so Arduino knows to update
Incremented version
2017-05-08 19:23:14 -05:00
spaceneedle
6538ae7db3 Long awaited fix to CTCSS detection and encoding
Two extremely powerful functions:

setCtcssEncoder(float freq)
setCtcssDecoder(float freq)

Yes, that does mean *any* frequency, including non-standard CTCSS tones.

Enjoy.

-Casey
2017-05-08 19:21:18 -05:00
3 changed files with 44 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
name=HamShield
version=1.0.3
version=1.0.5
author=Morgan Redfield <morgan@enhancedradio.com>, Casey Halverson <casey@enhancedradio.com>
maintainer=Morgan Redfield <morgan@enhancedradio.com>
sentence=A library for use with HamShield by Enhanced Radio Devices.

View File

@@ -1,4 +1,4 @@
// HamShield library collection
// HamShield library collection
// Based on Programming Manual rev. 2.0, 5/19/2011 (RM-MPU-6000A-00)
// 11/22/2013 by Morgan Redfield <redfieldm@gmail.com>
// 04/26/2015 various changes Casey Halverson <spaceneedle@gmail.com>
@@ -105,11 +105,11 @@ const uint16_t asciiMorseProgmem[] PROGMEM = {
};
#endif // MORSE_TABLE_PROGMEM
/* 2200 Hz */
/* 2200 Hz -- This lookup table should be deprecated */
const unsigned char AFSK_mark[] PROGMEM = { 154, 249, 91, 11, 205, 216, 25, 68, 251, 146, 0, 147, 250, 68, 24, 218, 203, 13, 88, 254, 128, 1, 167, 242, 52, 37, 231, 186, 5, 108, 255, 108, 5, 186, 231, 37, 52, 242, 167, 1, 128, 254, 88, 13, 203, 218, 24, 69, 250, 147, 0, 147, 250, 69, 24, 218, 203, 13, 88, 255, 127, 2, 165, 245, 48 };
/* 1200 Hz */
/* 1200 Hz -- This lookup table should be deprecated */
const unsigned char AFSK_space[] PROGMEM = { 140, 228, 250, 166, 53, 0, 53, 166, 249, 230, 128, 24, 7, 88, 203, 255, 203, 88, 7, 24, 128, 230, 249, 167, 53, 0, 53, 167, 249, 230, 128, 24, 6, 88, 202, 255, 202, 88, 6, 24, 127, 231, 249, 167, 52, 0, 52, 167, 248, 231, 127, 25, 6, 89, 202, 255, 202, 89, 6, 25, 127, 231, 248, 167, 53, 0, 54, 165, 251, 227, 133, 14};
@@ -672,6 +672,35 @@ uint16_t HamShield::getPABiasVoltage(){
}
*/
// Subaudio settings
// recommended function for placing CTCSS tone on channel -- schedule remainder for deprecation
// ctcss freq encoder
void HamShield::setCtcssEncoder(float freq) {
int dfreq = freq * 100; // Convert float into whole number (ctcss freq * 100)
setCtcssFreq(dfreq); // program CTCSS frequency buffer
HSwriteBitW(devAddr, A1846S_CTCSS_FREQ_PRG, 10, 1); // program CTCSS frequency buffer into CTCSS encoder (step 1)
HSwriteBitW(devAddr, A1846S_CTCSS_FREQ_PRG, 9, 1); // program CTCSS frequency buffer into CTCSS encoder (step 2)
}
// recommended function for detecting (and requiring) CTCSS to be on channel before audio is unmuted -- schedule remainder for deprecation
// ctcss freq decoder
void HamShield::setCtcssDecoder(float freq) {
int dfreq = freq * 100; // Convert float into whole number (ctcss freq * 100)
setCtcssFreq(dfreq); // program CTCSS frequency buffer
HSwriteBitW(devAddr, A1846S_CTCSS_FREQ_PRG, 10, 1); // program CTCSS frequency buffer into CTCSS encoder (step 1)
HSwriteBitW(devAddr, A1846S_CTCSS_FREQ_PRG, 9, 1); // program CTCSS frequency buffer into CTCSS encoder (step 2)
}
// TX and RX code
/*
Set code mode:

View File

@@ -2,7 +2,7 @@
// Based on Programming Manual rev. 2.0, 5/19/2011 (RM-MPU-6000A-00)
// 11/22/2013 by Morgan Redfield <redfieldm@gmail.com>
// 04/26/2015 various changes Casey Halverson <spaceneedle@gmail.com>
// 05/08/2017 CTCSS code added
#ifndef _HAMSHIELD_H_
@@ -47,6 +47,7 @@
#define A1846S_CTCSS_FREQ_REG 0x4A // ctcss_freq<15:0>
#define A1846S_CDCSS_CODE_HI_REG 0x4B // cdcss_code<23:16>
#define A1846S_CDCSS_CODE_LO_REG 0x4C // cdccs_code<15:0>
#define A1846S_CTCSS_FREQ_PRG 0x4e // copies CTCSS value from A1846S_CTCSS_FREQ_REG into CTCSS encoder
#define A1846S_SQ_OUT_SEL_REG 0x54 // see sq
#define A1846S_EMPH_FILTER_REG 0x58
#define A1846S_FLAG_REG 0x5C // holds flags for different statuses
@@ -311,6 +312,15 @@ class HamShield {
// Subaudio settings
// Recommended user function for setting and receiving CTCSS does
// TODO: set others to private and/or deprecate
void setCtcssEncoder(float freq); // generate sub audio tone on channel when transmitting
void setCtcssDecoder(float freq); // unmute audio on tone present when receiving channel
// Ctcss/cdcss mode sel
// x00=disable,
// 001=inner ctcss en,