Exemplo n.º 1
0
static GdkFilterReturn
popup_filter (GdkXEvent *gdk_xevent,
	      GdkEvent  *event,
	      GtkWidget *popup)
{
	XEvent *xevent = (XEvent *) gdk_xevent;
	XIEvent *xiev;
	XIDeviceEvent *xidev;

	switch (xevent->type) {
	case ButtonPress:
		handle_button_press_event (popup, xevent->xbutton.display, xevent->xbutton.subwindow);
		return GDK_FILTER_REMOVE;
	case KeyPress:
		if (xevent->xkey.keycode == XKeysymToKeycode (xevent->xany.display, XK_Escape)) {
			remove_popup (popup);
			return GDK_FILTER_REMOVE;
		}
		break;
	case GenericEvent:
		xiev = (XIEvent *) xevent->xcookie.data;
		xidev = (XIDeviceEvent *) xiev;
		switch (xiev->evtype) {
		case XI_KeyPress:
			if (xidev->detail == XKeysymToKeycode (xevent->xany.display, XK_Escape)) {
				remove_popup (popup);
				return GDK_FILTER_REMOVE;
			}
			break;
		case XI_ButtonPress:
			handle_button_press_event (popup, xidev->display, xidev->child);
			return GDK_FILTER_REMOVE;
		}
		break;
	default:
		break;
	}

	return GDK_FILTER_CONTINUE;
}
Exemplo n.º 2
0
static GdkFilterReturn
popup_filter (GdkXEvent *gdk_xevent,
	      GdkEvent  *event,
	      GtkWidget *popup)
{
	XEvent *xevent = (XEvent *) gdk_xevent;

	switch (xevent->type) {
	case ButtonPress:
		handle_button_press_event (popup, &xevent->xkey);
		return GDK_FILTER_REMOVE;
	case KeyPress:
		if (xevent->xkey.keycode == XKeysymToKeycode (xevent->xany.display, XK_Escape)) {
			remove_popup (popup);
			return GDK_FILTER_REMOVE;
		}
		break;
	default:
		break;
	}

	return GDK_FILTER_CONTINUE;
}
Exemplo n.º 3
0
static void interrupt_event_handler(void *data)
{
	struct event_info *info = data;
	struct slot *p_slot = info->p_slot;

	mutex_lock(&p_slot->lock);
	switch (info->event_type) {
	case INT_BUTTON_PRESS:
		handle_button_press_event(p_slot);
		break;
	case INT_POWER_FAULT:
		dbg("%s: power fault\n", __FUNCTION__);
		p_slot->hpc_ops->set_attention_status(p_slot, 1);
		p_slot->hpc_ops->green_led_off(p_slot);
		break;
	default:
		update_slot_info(p_slot);
		break;
	}
	mutex_unlock(&p_slot->lock);

	kfree(info);
}
Exemplo n.º 4
0
void Task_SmartPHTApp(void)
{
    message_t msg;
    adc_voltages_t *v;
    sensor_data_t *c;
    byte_t comRecvByte;
  
    if (knl_mailbox_pend(&taskMailbox, &msg) == RV_OK) {
        switch (msg.MsgId) {
            case MSG_ID_SYS_VOLTAGE_UPDATE:
                v = (adc_voltages_t*) msg.Param0;
                //tiny_printf("SYS: Vbat=%dmV, Vcc=%dmV, Vdd=%dmV, Vtft=%dmV\n", v->vbat, v->vcc, v->vdd, v->vtft);

//                if(v->vdd < 3000)
//                    tty_output("SYS: system voltage is low!\n");
//                if(v->vbat < 3300)
//                    tty_output("SYS: BATTERY LOW! replace or battery can be damaged\n");

                break;

            case MSG_ID_SYS_BATTERY_STAT:
//                if(msg.Param0 == BAT_CHARGE_COMPLETE)
//                    tty_output("SYS: battery charge complete.\n");
//                if(msg.Param0 == BAT_CHARGING)
//                    tty_output("SYS: charging...\n");
//                if(msg.Param0 == BAT_SHUTDOWN)
//                    tty_output("SYS: charger shtdn.\n");
//                break;
                break;

            case MSG_ID_USB_STATE_CHANGED:
                handle_usb_change(msg.Param0);
                break;

            case MSG_ID_SENSOR_UPDATE:
                c = (sensor_data_t*) msg.Param0;

                filter(&dashboardData.pressure, c->compensated.hp_pressure);
                filter(&dashboardData.humidity, c->compensated.sht_humidity);
                filter(&dashboardData.temperature, c->compensated.sht_temperature);

                update_min_max(&dashboardData.pressure);
                update_min_max(&dashboardData.humidity);
                update_min_max(&dashboardData.temperature);

                check_alarms();

                // update waveforms
                wfrm_put_sample(&wfrmPressure, dashboardData.pressure.val);
                wfrm_put_sample(&wfrmHumidity, dashboardData.humidity.val);
                wfrm_put_sample(&wfrmTemperature, dashboardData.temperature.val);

                // Write to file
                write_samples_to_file(c, (rtc_time_t*) msg.Param1);

                gui_invalidate(&dashb);
                gui_invalidate(&lineplot);
                break;

            case MSG_ID_MEDIA_DETECTED:
                //tty_output("SDCARD: inserted.");
                //if(msg.Param0) tty_output(" Card is write protected!");
                //tty_output("\n");

                sd_register();

                f_close(&samplesFile);

                // Mount filesystem
                f_mount(0, &filesystem);

                // Try open file;
                sampleFileIsOpen = try_open_file();
                
                // Change statusbar
                toolbar_set_status(&statusbar, STATUS_SDCARD_PRESENT);
                break;

            case MSG_ID_MEDIA_DISAPPEARED:
                //tty_output("SDCARD: removed\n");

                // Dismount file system
                f_mount(0, NULL);
                
                // Change statusbar
                toolbar_clear_status(&statusbar, STATUS_SDCARD_PRESENT);
                break;

            case MSG_ID_WDG_PRESSED:
                handle_button_press_event(msg.Param0);
                break;

            case MSG_ID_WDG_DELAYED_OP:
                handle_delayed_operation_event(msg.Param0);
                break;

            case MSG_ID_WDG_CHECKED:
                handle_button_checked_event(msg.Param0);
                break;

            case MSG_ID_WDG_INVALIDATE:     // GUI needs to be redrawn
                gui_draw();
                break;

            case MSG_ID_LPM_REQUEST:
                enter_sleep_mode();
                break;

            case MSG_ID_TOUCH_EVENT:

//                // Draw cursor
//                if(msg.Param0 == TOUCH_EVENT_PANEL_PRESSED)
//                {
//                    uint16_t i, j;
//                    i = msg.Param1;
//                    j = msg.Param2;
//
//                    if(i < 12) i = 12;
//                    else if(i > 467) i = 467;
//                    if(j < 12) j = 12;
//                    else if(j > 260) j = 260;
//
//                    gfx_set_color(COLOR_WHITE);
//                    gfx_draw_circle(i, j , 10);
//                }

                if(!darkenScreen)
                {
                    set_brightness(lightenBrightness);
                }
                darkenScreen = bTrue;
                // no break, gui must get this msg too
                
            default:
                gui_msg(&msg);
                break;
        }
    }

    // COMMAND PARSER
    if(usb_device_state == CONFIGURED_STATE)
        if (poll_getc_cdc(&comRecvByte)) {
            putc_cdc(comRecvByte); // echo
            CDC_Flush_In_Now();		

            cmd_parse_char(comRecvByte);
        }
}