Skip to content

Commit

Permalink
Support for OLED in mario (SRA-VJTI#66)
Browse files Browse the repository at this point in the history
* Add oled support for mario

* add function to provide servo angle

* add binary array for mario logo
  • Loading branch information
ChinmayLonkar authored Jun 16, 2022
1 parent 119fb9e commit c51db70
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 74 deletions.
22 changes: 22 additions & 0 deletions include/oled.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ esp_err_t display_sra_logo(u8g2_t *u8g2);
**/
esp_err_t display_walle_logo(u8g2_t *u8g2);

/**
* @brief displays MARIO Bitmap logo on OLED screen
* @param u8g2 pointer to u8g2_t struct
* @return esp_err_t i.e it shows if MARIO logo is displayed successfully or not
**/
esp_err_t display_mario_logo(u8g2_t *u8g2);

/**
* @brief displays LSA bar on OLED screen
Expand Down Expand Up @@ -100,4 +109,17 @@ esp_err_t display_mpu(float pitch, float roll, u8g2_t *u8g2);
**/
esp_err_t display_pid_values(float kp, float ki, float kd, u8g2_t *u8g2);

/**
* @brief displays Servo angles on the OLED screen
* @param s1 value of Servo_A in float
* @param s2 value of Servo_B in float
* @param s3 value of Servo_C in float
* @param s4 value of Servo_D in float
* @param u8g2 pointer to u8g2_t struct
* @return esp_err_t i.e it shows if Pitch and Roll values are displayed successfully or not
**/
esp_err_t display_servo_values(int s1, int s2, int s3, int s4, u8g2_t *u8g2);

#endif
22 changes: 15 additions & 7 deletions include/servo.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@
#include "esp_err.h"
#include "pin_defs.h"

typedef struct {
typedef struct
{
int servo_pin;
int min_pulse_width;
int max_pulse_width;
int max_degree;
int angle;
mcpwm_unit_t mcpwm_num;
mcpwm_timer_t timer_num;
mcpwm_generator_t gen;
mcpwm_generator_t gen;
} servo_config;

/** @struct servo_config
Expand All @@ -66,18 +68,24 @@ typedef struct {

/**
* @brief Enables Servo port on the sra board, sets up PWM for the three pins in servo port.
*
* @return esp_err_t - returns ESP_OK if servo pins initialised, else it returns ESP_ERR_INVALID_ARG
*
* @return esp_err_t - returns ESP_OK if servo pins initialised, else it returns ESP_ERR_INVALID_ARG
**/
esp_err_t enable_servo();

/**
* @brief Set the angle of the servos attached to the servo port of SRA Board
*
*
* @param config pointer to the servo_config struct
* @param degree_of_rotation angle to which the servo must be set, depends on value of MAX_DEGREE macro
* @return esp_err_t
* @return esp_err_t
*/
esp_err_t set_angle_servo(servo_config *config, unsigned int degree_of_rotation);

#endif
/**
* @brief Get the angle of the servos
* @return esp_err_t
*/
int read_servo(servo_config *config);

#endif
Loading

0 comments on commit c51db70

Please sign in to comment.