mirror of
https://github.com/robotdoly/DOLY-DIY.git
synced 2025-06-05 21:49:17 +02:00
Add files via upload
This commit is contained in:
58
CodeExamples/Doly/include/Gpio.h
Normal file
58
CodeExamples/Doly/include/Gpio.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
enum GpioType :uint8_t
|
||||
{
|
||||
GPIO_INPUT = 0,
|
||||
GPIO_OUTPUT = 1,
|
||||
GPIO_PWM = 2
|
||||
};
|
||||
|
||||
enum GpioState :bool
|
||||
{
|
||||
LOW = false,
|
||||
HIGH = true,
|
||||
};
|
||||
|
||||
enum PinId :uint8_t
|
||||
{
|
||||
// >= 50 GPIO_CHIP2
|
||||
Pin_Servo_Left_Enable = 56,
|
||||
Pin_Servo_Right_Enable = 57,
|
||||
};
|
||||
|
||||
enum PwmId :uint8_t
|
||||
{
|
||||
Pwm_Led_Left_B = 6,
|
||||
Pwm_Led_Left_G = 7,
|
||||
Pwm_Led_Left_R = 8,
|
||||
Pwm_Led_Right_B = 9,
|
||||
Pwm_Led_Right_G = 10,
|
||||
Pwm_Led_Right_R = 11,
|
||||
};
|
||||
|
||||
namespace GPIO
|
||||
{
|
||||
// Initialize IO pin
|
||||
// state is optional for GPIO
|
||||
// return 0 = success
|
||||
// return -1 = initialized failed
|
||||
// return -2 = wrong type
|
||||
int8_t init(PinId id, GpioType type, GpioState state = GpioState::LOW);
|
||||
|
||||
// Initialize PWM pin
|
||||
// return 0 = success
|
||||
// return -1 = initialized failed
|
||||
int8_t init(PwmId id);
|
||||
|
||||
// return 0 success
|
||||
// return -1 write failed
|
||||
// return -2 undefined id
|
||||
int8_t writePin(PinId id, GpioState state);
|
||||
|
||||
// return 0 success
|
||||
// return -1 write failed
|
||||
// return -2 undefined id
|
||||
int8_t writePwm(PwmId id, uint16_t value);
|
||||
|
||||
};
|
69
CodeExamples/Doly/include/LcdControl.h
Normal file
69
CodeExamples/Doly/include/LcdControl.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#define LCD_WIDTH 240
|
||||
#define LCD_HEIGHT 240
|
||||
|
||||
enum LcdColorDepth :uint8_t
|
||||
{
|
||||
// 0x06 = 18 bit, 0x03 = 12 bit
|
||||
LCD_12BIT = 0x03,
|
||||
LCD_18BIT = 0x06,
|
||||
};
|
||||
|
||||
enum LcdSide :uint8_t
|
||||
{
|
||||
LcdLeft = 0,
|
||||
LcdRight = 1,
|
||||
};
|
||||
|
||||
struct LcdData
|
||||
{
|
||||
uint8_t side;
|
||||
uint8_t* buffer;
|
||||
};
|
||||
|
||||
namespace LcdControl
|
||||
{
|
||||
// Initialize lcd
|
||||
// return 0 success
|
||||
// return 1 already initialized
|
||||
// return -1 open device failed
|
||||
// return -2 ioctl failed
|
||||
int8_t init(LcdColorDepth depth = LCD_12BIT);
|
||||
|
||||
// release file descriptor and deinitialize
|
||||
// return 0 success
|
||||
// return 1 already closed or not opened
|
||||
int8_t release();
|
||||
|
||||
// retuns state of lcds
|
||||
// return true initialized
|
||||
// return false not initialized
|
||||
bool isActive();
|
||||
|
||||
// fill lcd with RGB
|
||||
void LcdColorFill(LcdSide side, uint8_t R, uint8_t G, uint8_t B);
|
||||
|
||||
// write buffer data to lcd
|
||||
// return 0 success
|
||||
// return -1 ioct error
|
||||
// return -2 not active
|
||||
int8_t writeLcd(LcdData* frame_data);
|
||||
|
||||
//return lcd buffer size
|
||||
// pixel count * Color data byte size
|
||||
// ex. 240*240*3
|
||||
int getBufferSize();
|
||||
|
||||
// returns lcd color depth
|
||||
LcdColorDepth getColorDepth();
|
||||
|
||||
// brightness value min = 0, max = 10
|
||||
int8_t setBrightness(uint8_t value);
|
||||
|
||||
//converts 24 bit image to lcd image depth
|
||||
void LcdBufferFrom24Bit(uint8_t* output, uint8_t* input);
|
||||
};
|
||||
|
45
CodeExamples/Doly/include/ServoMotor.h
Normal file
45
CodeExamples/Doly/include/ServoMotor.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
// just for information, ignored if used more than defined (220 degree)
|
||||
// Arm servos can not rotate more than that.
|
||||
#define SERVO_ARM_MAX_ANGLE 220
|
||||
|
||||
enum ServoChannel : uint8_t
|
||||
{
|
||||
SERVO_LEFT,
|
||||
SERVO_RIGHT,
|
||||
SERVO_0,
|
||||
SERVO_1,
|
||||
};
|
||||
|
||||
namespace ServoMotor
|
||||
{
|
||||
// initialize all motors
|
||||
void Init();
|
||||
|
||||
//return true if module ready
|
||||
bool isActive();
|
||||
|
||||
// setup servo default values
|
||||
// 'min_us, max_us' depends on your servo and effects angle of movement
|
||||
// most PWM range them between (500us - 2500us)
|
||||
// 'angle' ignored for SERVO_LEFT & SERVO_RIGHT,
|
||||
// return 0 success
|
||||
// return -1 frequency interval error
|
||||
// return -2 angle error
|
||||
int8_t setup(ServoChannel channel, uint16_t min_us, uint16_t max_us, uint16_t angle, bool invert);
|
||||
|
||||
// sets servo position
|
||||
// return 0 success
|
||||
// return -1 max angle exceed error
|
||||
// return -2 speed range error (0-100)
|
||||
// return -3 undefined channel
|
||||
int8_t set(ServoChannel channel, float angle, uint8_t speed);
|
||||
|
||||
// stops servo
|
||||
// return 0 success
|
||||
// return -1 undefined servo
|
||||
int8_t stop(ServoChannel channel);
|
||||
};
|
||||
|
BIN
CodeExamples/Doly/libs/libGpio.a
Normal file
BIN
CodeExamples/Doly/libs/libGpio.a
Normal file
Binary file not shown.
BIN
CodeExamples/Doly/libs/libLcdControl.a
Normal file
BIN
CodeExamples/Doly/libs/libLcdControl.a
Normal file
Binary file not shown.
BIN
CodeExamples/Doly/libs/libServoMotor.a
Normal file
BIN
CodeExamples/Doly/libs/libServoMotor.a
Normal file
Binary file not shown.
BIN
CodeExamples/Doly/libs/libTimer.a
Normal file
BIN
CodeExamples/Doly/libs/libTimer.a
Normal file
Binary file not shown.
Reference in New Issue
Block a user