]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
New Protocol CW changes, and other things
authorc vw <dl1ycf@darc.de>
Mon, 29 Jul 2019 18:10:35 +0000 (20:10 +0200)
committerc vw <dl1ycf@darc.de>
Mon, 29 Jul 2019 18:10:35 +0000 (20:10 +0200)
16 files changed:
Makefile
Makefile.mac
cw_menu.c
cwramp.c
ext.c
iambic.c
new_menu.c
new_protocol.c
new_protocol.h
old_protocol.c
radio.c
radio.h
rigctl.c
transmitter.c
vfo.c
vfo_menu.c

index 8bf0d1438b2bdc2a9a4c47a1bceebba2efe96ecb..a6e660fa3f9338bfc1e6f751d83c9f66fedd9c38 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -258,7 +258,6 @@ agc_menu.c \
 vox_menu.c \
 fft_menu.c \
 diversity_menu.c \
-freqent_menu.c \
 tx_menu.c \
 vfo_menu.c \
 test_menu.c \
@@ -331,7 +330,6 @@ agc_menu.h \
 vox_menu.h \
 fft_menu.h \
 diversity_menu.h \
-freqent_menu.h \
 tx_menu.h \
 vfo_menu.h \
 test_menu.h \
@@ -400,7 +398,6 @@ agc_menu.o \
 vox_menu.o \
 fft_menu.o \
 diversity_menu.o \
-freqent_menu.o \
 tx_menu.o \
 vfo_menu.o \
 test_menu.o \
index 0095644330008beaa36c6408b520e43ab55098ec..9559b6712f12fc07553ce117f754ef71c1235610 100644 (file)
@@ -25,7 +25,7 @@ PURESIGNAL_INCLUDE=PURESIGNAL
 #SX1509_INCLUDE=sx1509
 
 # uncomment the line to below include support local CW keyer
-#LOCALCW_INCLUDE=LOCALCW
+LOCALCW_INCLUDE=LOCALCW
 
 # uncomment the line below to include support for STEMlab discovery (WITHOUT AVAHI)
 STEMLAB_DISCOVERY=STEMLAB_DISCOVERY_NOAVAHI
@@ -244,7 +244,6 @@ agc_menu.c \
 vox_menu.c \
 fft_menu.c \
 diversity_menu.c \
-freqent_menu.c \
 tx_menu.c \
 vfo_menu.c \
 test_menu.c \
@@ -317,7 +316,6 @@ agc_menu.h \
 vox_menu.h \
 fft_menu.h \
 diversity_menu.h \
-freqent_menu.h \
 tx_menu.h \
 vfo_menu.h \
 test_menu.h \
@@ -386,7 +384,6 @@ agc_menu.o \
 vox_menu.o \
 fft_menu.o \
 diversity_menu.o \
-freqent_menu.o \
 tx_menu.o \
 vfo_menu.o \
 test_menu.o \
