remove warnings
This commit is contained in:
parent
ed3f36fcc1
commit
5879972880
79 changed files with 606 additions and 613 deletions
|
|
@ -20,7 +20,6 @@
|
|||
/* clang-format off */
|
||||
#define DATALENGTH 8
|
||||
|
||||
#define SPI_SLAVE_SELECT (0x01)
|
||||
|
||||
#define w25qxx_FLASH_PAGE_SIZE 256
|
||||
#define w25qxx_FLASH_SECTOR_SIZE 4096
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ w25qxx_status_t w25qxx_init_dma(uint8_t spi_index, uint8_t spi_ss)
|
|||
spi_chip_select = spi_ss;
|
||||
sipeed_spi_init(spi_bus_no, SPI_WORK_MODE_0, SPI_FF_STANDARD, DATALENGTH, 0);
|
||||
uint32_t spi_clk = sysctl_clock_get_freq(SYSCTL_CLOCK_CPU) / 400 * 25 ;
|
||||
uint32_t spi_clk_return = sipeed_spi_set_clk_rate(spi_bus_no, spi_clk);
|
||||
/*uint32_t spi_clk_return = */sipeed_spi_set_clk_rate(spi_bus_no, spi_clk);
|
||||
w25qxx_page_program_fun = w25qxx_page_program_dma;
|
||||
w25qxx_read_fun = w25qxx_stand_read_data_dma;
|
||||
return W25QXX_OK;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
/* clang-format off */
|
||||
#define NO_OPERATION 0x00
|
||||
#define SOFTWARE_RESET 0x01
|
||||
#define READ_ID 0x04
|
||||
// #define READ_ID 0x04
|
||||
#define READ_STATUS 0x09
|
||||
#define READ_POWER_MODE 0x0A
|
||||
#define READ_MADCTL 0x0B
|
||||
|
|
@ -89,7 +89,7 @@
|
|||
|
||||
#define SPI_CHANNEL 0
|
||||
#define SPI_DMA_CH DMAC_CHANNEL1
|
||||
#define SPI_SLAVE_SELECT 3
|
||||
#define LCD_SPI_SLAVE_SELECT 3
|
||||
/* clang-format on */
|
||||
|
||||
void tft_hard_init(uint32_t freq, bool oct);
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ void lcd_set_area(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
|
|||
void lcd_draw_point(uint16_t x, uint16_t y, uint16_t color)
|
||||
{
|
||||
lcd_set_area(x, y, x, y);
|
||||
tft_write_byte(&color, 2);
|
||||
tft_write_byte((uint8_t*)&color, 2);
|
||||
}
|
||||
|
||||
void lcd_draw_char(uint16_t x, uint16_t y, char c, uint16_t color)
|
||||
|
|
@ -363,9 +363,8 @@ void lcd_draw_pic_roi(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t r
|
|||
{ //draw line by line
|
||||
p = (uint8_t *)(ptr) + w*2*(y_oft+ry) + 2*rx;
|
||||
lcd_set_area(x, y+y_oft, x + rw - 1, y+y_oft);
|
||||
tft_write_byte((uint32_t*)p, rw*2);//, lcd_ctl.mode ? 2 : 0);
|
||||
tft_write_byte((uint8_t*)p, rw*2);//, lcd_ctl.mode ? 2 : 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -379,7 +378,7 @@ void lcd_draw_pic_gray(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height
|
|||
g_lcd_display_buff[i] = gray2rgb565_swap[ptr[i+1]>>2];
|
||||
g_lcd_display_buff[i+1] = gray2rgb565_swap[ptr[i]>>2];
|
||||
}
|
||||
tft_write_word(g_lcd_display_buff, width * height / 2);
|
||||
tft_write_word((uint32_t*)g_lcd_display_buff, width * height / 2);
|
||||
}
|
||||
|
||||
void lcd_draw_pic_grayroi(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t rx, uint16_t ry, uint16_t rw, uint16_t rh, uint8_t *ptr)
|
||||
|
|
|
|||
|
|
@ -69,12 +69,12 @@ void tft_write_command(uint8_t cmd)
|
|||
spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0);
|
||||
spi_init_non_standard(SPI_CHANNEL, 8 /*instrction length*/, 0 /*address length*/, 0 /*wait cycles*/,
|
||||
SPI_AITM_AS_FRAME_FORMAT /*spi address trans mode*/);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, SPI_SLAVE_SELECT, (uint8_t *)(&cmd), 1, SPI_TRANS_CHAR);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, LCD_SPI_SLAVE_SELECT, (uint8_t *)(&cmd), 1, SPI_TRANS_CHAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
spi_init(SPI_CHANNEL, standard_work_mode, SPI_FF_STANDARD, 8, 0);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, SPI_SLAVE_SELECT, (uint8_t *)(&cmd), 1, SPI_TRANS_CHAR);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, LCD_SPI_SLAVE_SELECT, (uint8_t *)(&cmd), 1, SPI_TRANS_CHAR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,12 +86,12 @@ void tft_write_byte(uint8_t *data_buf, uint32_t length)
|
|||
spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 8, 0);
|
||||
spi_init_non_standard(SPI_CHANNEL, 0 /*instrction length*/, 8 /*address length*/, 0 /*wait cycles*/,
|
||||
SPI_AITM_AS_FRAME_FORMAT /*spi address trans mode*/);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_CHAR);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, LCD_SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_CHAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
spi_init(SPI_CHANNEL, standard_work_mode, SPI_FF_STANDARD, 8, 0);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_CHAR);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, LCD_SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_CHAR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,12 +103,12 @@ void tft_write_half(uint16_t *data_buf, uint32_t length)
|
|||
spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 16, 0);
|
||||
spi_init_non_standard(SPI_CHANNEL, 0 /*instrction length*/, 16 /*address length*/, 0 /*wait cycles*/,
|
||||
SPI_AITM_AS_FRAME_FORMAT /*spi address trans mode*/);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_SHORT);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, LCD_SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_SHORT);
|
||||
}
|
||||
else
|
||||
{
|
||||
spi_init(SPI_CHANNEL, standard_work_mode, SPI_FF_STANDARD, 16, 0);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_SHORT);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, LCD_SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_SHORT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -121,12 +121,12 @@ void tft_write_word(uint32_t *data_buf, uint32_t length)
|
|||
|
||||
spi_init_non_standard(SPI_CHANNEL, 0 /*instrction length*/, 32 /*address length*/, 0 /*wait cycles*/,
|
||||
SPI_AITM_AS_FRAME_FORMAT /*spi address trans mode*/);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_INT);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, LCD_SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_INT);
|
||||
}
|
||||
else
|
||||
{
|
||||
spi_init(SPI_CHANNEL, standard_work_mode, SPI_FF_STANDARD, 32, 0);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_INT);
|
||||
spi_send_data_normal_dma(SPI_DMA_CH, SPI_CHANNEL, LCD_SPI_SLAVE_SELECT, data_buf, length, SPI_TRANS_INT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -138,12 +138,12 @@ void tft_fill_data(uint32_t *data_buf, uint32_t length)
|
|||
spi_init(SPI_CHANNEL, SPI_WORK_MODE_0, SPI_FF_OCTAL, 32, 0);
|
||||
spi_init_non_standard(SPI_CHANNEL, 0 /*instrction length*/, 32 /*address length*/, 0 /*wait cycles*/,
|
||||
SPI_AITM_AS_FRAME_FORMAT /*spi address trans mode*/);
|
||||
spi_fill_data_dma(SPI_DMA_CH, SPI_CHANNEL, SPI_SLAVE_SELECT, data_buf, length);
|
||||
spi_fill_data_dma(SPI_DMA_CH, SPI_CHANNEL, LCD_SPI_SLAVE_SELECT, data_buf, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
spi_init(SPI_CHANNEL, standard_work_mode, SPI_FF_STANDARD, 32, 0);
|
||||
spi_fill_data_dma(SPI_DMA_CH, SPI_CHANNEL, SPI_SLAVE_SELECT, data_buf, length);
|
||||
spi_fill_data_dma(SPI_DMA_CH, SPI_CHANNEL, LCD_SPI_SLAVE_SELECT, data_buf, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ static void sipeed_spi_set_tmod(uint8_t spi_num, uint32_t tmod)
|
|||
void sipeed_spi_transfer_data_standard(spi_device_num_t spi_num, spi_chip_select_t chip_select, const uint8_t *tx_buff,uint8_t *rx_buff, size_t tx_len, size_t rx_len)
|
||||
{
|
||||
configASSERT(spi_num < SPI_DEVICE_MAX && spi_num != 2);
|
||||
configASSERT(tx_len > 0 && rx_len>=0 && tx_len >= rx_len);
|
||||
configASSERT(tx_len > 0 && tx_len >= rx_len);
|
||||
size_t index, fifo_len;
|
||||
sipeed_spi_set_tmod(spi_num, SPI_TMOD_TRANS_RECV);
|
||||
|
||||
|
|
|
|||
|
|
@ -143,8 +143,8 @@ static int entry_index(region_layer_t *rl, int location, int entry)
|
|||
static void softmax(float *data, int n, int stride)
|
||||
{
|
||||
int i;
|
||||
int diff;
|
||||
float e;
|
||||
// int diff;
|
||||
// float e;
|
||||
float sum = 0;
|
||||
float largest_i = data[0];
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ static void get_region_boxes(region_layer_t *rl, float *predictions, float **pro
|
|||
correct_region_boxes(rl, boxes);
|
||||
}
|
||||
|
||||
static int nms_comparator(void *pa, void *pb)
|
||||
static int nms_comparator(const void *pa, const void *pb)
|
||||
{
|
||||
sortable_box_t a = *(sortable_box_t *)pa;
|
||||
sortable_box_t b = *(sortable_box_t *)pb;
|
||||
|
|
@ -394,7 +394,6 @@ static void region_layer_output(region_layer_t *rl, obj_info_t *obj_info)
|
|||
uint32_t obj_number = 0;
|
||||
uint32_t image_width = rl->image_width;
|
||||
uint32_t image_height = rl->image_height;
|
||||
uint32_t boxes_number = rl->boxes_number;
|
||||
float threshold = rl->threshold;
|
||||
box_t *boxes = (box_t *)rl->boxes;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,15 @@
|
|||
|
||||
#include "py/ringbuf.h"
|
||||
#include "lib/utils/interrupt_char.h"
|
||||
#include "mpconfigport.h"
|
||||
|
||||
extern ringbuf_t stdin_ringbuf;
|
||||
|
||||
#if MICROPY_PY_THREAD
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
extern ringbuf_t stdin_ringbuf;
|
||||
extern TaskHandle_t mp_main_task_handle;
|
||||
#endif
|
||||
|
||||
//uint32_t mp_hal_ticks_us(void);
|
||||
//uint32_t mp_hal_ticks_ms(void);
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ STATIC mp_obj_t Maix_fft_freq(size_t n_args, const mp_obj_t *pos_args, mp_map_t
|
|||
ARG_sample_rate,
|
||||
};
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_points, MP_ARG_INT, {.u_obj = 64} },
|
||||
{ MP_QSTR_points, MP_ARG_INT, {.u_int = 64} },
|
||||
{ MP_QSTR_sample_rate, MP_ARG_INT, {.u_int = 16000} },
|
||||
};
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ STATIC mp_obj_t Maix_set_function(size_t n_args, const mp_obj_t *pos_args, mp_ma
|
|||
uint16_t pin_num = args[ARG_pin].u_int;
|
||||
fpioa_function_t func_num = args[ARG_func].u_int;
|
||||
|
||||
if(pin_num < 0 || pin_num > FPIOA_NUM_IO)
|
||||
if(pin_num > FPIOA_NUM_IO)
|
||||
mp_raise_ValueError("Don't have this Pin");
|
||||
|
||||
if(func_num < 0 || func_num > USABLE_FUNC_NUM)
|
||||
|
|
|
|||
|
|
@ -172,13 +172,14 @@ void Maix_gpios_deinit(void) {
|
|||
}
|
||||
}
|
||||
|
||||
STATIC void Maix_gpio_isr_handler(void *arg) {
|
||||
STATIC int Maix_gpio_isr_handler(void *arg) {
|
||||
Maix_gpio_obj_t *self = arg;
|
||||
//only gpiohs support irq,so only support gpiohs in this func
|
||||
mp_obj_t handler = self->callback;
|
||||
mp_call_function_2(handler, MP_OBJ_FROM_PTR(self), mp_obj_new_int_from_uint(self->id));
|
||||
// mp_sched_schedule(handler, MP_OBJ_FROM_PTR(self));
|
||||
// mp_hal_wake_main_task_from_isr();
|
||||
return 0;
|
||||
}
|
||||
|
||||
gpio_num_t Maix_gpio_get_id(mp_obj_t pin_in) {
|
||||
|
|
@ -213,7 +214,7 @@ STATIC mp_obj_t Maix_gpio_obj_init_helper(const Maix_gpio_obj_t *self, size_t n_
|
|||
mp_int_t pin_io_mode = mp_obj_get_int(args[ARG_mode].u_obj);
|
||||
if (0 <= self->num && self->num < MP_ARRAY_SIZE(Maix_gpio_obj)) {
|
||||
self = (Maix_gpio_obj_t*)&Maix_gpio_obj[self->num];
|
||||
if(pin_io_mode == GPIO_DM_OUTPUT && args[ARG_pull].u_obj != mp_const_none && args[ARG_pull].u_obj != GPIO_DM_PULL_NONE){
|
||||
if(pin_io_mode == GPIO_DM_OUTPUT && args[ARG_pull].u_obj != mp_const_none && mp_obj_get_int(args[ARG_pull].u_obj) != GPIO_DM_PULL_NONE){
|
||||
mp_raise_ValueError("When this pin is in output mode, it is not allowed to pull up and down.");
|
||||
}else{
|
||||
if(args[ARG_pull].u_obj != mp_const_none && mp_obj_get_int(args[ARG_pull].u_obj) != GPIO_DM_PULL_NONE ){
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ const mp_obj_type_t Maix_i2s_type;
|
|||
|
||||
STATIC void Maix_i2s_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
Maix_i2s_obj_t* self = MP_OBJ_TO_PTR(self_in);
|
||||
i2s_channle_t* channel_iter = &self->channel[0];
|
||||
// i2s_channle_t* channel_iter = &self->channel[0];
|
||||
mp_printf(print, "[MAIXPY]i2s%d:(sampling rate=%u, sampling points=%u)\n",
|
||||
self->i2s_num,self->sample_rate,self->points_num);
|
||||
for(int channel_iter = 0; channel_iter < 4; channel_iter++)
|
||||
|
|
@ -186,8 +186,9 @@ STATIC mp_obj_t Maix_i2s_channel_config(size_t n_args, const mp_obj_t *pos_args,
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(Maix_i2s_channel_config_obj, 2, Maix_i2s_channel_config);
|
||||
|
||||
STATIC mp_obj_t Maix_i2s_set_sample_rate(Maix_i2s_obj_t *self, mp_obj_t sample_rate)
|
||||
STATIC mp_obj_t Maix_i2s_set_sample_rate(void* self_, mp_obj_t sample_rate)
|
||||
{
|
||||
Maix_i2s_obj_t* self = (Maix_i2s_obj_t*)self_;
|
||||
uint32_t smp_rate = mp_obj_get_int(sample_rate);
|
||||
if(smp_rate > MAX_SAMPLE_RATE)
|
||||
{
|
||||
|
|
@ -263,16 +264,18 @@ STATIC mp_obj_t Maix_i2s_record(size_t n_args, const mp_obj_t *pos_args, mp_map_
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(Maix_i2s_record_obj,1,Maix_i2s_record);
|
||||
|
||||
STATIC mp_obj_t Maix_i2s_play(Maix_i2s_obj_t *self,mp_obj_t audio_obj)
|
||||
STATIC mp_obj_t Maix_i2s_play(void*self_, mp_obj_t audio_obj)
|
||||
{
|
||||
Maix_i2s_obj_t* self = (Maix_i2s_obj_t*)self_;
|
||||
Maix_audio_obj_t *audio_p = MP_OBJ_TO_PTR(audio_obj);
|
||||
i2s_send_data_dma(self->i2s_num, audio_p->audio.buf, audio_p->audio.points, DMAC_CHANNEL4);
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(Maix_i2s_play_obj,Maix_i2s_play);
|
||||
|
||||
STATIC mp_obj_t Maix_i2s_deinit(Maix_i2s_obj_t *self)
|
||||
STATIC mp_obj_t Maix_i2s_deinit(void*self_)
|
||||
{
|
||||
Maix_i2s_obj_t* self = (Maix_i2s_obj_t*)self_;
|
||||
m_del(uint32_t,self->buf,self->points_num);
|
||||
m_del_obj(Maix_i2s_obj_t,self);
|
||||
return mp_const_none;
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ static void py_kpu_net_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_p
|
|||
addr = mp_obj_get_int(self->model_addr);
|
||||
}
|
||||
|
||||
const char net_args[512];
|
||||
char net_args[512];
|
||||
|
||||
if(py_kpu_class_yolo2_print_to_buf(self->net_args, net_args) != 0)
|
||||
{
|
||||
|
|
@ -304,15 +304,15 @@ int model_deinit(kpu_task_t *task)
|
|||
{
|
||||
for (uint32_t i = 0; i < task->layers_length; i++)
|
||||
{
|
||||
free(task->layers[i].kernel_calc_type_cfg.data.active_addr);
|
||||
free(task->layers[i].kernel_pool_type_cfg.data.bwsx_base_addr);
|
||||
free(task->layers[i].kernel_load_cfg.data.para_start_addr);
|
||||
free((void*)task->layers[i].kernel_calc_type_cfg.data.active_addr);
|
||||
free((void*)task->layers[i].kernel_pool_type_cfg.data.bwsx_base_addr);
|
||||
free((void*)task->layers[i].kernel_load_cfg.data.para_start_addr);
|
||||
}
|
||||
free(task->layers);
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t py_kpu_class_load(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_kpu_class_load(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
{
|
||||
int err = 0;
|
||||
uint32_t model_size;
|
||||
|
|
@ -383,7 +383,7 @@ STATIC mp_obj_t py_kpu_class_load(uint n_args, const mp_obj_t *pos_args, mp_map_
|
|||
o->net_args = mp_const_none;
|
||||
o->net_deinit = mp_const_none;
|
||||
o->model_size = mp_obj_new_int(model_size);
|
||||
o->max_layers = sipeed_kpu_model_get_layer_num(o->kmodel_ctx);
|
||||
o->max_layers = mp_obj_new_int(sipeed_kpu_model_get_layer_num(o->kmodel_ctx));
|
||||
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
|
||||
|
|
@ -548,7 +548,7 @@ mp_obj_t py_kpu_calss_yolo2_deinit(mp_obj_t self_in)
|
|||
}
|
||||
}
|
||||
|
||||
STATIC mp_obj_t py_kpu_class_init_yolo2(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_kpu_class_init_yolo2(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
{
|
||||
enum { ARG_kpu_net, ARG_threshold, ARG_nms_value, ARG_anchor_number, ARG_anchor};
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
|
|
@ -734,7 +734,7 @@ static void ai_done(void *ctx)
|
|||
g_ai_done_flag = 1;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t py_kpu_class_run_yolo2(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_kpu_class_run_yolo2(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
{
|
||||
if(mp_obj_get_type(pos_args[0]) == &py_kpu_net_obj_type)
|
||||
{
|
||||
|
|
@ -856,7 +856,7 @@ void call_deinit(call_net_arg_deinit call_back, mp_obj_t o)
|
|||
call_back(o);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t py_kpu_deinit(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_kpu_deinit(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
{
|
||||
if(mp_obj_get_type(pos_args[0]) == &py_kpu_net_obj_type)
|
||||
{
|
||||
|
|
@ -1066,7 +1066,7 @@ mp_obj_t py_kpu_fmap_index(mp_obj_t self_in) { return mp_obj_new_int(((py_kpu_fm
|
|||
mp_obj_t py_kpu_fmap_w(mp_obj_t self_in) { return mp_obj_new_int(((py_kpu_fmap_obj_t *)self_in)->fmap.w); }
|
||||
mp_obj_t py_kpu_fmap_h(mp_obj_t self_in) { return mp_obj_new_int(((py_kpu_fmap_obj_t *)self_in)->fmap.h); }
|
||||
mp_obj_t py_kpu_fmap_ch(mp_obj_t self_in) { return mp_obj_new_int(((py_kpu_fmap_obj_t *)self_in)->fmap.ch); }
|
||||
mp_obj_t py_kpu_fmap_typecode(mp_obj_t self_in) { return mp_obj_new_str(((py_kpu_fmap_obj_t *)self_in)->fmap.typecode,1); }
|
||||
mp_obj_t py_kpu_fmap_typecode(mp_obj_t self_in) { return mp_obj_new_str((const char*)((py_kpu_fmap_obj_t *)self_in)->fmap.typecode,1); }
|
||||
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(py_kpu_fmap_size_obj, py_kpu_fmap_size);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(py_kpu_fmap_index_obj, py_kpu_fmap_index);
|
||||
|
|
@ -1118,14 +1118,14 @@ STATIC mp_obj_t py_kpu_set_layers(mp_obj_t kpu_net_obj, mp_obj_t len_obj)
|
|||
py_kpu_net_obj_t *kpu_net = MP_OBJ_TO_PTR(kpu_net_obj);
|
||||
int layers_length = mp_obj_get_int(len_obj); //how many layers you want calculate, set <=0 to calculate all layers
|
||||
int max_length = mp_obj_get_int(kpu_net->max_layers);
|
||||
sipeed_kpu_err_t ret;
|
||||
// sipeed_kpu_err_t ret;
|
||||
|
||||
if(layers_length > 0)
|
||||
{ //set layer count
|
||||
if(layers_length <= max_length)
|
||||
{
|
||||
//mp_printf(&mp_plat_print, "set layers_length to %d\r\n", layers_length);
|
||||
ret = sipeed_kpu_model_set_output(kpu_net->kmodel_ctx, 0, layers_length);
|
||||
/* ret = */sipeed_kpu_model_set_output(kpu_net->kmodel_ctx, 0, layers_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1141,7 +1141,7 @@ STATIC mp_obj_t py_kpu_set_layers(mp_obj_t kpu_net_obj, mp_obj_t len_obj)
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_kpu_set_layers_obj, py_kpu_set_layers);
|
||||
|
||||
STATIC mp_obj_t py_kpu_forward(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_kpu_forward(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
{
|
||||
enum { ARG_kpu_net, ARG_img, ARG_out_index};
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
|
|
@ -1185,7 +1185,7 @@ STATIC mp_obj_t py_kpu_forward(uint n_args, const mp_obj_t *pos_args, mp_map_t *
|
|||
uint8_t* features;
|
||||
size_t count;
|
||||
kpu_model_layer_type_t layer_type;
|
||||
ret = sipeed_kpu_model_get_layer_type(kpu_net->kmodel_ctx, kpu_net->max_layers-1, &layer_type);
|
||||
ret = sipeed_kpu_model_get_layer_type(kpu_net->kmodel_ctx, mp_obj_get_int(kpu_net->max_layers)-1, &layer_type);
|
||||
if(ret != SIPEED_KPU_ERR_NONE)
|
||||
{
|
||||
snprintf(char_temp, sizeof(char_temp), "%d", ret);
|
||||
|
|
@ -1202,10 +1202,10 @@ STATIC mp_obj_t py_kpu_forward(uint n_args, const mp_obj_t *pos_args, mp_map_t *
|
|||
fmap_t* fmap = &(o->fmap);
|
||||
fmap->data = features;
|
||||
fmap->size = (uint32_t)count + 1;
|
||||
fmap->index = kpu_net->max_layers-1;
|
||||
fmap->index = mp_obj_get_int(kpu_net->max_layers)-1;
|
||||
if(layer_type == KL_K210_CONV)
|
||||
{ //conv layer
|
||||
kpu_layer_argument_t* layer = sipeed_kpu_model_get_conv_layer(kpu_net->kmodel_ctx, kpu_net->max_layers-1);
|
||||
kpu_layer_argument_t* layer = sipeed_kpu_model_get_conv_layer(kpu_net->kmodel_ctx, mp_obj_get_int(kpu_net->max_layers)-1);
|
||||
if(!layer)
|
||||
{
|
||||
snprintf(char_temp, sizeof(char_temp), "%d", SIPEED_KPU_ERR_GET_CONV_LAYER);
|
||||
|
|
|
|||
|
|
@ -78,9 +78,9 @@ STATIC mp_obj_t Maix_mic_array_init(size_t n_args, const mp_obj_t *pos_args, mp_
|
|||
int ret = lib_mic_init(DMAC_CHANNEL4, lib_mic_cb, thermal_map_data);
|
||||
if(ret != 0)
|
||||
{
|
||||
uint8_t tmp[64];
|
||||
char tmp[64];
|
||||
sprintf(tmp,"lib_mic init error with %d",ret);
|
||||
mp_raise_ValueError(tmp);
|
||||
mp_raise_ValueError((const char*)tmp);
|
||||
return mp_const_false;
|
||||
}
|
||||
lib_init_flag = 1;
|
||||
|
|
|
|||
|
|
@ -14,17 +14,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "py/nlr.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/binary.h"
|
||||
#include <stdio.h>
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "modMaix.h"
|
||||
|
||||
#if MICROPY_PY_MACHINE
|
||||
|
||||
STATIC const mp_map_elem_t maix_module_globals_table[] = {
|
||||
STATIC const mp_rom_map_elem_t maix_module_globals_table[] = {
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_machine) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_FPIOA), MP_ROM_PTR(&Maix_fpioa_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GPIO), MP_ROM_PTR(&Maix_gpio_type) },
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ mp_obj_t py_kpufreq_get_kpu()
|
|||
return mp_obj_new_int(sysctl_clock_get_freq(SYSCTL_CLOCK_AI) / (1000000));
|
||||
}
|
||||
|
||||
mp_obj_t py_cpufreq_set_frequency(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
mp_obj_t py_cpufreq_set_frequency(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
{
|
||||
config_data_t config;
|
||||
enum {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ STATIC mp_obj_t Maix_audio_init_helper(Maix_audio_obj_t *self, size_t n_args, co
|
|||
ARG_points};
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_array, MP_ARG_OBJ , {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_path, MP_ARG_OBJ , {.u_int = mp_const_none} },
|
||||
{ MP_QSTR_path, MP_ARG_OBJ , {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_points, MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = MAX_SAMPLE_POINTS} },
|
||||
};
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
|
|
@ -84,7 +84,7 @@ STATIC mp_obj_t Maix_audio_init_helper(Maix_audio_obj_t *self, size_t n_args, co
|
|||
}else if(args[ARG_path].u_obj != mp_const_none)
|
||||
{
|
||||
int err = 0;
|
||||
char* path_str = mp_obj_str_get_str(args[ARG_path].u_obj);
|
||||
char* path_str = (char*)mp_obj_str_get_str(args[ARG_path].u_obj);
|
||||
mp_obj_t fp = vfs_internal_open(path_str,"rb",&err);
|
||||
if( err != 0)
|
||||
mp_raise_OSError(err);
|
||||
|
|
@ -129,8 +129,8 @@ STATIC mp_obj_t Maix_audio_init(size_t n_args, const mp_obj_t *args, mp_map_t *k
|
|||
MP_DEFINE_CONST_FUN_OBJ_KW(Maix_audio_init_obj,0 ,Maix_audio_init);
|
||||
|
||||
//----------------bo byte ------------------------
|
||||
STATIC mp_obj_t Maix_audio_to_bytes(Maix_audio_obj_t* self) {
|
||||
audio_t* audio = &self->audio;
|
||||
STATIC mp_obj_t Maix_audio_to_bytes(void* self) {
|
||||
audio_t* audio = &((Maix_audio_obj_t*)self)->audio;
|
||||
if(audio->buf == NULL || audio->points == 0)
|
||||
mp_raise_msg(&mp_type_AttributeError,"empty Audio");
|
||||
mp_obj_array_t* audio_array = m_new_obj(mp_obj_array_t);
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ mp_obj_t wav_play_process(audio_t* audio,uint32_t file_size)
|
|||
vfs_internal_close(audio->fp,&close_code);
|
||||
}
|
||||
uint32_t head_max_len = audio->points*(sizeof(uint32_t));
|
||||
uint32_t read_num = vfs_internal_read(audio->fp,audio->buf, head_max_len,&err_code);//read head
|
||||
/* uint32_t read_num = */vfs_internal_read(audio->fp,audio->buf, head_max_len,&err_code);//read head
|
||||
if(err_code != 0)
|
||||
{
|
||||
mp_printf(&mp_plat_print, "[MAIXPY]: read head error close file\n");
|
||||
|
|
@ -240,8 +240,8 @@ mp_obj_t wav_play(audio_t* audio)
|
|||
return mp_obj_new_int(0);
|
||||
if(play_obj->numchannels == 1)//TODO: optimize mono
|
||||
{
|
||||
int16_t* src = play_obj->audio_buf[play_obj->read_order].buf + audio->points * sizeof(uint32_t)/2;
|
||||
int32_t* dst = play_obj->audio_buf[play_obj->read_order].buf;
|
||||
int16_t* src = (int16_t*)(play_obj->audio_buf[play_obj->read_order].buf + audio->points * sizeof(uint32_t)/2);
|
||||
int32_t* dst = (int32_t*)(play_obj->audio_buf[play_obj->read_order].buf);
|
||||
for(int i=0; i<read_num/sizeof(int16_t); ++i)
|
||||
{
|
||||
src[i] = (int16_t)(src[i] * audio->volume / 100);
|
||||
|
|
@ -251,7 +251,7 @@ mp_obj_t wav_play(audio_t* audio)
|
|||
}
|
||||
else
|
||||
{
|
||||
int32_t* audio_buf = play_obj->audio_buf[play_obj->read_order].buf;
|
||||
int32_t* audio_buf = (int32_t*)play_obj->audio_buf[play_obj->read_order].buf;
|
||||
for(int i = 0; i < read_num / sizeof(uint32_t); i++)//Currently only supports two-channel wav files
|
||||
{
|
||||
LSB_audio = audio_buf[i];
|
||||
|
|
@ -283,7 +283,6 @@ mp_obj_t wav_play(audio_t* audio)
|
|||
|
||||
mp_obj_t wav_record_process(audio_t* audio,uint32_t channels)//channels = Number of channels
|
||||
{
|
||||
uint32_t head_len = 0;
|
||||
int err_code = 0;
|
||||
int close_code = 0;
|
||||
Maix_i2s_obj_t* i2s_dev = audio->dev;
|
||||
|
|
@ -350,9 +349,7 @@ mp_obj_t wav_record_process(audio_t* audio,uint32_t channels)//channels = Number
|
|||
mp_obj_t wav_record(audio_t* audio,dmac_channel_number_t DMA_channel)
|
||||
{
|
||||
wav_encode_t* record_obj = audio->record_obj; //get format
|
||||
Maix_i2s_obj_t* i2s_dev = audio->dev;//get device
|
||||
uint32_t read_num = 0;
|
||||
int err_code = 0;
|
||||
// Maix_i2s_obj_t* i2s_dev = audio->dev;//get device
|
||||
if(!record_obj->audio_buf[record_obj->write_order].empty)//empty ,altread to read
|
||||
{
|
||||
// mp_printf(&mp_plat_print, "[MAIXPY]: read_order = %d\n",play_obj->read_order);
|
||||
|
|
@ -375,15 +372,17 @@ int wav_process_data(audio_t* audio)//GO righit channel record, right chnanel pl
|
|||
if(1 == wav_encode->format.numchannels){//mono audio record | Go mic right
|
||||
|
||||
uint16_t* buf = (uint16_t*)malloc(audio->points * sizeof(uint32_t));//
|
||||
int j = 0;
|
||||
// int j = 0;
|
||||
for(int i = 0; i < audio->points; i += 1){
|
||||
buf[i*2] = 0;//left channel
|
||||
buf[i*2+1] = audio->buf[i] & 0xffff;//right channle 16 bit resolution
|
||||
// buf[i*2+1] = (audio->buf[i] >> 8) & 0xffff;//24 bit resolution
|
||||
}
|
||||
vfs_internal_write(audio->fp,buf,audio->points * sizeof(uint32_t),&err_code);
|
||||
vfs_internal_write(audio->fp,buf,audio->points * sizeof(uint32_t), &err_code);
|
||||
wav_encode->data.chunk_size += audio->points * sizeof(uint32_t);
|
||||
free(buf);
|
||||
if(err_code!=0)
|
||||
return err_code;
|
||||
}
|
||||
else if(2 == wav_encode->format.numchannels){//stereo audio record
|
||||
//TODO
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ DWORD get_fattime(void) {
|
|||
uint32_t hour = 0;
|
||||
uint32_t min = 0;
|
||||
uint32_t sec = 0;
|
||||
rtc_timer_get(&year,&mon,&mday,&hour,&min,&sec);
|
||||
rtc_timer_get((int*)&year, (int*)&mon, (int*)&mday, (int*)&hour, (int*)&min, (int*)&sec);
|
||||
return (year << 25) | (mon << 21) | (mday << 16) | (hour << 11) | (min << 5) | ( sec / 2 );
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ void mp_task(
|
|||
volatile void *mp_main_stack_top = &stack_p;
|
||||
mp_thread_init(mp_main_stack_top, MP_TASK_STACK_LEN);
|
||||
#else
|
||||
volatile void* mp_main_stack_top = (uint32_t)get_sp();
|
||||
volatile void* mp_main_stack_top = (void*)get_sp();
|
||||
#endif
|
||||
soft_reset:
|
||||
// initialise the stack pointer for the main thread
|
||||
|
|
@ -481,8 +481,6 @@ void* arg_list[16];
|
|||
|
||||
int core1_function(void *ctx)
|
||||
{
|
||||
uint64_t core = current_coreid();
|
||||
|
||||
while(1)
|
||||
{
|
||||
if(dual_func)
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ STATIC const mp_obj_type_t uhashlib_sha256_type = {
|
|||
{ &mp_type_type },
|
||||
.name = MP_QSTR_sha256,
|
||||
.make_new = uhashlib_sha256_make_new,
|
||||
.locals_dict = &uhashlib_sha256_locals_dict,
|
||||
.locals_dict = (mp_obj_dict_t*)&uhashlib_sha256_locals_dict,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ int mp_hal_stdin_rx_chr(void) {
|
|||
}
|
||||
|
||||
}
|
||||
void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len);
|
||||
void mp_hal_debug_tx_strn_cooked(void *env, const char *str, size_t len);
|
||||
|
||||
const mp_print_t mp_debug_print = {NULL, mp_hal_debug_tx_strn_cooked};
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
|
|||
mp_uos_dupterm_tx_strn(str, len);
|
||||
}
|
||||
|
||||
void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len) {
|
||||
void mp_hal_debug_tx_strn_cooked(void *env, const char *str, size_t len) {
|
||||
(void)env;
|
||||
while (len--) {
|
||||
if (*str == '\n') {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ int nes_volume=5; //0~8
|
|||
int nes_cycle_us=0; //60fps, 63us per cycle
|
||||
int repeat_n = 16;
|
||||
|
||||
mp_obj_t py_nes_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
mp_obj_t py_nes_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
int cs_num, mosi_num, miso_num, clk_num;
|
||||
|
||||
|
|
|
|||
|
|
@ -174,7 +174,6 @@ int cambus_scan()
|
|||
for (uint8_t addr=0x08; addr<=0x77; addr++) {
|
||||
if( cambus_read_id(addr ,&manuf_id,&device_id) != 0)
|
||||
continue;
|
||||
uint8_t temp[2];
|
||||
if(device_id!=0 && device_id!=0xffff)
|
||||
{
|
||||
return addr;
|
||||
|
|
@ -208,8 +207,6 @@ int cambus_readb(uint8_t slv_addr, uint8_t reg_addr, uint8_t *reg_data)
|
|||
|
||||
int cambus_writeb(uint8_t slv_addr, uint8_t reg_addr, uint8_t reg_data)
|
||||
{
|
||||
|
||||
int ret=0;
|
||||
sccb_i2c_write_byte(i2c_device, slv_addr, reg_addr, sccb_reg_width, reg_data, 10);
|
||||
mp_hal_delay_ms(10);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include "framebuffer.h"
|
||||
|
||||
mutex_t lock_tmp;
|
||||
static framebuffer_t _fb_framebuffer0={0,0,0,0,0,0,0,NULL,NULL};
|
||||
static framebuffer_t _fb_framebuffer0={0,0,0,0,0,0,0,0,0,NULL,NULL};
|
||||
// static framebuffer_t _fb_framebuffer1={0,0,0,0,0,0,0,NULL,g_ai_buf_out};
|
||||
framebuffer_t *fb_framebuffer = &_fb_framebuffer0;
|
||||
|
||||
|
|
|
|||
|
|
@ -968,15 +968,14 @@ static int gc0328_read_reg(sensor_t *sensor, uint8_t reg_addr)
|
|||
return reg_data;
|
||||
}
|
||||
|
||||
static int gc0328_write_reg(sensor_t *sensor, uint8_t reg_addr, uint8_t reg_data)
|
||||
static int gc0328_write_reg(sensor_t *sensor, uint8_t reg_addr, uint16_t reg_data)
|
||||
{
|
||||
return cambus_writeb(sensor->slv_addr, reg_addr, reg_data);
|
||||
return cambus_writeb(sensor->slv_addr, reg_addr, (uint8_t)reg_data);
|
||||
}
|
||||
|
||||
|
||||
static int gc0328_set_pixformat(sensor_t *sensor, pixformat_t pixformat)
|
||||
{
|
||||
int i=0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1027,56 +1026,48 @@ static int gc0328_set_quality(sensor_t *sensor, int qs)
|
|||
|
||||
static int gc0328_set_colorbar(sensor_t *sensor, int enable)
|
||||
{
|
||||
uint8_t reg;
|
||||
int ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int gc0328_set_auto_gain(sensor_t *sensor, int enable, float gain_db, float gain_db_ceiling)
|
||||
{
|
||||
uint8_t reg;
|
||||
int ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int gc0328_get_gain_db(sensor_t *sensor, float *gain_db)
|
||||
{
|
||||
uint8_t reg, gain;
|
||||
int ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int gc0328_set_auto_exposure(sensor_t *sensor, int enable, int exposure_us)
|
||||
{
|
||||
uint8_t reg;
|
||||
int ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int gc0328_get_exposure_us(sensor_t *sensor, int *exposure_us)
|
||||
{
|
||||
uint8_t reg, aec_10, aec_92, aec_1510;
|
||||
int ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int gc0328_set_auto_whitebal(sensor_t *sensor, int enable, float r_gain_db, float g_gain_db, float b_gain_db)
|
||||
{
|
||||
uint8_t reg;
|
||||
int ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int gc0328_get_rgb_gain_db(sensor_t *sensor, float *r_gain_db, float *g_gain_db, float *b_gain_db)
|
||||
{
|
||||
uint8_t reg;
|
||||
int ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int gc0328_set_hmirror(sensor_t *sensor, int enable)
|
||||
{
|
||||
uint8_t reg;
|
||||
int ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1089,7 +1080,7 @@ static int gc0328_set_vflip(sensor_t *sensor, int enable)
|
|||
}
|
||||
|
||||
|
||||
int gc0328_reset(void)
|
||||
int gc0328_reset(sensor_t* sensor)
|
||||
{
|
||||
uint16_t index = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ ack_start:
|
|||
else if(UART_DEVICE_MAX > uart->uart_num)
|
||||
{
|
||||
// uart_configure(uart->uart_num, (size_t)uart->baudrate, (size_t)uart->bitwidth, uart->stop, uart->parity);
|
||||
temp_size= uart_send_data(uart->uart_num, JPEG_FB()->pixels, xfer_length);
|
||||
temp_size= uart_send_data(uart->uart_num, (const char*)JPEG_FB()->pixels, xfer_length);
|
||||
}
|
||||
cmd = USBDBG_NONE;
|
||||
xfer_bytes = xfer_length;
|
||||
|
|
@ -262,7 +262,7 @@ ack_start:
|
|||
temp_size = uarths_send_data(ide_dbg_cmd_buf, length);
|
||||
}
|
||||
else if(UART_DEVICE_MAX > uart->uart_num)
|
||||
temp_size= uart_send_data(uart->uart_num, ide_dbg_cmd_buf, length);
|
||||
temp_size= uart_send_data(uart->uart_num, (const char*)ide_dbg_cmd_buf, length);
|
||||
xfer_bytes += length;
|
||||
if( xfer_bytes < xfer_length )
|
||||
goto ack_start;
|
||||
|
|
@ -283,7 +283,7 @@ ide_dbg_status_t ide_dbg_receive_data(machine_uart_obj_t* uart, uint8_t* data)
|
|||
// at least once before the script is fully uploaded xfer_bytes will be less
|
||||
// than the total length (xfer_length) and the script will Not be executed.
|
||||
if (!script_running && !gc_is_locked()) {
|
||||
vstr_add_strn_00(&script_buf, data, 1);
|
||||
vstr_add_strn_00(&script_buf, (const char*)data, 1);
|
||||
if (xfer_bytes+1 == xfer_length) {
|
||||
// Set script ready flag
|
||||
script_ready = true;
|
||||
|
|
@ -614,7 +614,7 @@ void ide_save_file()
|
|||
{
|
||||
|
||||
uint8_t* file_name = p_data_temp+32;
|
||||
int tmp = strlen(file_name)+1;
|
||||
int tmp = strlen((const char*)file_name)+1;
|
||||
tmp = tmp + 4-((tmp%4)?(tmp%4):4);
|
||||
data = file_name + tmp;
|
||||
uint32_t file_len = ide_file_length - 32 - tmp;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ bool bmp_read_geometry(mp_obj_t fp, image_t *img, bmp_read_settings_t *rs)
|
|||
uint32_t data_size = file_size - header_size;
|
||||
// if (data_size % 4) file_corrupted_raise(fp);
|
||||
// if (file_size % 4) file_corrupted_raise(fp);
|
||||
unsigned long header2_size;
|
||||
uint32_t header2_size;
|
||||
read_long_raise(fp, &header2_size);
|
||||
read_long_raise(fp, (uint32_t*) &rs->bmp_w);
|
||||
read_long_raise(fp, (uint32_t*) &rs->bmp_h);
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ int CLAHE (kz_pixel_t* pImage, unsigned int uiXRes, unsigned int uiYRes,
|
|||
if (uiNrY > uiMAX_REG_Y) return -2; /* # of regions y-direction too large */
|
||||
if (uiXRes % uiNrX) return -3; /* x-resolution no multiple of uiNrX */
|
||||
if (uiYRes % uiNrY) return -4; /* y-resolution no multiple of uiNrY */
|
||||
if (Max >= uiNR_OF_GREY) return -5; /* maximum too large */
|
||||
// if (Max >= uiNR_OF_GREY) return -5; /* maximum too large */
|
||||
if (Min >= Max) return -6; /* minimum equal or larger than maximum */
|
||||
if (uiNrX < 2 || uiNrY < 2) return -7;/* at least 4 contextual regions required */
|
||||
if (fCliplimit == 1.0) return 0; /* is OK, immediately returns original image. */
|
||||
|
|
|
|||
|
|
@ -31,13 +31,12 @@ static int kpu_done(void *ctx)
|
|||
|
||||
void imlib_conv3(image_t *img, float *krn)
|
||||
{
|
||||
int x,y;
|
||||
uint8_t* r;
|
||||
uint8_t* g;
|
||||
uint8_t* b;
|
||||
uint16_t* pix;
|
||||
int index,i, j;
|
||||
uint16_t c;
|
||||
int i, j;
|
||||
// uint16_t c;
|
||||
//do conv cal
|
||||
kpu_task_t task;
|
||||
if(img->pix_ai == NULL || img->pixels == NULL)
|
||||
|
|
@ -48,7 +47,7 @@ void imlib_conv3(image_t *img, float *krn)
|
|||
r=img->pix_ai;
|
||||
g=img->pix_ai+(img->w)*(img->h);
|
||||
b=img->pix_ai+(img->w)*(img->h)*2;
|
||||
pix = img->pixels;
|
||||
pix = (uint16_t*)img->pixels;
|
||||
//prepare conv kern
|
||||
memset((void*)conv_data,0,9*3*3*sizeof(float)); //clear
|
||||
for(j=0;j<9;j++)conv_data[0*27+0*9+j]=krn[j];
|
||||
|
|
@ -63,7 +62,7 @@ void imlib_conv3(image_t *img, float *krn)
|
|||
for(j=0;j<8;j++)_P("%04x ",g[j]);_P("\n");
|
||||
for(j=0;j<8;j++)_P("%04x ",b[j]);_P("\n");
|
||||
#endif
|
||||
unsigned long t0,t1;
|
||||
// unsigned long t0,t1;
|
||||
//t0=read_cycle();
|
||||
sipeed_conv_init(&task, img->w, img->h, 3, 3, conv_data);
|
||||
sipeed_conv_run(&task, img->pix_ai, img->pix_ai, kpu_done);
|
||||
|
|
|
|||
|
|
@ -2769,7 +2769,7 @@ static int
|
|||
ReadModuleColor(DmtxDecode *dec, DmtxRegion *reg, int symbolRow, int symbolCol,
|
||||
int sizeIdx, int colorPlane)
|
||||
{
|
||||
int err;
|
||||
// int err;
|
||||
int i;
|
||||
int symbolRows, symbolCols;
|
||||
int color, colorTmp=0;
|
||||
|
|
@ -2788,7 +2788,7 @@ ReadModuleColor(DmtxDecode *dec, DmtxRegion *reg, int symbolRow, int symbolCol,
|
|||
|
||||
dmtxMatrix3VMultiplyBy(&p, reg->fit2raw);
|
||||
|
||||
err = dmtxDecodeGetPixelValue(dec, (int)(p.X + 0.5), (int)(p.Y + 0.5),
|
||||
/* err = */dmtxDecodeGetPixelValue(dec, (int)(p.X + 0.5), (int)(p.Y + 0.5),
|
||||
colorPlane, &colorTmp);
|
||||
color += colorTmp;
|
||||
}
|
||||
|
|
@ -2815,9 +2815,9 @@ MatrixRegionFindSize(DmtxDecode *dec, DmtxRegion *reg)
|
|||
int colorOnAvg, bestColorOnAvg;
|
||||
int colorOffAvg, bestColorOffAvg;
|
||||
int contrast, bestContrast;
|
||||
DmtxImage *img;
|
||||
// DmtxImage *img;
|
||||
|
||||
img = dec->image;
|
||||
// img = dec->image;
|
||||
bestSizeIdx = DmtxUndefined;
|
||||
bestContrast = 0;
|
||||
bestColorOnAvg = bestColorOffAvg = 0;
|
||||
|
|
@ -3329,6 +3329,10 @@ TrailBlazeContinuous(DmtxDecode *dec, DmtxRegion *reg, DmtxPointFlow flowBegin,
|
|||
|
||||
/* Clear "visited" bit from trail */
|
||||
clears = TrailClear(dec, reg, 0x80);
|
||||
if(clears)
|
||||
{
|
||||
|
||||
}
|
||||
assert(posAssigns + negAssigns == clears - 1);
|
||||
|
||||
/* XXX clean this up ... redundant test above */
|
||||
|
|
@ -3354,7 +3358,7 @@ TrailBlazeGapped(DmtxDecode *dec, DmtxRegion *reg, DmtxBresLine line, int stream
|
|||
int xDiff, yDiff;
|
||||
int steps;
|
||||
int stepDir, dirMap[] = { 0, 1, 2, 7, 8, 3, 6, 5, 4 };
|
||||
DmtxPassFail err;
|
||||
// DmtxPassFail err;
|
||||
DmtxPixelLoc beforeStep, afterStep;
|
||||
DmtxPointFlow flow, flowNext;
|
||||
DmtxPixelLoc loc0;
|
||||
|
|
@ -3379,7 +3383,7 @@ TrailBlazeGapped(DmtxDecode *dec, DmtxRegion *reg, DmtxBresLine line, int stream
|
|||
if(flowNext.mag == DmtxUndefined)
|
||||
break;
|
||||
|
||||
err = BresLineGetStep(line, flowNext.loc, &travel, &outward);
|
||||
/* err = */BresLineGetStep(line, flowNext.loc, &travel, &outward);
|
||||
if(flowNext.mag < 50 || outward < 0 || (outward == 0 && travel < 0)) {
|
||||
onEdge = DmtxFalse;
|
||||
}
|
||||
|
|
@ -4616,7 +4620,7 @@ RsDecode(unsigned char *code, int sizeIdx, int fix)
|
|||
{
|
||||
int i;
|
||||
int blockStride, blockIdx;
|
||||
int blockDataWords, blockErrorWords, blockTotalWords, blockMaxCorrectable;
|
||||
int blockDataWords, blockErrorWords,/* blockTotalWords, */blockMaxCorrectable;
|
||||
int symbolDataWords, symbolErrorWords, symbolTotalWords;
|
||||
DmtxBoolean error, repairable;
|
||||
DmtxPassFail passFail;
|
||||
|
|
@ -4642,7 +4646,7 @@ RsDecode(unsigned char *code, int sizeIdx, int fix)
|
|||
{
|
||||
/* Data word count depends on blockIdx due to special case at 144x144 */
|
||||
blockDataWords = dmtxGetBlockDataSize(sizeIdx, blockIdx);
|
||||
blockTotalWords = blockErrorWords + blockDataWords;
|
||||
// blockTotalWords = blockErrorWords + blockDataWords;
|
||||
|
||||
/* Populate received list (rec) with data and error codewords */
|
||||
dmtxByteListInit(&rec, 0, 0, &passFail); CHKPASS;
|
||||
|
|
@ -5252,7 +5256,10 @@ dmtxImageCreate(unsigned char *pxl, int width, int height, int pack)
|
|||
default:
|
||||
return NULL;
|
||||
}
|
||||
if(err)
|
||||
{
|
||||
|
||||
}
|
||||
return img;
|
||||
}
|
||||
|
||||
|
|
@ -5681,7 +5688,9 @@ dmtxByteListPrint(DmtxByteList *list, char *prefix)
|
|||
int i;
|
||||
|
||||
if(prefix != NULL)
|
||||
{
|
||||
fprintf(stdout, "%s", prefix);
|
||||
}
|
||||
|
||||
for(i = 0; i < list->length; i++)
|
||||
fprintf(stdout, " %d", list->b[i]);
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ static void find_iris(image_t *src, array_t *gradients, int x_off, int y_off, in
|
|||
vec_t *v = (vec_t *) array_at(gradients, i);
|
||||
|
||||
// get vector from gradient to centor d
|
||||
vec_t d ={x-v->cx, y-v->cy};
|
||||
vec_t d ={x-v->cx, y-v->cy, 0, 0, 0};
|
||||
|
||||
// normalize d vector
|
||||
float m = fast_sqrtf(d.x*d.x+d.y*d.y);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#include "math.h"
|
||||
#include "fmath.h"
|
||||
|
||||
#define M_PI 3.14159265f
|
||||
#define M_PI_2 1.57079632f
|
||||
#define M_PI_4 0.78539816f
|
||||
// #define M_PI 3.14159265f
|
||||
// #define M_PI_2 1.57079632f
|
||||
// #define M_PI_4 0.78539816f
|
||||
|
||||
/*const float __atanf_lut[4] = {
|
||||
-0.0443265554792128f, //p7
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include "imlib.h"
|
||||
#define BLOCK_SIZE (126) // (2^7) - 2 // (DO NOT CHANGE!)
|
||||
|
||||
void gif_open(FIL *fp, int width, int height, bool color, bool loop)
|
||||
void gif_open(mp_obj_t fp, int width, int height, bool color, bool loop)
|
||||
{
|
||||
file_buffer_on(fp);
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ void gif_open(FIL *fp, int width, int height, bool color, bool loop)
|
|||
file_buffer_off(fp);
|
||||
}
|
||||
|
||||
void gif_add_frame(FIL *fp, image_t *img, uint16_t delay)
|
||||
void gif_add_frame(mp_obj_t fp, image_t *img, uint16_t delay)
|
||||
{
|
||||
file_buffer_on(fp);
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ void gif_add_frame(FIL *fp, image_t *img, uint16_t delay)
|
|||
file_buffer_off(fp);
|
||||
}
|
||||
|
||||
void gif_close(FIL *fp)
|
||||
void gif_close(mp_obj_t fp)
|
||||
{
|
||||
write_byte(fp, ';');
|
||||
file_close(fp);
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ array_t *imlib_detect_objects(image_t *image, cascade_t *cascade, rectangle_t *r
|
|||
int imlib_load_cascade_from_file(cascade_t *cascade, const char *path)
|
||||
{
|
||||
int i;
|
||||
FIL fp;
|
||||
mp_obj_t fp;
|
||||
FRESULT res=FR_OK;
|
||||
|
||||
file_read_open_raise(&fp, path);
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ static int find_lines_565(int ps)
|
|||
int i_start = (i_all+y_stride-1)*ps/y_stride/CORE_NUM*y_stride + roi->y + 1; //place a little more for core0
|
||||
int i_end = (i_all+y_stride-1)*(ps+1)/y_stride/CORE_NUM*y_stride + roi->y + 1;
|
||||
|
||||
for (int y = i_start, yy = roi->y + roi->h - 1; y < i_end; y += y_stride) {
|
||||
for (int y = i_start; y < i_end; y += y_stride) {
|
||||
uint16_t *row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(ptr, y);
|
||||
for (int x = roi->x + (y % x_stride) + 1, xx = roi->x + roi->w - 1; x < xx; x += x_stride) {
|
||||
int pixel; // Sobel Algorithm Below
|
||||
|
|
@ -563,13 +563,13 @@ static int find_circles(int core)
|
|||
rectangle_t *roi = (rectangle_t*)arg_list[2];
|
||||
unsigned int x_stride = (unsigned int)arg_list[3];
|
||||
unsigned int y_stride = (unsigned int)arg_list[4];
|
||||
uint32_t threshold = (uint32_t)arg_list[5];
|
||||
unsigned int x_margin = (unsigned int)arg_list[6];
|
||||
unsigned int y_margin = (unsigned int)arg_list[7];
|
||||
unsigned int r_margin = (unsigned int)arg_list[8];
|
||||
unsigned int r_min = (unsigned int)arg_list[9];
|
||||
unsigned int r_max = (unsigned int)arg_list[10];
|
||||
unsigned int r_step = (unsigned int)arg_list[11];
|
||||
// uint32_t threshold = (uint32_t)arg_list[5];
|
||||
// unsigned int x_margin = (unsigned int)arg_list[6];
|
||||
// unsigned int y_margin = (unsigned int)arg_list[7];
|
||||
// unsigned int r_margin = (unsigned int)arg_list[8];
|
||||
// unsigned int r_min = (unsigned int)arg_list[9];
|
||||
// unsigned int r_max = (unsigned int)arg_list[10];
|
||||
// unsigned int r_step = (unsigned int)arg_list[11];
|
||||
image_t *ptr = (image_t*)arg_list[12];
|
||||
|
||||
int i_start = roi->y + 1;
|
||||
|
|
|
|||
|
|
@ -603,7 +603,6 @@ void imlib_load_image(image_t *img, const char *path, mp_obj_t file)
|
|||
{
|
||||
int err = 0;
|
||||
char magic[2];
|
||||
uint16_t tmp;
|
||||
bool is_file_obj = true;
|
||||
|
||||
if( !file )
|
||||
|
|
|
|||
|
|
@ -1185,8 +1185,8 @@ uint16_t imlib_yuv_to_rgb(uint8_t y, int8_t u, int8_t v);
|
|||
void imlib_bayer_to_rgb565(image_t *img, int w, int h, int xoffs, int yoffs, uint16_t *rgbbuf);
|
||||
|
||||
/* Image file functions */
|
||||
void ppm_read_geometry(FIL *fp, image_t *img, const char *path, ppm_read_settings_t *rs);
|
||||
void ppm_read_pixels(FIL *fp, image_t *img, int line_start, int line_end, ppm_read_settings_t *rs);
|
||||
void ppm_read_geometry(mp_obj_t fp, image_t *img, const char *path, ppm_read_settings_t *rs);
|
||||
void ppm_read_pixels(mp_obj_t fp, image_t *img, int line_start, int line_end, ppm_read_settings_t *rs);
|
||||
void ppm_read(image_t *img, const char *path);
|
||||
void ppm_write_subimg(image_t *img, const char *path, rectangle_t *r);
|
||||
bool bmp_read_geometry(mp_obj_t fp, image_t *img, bmp_read_settings_t *rs);
|
||||
|
|
@ -1204,14 +1204,14 @@ void imlib_load_image(image_t *img, const char *path, mp_obj_t file);
|
|||
void imlib_save_image(image_t *img, const char *path, rectangle_t *roi, int quality);
|
||||
|
||||
/* GIF functions */
|
||||
void gif_open(FIL *fp, int width, int height, bool color, bool loop);
|
||||
void gif_add_frame(FIL *fp, image_t *img, uint16_t delay);
|
||||
void gif_close(FIL *fp);
|
||||
void gif_open(mp_obj_t fp, int width, int height, bool color, bool loop);
|
||||
void gif_add_frame(mp_obj_t fp, image_t *img, uint16_t delay);
|
||||
void gif_close(mp_obj_t fp);
|
||||
|
||||
/* MJPEG functions */
|
||||
void mjpeg_open(FIL *fp, int width, int height);
|
||||
void mjpeg_add_frame(FIL *fp, uint32_t *frames, uint32_t *bytes, image_t *img, int quality);
|
||||
void mjpeg_close(FIL *fp, uint32_t *frames, uint32_t *bytes, float fps);
|
||||
void mjpeg_open(mp_obj_t fp, int width, int height);
|
||||
void mjpeg_add_frame(mp_obj_t fp, uint32_t *frames, uint32_t *bytes, image_t *img, int quality);
|
||||
void mjpeg_close(mp_obj_t fp, uint32_t *frames, uint32_t *bytes, float fps);
|
||||
|
||||
/* Point functions */
|
||||
point_t *point_alloc(int16_t x, int16_t y);
|
||||
|
|
@ -1275,15 +1275,15 @@ array_t *orb_find_keypoints(image_t *image, bool normalized, int threshold,
|
|||
float scale_factor, int max_keypoints, corner_detector_t corner_detector, rectangle_t *roi);
|
||||
int orb_match_keypoints(array_t *kpts1, array_t *kpts2, int *match, int threshold, rectangle_t *r, point_t *c, int *angle);
|
||||
int orb_filter_keypoints(array_t *kpts, rectangle_t *r, point_t *c);
|
||||
int orb_save_descriptor(FIL *fp, array_t *kpts);
|
||||
int orb_load_descriptor(FIL *fp, array_t *kpts);
|
||||
int orb_save_descriptor(mp_obj_t fp, array_t *kpts);
|
||||
int orb_load_descriptor(mp_obj_t fp, array_t *kpts);
|
||||
float orb_cluster_dist(int cx, int cy, void *kp);
|
||||
|
||||
/* LBP Operator */
|
||||
uint8_t *imlib_lbp_desc(image_t *image, rectangle_t *roi);
|
||||
int imlib_lbp_desc_distance(uint8_t *d0, uint8_t *d1);
|
||||
int imlib_lbp_desc_save(FIL *fp, uint8_t *desc);
|
||||
int imlib_lbp_desc_load(FIL *fp, uint8_t **desc);
|
||||
int imlib_lbp_desc_save(mp_obj_t fp, uint8_t *desc);
|
||||
int imlib_lbp_desc_load(mp_obj_t fp, uint8_t **desc);
|
||||
|
||||
/* Iris detector */
|
||||
void imlib_find_iris(image_t *src, point_t *iris, rectangle_t *roi);
|
||||
|
|
|
|||
|
|
@ -800,7 +800,7 @@ __inline static void jpg_bpp2_1x1_unit(int x, int y, image_t *src, int* DCY, int
|
|||
|
||||
int jpg_bpp2_1x1(int ps)
|
||||
{
|
||||
image_t *src=(jpeg_buf_t*)arg_list[0];
|
||||
image_t *src=(image_t*)arg_list[0];
|
||||
jpeg_buf_t* jpeg_buf0=(jpeg_buf_t*)arg_list[1];
|
||||
jpeg_buf_t* jpeg_buf1=(jpeg_buf_t*)arg_list[2];
|
||||
jpeg_buf_t* jpeg_buf=ps?jpeg_buf1:jpeg_buf0;
|
||||
|
|
@ -887,7 +887,7 @@ __inline static void jpg_bpp2_2x1_unit(int x, int y, image_t *src, int* DCY, int
|
|||
|
||||
int jpg_bpp2_2x1(int ps)
|
||||
{
|
||||
image_t *src=(jpeg_buf_t*)arg_list[0];
|
||||
image_t *src=(image_t*)arg_list[0];
|
||||
jpeg_buf_t* jpeg_buf0=(jpeg_buf_t*)arg_list[1];
|
||||
jpeg_buf_t* jpeg_buf1=(jpeg_buf_t*)arg_list[2];
|
||||
jpeg_buf_t* jpeg_buf=ps?jpeg_buf1:jpeg_buf0;
|
||||
|
|
@ -1009,7 +1009,7 @@ __inline static void jpg_bpp2_2x2_unit(int x, int y, image_t *src, int* DCY, int
|
|||
|
||||
int jpg_bpp2_2x2(int ps)
|
||||
{
|
||||
image_t *src=(jpeg_buf_t*)arg_list[0];
|
||||
image_t *src=(image_t*)arg_list[0];
|
||||
jpeg_buf_t* jpeg_buf0=(jpeg_buf_t*)arg_list[1];
|
||||
jpeg_buf_t* jpeg_buf1=(jpeg_buf_t*)arg_list[2];
|
||||
jpeg_buf_t* jpeg_buf=ps?jpeg_buf1:jpeg_buf0;
|
||||
|
|
@ -1040,7 +1040,7 @@ int jpg_bpp2_2x2(int ps)
|
|||
|
||||
void jpg_bpp2_end(jpeg_buf_t* jpeg_buf0, jpeg_buf_t* jpeg_buf1)
|
||||
{
|
||||
int i, bitc0, bitc1, bit_oft;
|
||||
int i, bitc0, bitc1;//, bit_oft;
|
||||
uint8_t bitb = (jpeg_buf0->bitb)>>16;
|
||||
uint8_t* rest_data = jpeg_buf1->buf;
|
||||
|
||||
|
|
@ -1609,7 +1609,6 @@ void jpeg_read(image_t *img, const char *path)
|
|||
void jpeg_write(image_t *img, const char *path, int quality)
|
||||
{
|
||||
int err;
|
||||
mp_uint_t ret;
|
||||
|
||||
if (IM_IS_JPEG(img)) {
|
||||
file_save_data(path, img->pixels, img->bpp, &err);
|
||||
|
|
@ -1623,7 +1622,7 @@ void jpeg_write(image_t *img, const char *path, int quality)
|
|||
// will try to realloc. MP will detect that the pointer is outside of
|
||||
// the heap and return NULL which will cause an out of memory error.
|
||||
jpeg_compress(img, &out, quality, false);
|
||||
ret = file_save_data(path, out.pixels, out.bpp, &err);
|
||||
/* ret = */file_save_data(path, out.pixels, out.bpp, &err);
|
||||
fb_free();
|
||||
if(err != 0)
|
||||
mp_raise_OSError(err);
|
||||
|
|
|
|||
|
|
@ -93,16 +93,16 @@ int imlib_lbp_desc_distance(uint8_t *d0, uint8_t *d1)
|
|||
return sum;
|
||||
}
|
||||
|
||||
int imlib_lbp_desc_save(FIL *fp, uint8_t *desc)
|
||||
int imlib_lbp_desc_save(mp_obj_t fp, uint8_t *desc)
|
||||
{
|
||||
UINT bytes;
|
||||
mp_uint_t bytes;
|
||||
// Write descriptor
|
||||
return file_write(fp, desc, LBP_DESC_SIZE, &bytes);
|
||||
}
|
||||
|
||||
int imlib_lbp_desc_load(FIL *fp, uint8_t **desc)
|
||||
int imlib_lbp_desc_load(mp_obj_t fp, uint8_t **desc)
|
||||
{
|
||||
UINT bytes;
|
||||
mp_uint_t bytes;
|
||||
FRESULT res=FR_OK;
|
||||
|
||||
*desc = NULL;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#include <limits.h>
|
||||
#include "imlib.h"
|
||||
|
||||
#define PI 3.14159265358979f
|
||||
|
||||
#ifdef IMLIB_ENABLE_FIND_LINE_SEGMENTS
|
||||
#pragma GCC diagnostic push
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#define LENGTH_1_OFFSET (35*4)
|
||||
#define MOVI_OFFSET (54*4)
|
||||
|
||||
void mjpeg_open(FIL *fp, int width, int height)
|
||||
void mjpeg_open(mp_obj_t fp, int width, int height)
|
||||
{
|
||||
write_data(fp, "RIFF", 4); // FOURCC fcc; - 0
|
||||
write_long(fp, 0); // DWORD cb; size - updated on close - 1
|
||||
|
|
@ -89,7 +89,7 @@ void mjpeg_open(FIL *fp, int width, int height)
|
|||
write_data(fp, "movi", 4); // FOURCC fcc; - 55
|
||||
}
|
||||
|
||||
void mjpeg_add_frame(FIL *fp, uint32_t *frames, uint32_t *bytes, image_t *img, int quality)
|
||||
void mjpeg_add_frame(mp_obj_t fp, uint32_t *frames, uint32_t *bytes, image_t *img, int quality)
|
||||
{
|
||||
write_data(fp, "00dc", 4); // FOURCC fcc;
|
||||
*frames += 1;
|
||||
|
|
@ -114,7 +114,7 @@ void mjpeg_add_frame(FIL *fp, uint32_t *frames, uint32_t *bytes, image_t *img, i
|
|||
}
|
||||
}
|
||||
|
||||
void mjpeg_close(FIL *fp, uint32_t *frames, uint32_t *bytes, float fps)
|
||||
void mjpeg_close(mp_obj_t fp, uint32_t *frames, uint32_t *bytes, float fps)
|
||||
{
|
||||
// Needed
|
||||
file_seek(fp, SIZE_OFFSET, 0);
|
||||
|
|
|
|||
|
|
@ -676,9 +676,9 @@ int orb_filter_keypoints(array_t *kpts, rectangle_t *r, point_t *c)
|
|||
return matches;
|
||||
}
|
||||
|
||||
int orb_save_descriptor(FIL *fp, array_t *kpts)
|
||||
int orb_save_descriptor(mp_obj_t fp, array_t *kpts)
|
||||
{
|
||||
UINT bytes;
|
||||
mp_uint_t bytes;
|
||||
FRESULT res;
|
||||
|
||||
int kpts_size = array_length(kpts);
|
||||
|
|
@ -734,9 +734,9 @@ error:
|
|||
return res;
|
||||
}
|
||||
|
||||
int orb_load_descriptor(FIL *fp, array_t *kpts)
|
||||
int orb_load_descriptor(mp_obj_t fp, array_t *kpts)
|
||||
{
|
||||
UINT bytes;
|
||||
mp_uint_t bytes;
|
||||
FRESULT res=FR_OK;
|
||||
|
||||
int kpts_size=0;
|
||||
|
|
|
|||
|
|
@ -372,21 +372,21 @@ static int16 getExtendOffset(uint8 i)
|
|||
switch (i)
|
||||
{
|
||||
case 0: return 0;
|
||||
case 1: return ((-1)<<1) + 1;
|
||||
case 2: return ((-1)<<2) + 1;
|
||||
case 3: return ((-1)<<3) + 1;
|
||||
case 4: return ((-1)<<4) + 1;
|
||||
case 5: return ((-1)<<5) + 1;
|
||||
case 6: return ((-1)<<6) + 1;
|
||||
case 7: return ((-1)<<7) + 1;
|
||||
case 8: return ((-1)<<8) + 1;
|
||||
case 9: return ((-1)<<9) + 1;
|
||||
case 10: return ((-1)<<10) + 1;
|
||||
case 11: return ((-1)<<11) + 1;
|
||||
case 12: return ((-1)<<12) + 1;
|
||||
case 13: return ((-1)<<13) + 1;
|
||||
case 14: return ((-1)<<14) + 1;
|
||||
case 15: return ((-1)<<15) + 1;
|
||||
case 1: return (int16)( ((uint16)(-1)<<1) + 1 );
|
||||
case 2: return (int16)( ((uint16)(-1)<<2) + 1 );
|
||||
case 3: return (int16)( ((uint16)(-1)<<3) + 1 );
|
||||
case 4: return (int16)( ((uint16)(-1)<<4) + 1 );
|
||||
case 5: return (int16)( ((uint16)(-1)<<5) + 1 );
|
||||
case 6: return (int16)( ((uint16)(-1)<<6) + 1 );
|
||||
case 7: return (int16)( ((uint16)(-1)<<7) + 1 );
|
||||
case 8: return (int16)( ((uint16)(-1)<<8) + 1 );
|
||||
case 9: return (int16)( ((uint16)(-1)<<9) + 1 );
|
||||
case 10: return (int16)( ((uint16)(-1)<<10) + 1 );
|
||||
case 11: return (int16)( ((uint16)(-1)<<11) + 1 );
|
||||
case 12: return (int16)( ((uint16)(-1)<<12) + 1 );
|
||||
case 13: return (int16)( ((uint16)(-1)<<13) + 1 );
|
||||
case 14: return (int16)( ((uint16)(-1)<<14) + 1 );
|
||||
case 15: return (int16)( ((uint16)(-1)<<15) + 1 );
|
||||
default: return 0;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ static void read_int_reset(ppm_read_settings_t *rs)
|
|||
rs->read_int_c_valid = false;
|
||||
}
|
||||
|
||||
static void read_int(FIL *fp, uint32_t *i, ppm_read_settings_t *rs)
|
||||
static void read_int(mp_obj_t fp, uint32_t *i, ppm_read_settings_t *rs)
|
||||
{
|
||||
enum { EAT_WHITESPACE, EAT_COMMENT, EAT_NUMBER } mode = EAT_WHITESPACE;
|
||||
for(*i = 0;;) {
|
||||
|
|
@ -49,7 +49,7 @@ static void read_int(FIL *fp, uint32_t *i, ppm_read_settings_t *rs)
|
|||
}
|
||||
|
||||
// This function inits the geometry values of an image.
|
||||
void ppm_read_geometry(FIL *fp, image_t *img, const char *path, ppm_read_settings_t *rs)
|
||||
void ppm_read_geometry(mp_obj_t fp, image_t *img, const char *path, ppm_read_settings_t *rs)
|
||||
{
|
||||
read_int_reset(rs);
|
||||
read_byte_expect(fp, 'P');
|
||||
|
|
@ -67,7 +67,7 @@ void ppm_read_geometry(FIL *fp, image_t *img, const char *path, ppm_read_setting
|
|||
}
|
||||
|
||||
// This function reads the pixel values of an image.
|
||||
void ppm_read_pixels(FIL *fp, image_t *img, int line_start, int line_end, ppm_read_settings_t *rs)
|
||||
void ppm_read_pixels(mp_obj_t fp, image_t *img, int line_start, int line_end, ppm_read_settings_t *rs)
|
||||
{
|
||||
if (rs->ppm_fmt == '2') {
|
||||
for (int i = line_start; i < line_end; i++) {
|
||||
|
|
@ -110,7 +110,7 @@ void ppm_read_pixels(FIL *fp, image_t *img, int line_start, int line_end, ppm_re
|
|||
|
||||
void ppm_read(image_t *img, const char *path)
|
||||
{
|
||||
FIL fp;
|
||||
mp_obj_t fp;
|
||||
ppm_read_settings_t rs;
|
||||
file_read_open_raise(&fp, path);
|
||||
file_buffer_on(&fp);
|
||||
|
|
@ -125,7 +125,7 @@ void ppm_write_subimg(image_t *img, const char *path, rectangle_t *r)
|
|||
{
|
||||
rectangle_t rect;
|
||||
if (!rectangle_subimg(img, r, &rect)) fs_no_intersection(NULL);
|
||||
FIL fp;
|
||||
mp_obj_t fp;
|
||||
file_write_open_raise(&fp, path);
|
||||
|
||||
file_buffer_on(&fp);
|
||||
|
|
|
|||
|
|
@ -864,7 +864,7 @@ bool imlib_get_regression(find_lines_list_lnk_data_t *out, image_t *ptr, rectang
|
|||
long long *x_delta_histogram = fb_alloc0((2 * ptr->w) * sizeof(long long)); // Not roi so we don't have to adjust, we can burn the RAM.
|
||||
long long *y_delta_histogram = fb_alloc0((2 * ptr->h) * sizeof(long long)); // Not roi so we don't have to adjust, we can burn the RAM.
|
||||
|
||||
uint32_t size;
|
||||
uint64_t size;
|
||||
point_t *points = (point_t *) fb_alloc_all(&size);
|
||||
size_t points_max = size / sizeof(point_t);
|
||||
size_t points_count = 0;
|
||||
|
|
|
|||
|
|
@ -1625,7 +1625,9 @@ void _zbar_image_scanner_recycle_syms (zbar_image_scanner_t *iscn,
|
|||
}
|
||||
if(sym->syms) {
|
||||
if(_zbar_refcnt(&sym->syms->refcnt, -1))
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
_zbar_image_scanner_recycle_syms(iscn, sym->syms->head);
|
||||
sym->syms->head = NULL;
|
||||
_zbar_symbol_set_free(sym->syms);
|
||||
|
|
@ -1672,7 +1674,9 @@ inline void zbar_image_scanner_recycle_image (zbar_image_scanner_t *iscn,
|
|||
iscn->syms = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
STAT(iscn_syms_recycle);
|
||||
}
|
||||
}
|
||||
|
||||
syms = img->syms;
|
||||
|
|
@ -2310,7 +2314,9 @@ int zbar_scan_image (zbar_image_scanner_t *iscn,
|
|||
if(entry)
|
||||
entry->cache_count--;
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* recycle */
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#define GC0328_ID (0x9d)
|
||||
#define GC0328_ADDR (0x42)
|
||||
int gc0328_reset(void);
|
||||
int gc0328_reset(sensor_t*);
|
||||
uint8_t gc0328_scan(void);
|
||||
int gc0328_init(sensor_t *sensor);
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ typedef struct _sensor {
|
|||
// Resolution table
|
||||
extern const int resolution[][2];
|
||||
|
||||
void sensor_flush(void);
|
||||
int sensor_flush(void);
|
||||
|
||||
int binocular_sensor_reset(mp_int_t freq);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ int file_write_open(mp_obj_t* fp, const char *path);
|
|||
int file_read_open(mp_obj_t* fp, const char *path);
|
||||
int file_close(mp_obj_t fp);
|
||||
int file_seek(mp_obj_t fp, mp_int_t offset, uint8_t whence);
|
||||
bool file_eof(mp_obj_t fp);
|
||||
int file_seek_raise(mp_obj_t fp, mp_int_t offset, uint8_t whence);
|
||||
mp_uint_t file_save_data(const char* path, uint8_t* data, mp_uint_t length, int* error_code);
|
||||
mp_uint_t file_size(mp_obj_t fp);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ void mutex_init(mutex_t *mutex)
|
|||
|
||||
void mutex_lock(mutex_t *mutex, uint32_t tid)
|
||||
{
|
||||
volatile int locked = 0;
|
||||
// Wait for mutex to be unlocked
|
||||
while(mutex->lock != 0);
|
||||
mutex->lock = 1;
|
||||
|
|
@ -34,9 +33,6 @@ void mutex_lock(mutex_t *mutex, uint32_t tid)
|
|||
|
||||
int mutex_try_lock(mutex_t *mutex, uint32_t tid)
|
||||
{
|
||||
|
||||
volatile int locked = 1;
|
||||
|
||||
// If mutex is already locked by the current thread then
|
||||
// release the Kraken err.. the mutex, else attempt to lock it.
|
||||
if (mutex->tid == tid) {
|
||||
|
|
|
|||
|
|
@ -619,16 +619,16 @@ static int read_reg(sensor_t *sensor, uint8_t reg_addr)
|
|||
return reg_data;
|
||||
}
|
||||
|
||||
static int write_reg(sensor_t *sensor, uint8_t reg_addr, uint8_t reg_data)
|
||||
static int write_reg(sensor_t *sensor, uint8_t reg_addr, uint16_t reg_data)
|
||||
{
|
||||
return cambus_writeb(sensor->slv_addr, reg_addr, reg_data);
|
||||
return cambus_writeb(sensor->slv_addr, reg_addr, (uint8_t)reg_data);
|
||||
}
|
||||
|
||||
|
||||
static int set_pixformat(sensor_t *sensor, pixformat_t pixformat)
|
||||
{
|
||||
int i=0;
|
||||
const uint8_t (*regs)[2]=NULL;
|
||||
// int i=0;
|
||||
// const uint8_t (*regs)[2]=NULL;
|
||||
|
||||
/* read pixel format reg */
|
||||
// switch (pixformat) {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ image_t *py_helper_arg_to_image_mutable(const mp_obj_t arg);
|
|||
image_t *py_helper_arg_to_image_mutable_bayer(const mp_obj_t arg);
|
||||
image_t *py_helper_arg_to_image_grayscale(const mp_obj_t arg);
|
||||
image_t *py_helper_arg_to_image_color(const mp_obj_t arg);
|
||||
image_t *py_helper_keyword_to_image_mutable(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
image_t *py_helper_keyword_to_image_mutable(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, mp_obj_t kw, image_t *default_val);
|
||||
image_t *py_helper_keyword_to_image_mutable_mask(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
image_t *py_helper_keyword_to_image_mutable_mask(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args);
|
||||
void py_helper_keyword_rectangle(image_t *img, uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, mp_obj_t kw, rectangle_t *r);
|
||||
|
|
@ -22,21 +22,21 @@ void py_helper_keyword_xy(image_t *img, uint n_args, const mp_obj_t *args, uint
|
|||
mp_map_t *kw_args, mp_obj_t kw, point_t *oft);
|
||||
void py_helper_keyword_rectangle_roi(image_t *img, uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, rectangle_t *r);
|
||||
int py_helper_keyword_int(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
int py_helper_keyword_int(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, mp_obj_t kw, int default_val);
|
||||
float py_helper_keyword_float(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
float py_helper_keyword_float(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, mp_obj_t kw, float default_val);
|
||||
void py_helper_keyword_int_array(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
void py_helper_keyword_int_array(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, mp_obj_t kw, int *x, int size);
|
||||
void py_helper_keyword_float_array(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
void py_helper_keyword_float_array(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, mp_obj_t kw, float *x, int size);
|
||||
uint py_helper_consume_array(uint n_args, const mp_obj_t *args, uint arg_index, size_t len, const mp_obj_t **items);
|
||||
uint py_helper_consume_array(size_t n_args, const mp_obj_t *args, uint arg_index, size_t len, const mp_obj_t **items);
|
||||
int py_helper_keyword_color(image_t *img, uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, int default_val);
|
||||
void py_helper_arg_to_thresholds(const mp_obj_t arg, list_t *thresholds);
|
||||
void py_helper_keyword_thresholds(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
void py_helper_keyword_thresholds(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, list_t *thresholds);
|
||||
int py_helper_arg_to_ksize(const mp_obj_t arg);
|
||||
int py_helper_ksize_to_n(int ksize);
|
||||
mp_obj_t py_helper_keyword_object(uint n_args, const mp_obj_t *args, uint arg_index, mp_map_t *kw_args, mp_obj_t kw);
|
||||
mp_obj_t py_helper_keyword_object(size_t n_args, const mp_obj_t *args, uint arg_index, mp_map_t *kw_args, mp_obj_t kw);
|
||||
#endif // __PY_HELPER__
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ typedef struct py_gif_obj {
|
|||
int height;
|
||||
bool color;
|
||||
bool loop;
|
||||
FIL fp;
|
||||
mp_obj_t fp;
|
||||
} py_gif_obj_t;
|
||||
|
||||
static mp_obj_t py_gif_open(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_gif_open(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
py_gif_obj_t *gif = m_new_obj(py_gif_obj_t);
|
||||
gif->width = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_width), MAIN_FB()->w);
|
||||
|
|
@ -69,7 +69,7 @@ static mp_obj_t py_gif_loop(mp_obj_t gif_obj)
|
|||
return mp_obj_new_int(arg_gif->loop);
|
||||
}
|
||||
|
||||
static mp_obj_t py_gif_add_frame(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_gif_add_frame(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
py_gif_obj_t *arg_gif = args[0];
|
||||
image_t *arg_img = py_image_cobj(args[1]);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
extern void *py_image_cobj(mp_obj_t img_obj);
|
||||
|
||||
mp_obj_t py_func_unavailable(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
mp_obj_t py_func_unavailable(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
PY_ASSERT_TRUE_MSG(false, "This function is unavailable on your OpenMV Cam.");
|
||||
return args[0];
|
||||
|
|
@ -42,7 +42,7 @@ image_t *py_helper_arg_to_image_color(const mp_obj_t arg)
|
|||
return arg_img;
|
||||
}
|
||||
|
||||
image_t *py_helper_keyword_to_image_mutable(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
image_t *py_helper_keyword_to_image_mutable(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, mp_obj_t kw, image_t *default_val)
|
||||
{
|
||||
mp_map_elem_t *kw_arg = mp_map_lookup(kw_args, kw, MP_MAP_LOOKUP);
|
||||
|
|
@ -56,7 +56,7 @@ image_t *py_helper_keyword_to_image_mutable(uint n_args, const mp_obj_t *args, u
|
|||
return default_val;
|
||||
}
|
||||
|
||||
image_t *py_helper_keyword_to_image_mutable_mask(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
image_t *py_helper_keyword_to_image_mutable_mask(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args)
|
||||
{
|
||||
return py_helper_keyword_to_image_mutable(n_args, args, arg_index, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_mask), NULL);
|
||||
|
|
@ -128,7 +128,7 @@ void py_helper_keyword_rectangle_roi(image_t *img, uint n_args, const mp_obj_t *
|
|||
py_helper_keyword_rectangle(img, n_args, args, arg_index, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_roi), r);
|
||||
}
|
||||
|
||||
int py_helper_keyword_int(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
int py_helper_keyword_int(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, mp_obj_t kw, int default_val)
|
||||
{
|
||||
mp_map_elem_t *kw_arg = mp_map_lookup(kw_args, kw, MP_MAP_LOOKUP);
|
||||
|
|
@ -142,7 +142,7 @@ int py_helper_keyword_int(uint n_args, const mp_obj_t *args, uint arg_index,
|
|||
return default_val;
|
||||
}
|
||||
|
||||
float py_helper_keyword_float(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
float py_helper_keyword_float(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, mp_obj_t kw, float default_val)
|
||||
{
|
||||
mp_map_elem_t *kw_arg = mp_map_lookup(kw_args, kw, MP_MAP_LOOKUP);
|
||||
|
|
@ -156,7 +156,7 @@ float py_helper_keyword_float(uint n_args, const mp_obj_t *args, uint arg_index,
|
|||
return default_val;
|
||||
}
|
||||
|
||||
void py_helper_keyword_int_array(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
void py_helper_keyword_int_array(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, mp_obj_t kw, int *x, int size)
|
||||
{
|
||||
mp_map_elem_t *kw_arg = mp_map_lookup(kw_args, kw, MP_MAP_LOOKUP);
|
||||
|
|
@ -172,7 +172,7 @@ void py_helper_keyword_int_array(uint n_args, const mp_obj_t *args, uint arg_ind
|
|||
}
|
||||
}
|
||||
|
||||
void py_helper_keyword_float_array(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
void py_helper_keyword_float_array(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, mp_obj_t kw, float *x, int size)
|
||||
{
|
||||
mp_map_elem_t *kw_arg = mp_map_lookup(kw_args, kw, MP_MAP_LOOKUP);
|
||||
|
|
@ -188,7 +188,7 @@ void py_helper_keyword_float_array(uint n_args, const mp_obj_t *args, uint arg_i
|
|||
}
|
||||
}
|
||||
|
||||
uint py_helper_consume_array(uint n_args, const mp_obj_t *args, uint arg_index, size_t len, const mp_obj_t **items)
|
||||
uint py_helper_consume_array(size_t n_args, const mp_obj_t *args, uint arg_index, size_t len, const mp_obj_t **items)
|
||||
{
|
||||
if (MP_OBJ_IS_TYPE(args[arg_index], &mp_type_tuple) || MP_OBJ_IS_TYPE(args[arg_index], &mp_type_list)) {
|
||||
mp_obj_get_array_fixed_n(args[arg_index], len, (mp_obj_t **) items);
|
||||
|
|
@ -291,7 +291,7 @@ void py_helper_arg_to_thresholds(const mp_obj_t arg, list_t *thresholds)
|
|||
}
|
||||
}
|
||||
|
||||
void py_helper_keyword_thresholds(uint n_args, const mp_obj_t *args, uint arg_index,
|
||||
void py_helper_keyword_thresholds(size_t n_args, const mp_obj_t *args, uint arg_index,
|
||||
mp_map_t *kw_args, list_t *thresholds)
|
||||
{
|
||||
mp_map_elem_t *kw_arg = mp_map_lookup(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_thresholds), MP_MAP_LOOKUP);
|
||||
|
|
@ -315,7 +315,7 @@ int py_helper_ksize_to_n(int ksize)
|
|||
return ((ksize * 2) + 1) * ((ksize * 2) + 1);
|
||||
}
|
||||
|
||||
mp_obj_t py_helper_keyword_object(uint n_args, const mp_obj_t *args, uint arg_index, mp_map_t *kw_args, mp_obj_t kw)
|
||||
mp_obj_t py_helper_keyword_object(size_t n_args, const mp_obj_t *args, uint arg_index, mp_map_t *kw_args, mp_obj_t kw)
|
||||
{
|
||||
mp_map_elem_t *kw_arg = mp_map_lookup(kw_args, kw, MP_MAP_LOOKUP);
|
||||
|
||||
|
|
|
|||
|
|
@ -75,9 +75,9 @@ static void py_kp_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind
|
|||
mp_printf(print, "{\"size\":%d, \"threshold\":%d, \"normalized\":%d}", array_length(self->kpts), self->threshold, self->normalized);
|
||||
}
|
||||
|
||||
mp_obj_t py_kp_unary_op(mp_uint_t op, mp_obj_t self_in) {
|
||||
mp_obj_t py_kp_unary_op(mp_unary_op_t op, mp_obj_t self_in){
|
||||
py_kp_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
switch (op) {
|
||||
switch ((mp_uint_t)op) {
|
||||
case MP_UNARY_OP_LEN:
|
||||
return MP_OBJ_NEW_SMALL_INT(array_length(self->kpts));
|
||||
|
||||
|
|
@ -558,7 +558,7 @@ static mp_obj_t py_image_size(mp_obj_t img_obj)
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_size_obj, py_image_size);
|
||||
|
||||
STATIC mp_obj_t py_image_get_pixel(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_get_pixel(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable_bayer(args[0]);
|
||||
|
||||
|
|
@ -627,7 +627,7 @@ STATIC mp_obj_t py_image_get_pixel(uint n_args, const mp_obj_t *args, mp_map_t *
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_get_pixel_obj, 2, py_image_get_pixel);
|
||||
|
||||
STATIC mp_obj_t py_image_set_pixel(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_set_pixel(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable_bayer(args[0]);
|
||||
|
||||
|
|
@ -717,7 +717,7 @@ static mp_obj_t py_image_mean_pooled(mp_obj_t img_obj, mp_obj_t x_div_obj, mp_ob
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_mean_pooled_obj, py_image_mean_pooled);
|
||||
|
||||
static mp_obj_t py_image_midpoint_pool(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_midpoint_pool(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -750,7 +750,7 @@ static mp_obj_t py_image_midpoint_pool(uint n_args, const mp_obj_t *args, mp_map
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_midpoint_pool_obj, 3, py_image_midpoint_pool);
|
||||
|
||||
static mp_obj_t py_image_midpoint_pooled(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_midpoint_pooled(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -775,7 +775,7 @@ static mp_obj_t py_image_midpoint_pooled(uint n_args, const mp_obj_t *args, mp_m
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_midpoint_pooled_obj, 3, py_image_midpoint_pooled);
|
||||
|
||||
static mp_obj_t py_image_to_bitmap(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_to_bitmap(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
bool copy = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_copy), false);
|
||||
|
|
@ -840,7 +840,7 @@ static mp_obj_t py_image_to_bitmap(uint n_args, const mp_obj_t *args, mp_map_t *
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_to_bitmap_obj, 1, py_image_to_bitmap);
|
||||
|
||||
static mp_obj_t py_image_to_grayscale(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_to_grayscale(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
bool copy = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_copy), false);
|
||||
|
|
@ -893,7 +893,7 @@ static mp_obj_t py_image_to_grayscale(uint n_args, const mp_obj_t *args, mp_map_
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_to_grayscale_obj, 1, py_image_to_grayscale);
|
||||
|
||||
static mp_obj_t py_image_to_rgb565(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_to_rgb565(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
bool copy = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_copy), false);
|
||||
|
|
@ -950,7 +950,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_to_rgb565_obj, 1, py_image_to_rgb565)
|
|||
|
||||
extern const uint16_t rainbow_table[256];
|
||||
|
||||
static mp_obj_t py_image_to_rainbow(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_to_rainbow(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
bool copy = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_copy), false);
|
||||
|
|
@ -1012,7 +1012,7 @@ static mp_obj_t py_image_to_rainbow(uint n_args, const mp_obj_t *args, mp_map_t
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_to_rainbow_obj, 1, py_image_to_rainbow);
|
||||
|
||||
static mp_obj_t py_image_compress(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_compress(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable_bayer(args[0]);
|
||||
int arg_q = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_quality), 50);
|
||||
|
|
@ -1037,7 +1037,7 @@ static mp_obj_t py_image_compress(uint n_args, const mp_obj_t *args, mp_map_t *k
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_compress_obj, 1, py_image_compress);
|
||||
|
||||
static mp_obj_t py_image_to_bytes(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_to_bytes(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_image_cobj(args[0]);
|
||||
mp_uint_t size = 0;
|
||||
|
|
@ -1064,7 +1064,7 @@ static mp_obj_t py_image_to_bytes(uint n_args, const mp_obj_t *args, mp_map_t *k
|
|||
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_to_bytes_obj, 1, py_image_to_bytes);
|
||||
|
||||
static mp_obj_t py_image_compress_for_ide(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_compress_for_ide(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable_bayer(args[0]);
|
||||
int arg_q = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_quality), 50);
|
||||
|
|
@ -1122,7 +1122,7 @@ static mp_obj_t py_image_compress_for_ide(uint n_args, const mp_obj_t *args, mp_
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_compress_for_ide_obj, 1, py_image_compress_for_ide);
|
||||
|
||||
static mp_obj_t py_image_compressed(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_compressed(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable_bayer(args[0]);
|
||||
int arg_q = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_quality), 50);
|
||||
|
|
@ -1143,7 +1143,7 @@ static mp_obj_t py_image_compressed(uint n_args, const mp_obj_t *args, mp_map_t
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_compressed_obj, 1, py_image_compressed);
|
||||
|
||||
static mp_obj_t py_image_compressed_for_ide(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_compressed_for_ide(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable_bayer(args[0]);
|
||||
int arg_q = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_quality), 50);
|
||||
|
|
@ -1197,7 +1197,7 @@ static mp_obj_t py_image_compressed_for_ide(uint n_args, const mp_obj_t *args, m
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_compressed_for_ide_obj, 1, py_image_compressed_for_ide);
|
||||
|
||||
static mp_obj_t py_image_copy(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_copy(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_image_cobj(args[0]);
|
||||
|
||||
|
|
@ -1275,7 +1275,7 @@ static mp_obj_t py_image_copy(uint n_args, const mp_obj_t *args, mp_map_t *kw_ar
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_copy_obj, 1, py_image_copy);
|
||||
|
||||
static mp_obj_t py_image_save(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_save(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_image_cobj(args[0]);
|
||||
const char *path = mp_obj_str_get_str(args[1]);
|
||||
|
|
@ -1305,7 +1305,7 @@ STATIC mp_obj_t py_image_clear(mp_obj_t img_obj)
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_clear_obj, py_image_clear);
|
||||
|
||||
STATIC mp_obj_t py_image_draw_line(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_draw_line(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -1326,7 +1326,7 @@ STATIC mp_obj_t py_image_draw_line(uint n_args, const mp_obj_t *args, mp_map_t *
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_draw_line_obj, 2, py_image_draw_line);
|
||||
|
||||
STATIC mp_obj_t py_image_draw_rectangle(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_draw_rectangle(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -1349,7 +1349,7 @@ STATIC mp_obj_t py_image_draw_rectangle(uint n_args, const mp_obj_t *args, mp_ma
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_draw_rectangle_obj, 2, py_image_draw_rectangle);
|
||||
|
||||
STATIC mp_obj_t py_image_draw_circle(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_draw_circle(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -1371,7 +1371,7 @@ STATIC mp_obj_t py_image_draw_circle(uint n_args, const mp_obj_t *args, mp_map_t
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_draw_circle_obj, 2, py_image_draw_circle);
|
||||
|
||||
STATIC mp_obj_t py_image_draw_ellipse(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_draw_ellipse(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -1396,7 +1396,7 @@ STATIC mp_obj_t py_image_draw_ellipse(uint n_args, const mp_obj_t *args, mp_map_
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_draw_ellipse_obj, 2, py_image_draw_ellipse);
|
||||
|
||||
STATIC mp_obj_t py_image_draw_string(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_draw_string(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -1425,7 +1425,7 @@ STATIC mp_obj_t py_image_draw_string(uint n_args, const mp_obj_t *args, mp_map_t
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_draw_string_obj, 2, py_image_draw_string);
|
||||
|
||||
STATIC mp_obj_t py_image_draw_cross(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_draw_cross(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -1447,7 +1447,7 @@ STATIC mp_obj_t py_image_draw_cross(uint n_args, const mp_obj_t *args, mp_map_t
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_draw_cross_obj, 2, py_image_draw_cross);
|
||||
|
||||
STATIC mp_obj_t py_image_draw_arrow(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_draw_arrow(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -1486,7 +1486,7 @@ STATIC mp_obj_t py_image_draw_arrow(uint n_args, const mp_obj_t *args, mp_map_t
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_draw_arrow_obj, 2, py_image_draw_arrow);
|
||||
|
||||
STATIC mp_obj_t py_image_draw_image(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_draw_image(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -1516,7 +1516,7 @@ STATIC mp_obj_t py_image_draw_image(uint n_args, const mp_obj_t *args, mp_map_t
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_draw_image_obj, 3, py_image_draw_image);
|
||||
|
||||
#ifndef OMV_MINIMUM
|
||||
STATIC mp_obj_t py_image_draw_keypoints(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_draw_keypoints(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -1564,7 +1564,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_draw_keypoints_obj, 2, py_image_draw_
|
|||
#endif //OMV_MINIMUM
|
||||
|
||||
#ifdef IMLIB_ENABLE_FLOOD_FILL
|
||||
STATIC mp_obj_t py_image_flood_fill(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_flood_fill(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -1605,7 +1605,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_flood_fill_obj, 2, py_image_flood_fil
|
|||
// Binary Methods
|
||||
/////////////////
|
||||
|
||||
STATIC mp_obj_t py_image_binary(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_binary(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -1669,7 +1669,7 @@ STATIC mp_obj_t py_image_invert(mp_obj_t img_obj)
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_invert_obj, py_image_invert);
|
||||
|
||||
STATIC mp_obj_t py_image_b_and(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_b_and(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -1694,7 +1694,7 @@ STATIC mp_obj_t py_image_b_and(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_b_and_obj, 2, py_image_b_and);
|
||||
|
||||
STATIC mp_obj_t py_image_b_nand(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_b_nand(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -1719,7 +1719,7 @@ STATIC mp_obj_t py_image_b_nand(uint n_args, const mp_obj_t *args, mp_map_t *kw_
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_b_nand_obj, 2, py_image_b_nand);
|
||||
|
||||
STATIC mp_obj_t py_image_b_or(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_b_or(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -1744,7 +1744,7 @@ STATIC mp_obj_t py_image_b_or(uint n_args, const mp_obj_t *args, mp_map_t *kw_ar
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_b_or_obj, 2, py_image_b_or);
|
||||
|
||||
STATIC mp_obj_t py_image_b_nor(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_b_nor(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -1769,7 +1769,7 @@ STATIC mp_obj_t py_image_b_nor(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_b_nor_obj, 2, py_image_b_nor);
|
||||
|
||||
STATIC mp_obj_t py_image_b_xor(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_b_xor(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -1794,7 +1794,7 @@ STATIC mp_obj_t py_image_b_xor(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_b_xor_obj, 2, py_image_b_xor);
|
||||
|
||||
STATIC mp_obj_t py_image_b_xnor(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_b_xnor(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -1819,7 +1819,7 @@ STATIC mp_obj_t py_image_b_xnor(uint n_args, const mp_obj_t *args, mp_map_t *kw_
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_b_xnor_obj, 2, py_image_b_xnor);
|
||||
|
||||
STATIC mp_obj_t py_image_erode(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_erode(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
int arg_ksize =
|
||||
py_helper_arg_to_ksize(args[1]);
|
||||
|
|
@ -1836,7 +1836,7 @@ STATIC mp_obj_t py_image_erode(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_erode_obj, 2, py_image_erode);
|
||||
|
||||
STATIC mp_obj_t py_image_dilate(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_dilate(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
int arg_ksize =
|
||||
py_helper_arg_to_ksize(args[1]);
|
||||
|
|
@ -1853,7 +1853,7 @@ STATIC mp_obj_t py_image_dilate(uint n_args, const mp_obj_t *args, mp_map_t *kw_
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_dilate_obj, 2, py_image_dilate);
|
||||
|
||||
STATIC mp_obj_t py_image_open(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_open(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
int arg_ksize =
|
||||
py_helper_arg_to_ksize(args[1]);
|
||||
|
|
@ -1869,7 +1869,7 @@ STATIC mp_obj_t py_image_open(uint n_args, const mp_obj_t *args, mp_map_t *kw_ar
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_open_obj, 2, py_image_open);
|
||||
|
||||
STATIC mp_obj_t py_image_close(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_close(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
int arg_ksize =
|
||||
py_helper_arg_to_ksize(args[1]);
|
||||
|
|
@ -1891,7 +1891,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_close_obj, 2, py_image_close);
|
|||
// Math Methods
|
||||
///////////////
|
||||
|
||||
STATIC mp_obj_t py_image_top_hat(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_top_hat(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
int arg_ksize =
|
||||
py_helper_arg_to_ksize(args[1]);
|
||||
|
|
@ -1907,7 +1907,7 @@ STATIC mp_obj_t py_image_top_hat(uint n_args, const mp_obj_t *args, mp_map_t *kw
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_top_hat_obj, 2, py_image_top_hat);
|
||||
|
||||
STATIC mp_obj_t py_image_black_hat(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_black_hat(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
int arg_ksize =
|
||||
py_helper_arg_to_ksize(args[1]);
|
||||
|
|
@ -1923,7 +1923,7 @@ STATIC mp_obj_t py_image_black_hat(uint n_args, const mp_obj_t *args, mp_map_t *
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_black_hat_obj, 2, py_image_black_hat);
|
||||
|
||||
STATIC mp_obj_t py_image_gamma_corr(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_gamma_corr(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -1948,7 +1948,7 @@ STATIC mp_obj_t py_image_negate(mp_obj_t img_obj)
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_negate_obj, py_image_negate);
|
||||
|
||||
STATIC mp_obj_t py_image_replace(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_replace(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2001,7 +2001,7 @@ STATIC mp_obj_t py_image_replace(uint n_args, const mp_obj_t *args, mp_map_t *kw
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_replace_obj, 1, py_image_replace);
|
||||
|
||||
STATIC mp_obj_t py_image_add(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_add(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2026,7 +2026,7 @@ STATIC mp_obj_t py_image_add(uint n_args, const mp_obj_t *args, mp_map_t *kw_arg
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_add_obj, 2, py_image_add);
|
||||
|
||||
STATIC mp_obj_t py_image_sub(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_sub(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2053,7 +2053,7 @@ STATIC mp_obj_t py_image_sub(uint n_args, const mp_obj_t *args, mp_map_t *kw_arg
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_sub_obj, 2, py_image_sub);
|
||||
|
||||
STATIC mp_obj_t py_image_mul(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_mul(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2080,7 +2080,7 @@ STATIC mp_obj_t py_image_mul(uint n_args, const mp_obj_t *args, mp_map_t *kw_arg
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_mul_obj, 2, py_image_mul);
|
||||
|
||||
STATIC mp_obj_t py_image_div(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_div(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2111,7 +2111,7 @@ STATIC mp_obj_t py_image_div(uint n_args, const mp_obj_t *args, mp_map_t *kw_arg
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_div_obj, 2, py_image_div);
|
||||
|
||||
STATIC mp_obj_t py_image_min(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_min(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2136,7 +2136,7 @@ STATIC mp_obj_t py_image_min(uint n_args, const mp_obj_t *args, mp_map_t *kw_arg
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_min_obj, 2, py_image_min);
|
||||
|
||||
STATIC mp_obj_t py_image_max(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_max(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2161,7 +2161,7 @@ STATIC mp_obj_t py_image_max(uint n_args, const mp_obj_t *args, mp_map_t *kw_arg
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_max_obj, 2, py_image_max);
|
||||
|
||||
STATIC mp_obj_t py_image_difference(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_difference(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2186,7 +2186,7 @@ STATIC mp_obj_t py_image_difference(uint n_args, const mp_obj_t *args, mp_map_t
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_difference_obj, 2, py_image_difference);
|
||||
|
||||
STATIC mp_obj_t py_image_blend(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_blend(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2219,7 +2219,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_blend_obj, 2, py_image_blend);
|
|||
// Filtering Methods
|
||||
////////////////////
|
||||
#ifndef OMV_MINIMUM
|
||||
static mp_obj_t py_image_histeq(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_histeq(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2240,7 +2240,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_histeq_obj, 1, py_image_histeq);
|
|||
#endif //OMV_MINIMUM
|
||||
|
||||
#ifdef IMLIB_ENABLE_MEAN
|
||||
STATIC mp_obj_t py_image_mean(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_mean(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2264,7 +2264,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_mean_obj, 2, py_image_mean);
|
|||
#endif // IMLIB_ENABLE_MEAN
|
||||
|
||||
#ifdef IMLIB_ENABLE_MEDIAN
|
||||
STATIC mp_obj_t py_image_median(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_median(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2291,7 +2291,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_median_obj, 2, py_image_median);
|
|||
#endif // IMLIB_ENABLE_MEDIAN
|
||||
|
||||
#ifdef IMLIB_ENABLE_MODE
|
||||
STATIC mp_obj_t py_image_mode(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_mode(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2315,7 +2315,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_mode_obj, 2, py_image_mode);
|
|||
#endif // IMLIB_ENABLE_MODE
|
||||
|
||||
#ifdef IMLIB_ENABLE_MIDPOINT
|
||||
STATIC mp_obj_t py_image_midpoint(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_midpoint(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2342,7 +2342,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_midpoint_obj, 2, py_image_midpoint);
|
|||
#endif // IMLIB_ENABLE_MIDPOINT
|
||||
|
||||
#ifdef IMLIB_ENABLE_MORPH
|
||||
STATIC mp_obj_t py_image_morph(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_morph(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2390,7 +2390,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_morph_obj, 3, py_image_morph);
|
|||
#endif //IMLIB_ENABLE_MORPH
|
||||
|
||||
#ifdef IMLIB_ENABLE_GAUSSIAN
|
||||
STATIC mp_obj_t py_image_gaussian(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_gaussian(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2448,7 +2448,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_gaussian_obj, 2, py_image_gaussian);
|
|||
#endif // IMLIB_ENABLE_GAUSSIAN
|
||||
|
||||
#ifdef IMLIB_ENABLE_LAPLACIAN
|
||||
STATIC mp_obj_t py_image_laplacian(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_laplacian(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2508,7 +2508,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_laplacian_obj, 2, py_image_laplacian)
|
|||
#endif // IMLIB_ENABLE_LAPLACIAN
|
||||
|
||||
#ifdef IMLIB_ENABLE_BILATERAL
|
||||
STATIC mp_obj_t py_image_bilateral(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_bilateral(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2536,7 +2536,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_bilateral_obj, 2, py_image_bilateral)
|
|||
#endif // IMLIB_ENABLE_BILATERAL
|
||||
|
||||
#ifdef IMLIB_ENABLE_CARTOON
|
||||
STATIC mp_obj_t py_image_cartoon(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_cartoon(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2564,7 +2564,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_cartoon_obj, 1, py_image_cartoon);
|
|||
/////////////////////////
|
||||
|
||||
#ifdef IMLIB_ENABLE_REMOVE_SHADOWS
|
||||
STATIC mp_obj_t py_image_remove_shadows(uint n_args, const mp_obj_t *args)
|
||||
STATIC mp_obj_t py_image_remove_shadows(size_t n_args, const mp_obj_t *args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_color(args[0]);
|
||||
|
|
@ -2617,7 +2617,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_illuminvar_obj, py_image_illuminvar);
|
|||
////////////////////
|
||||
|
||||
#ifdef IMLIB_ENABLE_LINPOLAR
|
||||
static mp_obj_t py_image_linpolar(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_linpolar(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2633,7 +2633,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_linpolar_obj, 1, py_image_linpolar);
|
|||
#endif // IMLIB_ENABLE_LINPOLAR
|
||||
|
||||
#ifdef IMLIB_ENABLE_LOGPOLAR
|
||||
static mp_obj_t py_image_logpolar(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_logpolar(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2648,7 +2648,7 @@ static mp_obj_t py_image_logpolar(uint n_args, const mp_obj_t *args, mp_map_t *k
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_logpolar_obj, 1, py_image_logpolar);
|
||||
#endif // IMLIB_ENABLE_LOGPOLAR
|
||||
|
||||
STATIC mp_obj_t py_image_lens_corr(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_lens_corr(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -2667,7 +2667,7 @@ STATIC mp_obj_t py_image_lens_corr(uint n_args, const mp_obj_t *args, mp_map_t *
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_lens_corr_obj, 1, py_image_lens_corr);
|
||||
|
||||
#ifdef IMLIB_ENABLE_ROTATION_CORR
|
||||
STATIC mp_obj_t py_image_rotation_corr(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
STATIC mp_obj_t py_image_rotation_corr(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img =
|
||||
py_helper_arg_to_image_mutable(args[0]);
|
||||
|
|
@ -3441,7 +3441,7 @@ static const mp_obj_type_t py_histogram_type = {
|
|||
.locals_dict = (mp_obj_t) &py_histogram_locals_dict
|
||||
};
|
||||
|
||||
static mp_obj_t py_image_get_histogram(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_get_histogram(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -3545,7 +3545,7 @@ static mp_obj_t py_image_get_histogram(uint n_args, const mp_obj_t *args, mp_map
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_get_histogram_obj, 1, py_image_get_histogram);
|
||||
|
||||
static mp_obj_t py_image_get_statistics(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_get_statistics(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -3758,7 +3758,7 @@ static const mp_obj_type_t py_line_type = {
|
|||
.locals_dict = (mp_obj_t) &py_line_locals_dict
|
||||
};
|
||||
|
||||
static mp_obj_t py_image_get_regression(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_get_regression(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -3978,7 +3978,7 @@ static bool py_image_find_blobs_merge_cb(void *fun_obj, find_blobs_list_lnk_data
|
|||
return mp_obj_is_true(mp_call_function_2(fun_obj, o0, o1));
|
||||
}
|
||||
|
||||
static mp_obj_t py_image_find_blobs(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_blobs(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -4038,7 +4038,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_find_blobs_obj, 2, py_image_find_blob
|
|||
#endif //OMV_MINIMUM
|
||||
|
||||
#ifdef IMLIB_ENABLE_FIND_LINES
|
||||
static mp_obj_t py_image_find_lines(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_lines(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -4085,7 +4085,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_find_lines_obj, 1, py_image_find_line
|
|||
#endif // IMLIB_ENABLE_FIND_LINES
|
||||
|
||||
#ifdef IMLIB_ENABLE_FIND_LINE_SEGMENTS
|
||||
static mp_obj_t py_image_find_line_segments(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_line_segments(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -4204,7 +4204,7 @@ static const mp_obj_type_t py_circle_type = {
|
|||
.locals_dict = (mp_obj_t) &py_circle_locals_dict
|
||||
};
|
||||
|
||||
static mp_obj_t py_image_find_circles(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_circles(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -4339,7 +4339,7 @@ static const mp_obj_type_t py_rect_type = {
|
|||
.locals_dict = (mp_obj_t) &py_rect_locals_dict
|
||||
};
|
||||
|
||||
static mp_obj_t py_image_find_rects(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_rects(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -4505,7 +4505,7 @@ static const mp_obj_type_t py_qrcode_type = {
|
|||
.locals_dict = (mp_obj_t) &py_qrcode_locals_dict
|
||||
};
|
||||
|
||||
static mp_obj_t py_image_find_qrcodes(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_qrcodes(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -4707,7 +4707,7 @@ static const mp_obj_type_t py_apriltag_type = {
|
|||
.locals_dict = (mp_obj_t) &py_apriltag_locals_dict
|
||||
};
|
||||
|
||||
static mp_obj_t py_image_find_apriltags(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_apriltags(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -4886,7 +4886,7 @@ static const mp_obj_type_t py_datamatrix_type = {
|
|||
.locals_dict = (mp_obj_t) &py_datamatrix_locals_dict
|
||||
};
|
||||
|
||||
static mp_obj_t py_image_find_datamatrices(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_datamatrices(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -5036,7 +5036,7 @@ static const mp_obj_type_t py_barcode_type = {
|
|||
.locals_dict = (mp_obj_t) &py_barcode_locals_dict
|
||||
};
|
||||
|
||||
static mp_obj_t py_image_find_barcodes(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_barcodes(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -5152,7 +5152,7 @@ static const mp_obj_type_t py_displacement_type = {
|
|||
.locals_dict = (mp_obj_t) &py_displacement_locals_dict
|
||||
};
|
||||
|
||||
static mp_obj_t py_image_find_displacement(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_displacement(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
image_t *arg_template_img = py_helper_arg_to_image_mutable(args[1]);
|
||||
|
|
@ -5187,7 +5187,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_find_displacement_obj, 2, py_image_fi
|
|||
#endif // IMLIB_ENABLE_FIND_DISPLACEMENT
|
||||
|
||||
#ifndef OMV_MINIMUM
|
||||
static mp_obj_t py_image_find_template(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_template(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_grayscale(args[0]);
|
||||
image_t *arg_template = py_helper_arg_to_image_grayscale(args[1]);
|
||||
|
|
@ -5229,7 +5229,7 @@ static mp_obj_t py_image_find_template(uint n_args, const mp_obj_t *args, mp_map
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_find_template_obj, 3, py_image_find_template);
|
||||
|
||||
static mp_obj_t py_image_find_features(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_features(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
cascade_t *cascade = py_cascade_cobj(args[1]);
|
||||
|
|
@ -5263,7 +5263,7 @@ static mp_obj_t py_image_find_features(uint n_args, const mp_obj_t *args, mp_map
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_find_features_obj, 2, py_image_find_features);
|
||||
|
||||
static mp_obj_t py_image_find_eye(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_eye(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_grayscale(args[0]);
|
||||
|
||||
|
|
@ -5282,7 +5282,7 @@ static mp_obj_t py_image_find_eye(uint n_args, const mp_obj_t *args, mp_map_t *k
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_find_eye_obj, 2, py_image_find_eye);
|
||||
|
||||
static mp_obj_t py_image_find_lbp(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_lbp(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_grayscale(args[0]);
|
||||
|
||||
|
|
@ -5296,7 +5296,7 @@ static mp_obj_t py_image_find_lbp(uint n_args, const mp_obj_t *args, mp_map_t *k
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_find_lbp_obj, 2, py_image_find_lbp);
|
||||
|
||||
static mp_obj_t py_image_find_keypoints(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_keypoints(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
|
||||
|
|
@ -5337,7 +5337,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_find_keypoints_obj, 1, py_image_find_
|
|||
#endif //OMV_MINIMUM
|
||||
|
||||
#ifdef IMLIB_ENABLE_BINARY_OPS
|
||||
static mp_obj_t py_image_find_edges(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_edges(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_grayscale(args[0]);
|
||||
edge_detector_t edge_type = mp_obj_get_int(args[1]);
|
||||
|
|
@ -5373,7 +5373,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_find_edges_obj, 2, py_image_find_edge
|
|||
#endif
|
||||
|
||||
#ifdef IMLIB_ENABLE_HOG
|
||||
static mp_obj_t py_image_find_hog(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_find_hog(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_grayscale(args[0]);
|
||||
|
||||
|
|
@ -5390,7 +5390,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_find_hog_obj, 1, py_image_find_hog);
|
|||
#endif // IMLIB_ENABLE_HOG
|
||||
|
||||
#ifdef IMLIB_ENABLE_SELECTIVE_SEARCH
|
||||
static mp_obj_t py_image_selective_search(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_selective_search(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *img = py_helper_arg_to_image_mutable(args[0]);
|
||||
int t = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_threshold), 500);
|
||||
|
|
@ -5419,11 +5419,11 @@ static mp_obj_t py_image_selective_search(uint n_args, const mp_obj_t *args, mp_
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_selective_search_obj, 1, py_image_selective_search);
|
||||
#endif // IMLIB_ENABLE_SELECTIVE_SEARCH
|
||||
|
||||
static mp_obj_t py_image_dump_roi(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_dump_roi(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
const mp_obj_t *arg_vec;
|
||||
uint offset = py_helper_consume_array(n_args, args, 1, 4, &arg_vec);
|
||||
/* uint offset = */ py_helper_consume_array(n_args, args, 1, 4, &arg_vec);
|
||||
int x0 = mp_obj_get_int(arg_vec[0]);
|
||||
int y0 = mp_obj_get_int(arg_vec[1]);
|
||||
int w = mp_obj_get_int(arg_vec[2]);
|
||||
|
|
@ -5445,7 +5445,7 @@ static mp_obj_t py_image_dump_roi(uint n_args, const mp_obj_t *args, mp_map_t *k
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_dump_roi_obj, 2, py_image_dump_roi);
|
||||
|
||||
static mp_obj_t py_image_conv3(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_conv3(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
mp_map_elem_t *kw_arg = mp_map_lookup(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_kern), MP_MAP_LOOKUP);
|
||||
|
|
@ -5476,7 +5476,7 @@ static mp_obj_t py_image_conv3(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_conv3_obj, 2, py_image_conv3);
|
||||
|
||||
static mp_obj_t py_image_resize(mp_obj_t img_obj, mp_obj_t *w_obj, mp_obj_t *h_obj)
|
||||
static mp_obj_t py_image_resize(mp_obj_t img_obj, mp_obj_t w_obj, mp_obj_t h_obj)
|
||||
{
|
||||
image_t* img = (image_t *) py_image_cobj(img_obj);
|
||||
int w = mp_obj_get_int(w_obj);
|
||||
|
|
@ -5549,11 +5549,11 @@ static mp_obj_t py_image_resize(mp_obj_t img_obj, mp_obj_t *w_obj, mp_obj_t *h_o
|
|||
return mp_const_none;
|
||||
}
|
||||
uint16_t* out = xalloc(w*h*2);
|
||||
uint16_t* in = img->pixels;
|
||||
uint16_t* in = (uint16_t*)img->pixels;
|
||||
float sx=(float)(w0)/w;
|
||||
float sy=(float)(h0)/h;
|
||||
int x,y, x0,y0,x1,y1;
|
||||
float xf,yf;
|
||||
int x,y, x0,y0;//,x1,y1;
|
||||
// float xf,yf;
|
||||
mp_obj_t image = py_image(w, h, img->bpp, out); //TODO: here have bug
|
||||
for(y=0;y<h;y++)
|
||||
{
|
||||
|
|
@ -5597,7 +5597,7 @@ static mp_obj_t py_image_pix_to_ai(mp_obj_t img_obj)
|
|||
uint8_t* r = out;
|
||||
uint8_t* g = out+w*h;
|
||||
uint8_t* b = out+w*h*2;
|
||||
uint16_t* in = img->pixels;
|
||||
uint16_t* in = (uint16_t*)img->pixels;
|
||||
img->pix_ai = out; //TODO: check old one
|
||||
uint32_t index;
|
||||
for(index=0; index < w*h; index++)
|
||||
|
|
@ -5639,7 +5639,7 @@ static mp_obj_t py_image_ai_to_pix(mp_obj_t img_obj)
|
|||
uint8_t* r = out;
|
||||
uint8_t* g = out+w*h;
|
||||
uint8_t* b = out+w*h*2;
|
||||
uint16_t* in = img->pixels;
|
||||
// uint16_t* in = (uint16_t*)img->pixels;
|
||||
img->pix_ai = out; //TODO: check old one
|
||||
uint32_t index;
|
||||
for(index=0; index < w*h; index++)
|
||||
|
|
@ -5671,7 +5671,7 @@ static mp_obj_t py_image_strech_char(mp_obj_t img_obj, mp_obj_t de_dark_obj)
|
|||
{
|
||||
uint32_t index;
|
||||
uint16_t x,y,graymax;
|
||||
int sx2,sx,dx,ex,stdx,r2;
|
||||
int sx2,sx,/* dx,*/ex,/* stdx,*/ r2;
|
||||
int gate,dat;
|
||||
uint8_t* in = img->pixels;
|
||||
sx=0; sx2=0; graymax=0;
|
||||
|
|
@ -5683,8 +5683,8 @@ static mp_obj_t py_image_strech_char(mp_obj_t img_obj, mp_obj_t de_dark_obj)
|
|||
}
|
||||
//strech
|
||||
ex=sx/w/h;
|
||||
dx=sx2/w/h-(sx*sx/w/w/h/h);
|
||||
stdx=(int)sqrt(dx);
|
||||
// dx=sx2/w/h-(sx*sx/w/w/h/h);
|
||||
// stdx=(int)sqrt(dx);
|
||||
gate=ex;//+stdx/8;
|
||||
//mp_printf(&mp_plat_print, "ex=%d,dx=%d,stdx=%d,gate=%d,graymax=%d\r\n",ex,dx,stdx,gate,graymax);
|
||||
for(index=0; index < w*h; index++)
|
||||
|
|
@ -5743,7 +5743,7 @@ static float max(uint8_t* data, uint16_t x, uint16_t y)
|
|||
}
|
||||
|
||||
#define MAX_SCALE 5
|
||||
static mp_obj_t py_image_stretch(mp_obj_t img_obj, mp_obj_t *min_obj, mp_obj_t *max_obj)
|
||||
static mp_obj_t py_image_stretch(mp_obj_t img_obj, mp_obj_t min_obj, mp_obj_t max_obj)
|
||||
{
|
||||
image_t* img = (image_t *) py_image_cobj(img_obj);
|
||||
int to_min = mp_obj_get_int(min_obj);
|
||||
|
|
@ -5784,7 +5784,7 @@ static mp_obj_t py_image_stretch(mp_obj_t img_obj, mp_obj_t *min_obj, mp_obj_t *
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_stretch_obj, py_image_stretch);
|
||||
|
||||
|
||||
static mp_obj_t py_image_cut(uint n_args, const mp_obj_t *args)
|
||||
static mp_obj_t py_image_cut(size_t n_args, const mp_obj_t *args)
|
||||
{
|
||||
image_t* img = (image_t *) py_image_cobj(args[0]);
|
||||
|
||||
|
|
@ -5819,7 +5819,7 @@ static mp_obj_t py_image_cut(uint n_args, const mp_obj_t *args)
|
|||
case IMAGE_BPP_RGB565:
|
||||
{
|
||||
uint16_t* out = xalloc(w_cut*h_cut*2);
|
||||
uint16_t* in = img->pixels;
|
||||
uint16_t* in = (uint16_t*)img->pixels;
|
||||
mp_obj_t image = py_image(w_cut, h_cut, img->bpp, out); //TODO: here have bug
|
||||
for(y=y0;y<y1;y++)
|
||||
{
|
||||
|
|
@ -6136,7 +6136,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_imagewriter_obj, py_image_imagewriter)
|
|||
// ImageReader Object //
|
||||
typedef struct py_imagereader_obj {
|
||||
mp_obj_base_t base;
|
||||
FIL fp;
|
||||
mp_obj_t fp;
|
||||
uint32_t ms;
|
||||
} py_imagereader_obj_t;
|
||||
|
||||
|
|
@ -6151,24 +6151,24 @@ mp_obj_t py_imagereader_size(mp_obj_t self_in)
|
|||
return mp_obj_new_int(vfs_internal_size(&((py_imagereader_obj_t *) self_in)->fp));
|
||||
}
|
||||
|
||||
mp_obj_t py_imagereader_next_frame(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
mp_obj_t py_imagereader_next_frame(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
// Don't use the file buffer here...
|
||||
|
||||
bool copy_to_fb = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_copy_to_fb), true);
|
||||
if (copy_to_fb) fb_update_jpeg_buffer();
|
||||
|
||||
FIL *fp = &((py_imagereader_obj_t *) args[0])->fp;
|
||||
mp_obj_t fp = &((py_imagereader_obj_t *) args[0])->fp;
|
||||
image_t image = {0};
|
||||
|
||||
if (f_eof(fp)) {
|
||||
if (file_eof(fp)) {
|
||||
if (!py_helper_keyword_int(n_args, args, 2, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_loop), true)) {
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
file_seek(fp, 16, 0); // skip past the header
|
||||
|
||||
if (f_eof(fp)) { // empty file
|
||||
if (file_eof(fp)) { // empty file
|
||||
return mp_const_none;
|
||||
}
|
||||
}
|
||||
|
|
@ -6333,9 +6333,8 @@ mp_obj_t py_image_grayscale_to_rgb(mp_obj_t not_tuple)
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_grayscale_to_rgb_obj, py_image_grayscale_to_rgb);
|
||||
|
||||
// extern const uint8_t img[];
|
||||
mp_obj_t py_image_load_image(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
mp_obj_t py_image_load_image(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
const char *path = NULL;
|
||||
point_t xy = {0, 0};
|
||||
bool copy_to_fb = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_copy_to_fb), false);
|
||||
py_helper_keyword_xy(NULL, n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_size), &xy);
|
||||
|
|
@ -6410,7 +6409,7 @@ mp_obj_t py_image_load_image(uint n_args, const mp_obj_t *args, mp_map_t *kw_arg
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_load_image_obj, 0, py_image_load_image);
|
||||
|
||||
#ifndef OMV_MINIMUM
|
||||
mp_obj_t py_image_load_cascade(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
mp_obj_t py_image_load_cascade(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
cascade_t cascade;
|
||||
const char *path = mp_obj_str_get_str(args[0]);
|
||||
|
|
@ -6436,10 +6435,10 @@ mp_obj_t py_image_load_cascade(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_load_cascade_obj, 1, py_image_load_cascade);
|
||||
|
||||
mp_obj_t py_image_load_descriptor(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
mp_obj_t py_image_load_descriptor(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
FIL fp;
|
||||
UINT bytes;
|
||||
mp_obj_t fp;
|
||||
mp_uint_t bytes;
|
||||
FRESULT res;
|
||||
|
||||
uint32_t desc_type;
|
||||
|
|
@ -6484,7 +6483,7 @@ mp_obj_t py_image_load_descriptor(uint n_args, const mp_obj_t *args, mp_map_t *k
|
|||
}
|
||||
}
|
||||
|
||||
f_close(&fp);
|
||||
file_close(&fp);
|
||||
}
|
||||
|
||||
error:
|
||||
|
|
@ -6501,10 +6500,10 @@ error:
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_load_descriptor_obj, 1, py_image_load_descriptor);
|
||||
|
||||
mp_obj_t py_image_save_descriptor(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
mp_obj_t py_image_save_descriptor(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
FIL fp;
|
||||
UINT bytes;
|
||||
mp_obj_t fp;
|
||||
mp_uint_t bytes;
|
||||
FRESULT res;
|
||||
|
||||
uint32_t desc_type;
|
||||
|
|
@ -6540,7 +6539,7 @@ mp_obj_t py_image_save_descriptor(uint n_args, const mp_obj_t *args, mp_map_t *k
|
|||
}
|
||||
}
|
||||
// ignore unsupported descriptors when saving
|
||||
f_close(&fp);
|
||||
file_close(&fp);
|
||||
}
|
||||
|
||||
error:
|
||||
|
|
@ -6552,7 +6551,7 @@ error:
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_save_descriptor_obj, 2, py_image_save_descriptor);
|
||||
|
||||
static mp_obj_t py_image_match_descriptor(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_image_match_descriptor(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
mp_obj_t match_obj = mp_const_none;
|
||||
mp_obj_type_t *desc1_type = mp_obj_get_type(args[0]);
|
||||
|
|
@ -6632,7 +6631,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_match_descriptor_obj, 2, py_image_mat
|
|||
|
||||
int py_image_descriptor_from_roi(image_t *img, const char *path, rectangle_t *roi)
|
||||
{
|
||||
FIL fp;
|
||||
mp_obj_t fp;
|
||||
FRESULT res = FR_OK;
|
||||
|
||||
mp_printf(&mp_plat_print, "Save Descriptor: ROI(%d %d %d %d)\n", roi->x, roi->y, roi->w, roi->h);
|
||||
|
|
@ -6642,7 +6641,7 @@ int py_image_descriptor_from_roi(image_t *img, const char *path, rectangle_t *ro
|
|||
if (array_length(kpts)) {
|
||||
if ((res = file_write_open(&fp, path)) == FR_OK) {
|
||||
res = orb_save_descriptor(&fp, kpts);
|
||||
f_close(&fp);
|
||||
file_close(&fp);
|
||||
}
|
||||
// File open/write error
|
||||
if (res != FR_OK) {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ static mp_obj_t py_lcd_deinit()
|
|||
return mp_const_none;
|
||||
}
|
||||
|
||||
static mp_obj_t py_lcd_init(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_lcd_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
{
|
||||
uint16_t color = BLACK;
|
||||
py_lcd_deinit();
|
||||
|
|
@ -140,7 +140,7 @@ static mp_obj_t py_lcd_init(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_
|
|||
#ifdef CONFIG_BOARD_M5STICK
|
||||
fpioa_set_function(21, FUNC_GPIOHS0 + RST_GPIONUM);
|
||||
fpioa_set_function(20, FUNC_GPIOHS0 + DCX_GPIONUM);
|
||||
fpioa_set_function(22, FUNC_SPI0_SS0+SPI_SLAVE_SELECT);
|
||||
fpioa_set_function(22, FUNC_SPI0_SS0+LCD_SPI_SLAVE_SELECT);
|
||||
fpioa_set_function(19, FUNC_SPI0_SCLK);
|
||||
fpioa_set_function(18, FUNC_SPI0_D0);
|
||||
ret = lcd_init(args[ARG_freq].u_int, false, 52, 40, true, width_curr, height_curr);
|
||||
|
|
@ -148,7 +148,7 @@ static mp_obj_t py_lcd_init(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_
|
|||
// backlight_init = false;
|
||||
fpioa_set_function(37, FUNC_GPIOHS0 + RST_GPIONUM);
|
||||
fpioa_set_function(38, FUNC_GPIOHS0 + DCX_GPIONUM);
|
||||
fpioa_set_function(36, FUNC_SPI0_SS0+SPI_SLAVE_SELECT);
|
||||
fpioa_set_function(36, FUNC_SPI0_SS0+LCD_SPI_SLAVE_SELECT);
|
||||
fpioa_set_function(39, FUNC_SPI0_SCLK);
|
||||
ret = lcd_init(args[ARG_freq].u_int, true, 0, 0, false, width_curr, height_curr);
|
||||
#endif
|
||||
|
|
@ -208,13 +208,13 @@ static mp_obj_t py_lcd_get_backlight()
|
|||
return mp_const_none;
|
||||
}
|
||||
|
||||
static mp_obj_t py_lcd_display(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_lcd_display(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_image_cobj(args[0]);
|
||||
PY_ASSERT_TRUE_MSG(IM_IS_MUTABLE(arg_img), "Image format is not supported.");
|
||||
|
||||
rectangle_t rect;
|
||||
uint16_t x,y;
|
||||
// uint16_t x,y;
|
||||
point_t oft;
|
||||
int is_cut;
|
||||
int l_pad = 0, r_pad = 0;
|
||||
|
|
@ -285,7 +285,7 @@ static mp_obj_t py_lcd_display(uint n_args, const mp_obj_t *args, mp_map_t *kw_a
|
|||
return mp_const_none;
|
||||
}
|
||||
|
||||
static mp_obj_t py_lcd_clear(uint n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_lcd_clear(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
|
||||
{
|
||||
uint16_t color = BLACK;
|
||||
if(n_args >= 1)
|
||||
|
|
@ -362,7 +362,7 @@ STATIC void lcd_set_invert_helper()
|
|||
lcd_set_direction((lcd_dir_t)screen_dir);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t py_lcd_rotation(uint n_args, const mp_obj_t *args)
|
||||
STATIC mp_obj_t py_lcd_rotation(size_t n_args, const mp_obj_t *args)
|
||||
{
|
||||
if(n_args == 0)
|
||||
goto end;
|
||||
|
|
@ -396,7 +396,7 @@ end:
|
|||
return mp_obj_new_int(rotation);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t py_lcd_invert(uint n_args, const mp_obj_t *args)
|
||||
STATIC mp_obj_t py_lcd_invert(size_t n_args, const mp_obj_t *args)
|
||||
{
|
||||
if(n_args == 0)
|
||||
goto end;
|
||||
|
|
@ -416,7 +416,7 @@ end:
|
|||
}
|
||||
|
||||
//x0,y0,string,font color,bg color
|
||||
STATIC mp_obj_t py_lcd_draw_string(uint n_args, const mp_obj_t *args)
|
||||
STATIC mp_obj_t py_lcd_draw_string(size_t n_args, const mp_obj_t *args)
|
||||
{
|
||||
uint32_t* str_buf = NULL;
|
||||
char* str_cut = NULL;
|
||||
|
|
@ -434,12 +434,12 @@ STATIC mp_obj_t py_lcd_draw_string(uint n_args, const mp_obj_t *args)
|
|||
|
||||
uint16_t x0 = mp_obj_get_int(args[0]);
|
||||
uint16_t y0 = mp_obj_get_int(args[1]);
|
||||
char* str = mp_obj_str_get_str(args[2]);
|
||||
const char* str = mp_obj_str_get_str(args[2]);
|
||||
uint16_t fontc = RED;
|
||||
uint16_t bgc = BLACK;
|
||||
if(str == NULL)
|
||||
return mp_const_none;
|
||||
if(x0 < 0 || x0 >= width_conf || y0 < 0 || y0 > height_conf-16)
|
||||
if(x0 >= width_conf || y0 > height_conf-16)
|
||||
return mp_const_none;
|
||||
int len = strlen(str);
|
||||
int width,height;
|
||||
|
|
@ -461,7 +461,7 @@ STATIC mp_obj_t py_lcd_draw_string(uint n_args, const mp_obj_t *args)
|
|||
return mp_const_none;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t py_lcd_freq(uint n_args, const mp_obj_t *pos_args)
|
||||
STATIC mp_obj_t py_lcd_freq(size_t n_args, const mp_obj_t *pos_args)
|
||||
{
|
||||
mp_int_t freq = lcd_get_freq();
|
||||
if(n_args >= 1)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ typedef struct py_mjpeg_obj {
|
|||
mp_obj_t fp;
|
||||
} py_mjpeg_obj_t;
|
||||
|
||||
static mp_obj_t py_mjpeg_open(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_mjpeg_open(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
py_mjpeg_obj_t *mjpeg = m_new_obj(py_mjpeg_obj_t);
|
||||
mjpeg->width = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_width), MAIN_FB()->w);
|
||||
|
|
@ -57,7 +57,7 @@ static mp_obj_t py_mjpeg_size(mp_obj_t mjpeg_obj)
|
|||
return mp_obj_new_int(file_size(arg_mjpeg->fp));
|
||||
}
|
||||
|
||||
static mp_obj_t py_mjpeg_add_frame(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_mjpeg_add_frame(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
py_mjpeg_obj_t *arg_mjpeg = args[0];
|
||||
image_t *arg_img = py_image_cobj(args[1]);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
extern sensor_t sensor;
|
||||
|
||||
static mp_obj_t py_binocular_sensor_reset(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_binocular_sensor_reset(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
mp_map_elem_t *kw_arg = mp_map_lookup(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_freq), MP_MAP_LOOKUP);
|
||||
mp_int_t freq = OMV_XCLK_FREQUENCY;
|
||||
|
|
@ -32,7 +32,7 @@ static mp_obj_t py_binocular_sensor_reset(uint n_args, const mp_obj_t *args, mp_
|
|||
return mp_const_none;
|
||||
}
|
||||
|
||||
static mp_obj_t py_sensor_reset(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_sensor_reset(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
mp_map_elem_t *kw_arg = mp_map_lookup(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_freq), MP_MAP_LOOKUP);
|
||||
mp_int_t freq = OMV_XCLK_FREQUENCY;
|
||||
|
|
@ -64,7 +64,7 @@ static mp_obj_t py_sensor_flush(void) {
|
|||
return mp_const_none;
|
||||
}
|
||||
|
||||
static mp_obj_t py_sensor_snapshot(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
static mp_obj_t py_sensor_snapshot(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
// Snapshot image
|
||||
mp_obj_t image = py_image(0, 0, 0, 0);
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ static mp_obj_t py_sensor_snapshot(uint n_args, const mp_obj_t *args, mp_map_t *
|
|||
return image;
|
||||
}
|
||||
|
||||
static mp_obj_t py_sensor_skip_frames(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
static mp_obj_t py_sensor_skip_frames(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
mp_map_elem_t *kw_arg = mp_map_lookup(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_time), MP_MAP_LOOKUP);
|
||||
mp_int_t time = 300; // OV Recommended.
|
||||
|
|
@ -366,7 +366,7 @@ static mp_obj_t py_sensor_set_colorbar(mp_obj_t enable) {
|
|||
return mp_const_true;
|
||||
}
|
||||
|
||||
static mp_obj_t py_sensor_set_auto_gain(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
static mp_obj_t py_sensor_set_auto_gain(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
int enable = mp_obj_get_int(args[0]);
|
||||
float gain_db = py_helper_keyword_float(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_gain_db), NAN);
|
||||
float gain_db_ceiling = py_helper_keyword_float(n_args, args, 2, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_gain_db_ceiling), NAN);
|
||||
|
|
@ -384,7 +384,7 @@ static mp_obj_t py_sensor_get_gain_db() {
|
|||
return mp_obj_new_float(gain_db);
|
||||
}
|
||||
|
||||
static mp_obj_t py_sensor_set_auto_exposure(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
static mp_obj_t py_sensor_set_auto_exposure(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
int exposure_us = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_exposure_us), -1);
|
||||
if (sensor_set_auto_exposure(mp_obj_get_int(args[0]), exposure_us) != 0) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "Sensor control failed!"));
|
||||
|
|
@ -400,7 +400,7 @@ static mp_obj_t py_sensor_get_exposure_us() {
|
|||
return mp_obj_new_int(exposure_us);
|
||||
}
|
||||
|
||||
static mp_obj_t py_sensor_set_auto_whitebal(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
static mp_obj_t py_sensor_set_auto_whitebal(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
int enable = mp_obj_get_int(args[0]);
|
||||
float rgb_gain_db[3] = {NAN, NAN, NAN};
|
||||
py_helper_keyword_float_array(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_rgb_gain_db), rgb_gain_db, 3);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ volatile static uint8_t g_dvp_finish_flag = 0;
|
|||
|
||||
static volatile int line = 0;
|
||||
uint8_t _line_buf;
|
||||
static uint8_t *dest_fb = NULL;
|
||||
|
||||
const int resolution[][2] = {
|
||||
{0, 0 },
|
||||
|
|
@ -86,7 +85,7 @@ void _ndelay(uint32_t ns)
|
|||
|
||||
static int sensor_irq(void *ctx)
|
||||
{
|
||||
sensor_t *sensor = ctx;
|
||||
// sensor_t *sensor = ctx;
|
||||
if (dvp_get_interrupt(DVP_STS_FRAME_FINISH)) { //frame end
|
||||
dvp_clear_interrupt(DVP_STS_FRAME_FINISH);
|
||||
g_dvp_finish_flag = 1;
|
||||
|
|
@ -194,7 +193,7 @@ int sensro_ov_detect(sensor_t* sensor)
|
|||
/*lepton_init*/
|
||||
} else {
|
||||
// Read ON semi sensor ID.
|
||||
cambus_readb(sensor->slv_addr, ON_CHIP_ID, &sensor->chip_id);
|
||||
cambus_readb(sensor->slv_addr, ON_CHIP_ID, (uint8_t*)&sensor->chip_id);
|
||||
if (sensor->chip_id == MT9V034_ID) {
|
||||
/*set MT9V034 xclk rate*/
|
||||
/*mt9v034_init*/
|
||||
|
|
@ -310,8 +309,8 @@ int sensor_init_dvp(mp_int_t freq)
|
|||
if(sensor.size_set)
|
||||
{
|
||||
dvp_set_image_size(MAIN_FB()->w_max, MAIN_FB()->h_max);
|
||||
dvp_set_ai_addr(MAIN_FB()->pix_ai, (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h), (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h * 2));
|
||||
dvp_set_display_addr(MAIN_FB()->pixels);
|
||||
dvp_set_ai_addr((uint32_t)MAIN_FB()->pix_ai, (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h), (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h * 2));
|
||||
dvp_set_display_addr((uint32_t)MAIN_FB()->pixels);
|
||||
}
|
||||
|
||||
return init_ret;
|
||||
|
|
@ -368,8 +367,8 @@ void sensor_deinit()
|
|||
{
|
||||
sensor_run(0);
|
||||
dvp_set_image_size(0, 0);
|
||||
dvp_set_ai_addr(NULL, NULL, NULL);
|
||||
dvp_set_display_addr(NULL);
|
||||
dvp_set_ai_addr(0, 0, 0);
|
||||
dvp_set_display_addr(0);
|
||||
if(MAIN_FB()->pixels)
|
||||
free(MAIN_FB()->pixels);
|
||||
if(MAIN_FB()->pix_ai)
|
||||
|
|
@ -448,7 +447,7 @@ int binocular_sensor_scan()
|
|||
/*lepton_init*/
|
||||
} else {
|
||||
// Read ON semi sensor ID.
|
||||
cambus_readb(sensor.slv_addr, ON_CHIP_ID, &sensor.chip_id);
|
||||
cambus_readb(sensor.slv_addr, ON_CHIP_ID, (uint8_t*)&sensor.chip_id);
|
||||
if (sensor.chip_id == MT9V034_ID) {
|
||||
/*set MT9V034 xclk rate*/
|
||||
/*mt9v034_init*/
|
||||
|
|
@ -531,7 +530,7 @@ int binocular_sensor_reset(mp_int_t freq)
|
|||
if(sensor.size_set)
|
||||
{
|
||||
dvp_set_image_size(MAIN_FB()->w_max, MAIN_FB()->h_max);
|
||||
dvp_set_ai_addr(MAIN_FB()->pix_ai, (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h), (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h * 2));
|
||||
dvp_set_ai_addr((uint32_t)MAIN_FB()->pix_ai, (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h), (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h * 2));
|
||||
dvp_set_display_addr((uint32_t)(MAIN_FB()->pixels));
|
||||
}
|
||||
/* Some sensors have different reset polarities, and we can't know which sensor
|
||||
|
|
@ -689,8 +688,8 @@ int sensor_set_framesize(framesize_t framesize)
|
|||
if(sensor.reset_set)
|
||||
{
|
||||
dvp_set_image_size(MAIN_FB()->w_max, MAIN_FB()->h_max);
|
||||
dvp_set_ai_addr(MAIN_FB()->pix_ai, (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h), (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h * 2));
|
||||
dvp_set_display_addr(MAIN_FB()->pixels);
|
||||
dvp_set_ai_addr((uint32_t)MAIN_FB()->pix_ai, (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h), (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h * 2));
|
||||
dvp_set_display_addr((uint32_t)MAIN_FB()->pixels);
|
||||
sensor_run(1);
|
||||
}
|
||||
// Set MAIN FB backup width and height.
|
||||
|
|
@ -723,7 +722,7 @@ int sensor_set_windowing(int x, int y, int w, int h)
|
|||
MAIN_FB()->w = MAIN_FB()->u = w;
|
||||
MAIN_FB()->h = MAIN_FB()->v = h;
|
||||
dvp_set_image_size(w, h); //set QVGA default
|
||||
dvp_set_ai_addr(MAIN_FB()->pix_ai, (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h), (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h * 2));
|
||||
dvp_set_ai_addr((uint32_t)MAIN_FB()->pix_ai, (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h), (uint32_t)(MAIN_FB()->pix_ai + MAIN_FB()->w * MAIN_FB()->h * 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1025,12 +1024,12 @@ int reverse_u32pixel(uint32_t* addr,uint32_t length)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void sensor_flush(void)
|
||||
int sensor_flush(void)
|
||||
{ //flush old frame, let dvp capture new image
|
||||
//use it when you don't snap for a while.
|
||||
g_dvp_finish_flag = 0;
|
||||
fb_update_jpeg_buffer();
|
||||
return ;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sensor_snapshot(sensor_t *sensor, image_t *image, streaming_cb_t streaming_cb)
|
||||
|
|
|
|||
|
|
@ -51,6 +51,15 @@ int file_seek(mp_obj_t fp, mp_int_t offset, uint8_t whence)
|
|||
return err;
|
||||
}
|
||||
|
||||
bool file_eof(mp_obj_t fp)
|
||||
{
|
||||
//TODO: recode this function
|
||||
int err;
|
||||
mp_uint_t size = vfs_internal_size(fp);
|
||||
mp_uint_t curr = vfs_internal_seek(fp, 0, VFS_SEEK_CUR, &err);
|
||||
return curr<size;
|
||||
}
|
||||
|
||||
int file_seek_raise(mp_obj_t fp, mp_int_t offset, uint8_t whence)
|
||||
{
|
||||
int err;
|
||||
|
|
@ -198,7 +207,6 @@ int read_byte_raise(mp_obj_t fp, uint8_t* value)
|
|||
|
||||
int read_byte_expect(mp_obj_t fp, uint8_t value)
|
||||
{
|
||||
int err;
|
||||
uint8_t tmp;
|
||||
read_byte_raise(fp, &tmp);
|
||||
return (value != tmp);
|
||||
|
|
@ -253,7 +261,6 @@ int read_word_raise(mp_obj_t fp, uint16_t* value)
|
|||
|
||||
int read_word_expect(mp_obj_t fp, uint16_t value)
|
||||
{
|
||||
int err;
|
||||
uint16_t tmp;
|
||||
read_word_raise(fp, &tmp);
|
||||
return (value != tmp);
|
||||
|
|
@ -308,7 +315,6 @@ int read_long_raise(mp_obj_t fp, uint32_t* value)
|
|||
|
||||
int read_long_expect(mp_obj_t fp, uint32_t value)
|
||||
{
|
||||
int err;
|
||||
uint32_t tmp;
|
||||
read_long_raise(fp, &tmp);
|
||||
return (value != tmp);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ typedef struct _ipconfig_obj
|
|||
typedef struct _esp8285_obj
|
||||
{
|
||||
mp_obj_t uart_obj;
|
||||
uint8_t buffer[ESP8285_BUF_SIZE];
|
||||
char buffer[ESP8285_BUF_SIZE];
|
||||
|
||||
}esp8285_obj;
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ bool reset(esp8285_obj* nic);
|
|||
* @return the char* of version.
|
||||
*/
|
||||
|
||||
uint8_t* getVersion(esp8285_obj* nic);
|
||||
char* getVersion(esp8285_obj* nic);
|
||||
|
||||
/**
|
||||
* Set operation mode to staion.
|
||||
|
|
@ -101,7 +101,7 @@ bool setOprToStation(esp8285_obj* nic);
|
|||
* @retval false - failure.
|
||||
* @note This method will take a couple of seconds.
|
||||
*/
|
||||
bool joinAP(esp8285_obj* nic,uint8_t* ssid, uint8_t* pwd);
|
||||
bool joinAP(esp8285_obj* nic, const char* ssid, const char* pwd);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -112,7 +112,7 @@ bool joinAP(esp8285_obj* nic,uint8_t* ssid, uint8_t* pwd);
|
|||
*
|
||||
* @note This method will enable DHCP but only for client mode!
|
||||
*/
|
||||
bool enableClientDHCP(esp8285_obj* nic,uint8_t mode, bool enabled);
|
||||
bool enableClientDHCP(esp8285_obj* nic,char mode, bool enabled);
|
||||
|
||||
/**
|
||||
* Leave AP joined before.
|
||||
|
|
@ -127,14 +127,14 @@ bool leaveAP(esp8285_obj* nic);
|
|||
*
|
||||
* @return the status.
|
||||
*/
|
||||
uint8_t* getIPStatus(esp8285_obj* nic);
|
||||
char* getIPStatus(esp8285_obj* nic);
|
||||
|
||||
/**
|
||||
* Get the IP address of ESP8266.
|
||||
*
|
||||
* @return the IP list.
|
||||
*/
|
||||
uint8_t* getLocalIP(esp8285_obj* nic);
|
||||
char* getLocalIP(esp8285_obj* nic);
|
||||
|
||||
/**
|
||||
* Enable IP MUX(multiple connection mode).
|
||||
|
|
@ -166,7 +166,7 @@ bool disableMUX(esp8285_obj* nic);
|
|||
* @retval true - success.
|
||||
* @retval false - failure.
|
||||
*/
|
||||
bool createTCP(esp8285_obj* nic,uint8_t* addr, uint32_t port);
|
||||
bool createTCP(esp8285_obj* nic,char* addr, uint32_t port);
|
||||
/**
|
||||
* Release TCP connection in single mode.
|
||||
*
|
||||
|
|
@ -183,7 +183,7 @@ bool releaseTCP(esp8285_obj* nic);
|
|||
* @retval true - success.
|
||||
* @retval false - failure.
|
||||
*/
|
||||
bool registerUDP(esp8285_obj* nic,uint8_t* addr, uint32_t port);
|
||||
bool registerUDP(esp8285_obj* nic,char* addr, uint32_t port);
|
||||
|
||||
/**
|
||||
* Unregister UDP port number in single mode.
|
||||
|
|
@ -202,7 +202,7 @@ bool unregisterUDP(esp8285_obj* nic);
|
|||
* @retval true - success.
|
||||
* @retval false - failure.
|
||||
*/
|
||||
bool createTCP_mul(esp8285_obj* nic,uint8_t mux_id, uint8_t* addr, uint32_t port);
|
||||
bool createTCP_mul(esp8285_obj* nic,char mux_id, char* addr, uint32_t port);
|
||||
|
||||
/**
|
||||
* Release TCP connection in multiple mode.
|
||||
|
|
@ -211,7 +211,7 @@ bool createTCP_mul(esp8285_obj* nic,uint8_t mux_id, uint8_t* addr, uint32_t port
|
|||
* @retval true - success.
|
||||
* @retval false - failure.
|
||||
*/
|
||||
bool releaseTCP_mul(esp8285_obj* nic,uint8_t mux_id);
|
||||
bool releaseTCP_mul(esp8285_obj* nic,char mux_id);
|
||||
|
||||
/**
|
||||
* Register UDP port number in multiple mode.
|
||||
|
|
@ -222,7 +222,7 @@ bool releaseTCP_mul(esp8285_obj* nic,uint8_t mux_id);
|
|||
* @retval true - success.
|
||||
* @retval false - failure.
|
||||
*/
|
||||
bool registerUDP_mul(esp8285_obj* nic,uint8_t mux_id, uint8_t* addr, uint32_t port);
|
||||
bool registerUDP_mul(esp8285_obj* nic,char mux_id, char* addr, uint32_t port);
|
||||
|
||||
/**
|
||||
* Unregister UDP port number in multiple mode.
|
||||
|
|
@ -231,7 +231,7 @@ bool registerUDP_mul(esp8285_obj* nic,uint8_t mux_id, uint8_t* addr, uint32_t po
|
|||
* @retval true - success.
|
||||
* @retval false - failure.
|
||||
*/
|
||||
bool unregisterUDP_mul(esp8285_obj* nic,uint8_t mux_id);
|
||||
bool unregisterUDP_mul(esp8285_obj* nic,char mux_id);
|
||||
|
||||
/**
|
||||
* Set the timeout of TCP Server.
|
||||
|
|
@ -254,8 +254,8 @@ bool setTCPServerTimeout(esp8285_obj* nic,uint32_t timeout);
|
|||
* @retval false - failure.
|
||||
*
|
||||
* @see char* getIPStatus(void);
|
||||
* @see uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t len, uint32_t timeout);
|
||||
* @see bool releaseTCP(uint8_t mux_id);
|
||||
* @see uint32_t recv(char* coming_mux_id, char* buffer, uint32_t len, uint32_t timeout);
|
||||
* @see bool releaseTCP(char mux_id);
|
||||
*/
|
||||
bool startTCPServer(esp8285_obj* nic,uint32_t port);
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ bool stopTCPServer(esp8285_obj* nic);
|
|||
* @retval false - failure.
|
||||
*
|
||||
* @see char* getIPStatus(void);
|
||||
* @see uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t len, uint32_t timeout);
|
||||
* @see uint32_t recv(char* coming_mux_id, char* buffer, uint32_t len, uint32_t timeout);
|
||||
*/
|
||||
bool startServer(esp8285_obj* nic,uint32_t port);
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ bool startServer(esp8285_obj* nic,uint32_t port);
|
|||
*/
|
||||
bool stopServer(esp8285_obj* nic);
|
||||
|
||||
bool get_host_byname(esp8285_obj* nic,uint8_t* host,uint32_t len,uint8_t* out_ip);
|
||||
bool get_host_byname(esp8285_obj* nic, const char* host,uint32_t len,char* out_ip);
|
||||
|
||||
/**
|
||||
* Send data based on TCP or UDP builded already in single mode.
|
||||
|
|
@ -297,7 +297,7 @@ bool get_host_byname(esp8285_obj* nic,uint8_t* host,uint32_t len,uint8_t* out_ip
|
|||
* @retval true - success.
|
||||
* @retval false - failure.
|
||||
*/
|
||||
bool esp_send(esp8285_obj* nic,const uint8_t *buffer, uint32_t len, uint32_t timeout);
|
||||
bool esp_send(esp8285_obj* nic,const char* buffer, uint32_t len, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Send data based on one of TCP or UDP builded already in multiple mode.
|
||||
|
|
@ -308,7 +308,7 @@ bool esp_send(esp8285_obj* nic,const uint8_t *buffer, uint32_t len, uint32_t tim
|
|||
* @retval true - success.
|
||||
* @retval false - failure.
|
||||
*/
|
||||
bool esp_send_mul(esp8285_obj* nic,uint8_t mux_id, const uint8_t *buffer, uint32_t len);
|
||||
bool esp_send_mul(esp8285_obj* nic,char mux_id, const char* buffer, uint32_t len);
|
||||
|
||||
/**
|
||||
* Receive data from TCP or UDP builded already in single mode.
|
||||
|
|
@ -318,7 +318,7 @@ bool esp_send_mul(esp8285_obj* nic,uint8_t mux_id, const uint8_t *buffer, uint32
|
|||
* @param timeout - the time waiting data.
|
||||
* @return the length of data received actually.
|
||||
*/
|
||||
uint32_t esp_recv(esp8285_obj* nic,uint8_t *buffer, uint32_t buffer_size, uint32_t timeout);
|
||||
uint32_t esp_recv(esp8285_obj* nic,char* buffer, uint32_t buffer_size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Receive data from one of TCP or UDP builded already in multiple mode.
|
||||
|
|
@ -329,7 +329,7 @@ uint32_t esp_recv(esp8285_obj* nic,uint8_t *buffer, uint32_t buffer_size, uint32
|
|||
* @param timeout - the time waiting data.
|
||||
* @return the length of data received actually.
|
||||
*/
|
||||
uint32_t esp_recv_mul(esp8285_obj* nic,uint8_t mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout);
|
||||
uint32_t esp_recv_mul(esp8285_obj* nic,char mux_id, char* buffer, uint32_t buffer_size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Receive data from all of TCP or UDP builded already in multiple mode.
|
||||
|
|
@ -343,7 +343,7 @@ uint32_t esp_recv_mul(esp8285_obj* nic,uint8_t mux_id, uint8_t *buffer, uint32_t
|
|||
* @param timeout - the time waiting data.
|
||||
* @return the length of data received actually.
|
||||
*/
|
||||
uint32_t esp_recv_mul_id(esp8285_obj* nic,uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout);
|
||||
uint32_t esp_recv_mul_id(esp8285_obj* nic,char* coming_mux_id, char* buffer, uint32_t buffer_size, uint32_t timeout);
|
||||
|
||||
/*
|
||||
* Empty the buffer or UART RX.
|
||||
|
|
@ -353,13 +353,13 @@ void rx_empty(esp8285_obj* nic);
|
|||
/*
|
||||
* Recvive data from uart and search first target. Return true if target found, false for timeout.
|
||||
*/
|
||||
bool recvFind(esp8285_obj* nic,uint8_t* target, uint32_t timeout);
|
||||
bool recvFind(esp8285_obj* nic, const char* target, uint32_t timeout);
|
||||
|
||||
/*
|
||||
* Recvive data from uart and search first target and cut out the subchar* between begin and end(excluding begin and end self).
|
||||
* Return true if target found, false for timeout.
|
||||
*/
|
||||
bool recvFindAndFilter(esp8285_obj* nic,uint8_t* target, uint8_t* begin, uint8_t* end, uint8_t** data, uint32_t timeout);
|
||||
bool recvFindAndFilter(esp8285_obj* nic,const char* target, const char* begin, const char* end, char** data, uint32_t timeout);
|
||||
|
||||
/*
|
||||
* Receive a package from uart.
|
||||
|
|
@ -370,39 +370,39 @@ bool recvFindAndFilter(esp8285_obj* nic,uint8_t* target, uint8_t* begin, uint8_t
|
|||
* @param timeout - the duration waitting data comming.
|
||||
* @param coming_mux_id - in single connection mode, should be NULL and not NULL in multiple.
|
||||
*/
|
||||
uint32_t recvPkg(esp8285_obj*nic,uint8_t *buffer, uint32_t buffer_size, uint32_t *data_len, uint32_t timeout, uint8_t *coming_mux_id);
|
||||
uint32_t recvPkg(esp8285_obj*nic,char* buffer, uint32_t buffer_size, uint32_t *data_len, uint32_t timeout, char* coming_mux_id);
|
||||
|
||||
|
||||
bool eAT(esp8285_obj* nic);
|
||||
bool eATE(esp8285_obj* nic,bool enable);
|
||||
bool eATRST(esp8285_obj* nic);
|
||||
bool eATGMR(esp8285_obj* nic,uint8_t** version);
|
||||
bool qATCWMODE(esp8285_obj* nic,uint8_t *mode);
|
||||
bool sATCWMODE(esp8285_obj* nic,uint8_t mode);
|
||||
bool sATCWJAP(esp8285_obj* nic,uint8_t* ssid, uint8_t* pwd);
|
||||
bool sATCWDHCP(esp8285_obj* nic,uint8_t mode, bool enabled);
|
||||
bool eATGMR(esp8285_obj* nic,char** version);
|
||||
bool qATCWMODE(esp8285_obj* nic,char* mode);
|
||||
bool sATCWMODE(esp8285_obj* nic,char mode);
|
||||
bool sATCWJAP(esp8285_obj* nic, const char* ssid, const char* pwd);
|
||||
bool sATCWDHCP(esp8285_obj* nic,char mode, bool enabled);
|
||||
bool eATCWQAP(esp8285_obj* nic);
|
||||
|
||||
bool eATCIPSTATUS(esp8285_obj* nic,uint8_t** list);
|
||||
bool sATCIPSTARTSingle(esp8285_obj* nic,uint8_t* type, uint8_t* addr, uint32_t port);
|
||||
bool sATCIPSTARTMultiple(esp8285_obj*nic,uint8_t mux_id, uint8_t* type, uint8_t* addr, uint32_t port);
|
||||
bool sATCIPSENDSingle(esp8285_obj*nic,const uint8_t *buffer, uint32_t len, uint32_t timeout);
|
||||
bool sATCIPSENDMultiple(esp8285_obj* nic,uint8_t mux_id, const uint8_t *buffer, uint32_t len);
|
||||
bool sATCIPCLOSEMulitple(esp8285_obj* nic,uint8_t mux_id);
|
||||
bool eATCIPSTATUS(esp8285_obj* nic,char** list);
|
||||
bool sATCIPSTARTSingle(esp8285_obj* nic, const char* type, char* addr, uint32_t port);
|
||||
bool sATCIPSTARTMultiple(esp8285_obj*nic,char mux_id, char* type, char* addr, uint32_t port);
|
||||
bool sATCIPSENDSingle(esp8285_obj*nic,const char* buffer, uint32_t len, uint32_t timeout);
|
||||
bool sATCIPSENDMultiple(esp8285_obj* nic,char mux_id, const char* buffer, uint32_t len);
|
||||
bool sATCIPCLOSEMulitple(esp8285_obj* nic,char mux_id);
|
||||
bool eATCIPCLOSESingle(esp8285_obj* nic);
|
||||
bool eATCIFSR(esp8285_obj* nic,uint8_t** list);
|
||||
bool sATCIPMUX(esp8285_obj* nic,uint8_t mode);
|
||||
bool sATCIPSERVER(esp8285_obj* nic,uint8_t mode, uint32_t port);
|
||||
bool eATCIFSR(esp8285_obj* nic,char** list);
|
||||
bool sATCIPMUX(esp8285_obj* nic,char mode);
|
||||
bool sATCIPSERVER(esp8285_obj* nic,char mode, uint32_t port);
|
||||
bool sATCIPSTO(esp8285_obj* nic,uint32_t timeout);
|
||||
bool sATCIPMODE(esp8285_obj* nic,uint8_t mode);
|
||||
bool sATCIPDOMAIN(esp8285_obj* nic,uint8_t* domain_name);
|
||||
bool sATCIPMODE(esp8285_obj* nic,char mode);
|
||||
bool sATCIPDOMAIN(esp8285_obj* nic, const char* domain_name);
|
||||
bool qATCWJAP_CUR(esp8285_obj* nic);
|
||||
bool sATCIPSTA_CUR(esp8285_obj* nic,uint8_t* ip,uint8_t* gateway,uint8_t* netmask);
|
||||
bool sATCIPSTA_CUR(esp8285_obj* nic, const char* ip,char* gateway,char* netmask);
|
||||
bool qATCIPSTA_CUR(esp8285_obj* nic);
|
||||
bool eINIT(esp8285_obj* nic);
|
||||
bool get_ipconfig(esp8285_obj* nic, ipconfig_obj* ipconfig);
|
||||
bool eATCWLAP(esp8285_obj* nic);
|
||||
bool eATCWSAP(esp8285_obj* nic, char* ssid, char* key, int chl, int ecn);
|
||||
bool eATCWSAP(esp8285_obj* nic, const char* ssid, const char* key, int chl, int ecn);
|
||||
bool eATCWLAP_Start(esp8285_obj* nic);
|
||||
bool eATCWLAP_Get(esp8285_obj* nic, bool* end);
|
||||
/*
|
||||
|
|
@ -411,7 +411,7 @@ bool eATCWLAP_Get(esp8285_obj* nic, bool* end);
|
|||
*/
|
||||
|
||||
/*
|
||||
* bool sATCWSAP(char* ssid, char* pwd, uint8_t chl, uint8_t ecn);
|
||||
* bool sATCWSAP(char* ssid, char* pwd, char chl, char ecn);
|
||||
* bool eATCWLIF(char* &list);
|
||||
|
||||
*/
|
||||
|
|
@ -451,7 +451,7 @@ bool eATCWLAP_Get(esp8285_obj* nic, bool* end);
|
|||
* @param ecn - the way of encrypstion (0 - OPEN, 1 - WEP,
|
||||
* 2 - WPA_PSK, 3 - WPA2_PSK, 4 - WPA_WPA2_PSK, default: 4).
|
||||
* @note This method should not be called when station mode.
|
||||
* bool setSoftAPParam(char* ssid, char* pwd, uint8_t chl = 7, uint8_t ecn = 4);
|
||||
* bool setSoftAPParam(char* ssid, char* pwd, char chl = 7, char ecn = 4);
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ typedef struct _machine_uart_obj_t {
|
|||
} machine_uart_obj_t;
|
||||
|
||||
void uart_attach_to_repl(machine_uart_obj_t *self, bool attached);
|
||||
int uart_rx_char(machine_uart_obj_t *self);
|
||||
int uart_rx_char(mp_obj_t self);
|
||||
mp_uint_t uart_rx_any(machine_uart_obj_t *self);
|
||||
void uart_tx_strn(machine_uart_obj_t *uart_obj, const char *str, uint len);
|
||||
|
||||
|
|
|
|||
|
|
@ -251,7 +251,6 @@ STATIC void machine_hw_spi_init(mp_obj_base_t *self_in, size_t n_args, const mp_
|
|||
int cs[4] = {-1, -1, -1, -1};
|
||||
int d[8] = {-1,-1,-1,-1,-1,-1,-1,-1};
|
||||
int ret;
|
||||
bool valid = false;
|
||||
bool is_set_fpioa = false;
|
||||
sck = check_pin(args[ARG_sck].u_obj);
|
||||
cs[0] = check_pin(args[ARG_cs0].u_obj);
|
||||
|
|
@ -446,7 +445,7 @@ STATIC mp_obj_t mp_machine_spi_readinto(size_t n_args, const mp_obj_t *pos_args,
|
|||
{ MP_QSTR_write, MP_ARG_INT, {.u_int = 0} },
|
||||
{ MP_QSTR_cs, MP_ARG_INT, {.u_int = 0} },
|
||||
};
|
||||
machine_hw_spi_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
// machine_hw_spi_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(machine_spi_read_allowed_args)];
|
||||
mp_arg_parse_all(n_args - 2, pos_args + 2, kw_args,
|
||||
|
|
|
|||
|
|
@ -112,8 +112,9 @@ mp_uint_t uart_rx_any(machine_uart_obj_t *self)
|
|||
}
|
||||
}
|
||||
|
||||
mp_obj_t uart_any(machine_uart_obj_t *self)
|
||||
mp_obj_t uart_any(mp_obj_t self_)
|
||||
{
|
||||
machine_uart_obj_t* self = (machine_uart_obj_t*)self_;
|
||||
return mp_obj_new_int(uart_rx_any(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(machine_uart_any_obj, uart_any);
|
||||
|
|
@ -248,10 +249,9 @@ bool uart_rx_wait(machine_uart_obj_t *self, uint32_t timeout)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// assumes there is a character available
|
||||
int uart_rx_char(machine_uart_obj_t *self)
|
||||
int uart_rx_char(mp_obj_t self_)
|
||||
{
|
||||
machine_uart_obj_t* self = (machine_uart_obj_t*)self_;
|
||||
if (self->read_buf_tail != self->read_buf_head) {
|
||||
uint8_t data;
|
||||
data = self->read_buf[self->read_buf_tail];
|
||||
|
|
@ -269,6 +269,13 @@ int uart_rx_char(machine_uart_obj_t *self)
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// assumes there is a character available
|
||||
mp_obj_t uart_rx_char_py(void *self_)
|
||||
{
|
||||
return mp_obj_new_int(uart_rx_char(self_));
|
||||
}
|
||||
|
||||
mp_obj_t uart_readchar(machine_uart_obj_t *self)
|
||||
{
|
||||
int data = uart_rx_char(self);
|
||||
|
|
@ -279,7 +286,7 @@ mp_obj_t uart_readchar(machine_uart_obj_t *self)
|
|||
}
|
||||
return MP_OBJ_NULL;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(machine_uart_rx_char_obj, uart_rx_char);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(machine_uart_rx_char_obj, uart_rx_char_py);
|
||||
|
||||
int uart_rx_data(machine_uart_obj_t *self,uint8_t* buf_in,uint32_t size)
|
||||
{
|
||||
|
|
@ -322,7 +329,7 @@ STATIC size_t uart_tx_data(machine_uart_obj_t *self, const void *src_data, size_
|
|||
}
|
||||
*/
|
||||
//timeout = 2 * self->timeout_char;
|
||||
const uint8_t *src = (uint8_t*)src_data;
|
||||
uint8_t *src = (uint8_t*)src_data;
|
||||
size_t num_tx = 0;
|
||||
size_t cal = 0;
|
||||
if(self->attached_to_repl)
|
||||
|
|
@ -339,7 +346,7 @@ STATIC size_t uart_tx_data(machine_uart_obj_t *self, const void *src_data, size_
|
|||
if(MICROPY_UARTHS_DEVICE == self->uart_num)
|
||||
cal = uarths_send_data(src+num_tx, size - num_tx);
|
||||
else if(UART_DEVICE_MAX > self->uart_num)
|
||||
cal= uart_send_data(self->uart_num, (char*)(src+num_tx), size - num_tx);
|
||||
cal= uart_send_data(self->uart_num, (const char*)(src+num_tx), size - num_tx);
|
||||
num_tx += cal;
|
||||
}
|
||||
}
|
||||
|
|
@ -354,7 +361,7 @@ STATIC size_t uart_tx_data(machine_uart_obj_t *self, const void *src_data, size_
|
|||
if(MICROPY_UARTHS_DEVICE == self->uart_num)
|
||||
cal = uarths_send_data(src+num_tx, size - num_tx);
|
||||
else if(UART_DEVICE_MAX > self->uart_num)
|
||||
cal= uart_send_data(self->uart_num, (char*)(src+num_tx), size - num_tx);
|
||||
cal= uart_send_data(self->uart_num, (const char*)(src+num_tx), size - num_tx);
|
||||
num_tx = num_tx + cal;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ STATIC mp_obj_t machine_reset_cause()
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_cause_obj, machine_reset_cause);
|
||||
|
||||
STATIC const mp_map_elem_t machine_module_globals_table[] = {
|
||||
STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_machine) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&machine_uart_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Timer), MP_ROM_PTR(&machine_timer_type) },
|
||||
|
|
|
|||
|
|
@ -717,7 +717,7 @@ esp32_spi_aps_list_t *esp32_spi_scan_networks(void)
|
|||
*/
|
||||
int8_t esp32_spi_wifi_set_network(uint8_t *ssid)
|
||||
{
|
||||
esp32_spi_params_t *send = esp32_spi_params_alloc_1param(strlen(ssid), ssid);
|
||||
esp32_spi_params_t *send = esp32_spi_params_alloc_1param(strlen((const char*)ssid), ssid);
|
||||
esp32_spi_params_t *resp = esp32_spi_send_command_get_response(SET_NET_CMD, send, NULL, 0, 0);
|
||||
send->del(send);
|
||||
|
||||
|
|
@ -750,7 +750,7 @@ Sets the desired access point ssid and passphrase
|
|||
*/
|
||||
int8_t esp32_spi_wifi_wifi_set_passphrase(uint8_t *ssid, uint8_t *passphrase)
|
||||
{
|
||||
esp32_spi_params_t *send = esp32_spi_params_alloc_2param(strlen(ssid), ssid, strlen(passphrase), passphrase);
|
||||
esp32_spi_params_t *send = esp32_spi_params_alloc_2param(strlen((const char*)ssid), ssid, strlen((const char*)passphrase), passphrase);
|
||||
esp32_spi_params_t *resp = esp32_spi_send_command_get_response(SET_PASSPHRASE_CMD, send, NULL, 0, 0);
|
||||
send->del(send);
|
||||
|
||||
|
|
@ -985,7 +985,7 @@ int8_t esp32_spi_connect_AP(uint8_t *ssid, uint8_t *password, uint8_t retry_time
|
|||
//Converts a bytearray IP address to a dotted-quad string for printing
|
||||
void esp32_spi_pretty_ip(uint8_t *ip, uint8_t *str_ip)
|
||||
{
|
||||
sprintf(str_ip, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
sprintf((char*)str_ip, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1004,7 +1004,7 @@ int8_t esp32_spi_get_host_by_name(uint8_t *hostname, uint8_t *ip)
|
|||
printf("*** Get host by name\r\n");
|
||||
#endif
|
||||
|
||||
esp32_spi_params_t *send = esp32_spi_params_alloc_1param(strlen(hostname), hostname);
|
||||
esp32_spi_params_t *send = esp32_spi_params_alloc_1param(strlen((const char*)hostname), hostname);
|
||||
esp32_spi_params_t *resp = esp32_spi_send_command_get_response(REQ_HOST_BY_NAME_CMD, send, NULL, 0, 0);
|
||||
send->del(send);
|
||||
|
||||
|
|
@ -1181,7 +1181,7 @@ int8_t esp32_spi_socket_open(uint8_t sock_num, uint8_t *dest, uint8_t dest_type,
|
|||
send->params_num = 5;
|
||||
send->params = (void *)malloc(sizeof(void *) * send->params_num);
|
||||
//
|
||||
param_len = strlen(dest);
|
||||
param_len = strlen((const char*)dest);
|
||||
send->params[0] = (esp32_spi_param_t *)malloc(sizeof(esp32_spi_param_t));
|
||||
send->params[0]->param_len = param_len;
|
||||
send->params[0]->param = (uint8_t *)malloc(sizeof(uint8_t) * param_len);
|
||||
|
|
@ -1647,7 +1647,7 @@ uint8_t connect_server_port(char *host, uint16_t port)
|
|||
if (sock != 0xff)
|
||||
{
|
||||
uint8_t ip[6];
|
||||
if (esp32_spi_get_host_by_name(host, ip) == 0)
|
||||
if (esp32_spi_get_host_by_name((uint8_t*)host, ip) == 0)
|
||||
{
|
||||
if (esp32_spi_socket_connect(sock, ip, 0, port, TCP_MODE) != 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,7 +41,8 @@
|
|||
#include "esp8285.h"
|
||||
#include "sleep.h"
|
||||
|
||||
STATIC void kmp_get_next(char* targe, int next[])
|
||||
|
||||
STATIC void kmp_get_next(const char* targe, int next[])
|
||||
{
|
||||
int targe_Len = strlen(targe);
|
||||
next[0] = -1;
|
||||
|
|
@ -64,7 +65,7 @@ STATIC void kmp_get_next(char* targe, int next[])
|
|||
}
|
||||
}
|
||||
}
|
||||
STATIC int kmp_match(char* src,int src_len,char* targe, int* next)
|
||||
STATIC int kmp_match(char* src,int src_len, const char* targe, int* next)
|
||||
{
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
|
@ -87,17 +88,17 @@ STATIC int kmp_match(char* src,int src_len,char* targe, int* next)
|
|||
else
|
||||
return -1;
|
||||
}
|
||||
STATIC uint32_t kmp_find(uint8_t* src,uint32_t src_len,uint8_t* tagert)
|
||||
STATIC uint32_t kmp_find(char* src,uint32_t src_len, const char* tagert)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
uint32_t tag_len = strlen(tagert);
|
||||
uint32_t next = malloc(sizeof(uint32_t) * tag_len);
|
||||
int* next = (int*)malloc(sizeof(uint32_t) * tag_len);
|
||||
kmp_get_next(tagert,next);
|
||||
index = kmp_match(src,src_len,tagert,next);
|
||||
index = kmp_match(src,src_len,tagert, next);
|
||||
free(next);
|
||||
return index;
|
||||
}
|
||||
STATIC uint32_t data_find(uint8_t* src,uint32_t src_len,uint8_t* tagert)
|
||||
STATIC uint32_t data_find(char* src,uint32_t src_len, const char* tagert)
|
||||
{
|
||||
return kmp_find(src,src_len,tagert);
|
||||
}
|
||||
|
|
@ -124,16 +125,16 @@ bool reset(esp8285_obj* nic)
|
|||
return false;
|
||||
}
|
||||
|
||||
uint8_t* getVersion(esp8285_obj* nic)
|
||||
char* getVersion(esp8285_obj* nic)
|
||||
{
|
||||
uint8_t* version;
|
||||
char* version;
|
||||
eATGMR(nic,&version);
|
||||
return version;
|
||||
}
|
||||
|
||||
bool setOprToStation(esp8285_obj* nic)
|
||||
{
|
||||
uint8_t mode;
|
||||
char mode;
|
||||
if (!qATCWMODE(nic,&mode)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -149,12 +150,12 @@ bool setOprToStation(esp8285_obj* nic)
|
|||
}
|
||||
|
||||
|
||||
bool joinAP(esp8285_obj* nic,uint8_t* ssid, uint8_t* pwd)
|
||||
bool joinAP(esp8285_obj* nic, const char* ssid, const char* pwd)
|
||||
{
|
||||
return sATCWJAP(nic,ssid, pwd);
|
||||
}
|
||||
|
||||
bool enableClientDHCP(esp8285_obj* nic,uint8_t mode, bool enabled)
|
||||
bool enableClientDHCP(esp8285_obj* nic,char mode, bool enabled)
|
||||
{
|
||||
return sATCWDHCP(nic,mode, enabled);
|
||||
}
|
||||
|
|
@ -164,16 +165,16 @@ bool leaveAP(esp8285_obj* nic)
|
|||
return eATCWQAP(nic);
|
||||
}
|
||||
|
||||
uint8_t* getIPStatus(esp8285_obj* nic)
|
||||
char* getIPStatus(esp8285_obj* nic)
|
||||
{
|
||||
uint8_t* list;
|
||||
char* list;
|
||||
eATCIPSTATUS(nic, &list);
|
||||
return list;
|
||||
}
|
||||
|
||||
uint8_t* getLocalIP(esp8285_obj* nic)
|
||||
char* getLocalIP(esp8285_obj* nic)
|
||||
{
|
||||
uint8_t* list;
|
||||
char* list;
|
||||
eATCIFSR(nic, &list);
|
||||
return list;
|
||||
}
|
||||
|
|
@ -188,7 +189,7 @@ bool disableMUX(esp8285_obj* nic)
|
|||
return sATCIPMUX(nic,0);
|
||||
}
|
||||
|
||||
bool createTCP(esp8285_obj* nic,uint8_t* addr, uint32_t port)
|
||||
bool createTCP(esp8285_obj* nic,char* addr, uint32_t port)
|
||||
{
|
||||
return sATCIPSTARTSingle(nic,"TCP", addr, port);
|
||||
}
|
||||
|
|
@ -198,7 +199,7 @@ bool releaseTCP(esp8285_obj* nic)
|
|||
return eATCIPCLOSESingle(nic);
|
||||
}
|
||||
|
||||
bool registerUDP(esp8285_obj* nic,uint8_t* addr, uint32_t port)
|
||||
bool registerUDP(esp8285_obj* nic,char* addr, uint32_t port)
|
||||
{
|
||||
return sATCIPSTARTSingle(nic,"UDP", addr, port);
|
||||
}
|
||||
|
|
@ -208,22 +209,22 @@ bool unregisterUDP(esp8285_obj* nic)
|
|||
return eATCIPCLOSESingle(nic);
|
||||
}
|
||||
|
||||
bool createTCP_mul(esp8285_obj* nic,uint8_t mux_id, uint8_t* addr, uint32_t port)
|
||||
bool createTCP_mul(esp8285_obj* nic,char mux_id, char* addr, uint32_t port)
|
||||
{
|
||||
return sATCIPSTARTMultiple(nic,mux_id, "TCP", addr, port);
|
||||
}
|
||||
|
||||
bool releaseTCP_mul(esp8285_obj* nic,uint8_t mux_id)
|
||||
bool releaseTCP_mul(esp8285_obj* nic,char mux_id)
|
||||
{
|
||||
return sATCIPCLOSEMulitple(nic,mux_id);
|
||||
}
|
||||
|
||||
bool registerUDP_mul(esp8285_obj* nic,uint8_t mux_id, uint8_t* addr, uint32_t port)
|
||||
bool registerUDP_mul(esp8285_obj* nic,char mux_id, char* addr, uint32_t port)
|
||||
{
|
||||
return sATCIPSTARTMultiple(nic,mux_id, "UDP", addr, port);
|
||||
}
|
||||
|
||||
bool unregisterUDP_mul(esp8285_obj* nic,uint8_t mux_id)
|
||||
bool unregisterUDP_mul(esp8285_obj* nic,char mux_id)
|
||||
{
|
||||
return sATCIPCLOSEMulitple(nic,mux_id);
|
||||
}
|
||||
|
|
@ -258,7 +259,7 @@ bool stopServer(esp8285_obj* nic)
|
|||
return stopTCPServer(nic);
|
||||
}
|
||||
|
||||
bool get_host_byname(esp8285_obj* nic,uint8_t* host,uint32_t len,uint8_t* out_ip)
|
||||
bool get_host_byname(esp8285_obj* nic, const char* host,uint32_t len,char* out_ip)
|
||||
{
|
||||
int index = 0;
|
||||
if(false == sATCIPDOMAIN(nic,host))
|
||||
|
|
@ -266,14 +267,14 @@ bool get_host_byname(esp8285_obj* nic,uint8_t* host,uint32_t len,uint8_t* out_ip
|
|||
mp_printf(&mp_plat_print, "[MaixPy] %s | get_host_byname failed\n",__func__);
|
||||
return false;
|
||||
}
|
||||
uint8_t IP_buf[16]={0};
|
||||
char IP_buf[16]={0};
|
||||
index = data_find(nic->buffer,ESP8285_BUF_SIZE,"+CIPDOMAIN:");
|
||||
sscanf(nic->buffer + index,"+CIPDOMAIN:%s",IP_buf);
|
||||
mp_obj_t IP = mp_obj_new_str(IP_buf, strlen(IP_buf));
|
||||
nlr_buf_t nlr;
|
||||
if (nlr_push(&nlr) == 0)
|
||||
{
|
||||
netutils_parse_ipv4_addr(IP,out_ip,NETUTILS_BIG);
|
||||
netutils_parse_ipv4_addr(IP, (uint8_t*)out_ip,NETUTILS_BIG);
|
||||
nlr_pop();
|
||||
}
|
||||
return true;
|
||||
|
|
@ -284,7 +285,7 @@ bool get_ipconfig(esp8285_obj* nic, ipconfig_obj* ipconfig)
|
|||
|
||||
if(0 == qATCIPSTA_CUR(nic))
|
||||
return false;
|
||||
uint8_t* cur = NULL;
|
||||
char* cur = NULL;
|
||||
cur = strstr(nic->buffer, "ip");
|
||||
if(cur == NULL)
|
||||
{
|
||||
|
|
@ -317,8 +318,8 @@ bool get_ipconfig(esp8285_obj* nic, ipconfig_obj* ipconfig)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
uint8_t ssid[50] = {0};
|
||||
uint8_t MAC[17] = {0};
|
||||
char ssid[50] = {0};
|
||||
char MAC[17] = {0};
|
||||
cur = strstr(nic->buffer, "+CWJAP_CUR:");
|
||||
sscanf(cur, "+CWJAP_CUR:\"%[^\"]\",\"%[^\"]\"", ssid, MAC);
|
||||
ipconfig->ssid = mp_obj_new_str(ssid,strlen(ssid));
|
||||
|
|
@ -327,7 +328,7 @@ bool get_ipconfig(esp8285_obj* nic, ipconfig_obj* ipconfig)
|
|||
}
|
||||
|
||||
|
||||
bool esp_send(esp8285_obj* nic,const uint8_t *buffer, uint32_t len, uint32_t timeout)
|
||||
bool esp_send(esp8285_obj* nic,const char* buffer, uint32_t len, uint32_t timeout)
|
||||
{
|
||||
bool ret = false;
|
||||
uint32_t send_total_len = 0;
|
||||
|
|
@ -344,19 +345,19 @@ bool esp_send(esp8285_obj* nic,const uint8_t *buffer, uint32_t len, uint32_t tim
|
|||
return true;
|
||||
}
|
||||
|
||||
bool esp_send_mul(esp8285_obj* nic,uint8_t mux_id, const uint8_t *buffer, uint32_t len)
|
||||
bool esp_send_mul(esp8285_obj* nic,char mux_id, const char* buffer, uint32_t len)
|
||||
{
|
||||
return sATCIPSENDMultiple(nic,mux_id, buffer, len);
|
||||
}
|
||||
|
||||
uint32_t esp_recv(esp8285_obj* nic,uint8_t *buffer, uint32_t buffer_size, uint32_t timeout)
|
||||
uint32_t esp_recv(esp8285_obj* nic,char* buffer, uint32_t buffer_size, uint32_t timeout)
|
||||
{
|
||||
return recvPkg(nic,buffer, buffer_size, NULL, timeout, NULL);
|
||||
}
|
||||
|
||||
uint32_t esp_recv_mul(esp8285_obj* nic,uint8_t mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout)
|
||||
uint32_t esp_recv_mul(esp8285_obj* nic,char mux_id, char* buffer, uint32_t buffer_size, uint32_t timeout)
|
||||
{
|
||||
uint8_t id;
|
||||
char id;
|
||||
uint32_t ret;
|
||||
ret = recvPkg(nic,buffer, buffer_size, NULL, timeout, &id);
|
||||
if (ret > 0 && id == mux_id) {
|
||||
|
|
@ -365,7 +366,7 @@ uint32_t esp_recv_mul(esp8285_obj* nic,uint8_t mux_id, uint8_t *buffer, uint32_t
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint32_t esp_recv_mul_id(esp8285_obj* nic,uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout)
|
||||
uint32_t esp_recv_mul_id(esp8285_obj* nic,char* coming_mux_id, char* buffer, uint32_t buffer_size, uint32_t timeout)
|
||||
{
|
||||
return recvPkg(nic,buffer, buffer_size, NULL, timeout, coming_mux_id);
|
||||
}
|
||||
|
|
@ -373,19 +374,17 @@ uint32_t esp_recv_mul_id(esp8285_obj* nic,uint8_t *coming_mux_id, uint8_t *buffe
|
|||
/*----------------------------------------------------------------------------*/
|
||||
/* +IPD,<id>,<len>:<data> */
|
||||
/* +IPD,<len>:<data> */
|
||||
uint32_t recvPkg(esp8285_obj*nic,uint8_t *buffer, uint32_t buffer_size, uint32_t *data_len, uint32_t timeout, uint8_t *coming_mux_id)
|
||||
uint32_t recvPkg(esp8285_obj*nic,char* buffer, uint32_t buffer_size, uint32_t *data_len, uint32_t timeout, char* coming_mux_id)
|
||||
{
|
||||
int errcode;
|
||||
uint8_t data = 0;
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
|
||||
|
||||
char a;
|
||||
int index_PIPDcomma = -1;
|
||||
int index_colon = -1; /* : */
|
||||
int index_comma = -1; /* , */
|
||||
int len = -1;
|
||||
int8_t id = -1;
|
||||
int id = -1;
|
||||
bool has_data = false;
|
||||
uint32_t ret;
|
||||
unsigned long start;
|
||||
|
|
@ -440,7 +439,7 @@ uint32_t recvPkg(esp8285_obj*nic,uint8_t *buffer, uint32_t buffer_size, uint32_t
|
|||
*data_len = len;
|
||||
}
|
||||
if (index_comma != -1 && coming_mux_id) {
|
||||
*coming_mux_id = id;
|
||||
*coming_mux_id = (char)id;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -452,14 +451,14 @@ uint32_t recvPkg(esp8285_obj*nic,uint8_t *buffer, uint32_t buffer_size, uint32_t
|
|||
void rx_empty(esp8285_obj* nic)
|
||||
{
|
||||
int errcode;
|
||||
uint8_t data = 0;
|
||||
char data = 0;
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
while(uart_rx_any(nic->uart_obj) > 0) {
|
||||
uart_stream->read(nic->uart_obj,&data,1,&errcode);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t* recvString_1(esp8285_obj* nic,uint8_t* target1,uint32_t timeout)
|
||||
char* recvString_1(esp8285_obj* nic, const char* target1,uint32_t timeout)
|
||||
{
|
||||
int errcode;
|
||||
uint32_t iter = 0;
|
||||
|
|
@ -478,7 +477,7 @@ uint8_t* recvString_1(esp8285_obj* nic,uint8_t* target1,uint32_t timeout)
|
|||
}
|
||||
|
||||
|
||||
uint8_t* recvString_2(esp8285_obj* nic,uint8_t* target1, uint8_t* target2, uint32_t timeout, int8_t* find_index)
|
||||
char* recvString_2(esp8285_obj* nic,char* target1, char* target2, uint32_t timeout, int8_t* find_index)
|
||||
{
|
||||
int errcode;
|
||||
uint32_t iter = 0;
|
||||
|
|
@ -501,7 +500,7 @@ uint8_t* recvString_2(esp8285_obj* nic,uint8_t* target1, uint8_t* target2, uint3
|
|||
return NULL;
|
||||
}
|
||||
|
||||
uint8_t* recvString_3(esp8285_obj* nic,uint8_t* target1, uint8_t* target2,uint8_t* target3,uint32_t timeout, int8_t* find_index)
|
||||
char* recvString_3(esp8285_obj* nic,char* target1, char* target2,char* target3,uint32_t timeout, int8_t* find_index)
|
||||
{
|
||||
|
||||
int errcode;
|
||||
|
|
@ -528,9 +527,8 @@ uint8_t* recvString_3(esp8285_obj* nic,uint8_t* target1, uint8_t* target2,uint8_
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool recvFind(esp8285_obj* nic,uint8_t* target, uint32_t timeout)
|
||||
bool recvFind(esp8285_obj* nic, const char* target, uint32_t timeout)
|
||||
{
|
||||
uint8_t* data_tmp;
|
||||
recvString_1(nic, target, timeout);
|
||||
if (data_find(nic->buffer,ESP8285_BUF_SIZE,target) != -1) {
|
||||
return true;
|
||||
|
|
@ -538,7 +536,7 @@ bool recvFind(esp8285_obj* nic,uint8_t* target, uint32_t timeout)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool recvFindAndFilter(esp8285_obj* nic,uint8_t* target, uint8_t* begin, uint8_t* end, uint8_t** data, uint32_t timeout)
|
||||
bool recvFindAndFilter(esp8285_obj* nic,const char* target, const char* begin, const char* end, char** data, uint32_t timeout)
|
||||
{
|
||||
recvString_1(nic,target, timeout);
|
||||
if (data_find(nic->buffer,ESP8285_BUF_SIZE,target) != -1) {
|
||||
|
|
@ -546,8 +544,8 @@ bool recvFindAndFilter(esp8285_obj* nic,uint8_t* target, uint8_t* begin, uint8_t
|
|||
int32_t index2 = data_find(nic->buffer,ESP8285_BUF_SIZE,end);
|
||||
if (index1 != -1 && index2 != -1) {
|
||||
index1 += strlen(begin);
|
||||
*data = m_new(uint8_t, index2 - index1);
|
||||
memcpy(*data,nic->buffer[index1], index2 - index1);
|
||||
*data = m_new(char, index2 - index1);
|
||||
memcpy(*data,nic->buffer+index1, index2 - index1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -557,7 +555,7 @@ bool recvFindAndFilter(esp8285_obj* nic,uint8_t* target, uint8_t* begin, uint8_t
|
|||
bool eAT(esp8285_obj* nic)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT\r\n";
|
||||
const char* cmd = "AT\r\n";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);// clear rx
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
|
|
@ -567,18 +565,17 @@ bool eAT(esp8285_obj* nic)
|
|||
bool eATE(esp8285_obj* nic,bool enable)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "ATE0\r\n";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);// clear rx
|
||||
if(enable)
|
||||
{
|
||||
uint8_t* cmd = "ATE0\r\n";
|
||||
const char* cmd = "ATE0\r\n";
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
return recvFind(nic,"OK",1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t* cmd = "ATE1\r\n";
|
||||
const char* cmd = "ATE1\r\n";
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
return recvFind(nic,"OK",1000);
|
||||
}
|
||||
|
|
@ -588,18 +585,18 @@ bool eATE(esp8285_obj* nic,bool enable)
|
|||
bool eATRST(esp8285_obj* nic)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+RST\r\n";
|
||||
const char* cmd = "AT+RST\r\n";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);// clear rx
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
return recvFind(nic,"OK",1000);
|
||||
}
|
||||
|
||||
bool eATGMR(esp8285_obj* nic,uint8_t** version)
|
||||
bool eATGMR(esp8285_obj* nic,char** version)
|
||||
{
|
||||
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+GMR\r\n";
|
||||
const char* cmd = "AT+GMR\r\n";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);// clear rx
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
|
|
@ -607,12 +604,12 @@ bool eATGMR(esp8285_obj* nic,uint8_t** version)
|
|||
return recvFindAndFilter(nic,"OK", "\r\r\n", "\r\n\r\nOK", version, 5000);
|
||||
}
|
||||
|
||||
bool qATCWMODE(esp8285_obj* nic,uint8_t *mode)
|
||||
bool qATCWMODE(esp8285_obj* nic,char* mode)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CWMODE?\r\n";
|
||||
const char* cmd = "AT+CWMODE?\r\n";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
uint8_t* str_mode;
|
||||
char* str_mode;
|
||||
bool ret;
|
||||
if (!mode) {
|
||||
return false;
|
||||
|
|
@ -628,12 +625,12 @@ bool qATCWMODE(esp8285_obj* nic,uint8_t *mode)
|
|||
}
|
||||
}
|
||||
|
||||
bool sATCWMODE(esp8285_obj* nic,uint8_t mode)
|
||||
bool sATCWMODE(esp8285_obj* nic,char mode)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CWMODE=";
|
||||
const char* cmd = "AT+CWMODE=";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
uint8_t mode_str[10] = {0};
|
||||
char mode_str[10] = {0};
|
||||
int8_t find;
|
||||
itoa(mode, mode_str, 10);
|
||||
rx_empty(nic);
|
||||
|
|
@ -645,10 +642,10 @@ bool sATCWMODE(esp8285_obj* nic,uint8_t mode)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool sATCWJAP(esp8285_obj* nic,uint8_t* ssid, uint8_t* pwd)
|
||||
bool sATCWJAP(esp8285_obj* nic, const char* ssid, const char* pwd)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t *cmd = "AT+CWJAP=\"";
|
||||
const char* cmd = "AT+CWJAP=\"";
|
||||
int8_t find;
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
|
|
@ -663,13 +660,13 @@ bool sATCWJAP(esp8285_obj* nic,uint8_t* ssid, uint8_t* pwd)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool sATCWDHCP(esp8285_obj* nic,uint8_t mode, bool enabled)
|
||||
bool sATCWDHCP(esp8285_obj* nic,char mode, bool enabled)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CWDHCP=";
|
||||
const char* cmd = "AT+CWDHCP=";
|
||||
int8_t find;
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
uint8_t strEn[2] = {0};
|
||||
char strEn[2] = {0};
|
||||
if (enabled) {
|
||||
strcpy(strEn, "1");
|
||||
}
|
||||
|
|
@ -681,7 +678,7 @@ bool sATCWDHCP(esp8285_obj* nic,uint8_t mode, bool enabled)
|
|||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
uart_stream->write(nic->uart_obj,strEn,strlen(strEn),&errcode);
|
||||
uart_stream->write(nic->uart_obj,",",strlen(","),&errcode);
|
||||
uart_stream->write(nic->uart_obj,mode,1,&errcode);
|
||||
uart_stream->write(nic->uart_obj, &mode,1,&errcode);
|
||||
uart_stream->write(nic->uart_obj,"\r\n",strlen("\r\n"),&errcode);
|
||||
if( recvString_2(nic,"OK", "FAIL", 10000, &find) != NULL && find==0)
|
||||
return true;
|
||||
|
|
@ -692,17 +689,17 @@ bool sATCWDHCP(esp8285_obj* nic,uint8_t mode, bool enabled)
|
|||
bool eATCWQAP(esp8285_obj* nic)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CWQAP\r\n";
|
||||
const char* cmd = "AT+CWQAP\r\n";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
return recvFind(nic,"OK",1000);
|
||||
}
|
||||
|
||||
bool eATCIPSTATUS(esp8285_obj* nic,uint8_t** list)
|
||||
bool eATCIPSTATUS(esp8285_obj* nic,char** list)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIPSTATUS\r\n";
|
||||
const char* cmd = "AT+CIPSTATUS\r\n";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
msleep(100);
|
||||
|
|
@ -710,14 +707,14 @@ bool eATCIPSTATUS(esp8285_obj* nic,uint8_t** list)
|
|||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
return recvFindAndFilter(nic,"OK", "\r\r\n", "\r\n\r\nOK", list,1000);
|
||||
}
|
||||
bool sATCIPSTARTSingle(esp8285_obj* nic,uint8_t* type, uint8_t* addr, uint32_t port)
|
||||
bool sATCIPSTARTSingle(esp8285_obj* nic,const char* type, char* addr, uint32_t port)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIPSTART=\"";
|
||||
const char* cmd = "AT+CIPSTART=\"";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
mp_obj_t IP = netutils_format_ipv4_addr(addr,NETUTILS_BIG);
|
||||
uint8_t *host = mp_obj_str_get_str(IP);
|
||||
uint8_t port_str[10] = {0};
|
||||
mp_obj_t IP = netutils_format_ipv4_addr((uint8_t*)addr,NETUTILS_BIG);
|
||||
const char* host = mp_obj_str_get_str(IP);
|
||||
char port_str[10] = {0};
|
||||
int8_t find_index;
|
||||
itoa(port, port_str, 10);
|
||||
rx_empty(nic);
|
||||
|
|
@ -732,17 +729,17 @@ bool sATCIPSTARTSingle(esp8285_obj* nic,uint8_t* type, uint8_t* addr, uint32_t p
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
bool sATCIPSTARTMultiple(esp8285_obj*nic,uint8_t mux_id, uint8_t* type, uint8_t* addr, uint32_t port)
|
||||
bool sATCIPSTARTMultiple(esp8285_obj*nic,char mux_id, char* type, char* addr, uint32_t port)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIPSTART=";
|
||||
uint8_t port_str[10] = {0};
|
||||
const char* cmd = "AT+CIPSTART=";
|
||||
char port_str[10] = {0};
|
||||
int8_t find_index;
|
||||
itoa(port,port_str ,10);
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
uart_stream->write(nic->uart_obj,mux_id,1,&errcode);
|
||||
uart_stream->write(nic->uart_obj, &mux_id,1,&errcode);
|
||||
uart_stream->write(nic->uart_obj,",\"",strlen(",\""),&errcode);
|
||||
uart_stream->write(nic->uart_obj,type,strlen(type),&errcode);
|
||||
uart_stream->write(nic->uart_obj,"\",\"",strlen("\",\""),&errcode);
|
||||
|
|
@ -754,11 +751,11 @@ bool sATCIPSTARTMultiple(esp8285_obj*nic,uint8_t mux_id, uint8_t* type, uint8_t*
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
bool sATCIPSENDSingle(esp8285_obj*nic,const uint8_t *buffer, uint32_t len, uint32_t timeout)
|
||||
bool sATCIPSENDSingle(esp8285_obj*nic,const char* buffer, uint32_t len, uint32_t timeout)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIPSEND=";
|
||||
uint8_t len_str[10] = {0};
|
||||
const char* cmd = "AT+CIPSEND=";
|
||||
char len_str[10] = {0};
|
||||
itoa(len,len_str ,10);
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
|
|
@ -772,16 +769,16 @@ bool sATCIPSENDSingle(esp8285_obj*nic,const uint8_t *buffer, uint32_t len, uint3
|
|||
}
|
||||
return false;
|
||||
}
|
||||
bool sATCIPSENDMultiple(esp8285_obj* nic,uint8_t mux_id, const uint8_t *buffer, uint32_t len)
|
||||
bool sATCIPSENDMultiple(esp8285_obj* nic,char mux_id, const char* buffer, uint32_t len)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIPSEND=";
|
||||
uint8_t len_str[10] = {0};
|
||||
const char* cmd = "AT+CIPSEND=";
|
||||
char len_str[10] = {0};
|
||||
itoa(len,len_str ,10);
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
uart_stream->write(nic->uart_obj,mux_id,1,&errcode);
|
||||
uart_stream->write(nic->uart_obj, &mux_id,1,&errcode);
|
||||
uart_stream->write(nic->uart_obj,",",strlen(","),&errcode);
|
||||
uart_stream->write(nic->uart_obj,len_str,strlen(len_str),&errcode);
|
||||
if (recvFind(nic,">", 5000)) {
|
||||
|
|
@ -792,15 +789,15 @@ bool sATCIPSENDMultiple(esp8285_obj* nic,uint8_t mux_id, const uint8_t *buffer,
|
|||
}
|
||||
return false;
|
||||
}
|
||||
bool sATCIPCLOSEMulitple(esp8285_obj* nic,uint8_t mux_id)
|
||||
bool sATCIPCLOSEMulitple(esp8285_obj* nic,char mux_id)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIPCLOSE=";
|
||||
const char* cmd = "AT+CIPCLOSE=";
|
||||
int8_t find;
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
uart_stream->write(nic->uart_obj,mux_id,1,&errcode);
|
||||
uart_stream->write(nic->uart_obj,(const char*)&mux_id,1,&errcode);
|
||||
uart_stream->write(nic->uart_obj,"\r\n",strlen("\r\n"),&errcode);
|
||||
if(recvString_2(nic,"OK", "link is not", 5000, &find) != NULL)
|
||||
return true;
|
||||
|
|
@ -810,26 +807,26 @@ bool eATCIPCLOSESingle(esp8285_obj* nic)
|
|||
{
|
||||
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIPCLOSE\r\n";
|
||||
const char* cmd = "AT+CIPCLOSE\r\n";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
return recvFind(nic,"OK", 5000);
|
||||
}
|
||||
bool eATCIFSR(esp8285_obj* nic,uint8_t** list)
|
||||
bool eATCIFSR(esp8285_obj* nic,char** list)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIFSR\r\n";
|
||||
const char* cmd = "AT+CIFSR\r\n";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
return recvFindAndFilter(nic,"OK", "\r\r\n", "\r\n\r\nOK", list,5000);
|
||||
}
|
||||
bool sATCIPMUX(esp8285_obj* nic,uint8_t mode)
|
||||
bool sATCIPMUX(esp8285_obj* nic,char mode)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIPMUX=";
|
||||
uint8_t mode_str[10] = {0};
|
||||
const char* cmd = "AT+CIPMUX=";
|
||||
char mode_str[10] = {0};
|
||||
int8_t find;
|
||||
itoa(mode, mode_str, 10);
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
|
|
@ -841,14 +838,14 @@ bool sATCIPMUX(esp8285_obj* nic,uint8_t mode)
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
bool sATCIPSERVER(esp8285_obj* nic,uint8_t mode, uint32_t port)
|
||||
bool sATCIPSERVER(esp8285_obj* nic,char mode, uint32_t port)
|
||||
{
|
||||
int errcode = 0;
|
||||
int8_t find;
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
if (mode) {
|
||||
uint8_t* cmd = "AT+CIPSERVER=1,";
|
||||
uint8_t port_str[10] = {0};
|
||||
const char* cmd = "AT+CIPSERVER=1,";
|
||||
char port_str[10] = {0};
|
||||
itoa(port, port_str, 10);
|
||||
rx_empty(nic);
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
|
|
@ -859,7 +856,7 @@ bool sATCIPSERVER(esp8285_obj* nic,uint8_t mode, uint32_t port)
|
|||
return false;
|
||||
} else {
|
||||
rx_empty(nic);
|
||||
uint8_t* cmd = "AT+CIPSERVER=0";
|
||||
const char* cmd = "AT+CIPSERVER=0";
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
uart_stream->write(nic->uart_obj,"\r\n",strlen("\r\n"),&errcode);
|
||||
return recvFind(nic,"\r\r\n",1000);
|
||||
|
|
@ -869,8 +866,8 @@ bool sATCIPSTO(esp8285_obj* nic,uint32_t timeout)
|
|||
{
|
||||
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIPSTO=";
|
||||
uint8_t timeout_str[10] = {0};
|
||||
const char* cmd = "AT+CIPSTO=";
|
||||
char timeout_str[10] = {0};
|
||||
itoa(timeout, timeout_str, 10);
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
|
|
@ -880,12 +877,12 @@ bool sATCIPSTO(esp8285_obj* nic,uint32_t timeout)
|
|||
return recvFind(nic,"OK",1000);
|
||||
}
|
||||
|
||||
bool sATCIPMODE(esp8285_obj* nic,uint8_t mode)
|
||||
bool sATCIPMODE(esp8285_obj* nic,char mode)
|
||||
{
|
||||
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIPMODE=";
|
||||
uint8_t mode_str[10] = {0};
|
||||
const char* cmd = "AT+CIPMODE=";
|
||||
char mode_str[10] = {0};
|
||||
itoa(mode, mode_str, 10);
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
|
|
@ -895,10 +892,10 @@ bool sATCIPMODE(esp8285_obj* nic,uint8_t mode)
|
|||
return recvFind(nic,"OK",1000);
|
||||
}
|
||||
|
||||
bool sATCIPDOMAIN(esp8285_obj* nic,uint8_t* domain_name)
|
||||
bool sATCIPDOMAIN(esp8285_obj* nic, const char* domain_name)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIPDOMAIN=";
|
||||
const char* cmd = "AT+CIPDOMAIN=";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
|
|
@ -912,17 +909,17 @@ bool sATCIPDOMAIN(esp8285_obj* nic,uint8_t* domain_name)
|
|||
bool qATCIPSTA_CUR(esp8285_obj* nic)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIPSTA_CUR?";
|
||||
const char* cmd = "AT+CIPSTA_CUR?";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
uart_stream->write(nic->uart_obj,"\r\n",strlen("\r\n"),&errcode);
|
||||
return recvFind(nic,"OK",1000);
|
||||
}
|
||||
bool sATCIPSTA_CUR(esp8285_obj* nic,uint8_t* ip,uint8_t* gateway,uint8_t* netmask)
|
||||
bool sATCIPSTA_CUR(esp8285_obj* nic, const char* ip,char* gateway,char* netmask)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CIPSTA_CUR=";
|
||||
const char* cmd = "AT+CIPSTA_CUR=";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
if(NULL == ip)
|
||||
|
|
@ -952,7 +949,7 @@ bool sATCIPSTA_CUR(esp8285_obj* nic,uint8_t* ip,uint8_t* gateway,uint8_t* netmas
|
|||
bool qATCWJAP_CUR(esp8285_obj* nic)
|
||||
{
|
||||
int errcode = 0;
|
||||
uint8_t* cmd = "AT+CWJAP_CUR?";
|
||||
const char* cmd = "AT+CWJAP_CUR?";
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
rx_empty(nic);
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
|
|
@ -974,11 +971,9 @@ bool eINIT(esp8285_obj* nic)
|
|||
|
||||
bool eATCWLAP(esp8285_obj* nic)
|
||||
{
|
||||
int errcode = 0, i = 0;
|
||||
int errcode = 0;
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
const char cmd[] = {"AT+CWLAP"};
|
||||
char *p = NULL;
|
||||
mp_obj_t list = mp_obj_new_list(0, NULL);
|
||||
|
||||
rx_empty(nic);
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
|
|
@ -992,11 +987,9 @@ bool eATCWLAP(esp8285_obj* nic)
|
|||
|
||||
bool eATCWLAP_Start(esp8285_obj* nic)
|
||||
{
|
||||
int errcode = 0, i = 0;
|
||||
int errcode = 0;
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
const char cmd[] = {"AT+CWLAP"};
|
||||
char *p = NULL;
|
||||
mp_obj_t list = mp_obj_new_list(0, NULL);
|
||||
|
||||
rx_empty(nic);
|
||||
uart_stream->write(nic->uart_obj,cmd,strlen(cmd),&errcode);
|
||||
|
|
@ -1018,10 +1011,9 @@ bool eATCWLAP_Get(esp8285_obj* nic, bool* end)
|
|||
}
|
||||
|
||||
|
||||
bool eATCWSAP(esp8285_obj* nic, char* ssid, char* key, int chl, int ecn)
|
||||
bool eATCWSAP(esp8285_obj* nic, const char* ssid, const char* key, int chl, int ecn)
|
||||
{
|
||||
int errcode;
|
||||
int iter = 0;
|
||||
const mp_stream_p_t * uart_stream = mp_get_stream(nic->uart_obj);
|
||||
char ap_cmd[128] = {0};
|
||||
|
||||
|
|
@ -1047,7 +1039,7 @@ bool eATCWSAP(esp8285_obj* nic, char* ssid, char* key, int chl, int ecn)
|
|||
|
||||
//bool setOprToSoftAP(void)
|
||||
//{
|
||||
// uint8_t mode;
|
||||
// char mode;
|
||||
// if (!qATCWMODE(&mode)) {
|
||||
// return false;
|
||||
// }
|
||||
|
|
@ -1064,7 +1056,7 @@ bool eATCWSAP(esp8285_obj* nic, char* ssid, char* key, int chl, int ecn)
|
|||
|
||||
//bool setOprToStationSoftAP(void)
|
||||
//{
|
||||
// uint8_t mode;
|
||||
// char mode;
|
||||
// if (!qATCWMODE(&mode)) {
|
||||
// return false;
|
||||
// }
|
||||
|
|
@ -1087,7 +1079,7 @@ bool eATCWSAP(esp8285_obj* nic, char* ssid, char* key, int chl, int ecn)
|
|||
//}
|
||||
|
||||
|
||||
//bool setSoftAPParam(String ssid, String pwd, uint8_t chl, uint8_t ecn)
|
||||
//bool setSoftAPParam(String ssid, String pwd, char chl, char ecn)
|
||||
//{
|
||||
// return sATCWSAP(ssid, pwd, chl, ecn);
|
||||
//}
|
||||
|
|
@ -1108,7 +1100,7 @@ bool eATCWSAP(esp8285_obj* nic, char* ssid, char* key, int chl, int ecn)
|
|||
//}
|
||||
|
||||
|
||||
//bool sATCWSAP(String ssid, String pwd, uint8_t chl, uint8_t ecn)
|
||||
//bool sATCWSAP(String ssid, String pwd, char chl, char ecn)
|
||||
//{
|
||||
// String data;
|
||||
// rx_empty();
|
||||
|
|
|
|||
|
|
@ -291,19 +291,19 @@ STATIC int cc3k_socket_ioctl(mod_network_socket_obj_t *socket, mp_uint_t request
|
|||
}
|
||||
*/
|
||||
|
||||
STATIC mp_uint_t esp8285_socket_close(mod_network_socket_obj_t *socket) {
|
||||
if(&mod_network_nic_type_esp8285 != mp_obj_get_type(MP_OBJ_TO_PTR(socket->nic)))
|
||||
STATIC void esp8285_socket_close(mod_network_socket_obj_t *socket) {
|
||||
if((mp_obj_type_t*)&mod_network_nic_type_esp8285 != mp_obj_get_type(MP_OBJ_TO_PTR(socket->nic)))
|
||||
{
|
||||
mp_printf(&mp_plat_print, "[MaixPy] %s | esp8285_socket_connect can not get nic\n",__func__);
|
||||
return -1;
|
||||
return ;
|
||||
}
|
||||
nic_obj_t* self = MP_OBJ_TO_PTR(socket->nic);
|
||||
return releaseTCP(&self->esp8285);
|
||||
releaseTCP(&self->esp8285);
|
||||
}
|
||||
|
||||
|
||||
STATIC mp_uint_t esp8285_socket_recv(mod_network_socket_obj_t *socket, byte *buf, mp_uint_t len, int *_errno) {
|
||||
if(&mod_network_nic_type_esp8285 != mp_obj_get_type(MP_OBJ_TO_PTR(socket->nic)))
|
||||
if((mp_obj_type_t*)&mod_network_nic_type_esp8285 != mp_obj_get_type(MP_OBJ_TO_PTR(socket->nic)))
|
||||
{
|
||||
mp_printf(&mp_plat_print, "[MaixPy] %s | esp8285_socket_connect can not get nic\n",__func__);
|
||||
*_errno = MP_EPIPE;
|
||||
|
|
@ -311,7 +311,7 @@ STATIC mp_uint_t esp8285_socket_recv(mod_network_socket_obj_t *socket, byte *buf
|
|||
}
|
||||
nic_obj_t* self = MP_OBJ_TO_PTR(socket->nic);
|
||||
int read_len = 0;
|
||||
read_len = esp_recv(&self->esp8285,buf,len, (uint32_t)(socket->timeout*1000) );
|
||||
read_len = esp_recv(&self->esp8285, (char*)buf, len, (uint32_t)(socket->timeout*1000) );
|
||||
if(-1 == read_len)
|
||||
*_errno = MP_EIO;
|
||||
return read_len;
|
||||
|
|
@ -319,14 +319,14 @@ STATIC mp_uint_t esp8285_socket_recv(mod_network_socket_obj_t *socket, byte *buf
|
|||
|
||||
STATIC mp_uint_t esp8285_socket_send(mod_network_socket_obj_t *socket, const byte *buf, mp_uint_t len, int *_errno) {
|
||||
|
||||
if(&mod_network_nic_type_esp8285 != mp_obj_get_type(MP_OBJ_TO_PTR(socket->nic)))
|
||||
if((mp_obj_type_t*)&mod_network_nic_type_esp8285 != mp_obj_get_type(MP_OBJ_TO_PTR(socket->nic)))
|
||||
{
|
||||
mp_printf(&mp_plat_print, "[MaixPy] %s | esp8285_socket_connect can not get nic\n",__func__);
|
||||
*_errno = MP_EPIPE;
|
||||
return -1;
|
||||
}
|
||||
nic_obj_t* self = MP_OBJ_TO_PTR(socket->nic);
|
||||
if(0 == esp_send(&self->esp8285,buf,len, (uint32_t)(socket->timeout*1000) ) )
|
||||
if(0 == esp_send(&self->esp8285,(const char*)buf,len, (uint32_t)(socket->timeout*1000) ) )
|
||||
{
|
||||
mp_printf(&mp_plat_print, "[MaixPy] %s | send data failed\n",__func__);
|
||||
*_errno = MP_EIO;
|
||||
|
|
@ -344,7 +344,7 @@ STATIC int esp8285_socket_socket(mod_network_socket_obj_t *socket, int *_errno)
|
|||
|
||||
|
||||
STATIC int esp8285_socket_connect(mod_network_socket_obj_t *socket, byte *ip, mp_uint_t port, int *_errno) {
|
||||
if(&mod_network_nic_type_esp8285 != mp_obj_get_type(MP_OBJ_TO_PTR(socket->nic)))
|
||||
if((mp_obj_type_t*)&mod_network_nic_type_esp8285 != mp_obj_get_type(MP_OBJ_TO_PTR(socket->nic)))
|
||||
{
|
||||
mp_printf(&mp_plat_print, "[MaixPy] %s | esp8285_socket_connect can not get nic\n",__func__);
|
||||
*_errno = -1;
|
||||
|
|
@ -355,7 +355,7 @@ STATIC int esp8285_socket_connect(mod_network_socket_obj_t *socket, byte *ip, mp
|
|||
{
|
||||
case MOD_NETWORK_SOCK_STREAM:
|
||||
{
|
||||
if(false == createTCP(&self->esp8285,ip,port))
|
||||
if(false == createTCP(&self->esp8285, (char*)ip,port))
|
||||
{
|
||||
*_errno = -1;
|
||||
return -1;
|
||||
|
|
@ -364,7 +364,7 @@ STATIC int esp8285_socket_connect(mod_network_socket_obj_t *socket, byte *ip, mp
|
|||
}
|
||||
case MOD_NETWORK_SOCK_DGRAM:
|
||||
{
|
||||
if(false == registerUDP(&self->esp8285,ip,port))
|
||||
if(false == registerUDP(&self->esp8285, (char*)ip,port))
|
||||
{
|
||||
*_errno = -1;
|
||||
return -1;
|
||||
|
|
@ -373,7 +373,7 @@ STATIC int esp8285_socket_connect(mod_network_socket_obj_t *socket, byte *ip, mp
|
|||
}
|
||||
default:
|
||||
{
|
||||
if(false == createTCP(&self->esp8285,ip,port))
|
||||
if(false == createTCP(&self->esp8285, (char*)ip,port))
|
||||
{
|
||||
*_errno = -1;
|
||||
return -1;
|
||||
|
|
@ -385,12 +385,10 @@ STATIC int esp8285_socket_connect(mod_network_socket_obj_t *socket, byte *ip, mp
|
|||
}
|
||||
|
||||
|
||||
STATIC int esp8285_socket_gethostbyname(mp_obj_t nic, const char *name, mp_uint_t len, uint8_t *out_ip) {
|
||||
nic_obj_t* self = NULL;
|
||||
if(&mod_network_nic_type_esp8285 == mp_obj_get_type(nic))
|
||||
STATIC int esp8285_socket_gethostbyname(mp_obj_t nic, const char *name, mp_uint_t len, uint8_t* out_ip) {
|
||||
if((mp_obj_type_t*)&mod_network_nic_type_esp8285 == mp_obj_get_type(nic))
|
||||
{
|
||||
self = nic;
|
||||
return get_host_byname(&nic_obj.esp8285,name,len,out_ip);
|
||||
return get_host_byname(&nic_obj.esp8285,name,len, (char*)out_ip);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -434,7 +432,7 @@ STATIC mp_obj_t esp8285_nic_connect(size_t n_args, const mp_obj_t *pos_args, mp_
|
|||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
//get nic
|
||||
if(&mod_network_nic_type_esp8285 == mp_obj_get_type(pos_args[0]))
|
||||
if((mp_obj_type_t*)&mod_network_nic_type_esp8285 == mp_obj_get_type(pos_args[0]))
|
||||
{
|
||||
mp_printf(&mp_plat_print, "[MaixPy] %s | get nic\n",__func__);
|
||||
self = pos_args[0];
|
||||
|
|
@ -453,7 +451,7 @@ STATIC mp_obj_t esp8285_nic_connect(size_t n_args, const mp_obj_t *pos_args, mp_
|
|||
}
|
||||
// connect to AP
|
||||
|
||||
if (0 == joinAP(&self->esp8285,(uint8_t*)ssid,(uint8_t*)key)) {
|
||||
if (0 == joinAP(&self->esp8285, ssid, key)) {
|
||||
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "could not connect to ssid=%s, key=%s\n", ssid, key));
|
||||
}
|
||||
nic_connected = 1;
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_settimeout_obj, socket_settimeout);
|
|||
|
||||
// method socket.setblocking(flag)
|
||||
STATIC mp_obj_t socket_setblocking(mp_obj_t self_in, mp_obj_t blocking) {
|
||||
mod_network_socket_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
// mod_network_socket_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_printf(&mp_plat_print, "[MaixPy] %s | uart socket Do nothing\n",__func__);
|
||||
return mp_const_none;
|
||||
}
|
||||
|
|
@ -437,7 +437,6 @@ STATIC mp_obj_t mod_usocket_getaddrinfo(mp_obj_t host_in, mp_obj_t port_in) {
|
|||
mod_network_nic_type_t *nic_type = (mod_network_nic_type_t*)mp_obj_get_type(nic);
|
||||
if(parse_ret == 0)
|
||||
{
|
||||
int ret = 0;
|
||||
if (nic_type->gethostbyname != NULL)
|
||||
if(false == nic_type->gethostbyname(nic ,host,strlen(host),out_ip))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,11 +35,10 @@ typedef struct {
|
|||
mp_obj_t vfs_internal_spiffs_open(spiffs_user_mount_t* vfs, const char* path, const char* mode_s, int* error_code)
|
||||
{
|
||||
uint32_t mode = 0;
|
||||
mp_obj_type_t* type = &mp_type_vfs_spiffs_textio;
|
||||
mp_obj_type_t* type = (mp_obj_type_t*)&mp_type_vfs_spiffs_textio;
|
||||
|
||||
*error_code = 0;
|
||||
uint16_t i = 0;
|
||||
char* open_name = path;
|
||||
char* open_name = (char*)path;
|
||||
if(open_name[0] == '.' && open_name[1] == '/')
|
||||
{
|
||||
memmove(open_name, open_name+1, strlen(open_name));
|
||||
|
|
@ -70,11 +69,11 @@ mp_obj_t vfs_internal_spiffs_open(spiffs_user_mount_t* vfs, const char* path, co
|
|||
break;
|
||||
#if MICROPY_PY_IO_FILEIO
|
||||
case 'b':
|
||||
type = &mp_type_vfs_spiffs_fileio;
|
||||
type = (mp_obj_type_t*)&mp_type_vfs_spiffs_fileio;
|
||||
break;
|
||||
#endif
|
||||
case 't':
|
||||
type = &mp_type_vfs_spiffs_textio;
|
||||
type = (mp_obj_type_t*)&mp_type_vfs_spiffs_textio;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -96,7 +95,7 @@ mp_obj_t vfs_internal_spiffs_open(spiffs_user_mount_t* vfs, const char* path, co
|
|||
mp_obj_t vfs_internal_fatfs_open(fs_user_mount_t* vfs, const char* path, const char* mode_s, int* error_code)
|
||||
{
|
||||
int mode = 0;
|
||||
mp_obj_type_t* type = &mp_type_vfs_spiffs_textio;
|
||||
mp_obj_type_t* type = (mp_obj_type_t*)&mp_type_vfs_spiffs_textio;
|
||||
|
||||
*error_code = 0;
|
||||
// TODO: make sure only one of r, w, x, a, and b, t are specified
|
||||
|
|
@ -119,11 +118,11 @@ mp_obj_t vfs_internal_fatfs_open(fs_user_mount_t* vfs, const char* path, const c
|
|||
break;
|
||||
#if MICROPY_PY_IO_FILEIO
|
||||
case 'b':
|
||||
type = &mp_type_vfs_fat_fileio;
|
||||
type = (mp_obj_type_t*)&mp_type_vfs_fat_fileio;
|
||||
break;
|
||||
#endif
|
||||
case 't':
|
||||
type = &mp_type_vfs_fat_textio;
|
||||
type = (mp_obj_type_t*)&mp_type_vfs_fat_textio;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -164,11 +163,11 @@ mp_obj_t vfs_internal_open(const char* path, const char* mode, int* error_code)
|
|||
{
|
||||
// *error_code = EPERM;
|
||||
// return MP_OBJ_NULL;
|
||||
return vfs_internal_spiffs_open(fs, real_path, mode, error_code);
|
||||
return vfs_internal_spiffs_open((spiffs_user_mount_t*)fs, real_path, mode, error_code);
|
||||
}
|
||||
else if( fs->base.type == &mp_fat_vfs_type)
|
||||
{
|
||||
return vfs_internal_fatfs_open(fs, real_path, mode, error_code);
|
||||
return vfs_internal_fatfs_open((fs_user_mount_t*)fs, real_path, mode, error_code);
|
||||
}
|
||||
*error_code = MP_ENOENT;
|
||||
return MP_OBJ_NULL;
|
||||
|
|
@ -177,7 +176,7 @@ mp_obj_t vfs_internal_open(const char* path, const char* mode, int* error_code)
|
|||
mp_uint_t vfs_internal_write(mp_obj_t fs, void* data, mp_uint_t length, int* error_code)
|
||||
{
|
||||
fs_info_t* fs_info = (fs_info_t*)fs;
|
||||
mp_stream_p_t* stream = fs_info->base.type->protocol;
|
||||
mp_stream_p_t* stream = (mp_stream_p_t*)fs_info->base.type->protocol;
|
||||
*error_code = 0;
|
||||
return stream->write(fs, data, length, error_code);
|
||||
}
|
||||
|
|
@ -185,7 +184,7 @@ mp_uint_t vfs_internal_write(mp_obj_t fs, void* data, mp_uint_t length, int* err
|
|||
mp_uint_t vfs_internal_read(mp_obj_t fs, void* data, mp_uint_t length, int* error_code)
|
||||
{
|
||||
fs_info_t* fs_info = (fs_info_t*)fs;
|
||||
mp_stream_p_t* stream = fs_info->base.type->protocol;
|
||||
mp_stream_p_t* stream = (mp_stream_p_t*)fs_info->base.type->protocol;
|
||||
*error_code = 0;
|
||||
return stream->read(fs, data, length, error_code);
|
||||
}
|
||||
|
|
@ -193,7 +192,7 @@ mp_uint_t vfs_internal_read(mp_obj_t fs, void* data, mp_uint_t length, int* erro
|
|||
void vfs_internal_close(mp_obj_t fs, int* error_code)
|
||||
{
|
||||
fs_info_t* fs_info = (fs_info_t*)fs;
|
||||
mp_stream_p_t* stream = fs_info->base.type->protocol;
|
||||
mp_stream_p_t* stream = (mp_stream_p_t*)fs_info->base.type->protocol;
|
||||
*error_code = 0;
|
||||
stream->ioctl(fs, MP_STREAM_CLOSE, 0, error_code);
|
||||
if(fs_info->base.type == &mp_type_vfs_spiffs_fileio ||
|
||||
|
|
@ -211,18 +210,18 @@ void vfs_internal_close(mp_obj_t fs, int* error_code)
|
|||
mp_uint_t vfs_internal_seek(mp_obj_t fs, mp_int_t offset, uint8_t whence, int* error_code)
|
||||
{
|
||||
fs_info_t* fs_info = (fs_info_t*)fs;
|
||||
mp_stream_p_t* stream = fs_info->base.type->protocol;
|
||||
mp_stream_p_t* stream = (mp_stream_p_t*)fs_info->base.type->protocol;
|
||||
*error_code = 0;
|
||||
struct mp_stream_seek_t seek;
|
||||
seek.offset = offset;
|
||||
seek.whence = whence;
|
||||
return stream->ioctl(fs, MP_STREAM_SEEK, &seek, error_code);
|
||||
return stream->ioctl(fs, MP_STREAM_SEEK, (uintptr_t)&seek, error_code);
|
||||
}
|
||||
|
||||
mp_uint_t vfs_internal_size(mp_obj_t fs)
|
||||
{
|
||||
fs_info_t* fs_info = (fs_info_t*)fs;
|
||||
mp_stream_p_t* stream = fs_info->base.type->protocol;
|
||||
// mp_stream_p_t* stream = (mp_stream_p_t*)fs_info->base.type->protocol;
|
||||
if(fs_info->base.type == &mp_type_vfs_spiffs_fileio ||
|
||||
fs_info->base.type == &mp_type_vfs_spiffs_textio)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ STATIC mp_obj_t mp_vfs_spiffs_ilistdir_it_iternext(mp_obj_t self_in) {
|
|||
// static const char types[] = "?fdhs"; // file, dir, hardlink, softlink
|
||||
for (;;) {
|
||||
de_ret = SPIFFS_readdir(&self->dir, &de);
|
||||
char *fn = de.name;
|
||||
char *fn = (char*)de.name;
|
||||
if (de_ret == NULL || fn[0] == 0) {
|
||||
// stop on error or end of dir
|
||||
break;
|
||||
|
|
@ -251,8 +251,7 @@ STATIC mp_obj_t spiffs_vfs_remove_internal(mp_obj_t vfs_in, mp_obj_t path_in, mp
|
|||
STATIC mp_obj_t spiffs_vfs_remove(mp_obj_t vfs_in, mp_obj_t path_in) {
|
||||
spiffs_user_mount_t* vfs = MP_OBJ_TO_PTR(vfs_in);
|
||||
const char *path = mp_obj_str_get_str(path_in);
|
||||
int i = 0;
|
||||
char* open_name = path;
|
||||
char* open_name = (char*)path;
|
||||
if(path[0] == '.' && path[1] == '/')
|
||||
{
|
||||
memmove(open_name, open_name+1, strlen(open_name));
|
||||
|
|
@ -287,7 +286,7 @@ STATIC mp_obj_t spiffs_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t pa
|
|||
const char *old_path = mp_obj_str_get_str(path_in);
|
||||
const char *new_path = mp_obj_str_get_str(path_out);
|
||||
int i = 0;
|
||||
char* old_name = &old_path[i];
|
||||
char* old_name = (char*)&old_path[i];
|
||||
if(old_path[0] == '.' && old_path[1] == '/')
|
||||
{
|
||||
memmove(old_name, old_name+1, strlen(old_name));
|
||||
|
|
@ -300,7 +299,7 @@ STATIC mp_obj_t spiffs_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t pa
|
|||
strcat(old_name, old_path);
|
||||
}
|
||||
i = 0;
|
||||
char* new_name = &new_path[i];
|
||||
char* new_name = (char*)&new_path[i];
|
||||
if(new_path[0] == '.' && new_path[1] == '/')
|
||||
{
|
||||
memmove(new_name, new_name+1, strlen(new_name));
|
||||
|
|
@ -391,7 +390,7 @@ STATIC mp_obj_t spiffs_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) {
|
|||
fno.type = SPIFFS_TYPE_DIR;
|
||||
} else {
|
||||
int res = 0;
|
||||
char* open_name = &path[res];
|
||||
char* open_name = (char*)&path[res];
|
||||
if(path[0] == '.' && path[1] == '/')
|
||||
{
|
||||
memmove(open_name, open_name+1, strlen(open_name));
|
||||
|
|
@ -436,7 +435,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(spiffs_vfs_stat_obj, spiffs_vfs_stat);
|
|||
// Get the status of a VFS.
|
||||
STATIC mp_obj_t spiffs_vfs_statvfs(mp_obj_t vfs_in, mp_obj_t path_in) {
|
||||
|
||||
const char* path = mp_obj_str_get_str(path_in);
|
||||
// const char* path = mp_obj_str_get_str(path_in);
|
||||
|
||||
spiffs_user_mount_t *self = MP_OBJ_TO_PTR(vfs_in);
|
||||
(void)path_in;
|
||||
|
|
|
|||
|
|
@ -198,8 +198,7 @@ STATIC const mp_arg_t file_open_args[] = {
|
|||
|
||||
STATIC mp_obj_t file_open(spiffs_user_mount_t *vfs, const mp_obj_type_t *type, mp_arg_val_t *args) {
|
||||
const char* file_name = mp_obj_str_get_str(args[0].u_obj);
|
||||
int i = 0;
|
||||
char* open_name = file_name;
|
||||
char* open_name = (char*)file_name;
|
||||
if(open_name[0] == '.' && open_name[1] == '/')
|
||||
{
|
||||
memmove(open_name, open_name+1, strlen(open_name));
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) {
|
|||
if (n_args == 0 || args[0] == mp_const_none) {
|
||||
uint32_t year = 0;uint32_t mon = 0;uint32_t mday = 0;uint32_t hour = 0;
|
||||
uint32_t min = 0;uint32_t sec = 0;uint32_t wday = 0;uint32_t yday = 0;
|
||||
rtc_timer_get(&year,&mon,&mday,&hour,&min,&sec);
|
||||
rtc_timer_get((int*)&year, (int*)&mon, (int*)&mday, (int*)&hour, (int*)&min, (int*)&sec);
|
||||
wday = rtc_get_wday(year,mon,mday);
|
||||
yday = rtc_get_yday(year,mon,mday);
|
||||
tm.tm_year = (uint16_t)year;
|
||||
|
|
@ -117,11 +117,10 @@ STATIC mp_obj_t time_mktime(mp_obj_t tuple) {
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(time_mktime_obj, time_mktime);
|
||||
|
||||
STATIC mp_obj_t time_time(void) {
|
||||
timeutils_struct_time_t tm;
|
||||
mp_uint_t seconds;
|
||||
volatile int year = 0, mon = 0, mday = 0, hour = 0;
|
||||
volatile int min = 0, sec = 0;
|
||||
rtc_timer_get(&year,&mon,&mday,&hour,&min,&sec);
|
||||
rtc_timer_get((int*)&year, (int*)&mon, (int*)&mday, (int*)&hour, (int*)&min, (int*)&sec);
|
||||
seconds = timeutils_seconds_since_1970(year,mon, mday, hour, min,sec);
|
||||
return mp_obj_new_int_from_uint(seconds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,12 @@ extern "C"
|
|||
{
|
||||
#endif
|
||||
|
||||
#ifndef INT_MIN
|
||||
#define INT_MIN (-1 - 0x7fffffff)
|
||||
#endif
|
||||
#ifndef INT_MAX
|
||||
#define INT_MAX 0x7fffffff
|
||||
#endif
|
||||
|
||||
struct median_filter_t
|
||||
{
|
||||
|
|
|
|||
|
|
@ -160,13 +160,12 @@ static void lcd_draw_cross(int x, int y, uint16_t color)
|
|||
|
||||
static void cairo_draw_string(int x, int y, const char *title)
|
||||
{
|
||||
lcd_draw_string(x, y, title, WHITE);
|
||||
lcd_draw_string(x, y, (char*)title, WHITE);
|
||||
}
|
||||
|
||||
int do_tscal(struct ts_ns2009_pdata_t *ts_ns2009_pdata, int width, int height, int* c)
|
||||
{
|
||||
struct tscal_t cal;
|
||||
lcd_ctl_t lcd_ctl;
|
||||
|
||||
// char buffer[256];
|
||||
int index;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ static const mp_obj_type_t py_video_avi_type = {
|
|||
};
|
||||
|
||||
|
||||
mp_obj_t py_video_open(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
mp_obj_t py_video_open(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
const char *path = mp_obj_str_get_str(args[0]);
|
||||
GET_STR_LEN(args[0], len);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ int video_play_avi_init(const char* path, avi_t* avi)
|
|||
{
|
||||
|
||||
int err;
|
||||
uint32_t offset;
|
||||
// uint32_t offset;
|
||||
|
||||
video_play_avi_destroy(avi);
|
||||
|
||||
|
|
@ -103,7 +103,6 @@ video_status_t video_play_avi(avi_t* avi)
|
|||
.y = 0
|
||||
};
|
||||
int status = VIDEO_STATUS_PLAYING;
|
||||
uint8_t tmp_u8;
|
||||
uint8_t* pbuf;
|
||||
|
||||
if(avi->status != VIDEO_STATUS_RESUME && avi->status != VIDEO_STATUS_PLAYING && avi->status != VIDEO_STATUS_PLAY_END)
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ int video_hal_display(image_t* img, video_display_roi_t img_roi)
|
|||
int is_cut;
|
||||
uint16_t lcd_width = lcd_get_width();
|
||||
uint16_t lcd_height = lcd_get_height();
|
||||
int l_pad = 0, r_pad = 0;
|
||||
int t_pad = 0, b_pad = 0;
|
||||
int l_pad = 0;//, r_pad = 0;
|
||||
int t_pad = 0;//, b_pad = 0;
|
||||
|
||||
if (img_roi.w > lcd_width) {
|
||||
int adjust = img_roi.w - lcd_width;
|
||||
|
|
@ -27,7 +27,7 @@ int video_hal_display(image_t* img, video_display_roi_t img_roi)
|
|||
} else if (img_roi.w < lcd_width) {
|
||||
int adjust = lcd_width - img_roi.w;
|
||||
l_pad = adjust / 2;
|
||||
r_pad = (adjust + 1) / 2;
|
||||
// r_pad = (adjust + 1) / 2;
|
||||
}
|
||||
if (img_roi.h > lcd_height) {
|
||||
int adjust = img_roi.h - lcd_height;
|
||||
|
|
@ -36,7 +36,7 @@ int video_hal_display(image_t* img, video_display_roi_t img_roi)
|
|||
} else if (img_roi.h < lcd_height) {
|
||||
int adjust = lcd_height - img_roi.h;
|
||||
t_pad = adjust / 2;
|
||||
b_pad = (adjust + 1) / 2;
|
||||
// b_pad = (adjust + 1) / 2;
|
||||
}
|
||||
|
||||
is_cut =((img_roi.x != 0) || (img_roi.y != 0) || \
|
||||
|
|
@ -97,7 +97,7 @@ int video_hal_audio_init(avi_t* avi)
|
|||
/*TRIGGER_LEVEL_1*/TRIGGER_LEVEL_4,
|
||||
RIGHT_JUSTIFYING_MODE
|
||||
);
|
||||
uint32_t ret = i2s_set_sample_rate(I2S_DEVICE_0, avi->audio_sample_rate);//TODO: /2 ?
|
||||
/* uint32_t ret = */i2s_set_sample_rate(I2S_DEVICE_0, avi->audio_sample_rate);//TODO: /2 ?
|
||||
|
||||
dmac_set_irq(DMAC_CHANNEL3, on_irq_dma3, (void*)avi, 1);
|
||||
avi->audio_buf[0].buf = (uint8_t*)malloc(avi->audio_buf_size+8);
|
||||
|
|
|
|||
Loading…
Reference in a new issue