MicroPython使用过程中的小问题

错误1:ValueError: invalid literal for int() with base 10

  • int(str)函数将符合整数的规定的字符串转换成int型的
  • float(str)函数将符合浮点型的规定的字符串转换成float型的
  • str(num)将整数、浮点型转换成字符串型的 

错误2:持续更新......

函数方法:

object <Display object at 3ffe7bb0> is of type Display
  RGB -- True
  PURPLE -- 4224
  _setwindowloc -- <function _setwindowloc at 0x3ffe5b90>
  draw_filledRectangle -- <function draw_filledRectangle at 0x3ffe6130>
  DARKGREEN -- 4
  draw_image -- <function draw_image at 0x3ffe5c90>
  show -- <function show at 0x3ffe5e90>
  display_on -- <function display_on at 0x3ffe5d70>
  __qualname__ -- Display
  letter -- <function letter at 0x3ffe61d0>
  is_off_grid -- <function is_off_grid at 0x3ffe5be0>
  INDIGO -- 6159
  circle -- <function circle at 0x3ffe60d0>
  BGR -- False
  load_sprite -- <function load_sprite at 0x3ffe5cf0>
  draw_filledCircle -- <function draw_filledCircle at 0x3ffe60f0>
  fill_ellipse -- <function fill_ellipse at 0x3ffe6120>
  lines -- <function lines at 0x3ffe5de0>
  draw_hline -- <function draw_hline at 0x3ffe5da0>
  __module__ -- ST7735
  BLUE -- 7936
  write_cmd -- <function write_cmd at 0x3ffe5bb0>
  draw_filledPolygon -- <function draw_filledPolygon at 0x3ffe6150>
  draw_pixel -- <function draw_pixel at 0x3ffe5d90>
  FUCHSIA -- 8184
  LIGHT_CORAL -- 4348
  RED -- 4088
  _draw -- <function _draw at 0x3ffe5b70>
  _copy -- <function _copy at 0x3ffe5b60>
  OLIVE -- 132
  YELLOW -- 57599
  cleanup -- <function cleanup at 0x3ffe5d80>
  GREEN -- 57351
  write_data -- <function write_data at 0x3ffe5bc0>
  CYAN -- 65415
  MAROON -- 128
  DODGER_BLUE -- 7940
  draw_vline -- <function draw_vline at 0x3ffe5db0>
  __init__ -- <closure>
  draw_filledEllipse -- <function draw_filledEllipse at 0x3ffe6110>
  rotation -- <function rotation at 0x3ffe5d50>
  draw_text -- <function draw_text at 0x3ffe5e20>
  clear -- <function clear at 0x3ffe5c50>
  BLACK -- 0
  text -- <function text at 0x3ffe5e60>
  polygon -- <function polygon at 0x3ffe6090>
  MADCTL -- 54
  DEEP_PINK -- 4344
  setMADCTL -- <function setMADCTL at 0x3ffe5d40>
  draw_sprite -- <function draw_sprite at 0x3ffe5d00>
  display_off -- <function display_off at 0x3ffe5d60>
  NAVY -- 4096
  WHITE -- 65535
  set_rgb -- <function set_rgb at 0x3ffe5d20>
  CHARTREUSE -- 57479
  draw_circle -- <function draw_circle at 0x3ffe60c0>
  _pushcolor -- <function _pushcolor at 0x3ffe5ba0>
  draw_lines -- <function draw_lines at 0x3ffe5dd0>
  draw_letter -- <function draw_letter at 0x3ffe6190>
  _setColor -- <function _setColor at 0x3ffe5b50>
  LIGHT_YELLOW -- 61695
  size -- <function size at 0x3ffe5bd0>
  PINK -- 8188
  AQUA -- 65287
  TEAL -- 4100
  draw_polygon -- <function draw_polygon at 0x3ffe6060>
  draw_rectangle -- <function draw_rectangle at 0x3ffe5df0>
  _setwindowpoint -- <function _setwindowpoint at 0x3ffe5b80>
  draw_line -- <function draw_line at 0x3ffe5dc0>
  LIGHT_SLATE_BLUE -- 8068
  SPRING_GREEN -- 61447
  ORANGE -- 252
  LIGHT_GREEN -- 61575
  draw_ellipse -- <function draw_ellipse at 0x3ffe60e0>
  fill_circle -- <function fill_circle at 0x3ffe6100>
  image -- <function image at 0x3ffe5cd0>
  _getletter -- <function _getletter at 0x3ffe6170>
  block -- <function block at 0x3ffe5c30>
