PicoWAN SDK Documentation
Macros | Enumerations | Functions
button.h File Reference

Button driver with debounce. More...

#include <stdint.h>

Go to the source code of this file.

Macros

#define MAX_BUTTONS   4
 

Enumerations

enum  button_mode { BUTTON_ACTIVE_LOW = 0, BUTTON_ACTIVE_HIGH = 1 }
 
enum  button_press_duration { BUTTON_SHORT_PRESS = 0, BUTTON_LONG_PRESS = 1 }
 

Functions

void button_init (void(*cb)(uint8_t num, enum button_press_duration duration))
 Initializes the button driver. More...
 
uint8_t button_is_pressed (uint8_t num)
 Checks if a button is currently pressed. More...
 

Detailed Description

Button driver with debounce.

Copyright (c) 2018, Archos S.A. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND AND EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARCHOS S.A. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

void button_init ( void(*)(uint8_t num, enum button_press_duration duration)  cb)

Initializes the button driver.

This function initializes the button driver, and allows to register a button callback that will be executed everytime a button is pressed. The drivers supports short and long presses, and already performes a debounce.

Parameters
cbThe callback to register.
uint8_t button_is_pressed ( uint8_t  num)

Checks if a button is currently pressed.

Parameters
numThe number of the button to check.
Return values
uint8_t1 if the button is pressed, 0 otherwise.