我们的开源宗旨:* 协调 开放 合作 共享
拥抱开源,丰富国内开源生态,开展多人运动,欢迎加入我们哈~
和一群志同道合的人,做自己所热爱的事!
项目开源地址:https://github.com/Cai-Zi/STM32_RC_Transmitter
Bilibili账号:蔡子CaiZi
1.为什么要用STM32做航模遥控器?Arduino不香嘛?
之前用Arduino Pro Mini制作了一个航模遥控器+接收机,不得不说Arduino开发起来非常方便,但是博主用的开发板比较廉价,芯片资源较少,只能实现基础功能,遥控性能也不能令人满意。我们的经费又不够来买大几百的UNO,怎么办?我找到了同价位的STM32F103C8T6开发板,十元包邮解君愁!这个小板子于我们遥控器而言,资源足够用了,别人甚至拿它来玩平衡车、四旋翼、智能家居,足见其强大!
2.为什么要命名为J20遥控器?
其一,我们自己DIY的遥控器,当然要用我国之重器-J20来命名!相信如果当年LUOLI大佬开发遥控器时,我们祖国的J20面世了,他也会用J20来命名自己的遥控器,而不是SU27,每个人都有自己的民族自豪感,我也一样!
其二,J20的总设计师-杨伟院士,是我的学长!招生宣传一波哈哈哈哈哈哈,欢迎报考西北工业大学!(招生办是不是该打钱了)我们学校真是太低调了,当年报考前我压根没听说过西工大,宣传力度要加强啊。
其三,今年是2020年,就说应景不应景!J20中的数字也象征着我们的开发时间,独特的年份,用来命名我们的遥控器刚刚好~
3.为什么要记录开发制作过程?
博主也是边学边做,并且是利用业余时间(导师:论文看累了,就敲点代码放松一下),实际上很耗费时间和精力啊!把学习过程记录下来,一是方便加深自己的理解,二是希望能帮到别人叭,三是提供给DIY玩家自己改造的空间,一千个人心中有一千个哈姆雷特,每个人都有自己的想法,授人以鱼不如授人以渔,教程可以帮助读者完成自己的个性化设计,比如设计开机界面、添加修改功能。
项目完全开源,还附带教程,怎么样?上车吧!
开始正文
1. 项目计划
前天,北斗三号最后一颗全球组网卫星发射成功,实现全球组网。不得不说我们祖国越来越强大了,我们自己也要更努力才行啊,现在我们总被漂亮国卡脖子,但是莫欺少年穷!我们每个人都为祖国建设添砖加瓦,迟早祖国会实现伟大复兴!
北斗系统建设采用“三步走”战略-【从无到有-服务亚太-全球组网】,那么我们的遥控器也分三步走,先完成基础版,实现遥控器的基础功能,再进行升级,添加屏幕界面交互,最后添加更高级人性化的功能。先会爬 再会走路 最后学会奔跑,这样看,万物是不是都相通的?
2. 开机界面制作
侃了这么多,来开工吧,万事开头难,我们先做一个帅气的J20开机界面!
(1)修改图片尺寸
找一张J20图片,用2345看图王修改图片尺寸128像素*64像素(或者比这个范围小一点),因为我们的OLED显示屏只有128*64个像素点,这一步也可以和第二步一起用程序实现。
(2)图像二值化
所谓图像二值化,就是将彩色图片变成黑白的,我们的显示屏单个像素只有亮/暗两种状态,对应1/0二值。可以用MATLAB/Python/Photoshop等来处理成黑白的,这里我用的是MATLAB,图片和m文件放在同一文件夹,代码如下:
close all
clear all
clc
%%
A=imread('j20.jpg');% 输入图片
n = graythresh(A);
% D=imbinarize(A,n);
D=im2bw(A,n);
% figure;
% imshow(D);
imwrite(D,'j20.bmp');% 输出图片
e=imread('j20.bmp');
[m,n] = size(e);
img = zeros(m,n);
fd=[m,n,];%设置空白图片矩阵
f=uint8 (round (fd*)); %转换为RGB值
bg=;%灰色背景51
for i=::m
for j=::n
if (e(i,j)<=)
f(i,j,)=;
f(i,j,)=;
f(i,j,)=;
else
f(i,j,)=;
f(i,j,)=;
f(i,j,)=;
end
end
end
% figure;
% imshow(f);
% sa=imcrop(f,[,,,]);%裁剪[左上角起始位置x,y,裁剪宽,高]
% imwrite(f,'j20.png');
生成j20.bmp后,有一些不满意的地方,接下来我们拿PS来修一下。
花费一点时间, 把边边角角清理干净,把线条补充上,再加个J-20文字,最后保存成bmp文件。
(3)Img2Lcd图片转数组
打开刚才修好的bmp图片,按如下四步操作,保存数组。如果发现显示不对,可以尝试改变图中设置,如果你不想搞懂OLED显示原理,那么一个一个试就可以了。扫描模式(4种选项)和6个选项栏(勾选/不勾选),最多4*2^6=256次,我比较幸运,只试了10次。
奉上我做好的两个数组,建议给我们的UI设计师加鸡腿!最后一张太好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logoR[]=
{
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X80,0XC0,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XC0,0X40,0X40,0X40,0X40,0X40,0X7C,
0X18,0X30,0X20,0X20,0X30,0X18,0X0C,0X06,0X03,0X01,0XFF,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XF0,0X80,0X80,0X00,0XF0,0XA0,0XF0,0X00,
0X70,0X50,0XF0,0X00,0XF0,0X00,0XF0,0X90,0XF0,0X00,0X00,0X00,0X00,0XF0,0X90,0X90,
0X00,0XF0,0X90,0XF0,0X00,0XF0,0X80,0XF0,0X00,0X80,0XF0,0X80,0X00,0XF0,0X80,0X80,
0X00,0XF0,0X90,0XF0,0X00,0XF0,0X10,0X00,0XF0,0X10,0X00,0XF0,0X90,0XD0,0X00,0XF0,
0X80,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0XF0,0XF0,0XF0,0XF0,0XF0,0XF0,0XFF,0XE0,0XC0,0X80,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X08,0X0C,0X0E,0X0E,0X0E,0X0E,0X0E,0X0E,0X0E,0X0E,
0XFE,0XFE,0XFE,0XFE,0XFE,0XFE,0XFE,0X00,0X0E,0X1E,0X3E,0X7E,0XFE,0XFE,0XFE,0XFE,
0XFE,0XEE,0XCE,0X8E,0X0E,0X0E,0X0E,0X0E,0X0E,0X0E,0X0E,0X0C,0X08,0X00,0XFE,0XFE,
0XFE,0XFE,0XFE,0XFE,0XCE,0X8E,0X0E,0X0E,0X0E,0X0E,0X0E,0X0E,0XFE,0XFE,0XFE,0XFC,
0XF8,0XF0,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X02,
0X06,0X8E,0XDE,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0XFC,
0XF8,0XF0,0XE0,0XC0,0X80,0X00,0X00,0X00,0X00,0X00,0X07,0X1C,0X30,0XE0,0X80,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0X03,0X07,
0X0F,0X1F,0X3F,0X7F,0XFF,0XFE,0XFC,0XF8,0XF0,0XE0,0XC0,0X80,0X00,0X00,0XFF,0XFF,
0XFF,0XFF,0XFF,0XFF,0X03,0X07,0X0F,0X1E,0X3C,0X78,0XF0,0XE0,0XFF,0XFF,0XFF,0XFF,
0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X10,0X18,0X1C,0X1E,
0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,
0X3F,0X7F,0XFF,0XFF,0XFF,0XFF,0XFE,0XFC,0XF8,0XF0,0XE0,0XC0,0X80,0X00,0X01,0X07,
0X0C,0X38,0X20,0X30,0X18,0X0C,0XFE,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X00,0X00,0X1C,0X1C,0X1C,0X1C,0X1C,0X1C,0X1C,
0X1C,0X1C,0X1C,0X1C,0X1C,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X00,0X00,0X1F,0X1F,
0X1F,0X1F,0X1F,0X1F,0X1C,0X1C,0X1C,0X1C,0X1C,0X1C,0X1C,0X1D,0X1F,0X1F,0X1F,0X1F,
0X1F,0X1F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X01,0X03,0X03,0X07,0X8F,0XCF,0XFF,0XFF,0XFF,0XFF,0XFE,0XFC,
0XF8,0XF0,0XE0,0XC0,0X80,0X00,0X1F,0X70,0XC0,0X80,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X02,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,
0X03,0X03,0X03,0X07,0X0F,0X0F,0X1E,0X3C,0X38,0X73,0X66,0XDC,0XF0,0XE0,0X80,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0X01,0X03,0X07,
0X04,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
};
图片取模数组代码
(4)图片显示程序
首先声明数组是全局变量,再在循环中调用显示函数。
/*
=============菜单显示==============
芯片STM32F103C8T6,先做一个J20开机界面
OLED显示屏:
GND 电源地
VCC 接3.3v电源
SCL 接PB8(SCL)
SDA 接PB9(SDA)
串口USB-TTL接法:
GND 电源地
3V3 接3.3v
TXD 接PB7
RXD 接PB6
ST-LINK V2接法:
GND 电源地
3V3 接3.3v
SWCLK 接DCLK
SWDIO 接DIO
by Bilibili 蔡子CaiZi
*/
#include "config.h"
#include "delay.h"
#include "usart.h"
#include "stm32f10x.h"
#include "oled.h"
#include "rtc.h"
#include "stdio.h"
#include "string.h"
extern unsigned char J20logo[];
extern unsigned char J20logoR[];
extern unsigned char BMP1[];
int main()
{
// u8 txt[16]={0};
delay_init();//初始化延时函数
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2,2位抢占优先级和2位子优先级
usart_init();//初始化串口1,波特率为115200
// TIM3_PWM_Init(19999,71);//预分频72,频率1MHz,周期1us;自动装载值20 000,故PWM周期1us*20 000
// TIM2_Init(499,71);//1MHz,每500us采集一次;可设置9us以上,但过小影响OLED显示
// DMA1_Init(); //DMA初始化
// GPIOA_Init(); //PA初始化
// Adc_Init(); //ADC初始化
// RTC_Init(); //RTC初始化
OLED_Init(); //初始化OLED
OLED_Clear();
OLED_Refresh_Gram();
while (){
// itoa(PWM1value,txt,10);//将int类型转换成10进制字符串
// printf("采样值:%d\t舵量:%s\t",ch1Value,txt);
// printf("当前时间:%d:%d:%d\n",calendar.hour,calendar.min,calendar.sec);
// //OLED_Clear();//一直清屏会造成闪烁
// strcat(txt," us");//合并字符串
// OLED_ShowString(6,3,txt,24); //位置6,3;字符大小24*24点阵
OLED_DrawBMP(,,,,J20logo);
// OLED_DrawBMP(0,0,128,8,BMP1);
//OLED_ShowString(6,3,"CaiZi",24); //位置6,3;字符大小24*24点阵
//OLED_Refresh_Gram();
delay_ms();
}
}
完整的工程文件已上传天翼云盘:
https://cloud.189.cn/t/rYZzQ3yIbIrm(访问码:5eju)
项目宣传视频
写在最后:
如果你手上有废弃的遥控器,有吃灰的开发板,有9块9包邮的烙铁或者焊台,欢迎加入我们,一起来感受DIY的乐趣;
如果你是一个技术小白,拥有一腔热血却很迷茫,欢迎加入我们,虽然这里除了知识和快乐,其他什么都没有;
无论你是入坑菜鸟还是航模老鸟,只要你有一颗热爱的心,来自五湖四海,我们都期待你的加入!
我们期待听到不同的声音,希望得到更多人的反馈,帮助我们来研发和测试~
QQ群:1091996634,密码:J20
想要一起研发的话,加群后请私聊群主喔~
开源团队现有成员:(持续更新)
蔡子CaiZi(B站up主) - STM32开发
A-XIN(模友) - STM32开发
小何(模友) - PCB设计
ZL_Studio(B站up主) - C51开发
王天天(舍友) - STM32开发
刘桶桶(模友) - PCB设计
简繁(模友) - UI设计
王博(模友) - STM32开发
与非门(模友) - STM32开发
Talons(模友) - STM32开发
大米粥(模友) - 结构设计
P a S S ||(模友) - STM32开发