index cdd82276a9561fdc9895d3de6f880cce9adeb37e..4849673d704be4f42e8bd4eddd1cc9164ca737d2 100644 (file)
--- a/cw_menu.c
+++ b/cw_menu.c
@@ -44,6 +44,7 @@ static GtkWidget *dialog=NULL;
 void cw_changed() {
 // inform the local keyer about CW parameter changes
 // (only if LOCALCW is active).
+// NewProtocol: rely on periodically sent HighPrio packets
 #ifdef LOCALCW
   keyer_update();
 #endif
index dd75afed27ac7539fb80a0bef04e8ac1be872821..910d6c2064e643a297d5a4ec45a4032b24ce0b74 100644 (file)
--- a/cwramp.c
+++ b/cwramp.c
  * (more than we need for double) and copy/pasted into this file.
  *
  *
+ * For the new protocol, we must generate four intermediate values for each
+ * of the ramp indices 1 ... 199, this generate a ramp of length 798
+ * This is contained in cwramp192[0..803]
+ *
  * MEASURING SPECTRAL POLLUTION
  * ============================
  *
@@ -65,7 +69,7 @@
  * ramp does far better if more than 500 Hz off.
  */
 
-double  cwramp[201] = {
+double  cwramp48[201] = {
 0.0,
 9.01187795859706156177643839E-7,
 2.194323834526231706516646770E-6,
@@ -268,3 +272,808 @@ double  cwramp[201] = {
 0.9999990988122041402938438223562,
 1.0000000000000000000000000000000};
 
+double cwramp192[804]={
+0.0000000000000000000000000000000,
+0.0000000000000000000000000000000,
+0.0000000000000000000000000000000,
+0.0000000000000000000000000000000,
+2.1087113317671381833565174840727e-7,
+4.2789435824354591536843938904892e-7,
+6.5723292732737739707876232636477e-7,
+9.0507241299505540454967362246168e-7,
+1.1776318683873409461578071419866e-6,
+1.4811749872436350930711561582232e-6,
+1.8220212637711159397580637845994e-6,
+2.2065571523033918626180464813166e-6,
+2.6412472266831312725563990326518e-6,
+3.1326453392903740711786481063320e-6,
+3.6874057796233759566280749901136e-6,
+4.3122944323218959000110142906577e-6,
+5.0141999345038235797612466731302e-6,
+5.8001448322649730999098419262305e-6,
+6.6772967361687594274590073599604e-6,
+7.6529794755273438687708399508802e-6,
+8.7346842512487054640629609369454e-6,
+9.9300807869949889924482169389513e-6,
+0.000011247028478366421593366102069835,
+0.000012693587539792104720261483939737,
+0.000014278030148774103779495710188096,
+0.000016008851587094503518548517704662,
+0.000017894781378556503756968968656315,
+0.000019944794422790229723431919374140,
+0.000022168122124611757951822496605471,
+0.000024574263518379947812869834323379,
+0.000027172996386750057242246564425362,
+0.000029974388373175847486624418669545,
+0.000032988808087462985605180898968806,
+0.000036226936203626076352906919540469,
+0.000039699776549249639662716612034260,
+0.000043418667185499840348716494760728,
+0.000047395291476878818341452159746663,
+0.000051641689149757107532048360625462,
+0.000056170267338661917236323837748704,
+0.000060993811619240031747438602548665,
+0.000066125497026753811014551418635115,
+0.000071578899058907300953611292113475,
+0.000077368004661736838219673758849912,
+0.000083507223197236815535212897563477,
+0.000090011397391326515060210710326884,
+0.000096895814260698175053180577872731,
+0.00010417621601701978647844709328171,
+0.00011186881094689857952236177374028,
+0.00011999028426594281439786999256365,
+0.00012855780894519039646239417481136,
+0.00013758905650810305353988143935181,
+0.00014710220779625440524791789805209,
+0.00015711596370176928270084651587499,
+0.00016764955586450018555672231545969,
+0.00017872275733185485607621976399342,
+0.00019035589317911667140949755832244,
+0.00020256985108802697109203568540354,
+0.00021538609188132561266450922356515,
+0.00022882666001087305092587985441660,
+0.00024291419399690413256949407569141,
+0.00025767193681589065527681180219285,
+0.00027312374623441662659705707925054,
+0.00028929410508639714133029764951898,
+0.00030620813149089894517997946293024,
+0.00032389158900774813594423190850400,
+0.00034237089672803814049491448304436,
+0.00036167313929657916545132242335113,
+0.00038182607686325882112797866907961,
+0.00040285815496021263144747840314025,
+0.00042479851430163273652629671164358,
+0.00044767700050297333902571479449505,
+0.00047152417371624240952250881680117,
+0.00049637131817800091940824694157901,
+0.00052225045166662348134140363754389,
+0.00054919433486530781603191463247018,
+0.00057723648062725499887508039682177,
+0.00060641116313937803912918334587862,
+0.00063675342698083307607724031218746,
+0.00066829909607260540868027441678641,
+0.00070108478251432177494744883522732,
+0.00073514789530440083147930487114852,
+0.00077052664893959571873226387502073,
+0.00080726007188992599929419378060942,
+0.00084538801494494119003630102932854,
+0.00088495115942720463895040890574047,
+0.00092599102526883468763312109132561,
+0.00096854997894688997384120352378061,
+0.0010126712412733374276350188898640,
+0.0010583988950352950608422386994228,
+0.0011057778924811971035363698983517,
+0.0011548540626484864626460091243106,
+0.0012056741185283989254492021904137,
+0.0012582856640633650623250109783958,
+0.0013127372009725194554564810852078,
+0.0013690781354007727488530357518393,
+0.0014273587843868701346154418264112,
+0.0014876303821458303141751217953776,
+0.0015499450861611317534777359575917,
+0.0016143559830819882386902029072980,
+0.0016809170944210333836602283081663,
+0.0017496833820477138904086504936653,
+0.0018207107534726740664031190858499,
+0.0018940560669183994028819598871195,
+0.0019697771361713749612895672483489,
+0.0020479327352110049427203001908145,
+0.0021285826026105331694355269134035,
+0.0022117874457052003277926775534943,
+0.0022976089445228727465346484834697,
+0.0023861097554723792499850248217240,
+0.0024773535147847972673256983223040,
+0.0025714048417029369302101034261387,
+0.0026683293414142823832363688797436,
+0.0027681936077226629953295076518733,
+0.0028710652254539436232041298935747,
+0.0029770127725910425674023204098673,
+0.0030861058221336084017639988630727,
+0.0031984149436777124716404688551759,
+0.0033140117047109425659476350227711,
+0.0034329686716183150926847318139061,
+0.0035553594103944580443781996165620,
+0.0036812584870575551447401858711181,
+0.0038107414677605828344616800994838,
+0.0039438849185954161943924842972825,
+0.0040807664050854275283757907615298,
+0.0042214644913622521437520704647014,
+0.0043660587390224498811261527952966,
+0.0045146297056598481605443585092382,
+0.0046672589430694127309264624541007,
+0.0048240289951185559336308638248258,
+0.0049850233952818591176022063291776,
+0.0051503266638352558688635817117752,
+0.0053200243047057959353718452562791,
+0.0054942028019731861316473643458710,
+0.0056729496160193840862988980474521,
+0.0058563531793226034377548083961200,
+0.0060445028918921749753305742540381,
+0.0062374891163407972483387929655944,
+0.0064354031725908023073933510887484,
+0.0066383373322111574794705404658347,
+0.0068463848123820223897503993348027,
+0.0070596397694837818048469788245517,
+0.0072781972923075792578191818194915,
+0.0075021533948844837974105963701023,
+0.0077316050089305325523851307783982,
+0.0079666499759050050847134857666071,
+0.0082073870386794016888624160865753,
+0.0084539158328147168427251380482097,
+0.0087063368774447208910424013086311,
+0.0089647515657630877048030968282711,
+0.0092292621551123334684672734458439,
+0.0094999717566726618574085777328700,
+0.0097769843247489436353291208335505,
+0.010060404645654194078293843834485,
+0.010350338326188049569353811608784,
+0.010646891781708885154543286252021,
+0.010950172223798357754604946285802,
+0.011260287647517305032601322612720,
+0.011577346818252077569331479548254,
+0.011901459258150531938181195607839,
+0.012232735232147064438977423293752,
+0.012571285733576219585199790156626,
+0.012917222469374563877478800219660,
+0.013270657844870673874016151359696,
+0.013631704948163248019139849155321,
+0.014000477534087514046838136074487,
+0.014377090007770267967456346858194,
+0.014761657407774046601949609437339,
+0.015154295388831103276861200434830,
+0.015555120204168025560815154925755,
+0.015964248687422004734656664984981,
+0.016381798234149938965976413225514,
+0.016807886782931725826831840989589,
+0.017242632796069274771969644286699,
+0.017686155239882946403462793571599,
+0.018138573564607302704908681695568,
+0.018600007683888230851543589435575,
+0.019070577953883682608049690585690,
+0.019550405151970451628630242680456,
+0.020039610455059592088244444888635,
+0.020538315417523263912879794943674,
+0.021046641948735972352611518514529,
+0.021564712290233352665276773215700,
+0.022092648992491834161348941213946,
+0.022630574891332701711706202768021,
+0.023178613083954256948366371101434,
+0.023736886904595965702117898315558,
+0.024305519899838662627868113491276,
+0.024884635803545068375397824301927,
+0.025474358511445058976439960072061,
+0.026074812055370311244462073651303,
+0.026686120577143131826641049447266,
+0.027308408302124461013276284852685,
+0.027941799512426225402939013509847,
+0.028586418519793395946336737313587,
+0.029242389638161289652263216771770,
+0.029909837155893834238982126652275,
+0.030588885307708695157680098839869,
+0.031279658246295343604846340775321,
+0.031982280013632322281167857745092,
+0.032696874512010142649353359001283,
+0.033423565474766423195855175587296,
+0.034162476436740052615498034030857,
+0.034913730704451334817461499479598,
+0.035677451326015244100031699774695,
+0.036453761060795088664440236434221,
+0.037242782348804048739670036655132,
+0.038044637279862221875431809564713,
+0.038859447562516972335132693932346,
+0.039687334492734543890584925714135,
+0.040528418922371055591986340801123,
+0.041382821227431158167483440470840,
+0.042250661276122784504178955469039,
+0.043132058396716581085239141131793,
+0.044027131345218758215005619698021,
+0.044935998272866245265732779326289,
+0.045858776693453182936612403313918,
+0.046795583450497927539868823433935,
+0.047746534684259882532616306840947,
+0.048711745798615609810571129432571,
+0.049691331427803807585359012649044,
+0.050685405403048872896908560407433,
+0.051694080719072894883275395800970,
+0.052717469500506049760398854397735,
+0.053755682968205489973196940462042,
+0.054808831405492938087791428043050,
+0.055877024124321310624598007414939,
+0.056960369431380808106975877083641,
+0.058058974594155015044997525731772,
+0.059172945806937657315038667482309,
+0.060302388156820764361186340468896,
+0.061447405589665079763369470506339,
+0.062608100876063655920686425916359,
+0.063784575577309656819342245515906,
+0.064976930011379477027307876104165,
+0.066185263218942365118398487297559,
+0.067409672929407815614830941523325,
+0.068650255527022065189163362004456,
+0.069907106017025096225390286413257,
+0.071180317991879613848296161953869,
+0.072469983597583521135308237520781,
+0.073776193500077471373341915222637,
+0.075099036851759125863790513540962,
+0.076438601258115790863191994938246,
+0.077794972744487147728576142780523,
+0.079168235722969826170510468599020,
+0.080558472959475601660990309430887,
+0.081965765540955024457270652876091,
+0.083390192842798309348398652352618,
+0.084831832496425332072659782375735,
+0.086290760357076590357704840823397,
+0.087767050471816994669336326621729,
+0.089260775047764355990630440763894,
+0.090772004420554435263379242563858,
+0.092300807023054411484196462453932,
+0.093847249354336612835816138931998,
+0.095411395948924337630256250528042,
+0.096993309346321569227122650485086,
+0.098593050060838361452283141744859,
+0.10021067655172363836674224936860,
+0.10184624519361711451250632220358,
+0.10349981024733199898368814000176,
+0.10517142383098009883164359971665,
+0.10686113589145088440959500889326,
+0.10856899417625602129447082412255,
+0.11029504420575081039354272635688,
+0.11203932924574390975530390372094,
+0.11380189028050663846482220182350,
+0.11558276598619308482291560396762,
+0.11738199270468215779781714907419,
+0.11919960441785263251188934638845,
+0.12103563272230214730126719628907,
+0.12289010680452101168239058737097,
+0.12476305341653158139804841906366,
+0.12665449685200384862109216685845,
+0.12856445892285778239315065346246,
+0.13049295893636283649771956994986,
+0.13244001367274491924359386833822,
+0.13440563736331099209989012387317,
+0.13638984166910133181443671845826,
+0.13839263566007935360208331227128,
+0.14041402579486875124989898660378,
+0.14245401590104756359608780190209,
+0.14451260715600862584492824534947,
+0.14658979806839570862967864507081,
+0.14868558446012448768006771595344,
+0.15079995944899732244391597005599,
+0.15293291343192065310912117174584,
+0.15508443406873365223048192891762,
+0.15725450626665658964567820863435,
+0.15944311216536718762845943862911,
+0.16165023112271305733920048810401,
+0.16387583970106811766014391572835,
+0.16611991165434070351367599962861,
+0.16838241791564087282782923639171,
+0.17066332658561421950690209120232,
+0.17296260292144929416173482302959,
+0.17528020932656552503090252450452,
+0.17761610534098831856000078514917,
+0.17997024763241780258238159741654,
+0.18234258998799745504414545780810,
+0.18473308330678863782379326829855,
+0.18714167559295682849941862068489,
+0.18956831194967511300221492803250,
+0.19201293457375026905468757845803,
+0.19447548275097653421732988912792,
+0.19695589285222191335235816419193,
+0.19945409833025163845276150648843,
+0.20197002971729314917635894248078,
+0.20450361462334671516627457024502,
+0.20705477773524557143125166049073,
+0.20962344081646918580299928253962,
+0.21220952270771302288618251395419,
+0.21481293932821791207397586764010,
+0.21743360367786186822386027319269,
+0.22007142584001695258138284190647,
+0.22272631298517349861195631471557,
+0.22539816937533376266165545828552,
+0.22808689636917679292768612158752,
+0.23079239242799604218913353520832,
+0.23351455312241098024111989986545,
+0.23625327113985369110394965389324,
+0.23900843629283116795742415141924,
+0.24177993552796374549433896555599,
+0.24456765293579983511209750076264,
+0.24737146976140685318397681213752,
+0.25019126441573795668913391095395,
+0.25302691248777392385083081611986,
+0.25587828675743924025403357803856,
+0.25874525720929117330545838962331,
+0.26162769104698033998069745272810,
+0.26452545270848099469404800143849,
+0.26743840388208898594720977460909,
+0.27036640352318505228350117490323,
+0.27330930787176085011527741113257,
+0.27626697047070482832457438953037,
+0.27923924218484478728150444918964,
+0.28222597122074368320248464312911,
+0.28522700314724496270185225280600,
+0.28824218091676343709660005140683,
+0.29127134488731743162548796629063,
+0.29431433284529767136109936207106,
+0.29737098002896809334668966075191,
+0.30044111915269350349878304944392,
+0.30352458043188872720089121345295,
+0.30662119160868363439249999010266,
+0.30973077797829815344914235623389,
+0.31285316241612112337194056715696,
+0.31598816540548657087583401334788,
+0.31913560506614073800151788799045,
+0.32229529718339292699287661344322,
+0.32546705523794297249459327863446,
+0.32865069043637789674799558856850,
+0.33184601174233005151050207717290,
+0.33505282590828880100774379349488,
+0.33827093750805755345902673081645,
+0.34150014896984770470667000533122,
+0.34474026061000081633718096543132,
+0.34799107066733011251530899270932,
+0.35125237533807214466761999955394,
+0.35452396881143924125593274913176,
+0.35780564330576313127699656859607,
+0.36109718910521990491601739486620,
+0.36439839459712625306946272277496,
+0.36770904630979670933691027769531,
+0.37102892895095140366092149471183,
+0.37435782544666362616479831887041,
+0.37769551698083629299575891806814,
+0.38104178303519620321899472961082,
+0.38439640142979477711796274160057,
+0.38775914836400377172805673496007,
+0.39112979845799427915259675089182,
+0.39450812479468712726811412723279,
+0.39789389896216262090451304836411,
+0.40128689109651738456722546511367,
+0.40468686992515589533331367236067,
+0.40809360281050412677994501835618,
+0.41150685579413256176802004055217,
+0.41492639364127567368011695104950,
+0.41835197988573482237230699988565,
+0.42178337687515136271359276695409,
+0.42522034581663662022229645262154,
+0.42866264682274525003099094866769,
+0.43211003895777836228354479341310,
+0.43556228028440266915024194171792,
+0.43901912791057178599808389709123,
+0.44248033803673570192924743102707,
+0.44594566600332432295480690202771,
+0.44941486633849088455434890849725,
+0.45288769280610092933365749204151,
+0.45636389845395244997839064099843,
+0.45984323566221270775525189648788,
+0.46332545619205715247469905855686,
+0.46681031123449579113928535993164,
+0.47029755145937227949528299859722,
+0.47378692706452094341568836018045,
+0.47727818782506687550083730456247,
+0.48077108314285419651682760891294,
+0.48426536209598752132727528626736,
+0.48776077348847162483349154639140,
+0.49125706589993426514216387276280,
+0.49475398773541708874559081684765,
+0.49825128727521951594230608573670,
+0.50174871272478048405769391426330,
+0.50524601226458291125440918315235,
+0.50874293410006573485783612723720,
+0.51223922651152837516650845360860,
+0.51573463790401247867272471373264,
+0.51922891685714580348317239108706,
+0.52272181217493312449916269543753,
+0.52621307293547905658431163981955,
+0.52970244854062772050471700140278,
+0.53318968876550420886071464006836,
+0.53667454380794284752530094144314,
+0.54015676433778729224474810351212,
+0.54363610154604755002160935900157,
+0.54711230719389907066634250795849,
+0.55058513366150911544565109150275,
+0.55405433399667567704519309797229,
+0.55751966196326429807075256897293,
+0.56098087208942821400191610290877,
+0.56443771971559733084975805828208,
+0.56788996104222163771645520658690,
+0.57133735317725474996900905133231,
+0.57477965418336337977770354737846,
+0.57821662312484863728640723304591,
+0.58164802011426517762769300011435,
+0.58507360635872432631988304895050,
+0.58849314420586743823197995944783,
+0.59190639718949587322005498164382,
+0.59531313007484410466668632763933,
+0.59871310890348261543277453488633,
+0.60210610103783737909548695163589,
+0.60549187520531287273188587276721,
+0.60887020154200572084740324910818,
+0.61224085163599622827194326503993,
+0.61560359857020522288203725839943,
+0.61895821696480379678100527038918,
+0.62230448301916370700424108193186,
+0.62564217455333637383520168112959,
+0.62897107104904859633907850528817,
+0.63229095369020329066308972230469,
+0.63560160540287374693053727722504,
+0.63890281089478009508398260513380,
+0.64219435669423686872300343140393,
+0.64547603118856075874406725086824,
+0.64874762466192785533238000044606,
+0.65200892933266988748469100729068,
+0.65525973938999918366281903456868,
+0.65849985103015229529332999466878,
+0.66172906249194244654097326918355,
+0.66494717409171119899225620650512,
+0.66815398825766994848949792282710,
+0.67134930956362210325200441143150,
+0.67453294476205702750540672136554,
+0.67770470281660707300712338655678,
+0.68086439493385926199848211200955,
+0.68401183459451342912416598665212,
+0.68714683758387887662805943284304,
+0.69026922202170184655085764376611,
+0.69337880839131636560750000989734,
+0.69647541956811127279910878654705,
+0.69955888084730649650121695055608,
+0.70262901997103190665331033924809,
+0.70568566715470232863890063792894,
+0.70872865511268256837451203370937,
+0.71175781908323656290339994859317,
+0.71477299685275503729814774719400,
+0.71777402877925631679751535687089,
+0.72076075781515521271849555081036,
+0.72373302952929517167542561046963,
+0.72669069212823914988472258886743,
+0.72963359647681494771649882509677,
+0.73256159611791101405279022539091,
+0.73547454729151900530595199856151,
+0.73837230895301966001930254727190,
+0.74125474279070882669454161037669,
+0.74412171324256075974596642196144,
+0.74697308751222607614916918388014,
+0.74980873558426204331086608904605,
+0.75262853023859314681602318786248,
+0.75543234706420016488790249923736,
+0.75822006447203625450566103444401,
+0.76099156370716883204257584858076,
+0.76374672886014630889605034610676,
+0.76648544687758901975888010013455,
+0.76920760757200395781086646479168,
+0.77191310363082320707231387841248,
+0.77460183062466623733834454171448,
+0.77727368701482650138804368528443,
+0.77992857415998304741861715809353,
+0.78256639632213813177613972680731,
+0.78518706067178208792602413235990,
+0.78779047729228697711381748604581,
+0.79037655918353081419700071746038,
+0.79294522226475442856874833950927,
+0.79549638537665328483372542975498,
+0.79802997028270685082364105751922,
+0.80054590166974836154723849351157,
+0.80304410714777808664764183580807,
+0.80552451724902346578267011087208,
+0.80798706542624973094531242154197,
+0.81043168805032488699778507196750,
+0.81285832440704317150058137931511,
+0.81526691669321136217620673170145,
+0.81765741001200254495585454219190,
+0.82002975236758219741761840258346,
+0.82238389465901168143999921485083,
+0.82471979067343447496909747549548,
+0.82703739707855070583826517697041,
+0.82933667341438578049309790879768,
+0.83161758208435912717217076360829,
+0.83388008834565929648632400037139,
+0.83612416029893188233985608427165,
+0.83834976887728694266079951189599,
+0.84055688783463281237154056137089,
+0.84274549373334341035432179136565,
+0.84491556593126634776951807108238,
+0.84706708656807934689087882825416,
+0.84920004055100267755608402994401,
+0.85131441553987551231993228404656,
+0.85341020193160429137032135492919,
+0.85548739284399137415507175465053,
+0.85754598409895243640391219809791,
+0.85958597420513124875010101339622,
+0.86160736433992064639791668772872,
+0.86361015833089866818556328154174,
+0.86559436263668900790010987612683,
+0.86755998632725508075640613166178,
+0.86950704106363716350228043005014,
+0.87143554107714221760684934653754,
+0.87334550314799615137890783314155,
+0.87523694658346841860195158093634,
+0.87710989319547898831760941262903,
+0.87896436727769785269873280371093,
+0.88080039558214736748811065361155,
+0.88261800729531784220218285092581,
+0.88441723401380691517708439603238,
+0.88619810971949336153517779817650,
+0.88796067075425609024469609627906,
+0.88970495579424918960645727364312,
+0.89143100582374397870552917587745,
+0.89313886410854911559040499110674,
+0.89482857616901990116835640028335,
+0.89650018975266800101631185999824,
+0.89815375480638288548749367779642,
+0.89978932344827636163325775063140,
+0.90140694993916163854771685825514,
+0.90300669065367843077287734951491,
+0.90458860405107566236974374947196,
+0.90615275064566338716418386106800,
+0.90769919297694558851580353754607,
+0.90922799557944556473662075743614,
+0.91073922495223564400936955923611,
+0.91223294952818300533066367337827,
+0.91370923964292340964229515917660,
+0.91516816750357466792734021762427,
+0.91660980715720169065160134764738,
+0.91803423445904497554272934712391,
+0.91944152704052439833900969056911,
+0.92083176427703017382948953140098,
+0.92220502725551285227142385721948,
+0.92356139874188420913680800506175,
+0.92490096314824087413620948645904,
+0.92622380649992252862665808477736,
+0.92753001640241647886469176247922,
+0.92881968200812038615170383804613,
+0.93009289398297490377460971358674,
+0.93134974447297793481083663799554,
+0.93259032707059218438516905847667,
+0.93381473678105763488160151270244,
+0.93502306998862052297269212389584,
+0.93621542442269034318065775448409,
+0.93739189912393634407931357408364,
+0.93855259441033492023663052949366,
+0.93969761184317923563881365953110,
+0.94082705419306234268496133251769,
+0.94194102540584498495500247426823,
+0.94303963056861919189302412291636,
+0.94412297587567868937540199258506,
+0.94519116859450706191220857195695,
+0.94624431703179451002680305953796,
+0.94728253049949395023960114560227,
+0.94830591928092710511672460419903,
+0.94931459459695112710309143959257,
+0.95030866857219619241464098735096,
+0.95128825420138439018942887056743,
+0.95225346531574011746738369315905,
+0.95320441654950207246013117656606,
+0.95414122330654681706338759668608,
+0.95506400172713375473426722067371,
+0.95597286865478124178499438030198,
+0.95686794160328341891476085886821,
+0.95774933872387721549582104453096,
+0.95861717877256884183251655952916,
+0.95947158107762894440801365919888,
+0.96031266550726545610941507428586,
+0.96114055243748302766486730606765,
+0.96195536272013777812456819043529,
+0.96275721765119595126032996334487,
+0.96354623893920491133555976356578,
+0.96432254867398475589996830022531,
+0.96508626929554866518253850052040,
+0.96583752356325994738450196596914,
+0.96657643452523357680414482441270,
+0.96730312548798985735064664099872,
+0.96801771998636767771883214225491,
+0.96872034175370465639515365922468,
+0.96941111469229130484231990116013,
+0.97009016284410616576101787334773,
+0.97075761036183871034773678322823,
+0.97141358148020660405366326268641,
+0.97205820048757377459706098649015,
+0.97269159169787553898672371514731,
+0.97331387942285686817335895055273,
+0.97392518794462968875553792634870,
+0.97452564148855494102356003992794,
+0.97511536419645493162460217569807,
+0.97569448010016133737213188650872,
+0.97626311309540403429788210168444,
+0.97682138691604574305163362889857,
+0.97736942510866729828829379723198,
+0.97790735100750816583865105878605,
+0.97843528770976664733472322678430,
+0.97895335805126402764738848148547,
+0.97946168458247673608712020505633,
+0.97996038954494040791175555511137,
+0.98044959484802954837136975731954,
+0.98092942204611631739195030941431,
+0.98139999231611176914845641056442,
+0.98186142643539269729509131830443,
+0.98231384476011705359653720642840,
+0.98275736720393072522803035571330,
+0.98319211321706827417316815901041,
+0.98361820176585006103402358677449,
+0.98403575131257799526534333501502,
+0.98444487979583197443918484507424,
+0.98484570461116889672313879956517,
+0.98523834259222595339805039056266,
+0.98562290999222973203254365314181,
+0.98599952246591248595316186392551,
+0.98636829505183675198086015084468,
+0.98672934215512932612598384864030,
+0.98708277753062543612252119978034,
+0.98742871426642378041480020984337,
+0.98776726476785293556102257670625,
+0.98809854074184946806181880439216,
+0.98842265318174792243066852045175,
+0.98873971235248269496739867738728,
+0.98904982777620164224539505371420,
+0.98935310821829111484545671374798,
+0.98964966167381195043064618839122,
+0.98993959535434580592170615616552,
+0.99022301567525105636467087916645,
+0.99050002824332733814259142226713,
+0.99077073784488766653153272655416,
+0.99103524843423691229519690317173,
+0.99129366312255527910895759869137,
+0.99154608416718528315727486195179,
+0.99179261296132059831113758391342,
+0.99203335002409499491528651423339,
+0.99226839499106946744761486922160,
+0.99249784660511551620258940362990,
+0.99272180270769242074218081818051,
+0.99294036023051621819515302117545,
+0.99315361518761797761024960066520,
+0.99336166266778884252052945953417,
+0.99356459682740919769260664891125,
+0.99376251088365920275166120703441,
+0.99395549710810782502466942574596,
+0.99414364682067739656224519160388,
+0.99432705038398061591370110195255,
+0.99450579719802681386835263565413,
+0.99467997569529420406462815474372,
+0.99484967333616474413113641828822,
+0.99501497660471814088239779367082,
+0.99517597100488144406636913617517,
+0.99533274105693058726907353754590,
+0.99548537029434015183945564149076,
+0.99563394126097755011887384720470,
+0.99577853550863774785624792953530,
+0.99591923359491457247162420923847,
+0.99605611508140458380560751570272,
+0.99618925853223941716553831990052,
+0.99631874151294244485525981412888,
+0.99644464058960554195562180038344,
+0.99656703132838168490731526818609,
+0.99668598829528905743405236497723,
+0.99680158505632228752835953114482,
+0.99691389417786639159823600113693,
+0.99702298722740895743259767959013,
+0.99712893477454605637679587010643,
+0.99723180639227733700467049234813,
+0.99733167065858571761676363112026,
+0.99742859515829706306978989657386,
+0.99752264648521520273267430167770,
+0.99761389024452762075001497517828,
+0.99770239105547712725346535151653,
+0.99778821255429479967220732244651,
+0.99787141739738946683056447308660,
+0.99795206726478899505727969980919,
+0.99803022286382862503871043275165,
+0.99810594393308160059711804011288,
+0.99817928924652732593359688091415,
+0.99825031661795228610959134950633,
+0.99831908290557896661633977169183,
+0.99838564401691801176130979709270,
+0.99845005491383886824652226404241,
+0.99851236961785416968582487820462,
+0.99857264121561312986538455817359,
+0.99863092186459922725114696424816,
+0.99868726279902748054454351891479,
+0.99874171433593663493767498902160,
+0.99879432588147160107455079780959,
+0.99884514593735151353735399087569,
+0.99889422210751880289646363010165,
+0.99894160110496470493915776130058,
+0.99898732875872666257236498111014,
+0.99903145002105311002615879647622,
+0.99907400897473116531236687890867,
+0.99911504884057279536104959109426,
+0.99915461198505505880996369897067,
+0.99919273992811007400070580621939,
+0.99922947335106040428126773612498,
+0.99926485210469559916852069512885,
+0.99929891521748567822505255116477,
+0.99933170090392739459131972558321,
+0.99936324657301916692392275968781,
+0.99939358883686062196087081665412,
+0.99942276351937274500112491960318,
+0.99945080566513469218396808536753,
+0.99947774954833337651865859636246,
+0.99950362868182199908059175305842,
+0.99952847582628375759047749118320,
+0.99955232299949702666097428520550,
+0.99957520148569836726347370328836,
+0.99959714184503978736855252159686,
+0.99961817392313674117887202133092,
+0.99963832686070342083454867757665,
+0.99965762910327196185950508551696,
+0.99967610841099225186405576809150,
+0.99969379186850910105482002053707,
+0.99971070589491360285866970235048,
+0.99972687625376558337340294292075,
+0.99974232806318410934472318819781,
+0.99975708580600309586743050592431,
+0.99977117333998912694907412014558,
+0.99978461390811867438733549077643,
+0.99979743014891197302890796431460,
+0.99980964410682088332859050244168,
+0.99982127724266814514392378023601,
+0.99983235044413549981444327768454,
+0.99984288403629823071729915348413,
+0.99985289779220374559475208210195,
+0.99986241094349189694646011856065,
+0.99987144219105480960353760582519,
+0.99988000971573405718560213000744,
+0.99988813118905310142047763822626,
+0.99989582378398298021352155290672,
+0.99990310418573930182494681942213,
+0.99990998860260867348493978928967,
+0.99991649277680276318446478710244,
+0.99992263199533826316178032624115,
+0.99992842110094109269904638870789,
+0.99993387450297324618898544858136,
+0.99993900618838075996825256139745,
+0.99994382973266133808276367616225,
+0.99994835831085024289246795163937,
+0.99995260470852312118165854784025,
+0.99995658133281450015965128350524,
+0.99996030022345075036033728338797,
+0.99996377306379637392364709308046,
+0.99996701119191253701439481910103,
+0.99997002561162682415251337558133,
+0.99997282700361324994275775343557,
+0.99997542573648162005218713016568,
+0.99997783187787538824204817750339,
+0.99998005520557720977027656808063,
+0.99998210521862144349624303103134,
+0.99998399114841290549648145148230,
+0.99998572196985122589622050428981,
+0.99998730641246020789527973851606,
+0.99998875297152163357840663389793,
+0.99999006991921300501100755178306,
+0.99999126531574875129453593703906,
+0.99999234702052447265613122916005,
+0.99999332270326383124057254099264,
+0.99999419985516773502690009015807,
+0.99999498580006549617642023875333,
+0.99999568770556767810409998898571,
+0.99999631259422037662404337192501,
+0.99999686735466070962592882135189,
+0.99999735875277331686872744360097,
+0.99999779344284769660813738195352,
+0.99999817797873622888406024193622,
+0.99999851882501275636490692884384,
+0.99999882236813161265905384219286,
+0.99999909492758700494459545032638,
+0.99999934276707267262260292123767,
+0.99999957210564175645408463156061,
+0.99999978912886682328618166434825,
+1.0000000000000000000000000000000,
+1.0000000000000000000000000000000,
+1.0000000000000000000000000000000,
+1.0000000000000000000000000000000};
diff --git a/ext.c b/ext.c
index 28f7ed7b44600d73ae9e8c9656d411671a952b07..fe33284915c1a77889f9d0c2af5faa998ad26cc1 100644 (file)
--- a/ext.c
+++ b/ext.c
@@ -33,6 +33,7 @@
 #ifdef PURESIGNAL
 #include "ps_menu.h"
 #endif
+#include "band.h"
 
 // The following calls functions can be called usig g_idle_add
 
@@ -49,7 +50,19 @@ int ext_discovery(void *data) {
 }
 
 int ext_set_frequency(void *data) {
-  setFrequency(*(long long *)data);
+  //
+  // If new frequency is outside of current band,
+  // behave as if the user had chosen the new band
+  // via the menu prior to changing the frequency
+  //
+  long long freq = *(long long *)data;
+  int id=active_receiver->id;
+  int b = get_band_from_frequency(freq);
+  if (b < 0) b=bandGen;
+  if (b != vfo[id].band) {
+    vfo_band_changed(b);
+  }
+  setFrequency(freq);
   free(data);
   return 0;
 }
index 225b6af3ec10b2cf4219db1cb19e3e68bfa6aaed..97800b615a9781100c032af0d83c1c5f84c93bd9 100644 (file)
--- a/iambic.c
+++ b/iambic.c
@@ -79,6 +79,8 @@
  *   mlockall and munlockall still apply process-wide and are therefore executed in
  *   keyer_init/keyer_close.
  *
+ *   APPLE MacOS: if we run this in MacOS, most likely we are not "root". Therefore no locking/scheduling.
+ *
  * b) SIDE TONE GENERATION
  * =======================
  *
@@ -242,18 +244,16 @@ static sem_t cw_event;
 
 static int cwvox = 0;
 
+#ifndef __APPLE__
 // using clock_nanosleep of librt
 extern int clock_nanosleep(clockid_t __clock_id, int __flags,
       __const struct timespec *__req,
       struct timespec *__rem);
+#endif
 
 #ifndef GPIO
 //
-// It makes absolutely no sense to activate LOCALCW but not GPIO.
-// However, if this is done, the code should compile although it does
-// not do anything. Therefore we provide dummy functions related to
-// GPIO side tone generation. Without GPIO, keyer_event is never
-// called so the keyer_thread does nothing.
+// Dummy functions if compiled without GPIO
 //
 int gpio_cw_sidetone_enabled() { return 0; }
 void gpio_cw_sidetone_set(int level) {}
@@ -306,8 +306,14 @@ void keyer_update() {
 // state=0: paddle has been released
 // state=1: paddle has been hit
 //
+static int enforce_cw_vox;
+
 void keyer_event(int left, int state) {
+    if (!running) return;
     if (state) {
+        // This is to remember whether the key stroke interrupts a running CAT CW 
+       // Since in this case we return to RX after vox delay.
+       if (CAT_cw_is_active) enforce_cw_vox=1;
         // This is for aborting CAT CW messages if a key is hit.
        cw_key_hit = 1;
     }
@@ -330,18 +336,10 @@ void keyer_event(int left, int state) {
 }
 
 void set_keyer_out(int state) {
-  switch (protocol) {
-    case ORIGINAL_PROTOCOL:
-      if (state) {
-        cw_hold_key(1); // this starts a CW pulse in transmitter.c
-      } else {
-        cw_hold_key(0); // this stops a CW pulse in transmitter.c
-      }
-      break;
-    case NEW_PROTOCOL:
-      cw_key_state = state;
-      schedule_high_priority();
-      break;
+  if (state) {
+    cw_hold_key(1); // this starts a CW pulse in transmitter.c
+  } else {
+    cw_hold_key(0); // this stops a CW pulse in transmitter.c
   }
 }
 
@@ -354,15 +352,21 @@ static void* keyer_thread(void *arg) {
     int i;
     int kdelay;
     int old_volume;
-    struct sched_param param;
+#ifdef __APPLE__
+    struct timespec now;
+#endif
 
+#ifndef __APPLE__
+    struct sched_param param;
     param.sched_priority = MY_PRIORITY;
     if(sched_setscheduler((pid_t)0, SCHED_FIFO, &param) == -1) {
             perror("sched_setscheduler failed");
     }
+#endif
 
     fprintf(stderr,"keyer_thread  state running= %d\n", running);
     while(running) {
+        enforce_cw_vox=0;
 #ifdef __APPLE__
         sem_wait(cw_event);
 #else
@@ -383,6 +387,8 @@ static void* keyer_thread(void *arg) {
           while ((!mox || cw_not_ready) && i-- > 0) usleep(1000L);
           cwvox=(int) cw_keyer_hang_time;
        }
+       // Trigger VOX if CAT CW was active and we have interrupted it by hitting a key
+       if (enforce_cw_vox) cwvox=(int) cw_keyer_hang_time;
 
         key_state = CHECK;
 
@@ -439,7 +445,18 @@ static void* keyer_thread(void *arg) {
                            loop_delay.tv_nsec -= NSEC_PER_SEC;
                            loop_delay.tv_sec++;
                          }
+#ifdef __APPLE__
+                         clock_gettime(CLOCK_MONOTONIC, &now);
+                         now.tv_sec =loop_delay.tv_sec  - now.tv_sec;
+                         now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec;
+                         while (now.tv_nsec < 0) {
+                           now.tv_nsec += 1000000000;
+                           now.tv_sec--;
+                         }
+                         nanosleep(&now, NULL);
+#else
                          clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL);
+#endif
                          gpio_cw_sidetone_set(0);
                          loop_delay.tv_nsec += sidewait;
                          while (loop_delay.tv_nsec >= NSEC_PER_SEC) {
@@ -447,7 +464,18 @@ static void* keyer_thread(void *arg) {
                            loop_delay.tv_sec++;
                          }
                          if (!*kdash) break;
+#ifdef __APPLE__
+                         clock_gettime(CLOCK_MONOTONIC, &now);
+                         now.tv_sec =loop_delay.tv_sec  - now.tv_sec;
+                         now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec;
+                         while (now.tv_nsec < 0) {
+                           now.tv_nsec += 1000000000;
+                           now.tv_sec--;
+                         }
+                         nanosleep(&now, NULL);
+#else
                          clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL);
+#endif
                        }
                      } else {
                        // No-GPIO-sidetone case:
@@ -459,7 +487,18 @@ static void* keyer_thread(void *arg) {
                            loop_delay.tv_sec++;
                          }
                          if (!*kdash) break;
+#ifdef __APPLE__
+                         clock_gettime(CLOCK_MONOTONIC, &now);
+                         now.tv_sec =loop_delay.tv_sec  - now.tv_sec;
+                         now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec;
+                         while (now.tv_nsec < 0) {
+                           now.tv_nsec += 1000000000;
+                           now.tv_sec--;
+                         }
+                         nanosleep(&now, NULL);
+#else
                          clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL);
+#endif
                        }
                       }
                      // dash released.
@@ -472,7 +511,18 @@ static void* keyer_thread(void *arg) {
                            loop_delay.tv_nsec -= NSEC_PER_SEC;
                            loop_delay.tv_sec++;
                          }
+#ifdef __APPLE__
+                         clock_gettime(CLOCK_MONOTONIC, &now);
+                         now.tv_sec =loop_delay.tv_sec  - now.tv_sec;
+                         now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec;
+                         while (now.tv_nsec < 0) {
+                           now.tv_nsec += 1000000000;
+                           now.tv_sec--;
+                         }
+                         nanosleep(&now, NULL);
+#else
                          clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL);
+#endif
                          cw_keyer_sidetone_volume=old_volume;
                       }
                     }
