Beispiel #1
0
void ui_init(void)
{
	c42048a_init();
	ui_display_text(lcd_welcome,sizeof(lcd_welcome));
	c42048a_set_pixel(ICON_AVR);
	c42048a_blink_pixel(ICON_USB);
}
Beispiel #2
0
/**
 * \brief LCD interrupt callback function
 *
 * This function is called when an interrupt has occurred on LCD.
 */
void lcd_interrupt_callback(void)
{
	uint32_t buf_temp;

	// Change text string on LCD when a button is pressed
	if (ui_pusb_button_0()) {
		ui_display_text(lcd_msg_gain_cal, sizeof(lcd_msg_gain_cal));
		c42048a_clear_pixel(ICON_DEGREE_C);
		c42048a_clear_pixel(ICON_MILLI_VOLT);
		test_release_button_gain_cal = true;
	}

	//to limit EEPROM write operations, CAL stored when button released
	if((ui_pusb_button_0() == false)
			&& (test_release_button_gain_cal == true)) {
		buf_temp = (((uint32_t)ext_voltage - ext_offset_cal_val)
				*8000/4095);
		buf_temp = buf_temp * ADC_GAIN_EXT;
		buf_temp = buf_temp / ext_gain_cal_val;

		//store gain value in Flash memory
		if(((buf_temp > EXT_GAIN_MIN_VAL)
				&& (buf_temp < EXT_GAIN_MAX_VAL))){
			ext_gain_cal_val = buf_temp;
			nvm_eeprom_write_byte(ext_gain_cal_addr + 1
				, (uint8_t)(buf_temp>>8));
			nvm_eeprom_write_byte(ext_gain_cal_addr,
				(uint8_t)(buf_temp));
		}
Beispiel #3
0
void ui_init(void)
{
	c42048a_init();
	ui_display_text(lcd_welcome,sizeof(lcd_welcome));
	c42048a_set_pixel(ICON_AVR);
	backlight_off();
}
Beispiel #4
0
void draw_special_restart_text (void)
{
	char
		buffer [64];

	int
		string_length;
	
	float
		x;

	//
	// display game name
	//

	if (current_game_session)
	{
		sprintf (buffer, "%s", current_game_session->title);
		string_length = ui_get_string_length ( buffer );

		x = get_integer_screen_x_mid () - (string_length / 2);

		ui_display_text (buffer, x, 73 + iy_640_480);
	}

	//
	// display flashing message
	//

	if (flash_timer < 0.666)
	{
		set_ui_font_type (UI_FONT_ARIAL_14);

		set_ui_font_colour (ui_colour_yellow);

		sprintf ( buffer, get_trans ("PRESS SPACE") );

		string_length = ui_get_string_length (buffer);

		ui_display_text (buffer, get_integer_screen_x_mid () - (string_length / 2), 420 + iy_640_480);
	}
}
Beispiel #5
0
void usb_hid_com_report_out_received(uint8_t *data)
{
	// Mapped received data to report out type
	struct hid_report_out *report_out=(struct hid_report_out*)data;

	// Update LEDs with new report value
	ui_led(report_out->leds);
	// Load contrast value
	ui_set_contrast(report_out->contrast);
	// Set Backlight level
	ui_set_backlight(report_out->backlight<<8);
	// Display test user message if requested
	if (report_out->lcd_notify & 0x01) {
		ui_display_text(report_out->lcd_user_text, LCD_TEXT_STRING_SIZE);
		main_notify_external_msg();
	}
	// Display numeric user message if requested
	if (report_out->lcd_notify & 0x02) {
		ui_display_sensor(report_out->lcd_user_num, UI_UNIT_NONE);
		main_notify_external_msg();
	}
}
Beispiel #6
0
static void draw_area_ui_object (ui_object *obj)
{

	float
		x,
		y,
		x1,
		y1,
		x2,
		y2;

	int
		redraw_flag = FALSE,
		masked,
		width,
		height,
		pitch;

	font_types
		font_id;

	area_ui_object
		*area;

	struct SCREEN
		*old_active_screen,
		*memory_graphic;

	unsigned short int
		*graphic;

	struct ZOOMABLE_GRAPHIC
		*zoomable_graphic;

	unsigned char
		*data;

	ui_object
		*parent;

	if (get_ui_object_redraw (obj))
	{

		area = (area_ui_object *) obj->data;

		//debug_log ("AR_DRAW: drawing area %f, %f  %f, %f", area->x, area->y, area->x_size, area->y_size);

		x1 = area->x;
		y1 = area->y;

		x2 = x1 + area->x_size;
		y2 = y1 + area->y_size;

		old_active_screen = get_active_screen ();

		if (get_ui_object_active_screen (obj))
		{
	
			set_active_screen (get_ui_object_active_screen (obj));
		}
		else
		{

			set_active_screen (video_screen);
		}

		if (lock_screen (active_screen))
		{
	
			switch (get_ui_object_graphic_type (obj))
			{
	
				case UI_OBJECT_GRAPHIC:
				{
		
					if (!get_ui_object_clear (obj))
					{
		
						graphic = get_ui_object_graphic (obj);
	
						ui_draw_graphic (x1, y1, x2, y2, graphic);
	
						redraw_flag = TRUE;
					}
					else
					{
	
						parent = get_ui_object_parent (obj);
	
						if (parent)
						{
	
							graphic = get_ui_object_graphic (parent);
	
							ui_draw_part_graphic (x1, y1, x2, y2, x1, y1, graphic);
	
							redraw_flag = TRUE;
						}
					}
	
					break;
				}
	
				case UI_OBJECT_MEMORY_GRAPHIC:
				{
	
					memory_graphic = get_ui_object_memory_graphic (obj);

					if (lock_screen (memory_graphic))
					{
		
						width = get_screen_width (memory_graphic);
		
						height = get_screen_height (memory_graphic);
		
						data = get_screen_data (memory_graphic);
		
						pitch = get_screen_pitch (memory_graphic);
		
						masked = get_ui_object_clear (obj);
		
						ui_draw_memory_graphic (obj, x1, y1, x2, y2, width, height, pitch, masked);

						unlock_screen (memory_graphic);
					}
	
					redraw_flag = TRUE;
	
					break;
				}
	
				case UI_OBJECT_ALPHA_GRAPHIC:
				{
		
					if (!get_ui_object_clear (obj))
					{
		
						graphic = get_ui_object_graphic (obj);
	
						ui_draw_alpha_graphic (x1, y1, x2, y2, graphic);
	
						redraw_flag = TRUE;
					}
					else
					{
	
						parent = get_ui_object_parent (obj);
	
						if (parent)
						{
	
							graphic = get_ui_object_graphic (parent);
	
							ui_draw_part_alpha_graphic (x1, y1, x2, y2, x1, y1, graphic);
	
							redraw_flag = TRUE;
						}
					}
	
					break;
				}
	
				case UI_OBJECT_ZOOMABLE_PALETTE_GRAPHIC:
				{
		
					if (!get_ui_object_clear (obj))
					{
	
						zoomable_graphic = get_ui_object_zoomable_palette_graphic (obj);
	
						draw_zoomable_graphic (zoomable_graphic, area->cx, area->cy, x1, y1, x2, y2, area->zoom);
	
						redraw_flag = TRUE;
					}
	
					break;
				}
	
				case UI_OBJECT_NO_GRAPHIC:
				default:
				{
	
					if (!get_ui_object_clear (obj))
					{
	
						ui_draw_area (x1, y1, x2, y2);
	
						redraw_flag = TRUE;
					}
				}
			}
	
			// text position
	
			if (get_ui_object_text (obj))
			{
	
				font_id = get_ui_font ();
	
				set_ui_font (get_ui_object_font (obj));
	
				get_text_position (&x, &y, x1, y1, x2, y2, obj);
		
				ui_display_text (get_ui_object_text (obj), x, y);
	
				set_ui_font (font_id);
	
				redraw_flag = TRUE;
			}
	
			if (redraw_flag)
			{
		
				set_ui_repaint_area (x1 + ui_x_origin, y1 + ui_y_origin, x2 + ui_x_origin + 1, y2 + ui_y_origin + 1);
			}
	
			unlock_screen (active_screen);
		}

		set_active_screen (old_active_screen);

		area->redraw --;

		call_ui_object_draw_function (obj, NULL);
	}
}
Beispiel #7
0
static void draw_button_ui_object (ui_object *obj)
{

	float
//		px1,
//		py1,
		x,
		//y,
		//vp_x1,
		//vp_y1,
		//vp_x2,
		//vp_y2,
		x_size,
		y_size,
		x_origin,
		y_origin,
		x1,
		y1,
		x2,
		y2;
		//nx1,
		//ny1,
		//nx2,
		//ny2;

	int
		redraw_flag = FALSE;
//		width,
//		height,
//		pitch;

	struct SCREEN
		*old_active_screen;
//		*memory_graphic;

//	unsigned short
//		*graphic;

//	unsigned char
//		*data;

//	ui_object
//		*parent;

	button_ui_object
		*button;

	button = obj->button;

	if (get_ui_object_redraw (obj))
	{

		if (get_ui_object_autosize (obj))
		{

			ui_object_autosize (obj);
		}

		//debug_log ("BU_DRAW: drawing button %f, %f  %f, %f", button->area.x, button->area.y, button->area.x_size, button->area.y_size);

		//x1 = get_ui_object_x (obj);
		//y1 = get_ui_object_y (obj);

		x_size = get_ui_object_x_size (obj);
		y_size = get_ui_object_y_size (obj);
	
		x_origin = get_ui_object_x_origin (obj);
		y_origin = get_ui_object_y_origin (obj);
	
		ui_set_origin (x_origin, y_origin);


		//x2 = x1 + x_size;// - 1;
		//y2 = y1 + y_size;// - 1;

		x1 = get_ui_object_x (obj);
		y1 = get_ui_object_y (obj);

		x1 += x_origin;
		y1 += y_origin;

		x2 = x1 + get_ui_object_x_size (obj);
		y2 = y1 + get_ui_object_y_size (obj);

		old_active_screen = get_active_screen ();

		if (get_ui_object_active_screen (obj))
		{
	
			set_active_screen (get_ui_object_active_screen (obj));
		}
		else
		{

			set_active_screen (video_screen);
		}

		// debug
		set_active_screen (video_screen);
		// debug

//		if (lock_screen (active_screen))
		{

//			memory_graphic = get_ui_object_memory_graphic (obj);
	
			if (!get_ui_object_clear (obj))
			{
	
				switch (get_ui_object_graphic_type (obj))
				{

					case UI_OBJECT_TEXTURE_GRAPHIC:
					{
			
						texture_graphic
							*graphic;
					
						if ((get_ui_object_state (obj) == UI_OBJECT_STATE_ON) && (get_ui_object_selected_texture_graphic (obj)))
						{
					
							graphic = get_ui_object_selected_texture_graphic (obj);
						}
						else if ((get_ui_object_highlighted (obj)) && (get_ui_object_highlighted_texture_graphic (obj)))
						{
					
							graphic = get_ui_object_highlighted_texture_graphic (obj);
						}
						else
						{
					
							graphic = get_ui_object_texture_graphic (obj);
						}
			
						if (graphic)
						{

							rgb_colour
								colour;

							real_colour
								text_colour;

							colour = get_ui_object_colour ( obj );

							text_colour.red = colour.r;
							text_colour.green = colour.g;
							text_colour.blue = colour.b;
							text_colour.alpha = colour.a;

							ui_draw_texture_graphic (x1, y1, x2, y2, graphic, text_colour);
						}
						else
						{
				
							ui_draw_area (0, 0, x2 - x1, y2 - y1, obj);
						}
				
						break;
					}
/*
					case UI_OBJECT_GRAPHIC:
					{
			
						if (get_ui_object_state (obj) == UI_OBJECT_STATE_ON)
						{
		
							graphic = get_ui_object_graphic (obj);
		
							ui_draw_graphic (x1, y1, x2, y2, graphic);
	
							redraw_flag = TRUE;
						}
						else
						{
	
							parent = get_ui_object_parent (obj);
	
							if (parent)
							{
	
								graphic = get_ui_object_graphic (parent);
	
								px1 = get_ui_object_x (parent);
	
								py1 = get_ui_object_y (parent);
	
								x1 -= px1;
								x2 -= px1;
	
								y1 -= py1;
								y2 -= py1;
		
								ui_draw_part_graphic (x1, y1, x2, y2, x1, y1, graphic);
	
								redraw_flag = TRUE;
							}
						}
	
						break;
					}
	
					case UI_OBJECT_MEMORY_GRAPHIC:
					{
		
						memory_graphic = get_ui_object_memory_graphic (obj);
	
						if (lock_screen (memory_graphic))
						{
		
							width = get_screen_width (memory_graphic);
		
							height = get_screen_height (memory_graphic);
		
							data = get_screen_data (memory_graphic);
		
							pitch = get_screen_pitch (memory_graphic);
			
							ui_draw_memory_graphic (obj, x1, y1, x2, y2, width, height, pitch, FALSE);
		
							unlock_screen (memory_graphic);
						}
	
						redraw_flag = TRUE;
	
						break;
					}
	
					case UI_OBJECT_ALPHA_GRAPHIC:
					{
			
						if (!get_ui_object_clear (obj))
						{
			
							graphic = get_ui_object_graphic (obj);
		
							ui_draw_alpha_graphic (x1, y1, x2, y2, graphic);
		
							redraw_flag = TRUE;
						}
						else
						{
		
							parent = get_ui_object_parent (obj);
		
							if (parent)
							{
		
								graphic = get_ui_object_graphic (parent);
		
								ui_draw_part_alpha_graphic (x1, y1, x2, y2, x1, y1, graphic);
		
								redraw_flag = TRUE;
							}
						}
		
						break;
					}
*/
					case UI_OBJECT_NO_GRAPHIC:
					default:
					{

						int
							state;

						state = get_ui_object_state (obj);

						if ((state == UI_OBJECT_STATE_OFF) && (get_ui_object_highlighted (obj)))
						{

							state = UI_OBJECT_STATE_HIGHLIGHTED;
						}

						ui_draw_button (x1, y1, x2, y2, state);
	
						redraw_flag = TRUE;
					}
				}
			}
		
			if (get_ui_object_text (obj))
			{

				const char
					*text_ptr;

				int
					count;

				float
					y3;
	
				ui_save_current_font ();

				ui_set_object_font (obj);

				// count number of lines spanned

				text_ptr = get_ui_object_text (obj);

				count = 0;

				while (text_ptr)
				{

					count ++;

					text_ptr = strchr (text_ptr, '\n');

					// if found, step over it and display the next part of string
					if (text_ptr)
					{

						text_ptr ++;
					}
				}

				// now draw text

				text_ptr = get_ui_object_text (obj);
			
				get_text_y_position (&y3, y1, y2, text_ptr, get_ui_object_text_justify (obj), count);

				while (text_ptr)
				{
			
					get_text_x_position (&x, x1, x2, text_ptr, get_ui_object_text_justify (obj));
			
					ui_display_text (text_ptr, x, y3);

					y3 += ui_get_font_height ();

					// check for carriage return
					text_ptr = strchr (text_ptr, '\n');

					// if found, step over it and display the next part of string
					if (text_ptr)
					{

						text_ptr ++;
					}
				}

				ui_restore_current_font ();
	
				redraw_flag = TRUE;
			}
	
			if (redraw_flag)
			{
	
				set_ui_repaint_area (x1 - 1, y1 - 1, x2 + 1, y2 + 1);
			}
	
//			unlock_screen (active_screen);
		}

		set_active_screen (old_active_screen);

		button->area.redraw --;

		call_ui_object_draw_function (obj, NULL);
	}
}
Beispiel #8
0
void main_sof_action(void)
{
	// LCD strings for on-board sensors
	static uint8_t lcd_txt_light[LCD_TEXT_STRING_SIZE + 2 * LCD_TEST_DISPLAY_SIZE]
			= "LIGHT SENSOR     ";
	static uint8_t lcd_txt_ntc[LCD_TEXT_STRING_SIZE + 2 * LCD_TEST_DISPLAY_SIZE]
			= "TEMPERATURE SENSOR     ";
	static uint8_t lcd_txt_pot[LCD_TEXT_STRING_SIZE + 2 * LCD_TEST_DISPLAY_SIZE]
			= "POTENTIOMETER INPUT     ";
	static uint8_t lcd_txt_ext_v[LCD_TEXT_STRING_SIZE + 2 * LCD_TEST_DISPLAY_SIZE]
			= "EXTERNAL VOLTAGE    ";

	static uint8_t old_button;

	if (main_timeout_user_message) {
		// Currently LCD is busy displaying user message from USB
		// Wait end of timeout to display again sensor message
		if (--main_timeout_user_message == 0) {
			switch (main_sensor_selected) {
			case LIGHT_SENSOR:
				ui_display_text(lcd_txt_light,
					sizeof(lcd_txt_light));
				break;
			case TEMPERATURE_SENSOR:
				ui_display_text(lcd_txt_ntc,
					sizeof(lcd_txt_ntc));
				break;
			case POTENTIOMETER_SENSOR:
				ui_display_text(lcd_txt_pot,
					sizeof(lcd_txt_pot));
				break;
			case EXT_VOLTAGE_INPUT:
				ui_display_text(lcd_txt_ext_v,
					sizeof(lcd_txt_ext_v));
			default:
				break;
			}
		}
	}

	// Change LOCAL text display when a button is pressed...
	if (old_button!=ui_button()) {
		old_button=ui_button();
		if (ui_pusb_button_0()) {
			ui_display_text(lcd_txt_light, sizeof(lcd_txt_light));
			main_sensor_selected = LIGHT_SENSOR;
		}
		if (ui_pusb_button_1()) {
			ui_display_text(lcd_txt_ntc, sizeof(lcd_txt_ntc));
			main_sensor_selected = TEMPERATURE_SENSOR;
		}
		if (ui_pusb_button_2()) {
			ui_display_text(lcd_txt_pot, sizeof(lcd_txt_pot));
			main_sensor_selected = POTENTIOMETER_SENSOR;
		}
		if (ui_pusb_button_3()) {
			ui_display_text(lcd_txt_ext_v, sizeof(lcd_txt_ext_v));
			main_sensor_selected = EXT_VOLTAGE_INPUT;
		}
		// If hid generic interface is not up and running, do nothing
		if (!main_b_generic_enable) {
			return;
		}
	}

	// Prepare new report each HID_SEND_REPORT_MS ms
	if ((udd_get_frame_number() % HID_SEND_REPORT_MS) == 0) {
		usb_hid_com_send_report_in();
	}

	// Prepare new ADC samples each ADC_NEW_SAMPLE_MS ms
	if ((udd_get_frame_number() % ADC_NEW_SAMPLE_MS) == 0) {
		adc_sensors_start_conversions();
	}

	// Each LCD_SCROLLING_MS ms Performs LCD scrolling
	if ((udd_get_frame_number() % LCD_SCROLLING_MS) == 0) {
		ui_scroll_text();
	}

	// Refresh on-board sensors LCD display
	// each LCD_SENSOR_MS and if no user message is displayed
	if (((udd_get_frame_number() % LCD_SENSOR_MS) == 0)
		&& (main_timeout_user_message == 0)) {
		switch (main_sensor_selected) {
		case LIGHT_SENSOR:
			ui_display_sensor(adc_sensor_get_light(),
					UI_UNIT_NONE);
			break;
		case TEMPERATURE_SENSOR:
			ui_display_sensor(adc_sensor_get_temperature(),
					UI_UNIT_DEGREE_C);
			break;
		case POTENTIOMETER_SENSOR:
			ui_display_sensor(adc_sensor_get_potentiometer(),
					UI_UNIT_MILIVOLT);
			break;
		case EXT_VOLTAGE_INPUT:
			ui_display_sensor(adc_sensor_get_ext_voltage(),
					UI_UNIT_MILIVOLT);
		default:
			break;
		}
	}
}
Beispiel #9
0
void draw_high_score_table (void)
{

	char
		buffer [256];

	int
		loop,
		length;

	screen
		*old_active_screen;

	pilot_score_type
		*item;

	old_active_screen = get_active_screen ();

	set_active_screen ( video_screen );

	if ( lock_screen ( active_screen ) )
	{
		//
		// draw leaderboard
		//
		
		for (loop = 0; loop < NUM_TABLE_ENTRIES; loop ++)
		{
			item = &pilot_high_score_table [loop];
			
			if (item->valid)
			{
				set_ui_font_type (UI_FONT_ARIAL_14);

				if (item->side == ENTITY_SIDE_BLUE_FORCE)
				{
					set_ui_font_colour (ui_colour_blue);
				}
				else
				{
					set_ui_font_colour (ui_colour_orange);
				}

				length = ui_get_string_length (item->name);
	
				sprintf (buffer, "%s : %d", item->name, item->kills);

				// print text assuming game-exit overlay is 640x480 centred in the screen whatever res.
				ui_display_text (buffer, get_integer_screen_x_mid () - length, iy_640_480 + 180 + (loop * (ui_get_font_height () + 1)));
			}
		}

		//
		// update flash timer
		//

		flash_timer += (FLASH_RATE * get_delta_time ());

		flash_timer = frac (flash_timer);

		unlock_screen ( active_screen );
	}

	set_active_screen ( old_active_screen );
}