You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.0 KiB
73 lines
2.0 KiB
/*
|
|
* splitflap.h
|
|
*
|
|
* Created on: 29.09.2022
|
|
* Author: jonas
|
|
*/
|
|
|
|
#ifndef SPLITFLAP_H_
|
|
#define SPLITFLAP_H_
|
|
|
|
#include <stdbool.h>
|
|
#include "McuULN2003.h"
|
|
#include "McuGPIO.h"
|
|
#include "lib/dict.h"
|
|
#include <string.h>
|
|
|
|
|
|
/****** SETTINGS ******/
|
|
#define SPLITFLAP_CONFIG_USE_FREERTOS_HEAP 0
|
|
#define SPLITFLAP_STEPS_ONE_ROUND 512
|
|
#define SPLITFLAP_AMOUNT_OF_SEGMENTS (sizeof(SF_Letters)/sizeof(SF_Letters[0]))
|
|
#define SPLITFLAP_STEPS_PER_SEGMENT ((float)SPLITFLAP_STEPS_ONE_ROUND/(float)SPLITFLAP_AMOUNT_OF_SEGMENTS)
|
|
|
|
|
|
/****** TYPES ******/
|
|
/* define splitflap handle type. SF_Handle_t points to SF_t */
|
|
typedef void* SF_Handle_t;
|
|
|
|
typedef struct {
|
|
McuULN2003_Handle_t motor;
|
|
McuGPIO_Handle_t magSensor;
|
|
int id;
|
|
} SF_t;
|
|
|
|
typedef struct {
|
|
McuULN2003_Config_t motorConfig;
|
|
McuGPIO_Config_t magSensorConfig;
|
|
} SF_Config_t;
|
|
|
|
/****** FUNCTIONS ******/
|
|
/* initializes dictonary with splitflap flaps position */
|
|
void SF_InitConfig(void);
|
|
|
|
/* free splitflap flaps dictionary */
|
|
void SF_DeInitConfig(void);
|
|
|
|
/* split flap initialization
|
|
* only pass configured types, they do not need to be initialized.
|
|
* Initialization will be made inside the SF_Init method */
|
|
SF_Handle_t SF_Init(SF_Config_t* instance, int id);
|
|
|
|
/* Moves split flap slowly to zero position.
|
|
* returns true if the move was successful, false if not
|
|
* (depending on if the sensor was hit before one round)
|
|
* with the offsetSegments parameter, the amount of segments to offset can be given */
|
|
bool SF_MoveMotorToZeroPosition(SF_Handle_t instance, int8_t offsetSegments);
|
|
|
|
/* split flap moves number of steps maybe uint16_t? */
|
|
void SF_MoveSteps(SF_Handle_t instance, int32_t steps);
|
|
|
|
/* get mag sensor state. returns true if sensor is at zero position, otherwise false */
|
|
bool SF_GetMagSensorAtZeroPosition(SF_Handle_t instance);
|
|
|
|
/* move to specific flap */
|
|
void SF_MoveToFlap(SF_Handle_t instance, char* flap);
|
|
|
|
/* get current position of motor */
|
|
int32_t SF_GetMotorPosition(SF_Handle_t instance);
|
|
|
|
/* split flap deinitialization */
|
|
void SF_Deinit(SF_Handle_t instance);
|
|
|
|
#endif /* SPLITFLAP_H_ */
|
|
|