Пример #1
0
void print_events()
{
	char ts[30];
	
	send_string("Number of events: ");
	sprintf(ts, "%d", events_count);
	send_string(ts);
	send_enter();
	
	for (uint8_t i = 0; i < events_count; i++)
	{
		print_event(i);
	}
	
}
Пример #2
0
void load_events()
{
	// initialize random number generator; it has to be done only once (after reset)
	srand(current_time());
	
	events_count = eeprom_read_byte(&events_count_ee);
	
	// initialize - for testing purposes
	/*
	if (events_count == 0)
	{
	send_string("add_default\r\n");
	add_default_events();
	}
	*/
	
	if (events_count == 0)
	{
		send_line("No events => MANUAL_MODE");
		event_mode = MANUAL_MODE;
		return;
	}
	
	// load events into ram
	eeprom_read_block(&events, &events_ee, sizeof(struct Event) * EVENTS_SIZE);
	
	// prepare
	prepare_actual_events();
	
	// print events
	print_events();
	
	// check current state of pins
	// if the device is power off, and later power on - it doesn't know what should be current state of pins
	
	int32_t time = current_time();
	send_string(" start time: ");
	
	char formatted_date[30];
	timeToString(time, formatted_date);
	send_string(formatted_date);
	send_enter();
	
	current_state();
}
Пример #3
0
void Pointer::setFocus(Surface *surface, const QPoint &pos)
{
    if (m_focusResource && m_focus != surface) {
        uint32_t serial = m_compositor->nextSerial();
        send_leave(m_focusResource->handle, serial, m_focus->resource()->handle);
    }

    Resource *resource = surface ? resourceMap().value(surface->resource()->client()) : 0;

    if (resource && (m_focus != surface || resource != m_focusResource)) {
        uint32_t serial = m_compositor->nextSerial();
        send_enter(resource->handle, serial, surface->resource()->handle,
                   wl_fixed_from_int(pos.x()), wl_fixed_from_int(pos.y()));
    }

    m_focusResource = resource;
    m_focus = surface;
}
Пример #4
0
void Keyboard::setFocus(Surface *surface)
{
    if (m_focusResource && m_focus != surface) {
        uint32_t serial = m_compositor->nextSerial();
        send_leave(m_focusResource->handle, serial, m_focus->resource()->handle);
    }

    Resource *resource = surface ? resourceMap().value(surface->resource()->client()) : 0;

    if (resource && (m_focus != surface || m_focusResource != resource)) {
        uint32_t serial = m_compositor->nextSerial();
        send_modifiers(resource->handle, serial, 0, 0, 0, 0);
        send_enter(resource->handle, serial, surface->resource()->handle, QByteArray());
    }

    m_focusResource = resource;
    m_focus = surface;
}
Пример #5
0
void print_event(uint8_t event_number)
{
	struct Event event = events[event_number];
	
	// print pin
	switch (event.pin)
	{
		case PWM0_PD6:
		send_string(" PWM0_PD6 ");
		break;
		
		case PWM1_PD5:
		send_string(" PWM1_PD5 ");
		break;
		
		case PWM2_PB1:
		send_string(" PWM2_PB1 ");
		break;
		
		case PWM3_PD3:
		send_string(" PWM3_PD3 ");
		break;
		
		case EXP0_PC2:
		send_string(" EXP0_PC2 ");
		break;
		
		case EXP1_PD4:
		send_string(" EXP1_PD4 ");
		break;
		
		case EXP2_PD7:
		send_string(" EXP2_PD7 ");
		break;
		
		case EXP3_PB0:
		send_string(" EXP3_PB0 ");
		break;
		
		default:
		send_string(" unknown pin ");
		break;
	}
	
	if (event.type == EXP)
	send_string("EXP ");
	else if (event.type == PWM)
	send_string("PWM ");
	else if (event.type == CLOUDS)
	send_string("CLOUDS ");
	
	// event_time
	char formatted_date[30];
	timeToString(event.time, formatted_date);
	send_string(formatted_date);
	send_string(" ");
	
	if (event.type == EXP)
	{
		if (event.pin_state == 1)
		{
			// simple event
			send_string("HIGH ");
			
		} else if (event.pin_state == 0)
		{
			send_string("LOW ");
		}
		
	}
	else if (event.type == PWM)
	{
		send_int(event.pin_state);
		send_string("% ");
		
		if ((event.inc != 0) & (event.duration != 0))
		{
			send_int(event.inc);
			send_string("%/");
			send_int(event.duration / 60);
			send_string("[m] ");
		}
	}
	else if (event.type == CLOUDS)
	{
		send_int(event.pin_state);
		send_string("% ");
		
		send_int(event.inc);
		send_string("%/");
		send_int(event.temp_duration);
		send_string("[s] ");
	}
	
	send_enter();
}
Пример #6
0
void QWaylandKeyboardPrivate::sendEnter(QWaylandSurface *surface, Resource *keyboardResource)
{
    uint32_t serial = compositor()->nextSerial();
    send_modifiers(keyboardResource->handle, serial, modsDepressed, modsLatched, modsLocked, group);
    send_enter(keyboardResource->handle, serial, surface->resource(), QByteArray::fromRawData((char *)keys.data(), keys.size() * sizeof(uint32_t)));
}