feat: prod mode, lcd display and temperature data upload
This commit is contained in:
parent
8edaf36a1a
commit
8894d23d78
44
src/main.c
44
src/main.c
@ -1,7 +1,6 @@
|
||||
#include <8052.h>
|
||||
#include "serial_command.h"
|
||||
|
||||
#include "onewire.h"
|
||||
#include "ds18b20.h"
|
||||
|
||||
typedef unsigned int u16;
|
||||
@ -16,13 +15,14 @@ u16 tim0countAll = 2000;
|
||||
u16 tim0count = 0;
|
||||
u8 tim0flag = 0;
|
||||
|
||||
#define person P1_0
|
||||
#define gasState P1_1
|
||||
#define beep P1_5
|
||||
|
||||
char g_mode = 0x01;
|
||||
char g_bodyMode = 0x00;
|
||||
#define person = P1_0;
|
||||
char g_gasMode = 0x00;
|
||||
#define gasState = P1_1;
|
||||
char FAS_LIGHT_BLINK = 0x50;
|
||||
#define beep = P1_5;
|
||||
|
||||
u8 m_flag = 0;
|
||||
|
||||
@ -45,8 +45,8 @@ u8 LcdSegment[10] = {
|
||||
0x6F
|
||||
};
|
||||
|
||||
#define CLASS_3
|
||||
#define CLASS_4
|
||||
// #define CLASS_3
|
||||
// #define CLASS_4
|
||||
|
||||
void delay(u16 i) {
|
||||
while (i--);
|
||||
@ -55,13 +55,11 @@ void delay(u16 i) {
|
||||
void Uart1Send(u16 sendData) {
|
||||
TI = 0;
|
||||
SBUF = (char) (sendData >> 8);
|
||||
while (TI == 0) {
|
||||
}
|
||||
while (TI == 0);
|
||||
TI = 0;
|
||||
|
||||
SBUF = (char) (sendData & 0xFF);
|
||||
while (TI == 0) {
|
||||
}
|
||||
while (TI == 0);
|
||||
TI = 0;
|
||||
delay(50);
|
||||
}
|
||||
@ -72,24 +70,36 @@ void UsartInit(void) {
|
||||
PCON = 0x80;
|
||||
TH1 = 0xF4;
|
||||
TL1 = 0xF4;
|
||||
TR1 = 1;
|
||||
ES = 1;
|
||||
EA = 1;
|
||||
TR1 = 1;
|
||||
PS = 1;
|
||||
|
||||
TH0 = 0x05;
|
||||
TL0 = 0x05;
|
||||
ET0 = 1;
|
||||
TR0 = 1;
|
||||
}
|
||||
|
||||
void Usart(void) __interrupt(4) {
|
||||
void Usart_ISR(void) __interrupt(4) {
|
||||
cmdCode = SBUF;
|
||||
newCmdFlag = 1;
|
||||
RI = 0;
|
||||
}
|
||||
|
||||
void Timer0_ISR(void) __interrupt(1) {
|
||||
tim0count++;
|
||||
if (tim0count >= tim0countAll) {
|
||||
tim0count = 0;
|
||||
tim0flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessCommand(void) {
|
||||
if (newCmdFlag) {
|
||||
#ifdef CLASS_3
|
||||
u16 recvData;
|
||||
recvData = (cmdCode << 8) + cmdCode;
|
||||
Uart1Send(recvData);
|
||||
u16 recv_data = (cmdCode << 8) + cmdCode;
|
||||
Uart1Send(recv_data);
|
||||
#endif
|
||||
newCmdFlag = 0;
|
||||
switch (cmdCode) {
|
||||
@ -166,7 +176,7 @@ void LcdDisplay(void) {
|
||||
break;
|
||||
}
|
||||
P0 = DisplayData[5 - i];
|
||||
delay(100);
|
||||
delay(200);
|
||||
P0 = 0x00;
|
||||
}
|
||||
}
|
||||
@ -229,11 +239,11 @@ void main(void) {
|
||||
UsartInit();
|
||||
while (1) {
|
||||
ProcessCommand();
|
||||
LcdDisplay();
|
||||
|
||||
#ifdef CLASS_4
|
||||
ProcessTempCmd();
|
||||
LcdDisplay();
|
||||
// Uart1Send(0x1234);
|
||||
#endif
|
||||
|
||||
if (tim0flag) {
|
||||
|
Loading…
Reference in New Issue
Block a user