致敬学长!J20航模遥控器开源项目计划【开局篇】 | 先做一个开机界面 | MATLAB图像二值化 | Img2Lcd图片取模 | OLED显示图片

我们的开源宗旨:自由 协调 开放 合作 共享

拥抱开源,丰富国内开源生态,开展多人运动,欢迎加入我们哈~

和一群志同道合的人,做自己所热爱的事!

项目开源地址:https://github.com/J20RC/STM32_RC_Transmitter

Bilibili账号:蔡子CaiZi

个人主页:https://space.bilibili.com/349576976

 

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文件放在同一文件夹,代码如下:

 1 close all
 2 clear all
 3 clc
 4 %%
 5 A=imread('j20.jpg');% 输入图片
 6 n = graythresh(A);
 7 % D=imbinarize(A,n);
 8 D=im2bw(A,n);
 9 % figure;
10 % imshow(D);
11 imwrite(D,'j20.bmp');% 输出图片
12 e=imread('j20.bmp');
13 [m,n] = size(e);
14 img = zeros(m,n);
15 fd=[m,n,3];%设置空白图片矩阵
16 f=uint8 (round (fd*255)); %转换为RGB值
17 bg=255;%灰色背景51
18 for i=1:1:m
19    for j=1:1:n
20        if (e(i,j)<=200)
21            f(i,j,1)=91;
22            f(i,j,2)=155;
23            f(i,j,3)=213;
24        else
25            f(i,j,1)=255;
26            f(i,j,2)=255;
27            f(i,j,3)=255;
28        end
29    end
30 end
31 % figure;
32 % imshow(f);
33 % sa=imcrop(f,[0,0,140,140]);%裁剪[左上角起始位置x,y,裁剪宽,高]
34 % imwrite(f,'j20.png');

生成j20.bmp后,有一些不满意的地方,接下来我们拿PS来修一下。 

花费一点时间, 把边边角角清理干净,把线条补充上,再加个J-20文字,最后保存成bmp文件。

(3)Img2Lcd图片转数组

打开刚才修好的bmp图片,按如下四步操作,保存数组。如果发现显示不对,可以尝试改变图中设置,如果你不想搞懂OLED显示原理,那么一个一个试就可以了。扫描模式(4种选项)和6个选项栏(勾选/不勾选),最多4*2^6=256次,我比较幸运,只试了10次。

 

奉上我做好的两个数组,建议给我们的UI设计师加鸡腿!最后一张太好看了叭!

 

  1 unsigned char J20logo[] =
  2 {
  3 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  4 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  5 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X7F,0X3F,0XFF,0XFF,0XFF,0XFF,0XFF,
  6 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  7 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  8 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
  9 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 10 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 11 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 12 0XFF,0XFF,0XFF,0XFF,0XFF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,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0XFE,0XFC,0XF8,
 63 0XFB,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 64 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 65 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 66 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
 67 };
 68  
 69 unsigned char J20logoR[]=
 70 {
 71 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
 72 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
 73 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X80,0XC0,0X00,0X00,0X00,0X00,0X00,
 74 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
 75 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
 76 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
 77 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
 78 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
 79 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
 80 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XC0,0X40,0X40,0X40,0X40,0X40,0X7C,
 81 0X18,0X30,0X20,0X20,0X30,0X18,0X0C,0X06,0X03,0X01,0XFF,0X00,0X00,0X00,0X00,0X00,
 82 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XF0,0X80,0X80,0X00,0XF0,0XA0,0XF0,0X00,
 83 0X70,0X50,0XF0,0X00,0XF0,0X00,0XF0,0X90,0XF0,0X00,0X00,0X00,0X00,0XF0,0X90,0X90,
 84 0X00,0XF0,0X90,0XF0,0X00,0XF0,0X80,0XF0,0X00,0X80,0XF0,0X80,0X00,0XF0,0X80,0X80,
 85 0X00,0XF0,0X90,0XF0,0X00,0XF0,0X10,0X00,0XF0,0X10,0X00,0XF0,0X90,0XD0,0X00,0XF0,
 86 0X80,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
 87 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
 88 0X00,0X00,0X00,0XF0,0XF0,0XF0,0XF0,0XF0,0XF0,0XFF,0XE0,0XC0,0X80,0X00,0X00,0X00,
 89 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XFF,0X00,0X00,0X00,0X00,0X00,
 90 0X00,0X00,0X00,0X00,0X00,0X00,0X08,0X0C,0X0E,0X0E,0X0E,0X0E,0X0E,0X0E,0X0E,0X0E,
 91 0XFE,0XFE,0XFE,0XFE,0XFE,0XFE,0XFE,0X00,0X0E,0X1E,0X3E,0X7E,0XFE,0XFE,0XFE,0XFE,
 92 0XFE,0XEE,0XCE,0X8E,0X0E,0X0E,0X0E,0X0E,0X0E,0X0E,0X0E,0X0C,0X08,0X00,0XFE,0XFE,
 93 0XFE,0XFE,0XFE,0XFE,0XCE,0X8E,0X0E,0X0E,0X0E,0X0E,0X0E,0X0E,0XFE,0XFE,0XFE,0XFC,
 94 0XF8,0XF0,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
 95 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X02,
 96 0X06,0X8E,0XDE,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0XFC,
 97 0XF8,0XF0,0XE0,0XC0,0X80,0X00,0X00,0X00,0X00,0X00,0X07,0X1C,0X30,0XE0,0X80,0X00,
 98 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
 99 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0X03,0X07,
100 0X0F,0X1F,0X3F,0X7F,0XFF,0XFE,0XFC,0XF8,0XF0,0XE0,0XC0,0X80,0X00,0X00,0XFF,0XFF,
101 0XFF,0XFF,0XFF,0XFF,0X03,0X07,0X0F,0X1E,0X3C,0X78,0XF0,0XE0,0XFF,0XFF,0XFF,0XFF,
102 0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
103 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X10,0X18,0X1C,0X1E,
104 0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,
105 0X3F,0X7F,0XFF,0XFF,0XFF,0XFF,0XFE,0XFC,0XF8,0XF0,0XE0,0XC0,0X80,0X00,0X01,0X07,
106 0X0C,0X38,0X20,0X30,0X18,0X0C,0XFE,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
107 0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X00,0X00,0X1C,0X1C,0X1C,0X1C,0X1C,0X1C,0X1C,
108 0X1C,0X1C,0X1C,0X1C,0X1C,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X00,0X00,0X1F,0X1F,
109 0X1F,0X1F,0X1F,0X1F,0X1C,0X1C,0X1C,0X1C,0X1C,0X1C,0X1C,0X1D,0X1F,0X1F,0X1F,0X1F,
110 0X1F,0X1F,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
111 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
112 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
113 0X00,0X00,0X00,0X00,0X01,0X03,0X03,0X07,0X8F,0XCF,0XFF,0XFF,0XFF,0XFF,0XFE,0XFC,
114 0XF8,0XF0,0XE0,0XC0,0X80,0X00,0X1F,0X70,0XC0,0X80,0X00,0X00,0X00,0X00,0X00,0X00,
115 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
116 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
117 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
118 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
119 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
120 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
121 0X00,0X00,0X00,0X00,0X00,0X00,0X02,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,
122 0X03,0X03,0X03,0X07,0X0F,0X0F,0X1E,0X3C,0X38,0X73,0X66,0XDC,0XF0,0XE0,0X80,0X00,
123 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
124 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
125 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
126 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
127 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
128 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
129 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
130 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0X01,0X03,0X07,
131 0X04,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
132 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
133 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
134 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
135 };
图片取模数组代码

