月度归档:2023年11月

ARDUINO NANO PICO RP2040 OPENMV

果然有坑,之前找的OPENMV官方固件,只打包了ARDUNIO的RP2040的OPENMV,pico版本的没有打包,不会打包的渣渣看了pico的配置,怎么都没法调试,再去试试看吧:

好在openmv的配置文件都是 omv_boardconfig.h 这个。

建议使用Ultimate PICO 16MB的FLASH RP2040

好吧和之前固件一样,只有QQVGA和RGB565,连jpg保存,二维码识别都没有,只有人脸和眼睛识别·。最多只能做一个RGB565 的QQVGA的串流模块,相关代码:

import sensor,image
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
eyes_cascade = image.HaarCascade("eye", stages=24)
face_cascade = image.HaarCascade("frontalface", stage = 25)

def face():
    img = sensor.snapshot()
    objects = img.find_features(face_cascade, threshold=0.5, scale_factor=1.25)
    print(objects)

def eye():
    img = sensor.snapshot()
     objects = img.find_features(eyes_cascade, threshold=0.5, scale=1.5)
     print(objects)

/*
 * This file is part of the OpenMV project.
 *
 * Copyright (c) 2013-2021 Ibrahim Abdelkader <iabdalkader@openmv.io>
 * Copyright (c) 2013-2021 Kwabena W. Agyeman <kwagyeman@openmv.io>
 *
 * This work is licensed under the MIT license, see the file LICENSE for details.
 *
 * Board configuration and pin definitions.
 */
#ifndef __OMV_BOARDCONFIG_H__
#define __OMV_BOARDCONFIG_H__

// Architecture info
#define OMV_ARCH_STR               "PICO M0" // 33 chars max
#define OMV_BOARD_TYPE             "PICO"

#ifndef LINKER_SCRIPT
extern unsigned char *OMV_UNIQUE_ID_ADDR;   // Unique address.
#endif
#define OMV_UNIQUE_ID_SIZE         2        // Unique ID size in words.
#define OMV_UNIQUE_ID_OFFSET       4        // Bytes offset for multi-word UIDs.


#define OMV_XCLK_MCO               (0U)
#define OMV_XCLK_TIM               (1U)

// Sensor external clock source.
#define OMV_XCLK_SOURCE            (OMV_XCLK_TIM)

// Sensor external clock timer frequency.
// TODO Not actually used right now, frequency is hardcoded.
#define OMV_XCLK_FREQUENCY         (12500000)

// Enable hardware JPEG
#define OMV_HARDWARE_JPEG          (0)

// Enable sensor drivers
#define OMV_ENABLE_OV2640          (0)
#define OMV_ENABLE_OV5640          (0)
#define OMV_ENABLE_OV7670          (1)
#define OMV_ENABLE_OV7690          (0)
#define OMV_ENABLE_OV7725          (0)
#define OMV_ENABLE_OV9650          (0)
#define OMV_ENABLE_MT9V0XX         (0)
#define OMV_ENABLE_LEPTON          (0)
#define OMV_ENABLE_HM01B0          (0)

// Set which OV767x sensor is used
#define OMV_OV7670_VERSION         (70)

// OV7670 clock divider
#define OMV_OV7670_CLKRC           (0x00)

// FIR Module
#define OMV_ENABLE_FIR_MLX90621    (0)
#define OMV_ENABLE_FIR_MLX90640    (0)
#define OMV_ENABLE_FIR_MLX90641    (0)
#define OMV_ENABLE_FIR_AMG8833     (1)
#define OMV_ENABLE_FIR_LEPTON      (0)

// Enable sensor features
#define OMV_ENABLE_OV5640_AF       (0)

// Enable WiFi debug
#define OMV_ENABLE_WIFIDBG         (0)
#define OMV_ENABLE_TUSBDBG         (1)
#define OMV_TUSBDBG_PACKET         (64)

// Enable self-tests on first boot
#define OMV_ENABLE_SELFTEST        (0)

// If buffer size is bigger than this threshold, the quality is reduced.
// This is only used for JPEG images sent to the IDE not normal compression.
#define JPEG_QUALITY_THRESH        (160 * 120)

// Low and high JPEG QS.
#define JPEG_QUALITY_LOW           35
#define JPEG_QUALITY_HIGH          60

// FB Heap Block Size
#define OMV_UMM_BLOCK_SIZE         16

// Core VBAT for selftests
#define OMV_CORE_VBAT              "3.3"

// USB IRQn.
#define OMV_USB_IRQN               (USBCTRL_IRQ_IRQn)
#define OMV_USB1_IRQ_HANDLER       (USBD_IRQHandler)

// Linker script constants (see the linker script template port/x.ld.S).
#define OMV_FB_MEMORY              RAM // Framebuffer, fb_alloc
#define OMV_MAIN_MEMORY            RAM // data, bss and heap memory
#define OMV_STACK_MEMORY           RAM // stack memory

#define OMV_FB_SIZE                (100K) // FB memory
#define OMV_FB_ALLOC_SIZE          (16K) // minimum fb alloc size
#define OMV_STACK_SIZE             (16K)
#define OMV_HEAP_SIZE              (60 * 1024) // MicroPython's heap
#define OMV_JPEG_BUF_SIZE          (20 * 1024) // IDE JPEG buffer (header + data).

// GP LED
#define LED_PIN                    (6)

// FIR I2C
#define FIR_I2C_ID                 (0)
#define FIR_I2C_SCL_PIN            (13)
#define FIR_I2C_SDA_PIN            (12)
#define FIR_I2C_SPEED              (OMV_I2C_SPEED_FULL)

// ISC I2C
#define ISC_I2C_ID                 (0)
#define ISC_I2C_SCL_PIN            (13)
#define ISC_I2C_SDA_PIN            (12)
#define ISC_I2C_SPEED              (OMV_I2C_SPEED_STANDARD)

// I2C0
#define I2C0_ID                    (0)
#define I2C0_SCL_PIN               (13)
#define I2C0_SDA_PIN               (12)
#define I2C0_SPEED                 (OMV_I2C_SPEED_FULL)

// I2C1 该处为摄像头SDA和SCL 建设设置
#define I2C1_ID                    (1)
#define I2C1_SCL_PIN               (27)
#define I2C1_SDA_PIN               (26)
#define I2C1_SPEED                 (OMV_I2C_SPEED_FULL)

// LCD config.
#define LCD_SPI                    (spi0)
#define LCD_CS_PIN                 (5)
#define LCD_MOSI_PIN               (7)
#define LCD_SCLK_PIN               (6)
#define LCD_RST_PIN                (4)
#define LCD_RS_PIN                 (0)

// AUDIO config.
#define PDM_PIO                    (pio1)
#define PDM_SM                     (0)
#define PDM_DMA                    (1)
#define PDM_DMA_IRQ                (DMA_IRQ_1)
#define PDM_DMA_CHANNEL            (0)

#define PDM_CLK_PIN                (23)
#define PDM_DIN_PIN                (22)


#此处和PICO不一样,但是好在都是OV7670摄像头
#下面为设置代码
// DCMI config.
#define DCMI_PIO                   (pio0)
#define DCMI_SM                    (0)
#define DCMI_DMA                   (0)
#define DCMI_DMA_IRQ               (DMA_IRQ_0)
#define DCMI_DMA_CHANNEL           (0)

#define DCMI_POWER_PIN             (0)
#define DCMI_RESET_PIN             (1)

#define DCMI_D0_PIN                (15)
#define DCMI_D1_PIN                (16)
#define DCMI_D2_PIN                (17)
#define DCMI_D3_PIN                (18)
#define DCMI_D4_PIN                (19)
#define DCMI_D5_PIN                (20)
#define DCMI_D6_PIN                (21)
#define DCMI_D7_PIN                (25) // MSB is read separately.

#define DCMI_XCLK_PIN              (28)

// Must match the pins defined in dcmi.pio.
#define DCMI_PXCLK_PIN             (29)
#define DCMI_HSYNC_PIN             (27)
#define DCMI_VSYNC_PIN             (26)

#endif //__OMV_BOARDCONFIG_H__

PICO OPENMV引脚设置

