Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #6

Merged
merged 27 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2e37adb
docs(changelog): 发布 v2.1.3-car-lock
DreamPWJ May 2, 2023
5b29873
chore: 增强嵌入式代码的健壮性和可维护性
DreamPWJ Jun 5, 2023
5f8370a
Merge remote-tracking branch 'origin/develop' into develop
DreamPWJ Jun 5, 2023
20fd67a
chore: 增强嵌入式代码的健壮性和可维护性
DreamPWJ Jun 7, 2023
977f3cf
docs(changelog): 发布 v2.0.1-car-lock
DreamPWJ Jun 7, 2023
e4c5fdc
docs(changelog): 发布 v2.2.0-car-lock
DreamPWJ Jun 7, 2023
c32ae13
chore: 增强嵌入式代码的健壮性和可维护性
DreamPWJ Jun 13, 2023
8c78fce
docs(changelog): 发布 v2.2.1-car-lock
DreamPWJ Jun 13, 2023
dadba01
docs(changelog): 发布 v2.0.1-car-lock
DreamPWJ Jun 27, 2023
ba14b80
chore: 增强嵌入式代码的健壮性和可维护性
DreamPWJ Jul 3, 2023
eca4be0
Merge remote-tracking branch 'origin/develop' into develop
DreamPWJ Jul 3, 2023
a167416
chore: 增强嵌入式代码的健壮性和可维护性
DreamPWJ Jul 7, 2023
0bd384a
docs(changelog): 发布 v2.2.0-car-lock
DreamPWJ Jul 7, 2023
877ca90
docs(changelog): 发布 v2.2.6-car-lock
DreamPWJ Jul 7, 2023
6efe2ca
docs(changelog): 发布 v2.3.0-car-lock
DreamPWJ Jul 10, 2023
49bf535
docs(changelog): 发布 v2.4.5-car-lock
DreamPWJ Jul 20, 2023
c34cbbb
docs(changelog): 发布 v2.0.1
DreamPWJ Jul 20, 2023
088a718
docs(changelog): 发布 v2.5.10
DreamPWJ Jul 20, 2023
16f20bf
chore: 增强嵌入式代码的健壮性和可维护性
DreamPWJ Aug 1, 2023
3c89aa9
Merge remote-tracking branch 'origin/develop' into develop
DreamPWJ Aug 1, 2023
2407ffe
chore: 增强嵌入式代码的健壮性和可维护性
DreamPWJ Aug 1, 2023
629c87a
chore: 增强嵌入式代码的健壮性和可维护性
DreamPWJ Aug 2, 2023
b654da8
chore: 增强嵌入式代码的健壮性和可维护性
DreamPWJ Aug 2, 2023
8498bcf
docs(changelog): 发布 v2.6.3
DreamPWJ Aug 27, 2023
890137b
chore: 增强嵌入式代码的健壮性和可维护性
DreamPWJ Sep 1, 2023
44f5d0d
Merge remote-tracking branch 'origin/develop' into develop
DreamPWJ Sep 1, 2023
281e52e
chore: 增强嵌入式代码的健壮性和可维护性
DreamPWJ Sep 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
## 2.6.3
`2023-08-27 13:55`<br><br>
#### 其它变更
- chore: 增强嵌入式代码的健壮性和可维护性 ([b654da8](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/b654da85469311247f1a593337ad1810988308a3)) @406798106
- chore: 增强嵌入式代码的健壮性和可维护性 ([629c87a](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/629c87a10820ae20b7670c7af3fa872bc8a0bc60)) @406798106
- chore: 增强嵌入式代码的健壮性和可维护性 ([2407ffe](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/2407ffe4217d257fef608c7160cf2990d859ea57)) @406798106
- chore: 增强嵌入式代码的健壮性和可维护性 ([16f20bf](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/16f20bf0cf4f6f7343099a3df1b087e00825c713)) @406798106

## 2.5.10
`2023-07-20 13:46`<br><br>

## 2.0.1
`2023-07-20 11:26`<br><br>

## 2.4.5-car-lock
`2023-07-20 11:08`<br><br>

## 2.3.0-car-lock
`2023-07-10 15:21`<br><br>
- docs(changelog): 发布 v2.2.6-car-lock @[email protected]
- docs(changelog): 发布 v2.2.0-car-lock @[email protected]

## 2.2.6-car-lock
`2023-07-07 17:10`<br><br>
#### 其它变更
- chore: 增强嵌入式代码的健壮性和可维护性 ([a167416](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/a1674161ef92567bb03f21b74e24c2729d365e97)) @406798106
- chore: 增强嵌入式代码的健壮性和可维护性 ([ba14b80](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/ba14b806c73da4c3b005027f33bcdca12a85f9b9)) @406798106

