예제 #1
0
void ui_usb_sof_event(void)
{
	static uint16_t counter_sof = 0;
	uint8_t i = 0;

	if (ui_enum_status == UHC_ENUM_SUCCESS) {
		if (++counter_sof > 2000) {
			counter_sof = 0;
		}

		if (read_complete_flag != AOA_READ_ONGOING) {
			if (read_complete_flag == AOA_READ_SUCCESS) {
				ui_usb_message_reception();
			}

			read_complete_flag = AOA_READ_ONGOING;
			uhi_aoa_read(ui_msg, sizeof(ui_msg), read_complete);
		}

		/* Buttons */
		for (i = 0; i < 5; i++) {
			if (button_changed(i)) {
				ui_button_state[i] = !ui_button_state[i];
				ui_msg[0] = MESSAGE_ATD_SIMPLE_SWITCH;
				ui_msg[1] = i;
				ui_msg[2] = ui_button_state[i];
				uhi_aoa_write(ui_msg, 3, NULL);
				ui_button_state_toggle[i] = 0;
			}
		}
	}
}
예제 #2
0
void Pbutton::on_off(quint8 newstate)
{
    quint8 aux;

    if (newstate) {
        aux = 0;
    } else {
        aux = 1;
    }

    emit button_changed(aux);
}
예제 #3
0
void Pbutton::change_state(quint8 newstate)
{
    //Detect rising edge
    if (pin_state ==  0 && newstate == 1) {

        //Update the state of the button only on rising edge!
        if (state == 0) {
            state = 1;
        } else {
            state = 0;
        }

        emit button_changed(state);
    }

    pin_state = newstate;
}