You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
230 lines
7.6 KiB
230 lines
7.6 KiB
#include "segment.h"
|
|
#include "segment_74hc595d.h"
|
|
#include "rtc_process.h"
|
|
|
|
const uint8_t SegmentData[SEG_INDEX_MAX] =
|
|
{
|
|
0x3F, //SEGMENT_0
|
|
0x06, //SEGMENT_1
|
|
0x5B, //SEGMENT_2
|
|
0x4F, //SEGMENT_3
|
|
0x66, //SEGMENT_4
|
|
0x6D, //SEGMENT_5
|
|
0x7D, //SEGMENT_6
|
|
0x07, //SEGMENT_7
|
|
0x7F, //SEGMENT_8
|
|
0x67, //SEGMENT_9
|
|
0x00, //SEGMENT_CLEAR
|
|
0x5F, //SEGMENT_A,
|
|
0x7C, //SEGMENT_B,
|
|
0x58, //SEGMENT_C,
|
|
0x5E, //SEGMENT_D,
|
|
0x79, //SEGMENT_E,
|
|
0x71, //SEGMENT_F,
|
|
0x3D, //SEGMENT_G,
|
|
0x74, //SEGMENT_H,
|
|
0x11, //SEGMENT_I,
|
|
0x0D, //SEGMENT_J,
|
|
0x75, //SEGMENT_K,
|
|
0x38, //SEGMENT_L,
|
|
0x55, //SEGMENT_M,
|
|
0x54, //SEGMENT_N,
|
|
0x5C, //SEGMENT_O,
|
|
0x73, //SEGMENT_P,
|
|
0x67, //SEGMENT_Q,
|
|
0x50, //SEGMENT_R,
|
|
0x2D, //SEGMENT_S,
|
|
0x78, //SEGMENT_T,
|
|
0x1C, //SEGMENT_U,
|
|
0x2A, //SEGMENT_V,
|
|
0x6A, //SEGMENT_W,
|
|
0x14, //SEGMENT_X,
|
|
0x6E, //SEGMENT_Y,
|
|
0x1B, //SEGMENT_Z,
|
|
0x40, //SEGMENT_MINUS
|
|
};
|
|
|
|
|
|
uint8_t Segment_OutputBuff[SEGMENT_SELECT_MAX_INDEX][SEGMENT_MAX_DATA_INDEX];
|
|
|
|
void Segment_Sensor_Error(void)
|
|
{
|
|
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_MINUS];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[SEG_MINUS];
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[SEG_MINUS];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[SEG_MINUS];
|
|
}
|
|
|
|
|
|
|
|
void Segment_All_Set_Data(uint8_t SegmentData)
|
|
{
|
|
uint8_t i;
|
|
for(i = SEGMENT_COM1 ; i < SEGMENT_SELECT_MAX_INDEX ; i++)
|
|
{
|
|
Segment_OutputBuff[i][SEGMENT_F1] = SegmentData;
|
|
Segment_OutputBuff[i][SEGMENT_F2] = SegmentData;
|
|
}
|
|
}
|
|
|
|
void Segment_Show_Version(void)
|
|
{
|
|
uint8_t temp;
|
|
Segment_All_Set_Data(0x00);
|
|
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F1] = SegmentData[SEG_V];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F1] = SegmentData[SEG_E];
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F1] = SegmentData[SEG_R];
|
|
|
|
|
|
temp = VERSION_MAJOR;
|
|
if(temp >= 99)
|
|
{
|
|
temp = 99;
|
|
}
|
|
if(VERSION_MAJOR < 10)
|
|
{
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_CLEAR];
|
|
}
|
|
else
|
|
{
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[temp/10];
|
|
}
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[temp%10] | 0x80;
|
|
|
|
temp = VERSION_MINOR;
|
|
if(temp >= 99)
|
|
{
|
|
temp = 99;
|
|
}
|
|
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[temp/10];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[temp%10];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Segment_Show_Time(void)
|
|
{
|
|
uint32_t colon_on = millis() % 1000;;
|
|
RTC_TIME rtc_time = RTC_Get_Time();
|
|
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F1] = SegmentData[rtc_time.rtc_Hour/10];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F1] = SegmentData[rtc_time.rtc_Hour%10];
|
|
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F1] = SegmentData[rtc_time.rtc_Min/10];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F1] = SegmentData[rtc_time.rtc_Min%10];
|
|
|
|
if(colon_on > 500)
|
|
{
|
|
Segment_OutputBuff[SEGMENT_EXT][SEGMENT_F1] = 0x02;
|
|
}
|
|
else
|
|
{
|
|
Segment_OutputBuff[SEGMENT_EXT][SEGMENT_F1] = SegmentData[SEG_CLEAR];
|
|
}
|
|
}
|
|
|
|
void Segment_Show_SensorData(uint32_t SensorData)
|
|
{
|
|
if(SensorData == 0xFFFF)
|
|
{
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_MINUS];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[SEG_MINUS];
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[SEG_MINUS];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[SEG_MINUS];
|
|
return;
|
|
}
|
|
|
|
if(SensorData >= 9999)
|
|
{
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_9];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[SEG_9];
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[SEG_9];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[SEG_9];
|
|
}
|
|
else if(SensorData >= 1000)
|
|
{
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SensorData/1000];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[(SensorData%1000)/100];
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[(SensorData%100)/10];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[(SensorData%10)];
|
|
}
|
|
else if(SensorData >= 100)
|
|
{
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_CLEAR];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[(SensorData%1000)/100];
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[(SensorData%100)/10];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[(SensorData%10)];
|
|
}
|
|
else if(SensorData >= 10)
|
|
{
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_CLEAR];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[SEG_CLEAR];
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[(SensorData%100)/10];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[(SensorData%10)];
|
|
}
|
|
else
|
|
{
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_CLEAR];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[SEG_CLEAR];
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[SEG_CLEAR];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[(SensorData%10)];
|
|
}
|
|
}
|
|
|
|
|
|
void Segment_Show_SettingData(SET_INDEX index, uint16_t SensorSetData)
|
|
{
|
|
uint32_t segment_toggle = millis() % (SEGMENT_TOGGLE_TIME *2);;
|
|
|
|
uint8_t temp_1000 = SensorSetData / 1000;
|
|
uint8_t temp_100 = (SensorSetData / 100) % 10;
|
|
uint8_t temp_10 = (SensorSetData / 10) % 10;
|
|
uint8_t temp_1 = SensorSetData % 10;
|
|
|
|
if(segment_toggle >= SEGMENT_TOGGLE_TIME)
|
|
{
|
|
switch (index)
|
|
{
|
|
case SET_1000:
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[SEG_CLEAR];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[temp_100];
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[temp_10];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[temp_1];
|
|
break;
|
|
case SET_100:
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[temp_1000];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[SEG_CLEAR];
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[temp_10];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[temp_1];
|
|
break;
|
|
case SET_10:
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[temp_1000];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[temp_100];
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[SEG_CLEAR];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[temp_1];
|
|
break;
|
|
case SET_1:
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[temp_1000];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[temp_100];
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[temp_10];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[SEG_CLEAR];
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Segment_OutputBuff[SEGMENT_1000][SEGMENT_F2] = SegmentData[temp_1000];
|
|
Segment_OutputBuff[SEGMENT_100][SEGMENT_F2] = SegmentData[temp_100];
|
|
Segment_OutputBuff[SEGMENT_10][SEGMENT_F2] = SegmentData[temp_10];
|
|
Segment_OutputBuff[SEGMENT_1][SEGMENT_F2] = SegmentData[temp_1];
|
|
}
|
|
}
|
|
|
|
|