## 2.2.0-car-lock
`2023-07-07 16:38`<br><br>
#### 其它变更
- chore: 增强嵌入式代码的健壮性和可维护性 ([a167416](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/a1674161ef92567bb03f21b74e24c2729d365e97)) @406798106
- chore: 增强嵌入式代码的健壮性和可维护性 ([ba14b80](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/ba14b806c73da4c3b005027f33bcdca12a85f9b9)) @406798106
- chore: 增强嵌入式代码的健壮性和可维护性 ([c32ae13](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/c32ae13883e8dc8f511bf33c0d06e6f803e36a54)) @406798106
- chore: 增强嵌入式代码的健壮性和可维护性 ([20fd67a](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/20fd67a3d021af16b9f336cef17a475706352688)) @406798106
- chore: 增强嵌入式代码的健壮性和可维护性 ([5b29873](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/5b29873c187a089b25754ec22cc48ab2423131dd)) @406798106

## 2.0.1-car-lock
`2023-06-27 16:57`<br><br>
- docs(changelog): 发布 v2.2.1-car-lock @[email protected]

## 2.2.1-car-lock
`2023-06-13 16:19`<br><br>
#### 其它变更
- chore: 增强嵌入式代码的健壮性和可维护性 ([c32ae13](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/c32ae13883e8dc8f511bf33c0d06e6f803e36a54)) @406798106

## 2.2.0-car-lock
`2023-06-07 10:37`<br><br>
- docs(changelog): 发布 v2.0.1-car-lock @[email protected]