/*
 * This file is part of the OpenMV project.
 *
 * Copyright (c) 2013-2021 Ibrahim Abdelkader <iabdalkader@openmv.io>
 * Copyright (c) 2013-2021 Kwabena W. Agyeman <kwagyeman@openmv.io>
 *
 * This work is licensed under the MIT license, see the file LICENSE for details.
 *
 * Board configuration and pin definitions.
 */
#ifndef __OMV_BOARDCONFIG_H__
#define __OMV_BOARDCONFIG_H__

// Architecture info
#define OMV_ARCH_STR               "PICO M0" // 33 chars max
#define OMV_BOARD_TYPE             "PICO"

#ifndef LINKER_SCRIPT
extern unsigned char *OMV_UNIQUE_ID_ADDR;   // Unique ID address.
#endif
#define OMV_UNIQUE_ID_SIZE         2        // Unique ID size in words.
#define OMV_UNIQUE_ID_OFFSET       4        // Bytes offset for multi-word UIDs.

#define OMV_XCLK_MCO               (0U)
#define OMV_XCLK_TIM               (1U)

// Sensor external clock source.
#define OMV_XCLK_SOURCE            (OMV_XCLK_TIM)

// Sensor external clock timer frequency.
// TODO Not actually used right now, frequency is hardcoded.
#define OMV_XCLK_FREQUENCY         (12500000)

// Enable hardware JPEG
#define OMV_HARDWARE_JPEG          (0)

// Enable sensor drivers
#define OMV_ENABLE_OV2640          (0)
#define OMV_ENABLE_OV5640          (0)
#define OMV_ENABLE_OV7670          (1)
#define OMV_ENABLE_OV7690          (0)
#define OMV_ENABLE_OV7725          (0)
#define OMV_ENABLE_OV9650          (0)
#define OMV_ENABLE_MT9V0XX         (0)
#define OMV_ENABLE_LEPTON          (0)
#define OMV_ENABLE_HM01B0          (0)

// Set which OV767x sensor is used
#define OMV_OV7670_VERSION         (70)

// OV7670 clock divider
#define OMV_OV7670_CLKRC           (0x00)

// FIR Module
#define OMV_ENABLE_FIR_MLX90621    (0)
#define OMV_ENABLE_FIR_MLX90640    (0)
#define OMV_ENABLE_FIR_MLX90641    (0)
#define OMV_ENABLE_FIR_AMG8833     (1)
#define OMV_ENABLE_FIR_LEPTON      (0)

// Enable sensor features
#define OMV_ENABLE_OV5640_AF       (0)

// Enable WiFi debug
#define OMV_ENABLE_WIFIDBG         (0)

// Enable self-tests on first boot
#define OMV_ENABLE_SELFTEST        (0)

// If buffer size is bigger than this threshold, the quality is reduced.
// This is only used for JPEG images sent to the IDE not normal compression.
#define JPEG_QUALITY_THRESH        (160 * 120)

// Low and high JPEG QS.
#define JPEG_QUALITY_LOW           35
#define JPEG_QUALITY_HIGH          60

// FB Heap Block Size
#define OMV_UMM_BLOCK_SIZE         16

// Core VBAT for selftests
#define OMV_CORE_VBAT              "3.3"

// USB IRQn.
#define OMV_USB_IRQN               (USBCTRL_IRQ_IRQn)
#define OMV_USB1_IRQ_HANDLER       (USBD_IRQHandler)

// Linker script constants (see the linker script template port/x.ld.S).
#define OMV_FB_MEMORY              RAM // Framebuffer, fb_alloc
#define OMV_MAIN_MEMORY            RAM // data, bss and heap memory
#define OMV_STACK_MEMORY           RAM // stack memory

#define OMV_FB_SIZE                (151K)   // FB memory: header + QVGA/GS image
#define OMV_FB_ALLOC_SIZE          (12K)    // minimum fb alloc size
#define OMV_STACK_SIZE             (8K)
#define OMV_HEAP_SIZE              (32 * 1024) // MicroPython's heap
#define OMV_JPEG_BUF_SIZE          (20 * 1024) // IDE JPEG buffer (header + data).

