📄 wio.c
字号:
/*
File: WIO.C
Version: Ver2.97
Author: Zhang Jun
Date: 2005.3.29
Last Edit: 2007.2.26
Function:
DspOn
DispClr
InitPws
SetLine
KbdInit
CloseKbd
KbdRead
KbdHit
printX
CrsrMake
CrsrPut
Delay
Beep
nBeepSet
SBar_Open
SBar_Close
BackLite
DateGet
TimeGet
DateSet
TimeSet
ReverseLine
CrsrInit
CloseCrsr
PowerDsp
EnterInteger
BeepInit
CloseBeep
ADInit
OpenEng
CloseEng
LockKbd
LockBar
LockDis
BLiteAllow
BliteLimit
ResetTimer
SleepSet
BackLightSet
SleepInit
CloseSleep
PowerSet
wake
cf_state
CFcardInit
PtnInit
PowerInit
Power
*Ver_Wio()
*/
#include <windows.h>
#include "wio.h"
#include "barcode.h"
#define VERWIO "3.00"
#define wchar unsigned short
#define dim(x) (sizeof(x)/sizeof(x[0]))
#pragma data_seg("shared")
HANDLE g_hPms; //the Handle of "PMS1"
HANDLE g_hKey; //the Handle of "KEY1"
HANDLE hDspIns; //the Handle of "DSP1"
HANDLE hSThread = NULL; //the Handle of automatic sleep
CRITICAL_SECTION LinSection;//the CriticalSection of Lines
CRITICAL_SECTION rSection; //the CriticalSection of ReverseDsp
CRITICAL_SECTION slSection; //the CriticalSection of SleepTime
int iDsp[8][192] = {'\0'};
int g_LiteStatus = 0;
int g_time = 0; //set the sleeptime
int g_bltime = 0; //set the backlitetime
//int cf_flg = 1; //the Flag of CF Card(1:cf card ok 0:cf card error)
//int wake_flg = 1;
//int g_cfstate = 1;
//<==2007.2.25
//int SleepTime = 0;
//int backliteflg = 0;
//int BackLightTime = 0;
//<==2007.2.25
//initialize the beep
int beep_flg = 0; //the Flag of Beep(1 => 5)
int beep_retimes[5] = {1,1,1,3,4}; //The number of repetitions
int beep_horl[5] = {1,1,1,1,1}; //high or low Beep(1 or 0)
int beep_time[5] = {5,7,1,5,4}; //the time of Beep
int beep_spacetime[5] = {10,10,10,200,400};//The interval of time between two beeps
#pragma data_seg()
#pragma comment(linker,"/SECTION:shared,RWS")
HANDLE hMutex;
HANDLE BeepThread;
HANDLE hPower; //the Handle of "PTN2"
//HANDLE hCfCard; //the Handle of CF Card check
//HANDLE hEvent; //CF Card Event
HANDLE hPchk; //the Handle of "PCK1"
//HANDLE hCf; //the Handle of "CFT1"
//HANDLE hBar; //the Handle of "BAR1"
//HANDLE hPtn; //the Handle of power button check
int iDspLine; // Lines of the Window
int iDspLine1;
int SleepTime;
int backliteflg;
int BackLightTime;
//int spe_flg = 0;
int g_lines; //Number of lines to display
int g_twoflg; // 1: two lines, 0: other
int g_initbuf = 0;
int g_bpflg = 0;
//int sbar_flg = 0; //the flag of bar
int g_engflg = 0; //the flag of input English
int g_iPowerDsp; //record the display info of power
int g_iPowerFlag = 0; //the flag of first run Power Check
int g_iPowerTime = 0; //record the times of low power
int temp[1000];
wchar Buffer[4][30];
int read_cf();
//==================================================
struct _Cursor
{
int CurPos; // the absolute pos of cursor;
int CurStatus; // 0 off, 1 on
int x;
int y;
HANDLE hCThread;
}Cursor;
//==================================================
/* -------------------------------- */
/* Function: */
/* DspOn */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* 0---- success */
/* -1---- failure */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int DspOn()
{
hMutex = CreateMutex (
NULL, // No security descriptor
FALSE, // Mutex object not owned
TEXT("NameOfMutexObject")); // Object name
InitializeCriticalSection (&rSection);
InitializeCriticalSection (&LinSection);
InitializeCriticalSection (&slSection);
hDspIns = CreateFile(TEXT("DSP1:"), GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, 0, NULL);
if (hDspIns == INVALID_HANDLE_VALUE)
{
Beep(4);
SetLine(0);
printX("Error Open DSP Port!");
return -1;
}
return 0;
}
/* -------------------------------- */
/* Function: */
/* ScrLines */
/* Parameter: */
/* int n */
/* Return Value */
/* int */
/* Author: */
/* ZhangJun */
/* Date: */
/* 2005.9.21 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int ScrLines(int n)
{
g_lines = n;
g_twoflg = 0;
if (g_lines == 2)//From 2 to 3
{
iDspLine = 1;
g_twoflg = 1;
g_lines = 3;
}
return g_lines;
}
/* -------------------------------- */
/* Function: */
/* SetLine */
/* Parameter: */
/* int nLine the line */
/* Return Value */
/* int */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int SetLine(int nLine)
{
EnterCriticalSection (&LinSection);
iDspLine1 = nLine;
LeaveCriticalSection (&LinSection);
return 0;
}
/* -------------------------------- */
/* Function: */
/* CodeCharacter */
/* Parameter: */
/* wchar swzCh */
/* the content of translate */
/* Return Value */
/* int retvalue */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int CodeCharacter(wchar swzCh)
{
int retvalue;
if (swzCh >= 0xFF66 && swzCh <= 0xFF9F)
{
retvalue = (swzCh - 0xFF66) + 0x56;
return retvalue;
}
switch (swzCh)
{
// 0 - 9
case '0':
retvalue = 0x00;
break;
case '1':
retvalue = 0x01;
break;
case '2':
retvalue = 0x02;
break;
case '3':
retvalue = 0x03;
break;
case '4':
retvalue = 0x04;
break;
case '5':
retvalue = 0x05;
break;
case '6':
retvalue = 0x06;
break;
case '7':
retvalue = 0x07;
break;
case '8':
retvalue = 0x08;
break;
case '9':
retvalue = 0x09;
break;
//end 0 -9
case '.':
retvalue = 0x0A;
break;
case '!':
retvalue = 0x0B;
break;
case '-':
retvalue = 0x0C;
break;
// '>' will be added later
case '{':
retvalue = 0x0E;
break;
case '}':
retvalue = 0x0F;
break;
case '[':
retvalue = 0x10;
break;
case ']':
retvalue = 0x11;
break;
case '(':
retvalue = 0x0D;
break;
case ')':
retvalue = 0x46;
break;
// A - Z
case 'A':
retvalue = 0x12;
break;
case 'B':
retvalue = 0x13;
break;
case 'C':
retvalue = 0x14;
break;
case 'D':
retvalue = 0x15;
break;
case 'E':
retvalue = 0x16;
break;
case 'F':
retvalue = 0x17;
break;
case 'G':
retvalue = 0x18;
break;
case 'H':
retvalue = 0x19;
break;
case 'I':
retvalue = 0x1A;
break;
case 'J':
retvalue = 0x1B;
break;
case 'K':
retvalue = 0x1C;
break;
case 'L':
retvalue = 0x1D;
break;
case 'M':
retvalue = 0x1E;
break;
case 'N':
retvalue = 0x1F;
break;
case 'O':
retvalue = 0x20;
break;
case 'P':
retvalue = 0x21;
break;
case 'Q':
retvalue = 0x22;
break;
case 'R':
retvalue = 0x23;
break;
case 'S':
retvalue = 0x24;
break;
case 'T':
retvalue = 0x25;
break;
case 'U':
retvalue = 0x26;
break;
case 'V':
retvalue = 0x27;
break;
case 'W':
retvalue = 0x28;
break;
case 'X':
retvalue = 0x29;
break;
case 'Y':
retvalue = 0x2A;
break;
case 'Z':
retvalue = 0x2B;
break;
// a- z
case 'a':
retvalue = 0x2C;
break;
case 'b':
retvalue = 0x2D;
break;
case 'c':
retvalue = 0x2E;
break;
case 'd':
retvalue = 0x2F;
break;
case 'e':
retvalue = 0x30;
break;
case 'f':
retvalue = 0x31;
break;
case 'g':
retvalue = 0x32;
break;
case 'h':
retvalue = 0x33;
break;
case 'i':
retvalue = 0x34;
break;
case 'j':
retvalue = 0x35;
break;
case 'k':
retvalue = 0x36;
break;
case 'l':
retvalue = 0x37;
break;
case 'm':
retvalue = 0x38;
break;
case 'n':
retvalue = 0x39;
break;
case 'o':
retvalue = 0x3A;
break;
case 'p':
retvalue = 0x3B;
break;
case 'q':
retvalue = 0x3C;
break;
case 'r':
retvalue = 0x3D;
break;
case 's':
retvalue = 0x3E;
break;
case 't':
retvalue = 0x3F;
break;
case 'u':
retvalue = 0x40;
break;
case 'v':
retvalue = 0x41;
break;
case 'w':
retvalue = 0x42;
break;
case 'x':
retvalue = 0x43;
break;
case 'y':
retvalue = 0x44;
break;
case 'z':
retvalue = 0x45;
break;
//
case '=':
retvalue = 0x47;
break;
case '?':
retvalue = 0x48;
break;
case '>':
retvalue = 0x49;
break;
case '<':
retvalue = 0x4A;
break;
case '~':
retvalue = 0x4B;
break;
case ' ':
retvalue = 0x4C;
break;
case '/':
retvalue = 0x4D;
break;
case ':':
retvalue = 0x4E;
break;
case '|':
retvalue = 0x4F;
break;
case ';':
retvalue = 0x50;
break;
//
case 0x5c:
retvalue = 0x51;
break;
case '*':
retvalue = 0x52;
break;
case ',':
retvalue = 0x53;
break;
case '#':
retvalue = 0x54;
break;
case '+':
retvalue = 0x55;
break;
default:
retvalue = 0x55;
break;
}
return retvalue;
}
//-----------------------------------------
/* -------------------------------- */
/* Function: */
/* WINAPI DllMain */
/* Parameter: */
/* NULL */
/* Return Value */
/* TRUE */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int WINAPI DllMain(HINSTANCE hInstance,DWORD fdwReason,PVOID pvReserved)
{
return TRUE;
}
/* -------------------------------- */
/* Function: */
/* KbdInit */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* 0---- success */
/* -1---- failure */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int KbdInit()
{
// g_hKey = CreateFile(TEXT("KEY1:"), GENERIC_READ | GENERIC_WRITE, 0, NULL,
// OPEN_EXISTING, NULL, NULL);
g_hKey = CreateFile(TEXT("KEY1:"), GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL);
if (g_hKey == INVALID_HANDLE_VALUE)
{
Beep(4);
SetLine(0);
printX("Error Open KEY Port!");
return -1;
}
return 0;
}
/* -------------------------------- */
/* Function: */
/* CloseKbd */
/* Parameter: */
/* NULL */
/* Return Value */
/* int */
/* Author: */
/* Yuan Kexin */
/* Date: */
/* 2005.3.29 */
/* Last Edit By Zhang Jun */
/* -------------------------------- */
int CloseKbd()
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -