code beautifying
This commit is contained in:
@ -6,11 +6,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <hmi.h>
|
||||||
#include "stm32f1xx_hal.h"
|
#include "stm32f1xx_hal.h"
|
||||||
#include "display.h"
|
|
||||||
#include "alarm.h"
|
#include "alarm.h"
|
||||||
#include <PontCoopScheduler.h>
|
#include <PontCoopScheduler.h>
|
||||||
|
#include "oled.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -50,6 +50,11 @@ void updateDisplay(void *handle) {
|
|||||||
LED_P8x16Str(0, 6, buf);
|
LED_P8x16Str(0, 6, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void hmiInit() {
|
||||||
|
schAdd(updateDisplay, &display, 0, 250);
|
||||||
|
}
|
||||||
|
|
||||||
void clearSetMode(void *handle) {
|
void clearSetMode(void *handle) {
|
||||||
tDisplay *lDisplay = (tDisplay*) handle;
|
tDisplay *lDisplay = (tDisplay*) handle;
|
||||||
lDisplay->setModeTemperature = 0;
|
lDisplay->setModeTemperature = 0;
|
@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* display.h
|
* hmi.h
|
||||||
*
|
*
|
||||||
* Created on: May 31, 2017
|
* Created on: May 31, 2017
|
||||||
* Author: wn
|
* Author: wn
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DISPLAY_H_
|
#ifndef HMI_H_
|
||||||
#define DISPLAY_H_
|
#define HMI_H_
|
||||||
|
|
||||||
|
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
@ -26,10 +26,11 @@ typedef struct {
|
|||||||
uint32_t overrunTime;
|
uint32_t overrunTime;
|
||||||
} tDisplay;
|
} tDisplay;
|
||||||
|
|
||||||
|
void hmiInit(void);
|
||||||
void updateDisplay(void *handle);
|
void updateDisplay(void *handle);
|
||||||
void displayToggleSetMode();
|
void displayToggleSetMode();
|
||||||
void displayDecValue();
|
void displayDecValue();
|
||||||
void displayIncValue();
|
void displayIncValue();
|
||||||
|
|
||||||
|
|
||||||
#endif /* DISPLAY_H_ */
|
#endif /* HMI_H_ */
|
@ -16,21 +16,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <hmi.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <PontCoopScheduler.h>
|
#include <PontCoopScheduler.h>
|
||||||
#include "stm32f1xx_hal.h"
|
#include "stm32f1xx_hal.h"
|
||||||
|
|
||||||
#include "oled.h"
|
#include "oled.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "display.h"
|
|
||||||
|
|
||||||
extern tDisplay display;
|
|
||||||
|
|
||||||
|
|
||||||
void my_setup_1() {
|
void my_setup_1() {
|
||||||
schInit();
|
schInit();
|
||||||
schAdd(updateDisplay, &display, 0, 250);
|
|
||||||
schAdd(secondTick, &display, 0, 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_loop() {
|
void my_loop() {
|
||||||
@ -47,7 +44,9 @@ void my_errorHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void my_setup_2() {
|
void my_setup_2() {
|
||||||
LED_Init();
|
hmiInit();
|
||||||
|
timerInit();
|
||||||
|
oledInit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ void Set_NOP(void)
|
|||||||
LED_WrCmd(0xE3); // Command for No Operation
|
LED_WrCmd(0xE3); // Command for No Operation
|
||||||
}
|
}
|
||||||
|
|
||||||
void LED_Init(void)
|
void oledInit(void)
|
||||||
{
|
{
|
||||||
// LEDPIN_Init();
|
// LEDPIN_Init();
|
||||||
// LED_PORT=0X0F;
|
// LED_PORT=0X0F;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* Adapted from Arduino to STM32 HAL by wollud1969
|
* Adapted from Arduino to STM32 HAL by wollud1969
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void LED_Init(void);
|
void oledInit(void);
|
||||||
|
|
||||||
void LED_CLS(void);
|
void LED_CLS(void);
|
||||||
void LED_Set_Pos(unsigned char x,unsigned char y);//Set the coordinate
|
void LED_Set_Pos(unsigned char x,unsigned char y);//Set the coordinate
|
||||||
|
@ -6,13 +6,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <hmi.h>
|
||||||
#include "stm32f1xx_hal.h"
|
#include "stm32f1xx_hal.h"
|
||||||
#include "switches.h"
|
#include "switches.h"
|
||||||
#include "display.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern tDisplay display;
|
|
||||||
volatile uint32_t lastEvent = 0;
|
volatile uint32_t lastEvent = 0;
|
||||||
|
|
||||||
|
|
||||||
@ -20,17 +19,17 @@ void switch_interrupt() {
|
|||||||
static uint8_t state = 0;
|
static uint8_t state = 0;
|
||||||
uint32_t currentEvent = HAL_GetTick();
|
uint32_t currentEvent = HAL_GetTick();
|
||||||
|
|
||||||
uint16_t line = HAL_GPIO_ReadPin(SWITCH_GPIO_Port, SWITCH_Pin);
|
GPIO_PinState line = HAL_GPIO_ReadPin(SWITCH_GPIO_Port, SWITCH_Pin);
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 0:
|
case 0:
|
||||||
if (line == RESET) {
|
if (line == GPIO_PIN_RESET) {
|
||||||
lastEvent = currentEvent;
|
lastEvent = currentEvent;
|
||||||
state = 1;
|
state = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (line != RESET) {
|
if (line != GPIO_PIN_RESET) {
|
||||||
if (lastEvent + LONG_BUTTON_TIME + DEBOUNCING_DEAD_TIME < currentEvent) {
|
if (lastEvent + LONG_BUTTON_TIME + DEBOUNCING_DEAD_TIME < currentEvent) {
|
||||||
lastEvent = currentEvent;
|
lastEvent = currentEvent;
|
||||||
buttonLong();
|
buttonLong();
|
||||||
@ -50,7 +49,7 @@ void switch_interrupt() {
|
|||||||
int myDigitalRead(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) {
|
int myDigitalRead(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) {
|
||||||
int16_t r = 0;
|
int16_t r = 0;
|
||||||
for (uint32_t i = 0; i < DEBOUNCING_REPEAT; i++) {
|
for (uint32_t i = 0; i < DEBOUNCING_REPEAT; i++) {
|
||||||
if (HAL_GPIO_ReadPin(GPIOx, GPIO_Pin) != RESET) {
|
if (HAL_GPIO_ReadPin(GPIOx, GPIO_Pin) != GPIO_PIN_RESET) {
|
||||||
r++;
|
r++;
|
||||||
} else {
|
} else {
|
||||||
r--;
|
r--;
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
* Author: wn
|
* Author: wn
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <hmi.h>
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "display.h"
|
|
||||||
#include "alarm.h"
|
#include "alarm.h"
|
||||||
|
|
||||||
|
|
||||||
@ -46,3 +46,7 @@ void secondTick(void *handle) {
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void timerInit() {
|
||||||
|
schAdd(secondTick, &display, 0, 1000);
|
||||||
|
}
|
||||||
|
@ -15,6 +15,8 @@ typedef enum {
|
|||||||
OVERRUN = 3
|
OVERRUN = 3
|
||||||
} tTimerState;
|
} tTimerState;
|
||||||
|
|
||||||
|
|
||||||
|
void timerInit();
|
||||||
void secondTick(void *handle);
|
void secondTick(void *handle);
|
||||||
void startTimer();
|
void startTimer();
|
||||||
void stopTimer();
|
void stopTimer();
|
||||||
|
Reference in New Issue
Block a user