From 8aca9b4c7df11b0d3bce6b276b3dfdb3c8f719ca Mon Sep 17 00:00:00 2001 From: kerwincui <164770707@qq.com> Date: Sun, 12 Sep 2021 18:03:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4stm32=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../smart_dormitory/User/MultiButton/LICENSE | 21 - .../User/MultiButton/README.md | 120 ---- .../MultiButton/examples/example_callback.c | 58 -- .../User/MultiButton/examples/example_poll.c | 37 -- .../User/MultiButton/multi_button.c | 197 ------ .../User/MultiButton/multi_button.h | 61 -- .../smart_dormitory/User/Process/process.c | 62 -- .../smart_dormitory/User/Process/process.h | 31 - .../stm32/smart_dormitory/User/RC522/rc522.c | 616 ------------------ .../stm32/smart_dormitory/User/RC522/rc522.h | 175 ----- .../stm32/smart_dormitory/User/dht11/dht11.c | 196 ------ .../stm32/smart_dormitory/User/dht11/dht11.h | 45 -- .../stm32/smart_dormitory/User/flash/flash.c | 71 -- .../stm32/smart_dormitory/User/flash/flash.h | 35 - .../smart_dormitory/User/key_scan/key_scan.c | 124 ---- .../smart_dormitory/User/key_scan/key_scan.h | 30 - .../smart_dormitory/User/light/sensor_light.c | 42 -- .../smart_dormitory/User/light/sensor_light.h | 19 - .../stm32/smart_dormitory/User/oled/codetab.h | 299 --------- .../stm32/smart_dormitory/User/oled/oled.c | 215 ------ .../stm32/smart_dormitory/User/oled/oled.h | 49 -- .../smart_dormitory/User/oled/oledfont.h | 381 ----------- .../User/xiaoyi_wifi/esp8266.c | 478 -------------- .../User/xiaoyi_wifi/esp8266.h | 98 --- .../smart_dormitory/User/xiaoyi_wifi/mqtt.c | 37 -- .../smart_dormitory/User/xiaoyi_wifi/mqtt.h | 26 - .../smart_dormitory/User/xiaoyi_wifi/tcp.c | 42 -- .../smart_dormitory/User/xiaoyi_wifi/tcp.h | 22 - 28 files changed, 3587 deletions(-) delete mode 100644 firmware/stm32/smart_dormitory/User/MultiButton/LICENSE delete mode 100644 firmware/stm32/smart_dormitory/User/MultiButton/README.md delete mode 100644 firmware/stm32/smart_dormitory/User/MultiButton/examples/example_callback.c delete mode 100644 firmware/stm32/smart_dormitory/User/MultiButton/examples/example_poll.c delete mode 100644 firmware/stm32/smart_dormitory/User/MultiButton/multi_button.c delete mode 100644 firmware/stm32/smart_dormitory/User/MultiButton/multi_button.h delete mode 100644 firmware/stm32/smart_dormitory/User/Process/process.c delete mode 100644 firmware/stm32/smart_dormitory/User/Process/process.h delete mode 100644 firmware/stm32/smart_dormitory/User/RC522/rc522.c delete mode 100644 firmware/stm32/smart_dormitory/User/RC522/rc522.h delete mode 100644 firmware/stm32/smart_dormitory/User/dht11/dht11.c delete mode 100644 firmware/stm32/smart_dormitory/User/dht11/dht11.h delete mode 100644 firmware/stm32/smart_dormitory/User/flash/flash.c delete mode 100644 firmware/stm32/smart_dormitory/User/flash/flash.h delete mode 100644 firmware/stm32/smart_dormitory/User/key_scan/key_scan.c delete mode 100644 firmware/stm32/smart_dormitory/User/key_scan/key_scan.h delete mode 100644 firmware/stm32/smart_dormitory/User/light/sensor_light.c delete mode 100644 firmware/stm32/smart_dormitory/User/light/sensor_light.h delete mode 100644 firmware/stm32/smart_dormitory/User/oled/codetab.h delete mode 100644 firmware/stm32/smart_dormitory/User/oled/oled.c delete mode 100644 firmware/stm32/smart_dormitory/User/oled/oled.h delete mode 100644 firmware/stm32/smart_dormitory/User/oled/oledfont.h delete mode 100644 firmware/stm32/smart_dormitory/User/xiaoyi_wifi/esp8266.c delete mode 100644 firmware/stm32/smart_dormitory/User/xiaoyi_wifi/esp8266.h delete mode 100644 firmware/stm32/smart_dormitory/User/xiaoyi_wifi/mqtt.c delete mode 100644 firmware/stm32/smart_dormitory/User/xiaoyi_wifi/mqtt.h delete mode 100644 firmware/stm32/smart_dormitory/User/xiaoyi_wifi/tcp.c delete mode 100644 firmware/stm32/smart_dormitory/User/xiaoyi_wifi/tcp.h diff --git a/firmware/stm32/smart_dormitory/User/MultiButton/LICENSE b/firmware/stm32/smart_dormitory/User/MultiButton/LICENSE deleted file mode 100644 index 16030756..00000000 --- a/firmware/stm32/smart_dormitory/User/MultiButton/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Zibin Zheng - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/firmware/stm32/smart_dormitory/User/MultiButton/README.md b/firmware/stm32/smart_dormitory/User/MultiButton/README.md deleted file mode 100644 index 96bd1683..00000000 --- a/firmware/stm32/smart_dormitory/User/MultiButton/README.md +++ /dev/null @@ -1,120 +0,0 @@ -# MultiButton - -## 简介 -MultiButton 是一个小巧简单易用的事件驱动型按键驱动模块,可无限量扩展按键,按键事件的回调异步处理方式可以简化你的程序结构,去除冗余的按键处理硬编码,让你的按键业务逻辑更清晰。 - -## 使用方法 -1.先申请一个按键结构 - -```c -struct Button button1; -``` -2.初始化按键对象,绑定按键的GPIO电平读取接口**read_button_pin()** ,后一个参数设置有效触发电平 - -```c -button_init(&button1, read_button_pin, 0); -``` -3.注册按键事件 - -```c -button_attach(&button1, SINGLE_CLICK, Callback_SINGLE_CLICK_Handler); -button_attach(&button1, DOUBLE_CLICK, Callback_DOUBLE_Click_Handler); -... -``` -4.启动按键 - -```c -button_start(&button1); -``` -5.设置一个5ms间隔的定时器循环调用后台处理函数 - -```c -while(1) { - ... - if(timer_ticks == 5) { - timer_ticks = 0; - - button_ticks(); - } -} -``` - -## 特性 - -MultiButton 使用C语言实现,基于面向对象方式设计思路,每个按键对象单独用一份数据结构管理: - -```c -struct Button { - uint16_t ticks; - uint8_t repeat: 4; - uint8_t event : 4; - uint8_t state : 3; - uint8_t debounce_cnt : 3; - uint8_t active_level : 1; - uint8_t button_level : 1; - uint8_t (*hal_button_Level)(void); - BtnCallback cb[number_of_event]; - struct Button* next; -}; -``` -这样每个按键使用单向链表相连,依次进入 button_handler(struct Button* handle) 状态机处理,所以每个按键的状态彼此独立。 - - -## 按键事件 - -事件 | 说明 ----|--- -PRESS_DOWN | 按键按下,每次按下都触发 -PRESS_UP | 按键弹起,每次松开都触发 -PRESS_REPEAT | 重复按下触发,变量repeat计数连击次数 -SINGLE_CLICK | 单击按键事件 -DOUBLE_CLICK | 双击按键事件 -LONG_PRESS_START | 达到长按时间阈值时触发一次 -LONG_PRESS_HOLD | 长按期间一直触发 - - -## Examples - -```c -#include "button.h" - -struct Button btn1; - -int read_button1_GPIO() -{ - return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin); -} - -int main() -{ - button_init(&btn1, read_button1_GPIO, 0); - button_attach(&btn1, PRESS_DOWN, BTN1_PRESS_DOWN_Handler); - button_attach(&btn1, PRESS_UP, BTN1_PRESS_UP_Handler); - button_attach(&btn1, PRESS_REPEAT, BTN1_PRESS_REPEAT_Handler); - button_attach(&btn1, SINGLE_CLICK, BTN1_SINGLE_Click_Handler); - button_attach(&btn1, DOUBLE_CLICK, BTN1_DOUBLE_Click_Handler); - button_attach(&btn1, LONG_PRESS_START, BTN1_LONG_PRESS_START_Handler); - button_attach(&btn2, LONG_PRESS_HOLD, BTN1_LONG_PRESS_HOLD_Handler); - button_start(&btn1); - - //make the timer invoking the button_ticks() interval 5ms. - //This function is implemented by yourself. - __timer_start(button_ticks, 0, 5); - - while(1) - {} -} - -void BTN1_PRESS_DOWN_Handler(void* btn) -{ - //do something... -} - -void BTN1_PRESS_UP_Handler(void* btn) -{ - //do something... -} - -... -``` - diff --git a/firmware/stm32/smart_dormitory/User/MultiButton/examples/example_callback.c b/firmware/stm32/smart_dormitory/User/MultiButton/examples/example_callback.c deleted file mode 100644 index d774069a..00000000 --- a/firmware/stm32/smart_dormitory/User/MultiButton/examples/example_callback.c +++ /dev/null @@ -1,58 +0,0 @@ -#include "multi_button.h" - -struct Button btn1; -struct Button btn2; - -uint8_t read_button1_GPIO() -{ - return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin); -} - -uint8_t read_button2_GPIO() -{ - return HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin); -} - -int main() -{ - button_init(&btn1, read_button1_GPIO, 0); - button_init(&btn2, read_button2_GPIO, 0); - - button_attach(&btn1, PRESS_DOWN, BTN1_PRESS_DOWN_Handler); - button_attach(&btn1, PRESS_UP, BTN1_PRESS_UP_Handler); - button_attach(&btn1, PRESS_REPEAT, BTN1_PRESS_REPEAT_Handler); - button_attach(&btn1, SINGLE_CLICK, BTN1_SINGLE_Click_Handler); - button_attach(&btn1, DOUBLE_CLICK, BTN1_DOUBLE_Click_Handler); - button_attach(&btn1, LONG_PRESS_START, BTN1_LONG_PRESS_START_Handler); - button_attach(&btn1, LONG_PRESS_HOLD, BTN1_LONG_PRESS_HOLD_Handler); - - button_attach(&btn2, PRESS_DOWN, BTN2_PRESS_DOWN_Handler); - button_attach(&btn2, PRESS_UP, BTN2_PRESS_UP_Handler); - button_attach(&btn2, PRESS_REPEAT, BTN2_PRESS_REPEAT_Handler); - button_attach(&btn2, SINGLE_CLICK, BTN2_SINGLE_Click_Handler); - button_attach(&btn2, DOUBLE_CLICK, BTN2_DOUBLE_Click_Handler); - button_attach(&btn2, LONG_PRESS_START, BTN2_LONG_PRESS_START_Handler); - button_attach(&btn2, LONG_PRESS_HOLD, BTN2_LONG_PRESS_HOLD_Handler); - - button_start(&btn1); - button_start(&btn2); - - //make the timer invoking the button_ticks() interval 5ms. - //This function is implemented by yourself. - __timer_start(button_ticks, 0, 5); - - while(1) - {} -} - -void BTN1_PRESS_DOWN_Handler(void* btn) -{ - //do something... -} - -void BTN1_PRESS_UP_Handler(void* btn) -{ - //do something... -} - -... \ No newline at end of file diff --git a/firmware/stm32/smart_dormitory/User/MultiButton/examples/example_poll.c b/firmware/stm32/smart_dormitory/User/MultiButton/examples/example_poll.c deleted file mode 100644 index 054cd728..00000000 --- a/firmware/stm32/smart_dormitory/User/MultiButton/examples/example_poll.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "multi_button.h" - -struct Button btn1; - -uint8_t read_button1_GPIO() -{ - return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin); -} - - -int main() -{ - static uint8_t btn1_event_val; - - button_init(&btn1, read_button1_GPIO, 0); - button_start(&btn1); - - //make the timer invoking the button_ticks() interval 5ms. - //This function is implemented by yourself. - __timer_start(button_ticks, 0, 5); - - while(1) - { - if(btn1_event_val != get_button_event(&btn1)) { - btn1_event_val = get_button_event(&btn1); - - if(btn1_event_val == PRESS_DOWN) { - //do something - } else if(btn1_event_val == PRESS_UP) { - //do something - } else if(btn1_event_val == LONG_PRESS_HOLD) { - //do something - } - } - } -} - diff --git a/firmware/stm32/smart_dormitory/User/MultiButton/multi_button.c b/firmware/stm32/smart_dormitory/User/MultiButton/multi_button.c deleted file mode 100644 index 3a96fa7d..00000000 --- a/firmware/stm32/smart_dormitory/User/MultiButton/multi_button.c +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) 2016 Zibin Zheng - * All rights reserved - */ - -#include "multi_button.h" - -#define EVENT_CB(ev) if(handle->cb[ev])handle->cb[ev]((Button*)handle) - -//button handle list head. -static struct Button* head_handle = NULL; - -/** - * @brief Initializes the button struct handle. - * @param handle: the button handle strcut. - * @param pin_level: read the HAL GPIO of the connet button level. - * @param active_level: pressed GPIO level. - * @retval None - */ -void button_init(struct Button* handle, uint8_t(*pin_level)(), uint8_t active_level) -{ - memset(handle, 0, sizeof(struct Button)); - handle->event = (uint8_t)NONE_PRESS; - handle->hal_button_Level = pin_level; - handle->button_level = handle->hal_button_Level(); - handle->active_level = active_level; -} - -/** - * @brief Attach the button event callback function. - * @param handle: the button handle strcut. - * @param event: trigger event type. - * @param cb: callback function. - * @retval None - */ -void button_attach(struct Button* handle, PressEvent event, BtnCallback cb) -{ - handle->cb[event] = cb; -} - -/** - * @brief Inquire the button event happen. - * @param handle: the button handle strcut. - * @retval button event. - */ -PressEvent get_button_event(struct Button* handle) -{ - return (PressEvent)(handle->event); -} - -/** - * @brief Button driver core function, driver state machine. - * @param handle: the button handle strcut. - * @retval None - */ -void button_handler(struct Button* handle) -{ - uint8_t read_gpio_level = handle->hal_button_Level(); - - //ticks counter working.. - if((handle->state) > 0) handle->ticks++; - - /*------------button debounce handle---------------*/ - if(read_gpio_level != handle->button_level) { //not equal to prev one - //continue read 3 times same new level change - if(++(handle->debounce_cnt) >= DEBOUNCE_TICKS) { - handle->button_level = read_gpio_level; - handle->debounce_cnt = 0; - } - } else { //leved not change ,counter reset. - handle->debounce_cnt = 0; - } - - /*-----------------State machine-------------------*/ - switch (handle->state) { - case 0: - if(handle->button_level == handle->active_level) { //start press down - handle->event = (uint8_t)PRESS_DOWN; - EVENT_CB(PRESS_DOWN); - handle->ticks = 0; - handle->repeat = 1; - handle->state = 1; - } else { - handle->event = (uint8_t)NONE_PRESS; - } - break; - - case 1: - if(handle->button_level != handle->active_level) { //released press up - handle->event = (uint8_t)PRESS_UP; - EVENT_CB(PRESS_UP); - handle->ticks = 0; - handle->state = 2; - - } else if(handle->ticks > LONG_TICKS) { - handle->event = (uint8_t)LONG_PRESS_START; - EVENT_CB(LONG_PRESS_START); - handle->state = 5; - } - break; - - case 2: - if(handle->button_level == handle->active_level) { //press down again - handle->event = (uint8_t)PRESS_DOWN; - EVENT_CB(PRESS_DOWN); - handle->repeat++; - EVENT_CB(PRESS_REPEAT); // repeat hit - handle->ticks = 0; - handle->state = 3; - } else if(handle->ticks > SHORT_TICKS) { //released timeout - if(handle->repeat == 1) { - handle->event = (uint8_t)SINGLE_CLICK; - EVENT_CB(SINGLE_CLICK); - } else if(handle->repeat == 2) { - handle->event = (uint8_t)DOUBLE_CLICK; - EVENT_CB(DOUBLE_CLICK); // repeat hit - } - handle->state = 0; - } - break; - - case 3: - if(handle->button_level != handle->active_level) { //released press up - handle->event = (uint8_t)PRESS_UP; - EVENT_CB(PRESS_UP); - if(handle->ticks < SHORT_TICKS) { - handle->ticks = 0; - handle->state = 2; //repeat press - } else { - handle->state = 0; - } - } - break; - - case 5: - if(handle->button_level == handle->active_level) { - //continue hold trigger - handle->event = (uint8_t)LONG_PRESS_HOLD; - EVENT_CB(LONG_PRESS_HOLD); - - } else { //releasd - handle->event = (uint8_t)PRESS_UP; - EVENT_CB(PRESS_UP); - handle->state = 0; //reset - } - break; - } -} - -/** - * @brief Start the button work, add the handle into work list. - * @param handle: target handle strcut. - * @retval 0: succeed. -1: already exist. - */ -int button_start(struct Button* handle) -{ - struct Button* target = head_handle; - while(target) { - if(target == handle) return -1; //already exist. - target = target->next; - } - handle->next = head_handle; - head_handle = handle; - return 0; -} - -/** - * @brief Stop the button work, remove the handle off work list. - * @param handle: target handle strcut. - * @retval None - */ -void button_stop(struct Button* handle) -{ - struct Button** curr; - for(curr = &head_handle; *curr; ) { - struct Button* entry = *curr; - if (entry == handle) { - *curr = entry->next; -// free(entry); - } else - curr = &entry->next; - } -} - -/** - * @brief background ticks, timer repeat invoking interval 5ms. - * @param None. - * @retval None - */ -void button_ticks() -{ - struct Button* target; - for(target=head_handle; target; target=target->next) { - button_handler(target); - } -} - diff --git a/firmware/stm32/smart_dormitory/User/MultiButton/multi_button.h b/firmware/stm32/smart_dormitory/User/MultiButton/multi_button.h deleted file mode 100644 index 6cf54d74..00000000 --- a/firmware/stm32/smart_dormitory/User/MultiButton/multi_button.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2016 Zibin Zheng - * All rights reserved - */ - -#ifndef _MULTI_BUTTON_H_ -#define _MULTI_BUTTON_H_ - -#include "stdint.h" -#include "string.h" - -//According to your need to modify the constants. -#define TICKS_INTERVAL 5 //ms -#define DEBOUNCE_TICKS 3 //MAX 8 -#define SHORT_TICKS (300 /TICKS_INTERVAL) -#define LONG_TICKS (1000 /TICKS_INTERVAL) - - -typedef void (*BtnCallback)(void*); - -typedef enum { - PRESS_DOWN = 0, - PRESS_UP, - PRESS_REPEAT, - SINGLE_CLICK, - DOUBLE_CLICK, - LONG_PRESS_START, - LONG_PRESS_HOLD, - number_of_event, - NONE_PRESS -}PressEvent; - -typedef struct Button { - uint16_t ticks; - uint8_t repeat : 4; - uint8_t event : 4; - uint8_t state : 3; - uint8_t debounce_cnt : 3; - uint8_t active_level : 1; - uint8_t button_level : 1; - uint8_t (*hal_button_Level)(void); - BtnCallback cb[number_of_event]; - struct Button* next; -}Button; - -#ifdef __cplusplus -extern "C" { -#endif - -void button_init(struct Button* handle, uint8_t(*pin_level)(), uint8_t active_level); -void button_attach(struct Button* handle, PressEvent event, BtnCallback cb); -PressEvent get_button_event(struct Button* handle); -int button_start(struct Button* handle); -void button_stop(struct Button* handle); -void button_ticks(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/firmware/stm32/smart_dormitory/User/Process/process.c b/firmware/stm32/smart_dormitory/User/Process/process.c deleted file mode 100644 index 67b231fc..00000000 --- a/firmware/stm32/smart_dormitory/User/Process/process.c +++ /dev/null @@ -1,62 +0,0 @@ -/****************************************Copyright (c)**************************************************** -** -** File name: process.c -** Created by: XiaoYi -** Created date: 2020-10-16 -** Version: v1.0 -** Descriptions: The original -** Link address: https://blog.csdn.net/weixin_45006076 -** -*********************************************************************************************************/ - -#include "process.h" -#include "gpio.h" -#include "flash.h" -#include "tim.h" -#include "oled.h" - -/* - SG90ĶҪƶ PWM źƵ50HzңΪ 20ms PWM źţźŵĸߵƽ0.5ms - 2.5ms֮ʱӦתĽǶȣӦ - valueֵ ߵƽ תǶ - 50 0.5ms 0 - 100 1ms 45 - 150 1.5ms 90 - 200 2ms 135 - 250 2.5ms 180 -*/ -void set_sg90(int value) // ģ⿪ -{ - __HAL_TIM_SET_COMPARE(&htim4, TIM_CHANNEL_1, value); -} - -void start_buzz(void) -{ - BUZZ = 1; -} - -void stop_buzz(void) -{ - BUZZ = 1; -} - -void process_local_handle(uint16_t value_humi) -{ - /* ʪСϵͳõСֵתˮʪȳֵʱֹͣˮرյ */ -; -} - -void process_report_data(void) -{ - uint8_t send_buff[12]; - - // ǰϵͳ״̬ʱ - -} - -void process_handle_wifi_data(void) -{ - int i = 0; - - -} - diff --git a/firmware/stm32/smart_dormitory/User/Process/process.h b/firmware/stm32/smart_dormitory/User/Process/process.h deleted file mode 100644 index ab85db81..00000000 --- a/firmware/stm32/smart_dormitory/User/Process/process.h +++ /dev/null @@ -1,31 +0,0 @@ -/****************************************Copyright (c)**************************************************** -** -** File name: process.h -** Created by: XiaoYi -** Created date: 2020-10-16 -** Version: v1.0 -** Descriptions: The original -** Link address: https://blog.csdn.net/weixin_45006076 -** -*********************************************************************************************************/ - -#ifndef __PROCESS_H__ -#define __PROCESS_H__ - -#include "main.h" - -/* ָ */ -#define BUZZ PBout(0) - -void start_buzz(void); - -void stop_buzz(void); - -void process_local_handle(uint16_t value_humi); - -void process_report_data(void); - -void process_handle_wifi_data(void); - -#endif - diff --git a/firmware/stm32/smart_dormitory/User/RC522/rc522.c b/firmware/stm32/smart_dormitory/User/RC522/rc522.c deleted file mode 100644 index f2b373e8..00000000 --- a/firmware/stm32/smart_dormitory/User/RC522/rc522.c +++ /dev/null @@ -1,616 +0,0 @@ -#include "rc522.h" -#include "spi.h" - -/** - * : ӴFlashȡһֽ - * : - * ֵ: uint8_tȡ - * ˵ This function must be used only if the Start_Read_Sequence - * function has been previously called. - */ -uint8_t SPI_FLASH_ReadByte(void) -{ - uint8_t d_read,d_send=Dummy_Byte; - if(HAL_SPI_TransmitReceive(&hspi2,&d_send,&d_read,1,0xFFFFFF)!=HAL_OK) - d_read=Dummy_Byte; - - return d_read; -} - -/** - * : Flashȡдһֽݲһֽ - * : byte - * ֵ: uint8_tյ - * ˵ - */ -uint8_t SPI_FLASH_SendByte(uint8_t byte) -{ - uint8_t d_read,d_send=byte; - if(HAL_SPI_TransmitReceive(&hspi2,&d_send,&d_read,1,0xFFFFFF)!=HAL_OK) - d_read=Dummy_Byte; - - return d_read; -} - -/* - * ReadRawRC - * RC522Ĵ - * ucAddressĴַ - * : Ĵĵǰֵ - * ڲ - */ -uint8_t ReadRawRC ( uint8_t ucAddress ) -{ - uint8_t ucAddr, ucReturn; - - ucAddr = ( ( ucAddress << 1 ) & 0x7E ) | 0x80; - - macRC522_CS_Enable() ; - - SPI_FLASH_SendByte ( ucAddr ); - - ucReturn = SPI_FLASH_ReadByte (); - - macRC522_CS_Disable(); - - return ucReturn; -} - -/* - * WriteRawRC - * дRC522Ĵ - * ucAddressĴַ - * ucValueдĴֵ - * : - * ڲ - */ -void WriteRawRC ( uint8_t ucAddress, uint8_t ucValue ) -{ - uint8_t ucAddr; - - ucAddr = ( ucAddress << 1 ) & 0x7E; - - macRC522_CS_Enable() ; - SPI_FLASH_SendByte ( ucAddr ); - SPI_FLASH_SendByte ( ucValue ); - - macRC522_CS_Disable(); -} - -/* - * SetBitMask - * RC522Ĵλ - * ucRegĴַ - * ucMaskλֵ - * : - * ڲ - */ -void SetBitMask ( uint8_t ucReg, uint8_t ucMask ) -{ - uint8_t ucTemp; - - ucTemp = ReadRawRC ( ucReg ); - WriteRawRC ( ucReg, ucTemp | ucMask ); // set bit mask -} - -/* - * ClearBitMask - * RC522Ĵλ - * ucRegĴַ - * ucMaskλֵ - * : - * ڲ - */ -void ClearBitMask ( uint8_t ucReg, uint8_t ucMask ) -{ - uint8_t ucTemp; - - ucTemp = ReadRawRC ( ucReg ); - - WriteRawRC ( ucReg, ucTemp & ( ~ ucMask) ); // clear bit mask -} - -/* - * PcdAntennaOn - * - * - * : - * ڲ - */ -void PcdAntennaOn ( void ) -{ - uint8_t uc; - - uc = ReadRawRC ( TxControlReg ); - - if ( ! ( uc & 0x03 ) ) - SetBitMask(TxControlReg, 0x03); -} - - -/* - * PcdAntennaOff - * - * - * : - * ڲ - */ -void PcdAntennaOff ( void ) -{ - ClearBitMask ( TxControlReg, 0x03 ); -} - -/* - * PcdRese - * λRC522 - * - * : - * ⲿ - */ -void PcdReset ( void ) -{ - macRC522_Reset_Disable(); - - HAL_Delay ( 1 ); - - macRC522_Reset_Enable(); - - HAL_Delay ( 1 ); - - macRC522_Reset_Disable(); - - HAL_Delay ( 1 ); - - WriteRawRC ( CommandReg, 0x0f ); - - while ( ReadRawRC ( CommandReg ) & 0x10 ); - - HAL_Delay ( 1 ); - - WriteRawRC ( ModeReg, 0x3D ); //巢ͺͽճģʽ MifareͨѶCRCʼֵ0x6363 - - WriteRawRC ( TReloadRegL, 30 ); //16λʱλ - WriteRawRC ( TReloadRegH, 0 ); //16λʱλ - - WriteRawRC ( TModeReg, 0x8D ); //ڲʱ - - WriteRawRC ( TPrescalerReg, 0x3E ); //öʱƵϵ - - WriteRawRC ( TxAutoReg, 0x40 ); //ƷźΪ100%ASK -} - -/* - * M500PcdConfigISOType - * RC522Ĺʽ - * ucTypeʽ - * : - * ⲿ - */ -void M500PcdConfigISOType ( uint8_t ucType ) -{ - if ( ucType == 'A') //ISO14443_A - { - ClearBitMask ( Status2Reg, 0x08 ); - - WriteRawRC ( ModeReg, 0x3D );//3F - - WriteRawRC ( RxSelReg, 0x86 );//84 - - WriteRawRC( RFCfgReg, 0x7F ); //4F - - WriteRawRC( TReloadRegL, 30 );//tmoLength);// TReloadVal = 'h6a =tmoLength(dec) - - WriteRawRC ( TReloadRegH, 0 ); - - WriteRawRC ( TModeReg, 0x8D ); - - WriteRawRC ( TPrescalerReg, 0x3E ); - - HAL_Delay ( 2 ); - - PcdAntennaOn ();// - } -} - -/* - * PcdComMF522 - * ͨRC522ISO14443ͨѶ - * ucCommandRC522 - * pInDataͨRC522͵Ƭ - * ucInLenByteݵֽڳ - * pOutDataյĿƬ - * pOutLenBitݵλ - * : ״ֵ̬ - * = MI_OKɹ - * ڲ - */ -char PcdComMF522 ( uint8_t ucCommand, uint8_t * pInData, uint8_t ucInLenByte, uint8_t * pOutData, uint32_t * pOutLenBit ) -{ - char cStatus = MI_ERR; - uint8_t ucIrqEn = 0x00; - uint8_t ucWaitFor = 0x00; - uint8_t ucLastBits; - uint8_t ucN; - uint32_t ul; - - switch ( ucCommand ) - { - case PCD_AUTHENT: //Mifare֤ - ucIrqEn = 0x12; //жErrIEn жIdleIEn - ucWaitFor = 0x10; //֤Ѱȴʱ ѯжϱ־λ - break; - - case PCD_TRANSCEIVE: //շ ͽ - ucIrqEn = 0x77; //TxIEn RxIEn IdleIEn LoAlertIEn ErrIEn TimerIEn - ucWaitFor = 0x30; //Ѱȴʱ ѯжϱ־λ жϱ־λ - break; - - default: - break; - } - - WriteRawRC ( ComIEnReg, ucIrqEn | 0x80 ); //IRqInvλܽIRQStatus1RegIRqλֵ෴ - ClearBitMask ( ComIrqReg, 0x80 ); //Set1λʱCommIRqRegλ - WriteRawRC ( CommandReg, PCD_IDLE ); //д - SetBitMask ( FIFOLevelReg, 0x80 ); //λFlushBufferڲFIFOĶдָԼErrRegBufferOvfl־λ - - for ( ul = 0; ul < ucInLenByte; ul ++ ) - WriteRawRC ( FIFODataReg, pInData [ ul ] ); //дݽFIFOdata - - WriteRawRC ( CommandReg, ucCommand ); //д - - if ( ucCommand == PCD_TRANSCEIVE ) - SetBitMask(BitFramingReg,0x80); //StartSendλݷ λշʹʱЧ - - ul = 1000;//ʱƵʵM1ȴʱ25ms - do //֤ Ѱȴʱ - { - ucN = ReadRawRC ( ComIrqReg ); //ѯ¼ж - ul --; - } while ( ( ul != 0 ) && ( ! ( ucN & 0x01 ) ) && ( ! ( ucN & ucWaitFor ) ) ); //˳i=0,ʱжϣд - - ClearBitMask ( BitFramingReg, 0x80 ); //StartSendλ - if ( ul != 0 ) - { - if ( ! ( ReadRawRC ( ErrorReg ) & 0x1B ) ) //־ĴBufferOfI CollErr ParityErr ProtocolErr - { - cStatus = MI_OK; - if ( ucN & ucIrqEn & 0x01 ) //Ƿʱж - cStatus = MI_NOTAGERR; - - if ( ucCommand == PCD_TRANSCEIVE ) - { - ucN = ReadRawRC ( FIFOLevelReg ); //FIFOбֽ - - ucLastBits = ReadRawRC ( ControlReg ) & 0x07; //յֽڵЧλ - - if ( ucLastBits ) - * pOutLenBit = ( ucN - 1 ) * 8 + ucLastBits; //Nֽȥ1һֽڣ+һλλ ȡλ - else - * pOutLenBit = ucN * 8; //յֽֽЧ - - if ( ucN == 0 ) - ucN = 1; - - if ( ucN > MAXRLEN ) - ucN = MAXRLEN; - - for ( ul = 0; ul < ucN; ul ++ ) - pOutData [ ul ] = ReadRawRC ( FIFODataReg ); - } - }else - { - cStatus = MI_ERR; - } - } - - SetBitMask ( ControlReg, 0x80 ); // stop timer now - WriteRawRC ( CommandReg, PCD_IDLE ); - - return cStatus; -} - -/* - * PcdRequest - * Ѱ - * ucReq_codeѰʽ - * = 0x52ѰӦз14443A׼Ŀ - * = 0x26Ѱδ״̬Ŀ - * pTagTypeƬʹ - * = 0x4400Mifare_UltraLight - * = 0x0400Mifare_One(S50) - * = 0x0200Mifare_One(S70) - * = 0x0800Mifare_Pro(X)) - * = 0x4403Mifare_DESFire - * : ״ֵ̬ - * = MI_OKɹ - * ⲿ - */ -char PcdRequest ( uint8_t ucReq_code, uint8_t * pTagType ) -{ - char cStatus; - uint8_t ucComMF522Buf [ MAXRLEN ]; - uint32_t ulLen; - - - ClearBitMask ( Status2Reg, 0x08 ); //ָʾMIFARECyptolԪͨԼпͨűܵ - WriteRawRC ( BitFramingReg, 0x07 ); // ͵һֽڵ λ - SetBitMask ( TxControlReg, 0x03 ); //TX1,TX2ܽŵźŴݾ͵Ƶ13.56زź - - ucComMF522Buf [ 0 ] = ucReq_code; // Ƭ - - cStatus = PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 1, ucComMF522Buf, & ulLen ); //Ѱ - - if ( ( cStatus == MI_OK ) && ( ulLen == 0x10 ) ) //Ѱɹؿ - { - * pTagType = ucComMF522Buf [ 0 ]; - * ( pTagType + 1 ) = ucComMF522Buf [ 1 ]; - } - - else - cStatus = MI_ERR; - - return cStatus; -} - -/* - * PcdAnticoll - * ײ - * pSnrƬкţ4ֽ - * : ״ֵ̬ - * = MI_OKɹ - * ⲿ - */ -char PcdAnticoll ( uint8_t * pSnr ) -{ - char cStatus; - uint8_t uc, ucSnr_check = 0; - uint8_t ucComMF522Buf [ MAXRLEN ]; - uint32_t ulLen; - - ClearBitMask ( Status2Reg, 0x08 ); //MFCryptol Onλ ֻгɹִMFAuthent󣬸λλ - WriteRawRC ( BitFramingReg, 0x00); //Ĵ ֹͣշ - ClearBitMask ( CollReg, 0x80 ); //ValuesAfterCollнյλڳͻ - - ucComMF522Buf [ 0 ] = 0x93; //Ƭͻ - ucComMF522Buf [ 1 ] = 0x20; - - cStatus = PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 2, ucComMF522Buf, & ulLen);//뿨Ƭͨ - - if ( cStatus == MI_OK) //ͨųɹ - { - for ( uc = 0; uc < 4; uc ++ ) - { - * ( pSnr + uc ) = ucComMF522Buf [ uc ]; //UID - ucSnr_check ^= ucComMF522Buf [ uc ]; - } - - if ( ucSnr_check != ucComMF522Buf [ uc ] ) - { - cStatus = MI_ERR; - } - } - - SetBitMask ( CollReg, 0x80 ); - - return cStatus; -} - -/* - * CalulateCRC - * RC522CRC16 - * pIndataCRC16 - * ucLenCRC16ֽڳ - * pOutDatażŵ׵ַ - * : - * ڲ - */ -void CalulateCRC ( uint8_t * pIndata, uint8_t ucLen, uint8_t * pOutData ) -{ - uint8_t uc, ucN; - - ClearBitMask(DivIrqReg,0x04); - WriteRawRC(CommandReg,PCD_IDLE); - SetBitMask(FIFOLevelReg,0x80); - - for ( uc = 0; uc < ucLen; uc ++) - WriteRawRC ( FIFODataReg, * ( pIndata + uc ) ); - - WriteRawRC ( CommandReg, PCD_CALCCRC ); - - uc = 0xFF; - do - { - ucN = ReadRawRC ( DivIrqReg ); - uc --; - } while ( ( uc != 0 ) && ! ( ucN & 0x04 ) ); - - pOutData [ 0 ] = ReadRawRC ( CRCResultRegL ); - pOutData [ 1 ] = ReadRawRC ( CRCResultRegM ); - -} - -/* - * PcdSelect - * ѡƬ - * pSnrƬкţ4ֽ - * : ״ֵ̬ - * = MI_OKɹ - * ⲿ - */ -char PcdSelect ( uint8_t * pSnr ) -{ - char ucN; - uint8_t uc; - uint8_t ucComMF522Buf [ MAXRLEN ]; - uint32_t ulLen; - - ucComMF522Buf [ 0 ] = PICC_ANTICOLL1; - ucComMF522Buf [ 1 ] = 0x70; - ucComMF522Buf [ 6 ] = 0; - - for ( uc = 0; uc < 4; uc ++ ) - { - ucComMF522Buf [ uc + 2 ] = * ( pSnr + uc ); - ucComMF522Buf [ 6 ] ^= * ( pSnr + uc ); - } - - CalulateCRC ( ucComMF522Buf, 7, & ucComMF522Buf [ 7 ] ); - ClearBitMask ( Status2Reg, 0x08 ); - - ucN = PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 9, ucComMF522Buf, & ulLen ); - - if ( ( ucN == MI_OK ) && ( ulLen == 0x18 ) ) - ucN = MI_OK; - else - ucN = MI_ERR; - - return ucN; -} - -/* - * PcdAuthState - * ֤Ƭ - * ucAuth_mode֤ģʽ - * = 0x60֤AԿ - * = 0x61֤BԿ - * uint8_t ucAddrַ - * pKey - * pSnrƬкţ4ֽ - * : ״ֵ̬ - * = MI_OKɹ - * ⲿ - */ -char PcdAuthState ( uint8_t ucAuth_mode, uint8_t ucAddr, uint8_t * pKey, uint8_t * pSnr ) -{ - char cStatus; - uint8_t uc, ucComMF522Buf [ MAXRLEN ]; - uint32_t ulLen; - - ucComMF522Buf [ 0 ] = ucAuth_mode; - ucComMF522Buf [ 1 ] = ucAddr; - - for ( uc = 0; uc < 6; uc ++ ) - ucComMF522Buf [ uc + 2 ] = * ( pKey + uc ); - - for ( uc = 0; uc < 6; uc ++ ) - ucComMF522Buf [ uc + 8 ] = * ( pSnr + uc ); - - cStatus = PcdComMF522 ( PCD_AUTHENT, ucComMF522Buf, 12, ucComMF522Buf, & ulLen ); - - if ( ( cStatus != MI_OK ) || ( ! ( ReadRawRC ( Status2Reg ) & 0x08 ) ) ) - cStatus = MI_ERR; - - return cStatus; -} - -/* - * PcdWrite - * дݵM1һ - * uint8_t ucAddrַ - * pDataдݣ16ֽ - * : ״ֵ̬ - * = MI_OKɹ - * ⲿ - */ -char PcdWrite ( uint8_t ucAddr, uint8_t * pData ) -{ - char cStatus; - uint8_t uc, ucComMF522Buf [ MAXRLEN ]; - uint32_t ulLen; - - ucComMF522Buf [ 0 ] = PICC_WRITE; - ucComMF522Buf [ 1 ] = ucAddr; - - CalulateCRC ( ucComMF522Buf, 2, & ucComMF522Buf [ 2 ] ); - - cStatus = PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 4, ucComMF522Buf, & ulLen ); - - if ( ( cStatus != MI_OK ) || ( ulLen != 4 ) || ( ( ucComMF522Buf [ 0 ] & 0x0F ) != 0x0A ) ) - cStatus = MI_ERR; - - if ( cStatus == MI_OK ) - { - //memcpy(ucComMF522Buf, pData, 16); - for ( uc = 0; uc < 16; uc ++ ) - ucComMF522Buf [ uc ] = * ( pData + uc ); - - CalulateCRC ( ucComMF522Buf, 16, & ucComMF522Buf [ 16 ] ); - - cStatus = PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 18, ucComMF522Buf, & ulLen ); - - if ( ( cStatus != MI_OK ) || ( ulLen != 4 ) || ( ( ucComMF522Buf [ 0 ] & 0x0F ) != 0x0A ) ) - cStatus = MI_ERR; - } - return cStatus; -} - -/* - * PcdRead - * ȡM1һ - * uint8_t ucAddrַ - * pDataݣ16ֽ - * : ״ֵ̬ - * = MI_OKɹ - * ⲿ - */ -char PcdRead ( uint8_t ucAddr, uint8_t * pData ) -{ - char cStatus; - uint8_t uc, ucComMF522Buf [ MAXRLEN ]; - uint32_t ulLen; - - ucComMF522Buf [ 0 ] = PICC_READ; - ucComMF522Buf [ 1 ] = ucAddr; - - CalulateCRC ( ucComMF522Buf, 2, & ucComMF522Buf [ 2 ] ); - cStatus = PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 4, ucComMF522Buf, & ulLen ); - - if ( ( cStatus == MI_OK ) && ( ulLen == 0x90 ) ) - { - for ( uc = 0; uc < 16; uc ++ ) - * ( pData + uc ) = ucComMF522Buf [ uc ]; - }else - cStatus = MI_ERR; - return cStatus; -} - -/* - * PcdHalt - * Ƭ״̬ - * - * : ״ֵ̬ - * = MI_OKɹ - * ⲿ - */ -char PcdHalt( void ) -{ - uint8_t ucComMF522Buf [ MAXRLEN ]; - uint32_t ulLen; - - ucComMF522Buf [ 0 ] = PICC_HALT; - ucComMF522Buf [ 1 ] = 0; - - CalulateCRC ( ucComMF522Buf, 2, & ucComMF522Buf [ 2 ] ); - PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 4, ucComMF522Buf, & ulLen ); - - return MI_OK; -} - -void IC_CMT ( uint8_t * UID, uint8_t * KEY, uint8_t RW, uint8_t * Dat ) -{ - uint8_t ucArray_ID [ 4 ] = { 0 };//ȺICͺUID(ICк) - - PcdRequest ( 0x52, ucArray_ID );//Ѱ - PcdAnticoll ( ucArray_ID );//ײ - PcdSelect ( UID );//ѡ - PcdAuthState ( 0x60, 0x10, KEY, UID );//У - - if ( RW )//дѡ1Ƕ0д - PcdRead ( 0x10, Dat ); - else - PcdWrite ( 0x10, Dat ); - - PcdHalt (); -} - diff --git a/firmware/stm32/smart_dormitory/User/RC522/rc522.h b/firmware/stm32/smart_dormitory/User/RC522/rc522.h deleted file mode 100644 index ebb41372..00000000 --- a/firmware/stm32/smart_dormitory/User/RC522/rc522.h +++ /dev/null @@ -1,175 +0,0 @@ -/****************************************Copyright (c)**************************************************** -** -** File name: light.h -** Created by: XiaoYi -** Created date: 2020-10-16 -** Version: v1.0 -** Descriptions: The original -** Link address: https://blog.csdn.net/weixin_45006076 -** -*********************************************************************************************************/ - -#ifndef __RC522_H__ -#define __RC522_H__ - -#include "main.h" - -//MF522 -///////////////////////////////////////////////////////////////////// -#define PCD_IDLE 0x00 //ȡǰ -#define PCD_AUTHENT 0x0E //֤Կ -#define PCD_RECEIVE 0x08 // -#define PCD_TRANSMIT 0x04 // -#define PCD_TRANSCEIVE 0x0C //Ͳ -#define PCD_RESETPHASE 0x0F //λ -#define PCD_CALCCRC 0x03 //CRC - -///////////////////////////////////////////////////////////////////// -//Mifare_OneƬ -///////////////////////////////////////////////////////////////////// -#define PICC_REQIDL 0x26 //Ѱδ״̬ -#define PICC_REQALL 0x52 //Ѱȫ -#define PICC_ANTICOLL1 0x93 //ײ -#define PICC_ANTICOLL2 0x95 //ײ -#define PICC_AUTHENT1A 0x60 //֤AԿ -#define PICC_AUTHENT1B 0x61 //֤BԿ -#define PICC_READ 0x30 // -#define PICC_WRITE 0xA0 //д -#define PICC_DECREMENT 0xC0 //ۿ -#define PICC_INCREMENT 0xC1 //ֵ -#define PICC_RESTORE 0xC2 //ݵ -#define PICC_TRANSFER 0xB0 //滺 -#define PICC_HALT 0x50 // - -///////////////////////////////////////////////////////////////////// -//MF522 FIFOȶ -///////////////////////////////////////////////////////////////////// -#define DEF_FIFO_LENGTH 64 //FIFO size=64byte -#define MAXRLEN 18 - -///////////////////////////////////////////////////////////////////// -//MF522Ĵ -///////////////////////////////////////////////////////////////////// -// PAGE 0 -#define RFU00 0x00 -#define CommandReg 0x01 -#define ComIEnReg 0x02 -#define DivlEnReg 0x03 -#define ComIrqReg 0x04 -#define DivIrqReg 0x05 -#define ErrorReg 0x06 -#define Status1Reg 0x07 -#define Status2Reg 0x08 -#define FIFODataReg 0x09 -#define FIFOLevelReg 0x0A -#define WaterLevelReg 0x0B -#define ControlReg 0x0C -#define BitFramingReg 0x0D -#define CollReg 0x0E -#define RFU0F 0x0F -// PAGE 1 -#define RFU10 0x10 -#define ModeReg 0x11 -#define TxModeReg 0x12 -#define RxModeReg 0x13 -#define TxControlReg 0x14 -#define TxAutoReg 0x15 -#define TxSelReg 0x16 -#define RxSelReg 0x17 -#define RxThresholdReg 0x18 -#define DemodReg 0x19 -#define RFU1A 0x1A -#define RFU1B 0x1B -#define MifareReg 0x1C -#define RFU1D 0x1D -#define RFU1E 0x1E -#define SerialSpeedReg 0x1F -// PAGE 2 -#define RFU20 0x20 -#define CRCResultRegM 0x21 -#define CRCResultRegL 0x22 -#define RFU23 0x23 -#define ModWidthReg 0x24 -#define RFU25 0x25 -#define RFCfgReg 0x26 -#define GsNReg 0x27 -#define CWGsCfgReg 0x28 -#define ModGsCfgReg 0x29 -#define TModeReg 0x2A -#define TPrescalerReg 0x2B -#define TReloadRegH 0x2C -#define TReloadRegL 0x2D -#define TCounterValueRegH 0x2E -#define TCounterValueRegL 0x2F -// PAGE 3 -#define RFU30 0x30 -#define TestSel1Reg 0x31 -#define TestSel2Reg 0x32 -#define TestPinEnReg 0x33 -#define TestPinValueReg 0x34 -#define TestBusReg 0x35 -#define AutoTestReg 0x36 -#define VersionReg 0x37 -#define AnalogTestReg 0x38 -#define TestDAC1Reg 0x39 -#define TestDAC2Reg 0x3A -#define TestADCReg 0x3B -#define RFU3C 0x3C -#define RFU3D 0x3D -#define RFU3E 0x3E -#define RFU3F 0x3F - -///////////////////////////////////////////////////////////////////// -//MF522ͨѶʱصĴ -///////////////////////////////////////////////////////////////////// -#define MI_OK 0x26 -#define MI_NOTAGERR 0xcc -#define MI_ERR 0xbb - - - -/************************˿ں궨**********************************/ -#define macRC522_GPIO_CS_PORT GPIOB -#define macRC522_GPIO_CS_PIN GPIO_PIN_12 - -#define macRC522_GPIO_RST_PORT GPIOB -#define macRC522_GPIO_RST_PIN GPIO_PIN_7 - -#define macRC522_GPIO_SCK_PORT GPIOB -#define macRC522_GPIO_SCK_PIN GPIO_PIN_13 - -#define macRC522_GPIO_MOSI_PORT GPIOB -#define macRC522_GPIO_MOSI_PIN GPIO_PIN_15 - -#define macRC522_GPIO_MISO_PORT GPIOB -#define macRC522_GPIO_MISO_PIN GPIO_PIN_14 -/*********************************** RC522 궨*********************************************/ -#define macRC522_CS_Enable() HAL_GPIO_WritePin ( macRC522_GPIO_CS_PORT, macRC522_GPIO_CS_PIN ,GPIO_PIN_RESET) -#define macRC522_CS_Disable() HAL_GPIO_WritePin ( macRC522_GPIO_CS_PORT, macRC522_GPIO_CS_PIN ,GPIO_PIN_SET) - -#define macRC522_Reset_Enable() HAL_GPIO_WritePin( macRC522_GPIO_RST_PORT, macRC522_GPIO_RST_PIN,GPIO_PIN_RESET ) -#define macRC522_Reset_Disable() HAL_GPIO_WritePin ( macRC522_GPIO_RST_PORT, macRC522_GPIO_RST_PIN,GPIO_PIN_SET) - -#define macRC522_SCK_0() HAL_GPIO_WritePin( macRC522_GPIO_SCK_PORT, macRC522_GPIO_SCK_PIN,GPIO_PIN_RESET ) -#define macRC522_SCK_1() HAL_GPIO_WritePin ( macRC522_GPIO_SCK_PORT, macRC522_GPIO_SCK_PIN,GPIO_PIN_SET ) - -#define macRC522_MOSI_0() HAL_GPIO_WritePin( macRC522_GPIO_MOSI_PORT, macRC522_GPIO_MOSI_PIN,GPIO_PIN_RESET ) -#define macRC522_MOSI_1() HAL_GPIO_WritePin ( macRC522_GPIO_MOSI_PORT, macRC522_GPIO_MOSI_PIN,GPIO_PIN_SET ) - -#define macRC522_MISO_GET() HAL_GPIO_ReadPin ( macRC522_GPIO_MISO_PORT, macRC522_GPIO_MISO_PIN ) - -#define macRC522_DELAY() HAL_Delay(20) - -#define Dummy_Byte 0xFF - - -void PcdReset ( void ); //λ -void M500PcdConfigISOType ( uint8_t type ); //ʽ -char PcdRequest ( uint8_t req_code, uint8_t * pTagType ); //Ѱ -char PcdAnticoll ( uint8_t * pSnr); // -char PcdAuthState ( uint8_t ucAuth_mode, uint8_t ucAddr, uint8_t * pKey, uint8_t * pSnr );//֤Ƭ -char PcdRead ( uint8_t ucAddr, uint8_t * pData ); // -char PcdSelect ( uint8_t * pSnr ); //ѡ - -#endif - diff --git a/firmware/stm32/smart_dormitory/User/dht11/dht11.c b/firmware/stm32/smart_dormitory/User/dht11/dht11.c deleted file mode 100644 index a0a2db4b..00000000 --- a/firmware/stm32/smart_dormitory/User/dht11/dht11.c +++ /dev/null @@ -1,196 +0,0 @@ -/****************************************Copyright (c)**************************************************** -** -** File name: humi.c -** Created by: XiaoYi -** Created date: 2020-10-16 -** Version: v1.0 -** Descriptions: The original -** Link address: https://blog.csdn.net/weixin_45006076 -** -*********************************************************************************************************/ - -#include "dht11.h" - - -/* ˽Ͷ --------------------------------------------------------------*/ -/* ˽к궨 ----------------------------------------------------------------*/ - -/* ˽б ------------------------------------------------------------------*/ -/* չ ------------------------------------------------------------------*/ -/* ˽кԭ --------------------------------------------------------------*/ -static void DHT11_Mode_IPU(void); -static void DHT11_Mode_Out_PP(void); -static uint8_t dht11_readByte(void); - -/* --------------------------------------------------------------------*/ -/** - * : - * : - * ֵ: - * ˵ - */ -static void dht11_delay(uint16_t time) -{ - uint8_t i; - - while(time) - { - for (i = 0; i < 10; i++) - { - - } - time--; - } -} - -/** - * : DHT11 ʼ - * : - * ֵ: - * ˵ - */ -void dht11_init ( void ) -{ - DHT11_Dout_GPIO_CLK_ENABLE(); - - DHT11_Mode_Out_PP(); - - DHT11_Dout_HIGH(); // GPIO -} - -/** - * : ʹDHT11-DATAűΪģʽ - * : - * ֵ: - * ˵ - */ -static void DHT11_Mode_IPU(void) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /* 蹦GPIO */ - GPIO_InitStruct.Pin = DHT11_Dout_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_PULLUP; - HAL_GPIO_Init(DHT11_Dout_PORT, &GPIO_InitStruct); -} - -/** - * : ʹDHT11-DATAűΪģʽ - * : - * ֵ: - * ˵ - */ -static void DHT11_Mode_Out_PP(void) -{ - GPIO_InitTypeDef GPIO_InitStruct; - - /* 蹦GPIO */ - GPIO_InitStruct.Pin = DHT11_Dout_PIN; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; - HAL_GPIO_Init(DHT11_Dout_PORT, &GPIO_InitStruct); -} - -/** - * : DHT11ȡһֽڣMSB - * : - * ֵ: - * ˵ - */ -static uint8_t dht11_readByte ( void ) -{ - uint8_t i, temp=0; - - for(i=0;i<8;i++) - { - /*ÿbit50us͵ƽÿʼѯֱӻ 50us ͵ƽ */ - while(DHT11_Data_IN()==GPIO_PIN_RESET); - - /*DHT11 26~28usĸߵƽʾ070usߵƽʾ1 - *ͨ x usĵƽ״ x ʱ - */ - dht11_delay(40); //ʱx us ʱҪ0ʱ伴 - - if(DHT11_Data_IN()==GPIO_PIN_SET)/* x usΪߵƽʾݡ1 */ - { - /* ȴ1ĸߵƽ */ - while(DHT11_Data_IN()==GPIO_PIN_SET); - - temp|=(uint8_t)(0x01<<(7-i)); //ѵ7-iλ1MSB - } - else // x usΪ͵ƽʾݡ0 - { - temp&=(uint8_t)~(0x01<<(7-i)); //ѵ7-iλ0MSB - } - } - return temp; -} - -/** - * : һݴΪ40bitλȳ - * : DHT11_Data:DHT11 - * ֵ: ERROR ȡ - * SUCCESSȡɹ - * ˵ 8bit ʪ + 8bit ʪС + 8bit ¶ + 8bit ¶С + 8bit У - */ -uint8_t dht11_get_tempHumi(DHT11_Data_TypeDef *DHT11_Data) -{ - uint8_t temp; - uint16_t humi_temp; - - /*ģʽ*/ - DHT11_Mode_Out_PP(); - /**/ - DHT11_Dout_LOW(); - /*ʱ18ms*/ - delay_ms(18); - - /* ʱ30us*/ - DHT11_Dout_HIGH(); - - dht11_delay(30); //ʱ30us - - /*Ϊ жϴӻӦź*/ - DHT11_Mode_IPU(); - - /*жϴӻǷе͵ƽӦź 粻ӦӦ*/ - if(DHT11_Data_IN()==GPIO_PIN_RESET) - { - /*ѯֱӻ 80us ͵ƽ ӦźŽ*/ - while(DHT11_Data_IN()==GPIO_PIN_RESET); - - /*ѯֱӻ 80us ߵƽ źŽ*/ - while(DHT11_Data_IN()==GPIO_PIN_SET); - - /*ʼ*/ - DHT11_Data->humi_high8bit= dht11_readByte(); - DHT11_Data->humi_low8bit = dht11_readByte(); - DHT11_Data->temp_high8bit= dht11_readByte(); - DHT11_Data->temp_low8bit = dht11_readByte(); - DHT11_Data->check_sum = dht11_readByte(); - - /*ȡŸΪģʽ*/ - DHT11_Mode_Out_PP(); - /**/ - DHT11_Dout_HIGH(); - - /* ݽд */ - humi_temp=DHT11_Data->humi_high8bit*100+DHT11_Data->humi_low8bit; - DHT11_Data->humidity =(float)humi_temp/100; - - humi_temp=DHT11_Data->temp_high8bit*100+DHT11_Data->temp_low8bit; - DHT11_Data->temperature=(float)humi_temp/100; - - /*ȡǷȷ*/ - temp = DHT11_Data->humi_high8bit + DHT11_Data->humi_low8bit + - DHT11_Data->temp_high8bit+ DHT11_Data->temp_low8bit; - if(DHT11_Data->check_sum==temp) - { - return SUCCESS; - } - else - return ERROR; - }else - return ERROR; -} \ No newline at end of file diff --git a/firmware/stm32/smart_dormitory/User/dht11/dht11.h b/firmware/stm32/smart_dormitory/User/dht11/dht11.h deleted file mode 100644 index 15bc5458..00000000 --- a/firmware/stm32/smart_dormitory/User/dht11/dht11.h +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************Copyright (c)**************************************************** -** -** File name: dht11.h -** Created by: xxx -** Created date: 2020-10-16 -** Version: v1.0 -** Descriptions: The original -** -*********************************************************************************************************/ - -#ifndef __DHT11_H__ -#define __DHT11_H__ - -#include "main.h" -/* Ͷ ------------------------------------------------------------------*/ -/************************ DHT11 Ͷ******************************/ -typedef struct -{ - uint8_t humi_high8bit; //ԭʼݣʪȸ8λ - uint8_t humi_low8bit; //ԭʼݣʪȵ8λ - uint8_t temp_high8bit; //ԭʼݣ¶ȸ8λ - uint8_t temp_low8bit; //ԭʼݣ¶ȸ8λ - uint8_t check_sum; //У - float humidity; //ʵʪ - float temperature; //ʵ¶ -} DHT11_Data_TypeDef; - -/* 궨 -------------------------------------------------------------------*/ -/*********************** DHT11 Ŷ **************************/ -#define DHT11_Dout_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() -#define DHT11_Dout_PORT GPIOB -#define DHT11_Dout_PIN GPIO_PIN_5 - -/*********************** DHT11 궨 ****************************/ -#define DHT11_Dout_LOW() HAL_GPIO_WritePin(DHT11_Dout_PORT,DHT11_Dout_PIN,GPIO_PIN_RESET) -#define DHT11_Dout_HIGH() HAL_GPIO_WritePin(DHT11_Dout_PORT,DHT11_Dout_PIN,GPIO_PIN_SET) -#define DHT11_Data_IN() HAL_GPIO_ReadPin(DHT11_Dout_PORT,DHT11_Dout_PIN) - -/* չ ------------------------------------------------------------------*/ -/* ------------------------------------------------------------------*/ -void dht11_init( void ); -uint8_t dht11_get_tempHumi(DHT11_Data_TypeDef * DHT11_Data); - -#endif - diff --git a/firmware/stm32/smart_dormitory/User/flash/flash.c b/firmware/stm32/smart_dormitory/User/flash/flash.c deleted file mode 100644 index 64105df2..00000000 --- a/firmware/stm32/smart_dormitory/User/flash/flash.c +++ /dev/null @@ -1,71 +0,0 @@ -/****************************************Copyright (c)**************************************************** -** -** File name: humi.c -** Created by: Brown Lee -** Created date: 2020-10-16 -** Version: v1.0 -** Descriptions: The original -** Link address: https://blog.csdn.net/weixin_45006076 -** -*********************************************************************************************************/ - -#include "flash.h" - -//ַָʼȡ -void FLASH_ReadMoreData(uint32_t startAddress,uint16_t *readData,uint16_t countToRead) -{ - uint16_t dataIndex; - for(dataIndex=0;dataIndex= (FLASH_BASE + 1024 * FLASH_SIZE))) - { - return;//Ƿַ - } - HAL_FLASH_Unlock(); //д -// offsetAddress=startAddress-FLASH_BASE; //ȥ0X08000000ʵƫƵַ -// sectorPosition=offsetAddress/FLASH_SIZE; //ַSTM32F103VET6Ϊ0~255 -// -// sectorStartAddress=sectorPosition*SECTOR_SIZE+FLASH_BASE; //Ӧ׵ַ - - HAL_FLASH_Unlock(); //Flash - - User_Flash.TypeErase = FLASH_TYPEERASE_PAGES; //Flashִҳֻ - User_Flash.PageAddress = startAddress; //Ҫĵַ - User_Flash.NbPages = 1; //˵Ҫҳ˲Min_Data = 1Max_Data =(ҳ-ʼҳֵ)ֵ֮ - - uint32_t PageError = 0; //PageError,ִᱻΪFLASHַ - HAL_FLASHEx_Erase(&User_Flash, &PageError); //ò - - for(dataIndex=0;dataIndexInstance == htim2.Instance) - { - button_ticks(); - } -} diff --git a/firmware/stm32/smart_dormitory/User/key_scan/key_scan.h b/firmware/stm32/smart_dormitory/User/key_scan/key_scan.h deleted file mode 100644 index 2c9adc53..00000000 --- a/firmware/stm32/smart_dormitory/User/key_scan/key_scan.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __KEY_SCAN_H -#define __KEY_SCAN_H - -#include "main.h" - -#define KEY1 0x40 -#define KEY2 0x41 -#define KEY3 0x42 - -typedef enum{ - KEY_NONE_PRESS, - KEY_SHORT_PRESS, - KEY_LONG_PRESS, -}key_event_e; - -typedef struct -{ - int enable; // ʹܣжϰǷ - int key; // - int type; // ͣkey_event_eж -}key_status_t; -extern key_status_t key_status; - - -void key_init(void); - -int key_scan(void); - -#endif - diff --git a/firmware/stm32/smart_dormitory/User/light/sensor_light.c b/firmware/stm32/smart_dormitory/User/light/sensor_light.c deleted file mode 100644 index 4b95e138..00000000 --- a/firmware/stm32/smart_dormitory/User/light/sensor_light.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************Copyright (c)**************************************************** -** -** File name: process.c -** Created by: XiaoYi -** Created date: 2020-10-16 -** Version: v1.0 -** Descriptions: The original -** Link address: https://blog.csdn.net/weixin_45006076 -** -*********************************************************************************************************/ - -#include "sensor_light.h" -#include "gpio.h" -#include "adc.h" - -uint16_t light_get_value(void) -{ - // ADCת - HAL_ADC_Start(&hadc1); - // ȴתɣڶʾʱʱ䣬λms - HAL_ADC_PollForConversion(&hadc1, 100); - return HAL_ADC_GetValue(&hadc1); -} - -uint8_t light_get_average_value(uint8_t times) //ȡݲظ -{ - uint32_t temp_val=0; - uint8_t t; - float temp_avrg=0; - - for(t=0;t4000) - temp_val=4000; //ֵ4000ʱǿתΪ4000// - - return (100-(temp_val/40)); //temp_valֵһ0-100֮// -} - diff --git a/firmware/stm32/smart_dormitory/User/light/sensor_light.h b/firmware/stm32/smart_dormitory/User/light/sensor_light.h deleted file mode 100644 index 17754b89..00000000 --- a/firmware/stm32/smart_dormitory/User/light/sensor_light.h +++ /dev/null @@ -1,19 +0,0 @@ -/****************************************Copyright (c)**************************************************** -** -** File name: light.h -** Created by: XiaoYi -** Created date: 2020-10-16 -** Version: v1.0 -** Descriptions: The original -** Link address: https://blog.csdn.net/weixin_45006076 -** -*********************************************************************************************************/ - -#ifndef __SENSOR_LIGHT_H__ -#define __SENSOR_LIGHT_H__ - -#include "main.h" - -uint8_t light_get_average_value(uint8_t times); - -#endif diff --git a/firmware/stm32/smart_dormitory/User/oled/codetab.h b/firmware/stm32/smart_dormitory/User/oled/codetab.h deleted file mode 100644 index 42cc0609..00000000 --- a/firmware/stm32/smart_dormitory/User/oled/codetab.h +++ /dev/null @@ -1,299 +0,0 @@ -/****************************************Copyright (c)**************************************************** -** -** File name: process.c -** Created by: XiaoYi -** Created date: 2020-10-16 -** Version: v1.0 -** Descriptions: The original -** Link address: https://blog.csdn.net/weixin_45006076 -** -*********************************************************************************************************/ - -#ifndef __CODETAB_H__ -#define __CODETAB_H__ - -/***************************16*16ĵȡģʽʽ*********/ -unsigned char F16x16[] = -{ - 0x00,0x02,0x02,0xFA,0xFA,0xAA,0xAA,0xFF,0xFF,0xAA,0xAA,0xFA,0xFA,0x02,0x02,0x00, - 0x00,0x42,0x72,0x72,0x3A,0x7A,0x42,0x4B,0x5B,0x52,0x62,0x62,0x13,0x77,0x66,0x00,/*"",0*/ - - 0x20,0x3C,0x1C,0xFF,0xFF,0xB0,0xB4,0x24,0x24,0x3F,0x3F,0xE4,0xE4,0x24,0x24,0x20, - 0x02,0x02,0x03,0xFF,0xFF,0x00,0x01,0x05,0x1D,0x59,0xC1,0xFF,0x7F,0x01,0x01,0x01,/*"",1*/ - - 0x00,0x00,0x00,0xF8,0xF8,0x48,0x4C,0x4F,0x4B,0x4A,0x48,0x48,0xF8,0xF8,0x00,0x00, - 0x00,0x00,0x00,0xFF,0xFF,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0xFF,0xFF,0x00,0x00,/*"",2*/ - - 0x20,0x24,0x24,0xE4,0xE4,0x24,0x24,0x24,0x30,0x10,0xFF,0xFF,0x10,0xF0,0xF0,0x00, - 0x08,0x1C,0x1F,0x0B,0x0C,0x0D,0x4F,0x6E,0x34,0x1C,0x0F,0x23,0x60,0x7F,0x3F,0x00,/*"",3*/ - - 0x80,0xC0,0x60,0xF8,0xFF,0x07,0x02,0x00,0xFF,0xFF,0xE0,0x70,0x3C,0x1C,0x08,0x00, - 0x00,0x00,0x00,0x7F,0x7F,0x04,0x06,0x03,0x3F,0x7F,0x40,0x40,0x40,0x78,0x78,0x00,/*"",4*/ -}; - -/************************************6*8ĵ************************************/ -const unsigned char F6x8[][6] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// sp - 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00,// ! - 0x00, 0x00, 0x07, 0x00, 0x07, 0x00,// " - 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14,// # - 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12,// $ - 0x00, 0x62, 0x64, 0x08, 0x13, 0x23,// % - 0x00, 0x36, 0x49, 0x55, 0x22, 0x50,// & - 0x00, 0x00, 0x05, 0x03, 0x00, 0x00,// ' - 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00,// ( - 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00,// ) - 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14,// * - 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08,// + - 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00,// , - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08,// - - 0x00, 0x00, 0x60, 0x60, 0x00, 0x00,// . - 0x00, 0x20, 0x10, 0x08, 0x04, 0x02,// / - 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0 - 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00,// 1 - 0x00, 0x42, 0x61, 0x51, 0x49, 0x46,// 2 - 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31,// 3 - 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10,// 4 - 0x00, 0x27, 0x45, 0x45, 0x45, 0x39,// 5 - 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6 - 0x00, 0x01, 0x71, 0x09, 0x05, 0x03,// 7 - 0x00, 0x36, 0x49, 0x49, 0x49, 0x36,// 8 - 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E,// 9 - 0x00, 0x00, 0x36, 0x36, 0x00, 0x00,// : - 0x00, 0x00, 0x56, 0x36, 0x00, 0x00,// ; - 0x00, 0x08, 0x14, 0x22, 0x41, 0x00,// < - 0x00, 0x14, 0x14, 0x14, 0x14, 0x14,// = - 0x00, 0x00, 0x41, 0x22, 0x14, 0x08,// > - 0x00, 0x02, 0x01, 0x51, 0x09, 0x06,// ? - 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,// @ - 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,// A - 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,// B - 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,// C - 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,// D - 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,// E - 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,// F - 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,// G - 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,// H - 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,// I - 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,// J - 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,// K - 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,// L - 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,// M - 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,// N - 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,// O - 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,// P - 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q - 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,// R - 0x00, 0x46, 0x49, 0x49, 0x49, 0x31,// S - 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,// T - 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,// U - 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,// V - 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,// W - 0x00, 0x63, 0x14, 0x08, 0x14, 0x63,// X - 0x00, 0x07, 0x08, 0x70, 0x08, 0x07,// Y - 0x00, 0x61, 0x51, 0x49, 0x45, 0x43,// Z - 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,// [ - 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55,// 55 - 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,// ] - 0x00, 0x04, 0x02, 0x01, 0x02, 0x04,// ^ - 0x00, 0x40, 0x40, 0x40, 0x40, 0x40,// _ - 0x00, 0x00, 0x01, 0x02, 0x04, 0x00,// ' - 0x00, 0x20, 0x54, 0x54, 0x54, 0x78,// a - 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,// b - 0x00, 0x38, 0x44, 0x44, 0x44, 0x20,// c - 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,// d - 0x00, 0x38, 0x54, 0x54, 0x54, 0x18,// e - 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,// f - 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,// g - 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,// h - 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,// i - 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,// j - 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,// k - 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,// l - 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,// m - 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,// n - 0x00, 0x38, 0x44, 0x44, 0x44, 0x38,// o - 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,// p - 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,// q - 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,// r - 0x00, 0x48, 0x54, 0x54, 0x54, 0x20,// s - 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,// t - 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,// u - 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,// v - 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,// w - 0x00, 0x44, 0x28, 0x10, 0x28, 0x44,// x - 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,// y - 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,// z - 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,// horiz lines -}; -/****************************************8*16ĵ************************************/ -const unsigned char F8X16[]= -{ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0 - 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1 - 0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2 - 0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3 - 0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4 - 0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5 - 0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6 - 0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7 - 0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8 - 0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9 - 0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10 - 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14 - 0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15 - 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16 - 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17 - 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18 - 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19 - 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20 - 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21 - 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22 - 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23 - 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24 - 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25 - 0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26 - 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27 - 0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28 - 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29 - 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30 - 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31 - 0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 32 - 0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 33 - 0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34 - 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35 - 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36 - 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37 - 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38 - 0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39 - 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40 - 0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41 - 0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42 - 0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43 - 0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44 - 0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45 - 0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46 - 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47 - 0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48 - 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49 - 0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50 - 0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51 - 0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52 - 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53 - 0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54 - 0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55 - 0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56 - 0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57 - 0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58 - 0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 59 - 0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\ 60 - 0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 61 - 0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 62 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 63 - 0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 64 - 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 65 - 0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66 - 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67 - 0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68 - 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69 - 0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70 - 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71 - 0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72 - 0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73 - 0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74 - 0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75 - 0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76 - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77 - 0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78 - 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79 - 0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80 - 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81 - 0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82 - 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83 - 0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84 - 0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85 - 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86 - 0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87 - 0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88 - 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89 - 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90 - 0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 91 - 0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 92 - 0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 93 - 0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94 -}; - -unsigned char BMP1[] = -{ - 0x00,0x03,0x05,0x09,0x11,0xFF,0x11,0x89,0x05,0xC3,0x00,0xE0,0x00,0xF0,0x00,0xF8, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x28,0xFF,0x11,0xAA,0x44,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x83,0x01,0x38,0x44,0x82,0x92, - 0x92,0x74,0x01,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x44,0xC7,0x01,0x7D, - 0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x01,0xFF,0x00, - 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,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,0x00,0x00,0x00,0x00, - 0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x00,0x00, - 0x6D,0x6D,0x6D,0x6D,0x6D,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x40,0x40, - 0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00, - 0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00,0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00,0xDB,0xDB, - 0xDB,0xDB,0xDB,0x00,0x00,0xDA,0xDA,0xDA,0xDA,0xDA,0x00,0x00,0xD8,0xD8,0xD8,0xD8, - 0xD8,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00, - 0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x80, - 0x80,0x80,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00, - 0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06, - 0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0xE6,0x66,0x20,0x00,0x06,0x06,0x86,0x06, - 0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x86,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00, - 0x00,0x86,0x86,0x86,0x86,0x86,0x80,0x80,0x86,0x86,0x06,0x86,0x86,0xC0,0xC0,0x86, - 0x86,0x86,0x06,0x06,0xD0,0x30,0x76,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06, - 0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06, - 0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x1C,0x00,0xFE,0x00,0x01, - 0x02,0x00,0xC4,0x18,0x20,0x02,0x9E,0x63,0xB2,0x0E,0x00,0xFF,0x81,0x81,0xFF,0x00, - 0x00,0x80,0x40,0x30,0x0F,0x00,0x00,0x00,0x00,0xFF,0x00,0x23,0xEA,0xAA,0xBF,0xAA, - 0xEA,0x03,0x3F,0x00,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,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x80,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,0x0E,0x0C,0x08,0x00,0x00,0x01,0x01,0x01, - 0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x81,0x80,0x80,0x81,0x80, - 0x81,0x80,0x80,0x80,0x80,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00, - 0x01,0x00,0x01,0x01,0x09,0x0C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0, - 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00, - 0x00,0x1E,0x21,0x40,0x40,0x50,0x21,0x5E,0x00,0x1E,0x21,0x40,0x40,0x50,0x21,0x5E, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xC1,0xC1,0xFF, - 0xFF,0xC1,0xC1,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,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x80,0xFC,0xF3,0xEF,0xF3,0xFC, - 0x80,0xFF,0x80,0xEE,0xEE,0xEE,0xF5,0xFB,0xFF,0x9C,0xBE,0xB6,0xB6,0x88,0xFF,0x00,/*"D:\DreamSpark\OLED\MP3_UI.bmp",0*/ -}; - -#endif - diff --git a/firmware/stm32/smart_dormitory/User/oled/oled.c b/firmware/stm32/smart_dormitory/User/oled/oled.c deleted file mode 100644 index aa94a4e6..00000000 --- a/firmware/stm32/smart_dormitory/User/oled/oled.c +++ /dev/null @@ -1,215 +0,0 @@ -/****************************************Copyright (c)**************************************************** -** -** File name: lcd.c -** Created by: XiaoYi -** Created date: 2020-10-16 -** Version: v1.0 -** Descriptions: The original -** Link address: https://blog.csdn.net/weixin_45006076 -** -*********************************************************************************************************/ - -#include -#include "main.h" -#include "i2c.h" -#include "oled.h" -#include "codetab.h" - -void oled_write_cmd(unsigned char cmd)//д -{ - HAL_I2C_Mem_Write(&hi2c1 ,0x78,0x00,I2C_MEMADD_SIZE_8BIT,&cmd,1,0x100); -} - -void oled_write_data(unsigned char data)//д -{ - HAL_I2C_Mem_Write(&hi2c1 ,0x78,0x40,I2C_MEMADD_SIZE_8BIT,&data,1,0x100); -} - -void oled_set_pos(unsigned char x, unsigned char y) //ʼ -{ - oled_write_cmd(0xb0+y); - oled_write_cmd(((x&0xf0)>>4)|0x10); - oled_write_cmd((x&0x0f)|0x01); -} - -void oled_fill(unsigned char fill_Data)//ȫ -{ - unsigned char m,n; - for(m=0;m<8;m++) - { - oled_write_cmd(0xb0+m); //page0-page1 - oled_write_cmd(0x00); //low column start address - oled_write_cmd(0x10); //high column start address - for(n=0;n<128;n++) - { - oled_write_data(fill_Data); - } - } -} - -void oled_clear_screen(void)// -{ - oled_fill(0x00); -} - -//-------------------------------------------------------------- -// Prototype : void oled_wakeup(void) -// Calls : -// Parameters : none -// Description : OLEDл -//-------------------------------------------------------------- -void oled_wakeup(void) -{ - oled_write_cmd(0X8D); //õɱ - oled_write_cmd(0X14); //ɱ - oled_write_cmd(0XAF); //OLED -} - -//-------------------------------------------------------------- -// Prototype : void oled_sleep(void) -// Calls : -// Parameters : none -// Description : OLED -- ģʽ,OLEDIJ10uA -//-------------------------------------------------------------- -void oled_sleep(void) -{ - oled_write_cmd(0X8D); //õɱ - oled_write_cmd(0X10); //رյɱ - oled_write_cmd(0XAE); //OLED -} - -//-------------------------------------------------------------- -// Prototype : void OLED_ShowChar(unsigned char x, unsigned char y, unsigned char ch[], unsigned char TextSize) -// Calls : -// Parameters : x,y -- ʼ(x:0~127, y:0~7); ch[] -- Ҫʾַ; TextSize -- ַС(1:6*8 ; 2:8*16) -// Description : ʾcodetab.hеASCIIַ,6*88*16ѡ -//-------------------------------------------------------------- -void oled_show_string(unsigned char x, unsigned char y, unsigned char ch[], unsigned char TextSize) -{ - unsigned char c = 0,i = 0,j = 0; - switch(TextSize) - { - case 1: - { - while(ch[j] != '\0') - { - c = ch[j] - 32; - if(x > 126) - { - x = 0; - y++; - } - oled_set_pos(x,y); - for(i=0;i<6;i++) - oled_write_data(F6x8[c][i]); - x += 6; - j++; - } - }break; - case 2: - { - while(ch[j] != '\0') - { - c = ch[j] - 32; - if(x > 120) - { - x = 0; - y++; - } - oled_set_pos(x,y); - for(i=0;i<8;i++) - oled_write_data(F8X16[c*16+i]); - oled_set_pos(x,y+1); - for(i=0;i<8;i++) - oled_write_data(F8X16[c*16+i+8]); - x += 8; - j++; - } - }break; - } -} - -//-------------------------------------------------------------- -// Prototype : void oled_show_chinese(unsigned char x, unsigned char y, unsigned char N) -// Calls : -// Parameters : x,y -- ʼ(x:0~127, y:0~7); N:codetab.hе -// Description : ʾcodetab.hеĺ,16*16 -//-------------------------------------------------------------- -void oled_show_chinese(unsigned char x, unsigned char y, unsigned char N) -{ - unsigned char wm=0; - unsigned int adder=32*N; - oled_set_pos(x , y); - for(wm = 0;wm < 16;wm++) - { - oled_write_data(F16x16[adder]); - adder += 1; - } - oled_set_pos(x,y + 1); - for(wm = 0;wm < 16;wm++) - { - oled_write_data(F16x16[adder]); - adder += 1; - } -} - -//-------------------------------------------------------------- -// Prototype : void oled_draw_bmp(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,unsigned char BMP[]); -// Calls : -// Parameters : x0,y0 -- ʼ(x0:0~127, y0:0~7); x1,y1 -- Խ()(x1:1~128,y1:1~8) -// Description : ʾBMPλͼ -//-------------------------------------------------------------- -void oled_draw_bmp(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,unsigned char *bmp) -{ - unsigned int j=0; - unsigned char x,y; - - if(y1%8==0) - y = y1/8; - else - y = y1/8 + 1; - for(y=y0;y - 0x00, 0x02, 0x01, 0x51, 0x09, 0x06,// ? - 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,// @ - 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,// A - 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,// B - 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,// C - 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,// D - 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,// E - 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,// F - 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,// G - 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,// H - 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,// I - 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,// J - 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,// K - 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,// L - 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,// M - 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,// N - 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,// O - 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,// P - 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q - 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,// R - 0x00, 0x46, 0x49, 0x49, 0x49, 0x31,// S - 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,// T - 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,// U - 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,// V - 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,// W - 0x00, 0x63, 0x14, 0x08, 0x14, 0x63,// X - 0x00, 0x07, 0x08, 0x70, 0x08, 0x07,// Y - 0x00, 0x61, 0x51, 0x49, 0x45, 0x43,// Z - 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,// [ - 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55,// 55 - 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,// ] - 0x00, 0x04, 0x02, 0x01, 0x02, 0x04,// ^ - 0x00, 0x40, 0x40, 0x40, 0x40, 0x40,// _ - 0x00, 0x00, 0x01, 0x02, 0x04, 0x00,// ' - 0x00, 0x20, 0x54, 0x54, 0x54, 0x78,// a - 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,// b - 0x00, 0x38, 0x44, 0x44, 0x44, 0x20,// c - 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,// d - 0x00, 0x38, 0x54, 0x54, 0x54, 0x18,// e - 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,// f - 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,// g - 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,// h - 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,// i - 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,// j - 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,// k - 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,// l - 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,// m - 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,// n - 0x00, 0x38, 0x44, 0x44, 0x44, 0x38,// o - 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,// p - 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,// q - 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,// r - 0x00, 0x48, 0x54, 0x54, 0x54, 0x20,// s - 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,// t - 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,// u - 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,// v - 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,// w - 0x00, 0x44, 0x28, 0x10, 0x28, 0x44,// x - 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,// y - 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,// z - 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,// horiz lines - }; - /****************************************8*16ĵ************************************/ - const unsigned char F8X16[]= - { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0 - 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1 - 0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2 - 0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3 - 0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4 - 0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5 - 0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6 - 0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7 - 0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8 - 0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9 - 0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10 - 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14 - 0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15 - 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16 - 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17 - 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18 - 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19 - 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20 - 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21 - 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22 - 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23 - 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24 - 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25 - 0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26 - 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27 - 0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28 - 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29 - 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30 - 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31 - 0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 32 - 0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 33 - 0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34 - 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35 - 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36 - 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37 - 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38 - 0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39 - 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40 - 0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41 - 0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42 - 0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43 - 0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44 - 0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45 - 0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46 - 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47 - 0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48 - 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49 - 0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50 - 0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51 - 0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52 - 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53 - 0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54 - 0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55 - 0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56 - 0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57 - 0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58 - 0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 59 - 0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\ 60 - 0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 61 - 0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 62 - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 63 - 0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 64 - 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 65 - 0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66 - 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67 - 0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68 - 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69 - 0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70 - 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71 - 0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72 - 0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73 - 0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74 - 0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75 - 0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76 - 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77 - 0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78 - 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79 - 0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80 - 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81 - 0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82 - 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83 - 0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84 - 0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85 - 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86 - 0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87 - 0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88 - 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89 - 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90 - 0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 91 - 0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 92 - 0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 93 - 0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94 - }; - - unsigned char BMP1[] = - { - 0x00,0x03,0x05,0x09,0x11,0xFF,0x11,0x89,0x05,0xC3,0x00,0xE0,0x00,0xF0,0x00,0xF8, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x28,0xFF,0x11,0xAA,0x44,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x83,0x01,0x38,0x44,0x82,0x92, - 0x92,0x74,0x01,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x44,0xC7,0x01,0x7D, - 0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x01,0xFF,0x00, - 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,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,0x00,0x00,0x00,0x00, - 0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01, - 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x00,0x00, - 0x6D,0x6D,0x6D,0x6D,0x6D,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x40,0x40, - 0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00, - 0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00,0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00,0xDB,0xDB, - 0xDB,0xDB,0xDB,0x00,0x00,0xDA,0xDA,0xDA,0xDA,0xDA,0x00,0x00,0xD8,0xD8,0xD8,0xD8, - 0xD8,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00, - 0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x80, - 0x80,0x80,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00, - 0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06, - 0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0xE6,0x66,0x20,0x00,0x06,0x06,0x86,0x06, - 0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x86,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00, - 0x00,0x86,0x86,0x86,0x86,0x86,0x80,0x80,0x86,0x86,0x06,0x86,0x86,0xC0,0xC0,0x86, - 0x86,0x86,0x06,0x06,0xD0,0x30,0x76,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06, - 0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06, - 0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x1C,0x00,0xFE,0x00,0x01, - 0x02,0x00,0xC4,0x18,0x20,0x02,0x9E,0x63,0xB2,0x0E,0x00,0xFF,0x81,0x81,0xFF,0x00, - 0x00,0x80,0x40,0x30,0x0F,0x00,0x00,0x00,0x00,0xFF,0x00,0x23,0xEA,0xAA,0xBF,0xAA, - 0xEA,0x03,0x3F,0x00,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,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x80,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,0x0E,0x0C,0x08,0x00,0x00,0x01,0x01,0x01, - 0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x81,0x80,0x80,0x81,0x80, - 0x81,0x80,0x80,0x80,0x80,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00, - 0x01,0x00,0x01,0x01,0x09,0x0C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0, - 0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00, - 0x00,0x1E,0x21,0x40,0x40,0x50,0x21,0x5E,0x00,0x1E,0x21,0x40,0x40,0x50,0x21,0x5E, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xC1,0xC1,0xFF, - 0xFF,0xC1,0xC1,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,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x80,0xFC,0xF3,0xEF,0xF3,0xFC, - 0x80,0xFF,0x80,0xEE,0xEE,0xEE,0xF5,0xFB,0xFF,0x9C,0xBE,0xB6,0xB6,0x88,0xFF,0x00,/*"D:\DreamSpark\OLED\MP3_UI.bmp",0*/ - }; - - #endif \ No newline at end of file diff --git a/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/esp8266.c b/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/esp8266.c deleted file mode 100644 index 6daf00fb..00000000 --- a/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/esp8266.c +++ /dev/null @@ -1,478 +0,0 @@ -#include "esp8266.h" -#include "usart.h" - - -struct STRUCT_USART_Fram ESP8266_Fram_Record_Struct= { 0 }; //һ֡ṹ -void ESP8266_Init(uint32_t bound) -{ - GPIO_InitTypeDef GPIO_InitStructure; - - __HAL_RCC_GPIOA_CLK_ENABLE(); - -// GPIO_InitStructure.Pin = ESP8266_RST_Pin; -// GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; // -// GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH; -// HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); -// -// GPIO_InitStructure.Pin = ESP8266_CH_PD_Pin; -// HAL_GPIO_Init(ESP8266_CH_PD_Pin_Port, &GPIO_InitStructure); -// - ESP8266_Rst(); -} - -//ESP8266ģ鷢ATָ -// cmd ͵ָ -// ack1,ack2;ڴӦΪNULLӦΪ߼ϵ -// time ȴӦʱ -//1ͳɹ 0ʧ -bool ESP8266_Send_AT_Cmd(char *cmd,char *ack1,char *ack2,uint32_t time) -{ - ESP8266_Fram_Record_Struct.InfBit .FramLength = 0; //½µݰ - ESP8266_USART("%s\r\n", cmd); - if(ack1==0&&ack2==0) //Ҫ - { - return true; - } - delay_ms(time); //ʱ - delay_ms(1000); - ESP8266_Fram_Record_Struct.Data_RX_BUF[ESP8266_Fram_Record_Struct.InfBit.FramLength ] = '\0'; - - printf("------ %s", ESP8266_Fram_Record_Struct.Data_RX_BUF); - if(ack1!=0&&ack2!=0) - { - return ( ( bool ) strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, ack1 ) || - ( bool ) strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, ack2 ) ); - } - else if( ack1 != 0 ) //strstr(s1,s2);s2ǷΪs1һ֣Ƿظλã򷵻falseǿתΪbool - return ( ( bool ) strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, ack1 ) ); - - else - return ( ( bool ) strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, ack2 ) ); -} - - -//λ -void ESP8266_Rst(void) -{ -// ESP8266_RST_Pin_SetL; -// delay_ms(500); -// ESP8266_RST_Pin_SetH; - ; -} - - -//ͻָĬָģָɳ -void ESP8266_ATE0(void) -{ - char count=0; - delay_ms(1000); - while(count < 10) - { - if(ESP8266_Send_AT_Cmd("ATE0","OK",NULL,500)) - { - printf("OK\r\n"); - return; - } - ++ count; - } -} - -//ͻָĬָģָɳ -void ESP8266_AT_Restore(void) -{ - char count=0; - delay_ms(1000); - while(count < 10) - { - if(ESP8266_Send_AT_Cmd("AT+RESTORE","OK",NULL,500)) - { - printf("OK\r\n"); - return; - } - ++ count; - } -} - -//ѡESP8266Ĺģʽ -// enumMode ģʽ -//ɹtrueʧܷfalse -bool ESP8266_Net_Mode_Choose(ENUM_Net_ModeTypeDef enumMode) -{ - switch ( enumMode ) - { - case STA: - return ESP8266_Send_AT_Cmd ( "AT+CWMODE=1", "OK", "no change", 2500 ); - - case AP: - return ESP8266_Send_AT_Cmd ( "AT+CWMODE=2", "OK", "no change", 2500 ); - - case STA_AP: - return ESP8266_Send_AT_Cmd ( "AT+CWMODE=3", "OK", "no change", 2500 ); - - default: - return false; - } -} - - -//ESP8266ⲿWIFI -//pSSID WiFiʺ -//pPassWord WiFi -//óɹtrue ֮false -bool ESP8266_JoinAP( char * pSSID, char * pPassWord) -{ - char cCmd [120]; - - sprintf ( cCmd, "AT+CWJAP=\"%s\",\"%s\"", pSSID, pPassWord ); - return ESP8266_Send_AT_Cmd( cCmd, "OK", NULL, 5000 ); -} - -//ESP8266 ͸ʹ -//enumEnUnvarnishTx Ƿӣbool -//óɹtrue֮false -bool ESP8266_Enable_MultipleId (FunctionalState enumEnUnvarnishTx ) -{ - char cStr [20]; - - sprintf ( cStr, "AT+CIPMUX=%d", ( enumEnUnvarnishTx ? 1 : 0 ) ); - - return ESP8266_Send_AT_Cmd ( cStr, "OK", 0, 500 ); - -} - - -//ESP8266 ӷ -//enumE -//ip IP -//ComNum ˿ -//idӺţȷͨŲ -//óɹtrue֮fasle -bool ESP8266_Link_Server(ENUM_NetPro_TypeDef enumE, char * ip, char * ComNum, ENUM_ID_NO_TypeDef id) -{ - char cStr [100] = { 0 }, cCmd [120]; - - switch ( enumE ) - { - case enumTCP: - sprintf ( cStr, "\"%s\",\"%s\",%s", "TCP", ip, ComNum ); - break; - - case enumUDP: - sprintf ( cStr, "\"%s\",\"%s\",%s", "UDP", ip, ComNum ); - break; - - default: - break; - } - - if ( id < 5 ) - sprintf ( cCmd, "AT+CIPSTART=%d,%s", id, cStr); - - else - sprintf ( cCmd, "AT+CIPSTART=%s", cStr ); - - return ESP8266_Send_AT_Cmd ( cCmd, "OK", "ALREAY CONNECT", 4000 ); - -} - - -//͸ʹ -//óɹtrue ֮false -bool ESP8266_UnvarnishSend ( void ) -{ - if (!ESP8266_Send_AT_Cmd ( "AT+CIPMODE=1", "OK", 0, 500 )) - return false; - - return - ESP8266_Send_AT_Cmd( "AT+CIPSEND", "OK", ">", 500 ); - -} - - -//ESP8266ַ -//enumEnUnvarnishTxǷʹ͸ģʽ -//pStrַ -//ulStrLengthַ -//ucId Ӻ -//óɹtrue ֮false -bool ESP8266_SendString(FunctionalState enumEnUnvarnishTx, char * pStr, uint32_t ulStrLength, ENUM_ID_NO_TypeDef ucId ) -{ - char cStr [20]; - bool bRet = false; - - - if ( enumEnUnvarnishTx ) - { - ESP8266_USART ( "%s", pStr ); - - bRet = true; - - } - else - { - if ( ucId < 5 ) - sprintf ( cStr, "AT+CIPSEND=%d,%d", ucId, ulStrLength + 2 ); - else - sprintf ( cStr, "AT+CIPSEND=%d", ulStrLength + 2 ); - - ESP8266_Send_AT_Cmd ( cStr, "> ", 0, 1000 ); - - bRet = ESP8266_Send_AT_Cmd ( pStr, "SEND OK", 0, 1000 ); - } - - return bRet; - -} - - -//ESP8266˳͸ģʽ -void ESP8266_ExitUnvarnishSend ( void ) -{ - delay_ms(1000); - ESP8266_USART( "+++" ); - delay_ms( 500 ); -} - - -//ESP8266 ״̬ -//0ȡ״̬ʧ -//2ip -//3 -//4ʧȥ -uint8_t ESP8266_Get_LinkStatus ( void ) -{ - if (ESP8266_Send_AT_Cmd( "AT+CIPSTATUS", "OK", 0, 500 ) ) - { - if ( strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, "STATUS:2\r\n" ) ) - return 2; - - else if ( strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, "STATUS:3\r\n" ) ) - return 3; - - else if ( strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, "STATUS:4\r\n" ) ) - return 4; - - } - - return 0; -} - -static char *itoa( int value, char *string, int radix ) -{ - int i, d; - int flag = 0; - char *ptr = string; - - /* This implementation only works for decimal numbers. */ - if (radix != 10) - { - *ptr = 0; - return string; - } - - if (!value) - { - *ptr++ = 0x30; - *ptr = 0; - return string; - } - - /* if this is a negative value insert the minus sign. */ - if (value < 0) - { - *ptr++ = '-'; - - /* Make the value positive. */ - value *= -1; - - } - - for (i = 10000; i > 0; i /= 10) - { - d = value / i; - - if (d || flag) - { - *ptr++ = (char)(d + 0x30); - value -= (d * i); - flag = 1; - } - } - - /* Null terminate the string. */ - *ptr = 0; - - return string; - -} /* NCL_Itoa */ - - -void USART_printf ( char * Data, ... ) -{ - const char *s; - int d; - char buf[16]; - uint8_t ch = 0; - - - va_list ap; - va_start(ap, Data); - - while ( * Data != 0 ) // жǷ񵽴 - { - if ( * Data == 0x5c ) //'\' - { - switch ( *++Data ) - { - case 'r': //س - ch = 0x0d; - HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF); - Data ++; - break; - - case 'n': //з - ch = 0x0a; - HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF); - Data ++; - break; - - default: - Data ++; - break; - } - } - - else if ( * Data == '%') - { - switch ( *++Data ) - { - case 's': //ַ - s = va_arg(ap, const char *); - for ( ; *s; s++) - { - HAL_UART_Transmit(&huart3, (uint8_t *)s, 1, 0xFFFF); - while( __HAL_UART_GET_FLAG(&huart3, UART_FLAG_TXE) == false); - } - Data++; - break; - - case 'd': - //ʮ - d = va_arg(ap, int); - itoa(d, buf, 10); - for (s = buf; *s; s++) - { - HAL_UART_Transmit(&huart3, (uint8_t *)s, 1, 0xFFFF); - while( __HAL_UART_GET_FLAG(&huart3, UART_FLAG_TXE) == false); - } - Data++; - break; - default: - Data++; - break; - } - } - else - { - HAL_UART_Transmit(&huart3, (uint8_t *)Data, 1, 0xFFFF); - Data++; - while( __HAL_UART_GET_FLAG(&huart3, UART_FLAG_TXE) == false); - } - - } -} - -//ΪESP8266MQTTָ - -/* -*MQTTû -*LinkID ID,Ŀǰֻ֧0 -*scheme ӷʽѡMQTT over TCP,Ϊ1 -*client_id MQTTclientID ڱ־client -*username ڵ¼ MQTT username -*password ڵ¼ MQTT password -*cert_key_ID ֤ ID, Ŀǰ֧һ cert ֤, Ϊ 0 -*CA_ID Ŀǰ֧һ CA ֤, Ϊ 0 -*path Դ·Ϊ"" -*óɹtrue ֮false -*/ -bool ESP8266_MQTTUSERCFG( char * pClient_Id, char * pUserName,char * PassWord) -{ - char cCmd [120]; - sprintf ( cCmd, "AT+MQTTUSERCFG=0,1,\"%s\",\"%s\",\"%s\",0,0,\"\"", pClient_Id,pUserName,PassWord ); - return ESP8266_Send_AT_Cmd( cCmd, "OK", NULL, 500 ); -} - - -/* -*ָMQTT -*LinkID ID,Ŀǰֻ֧0 -*IPMQTT϶ӦIPַ -*ComNum MQTT϶ӦĶ˿ںţһΪ1883 -*óɹtrue ֮false -*/ -bool ESP8266_MQTTCONN( char * Ip, int Num) -{ - char cCmd [120]; - sprintf ( cCmd,"AT+MQTTCONN=0,\"%s\",%d,0", Ip,Num); - return ESP8266_Send_AT_Cmd( cCmd, "OK", NULL, 500 ); -} - -/* -*ָӵ MQTT , ظζIJͬ topic -*LinkID ID,Ŀǰֻ֧0 -*Topic ĵ֣ΪTopic -*QosֵһΪ0Ϊ1 -*óɹtrue ֮false -*/ -bool ESP8266_MQTTSUB(char * Topic) -{ - char cCmd [120]; - sprintf ( cCmd, "AT+MQTTSUB=0,\"%s\",1",Topic ); - return ESP8266_Send_AT_Cmd( cCmd, "OK", NULL, 500 ); -} - - -/* -*LinkIDͨ topic data, data ΪַϢ -*LinkID ID,Ŀǰֻ֧0 -*Topic ĵ֣ΪTopic -*dataַϢ -*óɹtrue ֮false -*/ -bool ESP8266_MQTTPUB( char * Topic,char *temp) -{ - char cCmd [512]; - sprintf (cCmd, "AT+MQTTPUB=0,\"%s\",\"%s\",0,0", Topic ,temp); - return ESP8266_Send_AT_Cmd( cCmd, "OK", NULL, 1000 ); -} - -/* -*ر MQTT Client Ϊ LinkID , ͷڲռõԴ -*LinkID ID,Ŀǰֻ֧0 -*Topic ĵ֣ΪTopic -*dataַϢ -*óɹtrue ֮false -*/ -bool ESP8266_MQTTCLEAN(void) -{ - char cCmd [120]; - sprintf ( cCmd, "AT+MQTTCLEAN=0"); - return ESP8266_Send_AT_Cmd( cCmd, "OK", NULL, 500 ); -} - -//ESP8266ַ -//enumEnUnvarnishTxǷʹ͸ģʽ -//pStrַ -//ulStrLengthַ -//ucId Ӻ -//óɹtrue ֮false -bool MQTT_SendString(char * pTopic,char *temp2) -{ - bool bRet = false; - - bRet = ESP8266_MQTTPUB(pTopic,temp2); - - return bRet; -} - diff --git a/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/esp8266.h b/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/esp8266.h deleted file mode 100644 index 572025b0..00000000 --- a/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/esp8266.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef __ESP8266_H -#define __ESP8266_H - -#include "main.h" - -#include -#include -#include - -#if defined ( __CC_ARM ) -#pragma anon_unions -#endif - -//ESP8266ģʽѡ -typedef enum -{ - STA, - AP, - STA_AP -}ENUM_Net_ModeTypeDef; - -//紫Э飬ö -typedef enum{ - enumTCP, - enumUDP, -} ENUM_NetPro_TypeDef; -//ӺţָΪӺſԷֹͬһ˿ڶ -typedef enum{ - Multiple_ID_0 = 0, - Multiple_ID_1 = 1, - Multiple_ID_2 = 2, - Multiple_ID_3 = 3, - Multiple_ID_4 = 4, - Single_ID_0 = 5, -} ENUM_ID_NO_TypeDef; - -#define ESP8266_RST_Pin GPIO_PIN_4 //λܽ -#define ESP8266_RST_Pin_Port GPIOA //λ - -#define ESP8266_CH_PD_Pin GPIO_PIN_5 //ʹܹܽ -#define ESP8266_CH_PD_Pin_Port GPIOA //ʹܶ˿ - - -#define ESP8266_RST_Pin_SetH HAL_GPIO_WritePin(ESP8266_RST_Pin_Port, ESP8266_RST_Pin, GPIO_PIN_SET) -#define ESP8266_RST_Pin_SetL HAL_GPIO_WritePin(ESP8266_RST_Pin_Port, ESP8266_RST_Pin, GPIO_PIN_RESET) - - -#define ESP8266_CH_PD_Pin_SetH HAL_GPIO_WritePin(ESP8266_CH_PD_Pin_Port,ESP8266_CH_PD_Pin, GPIO_PIN_SET) -#define ESP8266_CH_PD_Pin_SetL HAL_GPIO_WritePin(ESP8266_CH_PD_Pin_Port,ESP8266_CH_PD_Pin, GPIO_PIN_RESET) - - -#define ESP8266_USART(fmt, ...) USART_printf (fmt, ##__VA_ARGS__) -#define PC_USART(fmt, ...) printf(fmt, ##__VA_ARGS__) //Ǵڴӡ1ִprintfԶִfputضprintf - - - -#define RX_BUF_MAX_LEN 1024 //ֽ -extern struct STRUCT_USART_Fram //֡ṹ -{ - char Data_RX_BUF[RX_BUF_MAX_LEN]; - union - { - __IO uint16_t InfAll; - struct - { - __IO uint16_t FramLength :15; // 14:0 - __IO uint16_t FramFinishFlag :1; // 15 - }InfBit; - }; - -}ESP8266_Fram_Record_Struct; - - -//ʼTCPܺ -void ESP8266_Init(uint32_t bound); -void ESP8266_ATE0(void); -bool ESP8266_Send_AT_Cmd(char *cmd,char *ack1,char *ack2,uint32_t time); -void ESP8266_Rst(void); -bool ESP8266_Net_Mode_Choose(ENUM_Net_ModeTypeDef enumMode); -bool ESP8266_JoinAP( char * pSSID, char * pPassWord ); -bool ESP8266_Enable_MultipleId ( FunctionalState enumEnUnvarnishTx ); -bool ESP8266_Link_Server(ENUM_NetPro_TypeDef enumE, char * ip, char * ComNum, ENUM_ID_NO_TypeDef id); -bool ESP8266_SendString(FunctionalState enumEnUnvarnishTx, char * pStr, uint32_t ulStrLength, ENUM_ID_NO_TypeDef ucId ); -bool ESP8266_UnvarnishSend ( void ); -void ESP8266_ExitUnvarnishSend ( void ); -uint8_t ESP8266_Get_LinkStatus ( void ); -void USART_printf( char * Data, ... ); - -//MQTTܺ -bool ESP8266_MQTTUSERCFG( char * pClient_Id, char * pUserName,char * PassWord); -bool ESP8266_MQTTCONN( char * Ip, int Num); -bool ESP8266_MQTTSUB(char * Topic); -bool ESP8266_MQTTPUB( char * Topic,char *temp); -bool ESP8266_MQTTCLEAN(void); -bool MQTT_SendString(char * pTopic,char *temp2); - -#endif - diff --git a/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/mqtt.c b/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/mqtt.c deleted file mode 100644 index 1cc303a4..00000000 --- a/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/mqtt.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "mqtt.h" - -void ESP8266_STA_MQTTClient_Init(void) -{ - char str[] = "{\"deviceNum\":\"863488052352477\"\,\"relayStatus\":0\,\ - \"lightStatus\":0\,\"isOnline\":1\,\"rssi\":-54\,\"deviceTemperature\":40\,\"airTemperature\":0\,\ - \"airHumidity\":0\,\"triggerSource\":0\,\"brightness\":11\,\"lightInterval\":432\,\ - \"lightMode\":0\,\"fadeTime\":259\,\"red\":255\,\"green\":0\,\"blue\":0}"; - - printf("ESP8266\r\n"); - ESP8266_ATE0();//ȡ - ESP8266_Net_Mode_Choose(STA); - while(!ESP8266_JoinAP(WIFI_SSID, WIFI_PWD)); - - // û - ESP8266_MQTTUSERCFG(WIFI_client_id,WIFI_username,WIFI_password); - delay_ms(200); - // MQTT - ESP8266_MQTTCONN( WIFI_MQTTServer_IP, WIFI_MQTTServer_PORT); - // - ESP8266_MQTTSUB( WIFI_MQTTServer_Topic_SUB); - printf("\r\nMQTT"); - - delay_ms(200); - - //ݵMQTT - if (MQTT_SendString (WIFI_MQTTServer_Topic_PUB, str)) - { - printf("send data to mqtt server success\r\n"); - }else - { - printf("send data to mqtt server error\r\n"); - printf(": %s\r\n", str); - } - -} - diff --git a/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/mqtt.h b/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/mqtt.h deleted file mode 100644 index ddcff045..00000000 --- a/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/mqtt.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __MQTT_H -#define __MQTT_H - -#include "main.h" -#include "esp8266.h" - -/* -*²Ҫû޸IJܲù -*/ - - -#define WIFI_SSID "DianJing" //wifi -#define WIFI_PWD "wzry6666" //wifi - -#define WIFI_client_id "50fccfefb50a48b98a93ce27bb04591f" //MQTTclientID ڱ־client 256ֽ -#define WIFI_username "admin" //ڵ¼ MQTT username,  64 ֽ -#define WIFI_password "admin13" //ڵ¼ MQTT password,  64 ֽ -#define WIFI_MQTTServer_IP "106.12.9.213" //MQTTطIP -#define WIFI_MQTTServer_PORT 1883 //˿ں -#define WIFI_MQTTServer_Topic_PUB "status" //MQTT -#define WIFI_MQTTServer_Topic_SUB "status/set/863488052352477" //MQTT - - -void ESP8266_STA_MQTTClient_Init(void); - -#endif diff --git a/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/tcp.c b/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/tcp.c deleted file mode 100644 index 429a4b94..00000000 --- a/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/tcp.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "tcp.h" - -volatile uint8_t TcpClosedFlag = 0; - -void ESP8266_STA_TCPClient_Test(void) -{ - uint8_t res; - - char str[100]={0}; - ESP8266_ATE0(); - printf("ESP8266\r\n"); - ESP8266_Net_Mode_Choose(STA); - while(!ESP8266_JoinAP(User_ESP8266_SSID, User_ESP8266_PWD)); - ESP8266_Enable_MultipleId ( DISABLE ); - while(!ESP8266_Link_Server(enumTCP, User_ESP8266_TCPServer_IP, User_ESP8266_TCPServer_PORT, Single_ID_0)); - while(!ESP8266_UnvarnishSend()); - printf("\r\n"); - while ( 1 ) - { - sprintf (str,"аſɿƼ޹˾" );//ʽַTCP - ESP8266_SendString ( ENABLE, str, 0, Single_ID_0 ); - delay_ms(1000); - if(TcpClosedFlag) //жǷʧȥ - { - ESP8266_ExitUnvarnishSend(); //˳͸ģʽ - do - { - res = ESP8266_Get_LinkStatus(); //ȡ״̬ - } - while(!res); - - if(res == 4) //ȷʧȥӣ - { - - - while (!ESP8266_JoinAP(User_ESP8266_SSID, User_ESP8266_PWD ) ); - while (!ESP8266_Link_Server(enumTCP, User_ESP8266_TCPServer_IP, User_ESP8266_TCPServer_PORT, Single_ID_0 ) ); - } - while(!ESP8266_UnvarnishSend()); - } - } -} diff --git a/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/tcp.h b/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/tcp.h deleted file mode 100644 index 828d0606..00000000 --- a/firmware/stm32/smart_dormitory/User/xiaoyi_wifi/tcp.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __TCP_H -#define __TCP_H - -#include "main.h" -#include "esp8266.h" - -/* -*²Ҫû޸IJܲù -*/ - -#define User_ESP8266_SSID "miot_default" //wifi -#define User_ESP8266_PWD "123456789x" //wifi - -#define User_ESP8266_TCPServer_IP "192.168.31.16" //IP -#define User_ESP8266_TCPServer_PORT "8888" //˿ں - - -extern volatile uint8_t TcpClosedFlag; //״̬־ - -void ESP8266_STA_TCPClient_Test(void); - -#endif