@@ -508,14 +558,36 @@ static void* keyer_thread(void *arg) {
                       loop_delay.tv_nsec -= NSEC_PER_SEC;
                       loop_delay.tv_sec++;
                     } 
+#ifdef __APPLE__
+                    clock_gettime(CLOCK_MONOTONIC, &now);
+                    now.tv_sec =loop_delay.tv_sec  - now.tv_sec;
+                    now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec;
+                    while (now.tv_nsec < 0) {
+                      now.tv_nsec += 1000000000;
+                      now.tv_sec--;
+                    }
+                    nanosleep(&now, NULL);
+#else
                     clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL);
+#endif
                     gpio_cw_sidetone_set(0);
                     loop_delay.tv_nsec += sidewait;
                     while (loop_delay.tv_nsec >= NSEC_PER_SEC) {
                       loop_delay.tv_nsec -= NSEC_PER_SEC;
                       loop_delay.tv_sec++;
                    }
+#ifdef __APPLE__
+                    clock_gettime(CLOCK_MONOTONIC, &now);
+                    now.tv_sec =loop_delay.tv_sec  - now.tv_sec;
+                    now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec;
+                    while (now.tv_nsec < 0) {
+                      now.tv_nsec += 1000000000;
+                      now.tv_sec--;
+                    }
+                    nanosleep(&now, NULL);
+#else
                     clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL);
+#endif
                   }
                } else {
                  // No-GPIO-sidetone case: just wait
@@ -524,7 +596,18 @@ static void* keyer_thread(void *arg) {
                     loop_delay.tv_nsec -= NSEC_PER_SEC;
                     loop_delay.tv_sec++;
                  }
+#ifdef __APPLE__
+                    clock_gettime(CLOCK_MONOTONIC, &now);
+                    now.tv_sec =loop_delay.tv_sec  - now.tv_sec;
+                    now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec;
+                    while (now.tv_nsec < 0) {
+                      now.tv_nsec += 1000000000;
+                      now.tv_sec--;
+                    }
+                    nanosleep(&now, NULL);
+#else
                   clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL);
+#endif
                }
                 set_keyer_out(0);
                 key_state = DOTDELAY;       // add inter-character spacing of one dot length
@@ -585,14 +668,36 @@ static void* keyer_thread(void *arg) {
                       loop_delay.tv_nsec -= NSEC_PER_SEC;
                       loop_delay.tv_sec++;
                     }
+#ifdef __APPLE__
+                    clock_gettime(CLOCK_MONOTONIC, &now);
+                    now.tv_sec =loop_delay.tv_sec  - now.tv_sec;
+                    now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec;
+                    while (now.tv_nsec < 0) {
+                      now.tv_nsec += 1000000000;
+                      now.tv_sec--;
+                    }
+                    nanosleep(&now, NULL);
+#else
                     clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL);
