Skip to content

Commit

Permalink
add input mixer and video composer
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkcass committed Oct 15, 2018
1 parent 9ba2685 commit 42e1152
Show file tree
Hide file tree
Showing 16 changed files with 1,034 additions and 62 deletions.
9 changes: 8 additions & 1 deletion somax_ui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

PROJ_NAME=somax_ui

OBJECT_FILES = somaxui_main.o
OBJECT_FILES = somaxui_main.o \
videocomposer.o \
videodisplay.o \
pixelbuffer.o \
inputmixer.o \
inputsource.o \
inputevent.o \


SRC_DIR = src
OBJ_DIR = build
Expand Down
66 changes: 5 additions & 61 deletions somax_ui/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Available applications:
of frame to target, height of target, direction of target travel, speed of target
and acceleration of target.

Available UI resources:
* **ui_menu** - a menu that displays text menu items in vertical list format.

#
**Operation**

Expand All @@ -50,66 +53,7 @@ at boot.
only joy3d-control-gimbal and joy3d-thermal-view are enabled. joy3d-gimbal-control
is ready for use. joy3d-thermal-view is in development and should be ready by
10/15/2018.
* October 14, 2018 - created framework for input mixer and supporting classes. created video
composer and supporting classes framework. created the first ui class ui_menu.

#
**Hardware**

| Specs | Maker |
| ---------- | ------- |
| Model | JH-D400X-R4 |
| Voltage | 3.3v (5.0v) |
| Power | n/a |
| Dimensions | 49x49x95 |
| Axis | 3 |
| Button | 1 |
| Resistance | 10k |
 

**Strapping**

None

 


**Pin Map**

|JH-D400 Pin | Edison Mini-Breakout Pin |
|------------- | ------------------------- |
| VIN | 5.0 POWER |
| GND | GND |
| JOYPAN | I2C1-1, ADC50-A0 |
| JOYROTATE | I2C1-1, ADC50-A1 |
| JOYTILT | I2C1-1, ADC50-A2 |
| JOYB | I2C1-1, ADC50-A3 |
 

**Joy-Stick map**

Looking down on the stick with max power to the right and min power to the left

JOYPANSTICK STICK_LEFT STICK_CENTER STICK_RIGHT

JOYTILT STICK_UP STICK_CENTER STICK_DOWN

JOYROTATE STICK_COUNTERCLK STICK_CENTER STICK_CLOCK
 

**Stick-ADC Map**

JOYPAN STICK_LEFT < STICK_CENTER < STICK_RIGHT

JOYTILT STICK_DOWN < STICK_CENTER < STICK_UP

JOYROTATE STICK_CLOCK < STICK_CENTER < STICK_COUNTERCLK

JOYB PRESSED = HIGH

&nbsp;

|Driver Option | Description |
|------------- | ------------------------- |
| run | start the joystick for normal operation |
| calibrate | start calibration function |
| sample-raw | test the values returned by the adc |
| sample-pwr | test converted adc samples as power levels |
Binary file modified somax_ui/somax_ui
Binary file not shown.
130 changes: 130 additions & 0 deletions somax_ui/src/inputevent.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// author: mark cass
// project: somax personal AI
// project url: https://mechanizedai.com
// license: open source and free for all uses without encumbrance.
//
// FILE: inputevent.c
// DESCRIPTION: Somax input event provides storage for input device streamed
// output.
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
#include <string.h>

#include "somax.h"
#include "inputevent.h"
#include "inputsource.h"

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//CONSTANTS
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
#define INPUTEVT_MAX_FIELDS 8
#define INPUTEVT_DTYPE_UNKNOWN 0
#define INPUTEVT_DTYPE_INT 1
#define INPUTEVT_DTYPE_FLOAT 2
#define INPUTEVT_DTYPE_INTARRAY 3
#define INPUTEVT_DTYPE_FLOATARRAY 4
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//DATA STRUCTURES
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

union INPUTEVT_FIELDDATA
{
int ival;
float fval;
int * iarray;
float *farray;
};

struct INPUTEVT_FIELD
{
inputevt_fieldid field_id;
inputevt_device_fieldid device_ref;
inputevt_dtypeid datatype_id;
INPUTEVT_FIELDDATA data;
};

typedef INPUTEVT_FIELD event_data[INPUTEVT_MAX_FIELDS];

struct INPUT_EVENT
{
inputevt_eventid event_id;
inputevt_deviceid device_id;
event_data data;
int num_data;
};

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//PRIVATE DATA
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
static INPUT_EVENT inputevt_templates[INPUTEVT_NUM_EVENTID + 1] =
{
{
0,
0,
{
{0,0,0},
},
0
},
{
INPUTEVT_EVENTID_PRESSED,
0,
{
//device_ref, data assigned by device
{INPUTEVT_FIELDID_PRESSED_ISPRESSED, 0, INPUTEVT_DTYPE_INT, 0},
},
1,
},
};
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//PRIVATE FUNCTION DECLARATIONS
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
static bool inputevt_can_new(inputevt_eventid event_id);

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//PUBLIC FUNCTIONS
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
input_event inputevt_ini_new(inputevt_eventid event_id, inputevt_deviceid device_id)
{
if (!inputevt_can_new(event_id))
return 0;

input_event evt = (input_event)somax_malloc(sizeof(struct INPUT_EVENT));

memcpy(evt, &inputevt_templates[event_id], sizeof(INPUT_EVENT));
evt->device_id = device_id;

return evt;
}

