Exemple #1
0
static void sig_dialog(void)
{
	const char *label = pdf_field_label(ctx, sig_widget->obj);

	ui_dialog_begin(400, (ui.gridsize+4)*3 + ui.lineheight*10);
	{
		ui_layout(T, X, NW, 2, 2);

		ui_label("%s", label);
		ui_spacer();

		if (sig_result)
			ui_label("Signature is valid.\n%s", sig_status);
		else
			ui_label("Could not verify signature:\n%s", sig_status);

		ui_layout(B, X, NW, 2, 2);
		ui_panel_begin(0, ui.gridsize, 0, 0, 0);
		{
			ui_layout(R, NONE, S, 0, 0);
			if (ui_button("Cancel") || (!ui.focus && ui.key == KEY_ESCAPE))
				ui.dialog = NULL;
			ui_spacer();
			if (ui_button("Sign"))
			{
				fz_strlcpy(cert_filename, filename, sizeof cert_filename);
				ui_init_open_file(".", cert_file_filter);
				ui.dialog = cert_file_dialog;
			}
		}
		ui_panel_end();
	}
	ui_dialog_end();
}
Exemple #2
0
static void tx_dialog(void)
{
	int ff = pdf_field_flags(ctx, tx_widget->obj);
	const char *label = pdf_field_label(ctx, tx_widget->obj);
	int tx_h = (ff & PDF_TX_FIELD_IS_MULTILINE) ? 10 : 1;
	int lbl_h = ui_break_lines((char*)label, NULL, 20, 394, NULL);
	int is;

	ui_dialog_begin(400, (ui.gridsize+4)*3 + ui.lineheight*(tx_h+lbl_h-2));
	{
		ui_layout(T, X, NW, 2, 2);
		ui_label("%s", label);
		is = ui_input(&tx_input, 200, tx_h);

		ui_layout(B, X, NW, 2, 2);
		ui_panel_begin(0, ui.gridsize, 0, 0, 0);
		{
			ui_layout(R, NONE, S, 0, 0);
			if (ui_button("Cancel") || (!ui.focus && ui.key == KEY_ESCAPE))
				ui.dialog = NULL;
			ui_spacer();
			if (ui_button("Okay") || is == UI_INPUT_ACCEPT)
			{
				pdf_set_text_field_value(ctx, tx_widget, tx_input.text);
				if (pdf_update_page(ctx, tx_widget->page))
					render_page();
				ui.dialog = NULL;
			}
		}
		ui_panel_end();
	}
	ui_dialog_end();
}
Exemple #3
0
static void cert_password_dialog(void)
{
	int is;
	ui_dialog_begin(400, (ui.gridsize+4)*3);
	{
		ui_layout(T, X, NW, 2, 2);
		ui_label("Password:"******"Cancel"))
				ui.dialog = NULL;
			ui_spacer();
			if (ui_button("Okay") || is == UI_INPUT_ACCEPT)
			{
				ui.dialog = NULL;
				do_sign();
			}
		}
		ui_panel_end();
	}
	ui_dialog_end();
}
Exemple #4
0
/*! \brief Main function. Execution starts here.
 */
int main(void)
{
	//Initialize interrupt controller
	irq_initialize_vectors();
	cpu_irq_enable();

	// Initialize sleep manager
	sleepmgr_init();
	// Initialize clock tree
	sysclk_init();
	// Initialize hardware board resources
	board_init();

	// Initialize user interface
	ui_init();
	ui_powerdown();

	// Sanity check about Silicon revision Vs Firmware build
	// for Silicon revision A, firmware should be specific
	if ((!firmware_rev_a) && (nvm_read_device_rev()==0)) {
		ui_si_revision_error();
		while(ui_button()!=1);
		while(ui_button()!=2);
		while(ui_button()!=4);
		while(ui_button()!=8);
	}

	// Initialize DATA Flash
	at45dbx_init();

	// Initialize ADC for on-board sensors
	adc_sensors_init();

	// Initialize USB HID report protocol
	usb_hid_com_init();

	// Start USB stack
	main_build_usb_serial_number();
	udc_start();

	// The main loop manages only the power mode
	// because everything else is managed by interrupt.
	// The USB Start of Frame event manages internal tick events for
	// on-board sensor updates as well as LCD display update.
	while (true) {
		if (main_b_msc_enable) {
			if (!udi_msc_process_trans()) {
				sleepmgr_enter_sleep();
			}
		} else {
			sleepmgr_enter_sleep();
		}
		if (usb_hid_com_is_start_dfu()) {
			main_start_dfu_session();
		}
	}
}
Exemple #5
0
static void ch_dialog(void)
{
	const char *label;
	const char *value;
	const char **options;
	int n, choice;
	int label_h;

	label = pdf_field_label(ctx, ch_widget->obj);
	label_h = ui_break_lines((char*)label, NULL, 20, 394, NULL);
	n = pdf_choice_widget_options(ctx, ch_widget->page->doc, ch_widget, 0, NULL);
	options = fz_malloc_array(ctx, n, sizeof(char*));
	pdf_choice_widget_options(ctx, ch_widget->page->doc, ch_widget, 0, options);
	value = pdf_field_value(ctx, ch_widget->obj);

	ui_dialog_begin(400, (ui.gridsize+4)*3 + ui.lineheight*(label_h-1));
	{
		ui_layout(T, X, NW, 2, 2);

		ui_label("%s", label);
		choice = ui_select("Widget/Ch", value, options, n);
		if (choice >= 0)
			pdf_set_choice_field_value(ctx, ch_widget, options[choice]);

		ui_layout(B, X, NW, 2, 2);
		ui_panel_begin(0, ui.gridsize, 0, 0, 0);
		{
			ui_layout(R, NONE, S, 0, 0);
			if (ui_button("Cancel") || (!ui.focus && ui.key == KEY_ESCAPE))
				ui.dialog = NULL;
			ui_spacer();
			if (ui_button("Okay"))
			{
				if (pdf_update_page(ctx, ch_widget->page))
					render_page();
				ui.dialog = NULL;
			}
		}
		ui_panel_end();
	}
	ui_dialog_end();

	fz_free(ctx, options);
}
Exemple #6
0
void g::menu_level::init_buttons()
{
    this->delta = 0.0;
    this->current = 0.0;
    this->direction = 0;
    if(this->levpackmenu)
    {
        this->buttons.clear();
        for(size_t i = 0; i < this->levels.size(); i++)
            this->buttons.push_back(ui_button());
    }
    else
    {
        this->buttons.clear();
        this->current_pack = this->lev_selected();
        for(size_t i = 0; i < this->levels[this->current_pack].size(); i++)
            this->buttons.push_back(ui_button());
    }
    this->update_button_positions(program_exe::get_instance().glfw->opengl);
}
Exemple #7
0
void usb_hid_com_send_report_in(void)
{
	// Fill HID report fields
	report_to_send.light = adc_sensor_get_light();
	report_to_send.temperature = adc_sensor_get_temperature();
	report_to_send.ext_voltage = adc_sensor_get_ext_voltage();
	report_to_send.potentiometer = adc_sensor_get_potentiometer();
	report_to_send.buttons = ui_button();
	report_to_send.sensor_selected = main_get_sensor_selected();
	// Send HID report in background
	udi_hid_generic_send_report_in((uint8_t*)&report_to_send);
}
void main_sof_action(void)
{
	static bool btn_last_state = 0;
	bool btn_state = ui_button();
	
	if (!main_b_generic_enable)
		return;
	ui_process(udd_get_frame_number());
	if(btn_state!=btn_last_state) {
		report_to_send[0]=btn_state;
		udi_hid_generic_send_report_in(report_to_send);
	}
	btn_last_state=btn_state;

}
Exemple #9
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;
		}
	}
}
Exemple #10
0
int ui_save_file(char filename[PATH_MAX], void (*extra_panel)(void))
{
	int i, rv = 0;

	ui_panel_begin(0, 0, 4, 4, 1);
	{
		ui_layout(L, Y, NW, 0, 0);
		ui_panel_begin(150, 0, 0, 0, 0);
		{
			ui_layout(T, X, NW, 2, 2);
			list_drives();
			if (extra_panel)
			{
				ui_spacer();
				extra_panel();
			}
			ui_layout(B, X, NW, 2, 2);
			if (ui_button("Cancel") || (!ui.focus && ui.key == KEY_ESCAPE))
			{
				filename[0] = 0;
				rv = 1;
			}
		}
		ui_panel_end();

		ui_layout(T, X, NW, 2, 2);
		if (ui_input(&fc.input_dir, 0, 1) == UI_INPUT_ACCEPT)
			load_dir(fc.input_dir.text);

		ui_layout(T, X, NW, 2, 2);
		ui_panel_begin(0, ui.gridsize, 0, 0, 0);
		{
			ui_layout(R, NONE, CENTER, 0, 0);
			if (ui_button("Save"))
			{
				fz_snprintf(filename, PATH_MAX, "%s/%s", fc.curdir, fc.input_file.text);
				rv = 1;
			}
			ui_spacer();
			if (ui_button("\xe2\x9e\x95")) /* U+2795 HEAVY PLUS */
				bump_file_version(1);
			if (ui_button("\xe2\x9e\x96")) /* U+2796 HEAVY MINUS */
				bump_file_version(-1);
			ui_spacer();
			ui_layout(ALL, X, CENTER, 0, 0);
			ui_input(&fc.input_file, 0, 1);
		}
		ui_panel_end();

		ui_layout(ALL, BOTH, NW, 2, 2);
		ui_list_begin(&fc.list_dir, fc.count, 0, 0);
		for (i = 0; i < fc.count; ++i)
		{
			const char *name = fc.files[i].name;
			char buf[PATH_MAX];
			if (fc.files[i].is_dir)
				fz_snprintf(buf, sizeof buf, "\xf0\x9f\x93\x81 %s", name);
			else
				fz_snprintf(buf, sizeof buf, "\xf0\x9f\x93\x84 %s", name);
			if (ui_list_item(&fc.list_dir, &fc.files[i], buf, i==fc.selected))
			{
				fc.selected = i;
				if (fc.files[i].is_dir)
				{
					fz_snprintf(buf, sizeof buf, "%s/%s", fc.curdir, name);
					load_dir(buf);
					ui.active = NULL;
				}
				else
				{
					ui_input_init(&fc.input_file, name);
				}
			}
		}
		ui_list_end(&fc.list_dir);
	}
	ui_panel_end();

	return rv;
}
Exemple #11
0
int ui_open_file(char filename[PATH_MAX])
{
	static int last_click_time = 0;
	static int last_click_sel = -1;
	int i, rv = 0;

	ui_panel_begin(0, 0, 4, 4, 1);
	{
		ui_layout(L, Y, NW, 0, 0);
		ui_panel_begin(150, 0, 0, 0, 0);
		{
			ui_layout(T, X, NW, 2, 2);
			list_drives();
			ui_layout(B, X, NW, 2, 2);
			if (ui_button("Cancel") || (!ui.focus && ui.key == KEY_ESCAPE))
			{
				filename[0] = 0;
				rv = 1;
			}
		}
		ui_panel_end();

		ui_layout(T, X, NW, 2, 2);
		ui_panel_begin(0, ui.gridsize, 0, 0, 0);
		{
			if (fc.selected >= 0)
			{
				ui_layout(R, NONE, CENTER, 0, 0);
				if (ui_button("Open") || (!ui.focus && ui.key == KEY_ENTER))
				{
					fz_snprintf(filename, PATH_MAX, "%s/%s", fc.curdir, fc.files[fc.selected].name);
					rv = 1;
				}
				ui_spacer();
			}
			ui_layout(ALL, X, CENTER, 0, 0);
			if (ui_input(&fc.input_dir, 0, 1) == UI_INPUT_ACCEPT)
				load_dir(fc.input_dir.text);
		}
		ui_panel_end();

		ui_layout(ALL, BOTH, NW, 2, 2);
		ui_list_begin(&fc.list_dir, fc.count, 0, 0);
		for (i = 0; i < fc.count; ++i)
		{
			const char *name = fc.files[i].name;
			char buf[PATH_MAX];
			if (fc.files[i].is_dir)
				fz_snprintf(buf, sizeof buf, "%C %s", ICON_FOLDER, name);
			else
				fz_snprintf(buf, sizeof buf, "%C %s", ICON_DOCUMENT, name);
			if (ui_list_item(&fc.list_dir, &fc.files[i], buf, i==fc.selected))
			{
				fc.selected = i;
				if (fc.files[i].is_dir)
				{
					fz_snprintf(buf, sizeof buf, "%s/%s", fc.curdir, name);
					load_dir(buf);
					ui.active = NULL;
					last_click_sel = -1;
				}
				else
				{
					int click_time = glutGet(GLUT_ELAPSED_TIME);
					if (i == last_click_sel && click_time < last_click_time + 250)
					{
						fz_snprintf(filename, PATH_MAX, "%s/%s", fc.curdir, name);
						rv = 1;
					}
					last_click_time = click_time;
					last_click_sel = i;
				}
			}
		}
		ui_list_end(&fc.list_dir);
	}
	ui_panel_end();

	return rv;
}