📄 p_kony_1.c
字号:
/*
A01 protocol
V 1.00 build 2003.05.24 by ssln
*/
#include <REG54.H>
#include <INTRINS.H>
#include "protocol.h"
#include "kernel.h"
#include "config.h"
unsigned char data data3,data4,data5,datax;
unsigned char data pp = 0; // for seq point
unsigned char bdata dir_fg = 0;
sbit r_fg = dir_fg^1;
sbit l_fg = dir_fg^2;
sbit u_fg = dir_fg^3;
sbit d_fg = dir_fg^4;
unsigned char asc2hex(unsigned char asc)
{
return ((asc < 0x3a) ? (asc - 0x30) : (asc - 0x37));
}
void (code *rr)(unsigned char rc);
void word1(unsigned char rc);
void word2(unsigned char rc);
void word3(unsigned char rc);
void words(unsigned char rc);
void words2(unsigned char rc);
void words3(unsigned char rc);
void words4(unsigned char rc);
void words5(unsigned char rc);
void wordp(unsigned char rc);
void wordp2(unsigned char rc);
void wordm(unsigned char rc);
void wordm2(unsigned char rc);
void word1(unsigned char rc) using 1
{
if ((rc == id) || (rc == 0)) rr = word2;
}
void word2(unsigned char rc) using 1
{
if (rc != 0x77)
rr = word1;
else
rr = word3;
}
void word3(unsigned char rc) using 1
{
data3 = rc;
switch (rc)
{
case '1':
case '2':
case '3':
case '4':
dir_fg = 0;
rr = wordm; // for manual control
return;
case '5':
iris_open_fg = 1;
break;
case '6':
iris_close_fg = 1;
break;
case '7':
zoom_wide_fg = 1;
zoom_need_stop = 1;
break;
case '8':
zoom_tele_fg = 1;
zoom_need_stop = 1;
break;
case '9':
focu_far_fg = 1;
focus_need_stop = 1;
break;
case 'A':
focu_near_fg = 1;
focus_need_stop = 1;
break;
case 'B':
power_on_fg = 1;
break;
case 'C':
power_off_fg = 1;
break;
case 'M':
disp_on_fg = 1;
break;
case 'N':
disp_off_fg = 1;
break;
case 'F':
run_swing2_fg = 1;
break;
case 'G':
run_swing2_fg = 0;
break;
case 0x80:
if (_testbit_(zoom_need_stop)) zoom_stop_fg = 1;
if (_testbit_(focus_need_stop)) focu_stop_fg = 1;
seq[12] = 0;
cont_fg = 1;
break;
case 0x59:
case 0x4c:
rr = wordp; // for preset
return;
case 0x5a:
pp = 0;
rr = words; // for seq
return;
}
rr = word1;
}
// for preset
void wordp(unsigned char rc) using 1
{
data4 = asc2hex(rc);
rr = wordp2;
}
void wordp2(unsigned char rc) using 1
{
data5 = asc2hex(rc);
seq[15] = (data4 << 4) | data5;
if (data3 == 0x4c)
call_pre_fg = 1;
else
set_pre_fg = 1;
rr = word1;
}
// for seq
void words(unsigned char rc) using 1
{
data4 = asc2hex(rc);
rr = words2;
}
void words2(unsigned char rc) using 1
{
data5 = asc2hex(rc);
seq[pp] = (data4 *10) + data5;
if ((seq[pp] == 0) || (pp >= 48))
{
run_seq_fg = 1;
seq[48] = 1;
rr = word1;
}
else
{
pp ++;
rr = words3;
}
}
void words3(unsigned char rc) using 1
{
seq[pp] = asc2hex(rc);
if ((seq[pp] == 0) || (pp >= 48))
{
run_seq_fg = 1;
seq[48] = 1;
rr = word1;
}
else
{
pp ++;
rr = words4;
}
}
void words4(unsigned char rc) using 1
{
data4 = asc2hex(rc);
rr = words5;
}
void words5(unsigned char rc) using 1
{
data5 = asc2hex(rc);
seq[pp] = (data4 *10) + data5;
if ((seq[pp] == 0) || (pp >= 48))
{
run_seq_fg = 1;
seq[48] = 1;
rr = word1;
}
else
{
pp ++;
rr = words;
}
}
// for manual control
void wordm(unsigned char rc) using 1
{
data4 = rc;
if (data4 > 0x4a)
{
r_fg = 1; // right
data4 -= 0x4a;
}
else if (data4 > 0x0a)
{
l_fg = 1; // left
data4 -= 0x0a;
}
else
data4 = 0;
data4 <<= 3;
rr = wordm2;
}
void wordm2(unsigned char rc) using 1
{
rr = word1;
data5 = rc;
if (data5 > 0x8a)
{
d_fg = 1; // down
data5 -= 0x8a;
}
else if (data5 > 0x0a)
{
u_fg = 1; // up
data5 -= 0x0a;
}
else
data5 = 0;
data5 <<= 3;
run_swing_fg = 0;
run_swing2_fg = 0;
run_seq_fg = 0;
cont_fg = 1;
seq[13] = data4;
seq[14] = data5;
seq[12] = dir_fg;
}
/* 返回值为1则不当做预置点功能,返回值为0则是预置点功能 */
/* 用设置预置点的方法来实现附加功能*/
extern bit do_set_addon(unsigned char no)
{
no = no;
return 0;
}
/* 用调用预置点的方法来实现附加功能*/
extern bit do_call_addon(unsigned char no)
{
no = no;
return 0;
}
extern void init_serial(void)
{
PCON = 0x00;SCON = 0xd0;
#ifdef FOCS_40M
TH2 = 0xfe; RCAP2H = 0xfe;
TL2 = 0xfc; RCAP2L = 0xfc;
#else // for 22.1184
TH2 = 0xff; RCAP2H = 0xff;
TL2 = 0x70; RCAP2L = 0x70;
#endif
T2CON = 0x34;
rr = word1;
}
void serial_int(void) interrupt 4 using 1
{
ES = 0;
if (_testbit_(RI)) (*rr)(SBUF);
ES = 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -