mirror of
https://github.com/eddyem/stm32samples.git
synced 2026-08-13 19:49:24 +03:00
simplest servo
This commit is contained in:
34
G4:G431/Servo/servo.h
Normal file
34
G4:G431/Servo/servo.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of the servo project.
|
||||
* Copyright 2026 Edward V. Emelianov <edward.emelianoff@gmail.com>.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// minimal and maximal pulse length for SG90
|
||||
#define SG90_MINPULSE 700
|
||||
#define SG90_MAXPULSE 2100
|
||||
#define SG90_MIDPULSE ((SG90_MINPULSE+SG90_MAXPULSE)/2)
|
||||
#define SG90_AMPL (SG90_MAXPULSE-SG90_MINPULSE)
|
||||
// maximal speed: 0.1s (5 ticks) per 60degr (1/3 of range): (SG90_AMPL/15)
|
||||
#define SG90_MAXSPEED 93
|
||||
|
||||
|
||||
void process_servo();
|
||||
bool servo_set_speed(uint8_t N, uint16_t s);
|
||||
bool servo_get_speed(uint8_t N, uint16_t *s);
|
||||
bool servo_set_tagpos(uint8_t N, uint16_t pos);
|
||||
bool servo_get_tagpos(uint8_t N, uint16_t *pos);
|
||||
Reference in New Issue
Block a user