📄 microvfd.c
字号:
if (ObjectKey.FireKey != NO_KEY) {
if (ObjectKey.FireKey == 10) {
ObjectKey.Digit10Key += 10;
#ifndef MASTER /* for VCD slave & stand alone vcd */
ObjectKey.Digit10Key = preprocess_digit_key(ObjectKey.Digit10Key,
&ignore_key,1);
#else /* for VCD and DVD master */
put_keycode(ObjectKey.Digit10Key | 0xf000);
#endif
ObjectKey.FireKey = NO_KEY;
} else if (ObjectKey.FireKey <= 10) {
ObjectKey.Digit10Key += ObjectKey.FireKey;
#ifndef MASTER /* for VCD slave & VCD */
ObjectKey.Digit10Key = preprocess_digit_key(ObjectKey.Digit10Key,
&ignore_key,0);
#else
ignore_key = 0;
#endif
if (!ignore_key)
put_keycode(ObjectKey.Digit10Key);
ObjectKey.Digit10Key = 0;
#ifdef DVD_VCD /* for VCD master and VCD slave */
ObjectKey.FireKey = NO_KEY;
#endif
} else {
key = ObjectKey.FireKey | 0xff00;
put_keycode(key); /* function key */
ObjectKey.FireKey = NO_KEY;
#ifndef MASTER /* for VCD slave and standalone vcd */
preprocess_function_key(key);
#endif
#ifdef IR_PHILIPS
key = NO_KEY; /* starts at 0xffxx.*/
#endif /* IR_PHILIPS */
ObjectKey.Digit10Key = 0;
}
}
}
/*===========================================================================*/
/*
* Output 2 7-segment digits.
*
* Inputs:
* lowaddr: ANODE location for low digit
* highaddr: ANODE location for high digit
* data: BCD data to write
* maskFlag: 1 - Show blank when the high digit is 0
* 0 - Show '0' when the high digit is 0
*/
PRIVATE void VFD_process7Segments(lowaddr, highaddr, data, maskFlag)
int lowaddr, highaddr;
unsigned char data;
int maskFlag;
{
int i;
char *ramByte;
unsigned char * digit_tbl = T_VFD_digit_tbl;
/* update the lower digit. */
ramByte = ShadowRam + lowaddr;
#ifdef FU_A300
*ramByte &= 0x01; /* Clean only 7 segments */
#else
*ramByte &= 0x80;
#endif
*ramByte |= digit_tbl[data & 0xf]; /* Data is BCD */
/* update the upper digit. */
ramByte = ShadowRam + highaddr;
#ifdef FU_A300
if(highaddr == TRACK_HIGH) {
*ramByte &= 0x00;
} else {
*ramByte &= 0x01;
}
#else
if(highaddr == TRACK_HIGH) {
*ramByte &= 0x00;
} else {
*ramByte &= 0x80;
}
#endif
data >>= 4;
/* If we don't want to mask off 0, or the digit is not 0, then
output the digit. */
if (!maskFlag || data)
*ramByte |= digit_tbl[data];
/* update the output stack. */
VFD_push(lowaddr);
VFD_push(highaddr);
}
/*===========================================================================*/
PRIVATE void VFD_processIndicator(int type, char indicator)
{
int i, j, index;
unsigned short * lkTbl = T_VFD_indicator_tbl + type * 8;
unsigned char tmp;
j = indicator;
for (index = 0; index < 8; index++) {
/* get the shadowram index which is in the higher byte*/
i = (*(lkTbl + index) >> 8) & 0xff;
/* Assign the value which is in the lower byte to ShadowRam */
tmp = *(lkTbl + index);
ShadowRam[i] &= ~tmp;
if (j & 1) ShadowRam[i] |= tmp;
VFD_push(i);
j >>= 1;
}
}
/*===========================================================================*/
PRIVATE void VFD_processMessage(int msgCode)
{
PRIVATE unsigned char VFD_ttmmss[] = {
TRACK_HIGH, TRACK_LOW, MINUTE_HIGH, MINUTE_LOW, SECOND_HIGH, SECOND_LOW
};
char *ramByte;
char *message;
int i, j;
/* set the message data pointer */
message = T_VFD_msg_tbl + msgCode * 6;
for (i = 0; i < 6;i++) {
j = VFD_ttmmss[i];
ramByte = ShadowRam + j;
*ramByte &= 0x80;
*ramByte |= *message++;
VFD_push(j);
}
}
/*===========================================================================*/
PRIVATE void VFD_processBlank(int inst)
{
int i;
if (inst == BLANK_TRACK) {
#ifdef FU_A300
ShadowRam[TRACK_LOW] &= 0x00;
ShadowRam[TRACK_HIGH] &= 0x01;
#else
ShadowRam[TRACK_LOW] &= 0x00;
ShadowRam[TRACK_HIGH] &= 0x80;
#endif
VFD_push(TRACK_LOW);
VFD_push(TRACK_HIGH);
}
#if (CUST71 || CUST71A)
else if (inst == BLANK_MIN) {
ShadowRam[MINUTE_LOW] &= 0x80;
ShadowRam[MINUTE_HIGH] &= 0x80;
VFD_push(MINUTE_LOW);
VFD_push(MINUTE_HIGH);
} else if (inst == BLANK_SEC) {
ShadowRam[SECOND_LOW] &= 0x80;
ShadowRam[SECOND_HIGH] &= 0x80;
VFD_push(SECOND_LOW);
VFD_push(SECOND_HIGH);
}
#endif
else if (inst == BLANK_ALL) {
for (i = 0; i < SHADOW_LENGTH;i++) {
ShadowRam[i] = 0;
VFD_push(i);
}
}
}
/*===========================================================================*/
/*
* Complement the calendar icon associated with FlashingCalendar.
*/
void flashCalendar()
{
unsigned char *dptr; /* Pointer to associated ShadowRam */
unsigned int offset; /* Offset to ShadowRam array */
unsigned short icon; /* Data read from T_VFD_calendar_tbl */
/*
* calendar_tbl is in xxxxyzzzzzzzz format where z is 1 hot while
* xxxxy give the "ShadowRam" index.
*/
icon = T_VFD_calendar_tbl[FlashingCalendar];
offset = icon >> 8;
dptr = ShadowRam + offset;
*dptr ^= (icon & 0xff); /* Complement the icon */
VFD_push(offset);
}
/*
* Lite those calendar icons associated with track_list. Only
* track_list items between [start_index, end_index) are included.
*
* If start_index > end_index, then we'll clean all calendar numbers.
*/
void VFD_update_calendar(int start_index, int end_index)
{
int i, track;
unsigned char *dptr; /* Pointer to associated ShadowRam */
unsigned short icon;
EnableFlashing = 0;
/*
* calendar_tbl is in xxxxyzzzzzzzz format where z is 1 hot while
* xxxxy give the "ShadowRam" index.
*/
/* Clear up all the calendar icons */
for (i = 0; i <= MAX_CALENDAR; i++) {
icon = T_VFD_calendar_tbl[i];
dptr = ShadowRam + (icon >> 8);
*dptr &= ~(icon & 0xff);
}
/* Lite up ones that we are interested in */
for (i = start_index; i < end_index; i++) {
track = track_list[i];
if (track <= MAX_CALENDAR) {
icon = T_VFD_calendar_tbl[track];
dptr = ShadowRam + (icon >> 8);
*dptr |= (icon & 0xff);
}
}
/*
* This is a hack right now. Futaba's calendar is at G1 while
* VFD28-0901 is at G1 and G2. Need to clean up.
*/
#ifdef VFD_FUTABA
#ifdef FU_A300
#ifndef CHANGE_271
#ifdef CHANGE_265
VFD_push(0);
VFD_push(1);
#else
VFD_push(11);
VFD_push(10);
#endif
#else
VFD_push(0);
VFD_push(1);
#endif
#else
VFD_push(0);
VFD_push(1);
#endif
#else
for (i = 0; i < 4; i++) VFD_push(i);
#endif
}
/*= add command packet to ring ==============================================*/
int addMicroRing(int instruction)
{
static int UpdateCalendar;
int inst,tmp, a, b, c;
inst = instruction & 0xff;
tmp = instruction & 0x0ff00;
#if defined(DVD_VCD) && defined(SLAVE) /* vcd slave send vfd to vcd master*/
tell_dsa_vfd(instruction);
return 1;
#endif
if (tmp < PANEL_BLANK) {
if (tmp == PANEL_MIN)
VFD_process7Segments(MINUTE_LOW, MINUTE_HIGH, inst, 0);
else if(tmp == PANEL_SEC)
VFD_process7Segments(SECOND_LOW, SECOND_HIGH, inst, 0);
else if (tmp == PANEL_TRACK) {
inst = hex2bcd[inst];
VFD_process7Segments(TRACK_LOW, TRACK_HIGH, inst, 1);
} else {
a = (tmp >> 8) - 0x1b;
VFD_processIndicator(a,(char)inst);
}
} else {
if (tmp == PANEL_BLANK) {
EnableFlashing = 0;
VFD_processBlank(inst);
} else if (tmp == SHOW_MSG)
VFD_processMessage(inst);
else if (tmp == FLASH_CAL) {
EnableFlashing = 1;
FlashingCalendar = inst;
}
}
return 0; /* no one use this return value */
}
/*===========================================================================*/
int ReceivedByte = 0;
#ifdef D16312
/************************************************************************
********************** State machine for 16312 *************************
************************************************************************/
PRIVATE void VFD_state_init()
{
VFD_strobeSendByte(VFD_MODE);
VFD_strobeSendByte(VFD_DUTY_CYCLE);
VFD_strobeSendByte(VFD_ADDRESS_INC);
CLEAR_VFD_STROBE;
VFD_objectSendByte(VFD_ADDRESS_MASK | 0x00);
DataLength = SHADOW_LENGTH;
while (--DataLength)
VFD_objectSendByte(0x00);
SET_VFD_STROBE;
VFD_next_state = VFD_state_scan_key_0;
}
PRIVATE void VFD_state_scan_key_0()
{
CLEAR_VFD_STROBE;
#ifdef VFD_EXPEND
Data_LED = KEY_LED;
DataLength = KEY_LENGTH - 4;
#else
DataLength = KEY_LENGTH;
#endif
VFD_objectSendByte(VFD_READ_KEY);
VFD_next_state = VFD_state_scan_key_1;
}
PRIVATE void VFD_state_scan_key_1()
{
VFD_objectReadByte();
VFD_next_state = VFD_state_scan_key_2;
}
PRIVATE void VFD_state_scan_key_2()
{
#ifdef VFD_EXPEND
ObjectKey.KeyBuffer[KEY_LENGTH - 4 - DataLength] = ReceivedByte;
#else
ObjectKey.KeyBuffer[KEY_LENGTH - DataLength] = ReceivedByte;
#endif
if (--DataLength)
VFD_state_scan_key_1();
else {
SET_VFD_STROBE;
#ifdef VFD_EXPEND
VFD_next_state = VFD_state_scan_keys_0;
#else
#ifdef VFD_LED
VFD_next_state = VFD_state_write_led_0;
#else
VFD_state_scan_key_3();
#endif
#endif
}
}
#ifdef VFD_LED
PRIVATE void VFD_state_write_led_0()
{
VFD_STROBE_ACTIVE;
VFD_objectSendByte(VFD_WRITE_LED);
VFD_next_state = VFD_state_write_led_1;
}
PRIVATE void VFD_state_write_led_1()
{
VFD_objectSendByte(vfdled);
VFD_STROBE_INACTIVE;
VFD_next_state = VFD_state_read_sw_0;
}
PRIVATE void VFD_state_read_sw_0()
{
VFD_STROBE_ACTIVE;
VFD_objectSendByte(VFD_READ_SW);
VFD_next_state = VFD_state_read_sw_1;
}
PRIVATE void VFD_state_read_sw_1()
{
VFD_objectReadByte();
vfdsw = ReceivedByte;
VFD_STROBE_INACTIVE;
VFD_next_state = VFD_state_scan_key_3;
}
#endif
#ifdef VFD_EXPEND
PRIVATE void VFD_state_scan_keys_0()
{
CLEAR_VFD_STROBE;
VFD_objectSendByte(VFD_WRITE_LED);
VFD_next_state = VFD_state_scan_keys_1;
}
PRIVATE void VFD_state_scan_keys_1()
{
VFD_objectSendByte(WRITE_LED[4 - Data_LED]);
SET_VFD_STROBE;
VFD_next_state = VFD_state_scan_keys_2;
}
PRIVATE void VFD_state_scan_keys_2()
{
CLEAR_VFD_STROBE;
VFD_objectSendByte(VFD_READ_SW);
VFD_next_state = VFD_state_scan_keys_3;
}
PRIVATE void VFD_state_scan_keys_3()
{
VFD_objectReadByte();
VFD_next_state = VFD_state_scan_keys_4;
}
PRIVATE void VFD_state_scan_keys_4()
{
DataLED=~ReceivedByte;
ObjectKey.KeyBuffer[KEY_LENGTH - Data_LED] = DataLED & 0x0f;
if (--Data_LED)
{
SET_VFD_STROBE;
VFD_next_state = VFD_state_scan_keys_0;
}
else {
SET_VFD_STROBE;
VFD_state_scan_key_3();
}
}
#endif
PRIVATE void VFD_state_scan_key_3()
{
VFD_searchKey();
VFD_next_state = VFD_state_scan_key_4;
}
PRIVATE void VFD_state_scan_key_4()
{
#if 0
unsigned char tmpKey;
if (REMOTE_VALID) {
char * key_tbl =(char *) T_IR_key_tbl;
CLEAR_REMOTE;
if (REMOTE_KEY > 0x20)
tmpKey = key_tbl[REMOTE_KEY - 0x20];
else
tmpKey = key_tbl[REMOTE_KEY];
if (ObjectKey.FireKey != tmpKey) {
ObjectKey.FireKey = tmpKey;
VFD_parseKey();
}
}
else
#endif
VFD_parseKey();
VFD_next_state = VFD_state_refresh_0;
}
PRIVATE void VFD_state_refresh_0()
{
if (!VFDptr)
VFD_state_refresh_5();
else {
VFD_strobeSendByte(VFD_MODE);
VFD_next_state = VFD_state_refresh_1;
}
}
PRIVATE void VFD_state_refresh_1()
{
VFD_strobeSendByte(VFD_DUTY_CYCLE);
VFD_next_state = VFD_state_refresh_2;
}
PRIVATE void VFD_state_refresh_2()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -