@18852935127 在 Openmv通讯问题,两个模块不能通讯,但是stm32或openmv单独与电脑可以通讯。 中说:
sensor.skip_frames(30)
我这面试验了一下,还是没有反应啊
@18852935127 在 Openmv通讯问题,两个模块不能通讯,但是stm32或openmv单独与电脑可以通讯。 中说:
sensor.skip_frames(30)
我这面试验了一下,还是没有反应啊
import sensor, image,time
import json
from pyb import UART
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False) # must turn this off to prevent image washout...
clock = time.clock()
uart = UART(3, 115200)
#uart.init(19200, bits=8, parity=None, stop=1) #8位数据位,无校验位,1位停止位
while(True):
clock.tick()
img = sensor.snapshot()
img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens.
for code in img.find_qrcodes():
img.draw_rectangle(code.rect(), color = (255, 0, 0))
message = code.payload()
uart.write(message)
print(code)
else:
print("not found!")
#if message == "abc" :
# num = 1
# uart.write(num)
# print(message)
# time.sleep(1000)
#if message == "def" :
# uart.write('2')
# time.sleep(1000)
```stm32代码
void LED_RED(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE); //使能PB,PE端口时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; //LED0-->PB.5 端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度为50MHz
GPIO_Init(GPIOE, &GPIO_InitStructure); //初始化GPIO
GPIO_SetBits(GPIOB,GPIO_Pin_5); //PE.5 输出高
GPIO_ResetBits(GPIOB,GPIO_Pin_5);
}
void USART1_IRQHandler(void)
{
u8 res;
if(USART_GetITStatus(USART1,USART_IT_RXNE))
{
res= USART_ReceiveData(USART1);
USART_SendData(USART1,res); //huan hang
if(res=='1')
{
res='a';
USART_SendData(USART1,res);
LED_RED(); //liang
Delay(5000000);
}
if(res=='2')
{
res='b';
USART_SendData(USART1,res);
LED_CLOSE(); //mie
Delay(5000000);
}
// if(res=='3')
// {
// res='c';
// USART_SendData(USART1,res);
// }
}
}
int main(void)
{
LED_CLOSE();
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
My_USART1_Init();
USART1_IRQHandler();
LED_CLOSE();
while(1);
}