Programmable Clock with RTOS 0.0.1
Implementaiton of a programmable clock using RTOS with STM32GO microcontroller.
Loading...
Searching...
No Matches
app_display.c File Reference

Implementation of state machine of LCD. More...

#include "bsp.h"
#include "app_display.h"
#include "hel_lcd.h"

Data Structures

struct  DisplayNode
 Struct for store function for each state of event machine. More...
 

Functions

static void Display_Machine (APP_MsgTypeDef *DisplayMsg)
 Initializate the State machine of Display.
 
static Display_M Time (APP_MsgTypeDef *DisplayMsg)
 Display the current time on the LCD.
 
static Display_M Date (APP_MsgTypeDef *DisplayMsg)
 Display the current Date on the LCD.
 
static void TimeString (char *string, uint8_t hours, uint8_t minutes, uint8_t seconds)
 Function to convert time to a string representation.
 
static void DateString (char *string, uint8_t month, uint8_t day, uint16_t year, uint8_t weekday)
 Function to convert date to a string representation.
 
static char * get_month (uint8_t month)
 Get the abbreviation of the month.
 
static Display_M Alarm_A (APP_MsgTypeDef *DisplayMsg)
 Prints the letter A.
 
static Display_M Alarm (APP_MsgTypeDef *DisplayMsg)
 Prints the ALARM!!!
 
static Display_M Alarm_Clean (APP_MsgTypeDef *DisplayMsg)
 Clean Alarm.
 
static void Display_Buzzer (TimerHandle_t pxTimer)
 Function for sotware timer of the buzzer.
 
static void Display_1Mn_Buzzer (TimerHandle_t pxTimer)
 Function for software timer for the 1mn of the alarm.
 
void Display_Init (void)
 Initializate the LCD.
 
void Display_Task (void)
 Display task function.
 

Variables

LCD_HandleTypeDef Hlcd
 Variable for LCD configuration.
 
SPI_HandleTypeDef SpiHandle
 Variable for SPI configuration.
 
static TIM_HandleTypeDef TimHandle
 Strucuture that gives format to timer.
 
uint8_t buzzer_flag = 0
 Flag that will tell if the buzzer needs to be activated.
 
uint8_t buzzer = 0
 Flag that will tell if the buzzer needs to be activated.
 
static TimerHandle_t xTimerBuzzer
 Struct for handling Software timer for the buzzer.
 
static TimerHandle_t xTimer1Mn_Buzzer
 Struct for handling Software timer for 1mn for the buzzer.
 

Detailed Description

Implementation of state machine of LCD.

In this file we are going to see the initialization of the lcd and the application

Function Documentation

◆ Alarm()

static Display_M Alarm ( APP_MsgTypeDef * DisplayMsg)
static

Prints the ALARM!!!

< precompilation direcctive

This function prints ALARM!!! when the alarm has been activated. Furthermore, it indicates that the buzzer must be activated

Parameters
DisplayMsgA pointer to the message structure containing state information
Returns
DISPLAY_2: State for testing and knowing a message have been sent

< precompilation direcctive

< Buzzer state

< Buzzer state

< Brief description

◆ Alarm_A()

static Display_M Alarm_A ( APP_MsgTypeDef * DisplayMsg)
static

Prints the letter A.

< precompilation direcctive

This function prints the letter A when the alarm has been setted

Parameters
DisplayMsgA pointer to the message structure containing state information
Returns
DISPLAY_1: State for testing and knowing a message have been sent

< precompilation direcctive

◆ Alarm_Clean()

static Display_M Alarm_Clean ( APP_MsgTypeDef * DisplayMsg)
static

Clean Alarm.

< precompilation direcctive

This function prints stop and turn off before the one-minute lapse expire by receiving a new date, time, or alarm through the CAN bus

Parameters
DisplayMsgA pointer to the message structure containing state information
Returns
DISPLAY_3: State for testing and knowing a message have been sent

< precompilation direcctive

< Buzzer state

< Buzzer state

< The maximum amount of time

< The maximum amount of time

< Brief description

< The maximum amount of time

◆ Date()

static Display_M Date ( APP_MsgTypeDef * DisplayMsg)
static

Display the current Date on the LCD.

< precompilation direcctive

This function rettrieves the curren date from the Clockmsg structure and formats it as a string in the format 000,00 0000 00

Parameters
DisplayMsgA pointer to the message structure containing state information
Returns
DISPLAY_IDLE_STATE: State for testing, even though it doesnt make the transition of another state it must return to IDLE

