Commit 648cc86c authored by g3gg0's avatar g3gg0
Browse files

added ml-cbr to modules using MODULE_NAMED_CBR()

--HG--
branch : unified
parent 7b9b8d80604f
......@@ -9,6 +9,7 @@
#include "property.h"
#include "beep.h"
#include "bmp.h"
#include "ml-cbr.h"
#ifndef CONFIG_MODULES_MODEL_SYM
#error Not defined file name with symbols
......@@ -484,17 +485,35 @@ static void _module_load_all(uint32_t list_only)
}
}
/* register property handlers */
if(module_list[mod].prop_handlers && !module_list[mod].error)
if(!module_list[mod].error)
{
module_prophandler_t **props = module_list[mod].prop_handlers;
while(*props != NULL)
module_cbr_t *cbr = module_list[mod].cbr;
/* register property handlers */
while(props && *props)
{
update_properties = 1;
printf(" [i] prop %s\n", (*props)->name);
prop_add_handler((*props)->property, (*props)->handler);
props++;
}
/* register ml-cbr callback handlers */
while(cbr && cbr->name)
{
/* register "named" callbacks through ml-cbr */
if(cbr->type == CBR_NAMED)
{
printf(" [i] ml-cbr '%s' 0%08X (%s)\n", cbr->name, cbr->handler, cbr->symbol);
ml_register_cbr(cbr->name, (cbr_func)cbr->handler, 0);
}
else
{
printf(" [i] cbr '%s' -> 0%08X\n", cbr->name, cbr->handler);
}
cbr++;
}
}
if(0)
......@@ -540,6 +559,19 @@ static void _module_unload_all(void)
module_list[mod].info->deinit();
module_list[mod].valid = 0;
}
module_cbr_t *cbr = module_list[mod].cbr;
/* register ml-cbr callback handlers */
while(cbr && cbr->name)
{
/* unregister "named" callbacks through ml-cbr */
if(cbr->type == CBR_NAMED)
{
ml_unregister_cbr(cbr->name, (cbr_func)cbr->handler);
}
cbr++;
}
}
}
}
......
......@@ -28,6 +28,7 @@
#define MODULE_LONG_STATUS_LENGTH 63
/* some callbacks that may be needed by modules. more to come. ideas? needs? */
#define CBR_NAMED 0x8000 /* named CBR using ml-cbr */
#define CBR_PRE_SHOOT 1 /* called before image is taken */
#define CBR_POST_SHOOT 2 /* called after image is taken */
#define CBR_SHOOT_TASK 3 /* called periodically from shoot task */
......@@ -207,7 +208,8 @@ typedef struct
#define MODULE_CBRS_START() MODULE_CBRS_START_(MODULE_CBR_PREFIX,MODULE_NAME)
#define MODULE_CBRS_START_(prefix,modname) MODULE_CBRS_START__(prefix,modname)
#define MODULE_CBRS_START__(prefix,modname) module_cbr_t prefix##modname[] = {
#define MODULE_CBR(cb_type,cbr,context) { .name = #cb_type, .symbol = #cbr, .type = cb_type, .handler = cbr, .ctx = context },
#define MODULE_CBR(cb_type,cbr,context) { .name = #cb_type, .symbol = #cbr, .type = cb_type, .handler = cbr, .ctx = context },
#define MODULE_NAMED_CBR(cb_name,cbr) { .name = cb_name, .symbol = #cbr, .type = CBR_NAMED, .handler = (void*)cbr, .ctx = 0 },
#define MODULE_CBRS_END() { (void *)0, (void *)0, 0, (void *)0, 0 }\
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment