# 前言
JB 家的东西实在是太好用了,丝毫不是因为我大半年没更新想水博客
# 准备环境
- Python3
- CLion
# 准备材料
- NodeMcu
- 7 针 0.96 寸 OLED
- 杜邦线若干
# 正文
1. 在 Clion Plugins 里搜索安装 PlatformIO for CLion,安装完成后重启 CLion
2. 安装 PlatformIO Core (CLI)
- Windows
- 下载 get-platformio.py
打开 powershell
cd C:\path\to\dir\where\is\located\script\get-platformio.py # get-platformio.py 下载目录
python.exe get-platformio.py # 运行脚本
Linux/MacOS
- 打开 terminal,下面命令三选一
python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"
curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -o get-platformio.py
python3 get-platformio.py
wget https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -O get-platformio.py
python3 get-platformio.py
3.CLion 创建 PlatformIO NodeMcu 项目
到此项目创建完成
4. 配置 NodeMCU 项目
修改 CMakeLists.txt,将 main.cpp 添加到项目
引入第三方库,如 U8g2
在 platformio lib 中搜索 U8g2 可以看到有两种安装方法
- 在 CLion 中打开 terminal,输入 pio lib install "olikraus/U8g2"
- 编辑 platformio.ini 文件,在末尾中加入下面配置,编译时自动安装
lib_deps = olikraus/U8g2 @ ^2.28.8
修改 CMakeLists.txt,将 U8g2 库添加到项目中
修改项目编译配置
把 build 删除
修改串口监视器
5. 编写代码并编译上传到 NodeMCU