SRA Board Components
ESP-IDF component for SRA Board
Functions
switches.h File Reference
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "esp_err.h"
#include "pin_defs.h"
Include dependency graph for switches.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

esp_err_t enable_switches ()
 Enables tactile switches on the sra board, sets up required gpio's in input pull-up mode. More...
 
int read_switch (int switch_id)
 Reads the state of one of the four switches on sra board. More...
 

Function Documentation

◆ enable_switches()

esp_err_t enable_switches ( )

Enables tactile switches on the sra board, sets up required gpio's in input pull-up mode.

Returns
esp_err_t - returns ESP_OK if gpio's initialised, else it returns ESP_ERR_INVALID_ARG

◆ read_switch()

int read_switch ( int  switch_id)

Reads the state of one of the four switches on sra board.

Parameters
switch_idid of the switch which needs to be read, we can pass the following macros: SWITCH_1, SWITCH_2, SWITCH_3, SWITCH_4.
Returns
int - returns state of the switch, 1 if it is pressed and 0 if it is not pressed.