Ejemplo n.º 1
0
void ui_process(uint16_t framenumber)
{
	static uint8_t cpt_sof = 0;
	bool b_btn_state;
	static bool btn0_last_state = false;
	static bool btn1_last_state = false;

	if ((framenumber % 1000) == 0) {
		LED_On(LED1_GPIO);
	}

	if ((framenumber % 1000) == 500) {
		LED_Off(LED1_GPIO);
	}

	/* Scan process running each 20ms */
	cpt_sof++;
	if (20 > cpt_sof) {
		return;
	}

	cpt_sof = 0;

	/* Scan buttons on switch 0 (left), 1 (middle), 2 (right) */
	b_btn_state = gpio_pin_is_low(GPIO_PUSH_BUTTON_0);
	if (b_btn_state != btn0_last_state) {
		btn0_last_state = b_btn_state;
		if (b_btn_state) {
			ieee11073_skeleton_send_measure_1();
		}
	}

	b_btn_state = gpio_pin_is_low(GPIO_PUSH_BUTTON_1);
	if (b_btn_state != btn1_last_state) {
		btn1_last_state = b_btn_state;
		if (b_btn_state) {
			ieee11073_skeleton_send_measure_2();
		}
	}
}
Ejemplo n.º 2
0
void ui_process(uint16_t framenumber)
{
	static uint8_t cpt_sof = 0;
	bool b_btn_state;
	static bool btn0_last_state = false;
	static bool btn1_last_state = false;

	if ((framenumber % 1000) == 0) {
		LED_On(LED0_GPIO);
	}

	if ((framenumber % 1000) == 500) {
		LED_Off(LED0_GPIO);
	}

	/* Scan process running each 20ms */
	cpt_sof++;
	if (20 > cpt_sof) {
		return;
	}

	cpt_sof = 0;

	/* Use buttons to send measures */
	b_btn_state = !gpio_pin_is_high(GPIO_PUSH_BUTTON_1);
	if (b_btn_state != btn0_last_state) {
		btn0_last_state = b_btn_state;
		if (b_btn_state) {
			ieee11073_skeleton_send_measure_1();
		}
	}

	b_btn_state = !gpio_pin_is_high(GPIO_PUSH_BUTTON_2);
	if (b_btn_state != btn1_last_state) {
		btn1_last_state = b_btn_state;
		if (b_btn_state) {
			ieee11073_skeleton_send_measure_2();
		}
	}
}