Skip to content
Snippets Groups Projects
Commit 07bb0c2b authored by Flax's avatar Flax
Browse files

STM32L011K4 : Updated display module with value to digits conversion.

parent 29807205
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,35 @@
#ifndef INC_DISPLAY_H_
#define INC_DISPLAY_H_
#include "stdbool.h"
#include "stdint.h"
typedef enum {
DISP_CHAR_7SEG_0 = 0,
DISP_CHAR_7SEG_1,
DISP_CHAR_7SEG_2,
DISP_CHAR_7SEG_3,
DISP_CHAR_7SEG_4,
DISP_CHAR_7SEG_5,
DISP_CHAR_7SEG_6,
DISP_CHAR_7SEG_7,
DISP_CHAR_7SEG_8,
DISP_CHAR_7SEG_9,
DISP_CHAR_7SEG_E,
DISP_CHAR_7SEG_R,
DISP_CHAR_7SEG_S,
DISP_CHAR_7SEG_P,
DISP_CHAR_7SEG_T,
DISP_CHAR_7SEG_O,
DISP_CHAR_7SEG_F,
DISP_CHAR_7SEG_MAX
}e_DISPChar7SegType;
extern void DISPInit (void);
extern void DISPStart (void);
extern void DISPStop (void);
extern bool DISPSetDisplayDigit (uint8_t digit_u8, char digit_value_u8);
extern bool DISPValueToDigits (uint16_t value_u16, uint8_t* digits_U8A[]);
#endif /* INC_DISPLAY_H_ */
......@@ -23,6 +23,7 @@ typedef enum {
HMI_EVENT_INPUT_MOVE_LEFT,
HMI_EVENT_INPUT_CLIC_SHORT,
HMI_EVENT_INPUT_CLIC_LONG,
HMI_EVENT_INPUT_MAX
}e_HMIInputEventType;
// ================
......
......@@ -12,6 +12,7 @@
// Shared includes
// ===============
#include "stdbool.h"
#include "stdint.h"
// ================
// Shared constants
......@@ -36,4 +37,7 @@ extern void REGStandbyReset(void);
extern void REGOffSet(void);
extern void REGOffReset(void);
extern bool REGSPTSet (uint16_t temp_spt_u16);
extern uint16_t REGSPTGet (void);
#endif /* INC_TEMPERATUREREGULATION_H_ */
......@@ -5,4 +5,110 @@
* Author: Flax
*/
// ==============
// Local includes
// ==============
#include "display.h"
// ===============
// Local constants
// ===============
#define cDISPMaxDigit (3U)
#define cDISPValueMax (999U)
// Division-less decade separation : https://www.baghli.com/hex2dec.php
#define cDISPDecadeSeparation100Num ((uint32_t)5243) // m
#define cDISPDecadeSeparation100Denom ((uint32_t)65536*8) // 2^s * 2^W
#define cDISPDecadeSeparation10Num ((uint32_t)52429) // m
#define cDISPDecadeSeparation10Denom ((uint32_t)65536*8) // 2^s * 2^W
// ===============
// Local variables
// ===============
// ===========================
// Local functions prototypes
// ===========================
// ===========================
// Local functions definitions
// ===========================
// ============================
// Shared functions definitions
// ============================
void DISPInit (void)
{
}
void DISPStart (void)
{
}
void DISPStop (void)
{
}
bool DISPSetDisplayDigit (uint8_t digit_u8, char digit_value_u8)
{
bool ret_B = false;
if (digit_u8 < (uint8_t)cDISPMaxDigit)
{
ret_B = true;
}
return (ret_B);
}
char DISPNumberToChar (uint8_t number_u8)
{
char ret_C;
return ret_C;
}
bool DISPValueToDigits (uint16_t value_u16, uint8_t* digits_U8A[])
{
bool ret_B = false;
uint16_t value_local_u16;
// Division-less decade separation : https://www.baghli.com/hex2dec.php
if (value_u16 <= cDISPValueMax)
{
ret_B = true;
value_local_u16 = value_u16;
// Check for 1st digit
if (value_local_u16 > 99U)
{
// Divide by 100
digits_U8A[0U] = (uint8_t)((cDISPDecadeSeparation100Num * (uint32_t)value_local_u16) / cDISPDecadeSeparation100Denom);
value_local_u16 = value_local_u16 - ((uint16_t)(digits_U8A[0U]) * 100U); // Remove 1st digit
}
else
{
digits_U8A[0U] = 0U;
}
// Check for 2nd digit
if (value_local_u16 > 9U)
{
// Divide by 10
digits_U8A[1U] = (uint8_t)((cDISPDecadeSeparation10Num * (uint32_t)value_local_u16) / cDISPDecadeSeparation10Denom);
value_local_u16 = value_local_u16 - ((uint16_t)(digits_U8A[1U]) * 10U); // Remove 2nd digit
}
else
{
digits_U8A[1U] = 0U;
}
// Check for 3nd digit
digits_U8A[2U] = (uint8_t)value_local_u16;
}
return ret_B;
}
......@@ -31,6 +31,7 @@ typedef enum {
HMI_DISPLAY_MODE_PARAM_TEMP_STBY,
HMI_DISPLAY_MODE_PARAM_GAIN_TITLE,
HMI_DISPLAY_MODE_PARAM_GAIN,
HMI_DISPLAY_MODE_MAX
}e_HMIDisplayModeType;
// ===============
......
......@@ -15,6 +15,8 @@
// ===============
// Local constants
// ===============
#define cREGTempSPTMax (400U)
#define cREGTempSPTMin (50U)
// ===============
// Local variables
......@@ -23,6 +25,8 @@ bool RegOffState_B;
bool RegStandbyState_B;
bool RegErrorState_B;
uint16_t RegTempSPT;
// ==========================
// Local functions prototypes
// ==========================
......@@ -98,3 +102,19 @@ void REGOffReset(void)
{
RegOffState_B = false;
}
bool REGSPTSet (uint16_t temp_spt_u16)
{
bool ret_B = false;
if ((temp_spt_u16 <= (uint16_t)cREGTempSPTMax) && (temp_spt_u16 >= (uint16_t)cREGTempSPTMin))
{
RegTempSPT = temp_spt_u16;
ret_B = true;
}
return (ret_B);
}
uint16_t REGSPTGet (void)
{
return RegTempSPT;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment