├── LICENSE
├── README.md
├── stm32
├── Inc
│ ├── DHT11.h
│ ├── GUI.h
│ ├── LCD_Driver.h
│ ├── bmp280.h
│ ├── esp8266_Driver.h
│ ├── esp_http_pages.h
│ ├── illuminanceMeas.h
│ ├── main.h
│ ├── stm32f4xx_hal_conf.h
│ └── stm32f4xx_it.h
├── IntelliSw.ioc
├── MDK-ARM
│ ├── DHT11.c
│ ├── GUI.c
│ ├── IntelliSw.uvprojx
│ ├── LCD_Driver.c
│ ├── bmp280.c
│ ├── esp8266_Driver.c
│ ├── esp_http_pages.c
│ ├── illuminanceMeas.c
│ ├── mcu_conf.html
│ ├── startup_stm32f401xc.s
│ └── 稳定版固件,带配网功能
│ │ └── IntelliSw.hex
├── README.md
└── Src
│ ├── main.c
│ ├── stm32f4xx_hal_msp.c
│ ├── stm32f4xx_hal_timebase_tim.c
│ ├── stm32f4xx_it.c
│ └── system_stm32f4xx.c
└── web
├── IntelliSw-App
├── char_convert.py
├── char_pixel.json
├── virtualScreen
│ └── app_conf.html
└── weather.py
├── IntelliSw
├── __init__.py
├── asgi.py
├── settings.py
├── urls.py
└── wsgi.py
├── NetAssist.exe
├── WebView
├── __init__.py
├── admin.py
├── apps.py
├── models.py
├── tests.py
└── views.py
├── iot-uploader.bat
├── iot-uploader.py
├── mail.html
├── manage.py
├── start.bat
├── static
├── app_conf.js
├── font-awesome-4.7.0
│ └── (PLACE DATA HERE)HELP-US-OUT.txt
├── gif
│ ├── load.gif
│ └── psc.jpg
├── index.css
└── index.js
└── template
├── app_conf.html
└── index.html
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 zhy
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # IntelliSw 智能WiFi开关
2 |
3 | - [x] Concept Video Uploaded:https://www.bilibili.com/video/BV14A411u7TP
4 | - [x] Web平台更新
5 | - [x] STM32平台更新(可能用IOT终端 or MCU来代替这一说法)
6 | - [x] 配网功能(请见于stm32目录)
7 | - [x] ESP8266实现HTTP服务器(同上)
8 |
9 | ## Web平台
10 |
11 | 部署Web平台需要下载Font-Awesome,并添加至Web目录下的static目录。
12 | Web平台采用Django框架构建,建立了3个模型,分别是
13 |
14 | - ServerInfo,储存服务器信息。
15 |
16 | - SampleData,储存IOT终端上报的数据。IOT终端通过ESP8266连接到互联网,为了保持与服务器的长连接,访问与本Web平台共同部署在一起的数据上报接口(iot-uploader.py)。数据上报接口通过GET请求Web平台内定义的/command命令执行接口来更新数据。或者Web平台在View.py内调用socket访问数据上报接口,调用内部已经与IOT终端建立连接的socket发送设备更改或时间同步命令。
17 |
18 | - DeviceControl,设备控制,储存自定义设备的状态。
19 |
20 | ## STM32平台
21 |
22 | ### Instruction to STM32 code
23 |
24 | - This Code Is Running On STM32F401CCU6.You can buy it on Taobao.
25 | - This is the basic STM32CUBEMX project files.Attention.I have deleted all innecessary driver files such as timer driver and usart driver.But I keep all the module drivers for the
26 | followings.
27 |
28 | - ESP8266(The Wifi module)
29 | - BMP280(Temperature and Atmosphere Pressure Sensor)
30 | - DHT11(Temperature and Humidity Sensor)
31 | - BF1750(Digital Lightness Sensor)
32 |
33 | #### MCU数据传输过程
34 |
35 | - MCU ↑↓(By USART)
36 | - ESP8266 ↑↓ (By long TCP connection and USART)
37 | - iot-uploader.py in SERVER ↑↓ (By long TCP connection and local TCP connection)
38 | - Django Framework in SERVER ↑↓ (By local TCP connection)
39 |
40 | > 最后更新于`2021年`2月13日。这个项目进入生产模式已经15天,出现过几次掉线,但也自动重连成功。迫于升学压力,可能这是我最后一次维护这个项目,得益于多多思考了整个系统的架构,项目还算稳定。不打算再动这个项目太多,简单的小bug会修复。
41 |
42 | > 考上t大了,这个项目运行稳定,值得信赖。 写于17点22分,2022年6月30日
43 |
--------------------------------------------------------------------------------
/stm32/Inc/DHT11.h:
--------------------------------------------------------------------------------
1 | #ifndef DHT11_HEADER
2 | #define DHT11_HEADER
3 | #include "main.h"
4 |
5 | extern uint8_t DHT11_HUMIDITY;
6 | void DHT11_Output(void);
7 |
8 | #endif
9 |
--------------------------------------------------------------------------------
/stm32/Inc/GUI.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtxzsxxk/intelli-switch/6cf144ad8ddad1dadf7d2fe7dc54e730b10d069b/stm32/Inc/GUI.h
--------------------------------------------------------------------------------
/stm32/Inc/LCD_Driver.h:
--------------------------------------------------------------------------------
1 | #ifndef LCD5110_H_
2 | #define LCD5110_H_
3 | #include "main.h"
4 | #define SCE_H HAL_GPIO_WritePin(LCD_CE_GPIO_Port,LCD_CE_Pin,GPIO_PIN_SET)
5 | #define SCE_L HAL_GPIO_WritePin(LCD_CE_GPIO_Port,LCD_CE_Pin,GPIO_PIN_RESET)
6 |
7 | #define DC_H HAL_GPIO_WritePin(LCD_DC_GPIO_Port,LCD_DC_Pin,GPIO_PIN_SET)
8 | #define DC_L HAL_GPIO_WritePin(LCD_DC_GPIO_Port,LCD_DC_Pin,GPIO_PIN_RESET)
9 |
10 | #define RST_H HAL_GPIO_WritePin(LCD_RST_GPIO_Port,LCD_RST_Pin,GPIO_PIN_SET)
11 | #define RST_L HAL_GPIO_WritePin(LCD_RST_GPIO_Port,LCD_RST_Pin,GPIO_PIN_RESET)
12 |
13 | #define DIN_H HAL_GPIO_WritePin(LCD_DIN_GPIO_Port,LCD_DIN_Pin,GPIO_PIN_SET)
14 | #define DIN_L HAL_GPIO_WritePin(LCD_DIN_GPIO_Port,LCD_DIN_Pin,GPIO_PIN_RESET)
15 |
16 | #define SCLK_H HAL_GPIO_WritePin(LCD_SCK_GPIO_Port,LCD_SCK_Pin,GPIO_PIN_SET)
17 | #define SCLK_L HAL_GPIO_WritePin(LCD_SCK_GPIO_Port,LCD_SCK_Pin,GPIO_PIN_RESET)
18 |
19 | #define CMD 0
20 | #define DAT 1
21 | enum StrLocation{
22 | Left=0,
23 | Middle,
24 | Right
25 | };
26 | void LCD_WriteByte(uint8_t dc,uint8_t b);
27 | void LCD_Init(void);
28 | void LCD_Clean(void);
29 | void LCD_SetXY(uint8_t x,uint8_t y);
30 | extern unsigned char font6x8[][6];
31 | uint8_t GetFont(uint8_t dat);
32 | void g_puts(uint8_t ch);
33 | void g_print(char* dat);
34 | void SetLine(uint8_t line);
35 | void l_print(char* dat,uint8_t line,enum StrLocation loc);
36 | void GUI_SetLine(uint8_t line);
37 | void f_print(char* dat);
38 | #endif
39 |
--------------------------------------------------------------------------------
/stm32/Inc/bmp280.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtxzsxxk/intelli-switch/6cf144ad8ddad1dadf7d2fe7dc54e730b10d069b/stm32/Inc/bmp280.h
--------------------------------------------------------------------------------
/stm32/Inc/esp8266_Driver.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtxzsxxk/intelli-switch/6cf144ad8ddad1dadf7d2fe7dc54e730b10d069b/stm32/Inc/esp8266_Driver.h
--------------------------------------------------------------------------------
/stm32/Inc/esp_http_pages.h:
--------------------------------------------------------------------------------
1 | #ifndef ESPHTTPPAGE
2 | #define ESPHTTPPAGE
3 | #include "main.h"
4 |
5 | extern char* ESP_SERVER_HTTP_ERRPAGE_404_1;
6 | extern char* ESP_SERVER_HTTP_ERRPAGE_404_2;
7 | extern char* ESP_SERVER_HTTP_INDEXPAGE;
8 | #endif
9 |
--------------------------------------------------------------------------------
/stm32/Inc/illuminanceMeas.h:
--------------------------------------------------------------------------------
1 | #ifndef ILLU_HEAD
2 | #define ILLU_HEAD
3 | #include "main.h"
4 | #define BH1750_ADDR 0xb8
5 |
6 | extern double illuminance;
7 | void bh1750_getIlluminance(void);
8 | #endif
9 |
--------------------------------------------------------------------------------
/stm32/Inc/main.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : main.h
5 | * @brief : Header for main.c file.
6 | * This file contains the common defines of the application.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | *
© Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __MAIN_H
24 | #define __MAIN_H
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include "stm32f4xx_hal.h"
32 |
33 | /* Private includes ----------------------------------------------------------*/
34 | /* USER CODE BEGIN Includes */
35 | #include
36 | #include
37 | #include
38 | #include "LCD_Driver.h"
39 | #include "esp8266_Driver.h"
40 | #include "bmp280.h"
41 | #include "illuminanceMeas.h"
42 | #include "DHT11.h"
43 | /* USER CODE END Includes */
44 |
45 | /* Exported types ------------------------------------------------------------*/
46 | /* USER CODE BEGIN ET */
47 |
48 | /* USER CODE END ET */
49 |
50 | /* Exported constants --------------------------------------------------------*/
51 | /* USER CODE BEGIN EC */
52 | extern I2C_HandleTypeDef hi2c1;
53 | extern uint8_t AppMode;
54 | extern RTC_TimeTypeDef now_Time;
55 | extern RTC_TimeTypeDef server_Time;
56 | extern UART_HandleTypeDef huart1;
57 | extern UART_HandleTypeDef huart2;
58 | extern TIM_HandleTypeDef htim3;
59 | void HOME_SCREEN(void);
60 |
61 | void FlashRead(void);
62 | void FlashWrite(void);
63 | /* USER CODE END EC */
64 |
65 | /* Exported macro ------------------------------------------------------------*/
66 | /* USER CODE BEGIN EM */
67 |
68 | /* USER CODE END EM */
69 |
70 | /* Exported functions prototypes ---------------------------------------------*/
71 | void Error_Handler(void);
72 |
73 | /* USER CODE BEGIN EFP */
74 | void delay_us(uint32_t i);
75 | /* USER CODE END EFP */
76 |
77 | /* Private defines -----------------------------------------------------------*/
78 | #define LED_TEST_Pin GPIO_PIN_13
79 | #define LED_TEST_GPIO_Port GPIOC
80 | #define LCD_SCK_Pin GPIO_PIN_5
81 | #define LCD_SCK_GPIO_Port GPIOA
82 | #define LCD_DIN_Pin GPIO_PIN_7
83 | #define LCD_DIN_GPIO_Port GPIOA
84 | #define LCD_CE_Pin GPIO_PIN_0
85 | #define LCD_CE_GPIO_Port GPIOB
86 | #define LCD_RST_Pin GPIO_PIN_1
87 | #define LCD_RST_GPIO_Port GPIOB
88 | #define LCD_DC_Pin GPIO_PIN_2
89 | #define LCD_DC_GPIO_Port GPIOB
90 | #define IOT_OUTPUT_1_Pin GPIO_PIN_12
91 | #define IOT_OUTPUT_1_GPIO_Port GPIOB
92 | #define IOT_OUTPUT_2_Pin GPIO_PIN_13
93 | #define IOT_OUTPUT_2_GPIO_Port GPIOB
94 | #define IOT_OUTPUT_5_Pin GPIO_PIN_8
95 | #define IOT_OUTPUT_5_GPIO_Port GPIOA
96 | #define IOT_OUTPUT_3_Pin GPIO_PIN_11
97 | #define IOT_OUTPUT_3_GPIO_Port GPIOA
98 | #define IOT_OUTPUT_4_Pin GPIO_PIN_12
99 | #define IOT_OUTPUT_4_GPIO_Port GPIOA
100 | #define DHT11_PORT_Pin GPIO_PIN_4
101 | #define DHT11_PORT_GPIO_Port GPIOB
102 | #define ESP8266_RST_Pin GPIO_PIN_5
103 | #define ESP8266_RST_GPIO_Port GPIOB
104 | #define Netconf_Pin GPIO_PIN_9
105 | #define Netconf_GPIO_Port GPIOB
106 | /* USER CODE BEGIN Private defines */
107 |
108 | /* USER CODE END Private defines */
109 |
110 | #ifdef __cplusplus
111 | }
112 | #endif
113 |
114 | #endif /* __MAIN_H */
115 |
116 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
117 |
--------------------------------------------------------------------------------
/stm32/Inc/stm32f4xx_hal_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_hal_conf_template.h
4 | * @author MCD Application Team
5 | * @brief HAL configuration template file.
6 | * This file should be copied to the application folder and renamed
7 | * to stm32f4xx_hal_conf.h.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © Copyright (c) 2017 STMicroelectronics.
12 | * All rights reserved.
13 | *
14 | * This software component is licensed by ST under BSD 3-Clause license,
15 | * the "License"; You may not use this file except in compliance with the
16 | * License. You may obtain a copy of the License at:
17 | * opensource.org/licenses/BSD-3-Clause
18 | *
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __STM32F4xx_HAL_CONF_H
24 | #define __STM32F4xx_HAL_CONF_H
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Exported types ------------------------------------------------------------*/
31 | /* Exported constants --------------------------------------------------------*/
32 |
33 | /* ########################## Module Selection ############################## */
34 | /**
35 | * @brief This is the list of modules to be used in the HAL driver
36 | */
37 | #define HAL_MODULE_ENABLED
38 |
39 | /* #define HAL_ADC_MODULE_ENABLED */
40 | /* #define HAL_CRYP_MODULE_ENABLED */
41 | /* #define HAL_CAN_MODULE_ENABLED */
42 | /* #define HAL_CRC_MODULE_ENABLED */
43 | /* #define HAL_CRYP_MODULE_ENABLED */
44 | /* #define HAL_DAC_MODULE_ENABLED */
45 | /* #define HAL_DCMI_MODULE_ENABLED */
46 | /* #define HAL_DMA2D_MODULE_ENABLED */
47 | /* #define HAL_ETH_MODULE_ENABLED */
48 | /* #define HAL_NAND_MODULE_ENABLED */
49 | /* #define HAL_NOR_MODULE_ENABLED */
50 | /* #define HAL_PCCARD_MODULE_ENABLED */
51 | /* #define HAL_SRAM_MODULE_ENABLED */
52 | /* #define HAL_SDRAM_MODULE_ENABLED */
53 | /* #define HAL_HASH_MODULE_ENABLED */
54 | #define HAL_I2C_MODULE_ENABLED
55 | /* #define HAL_I2S_MODULE_ENABLED */
56 | #define HAL_IWDG_MODULE_ENABLED
57 | /* #define HAL_LTDC_MODULE_ENABLED */
58 | /* #define HAL_RNG_MODULE_ENABLED */
59 | #define HAL_RTC_MODULE_ENABLED
60 | /* #define HAL_SAI_MODULE_ENABLED */
61 | /* #define HAL_SD_MODULE_ENABLED */
62 | /* #define HAL_MMC_MODULE_ENABLED */
63 | #define HAL_SPI_MODULE_ENABLED
64 | #define HAL_TIM_MODULE_ENABLED
65 | #define HAL_UART_MODULE_ENABLED
66 | /* #define HAL_USART_MODULE_ENABLED */
67 | /* #define HAL_IRDA_MODULE_ENABLED */
68 | /* #define HAL_SMARTCARD_MODULE_ENABLED */
69 | /* #define HAL_WWDG_MODULE_ENABLED */
70 | /* #define HAL_PCD_MODULE_ENABLED */
71 | /* #define HAL_HCD_MODULE_ENABLED */
72 | /* #define HAL_DSI_MODULE_ENABLED */
73 | /* #define HAL_QSPI_MODULE_ENABLED */
74 | /* #define HAL_QSPI_MODULE_ENABLED */
75 | /* #define HAL_CEC_MODULE_ENABLED */
76 | /* #define HAL_FMPI2C_MODULE_ENABLED */
77 | /* #define HAL_SPDIFRX_MODULE_ENABLED */
78 | /* #define HAL_DFSDM_MODULE_ENABLED */
79 | /* #define HAL_LPTIM_MODULE_ENABLED */
80 | /* #define HAL_EXTI_MODULE_ENABLED */
81 | #define HAL_GPIO_MODULE_ENABLED
82 | #define HAL_EXTI_MODULE_ENABLED
83 | #define HAL_DMA_MODULE_ENABLED
84 | #define HAL_RCC_MODULE_ENABLED
85 | #define HAL_FLASH_MODULE_ENABLED
86 | #define HAL_PWR_MODULE_ENABLED
87 | #define HAL_CORTEX_MODULE_ENABLED
88 |
89 | /* ########################## HSE/HSI Values adaptation ##################### */
90 | /**
91 | * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
92 | * This value is used by the RCC HAL module to compute the system frequency
93 | * (when HSE is used as system clock source, directly or through the PLL).
94 | */
95 | #if !defined (HSE_VALUE)
96 | #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */
97 | #endif /* HSE_VALUE */
98 |
99 | #if !defined (HSE_STARTUP_TIMEOUT)
100 | #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
101 | #endif /* HSE_STARTUP_TIMEOUT */
102 |
103 | /**
104 | * @brief Internal High Speed oscillator (HSI) value.
105 | * This value is used by the RCC HAL module to compute the system frequency
106 | * (when HSI is used as system clock source, directly or through the PLL).
107 | */
108 | #if !defined (HSI_VALUE)
109 | #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
110 | #endif /* HSI_VALUE */
111 |
112 | /**
113 | * @brief Internal Low Speed oscillator (LSI) value.
114 | */
115 | #if !defined (LSI_VALUE)
116 | #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
117 | #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
118 | The real value may vary depending on the variations
119 | in voltage and temperature.*/
120 | /**
121 | * @brief External Low Speed oscillator (LSE) value.
122 | */
123 | #if !defined (LSE_VALUE)
124 | #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
125 | #endif /* LSE_VALUE */
126 |
127 | #if !defined (LSE_STARTUP_TIMEOUT)
128 | #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
129 | #endif /* LSE_STARTUP_TIMEOUT */
130 |
131 | /**
132 | * @brief External clock source for I2S peripheral
133 | * This value is used by the I2S HAL module to compute the I2S clock source
134 | * frequency, this source is inserted directly through I2S_CKIN pad.
135 | */
136 | #if !defined (EXTERNAL_CLOCK_VALUE)
137 | #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/
138 | #endif /* EXTERNAL_CLOCK_VALUE */
139 |
140 | /* Tip: To avoid modifying this file each time you need to use different HSE,
141 | === you can define the HSE value in your toolchain compiler preprocessor. */
142 |
143 | /* ########################### System Configuration ######################### */
144 | /**
145 | * @brief This is the HAL system configuration section
146 | */
147 | #define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
148 | #define TICK_INT_PRIORITY ((uint32_t)1U) /*!< tick interrupt priority */
149 | #define USE_RTOS 0U
150 | #define PREFETCH_ENABLE 1U
151 | #define INSTRUCTION_CACHE_ENABLE 1U
152 | #define DATA_CACHE_ENABLE 1U
153 |
154 | /* ########################## Assert Selection ############################## */
155 | /**
156 | * @brief Uncomment the line below to expanse the "assert_param" macro in the
157 | * HAL drivers code
158 | */
159 | /* #define USE_FULL_ASSERT 1U */
160 |
161 | /* ################## Ethernet peripheral configuration ##################### */
162 |
163 | /* Section 1 : Ethernet peripheral configuration */
164 |
165 | /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
166 | #define MAC_ADDR0 2U
167 | #define MAC_ADDR1 0U
168 | #define MAC_ADDR2 0U
169 | #define MAC_ADDR3 0U
170 | #define MAC_ADDR4 0U
171 | #define MAC_ADDR5 0U
172 |
173 | /* Definition of the Ethernet driver buffers size and count */
174 | #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
175 | #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
176 | #define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
177 | #define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
178 |
179 | /* Section 2: PHY configuration section */
180 |
181 | /* DP83848_PHY_ADDRESS Address*/
182 | #define DP83848_PHY_ADDRESS 0x01U
183 | /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
184 | #define PHY_RESET_DELAY ((uint32_t)0x000000FFU)
185 | /* PHY Configuration delay */
186 | #define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU)
187 |
188 | #define PHY_READ_TO ((uint32_t)0x0000FFFFU)
189 | #define PHY_WRITE_TO ((uint32_t)0x0000FFFFU)
190 |
191 | /* Section 3: Common PHY Registers */
192 |
193 | #define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */
194 | #define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */
195 |
196 | #define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */
197 | #define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */
198 | #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */
199 | #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */
200 | #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */
201 | #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */
202 | #define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */
203 | #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */
204 | #define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */
205 | #define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */
206 |
207 | #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */
208 | #define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */
209 | #define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */
210 |
211 | /* Section 4: Extended PHY Registers */
212 | #define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
213 |
214 | #define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
215 | #define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
216 |
217 | /* ################## SPI peripheral configuration ########################## */
218 |
219 | /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
220 | * Activated: CRC code is present inside driver
221 | * Deactivated: CRC code cleaned from driver
222 | */
223 |
224 | #define USE_SPI_CRC 0U
225 |
226 | /* Includes ------------------------------------------------------------------*/
227 | /**
228 | * @brief Include module's header file
229 | */
230 |
231 | #ifdef HAL_RCC_MODULE_ENABLED
232 | #include "stm32f4xx_hal_rcc.h"
233 | #endif /* HAL_RCC_MODULE_ENABLED */
234 |
235 | #ifdef HAL_EXTI_MODULE_ENABLED
236 | #include "stm32f4xx_hal_exti.h"
237 | #endif /* HAL_EXTI_MODULE_ENABLED */
238 |
239 | #ifdef HAL_GPIO_MODULE_ENABLED
240 | #include "stm32f4xx_hal_gpio.h"
241 | #endif /* HAL_GPIO_MODULE_ENABLED */
242 |
243 | #ifdef HAL_DMA_MODULE_ENABLED
244 | #include "stm32f4xx_hal_dma.h"
245 | #endif /* HAL_DMA_MODULE_ENABLED */
246 |
247 | #ifdef HAL_CORTEX_MODULE_ENABLED
248 | #include "stm32f4xx_hal_cortex.h"
249 | #endif /* HAL_CORTEX_MODULE_ENABLED */
250 |
251 | #ifdef HAL_ADC_MODULE_ENABLED
252 | #include "stm32f4xx_hal_adc.h"
253 | #endif /* HAL_ADC_MODULE_ENABLED */
254 |
255 | #ifdef HAL_CAN_MODULE_ENABLED
256 | #include "stm32f4xx_hal_can.h"
257 | #endif /* HAL_CAN_MODULE_ENABLED */
258 |
259 | #ifdef HAL_CRC_MODULE_ENABLED
260 | #include "stm32f4xx_hal_crc.h"
261 | #endif /* HAL_CRC_MODULE_ENABLED */
262 |
263 | #ifdef HAL_CRYP_MODULE_ENABLED
264 | #include "stm32f4xx_hal_cryp.h"
265 | #endif /* HAL_CRYP_MODULE_ENABLED */
266 |
267 | #ifdef HAL_DMA2D_MODULE_ENABLED
268 | #include "stm32f4xx_hal_dma2d.h"
269 | #endif /* HAL_DMA2D_MODULE_ENABLED */
270 |
271 | #ifdef HAL_DAC_MODULE_ENABLED
272 | #include "stm32f4xx_hal_dac.h"
273 | #endif /* HAL_DAC_MODULE_ENABLED */
274 |
275 | #ifdef HAL_DCMI_MODULE_ENABLED
276 | #include "stm32f4xx_hal_dcmi.h"
277 | #endif /* HAL_DCMI_MODULE_ENABLED */
278 |
279 | #ifdef HAL_ETH_MODULE_ENABLED
280 | #include "stm32f4xx_hal_eth.h"
281 | #endif /* HAL_ETH_MODULE_ENABLED */
282 |
283 | #ifdef HAL_FLASH_MODULE_ENABLED
284 | #include "stm32f4xx_hal_flash.h"
285 | #endif /* HAL_FLASH_MODULE_ENABLED */
286 |
287 | #ifdef HAL_SRAM_MODULE_ENABLED
288 | #include "stm32f4xx_hal_sram.h"
289 | #endif /* HAL_SRAM_MODULE_ENABLED */
290 |
291 | #ifdef HAL_NOR_MODULE_ENABLED
292 | #include "stm32f4xx_hal_nor.h"
293 | #endif /* HAL_NOR_MODULE_ENABLED */
294 |
295 | #ifdef HAL_NAND_MODULE_ENABLED
296 | #include "stm32f4xx_hal_nand.h"
297 | #endif /* HAL_NAND_MODULE_ENABLED */
298 |
299 | #ifdef HAL_PCCARD_MODULE_ENABLED
300 | #include "stm32f4xx_hal_pccard.h"
301 | #endif /* HAL_PCCARD_MODULE_ENABLED */
302 |
303 | #ifdef HAL_SDRAM_MODULE_ENABLED
304 | #include "stm32f4xx_hal_sdram.h"
305 | #endif /* HAL_SDRAM_MODULE_ENABLED */
306 |
307 | #ifdef HAL_HASH_MODULE_ENABLED
308 | #include "stm32f4xx_hal_hash.h"
309 | #endif /* HAL_HASH_MODULE_ENABLED */
310 |
311 | #ifdef HAL_I2C_MODULE_ENABLED
312 | #include "stm32f4xx_hal_i2c.h"
313 | #endif /* HAL_I2C_MODULE_ENABLED */
314 |
315 | #ifdef HAL_I2S_MODULE_ENABLED
316 | #include "stm32f4xx_hal_i2s.h"
317 | #endif /* HAL_I2S_MODULE_ENABLED */
318 |
319 | #ifdef HAL_IWDG_MODULE_ENABLED
320 | #include "stm32f4xx_hal_iwdg.h"
321 | #endif /* HAL_IWDG_MODULE_ENABLED */
322 |
323 | #ifdef HAL_LTDC_MODULE_ENABLED
324 | #include "stm32f4xx_hal_ltdc.h"
325 | #endif /* HAL_LTDC_MODULE_ENABLED */
326 |
327 | #ifdef HAL_PWR_MODULE_ENABLED
328 | #include "stm32f4xx_hal_pwr.h"
329 | #endif /* HAL_PWR_MODULE_ENABLED */
330 |
331 | #ifdef HAL_RNG_MODULE_ENABLED
332 | #include "stm32f4xx_hal_rng.h"
333 | #endif /* HAL_RNG_MODULE_ENABLED */
334 |
335 | #ifdef HAL_RTC_MODULE_ENABLED
336 | #include "stm32f4xx_hal_rtc.h"
337 | #endif /* HAL_RTC_MODULE_ENABLED */
338 |
339 | #ifdef HAL_SAI_MODULE_ENABLED
340 | #include "stm32f4xx_hal_sai.h"
341 | #endif /* HAL_SAI_MODULE_ENABLED */
342 |
343 | #ifdef HAL_SD_MODULE_ENABLED
344 | #include "stm32f4xx_hal_sd.h"
345 | #endif /* HAL_SD_MODULE_ENABLED */
346 |
347 | #ifdef HAL_MMC_MODULE_ENABLED
348 | #include "stm32f4xx_hal_mmc.h"
349 | #endif /* HAL_MMC_MODULE_ENABLED */
350 |
351 | #ifdef HAL_SPI_MODULE_ENABLED
352 | #include "stm32f4xx_hal_spi.h"
353 | #endif /* HAL_SPI_MODULE_ENABLED */
354 |
355 | #ifdef HAL_TIM_MODULE_ENABLED
356 | #include "stm32f4xx_hal_tim.h"
357 | #endif /* HAL_TIM_MODULE_ENABLED */
358 |
359 | #ifdef HAL_UART_MODULE_ENABLED
360 | #include "stm32f4xx_hal_uart.h"
361 | #endif /* HAL_UART_MODULE_ENABLED */
362 |
363 | #ifdef HAL_USART_MODULE_ENABLED
364 | #include "stm32f4xx_hal_usart.h"
365 | #endif /* HAL_USART_MODULE_ENABLED */
366 |
367 | #ifdef HAL_IRDA_MODULE_ENABLED
368 | #include "stm32f4xx_hal_irda.h"
369 | #endif /* HAL_IRDA_MODULE_ENABLED */
370 |
371 | #ifdef HAL_SMARTCARD_MODULE_ENABLED
372 | #include "stm32f4xx_hal_smartcard.h"
373 | #endif /* HAL_SMARTCARD_MODULE_ENABLED */
374 |
375 | #ifdef HAL_WWDG_MODULE_ENABLED
376 | #include "stm32f4xx_hal_wwdg.h"
377 | #endif /* HAL_WWDG_MODULE_ENABLED */
378 |
379 | #ifdef HAL_PCD_MODULE_ENABLED
380 | #include "stm32f4xx_hal_pcd.h"
381 | #endif /* HAL_PCD_MODULE_ENABLED */
382 |
383 | #ifdef HAL_HCD_MODULE_ENABLED
384 | #include "stm32f4xx_hal_hcd.h"
385 | #endif /* HAL_HCD_MODULE_ENABLED */
386 |
387 | #ifdef HAL_DSI_MODULE_ENABLED
388 | #include "stm32f4xx_hal_dsi.h"
389 | #endif /* HAL_DSI_MODULE_ENABLED */
390 |
391 | #ifdef HAL_QSPI_MODULE_ENABLED
392 | #include "stm32f4xx_hal_qspi.h"
393 | #endif /* HAL_QSPI_MODULE_ENABLED */
394 |
395 | #ifdef HAL_CEC_MODULE_ENABLED
396 | #include "stm32f4xx_hal_cec.h"
397 | #endif /* HAL_CEC_MODULE_ENABLED */
398 |
399 | #ifdef HAL_FMPI2C_MODULE_ENABLED
400 | #include "stm32f4xx_hal_fmpi2c.h"
401 | #endif /* HAL_FMPI2C_MODULE_ENABLED */
402 |
403 | #ifdef HAL_SPDIFRX_MODULE_ENABLED
404 | #include "stm32f4xx_hal_spdifrx.h"
405 | #endif /* HAL_SPDIFRX_MODULE_ENABLED */
406 |
407 | #ifdef HAL_DFSDM_MODULE_ENABLED
408 | #include "stm32f4xx_hal_dfsdm.h"
409 | #endif /* HAL_DFSDM_MODULE_ENABLED */
410 |
411 | #ifdef HAL_LPTIM_MODULE_ENABLED
412 | #include "stm32f4xx_hal_lptim.h"
413 | #endif /* HAL_LPTIM_MODULE_ENABLED */
414 |
415 | /* Exported macro ------------------------------------------------------------*/
416 | #ifdef USE_FULL_ASSERT
417 | /**
418 | * @brief The assert_param macro is used for function's parameters check.
419 | * @param expr: If expr is false, it calls assert_failed function
420 | * which reports the name of the source file and the source
421 | * line number of the call that failed.
422 | * If expr is true, it returns no value.
423 | * @retval None
424 | */
425 | #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
426 | /* Exported functions ------------------------------------------------------- */
427 | void assert_failed(uint8_t* file, uint32_t line);
428 | #else
429 | #define assert_param(expr) ((void)0U)
430 | #endif /* USE_FULL_ASSERT */
431 |
432 | #ifdef __cplusplus
433 | }
434 | #endif
435 |
436 | #endif /* __STM32F4xx_HAL_CONF_H */
437 |
438 |
439 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
440 |
--------------------------------------------------------------------------------
/stm32/Inc/stm32f4xx_it.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32f4xx_it.h
5 | * @brief This file contains the headers of the interrupt handlers.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2021 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef __STM32F4xx_IT_H
23 | #define __STM32F4xx_IT_H
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Private includes ----------------------------------------------------------*/
30 | /* USER CODE BEGIN Includes */
31 |
32 | /* USER CODE END Includes */
33 |
34 | /* Exported types ------------------------------------------------------------*/
35 | /* USER CODE BEGIN ET */
36 |
37 | /* USER CODE END ET */
38 |
39 | /* Exported constants --------------------------------------------------------*/
40 | /* USER CODE BEGIN EC */
41 |
42 | /* USER CODE END EC */
43 |
44 | /* Exported macro ------------------------------------------------------------*/
45 | /* USER CODE BEGIN EM */
46 |
47 | /* USER CODE END EM */
48 |
49 | /* Exported functions prototypes ---------------------------------------------*/
50 | void NMI_Handler(void);
51 | void HardFault_Handler(void);
52 | void MemManage_Handler(void);
53 | void BusFault_Handler(void);
54 | void UsageFault_Handler(void);
55 | void SVC_Handler(void);
56 | void DebugMon_Handler(void);
57 | void PendSV_Handler(void);
58 | void SysTick_Handler(void);
59 | void TIM1_UP_TIM10_IRQHandler(void);
60 | void TIM4_IRQHandler(void);
61 | void USART1_IRQHandler(void);
62 | /* USER CODE BEGIN EFP */
63 |
64 | /* USER CODE END EFP */
65 |
66 | #ifdef __cplusplus
67 | }
68 | #endif
69 |
70 | #endif /* __STM32F4xx_IT_H */
71 |
72 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
73 |
--------------------------------------------------------------------------------
/stm32/IntelliSw.ioc:
--------------------------------------------------------------------------------
1 | #MicroXplorer Configuration settings - do not modify
2 | File.Version=6
3 | I2C1.ClockSpeed=10000
4 | I2C1.IPParameters=ClockSpeed,OwnAddress
5 | I2C1.OwnAddress=0
6 | IWDG.IPParameters=Prescaler,Reload
7 | IWDG.Prescaler=IWDG_PRESCALER_32
8 | IWDG.Reload=2000
9 | KeepUserPlacement=false
10 | Mcu.Family=STM32F4
11 | Mcu.IP0=I2C1
12 | Mcu.IP1=IWDG
13 | Mcu.IP2=NVIC
14 | Mcu.IP3=RCC
15 | Mcu.IP4=RTC
16 | Mcu.IP5=SPI1
17 | Mcu.IP6=SYS
18 | Mcu.IP7=TIM4
19 | Mcu.IP8=USART1
20 | Mcu.IP9=USART2
21 | Mcu.IPNb=10
22 | Mcu.Name=STM32F401C(B-C)Ux
23 | Mcu.Package=UFQFPN48
24 | Mcu.Pin0=PC13-ANTI_TAMP
25 | Mcu.Pin1=PC14-OSC32_IN
26 | Mcu.Pin10=PB0
27 | Mcu.Pin11=PB1
28 | Mcu.Pin12=PB2
29 | Mcu.Pin13=PB12
30 | Mcu.Pin14=PB13
31 | Mcu.Pin15=PB14
32 | Mcu.Pin16=PB15
33 | Mcu.Pin17=PA9
34 | Mcu.Pin18=PA10
35 | Mcu.Pin19=PA13
36 | Mcu.Pin2=PC15-OSC32_OUT
37 | Mcu.Pin20=PA14
38 | Mcu.Pin21=PB3
39 | Mcu.Pin22=PB4
40 | Mcu.Pin23=PB6
41 | Mcu.Pin24=PB7
42 | Mcu.Pin25=VP_IWDG_VS_IWDG
43 | Mcu.Pin26=VP_RTC_VS_RTC_Activate
44 | Mcu.Pin27=VP_RTC_VS_RTC_Calendar
45 | Mcu.Pin28=VP_SYS_VS_tim1
46 | Mcu.Pin29=VP_TIM4_VS_ClockSourceINT
47 | Mcu.Pin3=PH0 - OSC_IN
48 | Mcu.Pin4=PH1 - OSC_OUT
49 | Mcu.Pin5=PA2
50 | Mcu.Pin6=PA3
51 | Mcu.Pin7=PA5
52 | Mcu.Pin8=PA6
53 | Mcu.Pin9=PA7
54 | Mcu.PinsNb=30
55 | Mcu.ThirdPartyNb=0
56 | Mcu.UserConstants=
57 | Mcu.UserName=STM32F401CCUx
58 | MxCube.Version=5.3.0
59 | MxDb.Version=DB.5.0.30
60 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
61 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false
62 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
63 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false
64 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false
65 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false
66 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_2
67 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
68 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
69 | NVIC.TIM1_UP_TIM10_IRQn=true\:1\:0\:true\:false\:true\:false\:true
70 | NVIC.TIM4_IRQn=true\:1\:1\:true\:false\:true\:true\:true
71 | NVIC.TimeBase=TIM1_UP_TIM10_IRQn
72 | NVIC.TimeBaseIP=TIM1
73 | NVIC.USART1_IRQn=true\:2\:0\:true\:false\:true\:true\:true
74 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
75 | PA10.Mode=Asynchronous
76 | PA10.Signal=USART1_RX
77 | PA13.Mode=Trace_Asynchronous_SW
78 | PA13.Signal=SYS_JTMS-SWDIO
79 | PA14.Mode=Trace_Asynchronous_SW
80 | PA14.Signal=SYS_JTCK-SWCLK
81 | PA2.Mode=Asynchronous
82 | PA2.Signal=USART2_TX
83 | PA3.Mode=Asynchronous
84 | PA3.Signal=USART2_RX
85 | PA5.Mode=Full_Duplex_Master
86 | PA5.Signal=SPI1_SCK
87 | PA6.Mode=Full_Duplex_Master
88 | PA6.Signal=SPI1_MISO
89 | PA7.Mode=Full_Duplex_Master
90 | PA7.Signal=SPI1_MOSI
91 | PA9.Mode=Asynchronous
92 | PA9.Signal=USART1_TX
93 | PB0.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
94 | PB0.GPIO_Label=SPI1_CS
95 | PB0.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
96 | PB0.GPIO_PuPd=GPIO_NOPULL
97 | PB0.GPIO_Speed=GPIO_SPEED_FREQ_LOW
98 | PB0.Locked=true
99 | PB0.PinState=GPIO_PIN_RESET
100 | PB0.Signal=GPIO_Output
101 | PB1.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
102 | PB1.GPIO_Label=LCD_RST
103 | PB1.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
104 | PB1.GPIO_PuPd=GPIO_NOPULL
105 | PB1.GPIO_Speed=GPIO_SPEED_FREQ_LOW
106 | PB1.Locked=true
107 | PB1.PinState=GPIO_PIN_RESET
108 | PB1.Signal=GPIO_Output
109 | PB12.GPIOParameters=GPIO_Label
110 | PB12.GPIO_Label=IOT_OUTPUT_1
111 | PB12.Locked=true
112 | PB12.Signal=GPIO_Output
113 | PB13.GPIOParameters=GPIO_Label
114 | PB13.GPIO_Label=IOT_OUTPUT_2
115 | PB13.Locked=true
116 | PB13.Signal=GPIO_Output
117 | PB14.GPIOParameters=GPIO_Label
118 | PB14.GPIO_Label=IOT_OUTPUT_3
119 | PB14.Locked=true
120 | PB14.Signal=GPIO_Output
121 | PB15.GPIOParameters=GPIO_Label
122 | PB15.GPIO_Label=IOT_OUTPUT_4
123 | PB15.Locked=true
124 | PB15.Signal=GPIO_Output
125 | PB2.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
126 | PB2.GPIO_Label=LCD_DC
127 | PB2.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
128 | PB2.GPIO_PuPd=GPIO_NOPULL
129 | PB2.GPIO_Speed=GPIO_SPEED_FREQ_LOW
130 | PB2.Locked=true
131 | PB2.PinState=GPIO_PIN_RESET
132 | PB2.Signal=GPIO_Output
133 | PB3.Mode=Trace_Asynchronous_SW
134 | PB3.Signal=SYS_JTDO-SWO
135 | PB4.GPIOParameters=GPIO_Speed,GPIO_Label
136 | PB4.GPIO_Label=DHT11_PORT
137 | PB4.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
138 | PB4.Locked=true
139 | PB4.Signal=GPIO_Output
140 | PB6.Mode=I2C
141 | PB6.Signal=I2C1_SCL
142 | PB7.Mode=I2C
143 | PB7.Signal=I2C1_SDA
144 | PC13-ANTI_TAMP.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
145 | PC13-ANTI_TAMP.GPIO_Label=LED_TEST
146 | PC13-ANTI_TAMP.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
147 | PC13-ANTI_TAMP.GPIO_PuPd=GPIO_NOPULL
148 | PC13-ANTI_TAMP.GPIO_Speed=GPIO_SPEED_FREQ_LOW
149 | PC13-ANTI_TAMP.Locked=true
150 | PC13-ANTI_TAMP.PinState=GPIO_PIN_RESET
151 | PC13-ANTI_TAMP.Signal=GPIO_Output
152 | PC14-OSC32_IN.Mode=LSE-External-Oscillator
153 | PC14-OSC32_IN.Signal=RCC_OSC32_IN
154 | PC15-OSC32_OUT.Mode=LSE-External-Oscillator
155 | PC15-OSC32_OUT.Signal=RCC_OSC32_OUT
156 | PCC.Checker=false
157 | PCC.Line=STM32F401
158 | PCC.MCU=STM32F401C(B-C)Ux
159 | PCC.PartNumber=STM32F401CCUx
160 | PCC.Seq0=0
161 | PCC.Series=STM32F4
162 | PCC.Temperature=25
163 | PCC.Vdd=3.3
164 | PH0\ -\ OSC_IN.Mode=HSE-External-Oscillator
165 | PH0\ -\ OSC_IN.Signal=RCC_OSC_IN
166 | PH1\ -\ OSC_OUT.Mode=HSE-External-Oscillator
167 | PH1\ -\ OSC_OUT.Signal=RCC_OSC_OUT
168 | PinOutPanel.RotationAngle=0
169 | ProjectManager.AskForMigrate=true
170 | ProjectManager.BackupPrevious=false
171 | ProjectManager.CompilerOptimize=6
172 | ProjectManager.ComputerToolchain=false
173 | ProjectManager.CoupleFile=false
174 | ProjectManager.CustomerFirmwarePackage=
175 | ProjectManager.DefaultFWLocation=true
176 | ProjectManager.DeletePrevious=true
177 | ProjectManager.DeviceId=STM32F401CCUx
178 | ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.24.2
179 | ProjectManager.FreePins=false
180 | ProjectManager.HalAssertFull=false
181 | ProjectManager.HeapSize=0x800
182 | ProjectManager.KeepUserCode=true
183 | ProjectManager.LastFirmware=true
184 | ProjectManager.LibraryCopy=0
185 | ProjectManager.MainLocation=Src
186 | ProjectManager.NoMain=false
187 | ProjectManager.PreviousToolchain=
188 | ProjectManager.ProjectBuild=false
189 | ProjectManager.ProjectFileName=IntelliSw.ioc
190 | ProjectManager.ProjectName=IntelliSw
191 | ProjectManager.StackSize=0x1200
192 | ProjectManager.TargetToolchain=MDK-ARM V5
193 | ProjectManager.ToolChainLocation=
194 | ProjectManager.UnderRoot=false
195 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_SPI1_Init-SPI1-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_USART2_UART_Init-USART2-false-HAL-true,6-MX_I2C1_Init-I2C1-false-HAL-true,7-MX_RTC_Init-RTC-false-HAL-true,8-MX_TIM4_Init-TIM4-false-HAL-true
196 | RCC.48MHZClocksFreq_Value=48000000
197 | RCC.AHBFreq_Value=84000000
198 | RCC.APB1CLKDivider=RCC_HCLK_DIV2
199 | RCC.APB1Freq_Value=42000000
200 | RCC.APB1TimFreq_Value=84000000
201 | RCC.APB2Freq_Value=84000000
202 | RCC.APB2TimFreq_Value=84000000
203 | RCC.CortexFreq_Value=84000000
204 | RCC.FCLKCortexFreq_Value=84000000
205 | RCC.HCLKFreq_Value=84000000
206 | RCC.HSE_VALUE=25000000
207 | RCC.HSI_VALUE=16000000
208 | RCC.I2SClocksFreq_Value=96000000
209 | RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,FCLKCortexFreq_Value,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSI_VALUE,PLLCLKFreq_Value,PLLM,PLLN,PLLP,PLLQ,PLLQCLKFreq_Value,PLLSourceVirtual,RCC_RTC_Clock_Source,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S
210 | RCC.LSI_VALUE=32000
211 | RCC.PLLCLKFreq_Value=84000000
212 | RCC.PLLM=25
213 | RCC.PLLN=336
214 | RCC.PLLP=RCC_PLLP_DIV4
215 | RCC.PLLQ=7
216 | RCC.PLLQCLKFreq_Value=48000000
217 | RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE
218 | RCC.RCC_RTC_Clock_Source=RCC_RTCCLKSOURCE_LSE
219 | RCC.RTCFreq_Value=32768
220 | RCC.RTCHSEDivFreq_Value=12500000
221 | RCC.SYSCLKFreq_VALUE=84000000
222 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
223 | RCC.VCOI2SOutputFreq_Value=192000000
224 | RCC.VCOInputFreq_Value=1000000
225 | RCC.VCOOutputFreq_Value=336000000
226 | RCC.VcooutputI2S=96000000
227 | RTC.Date=20
228 | RTC.Format=RTC_FORMAT_BIN
229 | RTC.Hours=13
230 | RTC.IPParameters=Format,Hours,Minutes,Seconds,Year,Date,WeekDay
231 | RTC.Minutes=47
232 | RTC.Seconds=55
233 | RTC.WeekDay=RTC_WEEKDAY_WEDNESDAY
234 | RTC.Year=21
235 | SPI1.CalculateBaudRate=42.0 MBits/s
236 | SPI1.Direction=SPI_DIRECTION_2LINES
237 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
238 | SPI1.Mode=SPI_MODE_MASTER
239 | SPI1.VirtualType=VM_MASTER
240 | TIM4.CounterMode=TIM_COUNTERMODE_DOWN
241 | TIM4.IPParameters=Prescaler,CounterMode,Period
242 | TIM4.Period=1
243 | TIM4.Prescaler=84-1
244 | USART1.IPParameters=VirtualMode
245 | USART1.VirtualMode=VM_ASYNC
246 | USART2.IPParameters=VirtualMode
247 | USART2.VirtualMode=VM_ASYNC
248 | VP_IWDG_VS_IWDG.Mode=IWDG_Activate
249 | VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG
250 | VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled
251 | VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate
252 | VP_RTC_VS_RTC_Calendar.Mode=RTC_Calendar
253 | VP_RTC_VS_RTC_Calendar.Signal=RTC_VS_RTC_Calendar
254 | VP_SYS_VS_tim1.Mode=TIM1
255 | VP_SYS_VS_tim1.Signal=SYS_VS_tim1
256 | VP_TIM4_VS_ClockSourceINT.Mode=Internal
257 | VP_TIM4_VS_ClockSourceINT.Signal=TIM4_VS_ClockSourceINT
258 | board=custom
259 |
--------------------------------------------------------------------------------
/stm32/MDK-ARM/DHT11.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtxzsxxk/intelli-switch/6cf144ad8ddad1dadf7d2fe7dc54e730b10d069b/stm32/MDK-ARM/DHT11.c
--------------------------------------------------------------------------------
/stm32/MDK-ARM/GUI.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtxzsxxk/intelli-switch/6cf144ad8ddad1dadf7d2fe7dc54e730b10d069b/stm32/MDK-ARM/GUI.c
--------------------------------------------------------------------------------
/stm32/MDK-ARM/IntelliSw.uvprojx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2.1
5 |
6 | ### uVision Project, (C) Keil Software
7 |
8 |
9 |
10 | IntelliSw
11 | 0x4
12 | ARM-ADS
13 |
14 |
15 | STM32F401CCUx
16 | STMicroelectronics
17 | Keil.STM32F4xx_DFP.2.13.0
18 | http://www.keil.com/pack
19 | IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4")
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | $$Device:STM32F401CCUx$CMSIS/SVD/STM32F401x.svd
35 | 0
36 | 0
37 |
38 |
39 |
40 |
41 |
42 |
43 | 0
44 | 0
45 | 0
46 | 0
47 | 1
48 |
49 | IntelliSw\
50 | IntelliSw
51 | 1
52 | 0
53 | 1
54 | 1
55 | 1
56 |
57 | 1
58 | 0
59 | 0
60 |
61 | 0
62 | 0
63 |
64 |
65 | 0
66 | 0
67 | 0
68 | 0
69 |
70 |
71 | 0
72 | 0
73 |
74 |
75 | 0
76 | 0
77 | 0
78 | 0
79 |
80 |
81 | 0
82 | 0
83 |
84 |
85 | 0
86 | 0
87 |
88 | 0
89 |
90 |
91 |
92 | 0
93 | 0
94 | 0
95 | 0
96 | 0
97 | 1
98 | 0
99 | 0
100 | 0
101 | 0
102 | 3
103 |
104 |
105 | 0
106 |
107 |
108 | SARMCM3.DLL
109 | -REMAP -MPU
110 | DCM.DLL
111 | -pCM4
112 | SARMCM3.DLL
113 | -MPU
114 | TCM.DLL
115 | -pCM4
116 |
117 |
118 |
119 | 1
120 | 0
121 | 0
122 | 0
123 | 16
124 |
125 |
126 | 0
127 | 1
128 | 1
129 | 1
130 | 1
131 | 1
132 | 1
133 | 1
134 | 0
135 | 1
136 |
137 |
138 | 1
139 | 1
140 | 1
141 | 1
142 | 1
143 | 1
144 | 1
145 | 1
146 | 1
147 | 1
148 |
149 | 0
150 | 11
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 | STLink\ST-LINKIII-KEIL_SWO.dll
165 |
166 |
167 |
168 |
169 | 1
170 | 0
171 | 0
172 | 1
173 | 1
174 | 4107
175 |
176 | 1
177 | STLink\ST-LINKIII-KEIL_SWO.dll
178 |
179 |
180 |
181 |
182 |
183 | 0
184 |
185 |
186 |
187 | 0
188 | 1
189 | 1
190 | 1
191 | 1
192 | 1
193 | 1
194 | 1
195 | 0
196 | 1
197 | 1
198 | 0
199 | 1
200 | 1
201 | 0
202 | 0
203 | 1
204 | 1
205 | 1
206 | 1
207 | 1
208 | 1
209 | 1
210 | 1
211 | 1
212 | 0
213 | 0
214 | "Cortex-M4"
215 |
216 | 0
217 | 0
218 | 0
219 | 1
220 | 1
221 | 0
222 | 0
223 | 2
224 | 0
225 | 0
226 | 8
227 | 1
228 | 0
229 | 0
230 | 3
231 | 3
232 | 0
233 | 0
234 | 0
235 | 0
236 | 0
237 | 0
238 | 0
239 | 0
240 | 0
241 | 0
242 | 1
243 | 0
244 | 0
245 | 0
246 | 0
247 | 1
248 | 0
249 |
250 |
251 | 0
252 | 0x0
253 | 0x0
254 |
255 |
256 | 0
257 | 0x0
258 | 0x0
259 |
260 |
261 | 0
262 | 0x0
263 | 0x0
264 |
265 |
266 | 0
267 | 0x0
268 | 0x0
269 |
270 |
271 | 0
272 | 0x0
273 | 0x0
274 |
275 |
276 | 0
277 | 0x0
278 | 0x0
279 |
280 |
281 | 0
282 | 0x20000000
283 | 0x10000
284 |
285 |
286 | 1
287 | 0x8000000
288 | 0x40000
289 |
290 |
291 | 0
292 | 0x0
293 | 0x0
294 |
295 |
296 | 1
297 | 0x0
298 | 0x0
299 |
300 |
301 | 1
302 | 0x0
303 | 0x0
304 |
305 |
306 | 1
307 | 0x0
308 | 0x0
309 |
310 |
311 | 1
312 | 0x8000000
313 | 0x40000
314 |
315 |
316 | 1
317 | 0x0
318 | 0x0
319 |
320 |
321 | 0
322 | 0x0
323 | 0x0
324 |
325 |
326 | 0
327 | 0x0
328 | 0x0
329 |
330 |
331 | 0
332 | 0x0
333 | 0x0
334 |
335 |
336 | 0
337 | 0x20000000
338 | 0x10000
339 |
340 |
341 | 0
342 | 0x0
343 | 0x0
344 |
345 |
346 |
347 |
348 |
349 | 1
350 | 4
351 | 0
352 | 0
353 | 1
354 | 0
355 | 0
356 | 0
357 | 0
358 | 0
359 | 2
360 | 0
361 | 0
362 | 1
363 | 0
364 |
365 |
366 | USE_HAL_DRIVER,STM32F401xC,USE_HAL_DRIVER,STM32F401xC
367 |
368 | ../Inc; ../Drivers/STM32F4xx_HAL_Driver/Inc; ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy; ../Drivers/CMSIS/Device/ST/STM32F4xx/Include; ../Drivers/CMSIS/Include
369 |
370 |
371 |
372 | 1
373 | 0
374 | 0
375 | 0
376 | 0
377 | 0
378 | 0
379 | 0
380 | 0
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 | 1
390 | 0
391 | 0
392 | 0
393 | 1
394 | 0
395 | 0x08000000
396 | 0x20000000
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 | Application/MDK-ARM
410 |
411 |
412 | startup_stm32f401xc.s
413 | 2
414 | startup_stm32f401xc.s
415 |
416 |
417 |
418 |
419 | ::CMSIS
420 |
421 |
422 | Application/User
423 |
424 |
425 | GUI.c
426 | 1
427 | .\GUI.c
428 |
429 |
430 | LCD_Driver.c
431 | 1
432 | .\LCD_Driver.c
433 |
434 |
435 | bmp280.c
436 | 1
437 | .\bmp280.c
438 |
439 |
440 | illuminanceMeas.c
441 | 1
442 | .\illuminanceMeas.c
443 |
444 |
445 | DHT11.c
446 | 1
447 | .\DHT11.c
448 |
449 |
450 | main.c
451 | 1
452 | ../Src/main.c
453 |
454 |
455 | stm32f4xx_it.c
456 | 1
457 | ../Src/stm32f4xx_it.c
458 |
459 |
460 | stm32f4xx_hal_msp.c
461 | 1
462 | ../Src/stm32f4xx_hal_msp.c
463 |
464 |
465 | stm32f4xx_hal_timebase_tim.c
466 | 1
467 | ../Src/stm32f4xx_hal_timebase_tim.c
468 |
469 |
470 |
471 |
472 | Drivers/STM32F4xx_HAL_Driver
473 |
474 |
475 | stm32f4xx_hal_i2c.c
476 | 1
477 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c
478 |
479 |
480 | stm32f4xx_hal_i2c_ex.c
481 | 1
482 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c
483 |
484 |
485 | stm32f4xx_hal_iwdg.c
486 | 1
487 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_iwdg.c
488 |
489 |
490 | stm32f4xx_hal_rtc.c
491 | 1
492 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc.c
493 |
494 |
495 | stm32f4xx_hal_rtc_ex.c
496 | 1
497 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc_ex.c
498 |
499 |
500 | stm32f4xx_hal_spi.c
501 | 1
502 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c
503 |
504 |
505 | stm32f4xx_hal_tim.c
506 | 1
507 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c
508 |
509 |
510 | stm32f4xx_hal_tim_ex.c
511 | 1
512 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c
513 |
514 |
515 | stm32f4xx_hal_uart.c
516 | 1
517 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c
518 |
519 |
520 | stm32f4xx_hal_rcc.c
521 | 1
522 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c
523 |
524 |
525 | stm32f4xx_hal_rcc_ex.c
526 | 1
527 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c
528 |
529 |
530 | stm32f4xx_hal_flash.c
531 | 1
532 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c
533 |
534 |
535 | stm32f4xx_hal_flash_ex.c
536 | 1
537 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c
538 |
539 |
540 | stm32f4xx_hal_flash_ramfunc.c
541 | 1
542 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c
543 |
544 |
545 | stm32f4xx_hal_gpio.c
546 | 1
547 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c
548 |
549 |
550 | stm32f4xx_hal_dma_ex.c
551 | 1
552 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c
553 |
554 |
555 | stm32f4xx_hal_dma.c
556 | 1
557 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c
558 |
559 |
560 | stm32f4xx_hal_pwr.c
561 | 1
562 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c
563 |
564 |
565 | stm32f4xx_hal_pwr_ex.c
566 | 1
567 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c
568 |
569 |
570 | stm32f4xx_hal_cortex.c
571 | 1
572 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c
573 |
574 |
575 | stm32f4xx_hal.c
576 | 1
577 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c
578 |
579 |
580 | stm32f4xx_hal_exti.c
581 | 1
582 | ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c
583 |
584 |
585 |
586 |
587 | Drivers/CMSIS
588 |
589 |
590 | system_stm32f4xx.c
591 | 1
592 | ../Src/system_stm32f4xx.c
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
--------------------------------------------------------------------------------
/stm32/MDK-ARM/LCD_Driver.c:
--------------------------------------------------------------------------------
1 | #include "LCD_Driver.h"
2 | uint8_t g_line=0;
3 | uint8_t g_x=0;
4 | void LCD_WriteByte(uint8_t dc,uint8_t b)
5 | {
6 | uint8_t i;
7 | SCE_H;
8 | SCE_L;
9 | if(dc) DC_H;
10 | else DC_L;
11 | for(i=0;i<8;i++)
12 | {
13 | //10101010
14 | SCLK_L;
15 | if(b&0x80)
16 | DIN_H;
17 | else DIN_L;
18 | SCLK_H;
19 | b=b<<1;
20 | //delay_us(50);
21 | }
22 | SCLK_L;
23 | DIN_L;
24 | SCE_H;
25 | //delay_us(100);
26 | }
27 |
28 | void LCD_Init(void)
29 | {
30 | SCE_H;
31 | RST_L;
32 | HAL_Delay(10);
33 | RST_H;
34 | LCD_WriteByte(CMD,0x21);
35 | LCD_WriteByte(CMD,0xc8);
36 | LCD_WriteByte(CMD,0x06);
37 | LCD_WriteByte(CMD,0x13);
38 | LCD_WriteByte(CMD,0x20);
39 | LCD_Clean();
40 | LCD_WriteByte(CMD,0x0c);
41 | SCE_L;
42 | }
43 |
44 | void LCD_SetXY(uint8_t x,uint8_t y)
45 | {
46 | g_x=x;g_line=y;
47 | x=83-x;
48 | y=5-y;
49 | x+=0x80;
50 | y+=0x40;
51 |
52 | LCD_WriteByte(CMD,x);
53 | LCD_WriteByte(CMD,y);
54 | }
55 |
56 | void LCD_Clean(void)
57 | {
58 | uint16_t i=503;
59 | for(i=0;i<503;i++)
60 | {
61 | LCD_WriteByte(DAT,0x00);
62 | }
63 | }
64 |
65 | uint8_t GetFont(uint8_t dat)
66 | {
67 | return dat-32;
68 | }
69 |
70 | uint8_t bin[]={1,2,4,8,16,32,64,128};
71 | unsigned char Reverse(unsigned char x)
72 | {
73 | unsigned char t=0;
74 | for(unsigned char i=0;i<8;i++)
75 | {
76 | t+=((x&0x80)?1:0)*bin[i];
77 | x<<=1;
78 | }
79 | return t;
80 | }
81 |
82 | void g_puts(uint8_t ch)
83 | {
84 | uint8_t i,p=GetFont(ch);
85 | for(i=0;i<6;i++)
86 | {
87 | LCD_SetXY(g_x,g_line);
88 | LCD_WriteByte(DAT,Reverse(font6x8[p][i]));
89 | //LCD_WriteByte(DAT,font6x8[p][i]);
90 | g_x++;
91 |
92 | }
93 | }
94 |
95 | //write by userdefine-font
96 | void u_puts(uint8_t* user_define_font)
97 | {
98 | uint8_t i;
99 | for(i=0;i<6;i++)
100 | {
101 | LCD_SetXY(g_x,g_line);
102 | LCD_WriteByte(DAT,Reverse(user_define_font[i]));
103 | //LCD_WriteByte(DAT,font6x8[p][i]);
104 | g_x++;
105 | }
106 | }
107 |
108 | void g_print(char* dat)
109 | {
110 | uint8_t cc=*dat;//ShowChar(cc);
111 | while(cc!=0)
112 | {
113 | cc=*(dat++);
114 | g_puts(cc);
115 | }
116 | }
117 |
118 | void SetLine(uint8_t line)
119 | {
120 | g_line=line;
121 | //LCD_SetXY(83,5-line);
122 | LCD_SetXY(0,line);
123 | }
124 |
125 | uint8_t line_ctl=0;
126 |
127 | void GUI_SetLine(uint8_t line)
128 | {
129 | line_ctl=line;
130 | }
131 |
132 | void f_print(char* dat)
133 | {
134 | uint8_t cnt=0,length=strlen((const char*)dat);
135 | char buffer[14];
136 | memset(buffer,0,sizeof(buffer));
137 | if(length<=14)
138 | {
139 | memset(buffer,' ',sizeof(buffer));
140 | for(cnt=0;cnt14)
151 | {
152 | memcpy(buffer,dat+cnt,14);
153 | l_print((char*)&" ",line_ctl,Left);
154 | l_print(buffer,line_ctl,Left);
155 | if(line_ctl==5)
156 | line_ctl=0;
157 | else
158 | line_ctl++;
159 | memset(buffer,0,sizeof(buffer));
160 | cnt+=14;
161 | }
162 | memcpy(buffer,dat+cnt,length-cnt);
163 | uint8_t t_buffer[14];
164 | memset(t_buffer,' ',sizeof(t_buffer));
165 | for(cnt=0;cnt
225 | { 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 }, // ?
226 | { 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E }, // @
227 | { 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C }, // A
228 | { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 }, // B
229 | { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 }, // C
230 | { 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C }, // D
231 | { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 }, // E
232 | { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 }, // F
233 | { 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A }, // G
234 | { 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F }, // H
235 | { 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 }, // I
236 | { 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 }, // J
237 | { 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 }, // K
238 | { 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 }, // L
239 | { 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F }, // M
240 | { 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F }, // N
241 | { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E }, // O
242 | { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 }, // P
243 | { 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E }, // Q
244 | { 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 }, // R
245 | { 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 }, // S
246 | { 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 }, // T
247 | { 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F }, // U
248 | { 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F }, // V
249 | { 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F }, // W
250 | { 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 }, // X
251 | { 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 }, // Y
252 | { 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 }, // Z
253 | { 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 }, // [
254 | { 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 }, // 55
255 | { 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 }, // ]
256 | { 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 }, // ^
257 | { 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 }, // _
258 | { 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 }, // '
259 | { 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 }, // a
260 | { 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 }, // b
261 | { 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 }, // c
262 | { 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F }, // d
263 | { 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 }, // e
264 | { 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 }, // f
265 | { 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C }, // g
266 | { 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 }, // h
267 | { 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 }, // i
268 | { 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 }, // j
269 | { 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 }, // k
270 | { 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 }, // l
271 | { 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 }, // m
272 | { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 }, // n
273 | { 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 }, // o
274 | { 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 }, // p
275 | { 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC }, // q
276 | { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 }, // r
277 | { 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 }, // s
278 | { 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 }, // t
279 | { 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C }, // u
280 | { 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C }, // v
281 | { 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C }, // w
282 | { 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 }, // x
283 | { 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C }, // y
284 | { 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 }, // z
285 | { 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 } // horiz lines
286 | };
287 |
--------------------------------------------------------------------------------
/stm32/MDK-ARM/bmp280.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtxzsxxk/intelli-switch/6cf144ad8ddad1dadf7d2fe7dc54e730b10d069b/stm32/MDK-ARM/bmp280.c
--------------------------------------------------------------------------------
/stm32/MDK-ARM/esp8266_Driver.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtxzsxxk/intelli-switch/6cf144ad8ddad1dadf7d2fe7dc54e730b10d069b/stm32/MDK-ARM/esp8266_Driver.c
--------------------------------------------------------------------------------
/stm32/MDK-ARM/esp_http_pages.c:
--------------------------------------------------------------------------------
1 | #include "esp_http_pages.h"
2 |
3 | char* ESP_SERVER_HTTP_ERRPAGE_404_1="Unhandled ExceptionHTTP 404 ERROR
";
4 | char* ESP_SERVER_HTTP_ERRPAGE_404_2="
IntelliSw HTTP Server
\r\n\r\n";
5 |
6 | char* ESP_SERVER_HTTP_INDEXPAGE="IntelliSw - MCU";
7 |
--------------------------------------------------------------------------------
/stm32/MDK-ARM/illuminanceMeas.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtxzsxxk/intelli-switch/6cf144ad8ddad1dadf7d2fe7dc54e730b10d069b/stm32/MDK-ARM/illuminanceMeas.c
--------------------------------------------------------------------------------
/stm32/MDK-ARM/mcu_conf.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | IntelliSw - MCU配置
8 |
9 |
211 |
212 |
213 |
214 |
219 |
220 |
221 |
222 |
Configurations of MCU Network
223 |
224 |
Wi-Fi SSID
225 |
226 |
227 |
228 |
Wi-Fi PassWord
229 |
230 |
234 |
235 |
Server IP
236 |
237 |
238 |
239 |
Server Port
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
306 |
307 |
308 |
309 |
310 |
--------------------------------------------------------------------------------
/stm32/MDK-ARM/startup_stm32f401xc.s:
--------------------------------------------------------------------------------
1 | ;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
2 | ;* File Name : startup_stm32f401xc.s
3 | ;* Author : MCD Application Team
4 | ;* Description : STM32F401xc devices vector table for MDK-ARM toolchain.
5 | ;* This module performs:
6 | ;* - Set the initial SP
7 | ;* - Set the initial PC == Reset_Handler
8 | ;* - Set the vector table entries with the exceptions ISR address
9 | ;* - Branches to __main in the C library (which eventually
10 | ;* calls main()).
11 | ;* After Reset the CortexM4 processor is in Thread mode,
12 | ;* priority is Privileged, and the Stack is set to Main.
13 | ;* <<< Use Configuration Wizard in Context Menu >>>
14 | ;*******************************************************************************
15 | ;
16 | ;* Redistribution and use in source and binary forms, with or without modification,
17 | ;* are permitted provided that the following conditions are met:
18 | ;* 1. Redistributions of source code must retain the above copyright notice,
19 | ;* this list of conditions and the following disclaimer.
20 | ;* 2. Redistributions in binary form must reproduce the above copyright notice,
21 | ;* this list of conditions and the following disclaimer in the documentation
22 | ;* and/or other materials provided with the distribution.
23 | ;* 3. Neither the name of STMicroelectronics nor the names of its contributors
24 | ;* may be used to endorse or promote products derived from this software
25 | ;* without specific prior written permission.
26 | ;*
27 | ;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 | ;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 | ;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30 | ;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31 | ;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 | ;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33 | ;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34 | ;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35 | ;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 | ;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 | ;
38 | ;*******************************************************************************
39 |
40 | ; Amount of memory (in bytes) allocated for Stack
41 | ; Tailor this value to your application needs
42 | ; Stack Configuration
43 | ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
44 | ;
45 |
46 | Stack_Size EQU 0x1200
47 |
48 | AREA STACK, NOINIT, READWRITE, ALIGN=3
49 | Stack_Mem SPACE Stack_Size
50 | __initial_sp
51 |
52 |
53 | ; Heap Configuration
54 | ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
55 | ;
56 |
57 | Heap_Size EQU 0x800
58 |
59 | AREA HEAP, NOINIT, READWRITE, ALIGN=3
60 | __heap_base
61 | Heap_Mem SPACE Heap_Size
62 | __heap_limit
63 |
64 | PRESERVE8
65 | THUMB
66 |
67 |
68 | ; Vector Table Mapped to Address 0 at Reset
69 | AREA RESET, DATA, READONLY
70 | EXPORT __Vectors
71 | EXPORT __Vectors_End
72 | EXPORT __Vectors_Size
73 |
74 | __Vectors DCD __initial_sp ; Top of Stack
75 | DCD Reset_Handler ; Reset Handler
76 | DCD NMI_Handler ; NMI Handler
77 | DCD HardFault_Handler ; Hard Fault Handler
78 | DCD MemManage_Handler ; MPU Fault Handler
79 | DCD BusFault_Handler ; Bus Fault Handler
80 | DCD UsageFault_Handler ; Usage Fault Handler
81 | DCD 0 ; Reserved
82 | DCD 0 ; Reserved
83 | DCD 0 ; Reserved
84 | DCD 0 ; Reserved
85 | DCD SVC_Handler ; SVCall Handler
86 | DCD DebugMon_Handler ; Debug Monitor Handler
87 | DCD 0 ; Reserved
88 | DCD PendSV_Handler ; PendSV Handler
89 | DCD SysTick_Handler ; SysTick Handler
90 |
91 | ; External Interrupts
92 | DCD WWDG_IRQHandler ; Window WatchDog
93 | DCD PVD_IRQHandler ; PVD through EXTI Line detection
94 | DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
95 | DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
96 | DCD FLASH_IRQHandler ; FLASH
97 | DCD RCC_IRQHandler ; RCC
98 | DCD EXTI0_IRQHandler ; EXTI Line0
99 | DCD EXTI1_IRQHandler ; EXTI Line1
100 | DCD EXTI2_IRQHandler ; EXTI Line2
101 | DCD EXTI3_IRQHandler ; EXTI Line3
102 | DCD EXTI4_IRQHandler ; EXTI Line4
103 | DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
104 | DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
105 | DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
106 | DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
107 | DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
108 | DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
109 | DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
110 | DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
111 | DCD 0 ; Reserved
112 | DCD 0 ; Reserved
113 | DCD 0 ; Reserved
114 | DCD 0 ; Reserved
115 | DCD EXTI9_5_IRQHandler ; External Line[9:5]s
116 | DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
117 | DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
118 | DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
119 | DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
120 | DCD TIM2_IRQHandler ; TIM2
121 | DCD TIM3_IRQHandler ; TIM3
122 | DCD TIM4_IRQHandler ; TIM4
123 | DCD I2C1_EV_IRQHandler ; I2C1 Event
124 | DCD I2C1_ER_IRQHandler ; I2C1 Error
125 | DCD I2C2_EV_IRQHandler ; I2C2 Event
126 | DCD I2C2_ER_IRQHandler ; I2C2 Error
127 | DCD SPI1_IRQHandler ; SPI1
128 | DCD SPI2_IRQHandler ; SPI2
129 | DCD USART1_IRQHandler ; USART1
130 | DCD USART2_IRQHandler ; USART2
131 | DCD 0 ; Reserved
132 | DCD EXTI15_10_IRQHandler ; External Line[15:10]s
133 | DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
134 | DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
135 | DCD 0 ; Reserved
136 | DCD 0 ; Reserved
137 | DCD 0 ; Reserved
138 | DCD 0 ; Reserved
139 | DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
140 | DCD 0 ; Reserved
141 | DCD SDIO_IRQHandler ; SDIO
142 | DCD TIM5_IRQHandler ; TIM5
143 | DCD SPI3_IRQHandler ; SPI3
144 | DCD 0 ; Reserved
145 | DCD 0 ; Reserved
146 | DCD 0 ; Reserved
147 | DCD 0 ; Reserved
148 | DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
149 | DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
150 | DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
151 | DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
152 | DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
153 | DCD 0 ; Reserved
154 | DCD 0 ; Reserved
155 | DCD 0 ; Reserved
156 | DCD 0 ; Reserved
157 | DCD 0 ; Reserved
158 | DCD 0 ; Reserved
159 | DCD OTG_FS_IRQHandler ; USB OTG FS
160 | DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
161 | DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
162 | DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
163 | DCD USART6_IRQHandler ; USART6
164 | DCD I2C3_EV_IRQHandler ; I2C3 event
165 | DCD I2C3_ER_IRQHandler ; I2C3 error
166 | DCD 0 ; Reserved
167 | DCD 0 ; Reserved
168 | DCD 0 ; Reserved
169 | DCD 0 ; Reserved
170 | DCD 0 ; Reserved
171 | DCD 0 ; Reserved
172 | DCD 0 ; Reserved
173 | DCD FPU_IRQHandler ; FPU
174 | DCD 0 ; Reserved
175 | DCD 0 ; Reserved
176 | DCD SPI4_IRQHandler ; SPI4
177 |
178 | __Vectors_End
179 |
180 | __Vectors_Size EQU __Vectors_End - __Vectors
181 |
182 | AREA |.text|, CODE, READONLY
183 |
184 | ; Reset handler
185 | Reset_Handler PROC
186 | EXPORT Reset_Handler [WEAK]
187 | IMPORT SystemInit
188 | IMPORT __main
189 |
190 | LDR R0, =SystemInit
191 | BLX R0
192 | LDR R0, =__main
193 | BX R0
194 | ENDP
195 |
196 | ; Dummy Exception Handlers (infinite loops which can be modified)
197 |
198 | NMI_Handler PROC
199 | EXPORT NMI_Handler [WEAK]
200 | B .
201 | ENDP
202 | HardFault_Handler\
203 | PROC
204 | EXPORT HardFault_Handler [WEAK]
205 | B .
206 | ENDP
207 | MemManage_Handler\
208 | PROC
209 | EXPORT MemManage_Handler [WEAK]
210 | B .
211 | ENDP
212 | BusFault_Handler\
213 | PROC
214 | EXPORT BusFault_Handler [WEAK]
215 | B .
216 | ENDP
217 | UsageFault_Handler\
218 | PROC
219 | EXPORT UsageFault_Handler [WEAK]
220 | B .
221 | ENDP
222 | SVC_Handler PROC
223 | EXPORT SVC_Handler [WEAK]
224 | B .
225 | ENDP
226 | DebugMon_Handler\
227 | PROC
228 | EXPORT DebugMon_Handler [WEAK]
229 | B .
230 | ENDP
231 | PendSV_Handler PROC
232 | EXPORT PendSV_Handler [WEAK]
233 | B .
234 | ENDP
235 | SysTick_Handler PROC
236 | EXPORT SysTick_Handler [WEAK]
237 | B .
238 | ENDP
239 |
240 | Default_Handler PROC
241 |
242 | EXPORT WWDG_IRQHandler [WEAK]
243 | EXPORT PVD_IRQHandler [WEAK]
244 | EXPORT TAMP_STAMP_IRQHandler [WEAK]
245 | EXPORT RTC_WKUP_IRQHandler [WEAK]
246 | EXPORT FLASH_IRQHandler [WEAK]
247 | EXPORT RCC_IRQHandler [WEAK]
248 | EXPORT EXTI0_IRQHandler [WEAK]
249 | EXPORT EXTI1_IRQHandler [WEAK]
250 | EXPORT EXTI2_IRQHandler [WEAK]
251 | EXPORT EXTI3_IRQHandler [WEAK]
252 | EXPORT EXTI4_IRQHandler [WEAK]
253 | EXPORT DMA1_Stream0_IRQHandler [WEAK]
254 | EXPORT DMA1_Stream1_IRQHandler [WEAK]
255 | EXPORT DMA1_Stream2_IRQHandler [WEAK]
256 | EXPORT DMA1_Stream3_IRQHandler [WEAK]
257 | EXPORT DMA1_Stream4_IRQHandler [WEAK]
258 | EXPORT DMA1_Stream5_IRQHandler [WEAK]
259 | EXPORT DMA1_Stream6_IRQHandler [WEAK]
260 | EXPORT ADC_IRQHandler [WEAK]
261 | EXPORT EXTI9_5_IRQHandler [WEAK]
262 | EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
263 | EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
264 | EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
265 | EXPORT TIM1_CC_IRQHandler [WEAK]
266 | EXPORT TIM2_IRQHandler [WEAK]
267 | EXPORT TIM3_IRQHandler [WEAK]
268 | EXPORT TIM4_IRQHandler [WEAK]
269 | EXPORT I2C1_EV_IRQHandler [WEAK]
270 | EXPORT I2C1_ER_IRQHandler [WEAK]
271 | EXPORT I2C2_EV_IRQHandler [WEAK]
272 | EXPORT I2C2_ER_IRQHandler [WEAK]
273 | EXPORT SPI1_IRQHandler [WEAK]
274 | EXPORT SPI2_IRQHandler [WEAK]
275 | EXPORT USART1_IRQHandler [WEAK]
276 | EXPORT USART2_IRQHandler [WEAK]
277 | EXPORT EXTI15_10_IRQHandler [WEAK]
278 | EXPORT RTC_Alarm_IRQHandler [WEAK]
279 | EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
280 | EXPORT DMA1_Stream7_IRQHandler [WEAK]
281 | EXPORT SDIO_IRQHandler [WEAK]
282 | EXPORT TIM5_IRQHandler [WEAK]
283 | EXPORT SPI3_IRQHandler [WEAK]
284 | EXPORT DMA2_Stream0_IRQHandler [WEAK]
285 | EXPORT DMA2_Stream1_IRQHandler [WEAK]
286 | EXPORT DMA2_Stream2_IRQHandler [WEAK]
287 | EXPORT DMA2_Stream3_IRQHandler [WEAK]
288 | EXPORT DMA2_Stream4_IRQHandler [WEAK]
289 | EXPORT OTG_FS_IRQHandler [WEAK]
290 | EXPORT DMA2_Stream5_IRQHandler [WEAK]
291 | EXPORT DMA2_Stream6_IRQHandler [WEAK]
292 | EXPORT DMA2_Stream7_IRQHandler [WEAK]
293 | EXPORT USART6_IRQHandler [WEAK]
294 | EXPORT I2C3_EV_IRQHandler [WEAK]
295 | EXPORT I2C3_ER_IRQHandler [WEAK]
296 | EXPORT FPU_IRQHandler [WEAK]
297 | EXPORT SPI4_IRQHandler [WEAK]
298 |
299 | WWDG_IRQHandler
300 | PVD_IRQHandler
301 | TAMP_STAMP_IRQHandler
302 | RTC_WKUP_IRQHandler
303 | FLASH_IRQHandler
304 | RCC_IRQHandler
305 | EXTI0_IRQHandler
306 | EXTI1_IRQHandler
307 | EXTI2_IRQHandler
308 | EXTI3_IRQHandler
309 | EXTI4_IRQHandler
310 | DMA1_Stream0_IRQHandler
311 | DMA1_Stream1_IRQHandler
312 | DMA1_Stream2_IRQHandler
313 | DMA1_Stream3_IRQHandler
314 | DMA1_Stream4_IRQHandler
315 | DMA1_Stream5_IRQHandler
316 | DMA1_Stream6_IRQHandler
317 | ADC_IRQHandler
318 | EXTI9_5_IRQHandler
319 | TIM1_BRK_TIM9_IRQHandler
320 | TIM1_UP_TIM10_IRQHandler
321 | TIM1_TRG_COM_TIM11_IRQHandler
322 | TIM1_CC_IRQHandler
323 | TIM2_IRQHandler
324 | TIM3_IRQHandler
325 | TIM4_IRQHandler
326 | I2C1_EV_IRQHandler
327 | I2C1_ER_IRQHandler
328 | I2C2_EV_IRQHandler
329 | I2C2_ER_IRQHandler
330 | SPI1_IRQHandler
331 | SPI2_IRQHandler
332 | USART1_IRQHandler
333 | USART2_IRQHandler
334 | EXTI15_10_IRQHandler
335 | RTC_Alarm_IRQHandler
336 | OTG_FS_WKUP_IRQHandler
337 | DMA1_Stream7_IRQHandler
338 | SDIO_IRQHandler
339 | TIM5_IRQHandler
340 | SPI3_IRQHandler
341 | DMA2_Stream0_IRQHandler
342 | DMA2_Stream1_IRQHandler
343 | DMA2_Stream2_IRQHandler
344 | DMA2_Stream3_IRQHandler
345 | DMA2_Stream4_IRQHandler
346 | OTG_FS_IRQHandler
347 | DMA2_Stream5_IRQHandler
348 | DMA2_Stream6_IRQHandler
349 | DMA2_Stream7_IRQHandler
350 | USART6_IRQHandler
351 | I2C3_EV_IRQHandler
352 | I2C3_ER_IRQHandler
353 | FPU_IRQHandler
354 | SPI4_IRQHandler
355 |
356 | B .
357 |
358 | ENDP
359 |
360 | ALIGN
361 |
362 | ;*******************************************************************************
363 | ; User Stack and Heap initialization
364 | ;*******************************************************************************
365 | IF :DEF:__MICROLIB
366 |
367 | EXPORT __initial_sp
368 | EXPORT __heap_base
369 | EXPORT __heap_limit
370 |
371 | ELSE
372 |
373 | IMPORT __use_two_region_memory
374 | EXPORT __user_initial_stackheap
375 |
376 | __user_initial_stackheap
377 |
378 | LDR R0, = Heap_Mem
379 | LDR R1, =(Stack_Mem + Stack_Size)
380 | LDR R2, = (Heap_Mem + Heap_Size)
381 | LDR R3, = Stack_Mem
382 | BX LR
383 |
384 | ALIGN
385 |
386 | ENDIF
387 |
388 | END
389 |
390 | ;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
391 |
--------------------------------------------------------------------------------
/stm32/README.md:
--------------------------------------------------------------------------------
1 | # IntelliSw固件源代码
2 |
3 | ## 新加esp8266_Driver.c,提供ESP8266 AT指令库。简单配置后可做为5并发的HTTP服务器,可以实现简单的路由,提供静态页面访问以及GET请求处理
4 |
5 | ## 新加Wi-Fi配网功能,上电自动检测IO口电平,选择进入正常或配网模式
6 |
7 | ## 修复LCD显示bug,多行显示会漏字符
8 |
9 | ### 配网步骤
10 |
11 | - 将设置的IO口拉低,上电
12 | - 连接AP:intellisw,密码默认为123456789
13 | - 访问192.168.4.1,配置SSID,Password,Server IP,Port
14 | - 将IO口拉高,复位,进入正常模式
15 |
16 | ### 配网页面HTML模板:mcu_conf.html
17 |
18 | > 最后更新于2月13日。这个项目进入生产模式已经15天,出现过几次掉线,但也自动重连成功。迫于升学压力,可能这是我最后一次维护这个项目,得益于多多思考了整个系统的架构,项目还算稳定。不打算再动这个项目太多,简单的小bug会修复。感谢自己的支持。
19 | > zhy
20 |
--------------------------------------------------------------------------------
/stm32/Src/main.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtxzsxxk/intelli-switch/6cf144ad8ddad1dadf7d2fe7dc54e730b10d069b/stm32/Src/main.c
--------------------------------------------------------------------------------
/stm32/Src/stm32f4xx_hal_msp.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * File Name : stm32f4xx_hal_msp.c
5 | * Description : This file provides code for the MSP Initialization
6 | * and de-Initialization codes.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 | #include "main.h"
24 | /* USER CODE BEGIN Includes */
25 |
26 | /* USER CODE END Includes */
27 |
28 | /* Private typedef -----------------------------------------------------------*/
29 | /* USER CODE BEGIN TD */
30 |
31 | /* USER CODE END TD */
32 |
33 | /* Private define ------------------------------------------------------------*/
34 | /* USER CODE BEGIN Define */
35 |
36 | /* USER CODE END Define */
37 |
38 | /* Private macro -------------------------------------------------------------*/
39 | /* USER CODE BEGIN Macro */
40 |
41 | /* USER CODE END Macro */
42 |
43 | /* Private variables ---------------------------------------------------------*/
44 | /* USER CODE BEGIN PV */
45 |
46 | /* USER CODE END PV */
47 |
48 | /* Private function prototypes -----------------------------------------------*/
49 | /* USER CODE BEGIN PFP */
50 |
51 | /* USER CODE END PFP */
52 |
53 | /* External functions --------------------------------------------------------*/
54 | /* USER CODE BEGIN ExternalFunctions */
55 |
56 | /* USER CODE END ExternalFunctions */
57 |
58 | /* USER CODE BEGIN 0 */
59 |
60 | /* USER CODE END 0 */
61 | /**
62 | * Initializes the Global MSP.
63 | */
64 | void HAL_MspInit(void)
65 | {
66 | /* USER CODE BEGIN MspInit 0 */
67 |
68 | /* USER CODE END MspInit 0 */
69 |
70 | __HAL_RCC_SYSCFG_CLK_ENABLE();
71 | __HAL_RCC_PWR_CLK_ENABLE();
72 |
73 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_2);
74 |
75 | /* System interrupt init*/
76 |
77 | /* USER CODE BEGIN MspInit 1 */
78 |
79 | /* USER CODE END MspInit 1 */
80 | }
81 |
82 | /**
83 | * @brief I2C MSP Initialization
84 | * This function configures the hardware resources used in this example
85 | * @param hi2c: I2C handle pointer
86 | * @retval None
87 | */
88 | void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
89 | {
90 | GPIO_InitTypeDef GPIO_InitStruct = {0};
91 | if(hi2c->Instance==I2C1)
92 | {
93 | /* USER CODE BEGIN I2C1_MspInit 0 */
94 |
95 | /* USER CODE END I2C1_MspInit 0 */
96 |
97 | __HAL_RCC_GPIOB_CLK_ENABLE();
98 | /**I2C1 GPIO Configuration
99 | PB6 ------> I2C1_SCL
100 | PB7 ------> I2C1_SDA
101 | */
102 | GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
103 | GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
104 | GPIO_InitStruct.Pull = GPIO_PULLUP;
105 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
106 | GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
107 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
108 |
109 | /* Peripheral clock enable */
110 | __HAL_RCC_I2C1_CLK_ENABLE();
111 | /* USER CODE BEGIN I2C1_MspInit 1 */
112 |
113 | /* USER CODE END I2C1_MspInit 1 */
114 | }
115 |
116 | }
117 |
118 | /**
119 | * @brief I2C MSP De-Initialization
120 | * This function freeze the hardware resources used in this example
121 | * @param hi2c: I2C handle pointer
122 | * @retval None
123 | */
124 | void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
125 | {
126 | if(hi2c->Instance==I2C1)
127 | {
128 | /* USER CODE BEGIN I2C1_MspDeInit 0 */
129 |
130 | /* USER CODE END I2C1_MspDeInit 0 */
131 | /* Peripheral clock disable */
132 | __HAL_RCC_I2C1_CLK_DISABLE();
133 |
134 | /**I2C1 GPIO Configuration
135 | PB6 ------> I2C1_SCL
136 | PB7 ------> I2C1_SDA
137 | */
138 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7);
139 |
140 | /* USER CODE BEGIN I2C1_MspDeInit 1 */
141 |
142 | /* USER CODE END I2C1_MspDeInit 1 */
143 | }
144 |
145 | }
146 |
147 | /**
148 | * @brief RTC MSP Initialization
149 | * This function configures the hardware resources used in this example
150 | * @param hrtc: RTC handle pointer
151 | * @retval None
152 | */
153 | void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
154 | {
155 | if(hrtc->Instance==RTC)
156 | {
157 | /* USER CODE BEGIN RTC_MspInit 0 */
158 |
159 | /* USER CODE END RTC_MspInit 0 */
160 | /* Peripheral clock enable */
161 | __HAL_RCC_RTC_ENABLE();
162 | /* USER CODE BEGIN RTC_MspInit 1 */
163 |
164 | /* USER CODE END RTC_MspInit 1 */
165 | }
166 |
167 | }
168 |
169 | /**
170 | * @brief RTC MSP De-Initialization
171 | * This function freeze the hardware resources used in this example
172 | * @param hrtc: RTC handle pointer
173 | * @retval None
174 | */
175 | void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
176 | {
177 | if(hrtc->Instance==RTC)
178 | {
179 | /* USER CODE BEGIN RTC_MspDeInit 0 */
180 |
181 | /* USER CODE END RTC_MspDeInit 0 */
182 | /* Peripheral clock disable */
183 | __HAL_RCC_RTC_DISABLE();
184 | /* USER CODE BEGIN RTC_MspDeInit 1 */
185 |
186 | /* USER CODE END RTC_MspDeInit 1 */
187 | }
188 |
189 | }
190 |
191 | /**
192 | * @brief SPI MSP Initialization
193 | * This function configures the hardware resources used in this example
194 | * @param hspi: SPI handle pointer
195 | * @retval None
196 | */
197 | void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
198 | {
199 | GPIO_InitTypeDef GPIO_InitStruct = {0};
200 | if(hspi->Instance==SPI1)
201 | {
202 | /* USER CODE BEGIN SPI1_MspInit 0 */
203 |
204 | /* USER CODE END SPI1_MspInit 0 */
205 | /* Peripheral clock enable */
206 | __HAL_RCC_SPI1_CLK_ENABLE();
207 |
208 | __HAL_RCC_GPIOA_CLK_ENABLE();
209 | /**SPI1 GPIO Configuration
210 | PA5 ------> SPI1_SCK
211 | PA6 ------> SPI1_MISO
212 | PA7 ------> SPI1_MOSI
213 | */
214 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
215 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
216 | GPIO_InitStruct.Pull = GPIO_NOPULL;
217 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
218 | GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
219 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
220 |
221 | /* USER CODE BEGIN SPI1_MspInit 1 */
222 |
223 | /* USER CODE END SPI1_MspInit 1 */
224 | }
225 |
226 | }
227 |
228 | /**
229 | * @brief SPI MSP De-Initialization
230 | * This function freeze the hardware resources used in this example
231 | * @param hspi: SPI handle pointer
232 | * @retval None
233 | */
234 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
235 | {
236 | if(hspi->Instance==SPI1)
237 | {
238 | /* USER CODE BEGIN SPI1_MspDeInit 0 */
239 |
240 | /* USER CODE END SPI1_MspDeInit 0 */
241 | /* Peripheral clock disable */
242 | __HAL_RCC_SPI1_CLK_DISABLE();
243 |
244 | /**SPI1 GPIO Configuration
245 | PA5 ------> SPI1_SCK
246 | PA6 ------> SPI1_MISO
247 | PA7 ------> SPI1_MOSI
248 | */
249 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
250 |
251 | /* USER CODE BEGIN SPI1_MspDeInit 1 */
252 |
253 | /* USER CODE END SPI1_MspDeInit 1 */
254 | }
255 |
256 | }
257 |
258 | /**
259 | * @brief TIM_Base MSP Initialization
260 | * This function configures the hardware resources used in this example
261 | * @param htim_base: TIM_Base handle pointer
262 | * @retval None
263 | */
264 | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
265 | {
266 | if(htim_base->Instance==TIM4)
267 | {
268 | /* USER CODE BEGIN TIM4_MspInit 0 */
269 |
270 | /* USER CODE END TIM4_MspInit 0 */
271 | /* Peripheral clock enable */
272 | __HAL_RCC_TIM4_CLK_ENABLE();
273 | /* TIM4 interrupt Init */
274 | HAL_NVIC_SetPriority(TIM4_IRQn, 1, 1);
275 | HAL_NVIC_EnableIRQ(TIM4_IRQn);
276 | /* USER CODE BEGIN TIM4_MspInit 1 */
277 |
278 | /* USER CODE END TIM4_MspInit 1 */
279 | }
280 |
281 | }
282 |
283 | /**
284 | * @brief TIM_Base MSP De-Initialization
285 | * This function freeze the hardware resources used in this example
286 | * @param htim_base: TIM_Base handle pointer
287 | * @retval None
288 | */
289 | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
290 | {
291 | if(htim_base->Instance==TIM4)
292 | {
293 | /* USER CODE BEGIN TIM4_MspDeInit 0 */
294 |
295 | /* USER CODE END TIM4_MspDeInit 0 */
296 | /* Peripheral clock disable */
297 | __HAL_RCC_TIM4_CLK_DISABLE();
298 |
299 | /* TIM4 interrupt DeInit */
300 | HAL_NVIC_DisableIRQ(TIM4_IRQn);
301 | /* USER CODE BEGIN TIM4_MspDeInit 1 */
302 |
303 | /* USER CODE END TIM4_MspDeInit 1 */
304 | }
305 |
306 | }
307 |
308 | /**
309 | * @brief UART MSP Initialization
310 | * This function configures the hardware resources used in this example
311 | * @param huart: UART handle pointer
312 | * @retval None
313 | */
314 | void HAL_UART_MspInit(UART_HandleTypeDef* huart)
315 | {
316 | GPIO_InitTypeDef GPIO_InitStruct = {0};
317 | if(huart->Instance==USART1)
318 | {
319 | /* USER CODE BEGIN USART1_MspInit 0 */
320 |
321 | /* USER CODE END USART1_MspInit 0 */
322 | /* Peripheral clock enable */
323 | __HAL_RCC_USART1_CLK_ENABLE();
324 |
325 | __HAL_RCC_GPIOA_CLK_ENABLE();
326 | /**USART1 GPIO Configuration
327 | PA9 ------> USART1_TX
328 | PA10 ------> USART1_RX
329 | */
330 | GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
331 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
332 | GPIO_InitStruct.Pull = GPIO_PULLUP;
333 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
334 | GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
335 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
336 |
337 | /* USART1 interrupt Init */
338 | HAL_NVIC_SetPriority(USART1_IRQn, 2, 0);
339 | HAL_NVIC_EnableIRQ(USART1_IRQn);
340 | /* USER CODE BEGIN USART1_MspInit 1 */
341 |
342 | /* USER CODE END USART1_MspInit 1 */
343 | }
344 | else if(huart->Instance==USART2)
345 | {
346 | /* USER CODE BEGIN USART2_MspInit 0 */
347 |
348 | /* USER CODE END USART2_MspInit 0 */
349 | /* Peripheral clock enable */
350 | __HAL_RCC_USART2_CLK_ENABLE();
351 |
352 | __HAL_RCC_GPIOA_CLK_ENABLE();
353 | /**USART2 GPIO Configuration
354 | PA2 ------> USART2_TX
355 | PA3 ------> USART2_RX
356 | */
357 | GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
358 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
359 | GPIO_InitStruct.Pull = GPIO_PULLUP;
360 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
361 | GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
362 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
363 |
364 | /* USER CODE BEGIN USART2_MspInit 1 */
365 |
366 | /* USER CODE END USART2_MspInit 1 */
367 | }
368 |
369 | }
370 |
371 | /**
372 | * @brief UART MSP De-Initialization
373 | * This function freeze the hardware resources used in this example
374 | * @param huart: UART handle pointer
375 | * @retval None
376 | */
377 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
378 | {
379 | if(huart->Instance==USART1)
380 | {
381 | /* USER CODE BEGIN USART1_MspDeInit 0 */
382 |
383 | /* USER CODE END USART1_MspDeInit 0 */
384 | /* Peripheral clock disable */
385 | __HAL_RCC_USART1_CLK_DISABLE();
386 |
387 | /**USART1 GPIO Configuration
388 | PA9 ------> USART1_TX
389 | PA10 ------> USART1_RX
390 | */
391 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
392 |
393 | /* USART1 interrupt DeInit */
394 | HAL_NVIC_DisableIRQ(USART1_IRQn);
395 | /* USER CODE BEGIN USART1_MspDeInit 1 */
396 |
397 | /* USER CODE END USART1_MspDeInit 1 */
398 | }
399 | else if(huart->Instance==USART2)
400 | {
401 | /* USER CODE BEGIN USART2_MspDeInit 0 */
402 |
403 | /* USER CODE END USART2_MspDeInit 0 */
404 | /* Peripheral clock disable */
405 | __HAL_RCC_USART2_CLK_DISABLE();
406 |
407 | /**USART2 GPIO Configuration
408 | PA2 ------> USART2_TX
409 | PA3 ------> USART2_RX
410 | */
411 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
412 |
413 | /* USER CODE BEGIN USART2_MspDeInit 1 */
414 |
415 | /* USER CODE END USART2_MspDeInit 1 */
416 | }
417 |
418 | }
419 |
420 | /* USER CODE BEGIN 1 */
421 |
422 | /* USER CODE END 1 */
423 |
424 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
425 |
--------------------------------------------------------------------------------
/stm32/Src/stm32f4xx_hal_timebase_tim.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32f4xx_hal_timebase_TIM.c
5 | * @brief HAL time base based on the hardware TIM.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2021 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "stm32f4xx_hal.h"
23 | #include "stm32f4xx_hal_tim.h"
24 |
25 | /* Private typedef -----------------------------------------------------------*/
26 | /* Private define ------------------------------------------------------------*/
27 | /* Private macro -------------------------------------------------------------*/
28 | /* Private variables ---------------------------------------------------------*/
29 | TIM_HandleTypeDef htim1;
30 | /* Private function prototypes -----------------------------------------------*/
31 | /* Private functions ---------------------------------------------------------*/
32 |
33 | /**
34 | * @brief This function configures the TIM1 as a time base source.
35 | * The time source is configured to have 1ms time base with a dedicated
36 | * Tick interrupt priority.
37 | * @note This function is called automatically at the beginning of program after
38 | * reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig().
39 | * @param TickPriority: Tick interrupt priority.
40 | * @retval HAL status
41 | */
42 | HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
43 | {
44 | RCC_ClkInitTypeDef clkconfig;
45 | uint32_t uwTimclock = 0;
46 | uint32_t uwPrescalerValue = 0;
47 | uint32_t pFLatency;
48 |
49 | /*Configure the TIM1 IRQ priority */
50 | HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, TickPriority ,0);
51 |
52 | /* Enable the TIM1 global Interrupt */
53 | HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn);
54 |
55 | /* Enable TIM1 clock */
56 | __HAL_RCC_TIM1_CLK_ENABLE();
57 |
58 | /* Get clock configuration */
59 | HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);
60 |
61 | /* Compute TIM1 clock */
62 | uwTimclock = HAL_RCC_GetPCLK2Freq();
63 |
64 | /* Compute the prescaler value to have TIM1 counter clock equal to 1MHz */
65 | uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000) - 1);
66 |
67 | /* Initialize TIM1 */
68 | htim1.Instance = TIM1;
69 |
70 | /* Initialize TIMx peripheral as follow:
71 | + Period = [(TIM1CLK/1000) - 1]. to have a (1/1000) s time base.
72 | + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock.
73 | + ClockDivision = 0
74 | + Counter direction = Up
75 | */
76 | htim1.Init.Period = (1000000 / 1000) - 1;
77 | htim1.Init.Prescaler = uwPrescalerValue;
78 | htim1.Init.ClockDivision = 0;
79 | htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
80 | if(HAL_TIM_Base_Init(&htim1) == HAL_OK)
81 | {
82 | /* Start the TIM time Base generation in interrupt mode */
83 | return HAL_TIM_Base_Start_IT(&htim1);
84 | }
85 |
86 | /* Return function status */
87 | return HAL_ERROR;
88 | }
89 |
90 | /**
91 | * @brief Suspend Tick increment.
92 | * @note Disable the tick increment by disabling TIM1 update interrupt.
93 | * @param None
94 | * @retval None
95 | */
96 | void HAL_SuspendTick(void)
97 | {
98 | /* Disable TIM1 update Interrupt */
99 | __HAL_TIM_DISABLE_IT(&htim1, TIM_IT_UPDATE);
100 | }
101 |
102 | /**
103 | * @brief Resume Tick increment.
104 | * @note Enable the tick increment by Enabling TIM1 update interrupt.
105 | * @param None
106 | * @retval None
107 | */
108 | void HAL_ResumeTick(void)
109 | {
110 | /* Enable TIM1 Update interrupt */
111 | __HAL_TIM_ENABLE_IT(&htim1, TIM_IT_UPDATE);
112 | }
113 |
114 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
115 |
--------------------------------------------------------------------------------
/stm32/Src/stm32f4xx_it.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32f4xx_it.c
5 | * @brief Interrupt Service Routines.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2021 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "main.h"
23 | #include "stm32f4xx_it.h"
24 | /* Private includes ----------------------------------------------------------*/
25 | /* USER CODE BEGIN Includes */
26 | /* USER CODE END Includes */
27 |
28 | /* Private typedef -----------------------------------------------------------*/
29 | /* USER CODE BEGIN TD */
30 |
31 | /* USER CODE END TD */
32 |
33 | /* Private define ------------------------------------------------------------*/
34 | /* USER CODE BEGIN PD */
35 |
36 | /* USER CODE END PD */
37 |
38 | /* Private macro -------------------------------------------------------------*/
39 | /* USER CODE BEGIN PM */
40 |
41 | /* USER CODE END PM */
42 |
43 | /* Private variables ---------------------------------------------------------*/
44 | /* USER CODE BEGIN PV */
45 |
46 | /* USER CODE END PV */
47 |
48 | /* Private function prototypes -----------------------------------------------*/
49 | /* USER CODE BEGIN PFP */
50 |
51 | /* USER CODE END PFP */
52 |
53 | /* Private user code ---------------------------------------------------------*/
54 | /* USER CODE BEGIN 0 */
55 |
56 | /* USER CODE END 0 */
57 |
58 | /* External variables --------------------------------------------------------*/
59 | extern TIM_HandleTypeDef htim4;
60 | extern UART_HandleTypeDef huart1;
61 | extern TIM_HandleTypeDef htim1;
62 |
63 | /* USER CODE BEGIN EV */
64 |
65 | /* USER CODE END EV */
66 |
67 | /******************************************************************************/
68 | /* Cortex-M4 Processor Interruption and Exception Handlers */
69 | /******************************************************************************/
70 | /**
71 | * @brief This function handles Non maskable interrupt.
72 | */
73 | void NMI_Handler(void)
74 | {
75 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
76 |
77 | /* USER CODE END NonMaskableInt_IRQn 0 */
78 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
79 |
80 | /* USER CODE END NonMaskableInt_IRQn 1 */
81 | }
82 |
83 | /**
84 | * @brief This function handles Hard fault interrupt.
85 | */
86 | void HardFault_Handler(void)
87 | {
88 | /* USER CODE BEGIN HardFault_IRQn 0 */
89 |
90 | /* USER CODE END HardFault_IRQn 0 */
91 | while (1)
92 | {
93 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */
94 | /* USER CODE END W1_HardFault_IRQn 0 */
95 | }
96 | }
97 |
98 | /**
99 | * @brief This function handles Memory management fault.
100 | */
101 | void MemManage_Handler(void)
102 | {
103 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */
104 |
105 | /* USER CODE END MemoryManagement_IRQn 0 */
106 | while (1)
107 | {
108 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
109 | /* USER CODE END W1_MemoryManagement_IRQn 0 */
110 | }
111 | }
112 |
113 | /**
114 | * @brief This function handles Pre-fetch fault, memory access fault.
115 | */
116 | void BusFault_Handler(void)
117 | {
118 | /* USER CODE BEGIN BusFault_IRQn 0 */
119 |
120 | /* USER CODE END BusFault_IRQn 0 */
121 | while (1)
122 | {
123 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */
124 | /* USER CODE END W1_BusFault_IRQn 0 */
125 | }
126 | }
127 |
128 | /**
129 | * @brief This function handles Undefined instruction or illegal state.
130 | */
131 | void UsageFault_Handler(void)
132 | {
133 | /* USER CODE BEGIN UsageFault_IRQn 0 */
134 |
135 | /* USER CODE END UsageFault_IRQn 0 */
136 | while (1)
137 | {
138 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */
139 | /* USER CODE END W1_UsageFault_IRQn 0 */
140 | }
141 | }
142 |
143 | /**
144 | * @brief This function handles System service call via SWI instruction.
145 | */
146 | void SVC_Handler(void)
147 | {
148 | /* USER CODE BEGIN SVCall_IRQn 0 */
149 |
150 | /* USER CODE END SVCall_IRQn 0 */
151 | /* USER CODE BEGIN SVCall_IRQn 1 */
152 |
153 | /* USER CODE END SVCall_IRQn 1 */
154 | }
155 |
156 | /**
157 | * @brief This function handles Debug monitor.
158 | */
159 | void DebugMon_Handler(void)
160 | {
161 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */
162 |
163 | /* USER CODE END DebugMonitor_IRQn 0 */
164 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */
165 |
166 | /* USER CODE END DebugMonitor_IRQn 1 */
167 | }
168 |
169 | /**
170 | * @brief This function handles Pendable request for system service.
171 | */
172 | void PendSV_Handler(void)
173 | {
174 | /* USER CODE BEGIN PendSV_IRQn 0 */
175 |
176 | /* USER CODE END PendSV_IRQn 0 */
177 | /* USER CODE BEGIN PendSV_IRQn 1 */
178 |
179 | /* USER CODE END PendSV_IRQn 1 */
180 | }
181 |
182 | /**
183 | * @brief This function handles System tick timer.
184 | */
185 | void SysTick_Handler(void)
186 | {
187 | /* USER CODE BEGIN SysTick_IRQn 0 */
188 |
189 | /* USER CODE END SysTick_IRQn 0 */
190 |
191 | /* USER CODE BEGIN SysTick_IRQn 1 */
192 |
193 | /* USER CODE END SysTick_IRQn 1 */
194 | }
195 |
196 | /******************************************************************************/
197 | /* STM32F4xx Peripheral Interrupt Handlers */
198 | /* Add here the Interrupt Handlers for the used peripherals. */
199 | /* For the available peripheral interrupt handler names, */
200 | /* please refer to the startup file (startup_stm32f4xx.s). */
201 | /******************************************************************************/
202 |
203 | /**
204 | * @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
205 | */
206 | void TIM1_UP_TIM10_IRQHandler(void)
207 | {
208 | /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 0 */
209 |
210 | /* USER CODE END TIM1_UP_TIM10_IRQn 0 */
211 | HAL_TIM_IRQHandler(&htim1);
212 | /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 1 */
213 |
214 | /* USER CODE END TIM1_UP_TIM10_IRQn 1 */
215 | }
216 |
217 | /**
218 | * @brief This function handles TIM4 global interrupt.
219 | */
220 | void TIM4_IRQHandler(void)
221 | {
222 | /* USER CODE BEGIN TIM4_IRQn 0 */
223 |
224 | /* USER CODE END TIM4_IRQn 0 */
225 | HAL_TIM_IRQHandler(&htim4);
226 | /* USER CODE BEGIN TIM4_IRQn 1 */
227 |
228 | /* USER CODE END TIM4_IRQn 1 */
229 | }
230 |
231 | /**
232 | * @brief This function handles USART1 global interrupt.
233 | */
234 | void USART1_IRQHandler(void)
235 | {
236 | /* USER CODE BEGIN USART1_IRQn 0 */
237 |
238 | /* USER CODE END USART1_IRQn 0 */
239 | HAL_UART_IRQHandler(&huart1);
240 | /* USER CODE BEGIN USART1_IRQn 1 */
241 |
242 | /* USER CODE END USART1_IRQn 1 */
243 | }
244 |
245 | /* USER CODE BEGIN 1 */
246 |
247 | /* USER CODE END 1 */
248 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
249 |
--------------------------------------------------------------------------------
/web/IntelliSw-App/char_convert.py:
--------------------------------------------------------------------------------
1 | import json
2 | import os
3 | fontAscii = [
4 | [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ], # sp
5 | [ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 ], # !
6 | [ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 ], # "
7 | [ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 ], # #
8 | [ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 ], # $
9 | [ 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 ], # %
10 | [ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 ], # &
11 | [ 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 ], # '
12 | [ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 ], # (
13 | [ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 ], # )
14 | [ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 ], # *
15 | [ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 ], # +
16 | [ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 ], # ,
17 | [ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 ], # -
18 | [ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 ], # .
19 | [ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 ], # /
20 | [ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E ], # 0
21 | [ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 ], # 1
22 | [ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 ], # 2
23 | [ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 ], # 3
24 | [ 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 ], # 4
25 | [ 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 ], # 5
26 | [ 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 ], # 6
27 | [ 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 ], # 7
28 | [ 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 ], # 8
29 | [ 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E ], # 9
30 | [ 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 ], # :
31 | [ 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 ], # ;
32 | [ 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 ], # <
33 | [ 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 ], # =
34 | [ 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 ], # >
35 | [ 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 ], # ?
36 | [ 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E ], # @
37 | [ 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C ], # A
38 | [ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 ], # B
39 | [ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 ], # C
40 | [ 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C ], # D
41 | [ 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 ], # E
42 | [ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 ], # F
43 | [ 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A ], # G
44 | [ 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F ], # H
45 | [ 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 ], # I
46 | [ 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 ], # J
47 | [ 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 ], # K
48 | [ 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 ], # L
49 | [ 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F ], # M
50 | [ 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F ], # N
51 | [ 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E ], # O
52 | [ 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 ], # P
53 | [ 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E ], # Q
54 | [ 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 ], # R
55 | [ 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 ], # S
56 | [ 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 ], # T
57 | [ 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F ], # U
58 | [ 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F ], # V
59 | [ 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F ], # W
60 | [ 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 ], # X
61 | [ 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 ], # Y
62 | [ 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 ], # Z
63 | [ 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 ], # [
64 | [ 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 ], # 55
65 | [ 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 ], # ]
66 | [ 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 ], # ^
67 | [ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 ], # _
68 | [ 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 ], # '
69 | [ 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 ], # a
70 | [ 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 ], # b
71 | [ 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 ], # c
72 | [ 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F ], # d
73 | [ 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 ], # e
74 | [ 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 ], # f
75 | [ 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C ], # g
76 | [ 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 ], # h
77 | [ 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 ], # i
78 | [ 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 ], # j
79 | [ 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 ], # k
80 | [ 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 ], # l
81 | [ 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 ], # m
82 | [ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 ], # n
83 | [ 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 ], # o
84 | [ 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 ], # p
85 | [ 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC ], # q
86 | [ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 ], # r
87 | [ 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 ], # s
88 | [ 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 ], # t
89 | [ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C ], # u
90 | [ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C ], # v
91 | [ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C ], # w
92 | [ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 ], # x
93 | [ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C ], # y
94 | [ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 ], # z
95 | ]
96 |
97 | fontAsciiDict={}
98 |
99 | for i in range(0,fontAscii.__len__()):
100 | fontAsciiDict[chr(i+32)]=fontAscii[i]
101 |
102 | file=open("char_pixel.json","w")
103 | file.write(json.dumps(fontAsciiDict))
104 | file.close()
105 |
106 | print("Finished")
107 | os.system("notepad.exe "+os.path.join(os.getcwd(),"char_pixel.json"))
--------------------------------------------------------------------------------
/web/IntelliSw-App/char_pixel.json:
--------------------------------------------------------------------------------
1 | {" ": [0, 0, 0, 0, 0, 0], "!": [0, 0, 0, 47, 0, 0], "\"": [0, 0, 7, 0, 7, 0], "#": [0, 20, 127, 20, 127, 20], "$": [0, 36, 42, 127, 42, 18], "%": [0, 98, 100, 8, 19, 35], "&": [0, 54, 73, 85, 34, 80], "'": [0, 0, 5, 3, 0, 0], "(": [0, 0, 28, 34, 65, 0], ")": [0, 0, 65, 34, 28, 0], "*": [0, 20, 8, 62, 8, 20], "+": [0, 8, 8, 62, 8, 8], ",": [0, 0, 0, 160, 96, 0], "-": [0, 8, 8, 8, 8, 8], ".": [0, 0, 96, 96, 0, 0], "/": [0, 32, 16, 8, 4, 2], "0": [0, 62, 81, 73, 69, 62], "1": [0, 0, 66, 127, 64, 0], "2": [0, 66, 97, 81, 73, 70], "3": [0, 33, 65, 69, 75, 49], "4": [0, 24, 20, 18, 127, 16], "5": [0, 39, 69, 69, 69, 57], "6": [0, 60, 74, 73, 73, 48], "7": [0, 1, 113, 9, 5, 3], "8": [0, 54, 73, 73, 73, 54], "9": [0, 6, 73, 73, 41, 30], ":": [0, 0, 54, 54, 0, 0], ";": [0, 0, 86, 54, 0, 0], "<": [0, 8, 20, 34, 65, 0], "=": [0, 20, 20, 20, 20, 20], ">": [0, 0, 65, 34, 20, 8], "?": [0, 2, 1, 81, 9, 6], "@": [0, 50, 73, 89, 81, 62], "A": [0, 124, 18, 17, 18, 124], "B": [0, 127, 73, 73, 73, 54], "C": [0, 62, 65, 65, 65, 34], "D": [0, 127, 65, 65, 34, 28], "E": [0, 127, 73, 73, 73, 65], "F": [0, 127, 9, 9, 9, 1], "G": [0, 62, 65, 73, 73, 122], "H": [0, 127, 8, 8, 8, 127], "I": [0, 0, 65, 127, 65, 0], "J": [0, 32, 64, 65, 63, 1], "K": [0, 127, 8, 20, 34, 65], "L": [0, 127, 64, 64, 64, 64], "M": [0, 127, 2, 12, 2, 127], "N": [0, 127, 4, 8, 16, 127], "O": [0, 62, 65, 65, 65, 62], "P": [0, 127, 9, 9, 9, 6], "Q": [0, 62, 65, 81, 33, 94], "R": [0, 127, 9, 25, 41, 70], "S": [0, 70, 73, 73, 73, 49], "T": [0, 1, 1, 127, 1, 1], "U": [0, 63, 64, 64, 64, 63], "V": [0, 31, 32, 64, 32, 31], "W": [0, 63, 64, 56, 64, 63], "X": [0, 99, 20, 8, 20, 99], "Y": [0, 7, 8, 112, 8, 7], "Z": [0, 97, 81, 73, 69, 67], "[": [0, 0, 127, 65, 65, 0], "\\": [0, 85, 42, 85, 42, 85], "]": [0, 0, 65, 65, 127, 0], "^": [0, 4, 2, 1, 2, 4], "_": [0, 64, 64, 64, 64, 64], "`": [0, 0, 1, 2, 4, 0], "a": [0, 32, 84, 84, 84, 120], "b": [0, 127, 72, 68, 68, 56], "c": [0, 56, 68, 68, 68, 32], "d": [0, 56, 68, 68, 72, 127], "e": [0, 56, 84, 84, 84, 24], "f": [0, 8, 126, 9, 1, 2], "g": [0, 24, 164, 164, 164, 124], "h": [0, 127, 8, 4, 4, 120], "i": [0, 0, 68, 125, 64, 0], "j": [0, 64, 128, 132, 125, 0], "k": [0, 127, 16, 40, 68, 0], "l": [0, 0, 65, 127, 64, 0], "m": [0, 124, 4, 24, 4, 120], "n": [0, 124, 8, 4, 4, 120], "o": [0, 56, 68, 68, 68, 56], "p": [0, 252, 36, 36, 36, 24], "q": [0, 24, 36, 36, 24, 252], "r": [0, 124, 8, 4, 4, 8], "s": [0, 72, 84, 84, 84, 32], "t": [0, 4, 63, 68, 64, 32], "u": [0, 60, 64, 64, 32, 124], "v": [0, 28, 32, 64, 32, 28], "w": [0, 60, 64, 48, 64, 60], "x": [0, 68, 40, 16, 40, 68], "y": [0, 28, 160, 160, 160, 124], "z": [0, 68, 100, 84, 76, 68]}
--------------------------------------------------------------------------------
/web/IntelliSw-App/virtualScreen/app_conf.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Virtual Screen
7 |
8 |
50 |
51 |
52 |
53 |
54 |
72 |
73 |
74 |
75 |
76 |
77 |
GUI模拟
78 |
可供编辑的X大小为{{guiData.guisize_x}}个字符,Y大小为{{guiData.guisize_y}}个字符。
79 |
80 | 每个字符宽{{guiData.word_x}} px,高{{guiData.word_y}} px。
81 |
82 |
83 |
84 |
►
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
参数配置
98 |
99 |
100 |
101 | GUI制作
102 |
103 |
104 |
105 |
106 | #
107 |
109 |
110 |
118 |
126 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
330 |
331 |
332 |
333 |
--------------------------------------------------------------------------------
/web/IntelliSw-App/weather.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import json
3 | import time
4 | #guiStr:str=" APP MODE Weather ReportLoc:[10]TD:[11]TM:[11][14]"
5 | guiStr:str=" APP MODE Weather ReportLoc:%sTD:%sTM:%s%s"
6 |
7 | WAIT_TIME=30
8 |
9 | url='http://www.weather.com.cn/data/sk/101310201.html'
10 | Location='Jiyang Dt.'
11 | City=''
12 | TempNow=''
13 | TempLow=''
14 | TempHigh=''
15 |
16 | def FillStr(_str:str,len):
17 | output=_str
18 | for i in range(len-_str.__len__()):
19 | output=output+" "
20 | return output
21 |
22 | def GetWeather():
23 | global TempNow,TempLow,TempHigh
24 | response=requests.get("https://tianqiapi.com/api?version=v1&appid=74697218&appsecret=1f0cjpzU&city=%E4%B8%89%E4%BA%9A")
25 | jsonStr:str=response.text
26 | jsonObj=json.loads(jsonStr)
27 | weatherDict=jsonObj['data'][1]
28 | TempNow=jsonObj['data'][0]['tem'].replace("℃","'C")
29 | TempToday=weatherDict['tem'].replace("℃","'C")
30 | TempLow=weatherDict['tem2'].replace("℃","'C")
31 | TempHigh=weatherDict['tem1'].replace("℃","'C")
32 | msgstr=guiStr%(FillStr(Location,10),FillStr(TempNow,11),FillStr(TempToday,11),FillStr(("%s->%s"%(TempLow,TempHigh)),14))
33 | return msgstr
34 |
35 | while(True):
36 | MSGDATA=GetWeather()
37 | print(MSGDATA)
38 | if MSGDATA.__len__()!=84:
39 | raise Exception("字符串长度不一致")
40 | param={"apikey":"pmcsixbdkrefuwtl","scrdata":MSGDATA,"appid":"3","c":"appscrupd"}
41 | response=requests.get('http://127.0.0.1:8000/command/',params=param)
42 | print(response.text)
43 | time.sleep(WAIT_TIME)
44 | exitparam={"apikey":"pmcsixbdkrefuwtl","appid":"3","c":"appexit"}
45 | response=requests.get('http://127.0.0.1:8000/command/',params=exitparam)
46 | print(response.text)
47 | time.sleep(WAIT_TIME)
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/web/IntelliSw/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtxzsxxk/intelli-switch/6cf144ad8ddad1dadf7d2fe7dc54e730b10d069b/web/IntelliSw/__init__.py
--------------------------------------------------------------------------------
/web/IntelliSw/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for IntelliSw project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'IntelliSw.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/web/IntelliSw/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for IntelliSw project.
3 |
4 | Generated by 'django-admin startproject' using Django 3.1.3.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/3.1/ref/settings/
11 | """
12 |
13 | from pathlib import Path
14 | import os
15 |
16 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
17 | BASE_DIR = Path(__file__).resolve().parent.parent
18 |
19 |
20 | # Quick-start development settings - unsuitable for production
21 | # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
22 |
23 | # SECURITY WARNING: keep the secret key used in production secret!
24 | SECRET_KEY = 'o=r&=0q!$)$1!pb0oh7b^3$w6yv&6$+&7c*w7z0kiil5^n4sa0'
25 |
26 | # SECURITY WARNING: don't run with debug turned on in production!
27 | DEBUG = True
28 |
29 | ALLOWED_HOSTS = ['*']
30 |
31 |
32 | # Application definition
33 |
34 | INSTALLED_APPS = [
35 | 'django.contrib.admin',
36 | 'django.contrib.auth',
37 | 'django.contrib.contenttypes',
38 | 'django.contrib.sessions',
39 | 'django.contrib.messages',
40 | 'django.contrib.staticfiles',
41 | 'WebView'
42 | ]
43 |
44 | MIDDLEWARE = [
45 | 'django.middleware.security.SecurityMiddleware',
46 | 'django.contrib.sessions.middleware.SessionMiddleware',
47 | 'django.middleware.common.CommonMiddleware',
48 | 'django.middleware.csrf.CsrfViewMiddleware',
49 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
50 | 'django.contrib.messages.middleware.MessageMiddleware',
51 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
52 | ]
53 |
54 | ROOT_URLCONF = 'IntelliSw.urls'
55 |
56 | TEMPLATES = [
57 | {
58 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
59 | 'DIRS': ["template"],
60 | 'APP_DIRS': True,
61 | 'OPTIONS': {
62 | 'context_processors': [
63 | 'django.template.context_processors.debug',
64 | 'django.template.context_processors.request',
65 | 'django.contrib.auth.context_processors.auth',
66 | 'django.contrib.messages.context_processors.messages',
67 | ],
68 | },
69 | },
70 | ]
71 |
72 | WSGI_APPLICATION = 'IntelliSw.wsgi.application'
73 |
74 |
75 | # Database
76 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
77 |
78 | DATABASES = {
79 | 'default': {
80 | 'ENGINE': 'django.db.backends.sqlite3',
81 | 'NAME': BASE_DIR / 'db.sqlite3',
82 | }
83 | }
84 |
85 |
86 | # Password validation
87 | # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
88 |
89 | AUTH_PASSWORD_VALIDATORS = [
90 | {
91 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
92 | },
93 | {
94 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
95 | },
96 | {
97 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
98 | },
99 | {
100 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
101 | },
102 | ]
103 |
104 |
105 | # Internationalization
106 | # https://docs.djangoproject.com/en/3.1/topics/i18n/
107 |
108 | LANGUAGE_CODE = 'zh-hans'
109 |
110 | TIME_ZONE = 'Asia/Shanghai'
111 |
112 | USE_I18N = True
113 |
114 | USE_L10N = True
115 |
116 | USE_TZ = False
117 |
118 |
119 | # Static files (CSS, JavaScript, Images)
120 | # https://docs.djangoproject.com/en/3.1/howto/static-files/
121 |
122 | STATIC_URL = '/static/'
123 | STATICFILES_DIRS = [
124 | os.path.join(BASE_DIR, "static"),
125 | ]
126 |
--------------------------------------------------------------------------------
/web/IntelliSw/urls.py:
--------------------------------------------------------------------------------
1 | """IntelliSw URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/3.1/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import path
18 | from WebView import views
19 |
20 | urlpatterns = [
21 | path('admin/', admin.site.urls),
22 | path('',views.IndexPage),
23 | path('app_conf/',views.appConfPage),
24 | path('view/',views.IndexView),
25 | path('command/',views.commandExec),
26 | path('temp/',views.GetTemp),
27 | path('press/',views.GetPress),
28 | path('illu/',views.GetIllu),
29 | path('iotgo/',views.iotGoOnline),
30 | path('iotsync/',views.iotSync)
31 | ]
32 |
--------------------------------------------------------------------------------
/web/IntelliSw/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for IntelliSw project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'IntelliSw.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/web/NetAssist.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtxzsxxk/intelli-switch/6cf144ad8ddad1dadf7d2fe7dc54e730b10d069b/web/NetAssist.exe
--------------------------------------------------------------------------------
/web/WebView/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtxzsxxk/intelli-switch/6cf144ad8ddad1dadf7d2fe7dc54e730b10d069b/web/WebView/__init__.py
--------------------------------------------------------------------------------
/web/WebView/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from .models import ServerInfo,SampleData,DeviceControl,UserApp
3 | # Register your models here.
4 |
5 | admin.site.register(ServerInfo)
6 | admin.site.register(SampleData)
7 | admin.site.register(DeviceControl)
8 | admin.site.register(UserApp)
--------------------------------------------------------------------------------
/web/WebView/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class WebviewConfig(AppConfig):
5 | name = 'WebView'
6 |
--------------------------------------------------------------------------------
/web/WebView/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 | from django.utils import timezone
3 | import datetime
4 | import random
5 |
6 | # Create your models here.
7 |
8 | class ServerInfo(models.Model):
9 | servername=models.CharField('服务器名称',max_length=128)
10 | remoteIp=models.CharField('远程IP',max_length=128)
11 | localIp=models.CharField('内网IP',max_length=128)
12 | startup=models.DateTimeField('上线时间',default=datetime.datetime.now())
13 | totalDataPack=models.IntegerField('总数据包',default=0)
14 | #目前仅支持字符模式
15 | guisize_x=models.IntegerField('MCU板上显示屏可供显示的X字符范围',default=14)
16 | guisize_y=models.IntegerField('MCU板上显示屏可供显示的Y字符范围',default=6)
17 | word_x=models.IntegerField('一个字符的X大小',default=6)
18 | word_y=models.IntegerField('一个字符的Y大小',default=8)
19 | chars_pixel=models.TextField('JSON格式:字符的字模',default="{}")
20 |
21 | def __str__(self):
22 | return self.servername
23 |
24 | class SampleData(models.Model):
25 | report_time=models.DateTimeField('报告时间',default=datetime.datetime.now()) #22 bytes
26 | temperature=models.FloatField('温度',default=0.0) #4 bytes
27 | humidity=models.FloatField('相对湿度',default=0.0)
28 | atmospressure=models.FloatField('室内气压',default=0.0)
29 | illuminance=models.FloatField('光照强度',default=0.0)
30 | switchStatus=models.TextField('开关状态',max_length=512) #512 bytes but never used
31 |
32 | def __str__(self):
33 | return self.report_time.strftime('%Y-%m-%d %H:%M')
34 |
35 | class DeviceControl(models.Model):
36 |
37 | STATUS_CHOICES=(
38 | ('SWITCH','SWITCH'),
39 | ('PROGRESS','PROGRESS')
40 | )
41 | name=models.CharField('设备名称',max_length=32)
42 | deviceId=models.IntegerField('设备号')
43 | rwType=models.CharField('设备读写类型',max_length=64,choices=STATUS_CHOICES)
44 | deviceStatus=models.CharField('设备状态',max_length=64)
45 | deviceInformation=models.TextField('设备信息',max_length=256)
46 |
47 | def __str__(self):
48 | return self.name
49 |
50 | class UserApp(models.Model):
51 |
52 | def GenerateKey():
53 | return ''.join(random.sample('zyxwvutsrqponmlkjihgfedcba',16))
54 |
55 | name=models.CharField('APP名称',max_length=32)
56 | appid=models.IntegerField('APP ID',auto_created=True)
57 | description=models.CharField('解释',max_length=128)
58 | active=models.BooleanField('激活',default=False)
59 | app_key=models.CharField('APP访问KEY',max_length=16,default=GenerateKey())
60 | downstream_port=models.IntegerField('下行数据传输端口',default=random.randint(10011,10190))
61 |
62 | def __str__(self):
63 | return self.name
64 |
65 |
66 |
--------------------------------------------------------------------------------
/web/WebView/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/web/WebView/views.py:
--------------------------------------------------------------------------------
1 | from django.db.models.lookups import IsNull
2 | from django.db.models.query import QuerySet
3 | from django.shortcuts import render,HttpResponse
4 | from WebView.models import ServerInfo,SampleData,DeviceControl, UserApp
5 | from django.utils import timezone
6 | import django.http.request
7 | import datetime
8 | import time
9 | from hashlib import md5
10 | import socket
11 | import json
12 |
13 | # Create your views here.
14 |
15 | availablePin=['用你自己的'] #用户身份验证时输入的密码
16 | uploadKey='用你自己的' #IOT-UPLOADER上报数据给数据库或其他APP上报数据给MCU时需要输入的key
17 |
18 | def get_client_ip(request):
19 | x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
20 | if x_forwarded_for:
21 | ip = x_forwarded_for.split(',')[-1].strip()
22 | else:
23 | ip = request.META.get('REMOTE_ADDR')
24 | return ip
25 |
26 | def IphIDE(ip):
27 | source=ip.split('.')
28 | print(source)
29 | return "%s.***.%s.***"%(source[0],source[2])
30 |
31 | def IpOnlyOne(ip):
32 | source=ip.split('.')
33 | print(source)
34 | return source[0]
35 |
36 | def getDeviceMD5(request,pin):
37 | ua=str(request.META["HTTP_USER_AGENT"]+IpOnlyOne(get_client_ip(request)))
38 | md5code=md5(ua.encode('UTF-8')).hexdigest()+md5((ua+pin).encode('UTF-8')).hexdigest()
39 | return md5code
40 |
41 | def HasAuth(request):
42 | for i in availablePin:
43 | if 'device_auth' not in request.COOKIES:
44 | return False
45 | userfp=request.COOKIES['device_auth']
46 | validfp=getDeviceMD5(request,i)
47 | print("用户指纹:",userfp)
48 | print("验证指纹:",validfp)
49 | if userfp==validfp:
50 | deviceauth="当前设备已获权"
51 | return True
52 | return False
53 |
54 | def getDeviceStatus(deviceStatus,value):
55 | if deviceStatus=='SWITCH':
56 | if value=='1':
57 | return 'On'
58 | elif value=='0':
59 | return 'Off'
60 | else:
61 | raise Exception("未知的SWITCH状态",value)
62 | else:
63 | raise Exception("未知的状态",value)
64 |
65 | def IndexView(request):
66 | context={}
67 | serverinfoObj=ServerInfo.objects.all()[0]
68 | dnow=datetime.datetime.now()
69 | sonline=serverinfoObj.startup
70 | #deltaTime=int(str(dnow-sonline).split('.')[0].split(':')[0])*24*60\
71 | # +int(str(dnow-sonline).split('.')[0].split(':')[1])*60\
72 | # +int(str(dnow-sonline).split('.')[0].split(':')[2])/60
73 | deltaTime="%.1f"%((dnow-sonline).total_seconds()/60)
74 |
75 |
76 | alldata=SampleData.objects.all()
77 | lastestData:SampleData=None
78 | if alldata.__len__()==0:
79 | lastestData=SampleData()
80 | else:
81 | lastestData=alldata[alldata.__len__()-1]
82 |
83 | updateDeltaTime=str(int((dnow-lastestData.report_time).total_seconds()))
84 |
85 | deviceauth="当前设备权限已冻结"
86 | context['authstatus']=deviceauth
87 | if HasAuth(request):
88 | deviceauth="当前设备已获权,用户指纹:"+request.COOKIES['device_auth'][0:8]
89 | context['authstatus']="已获得设备访问权限"
90 | #lastestData.report_time.strftime("%Y-%m-%d %H:%M:%S")
91 | context['serverinfo']=("%s;服务器(%s);公网IP:%s;内网IP:%s;正常运行时间:%s 分钟;总数据包:%d 占用空间:%.2fKb;数据更新时间:%s秒前"%\
92 | (deviceauth,serverinfoObj.servername,IphIDE(get_client_ip(request)),serverinfoObj.localIp,deltaTime,alldata.__len__(),\
93 | alldata.__len__()*0.068,updateDeltaTime)).replace(";","
")
94 |
95 | context['temperature']="%.1f"%lastestData.temperature
96 | context['humidity']=int(lastestData.humidity)
97 | context['atmospressure']=int(lastestData.atmospressure)
98 | context['illuminance']="%.1f"%lastestData.illuminance
99 | context['serverStatus']='● RUNNING'
100 | disabled=''
101 | if (dnow-lastestData.report_time).total_seconds()>120:
102 | context['serverStatus']='○ ABORTED'
103 | disabled='disabled'
104 |
105 |
106 | dev_template=" +++name+++
"
107 | #Devices
108 | totalTemplate=""
109 | for i in DeviceControl.objects.all():
110 | template=dev_template.replace("+++Description+++",i.deviceInformation)\
111 | .replace("+++name+++",i.name).replace("+++deviceid+++",str(i.deviceId))\
112 | .replace("+++status+++",getDeviceStatus(i.rwType,i.deviceStatus))
113 | if getDeviceStatus(i.rwType,i.deviceStatus)=='Off':
114 | template=template.replace("btn-danger","btn-primary")
115 | totalTemplate=totalTemplate+template
116 |
117 | context['devicecontrols']=totalTemplate
118 | jsonObj=json.dumps(context)
119 | return HttpResponse(jsonObj)
120 |
121 |
122 | def IndexPage(request):
123 | context={}
124 | return render(request,"index.html",context)
125 |
126 | """
127 | 在线用户终端
128 | 除了登录指令以外,其他指令都需要验证cookie
129 | 指令格式:
130 | login [pincode]
131 | logout
132 |
133 | """
134 |
135 | def IotSend(tosend):
136 | time.sleep(0.8)
137 | try:
138 | mysock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
139 | mysock.connect(('127.0.0.1',10010))
140 | #tosend='$ch%d:%s#'%(deviceid,device.deviceStatus)
141 | mysock.send(tosend.encode('utf-8'))
142 | mysock.close()
143 | except Exception as e:
144 | print("无法上传至本地数据上报接口。",e)
145 |
146 | def getAppKey(request:django.http.request):
147 | appid=request.GET.get('appid')
148 | target:UserApp=UserApp.objects.get(appid=int(appid))
149 | if target!=None:
150 | return target.app_key
151 | return "NO SUCH A APP"
152 |
153 | def commandExec(request):
154 | ucmd=request.GET.get('c')
155 | print("WEB终端执行命令:"+ucmd)
156 | print("UA信息:",request.META['HTTP_USER_AGENT'])
157 | paras=ucmd.split(' ')
158 | response=HttpResponse("$webClient/ServerTerminal: "+ucmd)
159 | if paras[0]=='login' and paras.__len__()==2:
160 | if not HasAuth(request) and paras[1] in availablePin:
161 | fingerprint=getDeviceMD5(request,paras[1])
162 | print("用户获权,指纹:",fingerprint)
163 | response.set_cookie('device_auth',fingerprint,max_age=15*86400)
164 | response.write("\r\n获权成功。")
165 | else:
166 | response.write("\r\n获权失败。您可能已经获合法或非法权,或者输入的Pin码不在Pin集内。")
167 | elif paras[0]=='logout' and paras.__len__()==1:
168 | if not HasAuth(request):
169 | response.write("\r\n您的权限已被冻结。")
170 | else:
171 | response.delete_cookie('device_auth')
172 | response.write("\r\n您的权限已冻结。")
173 | elif paras[0]=='devedit' and paras.__len__()==3:
174 | if not HasAuth(request):
175 | response.write("\r\nerrs:您没有权限访问这个设备。")
176 | else:
177 | deviceid=int(paras[1])
178 | device=DeviceControl.objects.get(deviceId=deviceid)
179 | if device.rwType!='SWITCH':
180 | response.write("\r\nerrs:Cannot switch a none-switched device.")
181 | else:
182 | if device.deviceStatus=='1':
183 | device.deviceStatus='0'
184 | elif device.deviceStatus=='0':
185 | device.deviceStatus='1'
186 | else:
187 | raise Exception("未知的SWITCH设备状态",device.deviceStatus)
188 | device.save()
189 | tosend='^ch%d:%s#'%(deviceid,device.deviceStatus)
190 | IotSend(tosend)
191 | response.write("\r\n"+getDeviceStatus(device.rwType,device.deviceStatus))
192 |
193 | elif paras[0]=='iotrpt':
194 | #物联网终端上报数据
195 | #iot:物联网 rpt:report 大气压力 光照强度 (可选)设备信息,由设备返回的json序列,‘’为设备号
196 | #格式:iotrpt temperature humidity pressure illuminance {'1':1,'2':1,'3':1,'4':1}
197 | """
198 | HTTP请求格式:
199 | GET /command/?c=iotrpt+13.0+79+1013+212 HTTP/1.1
200 | User-Agent: app/iotserver
201 | """
202 | if paras.__len__()==5 and request.GET.get('pwd')==uploadKey:
203 | smp=SampleData(temperature=float(paras[1]),humidity=float(paras[2]),\
204 | atmospressure=float(paras[3]),illuminance=float(paras[4]),\
205 | report_time=datetime.datetime.now())
206 | smp.save()
207 | response.write('\r\nsaved.'+datetime.datetime.now().strftime("DT%a %H:%M:%S"))
208 | elif paras.__len__()==6:
209 | pass
210 | else:
211 | response.write('errs:can\'t resolve command or error upload key.')
212 | elif paras[0]=='iot-reset':
213 | if not HasAuth(request):
214 | response.write("\r\nerrs:您没有权限执行此命令。")
215 | else:
216 | IotSend("^FRS#")
217 | response.write("\r\n已发送复位指令。")
218 | pass
219 | elif paras[0]=='scr-reset':
220 | if not HasAuth(request):
221 | response.write("\r\nerrs:您没有权限执行此命令。")
222 | else:
223 | IotSend("^SRS#")
224 | response.write("\r\n已发送屏幕复位指令。")
225 | pass
226 | elif paras[0]=='esp-reset':
227 | if not HasAuth(request):
228 | response.write("\r\nerrs:您没有权限执行此命令。")
229 | else:
230 | IotSend("^ERS#")
231 | response.write("\r\n已发送esp8266复位指令。")
232 | pass
233 | elif paras[0]=='sync':
234 | if not HasAuth(request):
235 | response.write("\r\nerrs:您没有权限同步设备。")
236 | else:
237 | iotSync(request)
238 | response.write("\r\n设备已同步。")
239 |
240 | elif paras[0]=='appscrupd':
241 | """
242 | APP HTTP请求参数:apikey=API key,scrdata=屏幕数据,appid=APPID,c=appscrupd
243 | """
244 | if not request.GET.get('apikey')==getAppKey(request):
245 | response.write("\r\nerrs:APP没有权限访问设备。")
246 | else:
247 | scrdata=request.GET.get('scrdata')
248 | IotSend('^AP%s#'%scrdata)
249 | response.write("\r\n已将屏幕刷新数据写入。")
250 | elif paras[0]=='appexit':
251 | if not request.GET.get('apikey')==getAppKey(request):
252 | response.write("\r\nerrs:APP没有权限访问设备。")
253 | else:
254 | IotSend('^EA#')
255 | response.write("\r\n已丢失屏幕控制权。")
256 | else:
257 | response.write("\r\n无法识别输入的指令。")
258 | return response
259 |
260 | def GetTemp(request):
261 | now=datetime.datetime.now()
262 | dateData=request.GET.get('from').split('-')
263 |
264 | start_time=datetime.datetime(year=int(dateData[0]),month=int(dateData[1]),day=int(dateData[2]),\
265 | hour=0,minute=0,second=0)
266 |
267 | end_time=datetime.datetime(year=int(dateData[0]),month=int(dateData[1]),day=int(dateData[2]),\
268 | hour=23,minute=59,second=59)
269 |
270 | today_data:QuerySet=SampleData.objects.filter(report_time__range=(start_time,end_time))
271 | averageData=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
272 | cntData=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
273 | for i in today_data:
274 | #累加数据
275 | averageData[i.report_time.hour]=averageData[i.report_time.hour]+i.temperature
276 | cntData[i.report_time.hour]=cntData[i.report_time.hour]+1
277 | #计算平均
278 | for i in range(0,24):
279 | if cntData[i]!=0:
280 | averageData[i]=averageData[i]/cntData[i]
281 | response_data:str=json.dumps(averageData)
282 |
283 | return HttpResponse(response_data)
284 |
285 | def GetPress(request):
286 | now=datetime.datetime.now()
287 |
288 | dateData=request.GET.get('from').split('-')
289 |
290 | start_time=datetime.datetime(year=int(dateData[0]),month=int(dateData[1]),day=int(dateData[2]),\
291 | hour=0,minute=0,second=0)
292 | end_time=datetime.datetime(year=int(dateData[0]),month=int(dateData[1]),day=int(dateData[2]),\
293 | hour=23,minute=59,second=59)
294 |
295 | today_data:QuerySet=SampleData.objects.filter(report_time__range=(start_time,end_time))
296 | averageData=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
297 | cntData=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
298 | for i in today_data:
299 | #累加数据
300 | averageData[i.report_time.hour]=averageData[i.report_time.hour]+i.atmospressure
301 | cntData[i.report_time.hour]=cntData[i.report_time.hour]+1
302 | #计算平均
303 | for i in range(0,24):
304 | if cntData[i]!=0:
305 | averageData[i]=averageData[i]/cntData[i]
306 | response_data:str=json.dumps(averageData)
307 |
308 | return HttpResponse(response_data)
309 |
310 | def GetIllu(request):
311 | now=datetime.datetime.now()
312 |
313 | dateData=request.GET.get('from').split('-')
314 |
315 | start_time=datetime.datetime(year=int(dateData[0]),month=int(dateData[1]),day=int(dateData[2]),\
316 | hour=0,minute=0,second=0)
317 |
318 | end_time=datetime.datetime(year=int(dateData[0]),month=int(dateData[1]),day=int(dateData[2]),\
319 | hour=23,minute=59,second=59)
320 |
321 | today_data:QuerySet=SampleData.objects.filter(report_time__range=(start_time,end_time))
322 | averageData=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
323 | cntData=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
324 | for i in today_data:
325 | #累加数据
326 | averageData[i.report_time.hour]=averageData[i.report_time.hour]+i.illuminance
327 | cntData[i.report_time.hour]=cntData[i.report_time.hour]+1
328 | #计算平均
329 | for i in range(0,24):
330 | if cntData[i]!=0:
331 | averageData[i]=averageData[i]/cntData[i]
332 | response_data:str=json.dumps(averageData)
333 |
334 | return HttpResponse(response_data)
335 |
336 | def iotGoOnline(request):
337 | serverMod:ServerInfo=ServerInfo.objects.all()[0]
338 | serverMod.startup=datetime.datetime.now()
339 | serverMod.save()
340 | return HttpResponse("Updated.")
341 |
342 | def iotSync(request):
343 | #当IOT终端复位后发送给IOT终端恢复GPIO状态的指令
344 | devices=DeviceControl.objects.all()
345 | for i in devices:
346 | tosend='^ch%d:%s#'%(i.deviceId,i.deviceStatus)
347 | IotSend(tosend)
348 | return HttpResponse("Has Sync.")
349 |
350 | def appConfPage(request):
351 | context={'applist':UserApp.objects.all()}
352 | context['guiData']=ServerInfo.objects.all()[0]
353 |
354 | return render(request,"app_conf.html",context)
--------------------------------------------------------------------------------
/web/iot-uploader.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | python iot-uploader.py
--------------------------------------------------------------------------------
/web/iot-uploader.py:
--------------------------------------------------------------------------------
1 | import socket
2 | import threading
3 | import datetime
4 | import time
5 | import traceback
6 | import smtplib
7 | from email.mime.text import MIMEText
8 | from email.header import Header
9 | import requests
10 |
11 | time_out_setting:int=120
12 | listen_port:int=10010
13 | uploadKey='7355608'
14 |
15 | def SendMail(title:str,message:str):
16 | # 第三方 SMTP 服务
17 | #Thanks to runoob
18 | mail_host="smtp.qq.com" #设置服务器
19 | mail_user="@qq.com" #用户名
20 | mail_pass="" #口令
21 |
22 |
23 | sender = '@qq.com'
24 | receivers = ['@qq.com'] # 接收邮件,可设置为你的QQ邮箱或者其他邮箱
25 |
26 | htmlfile=open('mail.html','r',encoding='utf-8')
27 | htmldata=htmlfile.read()
28 | htmlfile.close()
29 | htmldata=htmldata.replace('{{time}}',time.strftime("%d日 %H时%M分%S秒", time.localtime())).\
30 | replace('{{message}}',message).replace('{{warning_title}}',title)
31 |
32 | mail_msg = htmldata
33 | message = MIMEText(mail_msg, 'html', 'utf-8')
34 | message['From'] = Header("服务器数据上报接口", 'utf-8')
35 | message['To'] = Header("管理员", 'utf-8')
36 |
37 | subject = 'IntelliSw - 错误报告'
38 | message['Subject'] = Header(subject, 'utf-8')
39 | try:
40 | smtpObj = smtplib.SMTP_SSL(host=mail_host)
41 | smtpObj.connect(mail_host, 465) # 25 为 SMTP 端口号
42 | smtpObj.login(mail_user,mail_pass)
43 | smtpObj.sendmail(sender, receivers, message.as_string())
44 | print("邮件发送成功")
45 | except smtplib.SMTPException:
46 | print("Error: 无法发送邮件")
47 |
48 |
49 | def UploadToHttp(iotdata):
50 | """upload_sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
51 | upload_sock.connect(('127.0.0.1',8000))
52 | tosend="GET /command/?c=iotrpt+%s+%s+%s+%s HTTP/1.1\r\nUser-Agent: app/iot-uploader\r\nConnection: close\r\nHost: 127.0.0.1:8000\r\n\r\n"%\
53 | (iotdata[0],iotdata[1],iotdata[2],iotdata[3])
54 |
55 | print(tosend)
56 |
57 | upload_sock.send(tosend.encode('utf-8'))
58 | time.sleep(0.2)
59 | tosendback=upload_sock.recv(1024)
60 | upload_sock.close()
61 | dat_str=tosendback.decode('utf-8')
62 | len=dat_str.split('\r\n').__len__()
63 | totellback="$%s#"%dat_str.split('\r\n')[len-1].replace('saved.','')
64 | print("服务器返回:",totellback)
65 | return totellback.encode('utf-8')"""
66 | headers={"User-Agent":"app/iot-uploader","Connection":"close"}
67 | kw={"c":"iotrpt %s %s %s %s"%(iotdata[0],iotdata[1],iotdata[2],iotdata[3]),"pwd":uploadKey}
68 | response=requests.get("http://127.0.0.1:8000/command/",headers=headers,params=kw)
69 | totellback="$%s#"%(response.text.split('\r\n')[1].replace('saved.',''))
70 | print("回传给IOT终端:",totellback)
71 | return totellback.encode('utf-8')
72 |
73 | iot_socket:socket.socket=None
74 |
75 | class Listening(threading.Thread):
76 | mysocket:socket.socket=None
77 | remote_addr=None
78 | has_sync=False
79 | def __init__(self,sock,addr):
80 | threading.Thread.__init__(self)
81 | self.mysocket=sock
82 | self.remote_addr=addr
83 |
84 | def run(self):
85 | global iot_socket
86 | while(True):
87 | try:
88 | recv_data=self.mysocket.recv(2048)
89 | iotdata=recv_data.decode('utf-8')
90 | if iotdata[0]=='$':
91 | 粘包分段尝试=iotdata.split('#')
92 | if 粘包分段尝试.__len__()>2:
93 | print(iotdata)
94 | print("MCU发送的数据包粘包")
95 | iotdata=粘包分段尝试[0]+'#'
96 | #$25.14:47:101443.33:83.3#
97 | print("%s 接收到MCU传来数据:%s"%(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),iotdata))
98 | iot_socket=self.mysocket
99 | self.mysocket.settimeout(time_out_setting)
100 | iotdata=iotdata.replace('$','').replace('#','')
101 | datas=iotdata.split(':')
102 | datas[2]="%.2f"%(float(datas[2])/100)
103 | print("温度:%s,湿度:%s,大气压:%s,光照强度:%s"%(datas[0],datas[1],datas[2],datas[3]))
104 | #上报服务器
105 | totellback=UploadToHttp(datas)
106 | self.mysocket.send(totellback)
107 | time.sleep(1)
108 | if self.has_sync==False:
109 | requests.get('http://127.0.0.1:8000/iotgo/')
110 | requests.get('http://127.0.0.1:8000/iotsync/')
111 | self.has_sync=True
112 | elif iotdata[0]=='^':
113 | print("%s 接收到本地服务器传来数据:%s"%(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),iotdata))
114 | #iotdata=iotdata.replace('^','$')
115 | templist=list(iotdata)
116 | templist[0]='$'
117 | iotdata=''.join(templist)
118 | if iot_socket!=None:
119 | print(iotdata)
120 | iot_socket.send(iotdata.encode('utf-8'))
121 | print("已将本地服务器要求转发MCU")
122 | else:
123 | print("尚未获取到IOT_SOCKET")
124 | self.mysocket.close()
125 | return
126 | except Exception as e:
127 | if str(e)=='timed out':
128 | print("=========MCU连接超时,未及时上传数据,将断开连接并发送邮件上报。")
129 | self.mysocket.close()
130 | SendMail('IntelliSw-MCU不在位警告','等待了%ds后,位于服务器的数据上报接口仍未收到来自MCU的心跳数据包。我们判定此终端已丢失连接。请立刻检查MCU电路,并恢复连接。'%time_out_setting)
131 | iot_socket=None
132 | return
133 | else:
134 | print(e)
135 | traceback.print_exc()
136 | self.mysocket.close()
137 | if iot_socket is self.mysocket:
138 | iot_socket=None
139 | print("===========MCU终端SOCKET释放,失去与MCU的连接。发送邮件上报事故。")
140 | SendMail('IntelliSw-MCU丢失连接错误','MCU终端意外地丢失了与服务器建立的长连接。这并非程序所刻意设计或料想的。可能是ESP8266模块或STM32单片机问题。按照程序逻辑,检测到丢失连接后会触发看门狗立刻复位。请即刻检查MCU并完成维护工作。')
141 | return
142 |
143 |
144 | serversocket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
145 | addr=('0.0.0.0',listen_port)
146 | serversocket.bind(addr)
147 | serversocket.listen(5)
148 | print("服务器上报程序开始监听端口%d"%listen_port)
149 |
150 | while(True):
151 | client_socket,client_addr=serversocket.accept()
152 | listener=Listening(client_socket,client_addr)
153 | listener.start()
154 | print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),client_addr,"连接了服务器。")
155 |
156 |
157 |
158 |
--------------------------------------------------------------------------------
/web/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | """Run administrative tasks."""
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'IntelliSw.settings')
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == '__main__':
22 | main()
23 |
--------------------------------------------------------------------------------
/web/start.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | python manage.py runserver 0.0.0.0:8000
--------------------------------------------------------------------------------
/web/static/app_conf.js:
--------------------------------------------------------------------------------
1 | function CanvasInit(vs_container, myCanvas) {
2 | var scr_width = vs_container.offsetWidth;
3 | var scr_height = scr_width / screenWidth * screenHeight;
4 | virtualPixelSize = scr_width / screenWidth;
5 | console.log(virtualPixelSize);
6 | CanvasWidth = scr_width;
7 | CanvasHeight = scr_height;
8 | vs_container.style.height = scr_height.toFixed(2).toString() + 'px';
9 | myCanvas.setAttribute("width", CanvasWidth);
10 | myCanvas.setAttribute("height", CanvasHeight);
11 | canvas = myCanvas;
12 | ctx = canvas.getContext("2d");
13 | CanvasTest();
14 | }
15 |
16 | function CanvasTest() {
17 | ctx.fillStyle = "#808000";
18 | ctx.fillRect(0, 0, CanvasWidth, CanvasHeight);
19 | ctx.font = CanvasHeight / guisize_y + "px Courier New";
20 | ctx.fillStyle = "#000000";
21 | //ctx.fillText("Hello World!34",10,CanvasHeight/guisize_y);
22 | printf(" IntelliSw");
23 | printf("Mon 15:43:11");
24 | printf("Temp:27.56'C");
25 | printf("QNH:1013.13hPa");
26 | printf("ILLU:103lx");
27 | printf("HUMI:56 per");
28 | }
29 |
30 | function SetAppActive(id) {
31 | alert(id + "已激活");
32 | }
33 |
34 | function PixelCalc(a) {
35 | return parseInt(a) + 0.5;
36 | }
37 |
38 | function SetColor(color) {
39 | ctx.fillStyle = color;
40 | ctx.strokeStyle = color;
41 | ctx.shadowColor = color;
42 | }
43 |
44 | function DrawSingleWord(word, x, y) {
45 | var modelArray = chars_pixel_jsondata[word];
46 | SetColor("#000000")
47 | for (var b = 0; b < 4; b++) {
48 | var loc_x = x;
49 | for (var i = 0; i < modelArray.length; i++) {
50 | var currentData = modelArray[i];
51 | var loc_y = y;
52 | for (var j = 0; j < 8; j++) {
53 | if ((currentData & 1) == 1)
54 | SetColor("#000000")
55 | else
56 | SetColor("#808000")
57 | ctx.fillRect(loc_x, loc_y, virtualPixelSize, virtualPixelSize);
58 | loc_y += virtualPixelSize;
59 | currentData = currentData >> 1;
60 | }
61 | loc_x += virtualPixelSize;
62 | }
63 | }
64 | }
65 |
66 | var currentLine = 0;
67 |
68 | function MoveLine() {
69 | var toreturn = currentLine++;
70 | if (currentLine == guisize_y)
71 | currentLine = 0;
72 | return toreturn;
73 | }
74 |
75 | var ScreenDataArray=new Array(guisize_y);
76 |
77 | function DrawCursor()
78 | {
79 | document.getElementById('line_cursor').style.marginTop=currentLine*virtualPixelSize * word_y+"px";
80 | }
81 |
82 | function printf(str) {
83 | var toshowStr = str;
84 | while (toshowStr.length > guisize_x) {
85 | var line = MoveLine();
86 | ScreenDataArray[line]="";
87 | for (var i = 0; i < guisize_x; i++) {
88 | DrawSingleWord(toshowStr[i], i * virtualPixelSize * word_x, line * virtualPixelSize * word_y);
89 | ScreenDataArray[line]+=toshowStr[i];
90 | }
91 | toshowStr = toshowStr.slice(14, toshowStr.length);
92 | }
93 | var line = MoveLine();
94 | ScreenDataArray[line]="";
95 | for (var i = 0; i < guisize_x; i++) {
96 | if(iimg
208 |
209 | /*设置gif下的img元素样式*/
210 | {
211 | height: 5%;
212 | width: 5%;
213 | border-radius: 10px;
214 | }
--------------------------------------------------------------------------------
/web/static/index.js:
--------------------------------------------------------------------------------
1 | function ClockEvent()
2 | {
3 | $('#reftime').html((parseInt($('#reftime').html())+1).toString());
4 | if(parseInt($('#reftime').html())>=60&&parseInt($('#reftime').html())<=70)
5 | GetView();
6 | }
7 |
8 | function GetView() {
9 | $.ajax({
10 | url: "view/",
11 | type: "GET",
12 | success: function (result) {
13 | var jsonObj = JSON.parse(result);
14 | for (var k in jsonObj) {
15 | $('#' + k).html(jsonObj[k]);
16 | }
17 | $(".gif").css("display", "none");
18 | }
19 | });
20 |
21 | }
22 |
23 | var isToday = true;
24 | function ChangeDate() {
25 | var time = new Date();
26 | var day = ("0" + time.getDate()).slice(-2);
27 | var month = ("0" + (time.getMonth() + 1)).slice(-2);
28 | var today = time.getFullYear() + "-" + (month) + "-" + (day);
29 | if ($('#date_picker').val() == today)
30 | isToday = true;
31 | else
32 | isToday = false;
33 | GetTempData();
34 | GetPressData();
35 | GetIlluData();
36 | }
37 | var temp_ctx = null;
38 | var tempChart = null;
39 |
40 | function GetTempData() {
41 | $.ajax({
42 | url: 'temp/',
43 | type: 'GET',
44 | data: { 'from': $('#date_picker').val() },
45 | success: function (result) {
46 | var mydata = JSON.parse(result);
47 | //这里如果遇到0度,会直接识别为没有数据,我找不到更好的解决方法
48 | var min_value = 99999; var max_value = -99999;
49 | for (var i = 0; i < mydata.length; i++) {
50 | mydata[i] = parseFloat(mydata[i].toFixed(2));
51 | if (mydata[i] > max_value)
52 | max_value = mydata[i];
53 | if (mydata[i] < min_value)
54 | min_value = mydata[i];
55 |
56 | var now = new Date();
57 | if (i > now.getHours() && isToday)
58 | mydata[i] = null;
59 | }
60 | temp_ctx = document.getElementById("tempChart").getContext('2d');
61 | tempChart = new Chart(temp_ctx, {
62 | type: 'line',
63 | data: {
64 | labels: ["0时", "1时", "2时", "3时", "4时", "5时", "6时", "7时", "8时", "9时", "10时"
65 | , "11时", "12时", "13时", "14时", "15时", "16时", "17时", "18时", "19时", "20时", "21时", "22时", "23时"],
66 | datasets: [{
67 | label: '温度变化曲线',
68 | data: mydata,
69 | backgroundColor: [
70 | 'rgba(255, 99, 132, 0.2)'
71 | ],
72 | borderColor: [
73 | 'rgba(255,99,132,1)'
74 | ],
75 | borderWidth: 1
76 | }]
77 | },
78 | options: {
79 | spanGaps: true,
80 | scales: {
81 | y: {
82 | suggestedMin: min_value - 2,
83 | suggestedMax: max_value + 2
84 | }
85 | }
86 | }
87 | });
88 | }
89 | });
90 | }
91 |
92 | var press_ctx = null;
93 | var pressChart = null;
94 | function GetPressData() {
95 | $.ajax({
96 | url: 'press/',
97 | type: 'GET',
98 | data: { 'from': $('#date_picker').val() },
99 | success: function (result) {
100 | var mydata = JSON.parse(result);
101 | for (var i = 0; i < mydata.length; i++) {
102 | mydata[i] = parseFloat(mydata[i].toFixed(2));
103 | var now = new Date();
104 | if (i > now.getHours() && isToday)
105 | mydata[i] = null;
106 | }
107 | press_ctx = document.getElementById("pressChart").getContext('2d');
108 | pressChart = new Chart(press_ctx, {
109 | type: 'line',
110 | data: {
111 | labels: ["0时", "1时", "2时", "3时", "4时", "5时", "6时", "7时", "8时", "9时", "10时"
112 | , "11时", "12时", "13时", "14时", "15时", "16时", "17时", "18时", "19时", "20时", "21时", "22时", "23时"],
113 | datasets: [{
114 | label: '气压变化曲线',
115 | data: mydata,
116 | backgroundColor: [
117 | 'rgba(255, 99, 132, 0.2)'
118 | ],
119 | borderColor: [
120 | 'rgba(255,99,132,1)'
121 | ],
122 | borderWidth: 1
123 | }]
124 | },
125 | options: {
126 | spanGaps: true,
127 | scales: {
128 | y: {
129 | suggestedMin: 950,
130 | suggestedMax: 1060
131 | }
132 | }
133 | }
134 | });
135 | }
136 | });
137 | }
138 |
139 | var illu_ctx = null;
140 | var illuChart = null;
141 | function GetIlluData() {
142 | $.ajax({
143 | url: 'illu/',
144 | type: 'GET',
145 | data: { 'from': $('#date_picker').val() },
146 | success: function (result) {
147 | var mydata = JSON.parse(result);
148 | for (var i = 0; i < mydata.length; i++) {
149 | //if (mydata[i] == 0)
150 | mydata[i] = parseFloat(mydata[i].toFixed(2));
151 | var now = new Date();
152 | if (i > now.getHours() && isToday)
153 | mydata[i] = null;
154 | }
155 | illu_ctx = document.getElementById("illuChart").getContext('2d');
156 | illuChart = new Chart(illu_ctx, {
157 | type: 'line',
158 | data: {
159 | labels: ["0时", "1时", "2时", "3时", "4时", "5时", "6时", "7时", "8时", "9时", "10时"
160 | , "11时", "12时", "13时", "14时", "15时", "16时", "17时", "18时", "19时", "20时", "21时", "22时", "23时"],
161 | datasets: [{
162 | label: '光照强度变化曲线',
163 | data: mydata,
164 | backgroundColor: [
165 | 'rgba(255, 99, 132, 0.2)'
166 | ],
167 | borderColor: [
168 | 'rgba(255,99,132,1)'
169 | ],
170 | borderWidth: 1
171 | }]
172 | },
173 | options: {
174 | spanGaps: true,
175 | scales: {
176 | yAxes: [{
177 | ticks: {
178 | }
179 | }]
180 | }
181 | }
182 | });
183 | }
184 | });
185 | }
186 |
187 | function OnTimeEvent() {
188 | RefreshHTML();
189 | }
190 |
191 | function navStick(liid, target) {
192 | document.getElementById('li1').setAttribute('class', '');
193 | document.getElementById('li2').setAttribute('class', '');
194 | document.getElementById('li3').setAttribute('class', '');
195 | document.getElementById('li4').setAttribute('class', '');
196 | document.getElementById(liid).setAttribute('class', 'active');
197 | $('html,body').animate({ scrollTop: $('#' + target).offset().top - 70 }, 1000);
198 |
199 | }
200 |
201 | function Talert(msg) {
202 | alert(msg);
203 | if (IsClient())
204 | window.web.ToastAlert(msg);
205 | }
206 |
207 | function isContains(str, substr) {
208 | return str.indexOf(substr) >= 0;
209 | }
210 |
211 | function debug() {
212 | //debuginfo
213 | Talert(navigator.userAgent);
214 | }
215 |
216 | function IsClient() {
217 | return isContains(navigator.userAgent, "app/");
218 | }
219 |
220 | function debuginfo() {
221 | var toshowinfo = "当前平台:";
222 | if (isContains(navigator.userAgent, "app/"))
223 | toshowinfo += "安卓客户端";
224 | else if (isContains(navigator.userAgent.toLowerCase(), "android"))
225 | toshowinfo += "安卓";
226 | else if (isContains(navigator.userAgent.toLowerCase(), "windows"))
227 | toshowinfo += "Windows";
228 | else if (isContains(navigator.userAgent.toLowerCase(), "linux"))
229 | toshowinfo += "Linux";
230 | else
231 | toshowinfo += "Invalid Platform"
232 | $('#serverinfodiv').html($('#serverinfodiv').html() + "
" + toshowinfo);
233 | }
234 |
235 | function webTerminal() {
236 | $("#termin-exec").attr({ "disabled": "disabled" });
237 | if ($('#commandbox').val() == "") {
238 | Talert('请输入有效命令');
239 | $("#termin-exec").attr({ "disabled": "" });
240 | return;
241 | }
242 | $.ajax({
243 | url: 'command/',
244 | type: 'GET',
245 | data: { 'c': $('#commandbox').val() },
246 | success: function (result) {
247 | Talert(result);
248 | GetView();
249 | }
250 | });
251 | $("#termin-exec").attr({ "disabled": "" });
252 | }
253 |
254 | function RefreshHTML() {
255 | if (IsClient())
256 | window.web.RefreshPage();
257 | else
258 | window.location.reload();
259 | }
260 |
261 | function exitPAGE() {
262 | if (IsClient())
263 | window.web.ExitProgram();
264 | else {
265 | window.opener = null;
266 | window.open('', '_self');
267 | window.close();
268 | }
269 | }
270 |
271 | function device_ctl(deviceId, cmd) {
272 | $("#devbtn" + deviceId.toString()).attr({ "disabled": "disabled" });
273 | $.ajax({
274 | url: 'command/',
275 | type: 'GET',
276 | data: { 'c': 'devedit ' + deviceId.toString() + ' ' + cmd },
277 | success: function (result) {
278 | if (isContains(result, 'errs')) {
279 | Talert(result.split('\r\n')[1]);
280 | }
281 | /*else {
282 | $('#devbtn' + deviceId.toString()).val(result.split('\r\n')[1]);
283 | if (result.split('\r\n')[1] == 'On') {
284 | $('#devbtn' + deviceId.toString()).removeClass('btn-primary');
285 | $('#devbtn' + deviceId.toString()).addClass('btn-danger');
286 | } else {
287 | $('#devbtn' + deviceId.toString()).addClass('btn-primary');
288 | $('#devbtn' + deviceId.toString()).removeClass('btn-danger');
289 | }
290 |
291 | }*/
292 | GetView();
293 | //$('#devbtn'+deviceId.toString()).val(result);
294 | }
295 | });
296 | $("#devbtn" + deviceId.toString()).attr({ "disabled": "" });
297 | }
--------------------------------------------------------------------------------
/web/template/app_conf.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | IntelliSw - 应用配置
7 |
8 |
10 |
52 |
53 |
54 |
55 |
56 |
74 |
75 |
76 |
77 |
78 |
79 |
GUI模拟
80 |
可供编辑的X大小为{{guiData.guisize_x}}个字符,Y大小为{{guiData.guisize_y}}个字符。
81 |
82 | 每个字符宽{{guiData.word_x}} px,高{{guiData.word_y}} px。
83 |
84 |
85 |
86 |
►
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | GUI制作
98 |
99 |
100 |
101 |
102 | #
103 |
104 |
105 |
113 |
121 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
插件管理
141 |
注册了的插件
142 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
206 | {% load static %}
207 |
208 |
209 |
210 |
211 |
--------------------------------------------------------------------------------