>>> 

 

test:

def test():
    """Test code."""
    display=Display(spi,SPI_CS,SPI_DC)
    print('display started')

    display.clear(color565(64, 0, 255))
    sleep(1)

    display.clear()

    display.draw_hline(10, 127, 63, color565(255, 0, 255))
    sleep(1)

    display.draw_vline(10, 0, 127, color565(0, 255, 255))
    sleep(1)

    display.draw_filledRectangle(23, 50, 30, 75, color565(255, 255, 255))
    sleep(1)

    display.draw_hline(0, 0, 127, color565(255, 0, 0))
    sleep(1)

    display.draw_line(127, 0, 64, 127, color565(255, 255, 0))
    sleep(2)

    display.clear()

    coords = [[0, 63], [78, 80], [122, 92], [50, 50], [78, 15], [0, 63]]
    display.draw_lines(coords, color565(0, 255, 255))
    sleep(1)

    display.clear()
    display.draw_filledPolygon(7, 63, 63, 50, color565(0, 255, 0))
    sleep(1)

    display.draw_filledRectangle(0, 0, 15, 127, color565(255, 0, 0))
    sleep(1)

    display.clear()

    display.draw_filledRectangle(0, 0, 63, 63, color565(128, 128, 255))
    sleep(1)

    display.draw_rectangle(0, 64, 63, 63, color565(255, 0, 255))
    sleep(1)

    display.draw_filledRectangle(64, 0, 63, 63, color565(128, 0, 255))
    sleep(1)

    display.draw_polygon(3, 96, 96, 30, color565(0, 64, 255),
                         rotate=15)
    sleep(3)

    display.clear()

    display.draw_filledCircle(32, 32, 30, color565(0, 255, 0))
    sleep(1)

    display.draw_circle(32, 96, 30, color565(0, 0, 255))
    sleep(1)

    display.draw_filledEllipse(96, 32, 30, 16, color565(255, 0, 0))
    sleep(1)

    display.draw_ellipse(96, 96, 16, 30, color565(255, 255, 0))

    sleep(5)
    display.cleanup()

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
2022 / 01/ 30: 新版esptool 刷micropython固件指令不是 esptool.py cmd... 而是 esptool cmd... 即可;另外rshell 在 >= python 3.10 的时候出错解决方法可以查看:  已于2022年发布的: 第二章:修复rshell在python3.10出错 免费内容: https://edu.csdn.net/course/detail/29666 micropython语法和python3一样,编写起来非常方便。如果你快速入门单片机玩物联网而且像轻松实现各种功能,那绝力推荐使用micropython。方便易懂易学。 同时如果你懂C语音,也可以用C写好函数并编译进micropython固件里然后进入micropython调用(非必须)。 能通过WIFI联网(2.1章),也能通过sim卡使用2G/3G/4G/5G联网(4.5章)。 为实现语音控制,本教程会教大家使用tensorflow利用神经网络训练自己的语音模型并应用。为实现通过网页控制,本教程会教大家linux(debian10 nginx->uwsgi->python3->postgresql)网站前后台入门。为记录单片机传输过来的数据, 本教程会教大家入门数据库。  本教程会通过通俗易懂的比喻来讲解各种原理与思路,并手把手编写程序来实现各项功能。 本教程micropython版本是 2019年6月发布的1.11; 更多内容请看视频列表。  学习这门课程之前你需要至少掌握: 1: python3基础(变量, 循环, 函数, 常用库, 常用方法)。 本视频使用到的零件与淘宝上大致价格:     1: 超声波传感器(3)     2: MAX9814麦克风放大模块(8)     3: DHT22(15)     4: LED(0.1)     5: 8路5V低电平触发继电器(12)     6: HX1838红外接收模块(2)     7:红外发射管(0.1),HX1838红外接收板(1)     other: 电表, 排线, 面包板(2)*2,ESP32(28)  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值