Skip to content

Instantly share code, notes, and snippets.

@bwywb00
Created November 5, 2019 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwywb00/e8991d94e268c02add3b987741eb8f95 to your computer and use it in GitHub Desktop.
Save bwywb00/e8991d94e268c02add3b987741eb8f95 to your computer and use it in GitHub Desktop.
/*
* Oven1.c
*
* Created on: Nov 5, 2019
* Author: sung
*/
#include "Oven1.h"
static ovenInterface this;
static void Excute(void);
static void TimerHandler(void);
static void Button1Handler(void);
static void ResetOven(void);
static void RunOven(void);
static void StopOven(void);
ovenInterface* usingOven1(void)
{
return &this;
}
void InitOven1(void)
{
ResetOven();
this.Excute = Excute;
this.TimerHandler = TimerHandler;
this.Button1Handler = Button1Handler;
this.ResetOven = ResetOven;
this.RunOven = RunOven;
this.StopOven = StopOven;
}
static void Excute(void)
{
if(this.ovenRunState == RUN_OVEN)
{
if(this.ovenRotateState == LEFT)
{
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);
}
else
{
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
}
}
else
{
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
}
}
static void TimerHandler(void)
{
if(this.ovenTimerState == STOP_TIMER)
{
this.ovenTimer = HAL_GetTick();
this.ovenTimerState = RUN_TIMER;
}
else
{
if(HAL_GetTick() - this.ovenTimer> this.ovenTimerLimit)
{
this.ovenRotateState = (this.ovenRotateState +1)%2;
this.ovenTimerState = STOP_TIMER;
}
}
}
static void Button1Handler(void)
{
//OvenChange
}
static void ResetOven(void)
{
this.ovenRunState = STOP_OVEN;
this.ovenRotateState = LEFT;
this.ovenTimer = 0;
}
static void RunOven(void)
{
this.ovenRunState = RUN_OVEN;
}
static void StopOven(void)
{
this.ovenRunState = STOP_OVEN;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment