void _zpu_interrupt(void) { int knobdir; char * lcdBuffer = " "; // Debounce inputs knob_debounce(); // Handle rotary encoder knobdir = knob_readEncoder(); if (knobdir==1) { if(freq > 10) { freq -= 10; lcdBuffer = itoa(freq, lcdBuffer, 10); LCD_clear(); LCD_move_to(0,0); LCD_print(lcdBuffer); setChannelFrequency(YM2149_CH_C, freq); } } else if (knobdir==-1) { if(freq < 4085) { freq += 10; lcdBuffer = itoa(freq, lcdBuffer, 10); LCD_clear(); LCD_move_to(0,0); LCD_print(lcdBuffer); setChannelFrequency(YM2149_CH_C, freq); } } // Clear Timer0 Interrupt Flag TMR0CTL &= ~(BIT(TCTLIF)); }
void TacanRadio::initData() { setMaxDetectRange(120.0); setNumberOfChannels(126); rangeIsValid = false; bearingIsValid = false; range = 0; grdrange = 0; bearing = 0; destLatitude = 0; destLongitude = 0; currentMagVar = 0; band = TCN_X_BAND; // Set frequencies { unsigned short chan = 1; // channels [ 1 .. 16 ] while (chan <= 16) { setChannelFrequency(chan++, 0.0f); } // channels [ 17 .. 59 ] while (chan < 59) { setChannelFrequency(chan, (LCreal(chan) * 0.1f + 106.3f)); chan++; } // channels [ 60 .. 69 ] while (chan <= 69) { setChannelFrequency(chan++, 0.0f); } // channels [ 70 .. 126 ] while (chan <= 126) { setChannelFrequency(chan, (LCreal(chan) * 0.1f + 107.3f) ); chan++; } } }
void setup(void) { // setup 1KHz timer setupTimer(); // init LCD LCD_init(); // init PPS // SPKR thru PPS pinMode(OUTPUTPIN,OUTPUT); pinModePPS(OUTPUTPIN,HIGH); outputPinForFunction( OUTPUTPIN, 14); /* set all the channels to same frequency, max level, no noise */ /*unsigned int slots[] = { 10, 11 }; unsigned int i; ym2149_channel_t chan; for (i = 0; i < sizeof(slots) / sizeof(slots[0]); ++i) { // select the YM module setDeviceSlot(slots[i]); for (chan = YM2149_CH_A; chan < YM2149_CH_MAX; ++chan) { setChannelFrequency(chan, 0x0500); setChannelMixerNoise(chan, 1); // 1 means disabled setChannelMixerTone(chan, 0); setChannelVolume(chan, 0x0f); } }*/ setDeviceSlot(10); setChannelFrequency(YM2149_CH_C, 0x0500); setChannelMixerNoise(YM2149_CH_C, 1); // 1 means disabled setChannelMixerTone(YM2149_CH_C, 0); setChannelVolume(YM2149_CH_C, 0x0f); pokey_setDeviceSlot(12); pokey_channel_t pokchan; for (pokchan = POKEY_CH_A; pokchan < POKEY_CH_D; ++pokchan) { pokey_setChannelPeriodMultiplier(pokchan, 0x90); pokey_setChannelControl(pokchan, 0x00); } pokey_setAudioCtrl(0x0); }
//------------------------------------------------------------------------------ // copyData() -- copy member data //------------------------------------------------------------------------------ void Radio::copyData(const Radio& org, const bool cc) { BaseClass::copyData(org); if (cc) initData(); // (Re)set the number of channels setNumberOfChannels(org.numChan); // Copy the channel frequencies unsigned short numChannels = getNumberOfChannels(); for (unsigned short chan = 1; chan <= numChannels; chan++) { setChannelFrequency( chan, org.getChannelFrequency(chan) ); } // Set the channel number setChannel(org.channel); radioId = org.radioId; maxDetectRange = org.maxDetectRange; }
bool Radio::setSlotChannels(const base::PairStream* const msg) { // --- // Quick out if the number of channels hasn't been set. // --- unsigned short nc = getNumberOfChannels(); if (nc == 0 || msg == nullptr) { std::cerr << "Radio::setSlotChannels() Number of channels is not set!" << std::endl; return false; } { unsigned short chan = 1; const base::List::Item* item = msg->getFirstItem(); while (chan <= nc && item != nullptr) { const base::Pair* pair = static_cast<const base::Pair*>(item->getValue()); const base::Frequency* p = static_cast<const base::Frequency*>(pair->object()); if (p != nullptr) { double freq = base::Hertz::convertStatic( *p ); bool ok = setChannelFrequency(chan, freq); if (!ok) { std::cerr << "Radio::setSlotChannels() Error setting frequency for channel " << chan << "; with freq = " << *p << std::endl; } } else { std::cerr << "Radio::setSlotChannels() channel# " << chan << " is not of type Frequency" << std::endl; } chan++; item = item->getNext(); } } return true; }