导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. yqzp
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    yqzp

    @yqzp

    0
    声望
    2
    楼层
    480
    资料浏览
    0
    粉丝
    0
    关注
    注册时间 最后登录
    网站 blog.csdn.net/liluan_sama

    yqzp 关注

    yqzp 发布的帖子

    • RE: 如何利用NRF24L01实现OPENMV4与主控STM32F1系列单片机的无线通信?

      https://blog.csdn.net/liluan_sama/article/details/98520128

      发布在 OpenMV Cam
      yqzp
    • 想用自己的0.96寸OLED显示东西,不想用拓展板之类的,求有没有解决办法?

      自己写了半天的配置,结果OLED没反应……查帖子也没人解决啊只说有LCD!
      希望有大佬解释一下原因

      # SPI Control   0.96 OLED未完
      
      import sensor, image, time
      from pyb import Pin, SPI
      
      gram = [ [0] * 8 for i in range(128)]
      cs  = Pin("P3", Pin.OUT_OD)
      rst = Pin("P7", Pin.OUT_PP)
      rs  = Pin("P8", Pin.OUT_PP)
      # The hardware SPI bus for your OpenMV Cam is always SPI bus 2.
      spi = SPI(2, SPI.MASTER, baudrate=int(1000000000/66), polarity=0, phase=0)
      
      def write_command_byte(c):
          cs.low()
          rs.low()
          spi.send(c)
          cs.high()
      
      def write_data_byte(c):
          cs.low()
          rs.high()
          spi.send(c)
          cs.high()
      
      def write_command(c, *data):
          write_command_byte(c)
          if data:
              for d in data: write_data_byte(d)
      
      def write_image(img):
          cs.low()
          rs.high()
          spi.send(img)
          cs.high()
      def write_string(*s):
          if s:
              for d in s: write_data_byte(d)
      # Reset the OLED.
      def reset_oled():
          rst.low()
          time.sleep(100)
          rst.high()
          time.sleep(100)
      
      # 开启OLED显示
      def display_on():
          write_command_byte(0x8D)
          time.sleep(120)
          write_command_byte(0x14)
          time.sleep(120)
          write_command_byte(0xAF) # Sleep Exit
          time.sleep(120)
      # 关闭OLED显示
      def display_off():
          write_command_byte(0x8D)
          time.sleep(120)
          write_command_byte(0x10)
          time.sleep(120)
          write_command_byte(0xAE) # Sleep
          time.sleep(120)
      
      #更新显存到LCD
      def OLED_Refresh_Gram():
          for i in range(0,8):
              write_command_byte (0xb0+i)    #设置页地址(0~7)
              write_command_byte (0x00)      #设置显示位置—列低地址
              write_command_byte (0x10)      #设置显示位置—列高地址
              for n in range(0,128):
                  write_string(gram[n][i])
      
      # 画点函数
      def draw_point(x,y,t):
          if(x>127|y>63):return;
          temp = 1<<(7-(y%8))
          if(t):gram[x][7-y//8]|=temp
          else:gram[x][7-y//8]&=~temp
      # 填充函数x1<=x2;y1<=y2 0<=x1<=127 0<=y1<=63
      def OLED_Fill(x1,y1,x2,y2,dot) :
          for x in range(x1,x2):
              for y in range(y1,y2):
                  draw_point(x,y,dot)
          OLED_Refresh_Gram()
      reset_oled()
      time.sleep(120)
      display_on()
      time.sleep(120)
      
      while(True):
          OLED_Fill(20,5,108,58,1)
          time.sleep(120)
      
      
      发布在 OpenMV Cam
      yqzp