예제 #1
0
int main()
{
    printf("\nFixed Point\n");
    printf("____________\n\n");
    printf("\nBy Calculation.\n\n");
    fixed_range();
    printf("\nFrom limits.h\n\n");
    header_limits_range();
    printf("\nFloating Point");
    printf("\n________________\n\n");
    printf("\nBy Calculation.\n\n");
    float_max();
    float_min();
    double_max();
    double_min();
    long_double_max();

    printf("\nFrom float.h\n\n");
    header_float_range();
	return 0;
}
예제 #2
0
void effect(struct razer_chroma *chroma)
{
	int r = 128, g = 0, b = 0;
	int count = 1;
	int count_dir = 1;
	int x,y;
	int span = 20;
	double c = 0;
	struct razer_rgb col;
	struct razer_rgb green = {.r=0,.g=255,.b=0}; //define a green color
	struct razer_pos pos;
	col.r = 0;
	col.g = 255;
	col.b = 0;
	while(running){


		//r += rand_span(span);
		r = count;		
		r = fixed_range(r, 255);

		g += rand_span(span);
		g = fixed_range(g, 255);
		g = 0;		

		b += rand_span(span);
		b = fixed_range(b, 255);
		b = 0;

		for(x=0;x<22;x++){
				for(y=0;y<6;y++){	
					
					g = fixed_range(r - (x * 10), 255);				
					
					chroma->keys->rows[y].column[x].r = (unsigned char)r;
					chroma->keys->rows[y].column[x].g = (unsigned char)g;
					chroma->keys->rows[y].column[x].b = (unsigned char)b;
					chroma->keys->update_mask |= 1<<y;
				}
			}

		
		col.g = (sin(c) + 1)/2 * 225;
		col.b = 255 - col.g;
		c += 0.05;

		pos.x = 2;
		pos.y = 3;
		razer_set_key_pos(chroma->keys,&pos,&green);
		pos.x += 1;
		razer_set_key_pos(chroma->keys,&pos,&green);
		pos.y -= 1;
		razer_set_key_pos(chroma->keys,&pos,&green);
		pos.y += 1; 
		pos.x += 1;
		razer_set_key_pos(chroma->keys,&pos,&green);
		
		for(int i=0;i<keys_max;i++)
			if(keys_history[i]!=-1){
				
				razer_convert_keycode_to_pos(keys_history[i],&pos);							
				razer_set_key_pos(chroma->keys,&pos,&col);
				
				if(pos.x == 17 && pos.y == 0){
					for(int i=0;i<keys_max;i++){
						keys_history[i] = -1;
					}
				}
				
			}
	

		razer_update_keys(chroma,chroma->keys);
		count+=count_dir;
		if(count<=0 || count>255){
			count_dir=-count_dir;
		}
		razer_update(chroma);
		razer_frame_limiter(chroma,13);
	
	}
}

#pragma GCC diagnostic pop

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"

void stop(int sig)
{
	#ifdef USE_DEBUGGING
		printf("Stopping input example\n");
	#endif
	running = 0;
}