// GP LED
#define LED_PIN                    (25)

// FIR I2C
#define FIR_I2C_ID                 (0)
#define FIR_I2C_SCL_PIN            (21)
#define FIR_I2C_SDA_PIN            (20)
#define FIR_I2C_SPEED              (OMV_I2C_SPEED_FULL)

// ISC I2C
#define ISC_I2C_ID                 (1)
#define ISC_I2C_SCL_PIN            (15)
#define ISC_I2C_SDA_PIN            (14)
#define ISC_I2C_SPEED              (OMV_I2C_SPEED_STANDARD)

// I2C0
#define I2C0_ID                    (0)
#define I2C0_SCL_PIN               (21)
#define I2C0_SDA_PIN               (20)
#define I2C0_SPEED                 (OMV_I2C_SPEED_FULL)

// I2C1
#define I2C1_ID                    (1)
#define I2C1_SCL_PIN               (15)
#define I2C1_SDA_PIN               (14)
#define I2C1_SPEED                 (OMV_I2C_SPEED_FULL)

#define LCD_SPI                    (spi0)
#define LCD_CS_PIN                 (17)
#define LCD_MOSI_PIN               (19)
#define LCD_SCLK_PIN               (18)
#define LCD_RST_PIN                (20)
#define LCD_RS_PIN                 (21)

// DCMI config.
#define DCMI_PIO                   (pio0)
#define DCMI_SM                    (0)
#define DCMI_DMA                   (0)
#define DCMI_DMA_IRQ               (DMA_IRQ_0)
#define DCMI_DMA_CHANNEL           (0)

#define DCMI_POWER_PIN             (0)
#define DCMI_RESET_PIN             (1)

#define DCMI_D0_PIN                (2)
#define DCMI_D1_PIN                (3)
#define DCMI_D2_PIN                (4)
#define DCMI_D3_PIN                (5)
#define DCMI_D4_PIN                (6)
#define DCMI_D5_PIN                (7)
#define DCMI_D6_PIN                (8)
#define DCMI_D7_PIN                (9)

#define DCMI_XCLK_PIN              (10)

// Must match the pins defined in dcmi.pio.
#define DCMI_PXCLK_PIN             (11)
#define DCMI_HSYNC_PIN             (12)
#define DCMI_VSYNC_PIN             (13)

#endif //__OMV_BOARDCONFIG_H__

和之前大佬分享的那个接线图。

大佬的代码说明

MCU股票

1联网

2 网页访问 (加载已经保存的股票信息) 展示

3 输入股票代码

4 返回信息

5 选择信息,发送给板子保存 添加

6 删除信息

MPY

定时获取信息

保存到每日的JSON

显示当前信息

HTML访问股票API

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</head>
<body>
    <div class="container">
        添加信息
        <div class="row" id="gpp">

        </div>
        <div class="row">
            <div class="col-md-8">
                <DIV class="input-group">
                    <input  class="form-control" type="number" id="code">
                    <div class="input-group-btn">
                        <button class="btn btn-info" id="search">查询</button>
                    </div>
                </DIV>
            </div>
        </div>
    </div>
    <script>
        function showLine(gpData){
            var div=$("<div></div>");
            var h2=$("<h2></h2>");
            var span_1=$("<span></span>");
            var small_code=$("<small></small>");
            var span_2=$("<span></span>");
            span_1.text(gpData[1]);
            small_code.text(gpData[2]);
            span_2.text(gpData[3]);
            h2.append(span_1);
            h2.append(small_code);
            h2.append(span_2);
            $("#gpp").append(h2);
        }
        function ajax(url){
            $.ajax({
                url:url,
                success:function(data){
                    if(data.length>50){
                        sData=data.split("~");
                        showLine(sData);
                    }
                }

            })
        }

        $("#search").click(function(){
            var code=$("#code").val();
            var code_sh="sh"+code;
            var code_sz="sz"+code;
            $("#gpp").html("");
            ajax("http://qt.gtimg.cn/q="+code_sz);
            ajax("http://qt.gtimg.cn/q="+code_sh)
        })
    </script>

</body>
</html>