< precompilation direcctive

◆ DateString()

static void DateString ( char * string,
uint8_t month,
uint8_t day,
uint16_t year,
uint8_t weekday )
static

Function to convert date to a string representation.

< precompilation direcctive

This function takes time values for year, month, day, weekday and formats them into a string

Parameters
stringPointer to a character buffer to store the formatted date
monthMonth (1-12)
dayDay of the month (1-31)
yearYear
weekdayWeekday(0-6), where 0 is Sunday and 6 is Saturday

< precompilation direcctive

< Position 0: First character of the month

< Position 0: First character of the month

< Position 1: Second character of the month

< Position 1: Second character of the month

< Position 2: First character of the month

< Position 2: First character of the month

< Position 4: Tens digits of the day

< Value for counter: 10

< Value for counter: 10

< Position 5: Ones digits of the day

< Value for counter: 10

< Position 7: Thousands digit of the year

< Value for counter: 1000

< Value for counter: 10

< Position 8: Hundreds digit of the year

< Value for counter: 100

< Value for counter: 10

< Position 9: Tens digit of the year

< Value for counter: 10

< Value for counter: 10

< Position 10: Ones digit of the year

< Value for counter: 10

< Position 12: First character of the week

< Value for counter: 0

< Position 13: Second character of the week

< Value for counter: 1

◆ Display_1Mn_Buzzer()

static void Display_1Mn_Buzzer ( TimerHandle_t pxTimer)
static

Function for software timer for the 1mn of the alarm.

< precompilation direcctive

This function after 1mn the alarm will be desactivated either by the time or by other message

Parameters
pxTimerTimer handler

< precompilation direcctive

< Buzzer state

< The maximum amount of time

< Brief description

◆ Display_Buzzer()

static void Display_Buzzer ( TimerHandle_t pxTimer)
static

Function for sotware timer of the buzzer.

< precompilation direcctive

Parameters
pxTimerTimer handler

This function with the help of the alarm that has been triggered, start to blink the LCD and making blink the buzzer

< precompilation direcctive

< Buzzer state

< Buzzer state

< Buzzer state

< Brief description

< Buzzer state

< Brief description

◆ Display_Init()

void Display_Init ( void )

Initializate the LCD.

This function gives the format of spi and initializate the lcd

< Brief description

< ID for timer used to update display

< The maximum amount of time

< ID for timer used to update display

< The maximum amount of time

◆ Display_Machine()

static void Display_Machine ( APP_MsgTypeDef * DisplayMsg)
static

Initializate the State machine of Display.

This function initializes the state machine for the Display module. It sets up an array of state functions and transitions to the initial state

Parameters
DisplayMsgA pointer to the message structure containing state information

< Total states in event machine

◆ Display_Task()

void Display_Task ( void )

Display task function.

This function checks the queue of pending tasks every 100ms and process them calling the display machine

◆ get_month()

static char * get_month ( uint8_t month)
static

Get the abbreviation of the month.

< precompilation direcctive

This function returns the abbreviation of a month given its number

Parameters
monthMonth number (1-12)
Returns
Pointer to the month abbreviation or NULL if the month number is invalid

< precompilation direcctive

< Value for counter: 1

< Value for counter: 12

< Value for counter: 1

◆ Time()

static Display_M Time ( APP_MsgTypeDef * DisplayMsg)
static

Display the current time on the LCD.

< precompilation direcctive

This function rettrieves the curren time from the Clockmsg structure and formats it as a string in the format 00:00:00

Parameters
DisplayMsgA pointer to the message structure containing state information
Returns
DISPLAY_MSG_TIME: State for testing and knowing a message have been sent

< precompilation direcctive

◆ TimeString()

static void TimeString ( char * string,
uint8_t hours,
uint8_t minutes,
uint8_t seconds )
static

Function to convert time to a string representation.

< precompilation direcctive

This function takes time values for hours, minutes, seconds and formats them into a string

Parameters
stringPointer to a character buffer to store the formatted time
hoursHours in 24-hour format (0-23)
minutesMinutes (0-59)
secondsSeconds (0-59)

< precompilation direcctive

< Position 7: Seconds ones digit

< Value for counter: 10

< Position 6: Seconds tens digit

< Value for counter: 10

< Position 5: Minutes ones digit

< Value for counter: 10

< Position 4: Minutes tens digit

< Value for counter: 10

< Position 3: Hours ones digit

< Value for counter: 10

< Position 1: Hours tens digit

< Value for counter: 10