Updated V2 (functioning)
This commit is contained in:
parent
20ed200486
commit
2210a04de7
103 changed files with 31170 additions and 20166 deletions
150
Src/main.c
Normal file → Executable file
150
Src/main.c
Normal file → Executable file
|
@ -1,4 +1,4 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : main.c
|
||||
|
@ -43,7 +43,7 @@
|
|||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "EPD_1in54.h"
|
||||
#include "EPD_1in54_V2.h"
|
||||
#include "DEV_Config.h"
|
||||
#include "GUI_Paint.h"
|
||||
#include "ImageData.h"
|
||||
|
@ -93,13 +93,13 @@ const uint8_t WeekLetter[7][2]={
|
|||
"So"
|
||||
};
|
||||
|
||||
enum Mode{Running, Choose, Set, Offscreen};
|
||||
enum Mode{Running, Choose, Set /*, Offscreen*/};
|
||||
uint8_t system_mode = Running;
|
||||
uint8_t setWeekday,weekday,hour,minsec;
|
||||
uint8_t selector_pos = 0;
|
||||
//Create a new image cache
|
||||
UBYTE *BlackImage;
|
||||
UWORD Imagesize = ((EPD_WIDTH % 8 == 0) ? (EPD_WIDTH / 8) : (EPD_WIDTH / 8 + 1)) * EPD_HEIGHT;
|
||||
UWORD Imagesize = ((EPD_1IN54_V2_WIDTH % 8 == 0) ? (EPD_1IN54_V2_WIDTH / 8) : (EPD_1IN54_V2_WIDTH / 8 + 1)) * EPD_1IN54_V2_HEIGHT;
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
|
@ -145,6 +145,7 @@ int main(void)
|
|||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
|
||||
/* MCU Configuration--------------------------------------------------------*/
|
||||
|
||||
|
@ -168,17 +169,17 @@ int main(void)
|
|||
MX_USART1_UART_Init();
|
||||
MX_RTC_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
if (EPD_Init(lut_full_update) != 0){
|
||||
printf("e-Paper init failed\r\n");
|
||||
}
|
||||
EPD_Clear();
|
||||
DEV_Delay_ms(500);
|
||||
DEV_Module_Init();
|
||||
printf("e-Paper Init and Clear...\r\n");
|
||||
EPD_1IN54_V2_Init();
|
||||
EPD_1IN54_V2_Clear();
|
||||
DEV_Delay_ms(500);
|
||||
|
||||
if ((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL){
|
||||
printf("Failed to apply for black memory...\r\n");
|
||||
return 1;
|
||||
}
|
||||
Paint_NewImage(BlackImage, EPD_WIDTH, EPD_HEIGHT, 270, WHITE);
|
||||
Paint_NewImage(BlackImage, EPD_1IN54_V2_WIDTH, EPD_1IN54_V2_HEIGHT, 270, WHITE);
|
||||
Paint_SelectImage(BlackImage);
|
||||
Paint_Clear(WHITE);
|
||||
sPaint_time.Hour = 0;
|
||||
|
@ -187,32 +188,37 @@ int main(void)
|
|||
|
||||
|
||||
//Partial refresh, example shows time
|
||||
if (EPD_Init(lut_partial_update) != 0){
|
||||
printf("e-Paper init failed\r\n");
|
||||
}
|
||||
Paint_SelectImage(BlackImage);
|
||||
Eeprom_loadsettings();
|
||||
|
||||
for (;;){
|
||||
HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BIN); // Get Time
|
||||
HAL_RTC_GetDate(&hrtc, &sDate, RTC_FORMAT_BIN); // Get Date
|
||||
sPaint_time.Hour = sTime.Hours;
|
||||
sPaint_time.Min = sTime.Minutes;
|
||||
sPaint_time.Sec = sTime.Seconds;
|
||||
if(system_mode!=Offscreen){
|
||||
// System_screenfullupdate(System_CustomHeartbeat(1));
|
||||
Paint_SelectImage(BlackImage);
|
||||
Paint_Clear(WHITE);
|
||||
Paint_DrawArray();
|
||||
Paint_DrawCurrent();
|
||||
Paint_Selector(System_CustomHeartbeat(2),selector_pos, system_mode);
|
||||
// System_screenfullupdate(System_CustomHeartbeat(1));
|
||||
Paint_SelectImage(BlackImage);
|
||||
Paint_Clear(WHITE);
|
||||
|
||||
Paint_Drawonoff(System_fire());
|
||||
EPD_Display(BlackImage);
|
||||
DEV_Delay_ms(50); //Analog clock 1s
|
||||
Paint_DrawArray();
|
||||
Paint_DrawCurrent();
|
||||
Paint_Selector(System_CustomHeartbeat(2),selector_pos, system_mode);
|
||||
Paint_Drawonoff(System_fire());
|
||||
|
||||
}
|
||||
EPD_1IN54_V2_DisplayPart(BlackImage);
|
||||
// DEV_Delay_ms(50); //Analog clock 1s
|
||||
System_bjt_output(System_fire());
|
||||
//printout current system
|
||||
// if(System_fire()){
|
||||
// printf("HOT \r\n");
|
||||
// }else{
|
||||
// printf("COLD \r\n");
|
||||
// }
|
||||
// if(HAL_GPIO_ReadPin(FLT_GPIO_Port,FLT_Pin)){
|
||||
// printf("FLT HIGH\r\n");
|
||||
// }else{
|
||||
// printf("FLT LOW\r\n");
|
||||
// }
|
||||
// else{
|
||||
// Paint_Clear(WHITE);
|
||||
// Paint_DrawString_EN(0,0,"You can remove the monitor",&Font16,WHITE,BLACK);
|
||||
|
@ -221,46 +227,30 @@ int main(void)
|
|||
// EPD_Sleep();
|
||||
// }
|
||||
// printf("500ms..\r\n");
|
||||
if(!HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_12)){
|
||||
if(!HAL_GPIO_ReadPin(ButtonLeft_GPIO_Port,ButtonLeft_Pin)){
|
||||
ButtonLeft_Pressed();
|
||||
}
|
||||
if(!HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_13)){
|
||||
if(!HAL_GPIO_ReadPin(ButtonPress_GPIO_Port,ButtonPress_Pin)){
|
||||
ButtonPress_Pressed();
|
||||
}
|
||||
if(!HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_14)){
|
||||
if(!HAL_GPIO_ReadPin(ButtonRight_GPIO_Port,ButtonRight_Pin)){
|
||||
ButtonRight_Pressed();
|
||||
}
|
||||
if(!HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_15)){
|
||||
HAL_Delay(100);
|
||||
if(!HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_15)){
|
||||
if(system_mode == Running){
|
||||
for(uint8_t i = 0 ; i<3 ;i++){
|
||||
system_mode = Offscreen;
|
||||
Paint_Clear(WHITE);
|
||||
Paint_DrawString_EN(0,0,"You can remove the monitor",&Font16,WHITE,BLACK);
|
||||
EPD_Display(BlackImage);
|
||||
DEV_Delay_ms(200); //Analog clock 1s
|
||||
}
|
||||
EPD_Sleep();
|
||||
|
||||
}else{
|
||||
// for(uint8_t i = 0 ; i<2 ;i++){
|
||||
//Partial refresh, example shows time
|
||||
if (EPD_Init(lut_partial_update) != 0){
|
||||
printf("e-Paper init failed\r\n");
|
||||
}
|
||||
Paint_SelectImage(BlackImage);
|
||||
EPD_Display(BlackImage);
|
||||
DEV_Delay_ms(200);
|
||||
// }
|
||||
system_mode = Running;
|
||||
}
|
||||
}
|
||||
if(!HAL_GPIO_ReadPin(EINK_Refresh_GPIO_Port,EINK_Refresh_Pin)){
|
||||
HAL_Delay(150);
|
||||
if(!HAL_GPIO_ReadPin(EINK_Refresh_GPIO_Port,EINK_Refresh_Pin)){
|
||||
EPD_1IN54_V2_Init();
|
||||
EPD_1IN54_V2_Clear();
|
||||
DEV_Delay_ms(20);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
|
||||
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
|
@ -282,12 +272,11 @@ void SystemClock_Config(void)
|
|||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
|
||||
|
||||
/**Initializes the CPU, AHB and APB busses clocks
|
||||
/** Initializes the CPU, AHB and APB busses clocks
|
||||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE;
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
|
||||
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
|
@ -296,7 +285,7 @@ void SystemClock_Config(void)
|
|||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/**Initializes the CPU, AHB and APB busses clocks
|
||||
/** Initializes the CPU, AHB and APB busses clocks
|
||||
*/
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||
|
@ -310,7 +299,7 @@ void SystemClock_Config(void)
|
|||
Error_Handler();
|
||||
}
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC;
|
||||
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
|
||||
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_HSE_DIV128;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
|
@ -331,11 +320,12 @@ static void MX_RTC_Init(void)
|
|||
|
||||
RTC_TimeTypeDef sTime = {0};
|
||||
RTC_DateTypeDef DateToUpdate = {0};
|
||||
RTC_TamperTypeDef sTamper = {0};
|
||||
|
||||
/* USER CODE BEGIN RTC_Init 1 */
|
||||
|
||||
/* USER CODE END RTC_Init 1 */
|
||||
/**Initialize RTC Only
|
||||
/** Initialize RTC Only
|
||||
*/
|
||||
hrtc.Instance = RTC;
|
||||
hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
|
||||
|
@ -346,10 +336,10 @@ static void MX_RTC_Init(void)
|
|||
}
|
||||
|
||||
/* USER CODE BEGIN Check_RTC_BKUP */
|
||||
|
||||
|
||||
/* USER CODE END Check_RTC_BKUP */
|
||||
|
||||
/**Initialize RTC and set the Time and Date
|
||||
/** Initialize RTC and set the Time and Date
|
||||
*/
|
||||
sTime.Hours = 0x0;
|
||||
sTime.Minutes = 0x0;
|
||||
|
@ -368,6 +358,14 @@ static void MX_RTC_Init(void)
|
|||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/** Enable the RTC Tamper
|
||||
*/
|
||||
sTamper.Tamper = RTC_TAMPER_1;
|
||||
sTamper.Trigger = RTC_TAMPERTRIGGER_LOWLEVEL;
|
||||
if (HAL_RTCEx_SetTamper(&hrtc, &sTamper) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN RTC_Init 2 */
|
||||
|
||||
/* USER CODE END RTC_Init 2 */
|
||||
|
@ -480,12 +478,18 @@ static void MX_GPIO_Init(void)
|
|||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : ButtonLeft_Pin ButtonPress_Pin ButtonRight_Pin system_mode_Pin */
|
||||
GPIO_InitStruct.Pin = ButtonLeft_Pin|ButtonPress_Pin|ButtonRight_Pin|system_mode_Pin;
|
||||
/*Configure GPIO pins : ButtonLeft_Pin ButtonPress_Pin ButtonRight_Pin EINK_Refresh_Pin */
|
||||
GPIO_InitStruct.Pin = ButtonLeft_Pin|ButtonPress_Pin|ButtonRight_Pin|EINK_Refresh_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : FLT_Pin */
|
||||
GPIO_InitStruct.Pin = FLT_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(FLT_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 4 */
|
||||
|
@ -589,15 +593,15 @@ void System_bjt_output(bool on){
|
|||
}
|
||||
|
||||
void System_screenfullupdate(bool heartbeat){
|
||||
if(heartbeat){
|
||||
if (EPD_Init(lut_full_update) != 0){
|
||||
printf("e-Paper init failed\r\n");
|
||||
}
|
||||
}else{
|
||||
if (EPD_Init(lut_partial_update) != 0){
|
||||
printf("e-Paper init failed\r\n");
|
||||
}
|
||||
}
|
||||
// if(heartbeat){
|
||||
// if (EPD_Init(lut_full_update) != 0){
|
||||
// printf("e-Paper init failed\r\n");
|
||||
// }
|
||||
// }else{
|
||||
// if (EPD_Init(lut_partial_update) != 0){
|
||||
// printf("e-Paper init failed\r\n");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
bool System_fire(){
|
||||
|
|
11
Src/stm32f1xx_hal_msp.c
Normal file → Executable file
11
Src/stm32f1xx_hal_msp.c
Normal file → Executable file
|
@ -92,7 +92,7 @@ void HAL_MspInit(void)
|
|||
|
||||
/* System interrupt init*/
|
||||
|
||||
/**NOJTAG: JTAG-DP Disabled and SW-DP Enabled
|
||||
/** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
|
||||
*/
|
||||
__HAL_AFIO_REMAP_SWJ_NOJTAG();
|
||||
|
||||
|
@ -109,7 +109,6 @@ void HAL_MspInit(void)
|
|||
*/
|
||||
void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
|
||||
{
|
||||
|
||||
if(hrtc->Instance==RTC)
|
||||
{
|
||||
/* USER CODE BEGIN RTC_MspInit 0 */
|
||||
|
@ -133,10 +132,8 @@ void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
|
|||
* @param hrtc: RTC handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
|
||||
{
|
||||
|
||||
if(hrtc->Instance==RTC)
|
||||
{
|
||||
/* USER CODE BEGIN RTC_MspDeInit 0 */
|
||||
|
@ -159,7 +156,6 @@ void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
|
|||
*/
|
||||
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(hspi->Instance==SPI1)
|
||||
{
|
||||
|
@ -192,10 +188,8 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
|
|||
* @param hspi: SPI handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
|
||||
{
|
||||
|
||||
if(hspi->Instance==SPI1)
|
||||
{
|
||||
/* USER CODE BEGIN SPI1_MspDeInit 0 */
|
||||
|
@ -225,7 +219,6 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
|
|||
*/
|
||||
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
||||
{
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(huart->Instance==USART1)
|
||||
{
|
||||
|
@ -263,10 +256,8 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
|||
* @param huart: UART handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
||||
{
|
||||
|
||||
if(huart->Instance==USART1)
|
||||
{
|
||||
/* USER CODE BEGIN USART1_MspDeInit 0 */
|
||||
|
|
1
Src/stm32f1xx_it.c
Normal file → Executable file
1
Src/stm32f1xx_it.c
Normal file → Executable file
|
@ -71,6 +71,7 @@
|
|||
/* USER CODE END 0 */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
|
0
Src/syscalls.c
Normal file → Executable file
0
Src/syscalls.c
Normal file → Executable file
0
Src/system_stm32f1xx.c
Normal file → Executable file
0
Src/system_stm32f1xx.c
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue