Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
added an import from QCFA.h in QCFA.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdoullahBougataya committed Jul 28, 2023
1 parent ebbd0b1 commit efb3a98
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
14 changes: 7 additions & 7 deletions examples/demo/demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#include <QCFA.h>

struct Quadcopter drone; /*get the drone parameters from the quadcopter structure*/

int buttonPressed(int button)
{
static int lastStates = 0;
Expand All @@ -18,23 +16,25 @@ int buttonPressed(int button)
return false;
}

struct Quadcopter drone; /*get the drone drone from the drone structure*/

void setup()
{
int motor1_esc_pin = 6;
int motor2_esc_pin = 10;
int motor3_esc_pin = 9;
int motor4_esc_pin = 11;
drone.mass = 352.5; /*variable of the mass in (g) */
drone.propellers_radius = 38; /*variable of the propeller radius in (mm) */
drone.voltage = 22.8; /*variable of the battery voltage in (v) */
drone.KVs = 2450; /*variable of the KVs of the motor (KV) */
/* The pulse width attached to pins 6, 9, 10 and 11
have a minimum of 1000 µs and maximum of 2000 µs */
drone.ESC1.attach(motor1_esc_pin, 1000, 2000);
drone.ESC2.attach(motor2_esc_pin, 1000, 2000);
drone.ESC3.attach(motor3_esc_pin, 1000, 2000);
drone.ESC4.attach(motor4_esc_pin, 1000, 2000);
bool calibrated = false; /* Set calibrated to false if it's the first time */
drone.mass = 352.5; /*variable of the mass in (g) */
drone.propellers_radius = 38; /*variable of the propeller radius in (mm) */
drone.voltage = 22.8; /*variable of the battery voltage in (v) */
drone.KVs = 2450; /*variable of the KVs of the motor (KV) */
bool calibrated = false; /* Set calibrated to false if it's the first time */
if (calibrated == false)
{
calibrate(drone, 20000); /*20 s is the time taken by the ESC to make that beep so this calibration process will take 40s (it may vary depending on the ESCs used)*/
Expand Down
14 changes: 1 addition & 13 deletions src/QCFA.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
#include <Arduino.h>

#include <QCFA.h>
#include <Servo.h>

float land_distance = 0;

struct Quadcopter
{
Servo ESC1;
Servo ESC2;
Servo ESC3;
Servo ESC4;
float mass;
float propellers_radius;
float voltage;
int KVs;
};

int calibrate(struct Quadcopter parameters, int bip_time)
{
signed long start_time1 = millis();
Expand Down
4 changes: 3 additions & 1 deletion src/QCFA.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <Arduino.h>
#include <Servo.h>

#ifndef QCFA_H
#define QCFA_H
struct Quadcopter
{
Servo ESC1;
Expand Down Expand Up @@ -28,3 +29,4 @@ int move_z(struct Quadcopter parameters, float distance, int speed, bool landed
int land(struct Quadcopter parameters);
int go_to(struct Quadcopter parameters, float x, float y, float z, int speed, bool pitch = false, bool landed = true);
int stop(struct Quadcopter parameters);
#endif

0 comments on commit efb3a98

Please sign in to comment.