Add to Chrome
✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
De quina de les següents maneres llegim l'estat del polsador 0 amb la placa del kit EFR32?
Primer configurem el HAL per poder llegir el botó i activem el callback corresponent. Tot seguit escrivim el nostre codi dins del callback específic de lectura del polsador zero, per exemple:
Primer configurem el HAL per poder llegir el botó i
activem el callback corresponent. Tot seguit escrivim el nostre codi
dins del callback específic de lectura del polsador zero, per exemple:
void sl_button_on_change(const sl_button_t *handle) { bool button_pressed = sl_button_get_state(handle) == SL_SIMPLE_BUTTON_PRESSED; if (button_pressed) { sl_zigbee_app_debug_println("Button 0 pressed"); } else { sl_zigbee_app_debug_println("Button 0 released") }}
Podem llegir els botons directament amb la funcion emberAfReadButton() que ens proporciona el Application Framework:
bool button_pressed = emberAfReadButton(0); //Argument set to zero to read button 0if (button_pressed){ sl_zigbee_app_debug_println("Button 0 pressed");}
else{ sl_zigbee_app_debug_println("Button 0 released")}
Mitjançant el callback de HAL corresponent. Primer configurem el "Software Component" per poder llegir el botó i activar el callback corresponent. Tot seguit escrivim el nostre codi dins del callback, per exemple:
Mitjançant el callback de HAL
corresponent. Primer configurem el "Software Component" per poder llegir el botó i
activar el callback corresponent. Tot seguit escrivim el nostre codi
dins del callback, per exemple:
void sl_button_on_change(const sl_button_t *handle){ bool button_pressed = sl_button_get_state(handle) == SL_SIMPLE_BUTTON_RELEASED; if (SL_SIMPLE_BUTTON_INSTANCE(BUTTON0) == handle) { if (button_pressed) { sl_zigbee_app_debug_println("Button 0 pressed"); } else { sl_zigbee_app_debug_println("Button 0 released") } }}
Cridant la rutina callback de HAL destinada a llegir els botons, per exemple:
bool button_pressed = sl_button_on_change(0); //Argument set to zero to read button 0if (button_pressed){ sl_zigbee_app_debug_println("Button 0 pressed");}else{ sl_zigbee_app_debug_println("Button 0 released")}
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!