void data(unsigned char a)
{
	char z;
	z=a & 0xf0;
	data_shift(z);
	z=((a<<4) & 0xf0);
	//z=a & 0xf0;
	data_shift(z);
}
Beispiel #2
0
void Task_LEDDIS(void *p_arg)
{
	(void)p_arg;	//'p_arg'没有用到,防止编译器警告

	while(1)
	{
		u8 a,b,c,d;						//定义a,b,c,d四个变量用来存放数码管各个位的值

		a = sum /1000;						//千位值存入a
		b = sum % 1000 /100;				//百位值存入b
		c = sum % 1000 % 100 /10;			//十位值存入c
		d = sum % 1000 % 100 % 10;		    //个位值存入d

		GPIO_SetBits(GPIOB , GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);     
//		Refresh_LED(1234);
		GPIO_ResetBits(GPIOB , GPIO_Pin_12);			//数码管0位位选脚相连引脚置低,使能位0
		data_shift(LEDData[d]);			//将个位数值对应的编码送入数码管数据管脚
		OSTimeDlyHMSM(0,0,0,3);

		GPIO_SetBits(GPIOB , GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);     
//		Refresh_LED(1234);
		GPIO_ResetBits(GPIOB , GPIO_Pin_13);			//数码管0位位选脚相连引脚置低,使能位0
		data_shift(LEDData[c]);			//将个位数值对应的编码送入数码管数据管脚
		OSTimeDlyHMSM(0,0,0,3);

		GPIO_SetBits(GPIOB , GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);     
//		Refresh_LED(1234);
		GPIO_ResetBits(GPIOB , GPIO_Pin_14);			//数码管0位位选脚相连引脚置低,使能位0
		data_shift(LEDData[b]);			//将个位数值对应的编码送入数码管数据管脚
		OSTimeDlyHMSM(0,0,0,3);

		GPIO_SetBits(GPIOB , GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);     
//		Refresh_LED(1234);
		GPIO_ResetBits(GPIOB , GPIO_Pin_15);			//数码管0位位选脚相连引脚置低,使能位0
		data_shift(LEDData[a]);			//将个位数值对应的编码送入数码管数据管脚
		OSTimeDlyHMSM(0,0,0,3);
	}
}
Beispiel #3
0
void processing_build_standing_wave(Processing* p, float* wave, float* light, size_t length, float thickness) {
    double f = p->peakFrequency;
    if(f < 40) f = 40;
    if(f > 16000) f = 16000;
    
    double waveLength = p->fd / f;
    
    size_t index = p->previewLength - waveLength * 2;
    
    double* src = &p->preview[index];
    
    double re = 0; double im = 0;
    for (size_t i = 0; i < waveLength*2; i++) {
        double t = (double)2.0 * M_PI * i / waveLength;
        re += src[i] * cos(t);
        im += src[i] * sin(t);
    }
    
    double phase = get_phase(re, im);
    
    double shift = waveLength * phase / (2.0 * M_PI);
    
    // here something wrong !!!
    // p->previewLength - waveLength * 2 - (size_t)(waveLength - shift) - (size_t)waveLength
    // p->previewLength - waveLength * 4 + (0 .. waveLength)
    double* shiftedSrc = &p->preview[index - (size_t)(waveLength - shift) - (size_t)waveLength];
    
    approximate_sinc(p->points, shiftedSrc, p->pointCount, 2*waveLength);
    double avr = data_avr(p->points, p->pointCount);
    data_shift(p->points, p->pointCount, -avr);
    double dev = data_dev(p->points, p->pointCount);
    if(dev != 0){
        data_scale(p->points, p->pointCount, 0.2/dev);
    }
    
    double dx = (double)2.0 / p->pointCount;
    float* dest = wave;
    for (size_t j = 0; j < p->pointCount-1; j ++) {
        float x0 = dx * j - 1.0;
        float y0 = p->points[j];
        float x1 = dx*(j + 1) - 1.0;
        float y1 = p->points[j+1];
        
        dest = build_edge(dest, x0, y0, x1, y1, thickness);
        
        for (int i = 0; i < 12; i++) {
            light = write_point4D(light, x0, y0, x1, y1);
        }
    }
}