コード例 #1
0
ファイル: CrossDlg.cpp プロジェクト: fdiskcn/Whorld
void CCrossDlg::SetInfo(const INFO& Info)
{
	SetPos(Info.Pos);
	SetSeconds(Info.Seconds);
	Loop(Info.Loop);
	SetWaveform(Info.Waveform);
}
コード例 #2
0
/*******************************************************************************
* Function Name: ChangeFrequency
********************************************************************************
*
* Summary
*  Stops the selected WaveDAC, modifies its array of samples according to the
*  desired frequency, and starts the DAC again.
*
* Parameters:
*  freq - the desired frequency
*
* Return:
*  The new frequency, or -1 if the desired frequency was invalid
*
*******************************************************************************/
int ChangeFrequency(int freq, int mode, uint8 voltage, int waveDacId)
{
    int fnGenerator, numSamples;
    uint8 *currentWaveform;
    uint8 voltage255;
    
    if (freq < FREQ_LOWER_LIMIT) {
        freq = FREQ_LOWER_LIMIT;
    } else if (freq > FREQ_UPPER_LIMIT) {
        freq = FREQ_UPPER_LIMIT;
    }
    
    if (freq < 2000) {
        if (waveDacId == 0) {
            fnGenerator = WAVEDAC_LOW_0;
        } else if (waveDacId == 1) {
            fnGenerator = WAVEDAC_LOW_1;
        }
        numSamples = WAVEDAC_CLOCK_LOW_FREQ / freq;
    } else {
        if (waveDacId == 0) {
            fnGenerator = WAVEDAC_HIGH_0;
        } else if (waveDacId == 1) {
            fnGenerator = WAVEDAC_HIGH_1;
        }
        numSamples = WAVEDAC_CLOCK_HIGH_FREQ / freq;
    }
    
    voltage255 = voltage * (255.0 / 100.0);
    currentWaveform = GetCurrentWaveform(fnGenerator);
    if (currentWaveform != NULL) {
        StopWaveDac(waveDacId);
        SetWaveform(numSamples, mode, voltage255, currentWaveform);
        StartWaveDac(numSamples, fnGenerator, currentWaveform);
        return freq;
    }
    
    return -1;
}