(4)图片显示程序

首先声明数组是全局变量,再在循环中调用显示函数。

 1 /*
 2 =============菜单显示==============
 3     芯片STM32F103C8T6,先做一个J20开机界面
 4     OLED显示屏:
 5                 GND   电源地
 6                 VCC   接3.3v电源
 7                 SCL   接PB8(SCL)
 8                 SDA   接PB9(SDA)
 9     串口USB-TTL接法:    
10                 GND   电源地
11                 3V3   接3.3v
12                 TXD   接PB7
13                 RXD   接PB6
14     ST-LINK V2接法:
15                 GND   电源地
16                 3V3   接3.3v
17                 SWCLK 接DCLK
18                 SWDIO 接DIO
19     by Bilibili 蔡子CaiZi
20 */
21 #include "config.h"
22 #include "delay.h"
23 #include "usart.h"
24 #include "stm32f10x.h"
25 #include "oled.h"
26 #include "rtc.h" 
27 #include "stdio.h"
28 #include "string.h"
29 extern unsigned char J20logo[];
30 extern unsigned char J20logoR[];
31 extern unsigned char BMP1[];
32 int main()
33 {
34 //    u8 txt[16]={0};
35     delay_init();//初始化延时函数
36     NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2,2位抢占优先级和2位子优先级
37     usart_init(115200);//初始化串口1,波特率为115200
38 //    TIM3_PWM_Init(19999,71);//预分频72,频率1MHz,周期1us;自动装载值20 000,故PWM周期1us*20 000
39 //    TIM2_Init(499,71);//1MHz,每500us采集一次;可设置9us以上,但过小影响OLED显示
40 //    DMA1_Init();    //DMA初始化
41 //    GPIOA_Init();    //PA初始化
42 //    Adc_Init();        //ADC初始化
43 //    RTC_Init();          //RTC初始化
44     OLED_Init();    //初始化OLED  
45     OLED_Clear();
46     OLED_Refresh_Gram();
47     while (1){
48 //        itoa(PWM1value,txt,10);//将int类型转换成10进制字符串
49 //        printf("采样值:%d\t舵量:%s\t",ch1Value,txt);
50 //        printf("当前时间:%d:%d:%d\n",calendar.hour,calendar.min,calendar.sec);
51 //        //OLED_Clear();//一直清屏会造成闪烁
52 //        strcat(txt," us");//合并字符串
53 //        OLED_ShowString(6,3,txt,24); //位置6,3;字符大小24*24点阵
54         OLED_DrawBMP(0,0,128,8,J20logo);
55 //        OLED_DrawBMP(0,0,128,8,BMP1);
56         //OLED_ShowString(6,3,"CaiZi",24); //位置6,3;字符大小24*24点阵
57         //OLED_Refresh_Gram();
58         delay_ms(500);
59     }
60 }

 

完整的工程文件已上传天翼云盘:

 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开发

posted @ 2020-08-05 10:11  蔡子CaiZi  阅读(733)  评论(0编辑  收藏  举报