Esempio n. 1
0
void Controller::update_calibration() {
  int c1 = m_gui->get_item_state_uint8("CAL1");
  int c2 = m_gui->get_item_state_uint8("CAL2");
  int c3 = m_gui->get_item_state_uint8("CAL3");
  int c4 = m_gui->get_item_state_uint8("CAL4");
  float calibration_scaling = ((float)c1) + (((float)c2)/10) + (((float)c3)/100) + (((float)c4)/1000);

  char text_sieverts[50];
  float_to_char(m_calibration_base*calibration_scaling,text_sieverts,5);
  text_sieverts[5] = ' ';
  text_sieverts[6] = '\x80';
  text_sieverts[7] = 'S';
  text_sieverts[8] = 'v';
  text_sieverts[9] = 0;
  m_gui->receive_update("FIXEDSV",text_sieverts);
}
Esempio n. 2
0
File: ga_img.c Progetto: fvdsn/gally
/* TODO : understand the png saving voodoo incantation */
void	ga_image_save(ga_image_t *img, char *path){
	png_byte color_type = PNG_COLOR_TYPE_RGBA;
	png_byte bit_depth = 8;
	png_structp png_ptr;
	png_infop info_ptr;
	png_bytep *row_ptr;
	float *buf = (float*)img->pixel;
	int i = img->sizey;
	int j = img->sizex;
	int k = 4;
	FILE *fp = fopen(path,"wb");
	if(!fp){
		fprintf(stderr,"ERROR: couldn't write file '%s'\n",path);
	}
	row_ptr = (png_bytep*)malloc(img->sizey*sizeof(png_bytep));
	while(i--){
		row_ptr[i] = (png_byte*)malloc(img->sizex*4*sizeof(png_byte));
		j = img->sizex;
		while(j--){
			k = 4;
			while(k--){
				row_ptr[i][j*4+k] = float_to_char(buf[i*img->sizex*4+j*4+k]);
			}
		}
	}
	png_ptr  = png_create_write_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL);
	info_ptr = png_create_info_struct(png_ptr);
	setjmp(png_jmpbuf(png_ptr));
	png_init_io(png_ptr,fp);
	setjmp(png_jmpbuf(png_ptr));
	png_set_IHDR(png_ptr,info_ptr,img->sizex,img->sizey,
			bit_depth, color_type, PNG_INTERLACE_NONE,
			PNG_COMPRESSION_TYPE_BASE,PNG_FILTER_TYPE_BASE);
	png_write_info(png_ptr, info_ptr);
	setjmp(png_jmpbuf(png_ptr));
	png_write_image(png_ptr,row_ptr);
	setjmp(png_jmpbuf(png_ptr));
	png_write_end(png_ptr,NULL);
	fclose(fp);
	i = img->sizey;
	while(i--){
		free(row_ptr[i]);
	}
	free(row_ptr);
}
Esempio n. 3
0
void Controller::event_save_calibration() {
  int c1 = m_gui->get_item_state_uint8("CAL1");
  int c2 = m_gui->get_item_state_uint8("CAL2");
  int c3 = m_gui->get_item_state_uint8("CAL3");
  int c4 = m_gui->get_item_state_uint8("CAL4");
  float calibration_scaling = ((float)c1) + (((float)c2)/10) + (((float)c3)/100) + (((float)c4)/1000);
  float base_sieverts = system_geiger->get_microsieverts_nocal();

  char text_sieverts[50];
  float_to_char(base_sieverts*calibration_scaling,text_sieverts,5);
  text_sieverts[5] = ' ';
  text_sieverts[6] = '\x80';
  text_sieverts[7] = 'S';
  text_sieverts[8] = 'v';
  text_sieverts[9] = 0;

  m_gui->receive_update("Sieverts",text_sieverts);
  system_geiger->set_calibration(calibration_scaling);
  m_dim_off=false;
  m_gui->jump_to_screen(0);
}
Esempio n. 4
0
void Controller::initialise_calibration() {
  m_dim_off=true;
  display_set_brightness(15);
  m_calibration_base = system_geiger->get_microsieverts_nocal();
  char text_sieverts[50];
  float_to_char(m_calibration_base*system_geiger->get_calibration(),text_sieverts,5);
  text_sieverts[5] = ' ';
  text_sieverts[6] = '\x80';
  text_sieverts[7] = 'S';
  text_sieverts[8] = 'v';
  text_sieverts[9] = 0;
  m_gui->receive_update("FIXEDSV",text_sieverts);

  uint8_t c1=system_geiger->get_calibration();
  uint8_t c2=((uint32_t)(system_geiger->get_calibration()*10))%10;
  uint8_t c3=((uint32_t)(system_geiger->get_calibration()*100))%10;
  uint8_t c4=((uint32_t)(system_geiger->get_calibration()*1000))%10;
  m_gui->receive_update("CAL1",&c1);
  m_gui->receive_update("CAL2",&c2);
  m_gui->receive_update("CAL3",&c3);
  m_gui->receive_update("CAL4",&c4);
}
Esempio n. 5
0
void createPacket(char* packet) {

	// Create packet of length 162 bytes
	//unsigned char packet [162];

	/* Packet content:
	 * 00: debug variable
	 * 01: lower motor speed
	 * 02: upper motor speed
	 * 03: Altitude
	 * 04: gyro X
	 * 05: gyro Y
	 * 06: gyro Z
	 * 07: acc X
	 * 08: acc Y
	 * 09: acc Z
	 * 10: roll
	 * 11: pitch
	 * 12: yaw
	 * 13: z-gyro (legacy code)
	 * 14: battery voltage
	 * 15: received rc throttle
	 * 16: received rc left/right
	 * 17: received rc yaw (z axis rotation)
	 * 18: received rc forward/back
	 * 19: Ultrasound/infrared altitude
	 */

	// Fill packet with data
	packet[0]='<';
	// Set debug to zero
	char tmp[8];
	/*int i;
	for(i=0; i<8; i++){
		tmp[i]='0';
	}*/
	float_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 0], tmp, 8);
	float_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 1], tmp, 8);
	float_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 2], tmp, 8);
	float_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 3], tmp, 8);
	double gyro_yaw = gyros_get_si(GYROS_YAW);
	float_to_char(gyro_yaw,tmp);
	memcpy((char*)&packet[1 + 8 * 4], tmp, 8);
	double gyro_pitch = gyros_get_si(GYROS_PITCH);
	float_to_char(gyro_pitch,tmp);
	memcpy((char*)&packet[1 + 8 * 5], tmp, 8);
	double gyro_roll = gyros_get_si(GYROS_ROLL);
	float_to_char(gyro_roll,tmp);
	memcpy((char*)&packet[1 + 8 * 6], tmp, 8);
	double accel_x = acc_get_si(ACC_X);
	float_to_char(accel_x,tmp);
	memcpy((char*)&packet[1 + 8 * 7], tmp, 8);
	double accel_y = acc_get_si(ACC_Y);
	float_to_char(accel_y,tmp);
	memcpy((char*)&packet[1 + 8 * 8], tmp, 8);
	double accel_z = acc_get_si(ACC_Z);
	float_to_char(accel_z,tmp);
	memcpy((char*)&packet[1 + 8 * 9], tmp, 8);
	float_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 10], tmp, 8);
	//double_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 11], tmp, 8);
	//double_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 12], tmp, 8);
	//double_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 13], tmp, 8);
	//double_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 14], tmp, 8);
	//double_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 15], tmp, 8);
	//double_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 16], tmp, 8);
	//double_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 17], tmp, 8);
	//double_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 18], tmp, 8);
	//double_to_char(0.0f,tmp);
	memcpy((char*)&packet[1 + 8 * 19], tmp, 8);

	packet[161]='>';
}