## 2.0.1-car-lock
`2023-06-07 10:27`<br><br>
#### 其它变更
- chore: 增强嵌入式代码的健壮性和可维护性 ([20fd67a](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/20fd67a3d021af16b9f336cef17a475706352688)) @406798106
- chore: 增强嵌入式代码的健壮性和可维护性 ([5b29873](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/5b29873c187a089b25754ec22cc48ab2423131dd)) @406798106
- chore: 增强嵌入式代码的健壮性和可维护性 ([b4eaa29](https://git.pengbocloud.com/lanneng_develop/embedded-monorepo/commit/b4eaa29dc1ba225c5ecdada4a14e690e682f654c)) @406798106

## 2.1.3-car-lock
`2023-05-02 17:27`<br><br>

## 2.1.7-car-lock
`2023-04-19 12:53`<br><br>
#### 其它变更
Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

### 开发平台:PlatformIO

- 用于嵌入式 C/C++ 开发的新一代工具集PlatformIO 世界上第一个用于嵌入式开发的包和项目依赖管理解决方案
- 安装执行 python get-platformio.py
- 用于嵌入式 C/C++ 开发的新一代工具集PlatformIO 世界上第一个用于嵌入式开发的包和项目依赖管理解决方案
- 安装执行 python get-platformio.py

### 跨芯片嵌入式框架: Arduino (不同芯片代码复用)

Expand All @@ -39,19 +39,17 @@

### 硬件调试烧录工具: EspTool、DapLink、ST-Link/J-Link

### WokWi在浏览器中模拟调试 IoT 嵌入式单片机项目
### Clion中集成PlatformIO平台

- https://wokwi.com
- https://www.jetbrains.com/help/clion/platformio.html

### Logic 2借助让您爱不释手的逻辑分析仪
### WokWi在浏览器中模拟调试 IoT 嵌入式单片机项目

- https://www.jetbrains.com/help/clion/platformio.html
- https://wokwi.com

#### 参考文章

https://randomnerdtutorials.com
https://blog.jetbrains.com/clion/2019/02/clion-2019-1-eap-clion-for-embedded-development-part-iii/
https://zhuanlan.zhihu.com/p/63672432
https://zhuanlan.zhihu.com/p/145801160

#### MinGW 是最小的C、C++编译环境 gcc、g++。 验证命令 gcc -v
Expand Down
45 changes: 32 additions & 13 deletions packages/athena-common/infrared_signals/infrared_signals.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
#include "infrared_signals.h"
#include <Arduino.h>
#include <IRremote.h>
#include <IRremote.hpp>

/**
* @author 潘维吉
* @date 2022/9/19 9:50
* @description 红外信号发送接收数据
*/

IRrecv irrecv(RECV_PIN);

decode_results results; // 注意这个数据类型
#define USE_MULTI_CORE 1 // 是否使用多核 根据芯片决定

/**
* 初始化
* 获取红外数据
*/
void init(void) {
irrecv.enableIRIn(); // 初始化红外接收器
void get_ir_data(void *pvParameters) {
while (1) { // RTOS多任务条件: 1. 不断循环 2. 无return关键字
if (IrReceiver.decode()) { // 注意这里取解码结果的方法,传递的是变量指针。
Serial.print("接收红外信号数据: ");
Serial.println(IrReceiver.decodedIRData.decodedRawData,
HEX); // Print raw data 以16进制换行输出接收代码
IrReceiver.printIRResultShort(&Serial); // Print complete received data in one line
IrReceiver.printIRSendUsage(&Serial); // Print the statement required to send this data
IrReceiver.resume(); // 给红外传送指令,让其继续接收下一个值。
}
delay(1000); // 多久执行一次 毫秒
}
}

/**
* 获取红外数据
* 初始化
*/
void get_data(void) {
if (irrecv.decode(&results)) { // 注意这里取解码结果的方法,传递的是变量指针。
Serial.println(results.value, HEX); // 以16进制换行输出接收代码。注意取值方法【results.value】。
irrecv.resume(); // 给红外传送指令,让其继续接收下一个值。
}
void init_ir(void) {
IrReceiver.begin(RECV_PIN, ENABLE_LED_FEEDBACK); // Start the receiver // 初始化红外接收器
#if !USE_MULTI_CORE
const char *params = NULL;
xTaskCreate(
get_ir_data, /* Task function. */
"get_ir_data", /* String with name of task. */
1024 * 8, /* Stack size in bytes. */
(void *) params, /* Parameter passed as input of the task */
6, /* Priority of the task.(configMAX_PRIORITIES - 1 being the highest, and 0 being the lowest.) */
NULL); /* Task handle. */
#else
//最后一个参数至关重要,决定这个任务创建在哪个核上.PRO_CPU 为 0, APP_CPU 为 1,或者 tskNO_AFFINITY 允许任务在两者上运行.
xTaskCreatePinnedToCore(get_ir_data, "get_ir_data", 1024 * 2, NULL, 5, NULL, 0);
#endif
}

4 changes: 2 additions & 2 deletions packages/athena-common/infrared_signals/infrared_signals.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class infrared_signals {

public:

void init(void);
void init_ir(void);

void get_data(void);
void get_ir_data(void *pvParameters);

};

Expand Down
4 changes: 2 additions & 2 deletions packages/athena-common/mqtt/at_mqtt/at_mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const char *at_mqtt_password = "emqx@2022"; // 设置MQTT服务器密码
const int at_mqtt_port = 1883;

/**
*
* 初始化MQTT客户端
*/
void init_at_mqtt() {
Expand All @@ -57,7 +56,7 @@ void init_at_mqtt() {
// 执行 AT+QMTOPEN? 时 ,若当前不存在已打开的客户端信息 ,则无 +QMTOPEN:<TCP_connectID>,<host_name>,<port>返回,仅返回 OK 或者 ERROR
send_mqtt_at_command("AT+QMTCLOSE=0\r\n", 1000, IS_DEBUG); // 关闭之前的连接 防止再次重连失败

// 设置MQTT连接所需要的的参数 不同的调制解调器模组需要适配不同的AT指令
// 设置MQTT连接所需要的的参数 不同的调制解调器模组需要适配不同的AT指令 session配置保持多次中断的会话 QOS:2才能生效
send_mqtt_at_command("AT+QMTCFG=\042version\042,0,1\r\n", 3000, IS_DEBUG); // 设置MQTT的版本
//send_mqtt_at_command("AT+ECMTCFG=\042keepalive\042,0,120\r\n", 6000, IS_DEBUG); // 配置心跳时间
//send_mqtt_at_command("AT+ECMTCFG=\042timeout\042,0,20\r\n", 6000, IS_DEBUG); // 配置数据包的发送超时时间(单位:s,范围:1-60,默认10s)
Expand Down Expand Up @@ -143,6 +142,7 @@ void at_mqtt_publish(String topic, String msg) {
* MQTT订阅消息
*/
void at_mqtt_subscribe(String topic) {
// 判断时间戳 过滤QOS2重试的过期无效的消息
Serial1.printf("AT+QMTSUB=0,1,\"%s\",2\r\n", topic.c_str());
}

Expand Down
24 changes: 13 additions & 11 deletions packages/athena-common/pwm/pwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void init_motor() {
*/
int channel_PWMA_duty;

void set_motor_up() {
void set_motor_up(int delay_time) {
#if IS_DEBUG
// 上报MQTT消息
string jsonData = "{\"msg\":\"开始控制电机正向运动\",\"chipId\":\"" + to_string(chipMacId) + "\"}";
Expand All @@ -84,7 +84,7 @@ void set_motor_up() {
}

channel_PWMA_duty = 1024; // PWM速度值
int overtime = 10; // 超时时间 秒s
int overtime = 12; // 超时时间 秒s

Serial.println("开始控制电机正向运动");
stop_down_motor(); // 停止反向电机
Expand All @@ -94,15 +94,15 @@ void set_motor_up() {
time(&startA);
ledcWrite(channel_PWMA, channel_PWMA_duty);
// 读取限位信号 停机电机 同时超时后自动复位或停止电机
delay(3000);
delay(delay_time);
while (get_pwm_status() == 2 && channel_PWMA_duty != 0) { // 在运动状态或PWM速度非0停止状态
delay(10);
time(&endA);
costA = difftime(endA, startA);
//printf("电机正向执行耗时:%f \n", costA);
if (ground_feeling_status() == 1) {
ledcWrite(channel_PWMA, 0); // 停止电机
Serial.println("地磁判断有车地锁不能继续抬起, 回落地锁");
Serial.println("地磁判断有车地锁不能继续升起, 回落地锁");
set_motor_down(); // 降锁
break;
}
Expand All @@ -119,12 +119,15 @@ void set_motor_up() {
"{\"command\":\"exception\",\"code\":\"1001\",\"msg\":\"车位锁电机抬起运行超时了\",\"chipId\":\"" +
to_string(chipMacId) + "\"}";
at_mqtt_publish(common_topic, jsonDataUP.c_str());
ledcWrite(channel_PWMA, 0); // 停止电机
// ledcWrite(channel_PWMA, 0); // 停止电机
Serial.println("电机正向运行超时不能继续升起, 回落地锁");
set_motor_down(); // 降锁
break;
}
}

if (get_pwm_status() == 1) {
if (get_pwm_status() == 1) { // 如果已经在上限位
ledcWrite(channel_PWMA, 0); // 停止电机
delay(200);
digitalWrite(GROUND_FEELING_RST_GPIO, HIGH); // 关闭地感检测
}
Expand All @@ -136,7 +139,7 @@ void set_motor_up() {
*/
int channel_PWMB_duty;

void set_motor_down() {
void set_motor_down(int delay_time) {
#if IS_DEBUG
// 上报MQTT消息
string jsonData = "{\"msg\":\"开始控制电机反向运动\",\"chipId\":\"" + to_string(chipMacId) + "\"}";
Expand All @@ -148,7 +151,7 @@ void set_motor_down() {
}

channel_PWMB_duty = 1024; // PWM速度值
int overtime = 10; // 超时时间 秒s
int overtime = 12; // 超时时间 秒s

Serial.println("开始控制电机反向运动");
stop_up_motor(); // 停止正向电机
Expand All @@ -157,7 +160,7 @@ void set_motor_down() {
double costB; // 时间差 秒
time(&startB);
ledcWrite(channel_PWMB, channel_PWMB_duty);
delay(3000);
delay(delay_time);
digitalWrite(GROUND_FEELING_RST_GPIO, LOW); // 开启地感检测
while (get_pwm_status() == 2 && channel_PWMB_duty != 0) { // 在运动状态与PWM速度非0停止状态
delay(10);
Expand All @@ -183,6 +186,7 @@ void set_motor_down() {
}

if (get_pwm_status() == 0) { // 已经在下限位
ledcWrite(channel_PWMB, 0); // 停止电机
// MQTT上报已落锁完成 可用于灯控或语音提醒等
string jsonDataDown =
"{\"command\":\"lock_status\",\"msg\":\"车位锁已落锁完成\",\"deviceCode\":\"" + to_string(chipMacId) +
Expand All @@ -191,9 +195,7 @@ void set_motor_down() {
at_mqtt_publish(common_topic, jsonDataDown.c_str());
}

delay(200);
ledcWrite(channel_PWMB, 0); // 停止电机

}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/athena-common/pwm/pwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

void init_motor();

void set_motor_up();
void set_motor_up(int delay_time = 2000);

void set_motor_down();
void set_motor_down(int delay_time = 2000);

void stop_motor();

Expand Down
33 changes: 0 additions & 33 deletions projects-demo/esp32-c3-demo/CMakeLists.txt

This file was deleted.

6 changes: 6 additions & 0 deletions projects-demo/esp32-c3-demo/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
#include <bluetooth_connect.h>
// #include <log_insight.h>

/**
* @author 潘维吉
* @date 2022/7/20 9:41
* @description 程序运行入口
*/

// 获取自定义多环境变量宏定义
#define XSTR(x) #x
#define STR(x) XSTR(x)
Expand Down
6 changes: 6 additions & 0 deletions projects-demo/esp32-s3-demo/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#include <Arduino.h>

/**
* @author 潘维吉
* @date 2022/7/20 9:41
* @description 程序运行入口
*/

void setup() {
// write your initialization code here
// 设置UART串口波特率
Expand Down
7 changes: 7 additions & 0 deletions projects-demo/stm32-demo/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
*
******************************************************************************
*/

/**
* @author 潘维吉
* @date 2022/7/20 9:41
* @description 程序运行入口
*/

/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include <stdio.h>
Expand Down
Loading