mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
OP-33 Flight/ExampleModule: Created three example modules that can be used as templates for actual modules
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@420 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
0faaa1e158
commit
8ca3279aa6
@ -75,6 +75,8 @@ OPSETTINGS = ./Settings
|
|||||||
OPSETTINGSINC = $(OPSETTINGS)/inc
|
OPSETTINGSINC = $(OPSETTINGS)/inc
|
||||||
OPTESTS = ./Tests
|
OPTESTS = ./Tests
|
||||||
OPMODULEDIR = ./Modules
|
OPMODULEDIR = ./Modules
|
||||||
|
MODEXAMPLE = $(OPMODULEDIR)/Example
|
||||||
|
MODEXAMPLEINC = $(MODEXAMPLE)/inc
|
||||||
MODTELEMETRY = $(OPMODULEDIR)/Telemetry
|
MODTELEMETRY = $(OPMODULEDIR)/Telemetry
|
||||||
MODTELEMETRYINC = $(MODTELEMETRY)/inc
|
MODTELEMETRYINC = $(MODTELEMETRY)/inc
|
||||||
MODGPS = $(OPMODULEDIR)/GPS
|
MODGPS = $(OPMODULEDIR)/GPS
|
||||||
@ -105,7 +107,8 @@ DOXYGENDIR = ../Doc/Doxygen
|
|||||||
# use file-extension c for "c-only"-files
|
# use file-extension c for "c-only"-files
|
||||||
|
|
||||||
## MODULES
|
## MODULES
|
||||||
SRC = $(MODTELEMETRY)/telemetry.c
|
SRC = $(MODEXAMPLE)/examplemodevent.c $(MODEXAMPLE)/examplemodperiodic.c $(MODEXAMPLE)/examplemodthread.c
|
||||||
|
SRC += $(MODTELEMETRY)/telemetry.c
|
||||||
SRC += $(MODGPS)/GPS.c $(MODGPS)/buffer.c
|
SRC += $(MODGPS)/GPS.c $(MODGPS)/buffer.c
|
||||||
|
|
||||||
## OPENPILOT:
|
## OPENPILOT:
|
||||||
@ -125,7 +128,8 @@ SRC += $(OPUAVOBJ)/eventdispatcher.c
|
|||||||
|
|
||||||
|
|
||||||
## UAVOBJECTS
|
## UAVOBJECTS
|
||||||
SRC += $(OPUAVOBJ)/exampleobject.c
|
SRC += $(OPUAVOBJ)/exampleobject1.c
|
||||||
|
SRC += $(OPUAVOBJ)/exampleobject2.c
|
||||||
SRC += $(OPUAVOBJ)/examplesettings.c
|
SRC += $(OPUAVOBJ)/examplesettings.c
|
||||||
|
|
||||||
## PIOS Hardware (STM32F10x)
|
## PIOS Hardware (STM32F10x)
|
||||||
@ -243,6 +247,8 @@ EXTRAINCDIRS += $(OPUAVOBJ)
|
|||||||
EXTRAINCDIRS += $(OPUAVOBJINC)
|
EXTRAINCDIRS += $(OPUAVOBJINC)
|
||||||
EXTRAINCDIRS += $(OPSETTINGS)
|
EXTRAINCDIRS += $(OPSETTINGS)
|
||||||
EXTRAINCDIRS += $(OPSETTINGSINC)
|
EXTRAINCDIRS += $(OPSETTINGSINC)
|
||||||
|
EXTRAINCDIRS += $(MODEXAMPLE)
|
||||||
|
EXTRAINCDIRS += $(MODEXAMPLEINC)
|
||||||
EXTRAINCDIRS += $(MODTELEMETRY)
|
EXTRAINCDIRS += $(MODTELEMETRY)
|
||||||
EXTRAINCDIRS += $(MODTELEMETRYINC)
|
EXTRAINCDIRS += $(MODTELEMETRYINC)
|
||||||
EXTRAINCDIRS += $(MODGPS)
|
EXTRAINCDIRS += $(MODGPS)
|
||||||
|
128
flight/OpenPilot/Modules/Example/examplemodevent.c
Normal file
128
flight/OpenPilot/Modules/Example/examplemodevent.c
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file examplemodevent.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Example module to be used as a template for actual modules.
|
||||||
|
* Event callback version.
|
||||||
|
*
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input objects: ExampleObject1, ExampleSettings
|
||||||
|
* Output object: ExampleObject2
|
||||||
|
*
|
||||||
|
* This module executes in response to ExampleObject1 updates. When the
|
||||||
|
* module is triggered it will update the data of ExampleObject2.
|
||||||
|
*
|
||||||
|
* No threads are used in this example.
|
||||||
|
*
|
||||||
|
* UAVObjects are automatically generated by the UAVObjectGenerator from
|
||||||
|
* the object definition XML file.
|
||||||
|
*
|
||||||
|
* Modules have no API, all communication to other modules is done through UAVObjects.
|
||||||
|
* However modules may use the API exposed by shared libraries.
|
||||||
|
* See the OpenPilot wiki for more details.
|
||||||
|
* http://www.openpilot.org/OpenPilot_Application_Architecture
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "examplemodevent.h"
|
||||||
|
#include "exampleobject1.h" // object the module will listen for updates (input)
|
||||||
|
#include "exampleobject2.h" // object the module will update (output)
|
||||||
|
#include "examplesettings.h" // object holding module settings (input)
|
||||||
|
|
||||||
|
// Private constants
|
||||||
|
|
||||||
|
// Private types
|
||||||
|
|
||||||
|
// Private variables
|
||||||
|
|
||||||
|
// Private functions
|
||||||
|
void ObjectUpdatedCb(UAVObjEvent* ev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise the module, called on startup.
|
||||||
|
* \returns 0 on success or -1 if initialisation failed
|
||||||
|
*/
|
||||||
|
int32_t ExampleModEventInitialize(void)
|
||||||
|
{
|
||||||
|
// Listen for ExampleObject1 updates, connect a callback function
|
||||||
|
ExampleObject1ConnectCallback(&ObjectUpdatedCb);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is called each time ExampleObject1 is updated, this could be
|
||||||
|
* a local update or a remote update from the GCS. In this example the module
|
||||||
|
* does not have its own thread, the callbacks are executed from within the
|
||||||
|
* event thread. Because of that the callback execution time must be kept to
|
||||||
|
* a minimum, if the callback needs to wait for I/O or other long operations
|
||||||
|
* then a thread should be used instead (see ExampleModThread.c). This is
|
||||||
|
* important since all callbacks are executed from the same thread, so other
|
||||||
|
* queued events can not be executed until the currently active callback returns.
|
||||||
|
*/
|
||||||
|
void ObjectUpdatedCb(UAVObjEvent* ev)
|
||||||
|
{
|
||||||
|
ExampleSettingsData settings;
|
||||||
|
ExampleObject1Data data1;
|
||||||
|
ExampleObject1Data data2;
|
||||||
|
int32_t step;
|
||||||
|
|
||||||
|
// Make sure that the object update is for ExampleObject1
|
||||||
|
// This is redundant in this case since this callback will
|
||||||
|
// only be called for a single object, it is however possible
|
||||||
|
// to use the same callback for multiple object updates.
|
||||||
|
if ( ev->obj == ExampleObject1Handle() )
|
||||||
|
{
|
||||||
|
// Update settings with latest value
|
||||||
|
ExampleSettingsGet(&settings);
|
||||||
|
|
||||||
|
// Get the input object
|
||||||
|
ExampleObject1Get(&data1);
|
||||||
|
|
||||||
|
// Determine how to update the output object
|
||||||
|
if ( settings.StepDirection == EXAMPLESETTINGS_STEPDIRECTION_UP )
|
||||||
|
{
|
||||||
|
step = settings.StepSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
step = -settings.StepSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update data
|
||||||
|
data2.Field1 = data1.Field1 + step;
|
||||||
|
data2.Field2 = data1.Field2 + step;
|
||||||
|
data2.Field3 = data1.Field3 + step;
|
||||||
|
data2.Field4[0] = data1.Field4[0] + step;
|
||||||
|
data2.Field4[1] = data1.Field4[1] + step;
|
||||||
|
|
||||||
|
// Update the ExampleObject2, after this function is called
|
||||||
|
// notifications to any other modules listening to that object
|
||||||
|
// will be sent and the GCS object will be updated through the
|
||||||
|
// telemetry link. All operations will take place asynchronously
|
||||||
|
// and the following call will return immediately.
|
||||||
|
ExampleObject2Set(&data2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
124
flight/OpenPilot/Modules/Example/examplemodperiodic.c
Normal file
124
flight/OpenPilot/Modules/Example/examplemodperiodic.c
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file examplemodperiodic.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Example module to be used as a template for actual modules.
|
||||||
|
* Threaded periodic version.
|
||||||
|
*
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input object: ExampleSettings
|
||||||
|
* Output object: ExampleObject1
|
||||||
|
*
|
||||||
|
* This module will periodically update the value of the ExampleObject object.
|
||||||
|
* The module settings can configure how the ExampleObject is manipulated.
|
||||||
|
*
|
||||||
|
* The module executes in its own thread in this example.
|
||||||
|
*
|
||||||
|
* UAVObjects are automatically generated by the UAVObjectGenerator from
|
||||||
|
* the object definition XML file.
|
||||||
|
*
|
||||||
|
* Modules have no API, all communication to other modules is done through UAVObjects.
|
||||||
|
* However modules may use the API exposed by shared libraries.
|
||||||
|
* See the OpenPilot wiki for more details.
|
||||||
|
* http://www.openpilot.org/OpenPilot_Application_Architecture
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "examplemodperiodic.h"
|
||||||
|
#include "exampleobject1.h" // object that will be updated by the module
|
||||||
|
#include "examplesettings.h" // object holding module settings
|
||||||
|
|
||||||
|
// Private constants
|
||||||
|
#define STACK_SIZE 200
|
||||||
|
#define TASK_PRIORITY (tskIDLE_PRIORITY)
|
||||||
|
|
||||||
|
// Private types
|
||||||
|
|
||||||
|
// Private variables
|
||||||
|
static xTaskHandle taskHandle;
|
||||||
|
|
||||||
|
// Private functions
|
||||||
|
static void exampleTask(void* parameters);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise the module, called on startup
|
||||||
|
* \returns 0 on success or -1 if initialisation failed
|
||||||
|
*/
|
||||||
|
int32_t ExampleModPeriodicInitialize(void)
|
||||||
|
{
|
||||||
|
// Start main task
|
||||||
|
xTaskCreate(exampleTask, (signed char*)"ExamplePeriodic", STACK_SIZE, NULL, TASK_PRIORITY, &taskHandle);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module thread, should not return.
|
||||||
|
*/
|
||||||
|
void exampleTask(void* parameters)
|
||||||
|
{
|
||||||
|
ExampleSettingsData settings;
|
||||||
|
ExampleObject1Data data;
|
||||||
|
int32_t step;
|
||||||
|
|
||||||
|
// Main task loop
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
// Update settings with latest value
|
||||||
|
ExampleSettingsGet(&settings);
|
||||||
|
|
||||||
|
// Get the object data
|
||||||
|
ExampleObject1Get(&data);
|
||||||
|
|
||||||
|
// Determine how to update the data
|
||||||
|
if ( settings.StepDirection == EXAMPLESETTINGS_STEPDIRECTION_UP )
|
||||||
|
{
|
||||||
|
step = settings.StepSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
step = -settings.StepSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the data
|
||||||
|
data.Field1 += step;
|
||||||
|
data.Field2 += step;
|
||||||
|
data.Field3 += step;
|
||||||
|
data.Field4[0] += step;
|
||||||
|
data.Field4[1] += step;
|
||||||
|
|
||||||
|
|
||||||
|
// Update the ExampleObject, after this function is called
|
||||||
|
// notifications to any other modules listening to that object
|
||||||
|
// will be sent and the GCS object will be updated through the
|
||||||
|
// telemetry link. All operations will take place asynchronously
|
||||||
|
// and the following call will return immediately.
|
||||||
|
ExampleObject1Set(&data);
|
||||||
|
|
||||||
|
// Since this module executes at fixed time intervals, we need to
|
||||||
|
// block the task until it is time for the next update.
|
||||||
|
// The settings field is in ms, to convert to RTOS ticks we need
|
||||||
|
// to divide by portTICK_RATE_MS.
|
||||||
|
vTaskDelay( settings.UpdatePeriod / portTICK_RATE_MS );
|
||||||
|
}
|
||||||
|
}
|
144
flight/OpenPilot/Modules/Example/examplemodthread.c
Normal file
144
flight/OpenPilot/Modules/Example/examplemodthread.c
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file examplemodthread.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Example module to be used as a template for actual modules.
|
||||||
|
* Threaded version.
|
||||||
|
*
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input objects: ExampleObject1, ExampleSettings
|
||||||
|
* Output object: ExampleObject2
|
||||||
|
*
|
||||||
|
* This module executes in response to ExampleObject1 updates. When the
|
||||||
|
* module is triggered it will update the data of ExampleObject2.
|
||||||
|
*
|
||||||
|
* The module executes in its own thread in this example.
|
||||||
|
*
|
||||||
|
* UAVObjects are automatically generated by the UAVObjectGenerator from
|
||||||
|
* the object definition XML file.
|
||||||
|
*
|
||||||
|
* Modules have no API, all communication to other modules is done through UAVObjects.
|
||||||
|
* However modules may use the API exposed by shared libraries.
|
||||||
|
* See the OpenPilot wiki for more details.
|
||||||
|
* http://www.openpilot.org/OpenPilot_Application_Architecture
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "examplemodthread.h"
|
||||||
|
#include "exampleobject1.h" // object the module will listen for updates (input)
|
||||||
|
#include "exampleobject2.h" // object the module will update (output)
|
||||||
|
#include "examplesettings.h" // object holding module settings (input)
|
||||||
|
|
||||||
|
// Private constants
|
||||||
|
#define MAX_QUEUE_SIZE 20
|
||||||
|
#define STACK_SIZE 200
|
||||||
|
#define TASK_PRIORITY (tskIDLE_PRIORITY)
|
||||||
|
|
||||||
|
// Private types
|
||||||
|
|
||||||
|
// Private variables
|
||||||
|
static xQueueHandle queue;
|
||||||
|
static xTaskHandle taskHandle;
|
||||||
|
|
||||||
|
// Private functions
|
||||||
|
static void exampleTask(void* parameters);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise the module, called on startup
|
||||||
|
* \returns 0 on success or -1 if initialisation failed
|
||||||
|
*/
|
||||||
|
int32_t ExampleModThreadInitialize(void)
|
||||||
|
{
|
||||||
|
// Create object queue
|
||||||
|
queue = xQueueCreate(MAX_QUEUE_SIZE, sizeof(UAVObjEvent));
|
||||||
|
|
||||||
|
// Listen for ExampleObject1 updates
|
||||||
|
ExampleObject1ConnectQueue(queue);
|
||||||
|
|
||||||
|
// Start main task
|
||||||
|
xTaskCreate(exampleTask, (signed char*)"ExampleThread", STACK_SIZE, NULL, TASK_PRIORITY, &taskHandle);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module thread, should not return.
|
||||||
|
*/
|
||||||
|
void exampleTask(void* parameters)
|
||||||
|
{
|
||||||
|
UAVObjEvent ev;
|
||||||
|
ExampleSettingsData settings;
|
||||||
|
ExampleObject1Data data1;
|
||||||
|
ExampleObject1Data data2;
|
||||||
|
int32_t step;
|
||||||
|
|
||||||
|
// Main task loop
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
// Check the event queue for any object updates. In this case
|
||||||
|
// we are only listening for the ExampleSettings object. However
|
||||||
|
// the module could listen to multiple objects.
|
||||||
|
// Since this object only executes on object updates, the task
|
||||||
|
// will block until an object event is pushed in the queue.
|
||||||
|
while ( xQueueReceive(queue, &ev, portMAX_DELAY) != pdTRUE );
|
||||||
|
|
||||||
|
// Make sure that the object update is for ExampleObject1
|
||||||
|
// This is redundant in this example since we have only
|
||||||
|
// registered a single object in the queue, however
|
||||||
|
// in most practical cases there will be more than one
|
||||||
|
// object connected in the queue.
|
||||||
|
if ( ev.obj == ExampleObject1Handle() )
|
||||||
|
{
|
||||||
|
// Update settings with latest value
|
||||||
|
ExampleSettingsGet(&settings);
|
||||||
|
|
||||||
|
// Get the input object
|
||||||
|
ExampleObject1Get(&data1);
|
||||||
|
|
||||||
|
// Determine how to update the output object
|
||||||
|
if ( settings.StepDirection == EXAMPLESETTINGS_STEPDIRECTION_UP )
|
||||||
|
{
|
||||||
|
step = settings.StepSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
step = -settings.StepSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update data
|
||||||
|
data2.Field1 = data1.Field1 + step;
|
||||||
|
data2.Field2 = data1.Field2 + step;
|
||||||
|
data2.Field3 = data1.Field3 + step;
|
||||||
|
data2.Field4[0] = data1.Field4[0] + step;
|
||||||
|
data2.Field4[1] = data1.Field4[1] + step;
|
||||||
|
|
||||||
|
// Update the ExampleObject2, after this function is called
|
||||||
|
// notifications to any other modules listening to that object
|
||||||
|
// will be sent and the GCS object will be updated through the
|
||||||
|
// telemetry link. All operations will take place asynchronously
|
||||||
|
// and the following call will return immediately.
|
||||||
|
ExampleObject2Set(&data2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
34
flight/OpenPilot/Modules/Example/inc/examplemodevent.h
Normal file
34
flight/OpenPilot/Modules/Example/inc/examplemodevent.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file examplemodevent.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Example module to be used as a template for actual modules.
|
||||||
|
*
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#ifndef EXAMPLEMODEVENT_H
|
||||||
|
#define EXAMPLEMODEVENT_H
|
||||||
|
|
||||||
|
#include "openpilot.h"
|
||||||
|
|
||||||
|
int32_t ExampleModEventInitialize(void);
|
||||||
|
|
||||||
|
#endif // EXAMPLEMODEVENT_H
|
||||||
|
|
34
flight/OpenPilot/Modules/Example/inc/examplemodperiodic.h
Normal file
34
flight/OpenPilot/Modules/Example/inc/examplemodperiodic.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file examplemodperiodic.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Example module to be used as a template for actual modules.
|
||||||
|
*
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#ifndef EXAMPLEMODPERIODIC_H
|
||||||
|
#define EXAMPLEMODPERIODIC_H
|
||||||
|
|
||||||
|
#include "openpilot.h"
|
||||||
|
|
||||||
|
int32_t ExampleModPeriodicInitialize(void);
|
||||||
|
|
||||||
|
#endif // EXAMPLEMODPERIODIC_H
|
||||||
|
|
34
flight/OpenPilot/Modules/Example/inc/examplemodthread.h
Normal file
34
flight/OpenPilot/Modules/Example/inc/examplemodthread.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file examplemodthread.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Example module to be used as a template for actual modules.
|
||||||
|
*
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#ifndef EXAMPLEMODTHREAD_H
|
||||||
|
#define EXAMPLEMODTHREAD_H
|
||||||
|
|
||||||
|
#include "openpilot.h"
|
||||||
|
|
||||||
|
int32_t ExampleModThreadInitialize(void);
|
||||||
|
|
||||||
|
#endif // EXAMPLEMODTHREAD_H
|
||||||
|
|
73
flight/OpenPilot/UAVObjects/exampleobject1.c
Normal file
73
flight/OpenPilot/UAVObjects/exampleobject1.c
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file exampleobject1.c
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Implementation of the ExampleObject1 object. This file has been
|
||||||
|
* automatically generated by the UAVObjectGenerator.
|
||||||
|
*
|
||||||
|
* @note Object definition file: exampleobject1.xml.
|
||||||
|
* This is an automatically generated file.
|
||||||
|
* DO NOT modify manually.
|
||||||
|
*
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "exampleobject1.h"
|
||||||
|
|
||||||
|
// Private variables
|
||||||
|
UAVObjHandle handle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize object.
|
||||||
|
* \return 0 Success
|
||||||
|
* \return -1 Failure
|
||||||
|
*/
|
||||||
|
int32_t ExampleObject1Initialize()
|
||||||
|
{
|
||||||
|
UAVObjMetadata metadata;
|
||||||
|
|
||||||
|
// Register object with the object manager
|
||||||
|
handle = UAVObjRegister(EXAMPLEOBJECT1_OBJID, EXAMPLEOBJECT1_NAME, 0, EXAMPLEOBJECT1_ISSINGLEINST, EXAMPLEOBJECT1_ISSETTINGS, EXAMPLEOBJECT1_NUMBYTES);
|
||||||
|
if (handle == 0) return -1;
|
||||||
|
|
||||||
|
// Initialize metadata
|
||||||
|
metadata.telemetryAcked = 1;
|
||||||
|
metadata.telemetryUpdateMode = UPDATEMODE_ONCHANGE;
|
||||||
|
metadata.telemetryUpdatePeriod = 0;
|
||||||
|
metadata.gcsTelemetryAcked = 1;
|
||||||
|
metadata.gcsTelemetryUpdateMode = UPDATEMODE_PERIODIC;
|
||||||
|
metadata.gcsTelemetryUpdatePeriod = 200;
|
||||||
|
metadata.loggingUpdateMode = UPDATEMODE_NEVER;
|
||||||
|
metadata.loggingUpdatePeriod = 0;
|
||||||
|
UAVObjSetMetadata(handle, &metadata);
|
||||||
|
|
||||||
|
// Done
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get object handle
|
||||||
|
*/
|
||||||
|
UAVObjHandle ExampleObject1Handle()
|
||||||
|
{
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file exampleobject.c
|
* @file exampleobject2.c
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @brief Implementation of the ExampleObject object. This file has been
|
* @brief Implementation of the ExampleObject2 object. This file has been
|
||||||
* automatically generated by the UAVObjectGenerator.
|
* automatically generated by the UAVObjectGenerator.
|
||||||
*
|
*
|
||||||
* @note Object definition file: exampleobject.xml.
|
* @note Object definition file: exampleobject2.xml.
|
||||||
* This is an automatically generated file.
|
* This is an automatically generated file.
|
||||||
* DO NOT modify manually.
|
* DO NOT modify manually.
|
||||||
*
|
*
|
||||||
@ -29,7 +29,7 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "exampleobject.h"
|
#include "exampleobject2.h"
|
||||||
|
|
||||||
// Private variables
|
// Private variables
|
||||||
UAVObjHandle handle;
|
UAVObjHandle handle;
|
||||||
@ -39,17 +39,17 @@ UAVObjHandle handle;
|
|||||||
* \return 0 Success
|
* \return 0 Success
|
||||||
* \return -1 Failure
|
* \return -1 Failure
|
||||||
*/
|
*/
|
||||||
int32_t ExampleObjectInitialize()
|
int32_t ExampleObject2Initialize()
|
||||||
{
|
{
|
||||||
UAVObjMetadata metadata;
|
UAVObjMetadata metadata;
|
||||||
|
|
||||||
// Register object with the object manager
|
// Register object with the object manager
|
||||||
handle = UAVObjRegister(EXAMPLEOBJECT_OBJID, EXAMPLEOBJECT_NAME, 0, EXAMPLEOBJECT_ISSINGLEINST, EXAMPLEOBJECT_ISSETTINGS, EXAMPLEOBJECT_NUMBYTES);
|
handle = UAVObjRegister(EXAMPLEOBJECT2_OBJID, EXAMPLEOBJECT2_NAME, 0, EXAMPLEOBJECT2_ISSINGLEINST, EXAMPLEOBJECT2_ISSETTINGS, EXAMPLEOBJECT2_NUMBYTES);
|
||||||
if (handle == 0) return -1;
|
if (handle == 0) return -1;
|
||||||
|
|
||||||
// Initialize metadata
|
// Initialize metadata
|
||||||
metadata.telemetryAcked = 1;
|
metadata.telemetryAcked = 1;
|
||||||
metadata.telemetryUpdateMode = UPDATEMODE_ONCHANGE;
|
metadata.telemetryUpdateMode = UPDATEMODE_PERIODIC;
|
||||||
metadata.telemetryUpdatePeriod = 100;
|
metadata.telemetryUpdatePeriod = 100;
|
||||||
metadata.gcsTelemetryAcked = 1;
|
metadata.gcsTelemetryAcked = 1;
|
||||||
metadata.gcsTelemetryUpdateMode = UPDATEMODE_ONCHANGE;
|
metadata.gcsTelemetryUpdateMode = UPDATEMODE_ONCHANGE;
|
||||||
@ -65,7 +65,7 @@ int32_t ExampleObjectInitialize()
|
|||||||
/**
|
/**
|
||||||
* Get object handle
|
* Get object handle
|
||||||
*/
|
*/
|
||||||
UAVObjHandle ExampleObjectGetHandle()
|
UAVObjHandle ExampleObject2Handle()
|
||||||
{
|
{
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
@ -65,7 +65,7 @@ int32_t ExampleSettingsInitialize()
|
|||||||
/**
|
/**
|
||||||
* Get object handle
|
* Get object handle
|
||||||
*/
|
*/
|
||||||
UAVObjHandle ExampleSettingsGetHandle()
|
UAVObjHandle ExampleSettingsHandle()
|
||||||
{
|
{
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
71
flight/OpenPilot/UAVObjects/inc/exampleobject1.h
Normal file
71
flight/OpenPilot/UAVObjects/inc/exampleobject1.h
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file exampleobject1.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Implementation of the ExampleObject1 object. This file has been
|
||||||
|
* automatically generated by the UAVObjectGenerator.
|
||||||
|
*
|
||||||
|
* @note Object definition file: exampleobject1.xml.
|
||||||
|
* This is an automatically generated file.
|
||||||
|
* DO NOT modify manually.
|
||||||
|
*
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EXAMPLEOBJECT1_H
|
||||||
|
#define EXAMPLEOBJECT1_H
|
||||||
|
|
||||||
|
#include "openpilot.h"
|
||||||
|
|
||||||
|
// Object constants
|
||||||
|
#define EXAMPLEOBJECT1_OBJID 3852936276U
|
||||||
|
#define EXAMPLEOBJECT1_NAME "ExampleObject1"
|
||||||
|
#define EXAMPLEOBJECT1_ISSINGLEINST 0
|
||||||
|
#define EXAMPLEOBJECT1_ISSETTINGS 0
|
||||||
|
#define EXAMPLEOBJECT1_NUMBYTES sizeof(ExampleObject1Data)
|
||||||
|
|
||||||
|
// Data access macros
|
||||||
|
#define ExampleObject1Get(dataOut) UAVObjGetData(ExampleObject1Handle(), dataOut)
|
||||||
|
#define ExampleObject1Set(dataIn) UAVObjSetData(ExampleObject1Handle(), dataIn)
|
||||||
|
#define ExampleObject1ConnectQueue(queue) UAVObjConnectQueue(ExampleObject1Handle(), queue, EV_MASK_ALL_UPDATES)
|
||||||
|
#define ExampleObject1ConnectCallback(cb) UAVObjConnectCallback(ExampleObject1Handle(), cb, EV_MASK_ALL_UPDATES)
|
||||||
|
|
||||||
|
// Object data
|
||||||
|
typedef struct {
|
||||||
|
int8_t Field1;
|
||||||
|
int16_t Field2;
|
||||||
|
int32_t Field3;
|
||||||
|
float Field4[4];
|
||||||
|
uint8_t Field5;
|
||||||
|
uint16_t Field6;
|
||||||
|
uint32_t Field7;
|
||||||
|
uint8_t Field8;
|
||||||
|
|
||||||
|
} __attribute__((packed)) ExampleObject1Data;
|
||||||
|
|
||||||
|
// Enumeration types
|
||||||
|
typedef enum { EXAMPLEOBJECT1_FIELD8_OPTION1=0, EXAMPLEOBJECT1_FIELD8_OPTION2=1, } EXAMPLEOBJECT1FIELD8Enum;
|
||||||
|
|
||||||
|
|
||||||
|
// Generic interface functions
|
||||||
|
int32_t ExampleObject1Initialize();
|
||||||
|
UAVObjHandle ExampleObject1Handle();
|
||||||
|
|
||||||
|
#endif // EXAMPLEOBJECT1_H
|
@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file exampleobject.h
|
* @file exampleobject2.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @brief Implementation of the ExampleObject object. This file has been
|
* @brief Implementation of the ExampleObject2 object. This file has been
|
||||||
* automatically generated by the UAVObjectGenerator.
|
* automatically generated by the UAVObjectGenerator.
|
||||||
*
|
*
|
||||||
* @note Object definition file: exampleobject.xml.
|
* @note Object definition file: exampleobject2.xml.
|
||||||
* This is an automatically generated file.
|
* This is an automatically generated file.
|
||||||
* DO NOT modify manually.
|
* DO NOT modify manually.
|
||||||
*
|
*
|
||||||
@ -29,41 +29,38 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef EXAMPLEOBJECT_H
|
#ifndef EXAMPLEOBJECT2_H
|
||||||
#define EXAMPLEOBJECT_H
|
#define EXAMPLEOBJECT2_H
|
||||||
|
|
||||||
#include "openpilot.h"
|
#include "openpilot.h"
|
||||||
|
|
||||||
// Object constants
|
// Object constants
|
||||||
#define EXAMPLEOBJECT_OBJID 1785231914U
|
#define EXAMPLEOBJECT2_OBJID 2743296914U
|
||||||
#define EXAMPLEOBJECT_NAME "ExampleObject"
|
#define EXAMPLEOBJECT2_NAME "ExampleObject2"
|
||||||
#define EXAMPLEOBJECT_ISSINGLEINST 0
|
#define EXAMPLEOBJECT2_ISSINGLEINST 0
|
||||||
#define EXAMPLEOBJECT_ISSETTINGS 0
|
#define EXAMPLEOBJECT2_ISSETTINGS 0
|
||||||
#define EXAMPLEOBJECT_NUMBYTES sizeof(ExampleObjectData)
|
#define EXAMPLEOBJECT2_NUMBYTES sizeof(ExampleObject2Data)
|
||||||
|
|
||||||
// Data access macros
|
// Data access macros
|
||||||
#define ExampleObjectGet(dataOut) UAVObjGetData(ExampleObjectGetHandle(), dataOut)
|
#define ExampleObject2Get(dataOut) UAVObjGetData(ExampleObject2Handle(), dataOut)
|
||||||
#define ExampleObjectSet(dataIn) UAVObjSetData(ExampleObjectGetHandle(), dataIn)
|
#define ExampleObject2Set(dataIn) UAVObjSetData(ExampleObject2Handle(), dataIn)
|
||||||
|
#define ExampleObject2ConnectQueue(queue) UAVObjConnectQueue(ExampleObject2Handle(), queue, EV_MASK_ALL_UPDATES)
|
||||||
|
#define ExampleObject2ConnectCallback(cb) UAVObjConnectCallback(ExampleObject2Handle(), cb, EV_MASK_ALL_UPDATES)
|
||||||
|
|
||||||
// Object data
|
// Object data
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t field1;
|
int8_t Field1;
|
||||||
int16_t field2;
|
int16_t Field2;
|
||||||
int32_t field3;
|
int32_t Field3;
|
||||||
float field4[4];
|
float Field4[4];
|
||||||
uint8_t field5;
|
|
||||||
uint16_t field6;
|
|
||||||
uint32_t field7;
|
|
||||||
uint8_t field8;
|
|
||||||
|
|
||||||
} __attribute__((packed)) ExampleObjectData;
|
} __attribute__((packed)) ExampleObject2Data;
|
||||||
|
|
||||||
// Enumeration types
|
// Enumeration types
|
||||||
typedef enum { EXAMPLEOBJECT_FIELD8_OPTION1=0, EXAMPLEOBJECT_FIELD8_OPTION2=1, } EXAMPLEOBJECTFIELD8Enum;
|
|
||||||
|
|
||||||
|
|
||||||
// Generic interface functions
|
// Generic interface functions
|
||||||
int32_t ExampleObjectInitialize();
|
int32_t ExampleObject2Initialize();
|
||||||
UAVObjHandle ExampleObjectGetHandle();
|
UAVObjHandle ExampleObject2Handle();
|
||||||
|
|
||||||
#endif // EXAMPLEOBJECT_H
|
#endif // EXAMPLEOBJECT2_H
|
@ -35,30 +35,32 @@
|
|||||||
#include "openpilot.h"
|
#include "openpilot.h"
|
||||||
|
|
||||||
// Object constants
|
// Object constants
|
||||||
#define EXAMPLESETTINGS_OBJID 3555345034U
|
#define EXAMPLESETTINGS_OBJID 1640607828U
|
||||||
#define EXAMPLESETTINGS_NAME "ExampleSettings"
|
#define EXAMPLESETTINGS_NAME "ExampleSettings"
|
||||||
#define EXAMPLESETTINGS_ISSINGLEINST 1
|
#define EXAMPLESETTINGS_ISSINGLEINST 1
|
||||||
#define EXAMPLESETTINGS_ISSETTINGS 1
|
#define EXAMPLESETTINGS_ISSETTINGS 1
|
||||||
#define EXAMPLESETTINGS_NUMBYTES sizeof(ExampleSettingsData)
|
#define EXAMPLESETTINGS_NUMBYTES sizeof(ExampleSettingsData)
|
||||||
|
|
||||||
// Data access macros
|
// Data access macros
|
||||||
#define ExampleSettingsGet(dataOut) UAVObjGetData(ExampleSettingsGetHandle(), dataOut)
|
#define ExampleSettingsGet(dataOut) UAVObjGetData(ExampleSettingsHandle(), dataOut)
|
||||||
#define ExampleSettingsSet(dataIn) UAVObjSetData(ExampleSettingsGetHandle(), dataIn)
|
#define ExampleSettingsSet(dataIn) UAVObjSetData(ExampleSettingsHandle(), dataIn)
|
||||||
|
#define ExampleSettingsConnectQueue(queue) UAVObjConnectQueue(ExampleSettingsHandle(), queue, EV_MASK_ALL_UPDATES)
|
||||||
|
#define ExampleSettingsConnectCallback(cb) UAVObjConnectCallback(ExampleSettingsHandle(), cb, EV_MASK_ALL_UPDATES)
|
||||||
|
|
||||||
// Object data
|
// Object data
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t setting1;
|
int32_t UpdatePeriod;
|
||||||
int16_t setting2;
|
int32_t StepSize;
|
||||||
int8_t setting3;
|
uint8_t StepDirection;
|
||||||
int32_t setting4;
|
|
||||||
|
|
||||||
} __attribute__((packed)) ExampleSettingsData;
|
} __attribute__((packed)) ExampleSettingsData;
|
||||||
|
|
||||||
// Enumeration types
|
// Enumeration types
|
||||||
|
typedef enum { EXAMPLESETTINGS_STEPDIRECTION_UP=0, EXAMPLESETTINGS_STEPDIRECTION_DOWN=1, } EXAMPLESETTINGSSTEPDIRECTIONEnum;
|
||||||
|
|
||||||
|
|
||||||
// Generic interface functions
|
// Generic interface functions
|
||||||
int32_t ExampleSettingsInitialize();
|
int32_t ExampleSettingsInitialize();
|
||||||
UAVObjHandle ExampleSettingsGetHandle();
|
UAVObjHandle ExampleSettingsHandle();
|
||||||
|
|
||||||
#endif // EXAMPLESETTINGS_H
|
#endif // EXAMPLESETTINGS_H
|
||||||
|
@ -42,8 +42,10 @@
|
|||||||
#define $(NAMEUC)_NUMBYTES sizeof($(NAME)Data)
|
#define $(NAMEUC)_NUMBYTES sizeof($(NAME)Data)
|
||||||
|
|
||||||
// Data access macros
|
// Data access macros
|
||||||
#define $(NAME)Get(dataOut) UAVObjGetData($(NAME)GetHandle(), dataOut)
|
#define $(NAME)Get(dataOut) UAVObjGetData($(NAME)Handle(), dataOut)
|
||||||
#define $(NAME)Set(dataIn) UAVObjSetData($(NAME)GetHandle(), dataIn)
|
#define $(NAME)Set(dataIn) UAVObjSetData($(NAME)Handle(), dataIn)
|
||||||
|
#define $(NAME)ConnectQueue(queue) UAVObjConnectQueue($(NAME)Handle(), queue, EV_MASK_ALL_UPDATES)
|
||||||
|
#define $(NAME)ConnectCallback(cb) UAVObjConnectCallback($(NAME)Handle(), cb, EV_MASK_ALL_UPDATES)
|
||||||
|
|
||||||
// Object data
|
// Object data
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -55,6 +57,6 @@ $(DATAENUM)
|
|||||||
|
|
||||||
// Generic interface functions
|
// Generic interface functions
|
||||||
int32_t $(NAME)Initialize();
|
int32_t $(NAME)Initialize();
|
||||||
UAVObjHandle $(NAME)GetHandle();
|
UAVObjHandle $(NAME)Handle();
|
||||||
|
|
||||||
#endif // $(NAMEUC)_H
|
#endif // $(NAMEUC)_H
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "openpilot.h"
|
#include "openpilot.h"
|
||||||
#include "exampleobject.h"
|
#include "exampleobject1.h"
|
||||||
|
#include "exampleobject2.h"
|
||||||
#include "examplesettings.h"
|
#include "examplesettings.h"
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +39,8 @@
|
|||||||
*/
|
*/
|
||||||
void UAVObjectsInitializeAll()
|
void UAVObjectsInitializeAll()
|
||||||
{
|
{
|
||||||
ExampleObjectInitialize();
|
ExampleObject1Initialize();
|
||||||
|
ExampleObject2Initialize();
|
||||||
ExampleSettingsInitialize();
|
ExampleSettingsInitialize();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ int32_t $(NAME)Initialize()
|
|||||||
/**
|
/**
|
||||||
* Get object handle
|
* Get object handle
|
||||||
*/
|
*/
|
||||||
UAVObjHandle $(NAME)GetHandle()
|
UAVObjHandle $(NAME)Handle()
|
||||||
{
|
{
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user