void inputevt_ini_dispose(input_event evt)
{
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//PRIVATE FUNCTIONS
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
static bool inputevt_can_new(inputevt_eventid event_id)
{
if (event_id <= 0 || event_id > INPUTSRC_NUM_DEVICEID)
{
somax_log_add(SOMAX_LOG_ERR, "INPUTEVT. open. unkown event id (%d)", event_id);
return false;
}

return true;
}
51 changes: 51 additions & 0 deletions somax_ui/src/inputevent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#ifndef __inputevent_h__
#define __inputevent_h__
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// author: mark cass
// project: somax personal AI
// project url: https://mechanizedai.com
// license: open source and free for all uses without encumbrance.
//
// FILE: inputevent.h
// DESCRIPTION: Somax input provides a common interface to various input events.
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

#include "somax.h"

#define INPUTEVT_EVENTID_UNKOWN 0b00000000000000000000000000000000
#define INPUTEVT_EVENTID_PRESSED 0b00000000000000000000000000000001
#define INPUTEVT_EVENTID_RELEASED 0b00000000000000000000000000000010
#define INPUTEVT_EVENTID_CLICKED 0b00000000000000000000000000000100
#define INPUTEVT_EVENTID_XCLICKED 0b00000000000000000000000000001000
#define INPUTEVT_EVENTID_UP 0b00000000000000000000000000010000
#define INPUTEVT_EVENTID_DOWN 0b00000000000000000000000000100000
#define INPUTEVT_EVENTID_LEFT 0b00000000000000000000000001000000
#define INPUTEVT_EVENTID_RIGHT 0b00000000000000000000000010000000
#define INPUTEVT_EVENTID_VALUEI 0b00000000000000000000000100000000
#define INPUTEVT_EVENTID_VALUEF 0b00000000000000000000001000000000
#define INPUTEVT_EVENTID_VALUEP 0b00000000000000000000010000000000
#define INPUTEVT_EVENTID_ARRAYI1D 0b00000000000000000000100000000000
#define INPUTEVT_EVENTID_ARRAYI2D 0b00000000000000000001000000000000
#define INPUTEVT_EVENTID_ARRAYF1D 0b00000000000000000010000000000000
#define INPUTEVT_EVENTID_ARRAYF2D 0b00000000000000000100000000000000
#define INPUTEVT_NUM_EVENTID 14

//pressed event
#define INPUTEVT_FIELDID_PRESSED_ISPRESSED 0
//released event
#define INPUTEVT_FIELDID_RELEASED_ISRELEASED 0

struct INPUT_EVENT;
typedef struct INPUT_EVENT *input_event;
typedef int inputevt_eventid;
typedef int inputevt_deviceid;
typedef int inputevt_fieldid;
typedef int inputevt_device_fieldid;
typedef int inputevt_dtypeid;

input_event inputevt_ini_new(inputevt_eventid event_id, inputevt_deviceid device_id);
void inputevt_ini_dispose(input_event evt);

#endif
97 changes: 97 additions & 0 deletions somax_ui/src/inputmixer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// author: mark cass
// project: somax personal AI
// project url: https://mechanizedai.com
// license: open source and free for all uses without encumbrance.
//
// FILE: inputmixer.c
// DESCRIPTION: Somax input mixer provides a means to configure and query input
// devices.
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

#include "somax.h"
#include "inputmixer.h"
#include "inputsource.h"

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//CONSTANTS
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//DATA STRUCTURES
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
struct INPUTMIXER_CONTEXT
{
int context_slotid;
inputsrc_context sources[INPUTMIX_NUM_SOURCEID];
int num_sources;
inputmix_applicationid applications[INPUTMIX_MAX_APPLICATIONS];
int num_applications;
};

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//PRIVATE DATA
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
static INPUTMIXER_CONTEXT mixer;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//PRIVATE FUNCTION DECLARATIONS
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
static bool inputmix_can_open();

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//PUBLIC FUNCTIONS
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
inputmix_applicationid inputmix_ini_open()
{
if (!inputmix_can_open())
return 0;

mixer.num_applications++;

return mixer.num_applications;
}

void inputmix_ini_close(inputmix_applicationid appid)
{
mixer.num_applications--;
}

bool inputmix_cfg_source(inputmix_applicationid appid, inputmix_sourceid source_id, bool enable)
{
bool error = false;
return error;
}

bool inputmix_cfg_event(inputmix_applicationid appid, inputmix_sourceid source_id, inputevt_eventid event_id, bool enable)
{
bool error = false;
return error;
}

bool inputmix_cfg_event_observer(inputmix_applicationid appid, inputmix_event_observer observer)
{
bool error = false;
return error;
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//PRIVATE FUNCTIONS
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
static bool inputmix_can_open()
{
return true;
}
Loading

0 comments on commit 42e1152

Please sign in to comment.