+#endif
                     gpio_cw_sidetone_set(0);
                     loop_delay.tv_nsec += sidewait;
                     while (loop_delay.tv_nsec >= NSEC_PER_SEC) {
                       loop_delay.tv_nsec -= NSEC_PER_SEC;
                       loop_delay.tv_sec++;
                     }
+#ifdef __APPLE__
+                    clock_gettime(CLOCK_MONOTONIC, &now);
+                    now.tv_sec =loop_delay.tv_sec  - now.tv_sec;
+                    now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec;
+                    while (now.tv_nsec < 0) {
+                      now.tv_nsec += 1000000000;
+                      now.tv_sec--;
+                    }
+                    nanosleep(&now, NULL);
+#else
                     clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL);
+#endif
                   }
                } else {
                  // No-GPIO-sidetone case: just wait
@@ -601,7 +706,18 @@ static void* keyer_thread(void *arg) {
                     loop_delay.tv_nsec -= NSEC_PER_SEC;
                     loop_delay.tv_sec++;
                   }
+#ifdef __APPLE__
+                    clock_gettime(CLOCK_MONOTONIC, &now);
+                    now.tv_sec =loop_delay.tv_sec  - now.tv_sec;
+                    now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec;
+                    while (now.tv_nsec < 0) {
+                      now.tv_nsec += 1000000000;
+                      now.tv_sec--;
+                    }
+                    nanosleep(&now, NULL);
+#else
                   clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL);
+#endif
                }
                 set_keyer_out(0);
                 key_state = DASHDELAY;       // add inter-character spacing of one dot length
@@ -663,13 +779,27 @@ static void* keyer_thread(void *arg) {
                 loop_delay.tv_nsec -= NSEC_PER_SEC;
                 loop_delay.tv_sec++;
             }
+#ifdef __APPLE__
+            clock_gettime(CLOCK_MONOTONIC, &now);
+            now.tv_sec =loop_delay.tv_sec  - now.tv_sec;
+            now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec;
+            while (now.tv_nsec < 0) {
+              now.tv_nsec += 1000000000;
+              now.tv_sec--;
+            }
+            nanosleep(&now, NULL);
+#else
             clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL);
+#endif
         }
 
     }
     fprintf(stderr,"keyer_thread: EXIT\n");
+#ifndef __APPLE__
     param.sched_priority = 0;
     sched_setscheduler((pid_t) 0, SCHED_OTHER, &param);
