各位Maker朋友们，大家好！今天给大家分享一个我最近在Beetle-RP2350上捣鼓出来的小玩意儿——一个简单却充满复古情怀的方块躲避游戏。借助RP2350的强大性能和灵活的IO，再配上一块小巧的OLED屏幕，随时随地都能体验一把掌上游戏的乐趣！硬件连接这次用到的硬件很简单：RP2350开发板0.96寸OLED屏幕(SSD1306)：小巧精致，用来显示游戏画面刚刚好。两个按键：控制玩家左右移动，手感清脆。温湿度传感器 (DHT11，可选)：顺手加了个环境信息显示，纯属Bonus连接方式如下，一看就明白：GP5 ---- SCL(OLED)GP4 ---- SDA(OLED)GP9 ---- K1(左)GP26 --- K2(右)GP8 ---- Data (DHT11)温馨提示：所有模块都采用3.3V供电。⚡按键另一端接地，代码里启用了内部上拉电阻，省去了外部电阻的麻烦。软件实现基于MicroPython进行开发，丰富的库支持让开发过程非常顺畅。主要实现了以下功能：玩家控制：通过两个按键控制屏幕底部小方块的左右移动。障碍物生成与移动：从屏幕顶部随机生成方块并向下移动，速度可控。碰撞检测：实时检测玩家是否与下落的障碍物发生碰撞。得分系统：成功躲避一个障碍物，得分+1。游戏结束与重置：碰撞后游戏结束，显示最终得分，等待一段时间后自动重置。 Game Over!OLED屏幕显示：清晰地显示游戏画面、得分以及（可选的）温湿度信息。代码我就不在这里赘述了，已经整理好放在附件里了，大家可以直接下载到Beetle-RP2350上运行体验 里面有详细的注释，方便大家理解和修改。仓库地址: https://github.com/zsuroy/block-dodge-rp2350效果展示B站: 基于RP2350的MicroPython方块小游戏：在指尖舞动像素未来展望这只是个非常基础的版本，未来还有很多可以扩展的地方：更丰富的障碍物类型：大小不一、速度各异，甚至会突然转向的障碍物，增加挑战性。不同的游戏模式：例如加速模式、限时模式等等，带来更多样的玩法。音效支持：加入简单的音效，比如碰撞时的“Duang”，得分时的“叮”，让游戏更有代入感。排行榜功能：如果能联网，搞个本地或者在线排行榜，看看谁是真正的躲避高手！希望这个小项目能给大家带来一些灵感，也欢迎各位大佬一起交流完善，提出宝贵的意见和建议，让我们一起让这个小游戏变得更有趣！
引言近期有幸体验了DFRobot推出的Beetle-RP2350微型开发板，这款仅硬币大小的开发板给我留下了深刻印象。作为一款基于树莓派RP2350微控制器的产品，它拥有以下核心特性：双核双架构，Arm Cortex-M33或Hazard3 RISC-V内核150MHz主频，520KB RAM，2MB flash。浏览了一下社区中关于Arduino生态的内容较为丰富，但出于对MicroPython的偏好，我决定采用MicroPython作为开发环境。本文将介绍在MacOS系统下搭建开发环境的完整过程，并通过基准测试其性能表现。前期准备开发环境如下系统: MacOS Catalina 10.15.7IDE: PyCharm Pro + MicroPython + Tabby(终端工具)硬件: Beetle-RP2350相关资料官方资料: https://www.raspberrypi.com/documentation/microcontrollers/silicon.html#rp2350固件地址:https://micropython.org/download/?mcu=rp2350https://micropython.org/download/RPI_PICO2/MicroPython 教程地址: https://docs.micropython.org/en/latest/rp2/quickref.html环境搭建根据 MicroPython 官方文档指导，可以将RP2350连上USB进入大容量设备模式（类似于U盘），将下载好的固件( RPI_PICO2-20250415-v1.25.0.uf2)拷贝进去即烧录成功自动重启。进入大容量模式：按住 BOOT 不放 + 点按 RST拖动拷贝固件到 RP2350 盘符，完成之后会自动弹出该盘符按下 RST 复位上机测试点灯测试from machine import Pin import time LED = Pin(25, Pin.OUT) while True: LED.on() time.sleep(1) LED.off() time.sleep(1)跑分测试摘录了以下RP2350和RP2040的性能表格，但是实际我这边测试出来与给出有点出入，仅供参考，建议以C/C++进行基准测试。测试涵盖：基础运算性能（整数/浮点）复杂算法处理（Mandelbrot集计算）高精度计算（π值计算）BenchMark: https://github.com/shaoziyang/micropython_benchmarks注: 时间单位ms, 越小则性能越好。BenchMark:''' Simple benchmark for micropython and circuitpython. Compare the performance of different MCUs by performing operations such as addition, multiplication, exponentiation, complex numbers, and pi. ''' import sys import gc try: from time import ticks_ms, ticks_diff import machine TEST_ENV = 'micropython' def freq(): try: f = machine.freq() // 1000000 except: f = machine.freq()[0] // 1000000 return f except: from time import monotonic_ns def ticks_ms(): return monotonic_ns() // 1000000 def ticks_diff(T2, T1): return T2 - T1 try: import board TEST_ENV = 'circuitpython' import microcontroller def freq(): return microcontroller.cpu.frequency // 1000000 except: TEST_ENV = 'OTHER' try: import psutil def freq(): return psutil.cpu_freq().max except: def freq(): return 'unknow' def memory(): try: r = gc.mem_free() + gc.mem_alloc() except: try: r = psutil.virtual_memory().total except: r = 'unkonw' return r PLATFORM = sys.platform VERSION = sys.version FREQ = freq() MEMORY = memory() def run_test(func, *param): gc.collect() try: t1 = ticks_ms() if param == None: func() else: func(*param) t2 = ticks_ms() dt = ticks_diff(t2, t1) print('Calculation time:', dt, 'ms\n') return dt except: print('Error occurred during operation!') def mandelbrot_test(p): iter = p[0] def in_set(c): z = 0 for i in range(iter): z = z * z + c if abs(z) > 4: return False return True r = '' for v in range(31): for u in range(81): if in_set((u / 30 - 2) + (v / 15 - 1) * 1j): r += ' ' else: r += '#' r += '\n' if len(p) > 1 and p[1]: print(r) def pi_test(p): iter = p[0] extra = 8 one = 10 ** (iter + extra) t, c, n, na, d, da = 3 * one, 3 * one, 1, 0, 0, 24 while t > 1: n, na, d, da = n + na, na + 8, d + da, da + 32 t = t * n // d c += t return c // (10 ** extra) def add_test(p): for i in range(p[0]): C = p[1] + p[2] def mul_test(p): for i in range(p[0]): C = p[1] * p[2] def div_test(p): for i in range(p[0]): C = p[1] / p[2] def pow_test(p): for i in range(p[0]): C = p[1] ** p[2] INT_ADD_TEST_LIST = ('Integer addition {} times', add_test, [12345678, 56781234], 10000, 100000, 1000000) INT_MUL_TEST_LIST = ('Integer multiplication {} times', mul_test, [12345678, 56781234], 10000, 100000, 1000000) INT_DIV_TEST_LIST = ('Integer division {} times', div_test, [99999991, 45481], 10000, 100000, 1000000) FLOAT_ADD_TEST_LIST = ('Float addition {} times', add_test, [12345678.1234, 56781234.5678], 10000, 100000, 1000000) FLOAT_MUL_TEST_LIST = ( 'Float multiplication {} times', mul_test, [12345678.1234, 56781234.5678], 10000, 100000, 1000000) FLOAT_DIV_TEST_LIST = ('Float division {} times', div_test, [99999991.2345, 45481.1357], 10000, 100000, 1000000) POWER_TEST_LIST = ('Power calculation {} times', pow_test, [1234.5678, 2.3456], 10000, 100000, 1000000) MAND_TEST_LIST = ('Mandelbrot iterating {} times', mandelbrot_test, [], 100, 500, 5000) PI_TEST_LIST = ('Pi Calculation {} bits', pi_test, [], 1000, 5000, 10000, 100000, 200000) TEST_LIST = ( INT_ADD_TEST_LIST, INT_MUL_TEST_LIST, INT_DIV_TEST_LIST, FLOAT_ADD_TEST_LIST, FLOAT_MUL_TEST_LIST, FLOAT_DIV_TEST_LIST, POWER_TEST_LIST, MAND_TEST_LIST, PI_TEST_LIST ) tr = [] def run(): global tr for TEST in TEST_LIST: for item in TEST: if type(item) == int: print(TEST[0].format(item)) p = TEST[2].copy() p.insert(0, item) r = run_test(TEST[1], p) tr.append([TEST[0].format(item), str(r)]) def print_result(): r1 = '| item | Platform | Version | Frequency | Memory |' r2 = '| - | - | - | - | - |' r3 = '| {} | {} | {} | {} | {} |'.format('result', PLATFORM, VERSION, FREQ, MEMORY) for i in range(len(tr)): r1 += ' {} |'.format(tr[i][0]) r2 += ' - |' r3 += ' {} |'.format(tr[i][8]) print(r1) print(r2) print(r3) ############################################################################### print('\n\n') print('##############') print('# Begin test #') print('##############') print('\nEnvironment:', TEST_ENV) print('Platform:', PLATFORM) print('Version:', VERSION) print('Frequency:', FREQ) print('Memory:', MEMORY) print() run() print('\nTest finished.') print('==============') print_result()串口运行结果日志:Calculation time: 4259 ms Integer multiplication 10000 times Calculation time: 161 ms Integer multiplication 100000 times Calculation time: 1628 ms Integer multiplication 1000000 times Calculation time: 16284 ms Integer division 10000 times Calculation time: 62 ms Integer division 100000 times Calculation time: 639 ms Integer division 1000000 times Calculation time: 6400 ms Float addition 10000 times Calculation time: 69 ms Float addition 100000 times Calculation time: 708 ms Float addition 1000000 times Calculation time: 7094 ms Float multiplication 10000 times Calculation time: 70 ms Float multiplication 100000 times Calculation time: 710 ms Float multiplication 1000000 times Calculation time: 7108 ms Float division 10000 times Calculation time: 71 ms Float division 100000 times Calculation time: 720 ms Float division 1000000 times Calculation time: 7208 ms Power calculation 10000 times Calculation time: 116 ms Power calculation 100000 times Calculation time: 1174 ms Power calculation 1000000 times Calculation time: 11755 ms Mandelbrot iterating 100 times Calculation time: 2608 ms Mandelbrot iterating 500 times Calculation time: 9103 ms Mandelbrot iterating 5000 times Calculation time: 81708 ms Pi Calculation 1000 bits Calculation time: 349 ms Pi Calculation 5000 bits Calculation time: 21192 ms Pi Calculation 10000 bits Calculation time: 58155 ms Pi Calculation 100000 bits跑分结论大致如下：CircuitPython(适用于大多数场景): 浮点运算速度快、内存占用低，运行复杂算法（如分形、高精度计算），推荐科学计算、图形渲染等场景。MicroPython: 整数运算速度快（如嵌入式控制、传感器数据处理），短任务响应更敏感（如快速初始化）。尾言通过本次完整的开发体验，Beetle-RP2350展现出了优异的性能表现和开发便利性。其双核架构在保持低功耗的同时，提供了显著的性能提升。MicroPython生态的成熟度也使得快速原型开发成为可能。对于嵌入式开发者而言，这款开发板在物联网终端、智能控制等领域都具有广阔的应用前景。后续计划：将进行环境监测系统实验，欢迎关注项目更新。题外话本文同步更新DFRobot社区: https://mc.dfrobot.com.cn/thread-325015-1-1.html#pid609120