+#endif
+    return NULL;
 }
 
 void keyer_close() {
@@ -687,7 +817,10 @@ void keyer_close() {
 #else
     sem_close(&cw_event);
 #endif
+
+#ifndef __APPLE__
     munlockall();
+#endif
 }
 
 int keyer_init() {
@@ -695,18 +828,20 @@ int keyer_init() {
 
     fprintf(stderr,".... starting keyer thread.\n");
     
+#ifndef __APPLE__
     if(mlockall(MCL_CURRENT|MCL_FUTURE) == -1) {
             perror("mlockall failed");
     }
+#endif
 
-    running = 1;
 #ifdef __APPLE__
     sem_unlink("CW");
-    cw_event=sem_open("CW", O_CREAT | O_EXCL), 0700, 0);
+    cw_event=sem_open("CW", O_CREAT | O_EXCL, 0700, 0);
     rc = (cw_event == SEM_FAILED);
 #else
     rc = sem_init(&cw_event, 0, 0);
 #endif
+    running = 1;
     rc |= pthread_create(&keyer_thread_id, NULL, keyer_thread, NULL);
     if(rc < 0) {
         fprintf(stderr,"pthread_create for keyer_thread failed %d\n", rc);
index ea9120ea4e0ea83547bb6c6242dec121082e392c..959c320a432ab94eab9f19284961aa68caad671d 100644 (file)
@@ -53,7 +53,6 @@
 #include "test_menu.h"
 #include "vox_menu.h"
 #include "diversity_menu.h"
-#include "freqent_menu.h"
 #include "tx_menu.h"
 #include "ps_menu.h"
 #include "encoder_menu.h"
@@ -321,16 +320,6 @@ static gboolean diversity_cb (GtkWidget *widget, GdkEventButton *event, gpointer
   return TRUE;
 }
 
-void start_freqent() {
-  cleanup();
-  freqent_menu(top_window);
-}
-
-static gboolean freqent_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
-  start_freqent();
-  return TRUE;
-}
-
 void start_vfo() {
   cleanup();
   vfo_menu(top_window);
index dc784c3affb684da6bf965e52336beead5a5325e..8a79b78e4668412c6a702f69ec61049762079bac 100644 (file)
@@ -61,6 +61,7 @@
 #endif
 #include "vox.h"
 #include "ext.h"
+#include "iambic.h"
 
 #define min(x,y) (x<y?x:y)
 
@@ -83,6 +84,9 @@ int data_socket=-1;
 
 static int running;
 
+static int dash=0;
+static int dot=0;
+
 #ifdef __APPLE__
 sem_t *response_sem;
 #else
@@ -631,17 +635,11 @@ static void new_protocol_high_priority() {
       mode=vfo[0].mode;
     }
     high_priority_buffer_to_radio[4]=running;
+//
+//  ??? why not setting the bit if transmitting in *all* cases ===
+//
     if(mode==modeCWU || mode==modeCWL) {
-      if(tune || CAT_cw_is_active) {
-        high_priority_buffer_to_radio[4]|=0x02;
-      }
-#ifdef LOCALCW
-      if (cw_keyer_internal == 0) {
-        // set the ptt if we are not in breakin mode and mox is on
-        if(cw_breakin == 0 && getMox()) high_priority_buffer_to_radio[4]|=0x02;
-      }
-#endif
-      if (cw_key_state) high_priority_buffer_to_radio[5]|= 0x01;
+      if (isTransmitting() && (!cw_keyer_internal || !cw_breakin || CAT_cw_is_active)) high_priority_buffer_to_radio[4]|=0x02;
     } else {
       if(isTransmitting()) {
         high_priority_buffer_to_radio[4]|=0x02;
@@ -1130,8 +1128,10 @@ static void new_protocol_transmit_specific() {
     transmit_specific_buffer[4]=1; // 1 DAC
     transmit_specific_buffer[5]=0; //  default no CW
     // may be using local pihpsdr OR hpsdr CW
-    if(mode==modeCWU || mode==modeCWL) {
+    if (mode==modeCWU || mode==modeCWL) {
+      if (cw_keyer_internal) {
         transmit_specific_buffer[5]|=0x02;
+      }
     }
     if(cw_keys_reversed) {
         transmit_specific_buffer[5]|=0x04;
@@ -1142,7 +1142,7 @@ static void new_protocol_transmit_specific() {
     if(cw_keyer_mode==KEYER_MODE_B) {
         transmit_specific_buffer[5]|=0x28;
     }
-    if(cw_keyer_sidetone_volume!=0) {
+    if(cw_keyer_sidetone_volume!=0 && cw_keyer_internal) {
         transmit_specific_buffer[5]|=0x10;
     }
     if(cw_keyer_spacing) {
@@ -1160,6 +1160,7 @@ static void new_protocol_transmit_specific() {
     transmit_specific_buffer[11]=cw_keyer_hang_time>>8;
     transmit_specific_buffer[12]=cw_keyer_hang_time; // cw hang delay
     transmit_specific_buffer[13]=0; // rf delay
+
     transmit_specific_buffer[50]=0;
     if(mic_linein) {
       transmit_specific_buffer[50]|=0x01;
@@ -1786,12 +1787,20 @@ static void process_high_priority(unsigned char *buffer) {
     alex_reverse_power=((high_priority_buffer[22]&0xFF)<<8)|(high_priority_buffer[23]&0xFF);
     supply_volts=((high_priority_buffer[49]&0xFF)<<8)|(high_priority_buffer[50]&0xFF);
 
+#ifdef LOCALCW
+#ifndef GPIO
     if (dash || dot) cw_key_hit=1;
+    if (!cw_keyer_internal) {
+      if (dash != previous_dash) keyer_event(0, dash);
+      if (dot  != previous_dot ) keyer_event(1, dot );
+    }
+#endif
+#endif
 
     int tx_vfo=split?VFO_B:VFO_A;
-    if(vfo[tx_vfo].mode==modeCWL || vfo[tx_vfo].mode==modeCWU) {
-      local_ptt=local_ptt|dot|dash;
-    }
+    //if(vfo[tx_vfo].mode==modeCWL || vfo[tx_vfo].mode==modeCWU) {
+    //  local_ptt=local_ptt|dot|dash;
+    //}
     if(previous_ptt!=local_ptt && !CAT_cw_is_active) {
       g_idle_add(ext_mox_update,(gpointer)(long)(local_ptt));
     }
@@ -1852,9 +1861,46 @@ void new_protocol_process_local_mic(unsigned char *buffer,int le) {
 
 }
 
+void new_protocol_cw_audio_samples(short left_audio_sample,short right_audio_sample) {
+  int rc;
+  int mode=transmitter->mode;
+  //
+  // Only process samples if transmitting in CW
+  if (isTransmitting() && (mode==modeCWU || mode==modeCWL)) {
+
+  // insert the samples
+  audiobuffer[audioindex++]=left_audio_sample>>8;
+  audiobuffer[audioindex++]=left_audio_sample;
+  audiobuffer[audioindex++]=right_audio_sample>>8;
+  audiobuffer[audioindex++]=right_audio_sample;
+
+  if(audioindex>=sizeof(audiobuffer)) {
+
+    // insert the sequence
+    audiobuffer[0]=audiosequence>>24;
+    audiobuffer[1]=audiosequence>>16;
+    audiobuffer[2]=audiosequence>>8;
+    audiobuffer[3]=audiosequence;
+
+    // send the buffer
+
+    rc=sendto(data_socket,audiobuffer,sizeof(audiobuffer),0,(struct sockaddr*)&audio_addr,audio_addr_length);
+    if(rc!=sizeof(audiobuffer)) {
+      fprintf(stderr,"sendto socket failed for %ld bytes of audio: %d\n",sizeof(audiobuffer),rc);
+    }
+    audioindex=4;
+    audiosequence++;
+  }
+  }
+}
+
 
 void new_protocol_audio_samples(RECEIVER *rx,short left_audio_sample,short right_audio_sample) {
   int rc;
+  int mode=transmitter->mode;
+  //
+  // Only process samples if NOT transmitting in CW
+  if (isTransmitting() && (mode==modeCWU || mode==modeCWL)) return;
 
   // insert the samples
   audiobuffer[audioindex++]=left_audio_sample>>8;
@@ -1929,22 +1975,47 @@ void new_protocol_iq_samples(int isample,int qsample) {
 }
 
 void* new_protocol_timer_thread(void* arg) {
-  int specific=0;
-fprintf(stderr,"new_protocol_timer_thread\n");
+  //
+  // We now sent HighPriority as well as General packets
+  // in addition. General packet re-sending is, for example,
+  // required if the band changes (band->disblePA), and HighPrio
+  // packets are necessary at very many instances when changing
+  // something in the menus, and then a small delay does no harm
+  //
+  // Of course, in time-critical situations (RX-TX transition etc.)
+  // it is still possible to explicitly send a packet.
+  //
+  // We send high prio packets every 100 msec
+  //         RX spec   packets every 200 msec
+  //         TX spec   packets every 200 msec
+  //         General   packets every 800 msec
+  //
+  int cycling=0;
+  usleep(100000);                              // wait for things to settle down
   while(running) {
-    usleep(100000); // 100ms
-//    if(running) {
-//      switch(specific) {
-//        case 0:
-          new_protocol_transmit_specific();
-//          specific=1;
-//          break;
-//        case 1:
-          new_protocol_receive_specific();
-//          specific=0;
-//          break;
-//      }
-//    }
+    cycling++;
+    switch (cycling) {
+      case 1:
+      case 3:
+      case 5:
+      case 7:
+       new_protocol_high_priority();           // every 100 msec
+       new_protocol_transmit_specific();       // every 200 msec
+       break;
+      case 2:
+      case 4:
+      case 6:
+       new_protocol_high_priority();           // every 100 msec
+       new_protocol_transmit_specific();       // every 200 msec
+        break;
+      case 8:
+       new_protocol_high_priority();           // every 100 msec
+       new_protocol_receive_specific();        // every 200 msec
+       new_protocol_general();                 // every 800 msec
+       cycling=0;
+       break;
+    }
+    usleep(100000);
   }
   return NULL;
 }
index 0a1bd9c6ab1e9aa91569a531a41a01bd08dc8538..fe900b3d83d02bdd6b1ea28c8f0933156ee849cf 100644 (file)
@@ -92,4 +92,5 @@ extern void new_protocol_process_local_mic(unsigned char *buffer,int le);
 extern void new_protocol_audio_samples(RECEIVER *rx,short left_audio_sample,short right_audio_sample);
 extern void new_protocol_iq_samples(int isample,int qsample);
 extern void new_protocol_flush_iq_samples();
+extern void new_protocol_cw_audio_samples(short l, short r);
 #endif
index 443336df949fd445784fcb73334060b112755958..d3598443b42cf96f5edf0b9b5e3c980940a2a641 100644 (file)
@@ -144,6 +144,8 @@ static int psk_divisor=6;
 #endif
 
 static int local_ptt=0;
+static int dash=0;
+static int dot=0;
 
 static double micinputbuffer[MAX_BUFFER_SIZE*2];
 
diff --git a/radio.c b/radio.c
index 3abb01dde357e821d0f53734af30093618328baf..d4acf84866f4cbd46d093feb61a6f73af910ffdf 100644 (file)
--- a/radio.c
+++ b/radio.c
@@ -275,6 +275,7 @@ int tx_filter_low=150;
 int tx_filter_high=2850;
 
 static int pre_tune_mode;
+static int pre_tune_cw_internal;
 static int pre_tune_filter_low;
 static int pre_tune_filter_high;
 
@@ -294,7 +295,6 @@ double vox_hang=250.0;
 int vox=0;
 int CAT_cw_is_active=0;
 int cw_key_hit=0;
-int cw_key_state=0;
 int n_adc=1;
 
 int diversity_enabled=0;
@@ -936,6 +936,7 @@ void setTune(int state) {
         mode=vfo[VFO_B].mode;
       }
       pre_tune_mode=mode;
+      pre_tune_cw_internal=cw_keyer_internal;
 
       //
       // in USB/DIGU/DSB, tune 1000 Hz above carrier
@@ -979,7 +980,7 @@ void setTune(int state) {
         case modeCWL:
         case modeCWU:
           tx_set_mode(transmitter,pre_tune_mode);
-          cw_keyer_internal=1;
+          cw_keyer_internal=pre_tune_cw_internal;
           break;
       }
     }
diff --git a/radio.h b/radio.h
index 211540c4ed060174c649949c2e872123a2c6c617..16b3ccacef2623a801d47ce92a399869afeec170 100644 (file)
--- a/radio.h
+++ b/radio.h
@@ -186,8 +186,6 @@ extern int mox;
 extern int tune;
 extern int memory_tune;
 extern int full_tune;
-extern int dot;
-extern int dash;
 extern int adc_overload;
 extern int pll_locked;
 extern unsigned int exciter_power;
@@ -247,7 +245,6 @@ extern double vox_hang;
 extern int vox;
 extern int CAT_cw_is_active;
 extern int cw_key_hit;
-extern int cw_key_state;
 extern int n_adc;
 
 extern int diversity_enabled;
index 27f438dc7b6cab21b2bff7294a60288435960828..264a683085f98423f870d54319653481ad290199 100644 (file)
--- a/rigctl.c
+++ b/rigctl.c
@@ -73,7 +73,8 @@ static const int TelnetPortA = 19090;
 static const int TelnetPortB = 19091;
 static const int TelnetPortC = 19092;
 
-#define RIGCTL_TIMER_DELAY  15000
+#define RIGCTL_THROTTLE_NSEC    15000000L
+#define NSEC_PER_SEC          1000000000L
 
 // max number of bytes we can get at once
 #define MAXDATASIZE 2000
@@ -110,7 +111,6 @@ FILTER * band_filter;
 
 #define MAX_CLIENTS 3
 static GThread *rigctl_server_thread_id = NULL;
-static GThread *rigctl_set_timer_thread_id = NULL;
 static GThread *rigctl_cw_thread_id = NULL;
 static int server_running;
 
@@ -193,16 +193,6 @@ void close_rigctl_ports() {
   }
 }
 
-// RigCtl Timer - to throttle passes through the parser...
-// Sets rigctl_timer while waiting - clears and exits thread.
-static gpointer set_rigctl_timer (gpointer data) {
-      rigctl_timer = 1;
-      // Wait throttle time
-      usleep(RIGCTL_TIMER_DELAY);
-      rigctl_timer = 0;
-      return NULL;
-}
-
 //
 // Used to convert transmitter->ctcss_frequency into 1-39 value for TS2000.
 // This COULD be done with a simple table lookup - but I've already written the code
@@ -318,80 +308,55 @@ static int dashsamples;
 //
 void send_dash() {
   int TimeToGo;
-  if (protocol == ORIGINAL_PROTOCOL) {
-    for(;;) {
-      TimeToGo=cw_key_up+cw_key_down;
-      // TimeToGo is invalid if local CW keying has set in
-      if (cw_key_hit || cw_not_ready) return;
-      if (TimeToGo == 0) break;
-      // sleep until 10 msec before ignition
-      if (TimeToGo > 500) usleep((long)(TimeToGo-500)*20L);
-      // sleep 1 msec
-      usleep(1000L);
-    }
-    // If local CW keying has set in, do not interfere
-    if (cw_key_hit || cw_not_ready) return;
-    cw_key_down = dashsamples;
-    cw_key_up   = dotsamples;
-  } else {
+  for(;;) {
+    TimeToGo=cw_key_up+cw_key_down;
+    // TimeToGo is invalid if local CW keying has set in
     if (cw_key_hit || cw_not_ready) return;
-    cw_key_state=1;
-    schedule_high_priority();
-    usleep(dashlen);
-    cw_key_state=0;
-    schedule_high_priority();
-    usleep(dotlen);
+    if (TimeToGo == 0) break;
+    // sleep until 10 msec before ignition
+    if (TimeToGo > 500) usleep((long)(TimeToGo-500)*20L);
+    // sleep 1 msec
+    usleep(1000L);
   }
+  // If local CW keying has set in, do not interfere
+  if (cw_key_hit || cw_not_ready) return;
+  cw_key_down = dashsamples;
+  cw_key_up   = dotsamples;
 }
 
 void send_dot() {
   int TimeToGo;
-  if (protocol == ORIGINAL_PROTOCOL) {
-    for(;;) {
-      TimeToGo=cw_key_up+cw_key_down;
-      // TimeToGo is invalid if local CW keying has set in
-      if (cw_key_hit || cw_not_ready) return;
-      if (TimeToGo == 0) break;
-      // sleep until 10 msec before ignition
-      if (TimeToGo > 500) usleep((long)(TimeToGo-500)*20L);
-      // sleep 1 msec
-      usleep(1000L);
-    }
-    // If local CW keying has set in, do not interfere
+  for(;;) {
+    TimeToGo=cw_key_up+cw_key_down;
+    // TimeToGo is invalid if local CW keying has set in
     if (cw_key_hit || cw_not_ready) return;
-    cw_key_down = dotsamples;
-    cw_key_up   = dotsamples;
-  } else {
-    if (cw_key_hit || cw_not_ready) return;
-    cw_key_state=1;
-    schedule_high_priority();
-    usleep(dotlen);
-    cw_key_state=0;
-    schedule_high_priority();
-    usleep(dotlen);
+    if (TimeToGo == 0) break;
+    // sleep until 10 msec before ignition
+    if (TimeToGo > 500) usleep((long)(TimeToGo-500)*20L);
+    // sleep 1 msec
+    usleep(1000L);
   }
+  // If local CW keying has set in, do not interfere
+  if (cw_key_hit || cw_not_ready) return;
+  cw_key_down = dotsamples;
+  cw_key_up   = dotsamples;
 }
 
 void send_space(int len) {
   int TimeToGo;
-  if (protocol == ORIGINAL_PROTOCOL) {
     for(;;) {
-      TimeToGo=cw_key_up+cw_key_down;
-      // TimeToGo is invalid if local CW keying has set in
-      if (cw_key_hit || cw_not_ready) return;
-      if (TimeToGo == 0) break;
-      // sleep until 10 msec before ignition
-      if (TimeToGo > 500) usleep((long)(TimeToGo-500)*20L);
-      // sleep 1 msec
-      usleep(1000L);
-    }
-    // If local CW keying has set in, do not interfere
+    TimeToGo=cw_key_up+cw_key_down;
+    // TimeToGo is invalid if local CW keying has set in
     if (cw_key_hit || cw_not_ready) return;
-    cw_key_up = len*dotsamples;
-  } else {
-    if (cw_key_hit || cw_not_ready) return;
-    usleep(len*dotlen);
+    if (TimeToGo == 0) break;
+    // sleep until 10 msec before ignition
+    if (TimeToGo > 500) usleep((long)(TimeToGo-500)*20L);
+    // sleep 1 msec
+    usleep(1000L);
   }
+  // If local CW keying has set in, do not interfere
+  if (cw_key_hit || cw_not_ready) return;
+  cw_key_up = len*dotsamples;
 }
 
 void rigctl_send_cw_char(char cw_char) {
@@ -896,27 +861,26 @@ void parse_cmd ( char * cmd_input,int len,int client_sock) {
         //int space = command.indexOf(' ');
         //char cmd_char = com_head->cmd_string[0]; // Assume the command is first thing!
         char cmd_str[3];
+        struct timespec nap;
+        static struct timespec throttle={0,0};
 
-        // Put in throtle check here - we have an issue with issuing to many 
-        // GUI commands - the idea is to create a separate thread that maintains a 200ms clock
-        // and use the Mutex mechanism to wait here till we process the next command
-
-        while(rigctl_timer != 0) {  // Wait here till the timer expires
-            usleep(1000);
-        }
-        // Start a new timer...
        
-        rigctl_set_timer_thread_id = g_thread_new( "Rigctl Timer", set_rigctl_timer, NULL);
-
-        while(rigctl_timer != 1) {  // Wait here till the timer sets!
-            usleep(1000);
-        }
-
-        usleep(1000);
-
-       // Clean up the thread
-       g_thread_unref(rigctl_set_timer_thread_id);
+        // Put in a throttle here - we have an issue with issuing to many 
+        // GUI commands.
+
+       if ((throttle.tv_sec !=0) || (throttle.tv_nsec != 0)) {
+          clock_gettime(CLOCK_MONOTONIC, &nap);
+         // calculate amount of time we should go for a nap.
+          nap.tv_sec =throttle.tv_sec  - nap.tv_sec;
+          nap.tv_nsec=throttle.tv_nsec - nap.tv_nsec + RIGCTL_THROTTLE_NSEC;
+          while (nap.tv_nsec < 0) {
+            nap.tv_nsec += NSEC_PER_SEC;
+            nap.tv_sec--;
+          }
+          nanosleep(&nap, NULL);
+       }
+       // set new time stamp
+       clock_gettime(CLOCK_MONOTONIC, &throttle);
 
         // On with the rest of the show..
         cmd_str[0] = cmd_input[0];
index d9ec70906fc53ca59b06b8f42c3652466913ad2b..2dc809ef8baf92ad9ff0672b4b908f045dffe50a 100644 (file)
@@ -82,7 +82,8 @@ int cw_not_ready=1;
 // and the pulses must be shaped. This is done via "cw_shape_buffer".
 // The TX mic samples buffer could possibly be used for this as well.
 //
-static double *cw_shape_buffer = NULL;
+static double *cw_shape_buffer48 = NULL;
+static double *cw_shape_buffer192 = NULL;
 static int cw_shape = 0;
 //
 // cwramp is the function defining the "ramp" of the CW pulse.
@@ -90,7 +91,8 @@ static int cw_shape = 0;
 // is hard-coded. We currently use the impulse response of a
 // Blackman-Harris window.
 //
-extern double cwramp[];  // see cwramp.c
+extern double cwramp48[];              // see cwramp.c, for 48 kHz sample rate
+extern double cwramp192[];             // see cwramp.c, for 192 kHz sample rate
 
 extern void cw_audio_write(double sample);
 
@@ -618,10 +620,11 @@ fprintf(stderr,"transmitter: allocate buffers: mic_input_buffer=%d iq_output_buf
   tx->iq_output_buffer=malloc(sizeof(double)*2*tx->output_samples);
   tx->samples=0;
   tx->pixel_samples=malloc(sizeof(float)*tx->pixels);
-  // The CW shape buffer is only used in the old protocol
-  if (protocol == ORIGINAL_PROTOCOL) {
-    if (cw_shape_buffer) free(cw_shape_buffer);
-    cw_shape_buffer=malloc(sizeof(double)*tx->buffer_size);
+  if (cw_shape_buffer48) free(cw_shape_buffer48);
+  if (cw_shape_buffer192) free(cw_shape_buffer192);
+  cw_shape_buffer48=malloc(sizeof(double)*tx->buffer_size);
+  if (protocol == NEW_PROTOCOL) {
+    cw_shape_buffer192=malloc(sizeof(double)*tx->output_samples);
   }
 fprintf(stderr,"transmitter: allocate buffers: mic_input_buffer=%p iq_output_buffer=%p pixels=%p\n",tx->mic_input_buffer,tx->iq_output_buffer,tx->pixel_samples);
 
@@ -790,6 +793,8 @@ static void full_tx_buffer(TRANSMITTER *tx) {
   int cwmode;
   int sidetone=0;
   static int txflag=0;
+  static long last_qsample=0;
+  long delta;
 
   // It is important to query tx->mode and tune only *once* within this function, to assure that
   // the two "if (cwmode)" clauses give the same result.
@@ -817,20 +822,19 @@ static void full_tx_buffer(TRANSMITTER *tx) {
     // also becomes visible on *our* TX spectrum display.
     //
     dp=tx->iq_output_buffer;
+    // These are the I/Q samples that describe our CW signal
+    // The only use we make of it is displaying the spectrum.
     switch (protocol) {
       case ORIGINAL_PROTOCOL:
-        // These are the I/Q samples that describe our CW signal
-        // The only use we make of it is displaying the spectrum.
         for (j = 0; j < tx->output_samples; j++) {
            *dp++ = 0.0;
-           *dp++ = cw_shape_buffer[j];
+           *dp++ = cw_shape_buffer48[j];
         }
        break;
       case NEW_PROTOCOL:
-       // Produce zero TX signal for "empty" spectrum
         for (j = 0; j < tx->output_samples; j++) {
            *dp++ = 0.0;
-           *dp++ = 0.0;
+           *dp++ = cw_shape_buffer192[j];
         }
        break;
     }
@@ -863,15 +867,6 @@ static void full_tx_buffer(TRANSMITTER *tx) {
       }
     }
 
-//
-//  When doing CW, we do not need WDSP since Q(t) = cw_shape_buffer(t) and I(t)=0
-//  For the old protocol where the IQ and audio samples are tied together, we can
-//  easily generate a synchronous side tone (and use the function
-//  old_protocol_iq_samples_with_sidetone for this purpose).
-//
-//  Note that the CW shape buffer is tied to the mic sample rate (48 kHz).
-//
-
     if (txflag == 0 && protocol == NEW_PROTOCOL) {
        //
        // this is the first time (after a pause) that we send TX samples
@@ -882,6 +877,14 @@ static void full_tx_buffer(TRANSMITTER *tx) {
        }       
     }
     txflag=1;
+//
+//  When doing CW, we do not need WDSP since Q(t) = cw_shape_buffer(t) and I(t)=0
+//  For the old protocol where the IQ and audio samples are tied together, we can
+//  easily generate a synchronous side tone (and use the function
+//  old_protocol_iq_samples_with_sidetone for this purpose).
+//
+//  Note that the CW shape buffer is tied to the mic sample rate (48 kHz).
+//
     if (cwmode) {
        //
        // "pulse shape case":
@@ -899,17 +902,22 @@ static void full_tx_buffer(TRANSMITTER *tx) {
             sidevol= 258.0 * cw_keyer_sidetone_volume;  // between 0.0 and 32766.0
            isample=0;                              // will be constantly zero
             for(j=0;j<tx->output_samples;j++) {
-             ramp=cw_shape_buffer[j];              // between 0.0 and 1.0
+             ramp=cw_shape_buffer48[j];                    // between 0.0 and 1.0
              qsample=floor(gain*ramp+0.5);         // always non-negative, isample is just the pulse envelope
              sidetone=sidevol * ramp * getNextInternalSideToneSample();
              old_protocol_iq_samples_with_sidetone(isample,qsample,sidetone);
            }
            break;
          case NEW_PROTOCOL:
+           //
            // Note: tx->output_samples is larger than tx->buffer_size
+           // therefore we do a linear interpolation within the ramp
+           // this is probably not necessary)
+           //
            isample=0;
-           qsample=0;
-           for(j=0;j<tx->output_samples;j++) {
+            for(j=0;j<tx->output_samples;j++) {
+             ramp=cw_shape_buffer192[j];                       // between 0.0 and 1.0
+             qsample=floor(gain*ramp+0.5);                     // always non-negative, isample is just the pulse envelope
              new_protocol_iq_samples(isample,qsample);
            }
            break;
@@ -971,48 +979,53 @@ void add_mic_sample(TRANSMITTER *tx,short mic_sample) {
 //
 //     We HAVE TO shape the signal to avoid hard clicks to be
 //     heard way beside our frequency. The envelope (ramp function)
-//      is stored in cwramp[0::200], so we "move" cw_shape between these
+//      is stored in cwramp48[0::200], so we "move" cw_shape between these
 //      values. The ramp width is 200 samples (4.16 msec)
 //
+//      In the new protocol, we use this ramp for the side tone, but
+//      must use values from cwramp192 for the TX iq signal.
+//
 //      Note that usually, the pulse is much broader than the ramp,
 //      that is, cw_key_down and cw_key_up are much larger than 200.
 //
        cw_not_ready=0;
-       switch (protocol) {
-         case ORIGINAL_PROTOCOL:
-           if (cw_key_down > 0 ) {
-             if (cw_shape < 200) cw_shape++;   // walk up the ramp
-             cw_key_down--;                    // decrement key-up counter
-           } else {
-             if (cw_key_up >= 0) {
+       if (cw_key_down > 0 ) {
+         if (cw_shape < 200) cw_shape++;       // walk up the ramp
+         cw_key_down--;                        // decrement key-up counter
+       } else {
+         if (cw_key_up >= 0) {
                // dig into this even if cw_key_up is already zero, to ensure
                // that we reach the bottom of the ramp for very small pauses
                if (cw_shape > 0) cw_shape--;   // walk down the ramp
                if (cw_key_up > 0) cw_key_up--; // decrement key-down counter
-             }
-           }
-           //
-           // store the ramp value in cw_shape_buffer, but also use it for shaping the "local"
-           // side tone
-           ramp=cwramp[cw_shape];
-           cw_audio_write(0.0078 * getNextSideToneSample() * cw_keyer_sidetone_volume * ramp);
-            cw_shape_buffer[tx->samples]=ramp;
-           break;
-         case NEW_PROTOCOL:
-           //
-           // In the new protocol, we only need to generate a side tone (for local audio) here.
-           // We "climb" the ramp upon "key down", and we "descend" upon "key up"
-           //
-           if (cw_key_state) {
-             // climb up the ramp
-             if (cw_shape < 200) cw_shape++;
-           } else {
-             // walk down the ramp
-             if (cw_shape > 0) cw_shape--;
-           }
-           ramp=cwramp[cw_shape];
-           cw_audio_write(0.0078 * getNextSideToneSample() * cw_keyer_sidetone_volume * ramp);
-           break;
+         }
+       }
+       //
+       // store the ramp value in cw_shape_buffer, but also use it for shaping the "local"
+       // side tone
+       ramp=cwramp48[cw_shape];
+       sample=0.0078 * getNextSideToneSample() * cw_keyer_sidetone_volume * ramp;
+       cw_audio_write(sample);
+        cw_shape_buffer48[tx->samples]=ramp;
+       //
+       // In the new protocol, we MUST maintain a constant flow of audio samples to the radio
+       // (at least for ANAN-200D and ANAN-7000 internal side tone generation)
+       // So we ship out audio: silence if CW is internal, side tone if CW is local.
+       //
+       // Furthermore, for each audio sample we have to create four TX samples. If we are at
+       // the beginning of the ramp, these are four zero samples, if we are at the, it is
+       // four unit samples, and in-between, we use the values from cwramp192.
+       // Note that this ramp has been extended a little, such that it begins with four zeros
+       // and ends with four times 1.0.
+       //
+        if (protocol == NEW_PROTOCOL) {
+           s=0;
+           if (!cw_keyer_internal || CAT_cw_is_active) s=(int) (sample * 32767.0);
+           new_protocol_cw_audio_samples(s, s);
+           cw_shape_buffer192[4*tx->samples+0]=cwramp192[4*cw_shape+0];
+           cw_shape_buffer192[4*tx->samples+1]=cwramp192[4*cw_shape+1];
+           cw_shape_buffer192[4*tx->samples+2]=cwramp192[4*cw_shape+2];
+           cw_shape_buffer192[4*tx->samples+3]=cwramp192[4*cw_shape+3];
        }
   } else {
 //
@@ -1025,7 +1038,13 @@ void add_mic_sample(TRANSMITTER *tx,short mic_sample) {
        cw_key_up=0;
        cw_key_down=0;
        cw_shape=0;
-       if (protocol == ORIGINAL_PROTOCOL) cw_shape_buffer[tx->samples]=0.0;
+       cw_shape_buffer48[tx->samples]=0.0;
+       if (protocol == NEW_PROTOCOL) {
+         cw_shape_buffer192[4*tx->samples+0]=0.0;
+         cw_shape_buffer192[4*tx->samples+1]=0.0;
+         cw_shape_buffer192[4*tx->samples+2]=0.0;
+         cw_shape_buffer192[4*tx->samples+3]=0.0;
+       }
   }
   tx->mic_input_buffer[tx->samples*2]=mic_sample_double;
   tx->mic_input_buffer[(tx->samples*2)+1]=0.0; //mic_sample_double;
@@ -1188,7 +1207,7 @@ static long asteps = 0;
 static long bsteps = 0;
 
 double getNextSideToneSample() {
-       double angle = (asteps*cw_keyer_sidetone_frequency)*TWOPIOVERSAMPLERATE;
+       double angle = (asteps*cw_keyer_sidetone_frequency)*TWOPIOVERSAMPLERATE;
        if (++asteps == 48000) asteps = 0;
        return sin(angle);
 }
diff --git a/vfo.c b/vfo.c
index c6af0c8d30a2492f11842b519e90cbf13bd49720..01075cc950f031531261fd8e7d2ea1c4e4eeea42 100644 (file)
--- a/vfo.c
+++ b/vfo.c
@@ -302,13 +302,14 @@ void vfo_band_changed(int b) {
   } else {
     tx_set_mode(transmitter,vfo[VFO_A].mode);
   }
-  calcDriveLevel();
-//
-// New protocol: communicate changes to radio
-//               HighPrio is scheduled anyway through calcDriveLevel
-//
+  //
+  // If the band has changed, it is necessary to re-calculate
+  // the drive level. Furthermore, possibly the "PA disable"
+  // status has changed.
+  //
+  calcDriveLevel();  // sends HighPrio packet if in new protocol
   if (protocol == NEW_PROTOCOL) {
-    schedule_general();                // for PA disable
+    schedule_general();
   }
   g_idle_add(ext_vfo_update,NULL);
 }
@@ -348,7 +349,14 @@ void vfo_bandstack_changed(int b) {
   } else {
     tx_set_mode(transmitter,vfo[VFO_A].mode);
   }
-  calcDriveLevel();
+  //
+  // I do not think the band can change within this function.
+  // But out of paranoia, I consider this possiblity here
+  //
+  calcDriveLevel();  // sends HighPrio packet if in new protocol
+  if (protocol == NEW_PROTOCOL) {
+    schedule_general();                // for PA disable
+  }
   g_idle_add(ext_vfo_update,NULL);
 
 }
index 4118d724ede7ed471723d265950c5f64b2969449..27a7b9fc3f31246565ccef805e6e85441a9c8da7 100644 (file)
@@ -85,6 +85,17 @@ static gboolean freqent_select_cb (GtkWidget *widget, gpointer data) {
   double  mult;
   long long f;
   static int set = 0;
+  int id, b;
+
+  // Instead of messing with LOCALE settings,
+  // we print a "0.0" and look what the decimal
+  // point is. What comes out of sprintf should be
+  // OK for atof.
+  char decimalpoint;
+  mult=0.0;
+  sprintf(output,"%1.1f",mult);
+  decimalpoint=output[1];
+
 
   if (set) {
     set = 0;
@@ -100,7 +111,13 @@ static gboolean freqent_select_cb (GtkWidget *widget, gpointer data) {
 
   if (isdigit (str[0]) || str[0] == '.') {
 
-    buffer[len] = (gchar) str[0];
+    // substitute decimal point by the LOCALE character for the decimal point
+    // otherwise atof() does not understand it.
+    if (str[0] == '.') {
+      buffer[len] = (gchar) decimalpoint;
+    } else {
+      buffer[len] = (gchar) str[0];
+    }
     buffer[len+1] = (gchar) 0;
 
     len = (buffer[0] == '0') ? 1 : 0;
@@ -134,29 +151,21 @@ static gboolean freqent_select_cb (GtkWidget *widget, gpointer data) {
       f = ((long long)(atof(buffer)*mult)+5)/10;
       sprintf(output, "<big>%lld</big>", f);
       gtk_label_set_markup (GTK_LABEL (label), output);
-      int b=get_band_from_frequency(f);
-      if(b<0) {
-        fprintf(stderr,"get_band_from_frequency: failed for f=%lld\n",f);
-        b=bandGen;
+      id=active_receiver->id;
+      b = get_band_from_frequency(f);
+      if (b < 0) {
+       b=bandGen;
       }
-      if(b!=band_get_current()) {
-        BAND *band=band_set_current(b);
-        BANDSTACK_ENTRY *entry=bandstack_entry_get_current();
-        //setMode(entry->mode);
-        set_mode(active_receiver,entry->mode);
-        FILTER* band_filters=filters[entry->mode];
-        FILTER* band_filter=&band_filters[entry->filter];
-        //setFilter(band_filter->low,band_filter->high);
-        set_filter(active_receiver,band_filter->low,band_filter->high);
-        if(active_receiver->id==0) {
-          set_alex_rx_antenna(band->alexRxAntenna);
-          set_alex_tx_antenna(band->alexTxAntenna);
-          set_alex_attenuation(band->alexAttenuation);
-        }
+      //
+      // If new frequency is outside of current band,
+      // behave as if the user had chosen the new band
+      // via the menu prior to changing the frequency
+      //
+      if (b != vfo[id].band) {
+        g_idle_add(ext_vfo_band_changed, (gpointer) (uintptr_t) b);
       }
       setFrequency(f);
       g_idle_add(ext_vfo_update,NULL);
-    
       set = 1;
     }
   }