/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define VARBANK_C
/******************************************************************************
* *
* C O M P I L E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
#include <ctype.h>
#include <stdio.h>
#include <string.h>
/******************************************************************************
* *
* U S E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
#include "Common.h"
#include "XCore.h"
#include "XLCD.h"
#include "XLED.h"
#include "XGPIO.h"
#include "XBuzzer.h"
#include "XFlash.h"
#include "XNutOS.h"
#include "XEMAC.h"
#include "XProFile.h"
#include "XCodePage.h"
#include "XParser.h"
#include "VarBank.h"
#include "XBt.h"
#include "XFunction.h"
#include "..\..\appl\Parser\ParserUtil.h"
extern _CalResult* GetCalResult(VOID); // ch_20220607
extern VOID InitializeCalRslt(_CalResult* Result); // ch_20220705
/******************************************************************************
* *
* L O C A L D E F I N E S *
* *
******************************************************************************/
#if defined(AT91SAM9260)
#define POWER_DOWN_DELAY_TIME 0x100000
#elif defined(SH7040)
#define POWER_DOWN_DELAY_TIME 0x10000 // about RTC...?
#elif defined(N3290)
#define POWER_DOWN_DELAY_TIME 0x100000
#endif
#if defined(N3290)
#define FIRST_SAVE_ADDR (FLASH_START_BUFFER_ADDR + 0x0000A000)//FuseSectorProtect
#define SECOND_SAVE_ADDR (FLASH_START_BUFFER_ADDR + 0x00008000)//FuseSectorProtect
#else
#define FIRST_SAVE_ADDR (FLASH_START_ADDR + 0x0000E000)//FuseSectorProtect
#define SECOND_SAVE_ADDR (FLASH_START_ADDR + 0x0000C000)//FuseSectorProtect
#endif
#define RECORD_SAVE_OFFSET 0
#define FACTORY_SAVE_OFFSET 128
#define CONFIG_SAVE_OFFSET 2048
#define CAL_SAVE_OFFSET 4096 // ch_20220607
#define PAPER_TYPE_OFFSET 8192 // CH_20220310
//#define FACTORY_MAGIC 0x00434146
//#define CHECKSUM_XOR 0xA55A
#define FACTORY_MAGIC 0xC4A4B0D8
#define CHECKSUM_XOR 0xC96D
#if defined(TTP245P_PCB)
#define DEFAULT_GAP_INTEN 4
#define DEFAULT_BLINE_INTEN 8
#define DEFAULT_CONTINUE_INTEN 4
#define DEFAULT_RIBBON_INTEN 1
#elif defined(T045_PCB)||defined(T40_PCB)
#if defined(XP470B)||defined(XP450B)||defined(DELUXE_2044) \
||defined(XPDT425B) || defined(XPDT108BLABEL)||defined(XPDT427B)\
||defined(XP460B) ||defined(XP490B)
#define DEFAULT_CONTINUE_INTEN 2
#define DEFAULT_GAP_INTEN 6
#else
#define DEFAULT_CONTINUE_INTEN 13 //~{A,PxV=G?6HD,HO~}13
#define DEFAULT_GAP_INTEN 4 //~{<dO6V=G?6HD,HO~}4
#endif
#define DEFAULT_BLINE_INTEN 2 //~{:Z1jV=G?6HD,HO~}2
#define DEFAULT_RIBBON_INTEN 1
#endif
#define DEFAULT_SPEED SPEED(4) //~{D,HOKY6H~}
#if defined(B43054TA)||defined(XP480B)
#define DEFAULT_PRINT_SPEED '5'
#elif defined(XPH500E) ||defined(DELUXE_3044) ||defined(DELUXE_2044) ||defined(XPH400B) \
||defined(B42044A)||defined(XPTT424B)||defined(XPH400E)
#define DEFAULT_PRINT_SPEED 'C'
#elif defined(B42064TB)||defined(B42064A)||defined(XPDT426B)
#define DEFAULT_PRINT_SPEED 'D'
#elif defined(XPDT427B)||defined(B42054D)
#define DEFAULT_PRINT_SPEED '7'
#else
#define DEFAULT_PRINT_SPEED '5'
#endif
#if defined(XP470B) ||defined(DELUXE_2044) ||defined(XP450B) \
||defined(XPDT425B)|| defined(XPDT108BLABEL)||defined(XPDT427B)\
||defined(XP460B)||defined(XP490B)
#define DEFAULT_BACKFEED_SPEED 'B' // Print Speed 2"*/
#else
#define DEFAULT_BACKFEED_SPEED 'A' // Print Speed 2"*/
#endif
#define DEFAULT_SLEW_SPEED 'D' // Print Speed 6"
#define DEFAULT_LIMITFEED (INT)(TPH_DPI * 10)
#define DEFAULT_WIDTH (100*MM_DOT)//---100mm(INT)(TPH_WIDTH_DOT) //~{D,HOV=UE?m6H~}
#define DEFAULT_PAPER (63.5*MM_DOT)//---100mm//(TPH_DPI * 4) //~{D,HOV=UE8_6H~}
#define DEFAULT_GAP (3*MM_DOT * 2.5) //~{D,HO<dO68_6H~}
#define DEFAULT_BLINE (3*MM_DOT * 2.5) //~{D,HO:Z1j8_6H~}
#define DEFAULT_WAIT_JOB_TIME 5000
/******************************************************************************
* *
* L O C A L T Y P E D E F S *
* *
******************************************************************************/
typedef enum
{
PROFILE_DEFAULT_VAR,
PROFILE_FIXED_VAR,
}_eDecideVar;
typedef struct
{
CHAR name[2];
WORD size;
VOID *data;
}_FacSetting;
/******************************************************************************
* *
* L O C A L F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
#define __align4(x) ((x + 3) / 4 * 4) /* align 4-byte */
/******************************************************************************
* *
* L O C A L I N I T I A L I Z E D D A T A D E F I N I T I O N S *
* *
******************************************************************************/
#if defined(ZPL2)
CONST _ZebraCfg sZebraDefault =
{
0, // AdjustPosition
16, // PrintDarkness
DEFAULT_LIMITFEED, // MaxLabelLength
(SHORT)TPH_DPI, // MaxLogPaperOut
(SHORT)(TPH_DPI / 2), // MaxPhysPaperOut
(SHORT)(MM_DOT / 2), // MaxRibbonOut
0, // LabelHomeX
0, // LabelHomeY
DEFAULT_WIDTH, // LabelWidth
0, // LabelShift
0, // LabelTop
'N', // LabelReverse
DEFAULT_PRINT_SPEED, // PrintSpeed
DEFAULT_SLEW_SPEED, // SlewSpeed
DEFAULT_BACKFEED_SPEED, // BackfeedSpeed
'N', // BackfeedSequence
'T', // PrintMode
'Y', // Prepeel
'N', // FeedPowerUp
'N', // FeedCloseHead
'Y', // AutoDetectType
'^', // CaretChar
'~', // TildeChar
',', // DelimiterChar
'A', // DotsMillimeter
'B', // MemoryAliasB
'E', // MemoryAliasE
'R', // MemoryAliasR
'A', // MemoryAliasA
'R', // EncodingDevice
"", // EncodingName
};
#endif
#if defined(DPL)
CONST _DmxCfg sDmxDefault =
{
'S', // (CC) ControlCodes
'Y', // (CH) CommHeatCommands
'Y', // (CS) CommSpeedCommands
'Y', // (CT) CommTOFCommands
'Y', // (ES) ESCSequences
'N', // (IC) IgnoreControlCodes
'N', // (IE) IgnoreDistances
'N', // (NS) DisableSymbolSet
'0', // (SM) MaximumLengthIgnore
'N', // (SV) SoftwareSwitch
{'P','M'}, // (AS) SingleByteSymbolSet
{'U','C'}, // (DS) DoubleByteSymbolSet
(-1), /* default */ // (pS) PrintSpeed
(-1), /* default */ // (SS) or (sS) FeedSpeed
(-1), /* default */ // (BS) or (bS) ReverseSpeed
(-1), /* default */ // (FS) SlewSpeed
(-1), /* default */ // (CE) CutterEquipped
(-1), /* default */ // (PS) PresentSensorEquipped
'N', /* Actually AUTO */ // (RE) RibbonSaverEquipped
'N', // (RM) RewinderEquipped
'N', // (VE) VerifierEquipped
'0', // (BL) BackupLabel
'1', // (EP) EndOfPrint (Output)
'4', // (EQ) StartOfPrint (Input)
'3', // (GS) GPIOSlew
'3', // (RS) RibbonLowSignal (Output)
'D', // (MT) MediaType
'G', // (ST) SensorType
'N', // (LA) LabelAlignment
(100 * TPH_DPI / 100), // (AL) AlignmentLength (Units:dot)
(100 * TPH_DPI / 100), // (CL) ContinuousLabelLength (Units:dot)
(-1), /* default */ // (LW) LabelWidth (Units:dot)
(1600 * TPH_DPI / 100), // (ML) MaximumLength (Units:dot)
(25 * TPH_DPI / 100), // (PO) PaperEmpty (Units:dot)
(138 * TPH_DPI / 100), // (RL) RibbonLowDiameter (Units:dot)
0, // (TB) TOFBias
10, // (TD) TOFDelta
11, // (TG) TOFGain
4, // (TN) NoPaperMin
0, // (RB) ReflectiveTOFBias
10, // (RD) ReflectiveTOFDelta
8, // (RG) ReflectiveTOFGain
4, // (RN) ReflectiveNoPaperMin
160, // (PV) PaperValue
40, // (GM) GapMarkValue
9, // (SG) SensorGainValue
160, // (RV) ReflectivePaperValue
40, // (MV) MarkValue
9, // (GR) GainReflectiveValue
0, // (EV) EmptySensorLevel
(-1), /* default */ // (CA) ColumnAdjust (Units:dot)
0, // (CF) ColumnAdjustFineTune (Units:dot)
0, // (CO) ColumnOffset (Units:dot)
(-1), /* default */ // (RA) RowAdjust (Units:dot)
0, // (RF) RowAdjustFineTune (Units:dot)
0, // (RO) RowOffset (Units:dot)
(-1), /* default */ // (PA) PresentAdjust (Units:dot)
0, // (PJ) PresentAdjustFineTune (Units:dot)
0, // (PD) PresentDistance (Units:dot)
10, // (HE) Heat
32, // (DK) Darkness
32, // (PC) PrintContrast
'N', // (BA) BackupAfterPrint
0, // (BD) BackupDelay (Units:ms)
'N', // (BP) BritishPound
'N', // (BZ) BuzzerEnable
0, // (CB) CutBehind
0, // (DE) DPIEmulation (Units:DPI)
(-1), /* default */ // (DM) DefaultModule
0, // (DR) DelayRate (Units:sec)
'0', // (EM) InputMode
'N', // (ET) ExactTime
'X', // (FA) FormatAttributes
'0', // (FE) FontEmulation
(50 * TPH_DPI / 100), // (FHD) VoidDistance (Units:dot)
'1', // (FHL) InteractionLevel
1, // (FHR) RetryCount
'N', // (FM) FeedbackMode
'N', // (GE) GPIOEquipped
'L', // (HB) HeadBias
0, // (HC) HeadCleaning
10, // (HT) HostTimeout (Units:sec)
'M', // (IL) ImagingMode
256, /* Interim */ // (IM) InternalModule (Units:KB)
'N', // (LE) LegacyEmulation
'N', // (LR) LabelRotation
"ENGLISH", // (LS) LanguageSelect
'F', // (LM) LabelStore
0, // (MCCG) SizeModuleG (Units:KB)
0, // (MCCZ) SizeModuleZ (Units:KB)
'U', // (MM) MenuMode
'N', // (NR) NoReprint
'N', // (OF) OptionFeedback
'N', // (PE) PeelMode
{0x00,0x00,0x00}, // (PL) PrinterLevel
'N', // (PM) PauseMode
{'0','0','0','0'}, // (PW) Password
'N', // (RP) RibbonLowPause
0, // (RR) RewinderAdjust
70, // (RW) RetractDelay (Units:ms)
128, // (SA) SOPAdjust (Units:dot)
256, // (SC) ScalableCache (Units:KB)
'D', // (SE) SOPEmulation
200, // (SH) ScalableHeap (Units:KB)
'N', // (Sl) SecurityLock
'H', // (SL) StopLocation
'N', // (TP) TOFPrecedence
'I', // (UM) UnitMeasure
'A', // (VT) VerifierType
'Y', // (NTD) EnableDHCP
'Y', // (NTT) EnableSNMP
'N', // (NTw) EnableWiFi
9100, // (NTP) PortNumber
0, // (NTI) AddressIP
0, // (NTS) SubnetMask
0, // (NTG) AddressGateway
0, // (NTN) AddressSNMP
0, // (NTW) AddressWINS1
0, // (NTU) AddressWINS2
0, // (NTY) AddressDNS1
0, // (NTZ) AddressDNS2
"EngWAN1", // (WEA) WiFiSSID
'1', // (WEC) WiFiChannel
'0', // (WEF) WiFiEnableDHCP
0, // (WEI) WiFiAddressIP
150, // (WEL) WiFiAcquireTimeDHCP (Units:sec)
'1', // (WEM) WiFiMaximumRate
"", // (WEN) WiFiClientName
'0', // (WEP) WiFiPointDensity
{'U','S'}, // (WER) WiFiRegion
'0', // (WET) WiFiType
15, // (WEV) WiFiRetransmitDHCP (Units:sec)
'0', // (WEX) WiFiEnableMAC
'0', // (WS) WiFiSecurity
};
#endif
CONST _PrintCfg sPrintDefault =
{
#if defined(NUTOS)
{ // Nut/OS configuration
sizeof(CONFOS), // Size of this structure
{'O','S'}, // Magic cookie
"admin", // Host name of the system
},
#endif
#if defined(NUTNET)
{ // Network configuration
sizeof(CONFNET), // Size of this structure
DEV_ETHER_NAME, // Magic cookie
{0x00,0x00,0x00,0x00,0x00,0x00}, // Ethernet MAC address
0, // Last used IP address
0, // IP netmask
0, // Default route
0, // Configured IP address
0, // Primary DNS IP address
0, // Secondary DNS IP address
},
{ // SMTP configuration
sizeof(CONFSMTP), // Size of this structure
"SMTP", // Magic cookie
0, // E-mail notification
0, // SMTP authentication
"", // SMTP server address
"", // E-mail Account Name
"", // E-mail Account Password
"", // Sender e-mail address
"", // Receiver e-mail address
},
{ // SNTP configuration
sizeof(CONFSNTP), // Size of this structure
"SNTP", // Magic cookie
0, // Clock synchronization
0, // Automatic update interval
85, // Time zones
0, // Time differences
{"","",""}, // SNTP server address
},
{ // WEB configuration
sizeof(CONFWEB), // Size of this structure
"WEB", // Magic cookie
"", // Root directory login user name
"", // Root directory login password
"", // Administrator login user name
"", // Administrator login password
},
#endif
#if defined(UART2_BT)//_BtSetting
{
FALSE,
MODEL_NAME,
"0000",
"",
"",
},
#endif
{ // GPIO input function
{GPIO_SIGNAL_OFF,0,GPI_FUNC_OFF}, // Channel 1
{GPIO_SIGNAL_OFF,0,GPI_FUNC_OFF}, // Channel 2
{GPIO_SIGNAL_OFF,0,GPI_FUNC_OFF}, // Channel 3
{GPIO_SIGNAL_OFF,0,GPI_FUNC_OFF}, // Channel 4
},
{ // GPIO output function
{GPIO_SIGNAL_OFF,0,0,0,0,GPO_FUNC_OFF}, // Channel 1
{GPIO_SIGNAL_OFF,0,0,0,0,GPO_FUNC_OFF}, // Channel 2
{GPIO_SIGNAL_OFF,0,0,0,0,GPO_FUNC_OFF}, // Channel 3
{GPIO_SIGNAL_OFF,0,0,0,0,GPO_FUNC_OFF}, // Channel 4
{GPIO_SIGNAL_OFF,0,0,0,0,GPO_FUNC_OFF}, // Channel 5
{GPIO_SIGNAL_OFF,0,0,0,0,GPO_FUNC_OFF}, // Channel 6
{GPIO_SIGNAL_OFF,0,0,0,0,GPO_FUNC_OFF}, // Channel 7
},
{ // Key function
{KEY_FUNC_DEFAULT}, // Key 1
{KEY_FUNC_DEFAULT}, // Key 2
{KEY_FUNC_DEFAULT}, // Key 3
{KEY_FUNC_DEFAULT}, // Key 4
{KEY_FUNC_DEFAULT}, // Key 5
{KEY_FUNC_DEFAULT}, // Key 6
},
{ // Uart Setting
UART_BAUD_230400, // Baud rate
UART_DATA_8, // Data bits
UART_PARITY_NONE, // Parity
UART_STOP_ONE, // Stop
UART_RTS_CTS | UART_XON_XOFF, // Flow control
},
GAP_MODE, // Sensor mode
MOTOR_FORWARD, // MotorDirection
TEAR_MODE, // Print Out Mode
DEBUG_LABEL, // Debug Mode Select
(FLOAT)8, // Print Density ~{4rS!E(6H~}
DEFAULT_PAPER, // Paper Size ~{V=UE3_4g~}
DEFAULT_GAP, // Gap Size ~{<dO68_6H~}
DEFAULT_BLINE, // Bline Size ~{:Z1j8_6H~}
0, // Gap size offset
0, // Bline size offset
0, // Direction
0, // Mirror
TRUE, // Carriage Open enable or not
FALSE, // Factory Test Flag
TRUE, // Tear Mode Flag
FALSE, // Reverse the gap sensor signal
TRUE, // Automatic sensor reference
FALSE, // Measure before printing
FALSE, // Calibrate before printing
TRUE, // Ribbon Mode Flag // ch_20220714 : changed to TRUE.
TRUE, // Ribbon Encoder Flag
FALSE, // Ribbon inside
FALSE, // Ignore AUTO.BAS
TRUE, // Reprint enable or disable
FALSE, // Print key Func
FALSE, // Reprint key Func
FALSE, // Barcode verifier
TRUE, // Return after finishing cutting
FALSE, // TPU
FALSE, //CutterContinuous
FALSE, //SuppressBack
0, // Dummy
0, // Firmware checksum
0, // Profile checksum
0, // Cutter counter
0, // Print key counter
0, // Reprint key counter
0, // LimitSpeed:2
0, // LimitDensity:2,
0, // LimitPaperSize:2
0, // LimitPaperWidth:2,
0, // LimitBline:2,
0, // LimitGap:2,
0, // LimitOutPeel:2,
0, // LimitOutCut:2,
0, // LimitOutOff:2,
0, // LimitOutTear:2,
0, // LimitDirection:2,
0, // LimitMirror:2,
0, // LimitCodepage:2,
0, // LimitDummy:6;
512, // Gap sensor reference
512, // Bline sensor reference
512, // Continue paper sensor reference
512, // Ribbon sensor reference
0, // Ignore Small Gap & Bline Size
0, // continue paper feed length
DEFAULT_WIDTH, // Paper Width
80, // TPH Over Heat
65, // TPH can reprint
70, // Motor Over Heat
65, // Motor can move
0, // Print out distance(OverHead)
DEFAULT_LIMITFEED, // Limit feed
DEFAULT_WAIT_JOB_TIME, // Waiting next job time
0, // Feed the length of paper
9100, // Base raw port number
0, // Adjust head position
0, // Cutter offset
0, // Image X shift X~{F+RF~}
0, // Image Y shift Y~{F+RF~}
0, // Print X Shift X~{4rS!F+RF~}
0, // Print Y Shift Y~{4rS!F+RF~}
0, // Usb Serial Mode
DEFAULT_SPEED, // Print Speed
0, // Display language
0, // Country code
10, // Code Page
DEFAULT_GAP_INTEN, // Gap sensor intension
DEFAULT_BLINE_INTEN, // Bline sensor intension
DEFAULT_CONTINUE_INTEN, // Continue paper sensor intension
DEFAULT_RIBBON_INTEN, // Ribbon sensor intension
0, // LED set flag
"AUTO.BAS", // File name of auto run
"", // Diagnostic tool's password
{"<","","",""}, // INPUT prefix for MIDAMERICA
{">","","",""}, // INPUT suffix for MIDAMERICA
{"","","","","","","","","",""}, // Keep counter data
{0,0,0,0,0,0,0,0,0,0}, // Keep counter step
#if defined(EPL2)
3, // Line mode row spacing (in dot)
1, // Line mode font width
1, // Line mode font height
"4.EFT", // Line mode font name
8, // Epl code page data bit
9, // Epl Code Page
0, // Epl Country code
0xd5, // Epl Euro Replace
FALSE, // Epl single buffer wait print
TRUE, // Windows driver enable flag
FALSE, // When Error Clear image buffer
FALSE, // Auto Error Report
0, // Auto error response
'$', // Error Start character
#endif
1, //my_encode_flag;
0, //my_encode_count
0, //lase_encode_count
};
/******************************************************************************
* *
* L O C A L U N I T I A L I Z E D D A T A D E F I N I T I O N S *
* *
******************************************************************************/
STATIC _PrintRecord sPrintRecord;
STATIC _FacSetting sFactorySetting[256];
STATIC _PrintCfg sPrintCfg;
STATIC _CalResult CalRslt_Save; // ch_20220607
#if defined(ZPL2)
STATIC _ZebraCfg sZebraCfg;
#endif
#if defined(DPL)
STATIC _DmxCfg sDmxCfg;
#endif
STATIC BYTE FactoryPool[2048];
/******************************************************************************
*
* Function:
*
*
* None
*
* Output:
* None.
*
******************************************************************************/
STATIC CHAR *DecideKind(_eDecideVar kind, CHAR *prompt)
{
STATIC CHAR keyword[128];
if (kind == PROFILE_DEFAULT_VAR)
sprintf(keyword, "DEFAULT %s", prompt);
if (kind == PROFILE_FIXED_VAR)
sprintf(keyword, "FIXED %s", prompt);
return keyword;
}
u8 get_sPrintCfg_BlineInten(void)
{
return sPrintCfg.BlineInten;
}
FLOAT ProfileLimit(CHAR *prompt)
{
FLOAT data = 0;
if (!GetProfileInt(DecideKind(PROFILE_FIXED_VAR, prompt), &data))
data = 0;
return data;
}
//
STATIC VOID ProfileDecideVar(_eDecideVar kind)
{
CHAR Keyword[128];
CHAR Buffer[128];
FLOAT data;
INT i;
//debug_printf("S:%d\n",sPrintCfg.BlineInten);
if (GetProfileInt(DecideKind(kind, "BAUDRATE"), &data))
{
CONST STATIC INT Baud[] = { 0,1200,2400,4800,9600,19200,38400,57600,115200 };
for (i = 0; i < sizeof(Baud) / sizeof(INT); i++)
if ((INT)data == Baud[i])
break;
if (i < sizeof(Baud) / sizeof(INT))
sPrintCfg.UartSetting.Baud = i;
}
if (GetProfileInt(DecideKind(kind, "DATABIT"), &data))
{
CONST STATIC INT Data[] = { 7,8 };
for (i = 0; i < sizeof(Data) / sizeof(INT); i++)
if ((INT)data == Data[i])
break;
if (i < sizeof(Data) / sizeof(INT))
sPrintCfg.UartSetting.DataBits = i;
}
if (GetProfileString(DecideKind(kind, "PARITY"), Buffer))
{
CONST STATIC CHAR *Parity[] = { "NONE","ODD","EVEN" };
for (i = 0; i < sizeof(Parity) / sizeof(CHAR *); i++)
if (strcmp(Buffer, Parity[i]) == 0)
break;
if (i < sizeof(Parity) / sizeof(CHAR *))
sPrintCfg.UartSetting.Parity = i;
}
if (GetProfileInt(DecideKind(kind, "STOPBIT"), &data))
{
CONST STATIC INT Stop[] = { 1,2 };
for (i = 0; i < sizeof(Stop) / sizeof(INT); i++)
if ((INT)data == Stop[i])
break;
if (i < sizeof(Stop) / sizeof(INT))
sPrintCfg.UartSetting.Stop = i;
}
if (GetProfileString(DecideKind(kind, "SENSOR"), Buffer))
{
CONST STATIC CHAR *Sensor[] = { "GAP","BLINE","CONTINUE","CONTINUE","FEED CONTINUE" };
for (i = 0; i < sizeof(Sensor) / sizeof(CHAR *); i++)
if (strcmp(Buffer, Sensor[i]) == 0)
break;
if (i < sizeof(Sensor) / sizeof(CHAR *))
sPrintCfg.SensorMode = (_eSensorMode)i;
if ( sPrintCfg.SensorMode == FEED_CONTINUE_MODE )
sPrintCfg.fPaperSize = HALF_IMAGE_LENGTH;
}
if (GetProfileInt(DecideKind(kind, "PAPER SIZE"), &data))
{
if (sPrintCfg.SensorMode == FEED_CONTINUE_MODE)
sPrintCfg.ContinuePaperFeed = (WORD)data;
else
sPrintCfg.fPaperSize = data;
}
if (GetProfileInt(DecideKind(kind, "GAP SIZE"), &data))
sPrintCfg.fGapSize = data;
if (GetProfileInt(DecideKind(kind, "BLINE SIZE"), &data))
sPrintCfg.fBlineSize = data;
if (GetProfileString(DecideKind(kind, "REMOVAL"), Buffer))
{
if (strcmp(Buffer, "OFF") == 0)
{
#if defined(ZPL2)
sZebraCfg.PrintMode = 'T';
#endif
sPrintCfg.TearMode = FALSE;
sPrintCfg.PrintOutMode = OFF_MODE;
}
else if (strcmp(Buffer, "TEAR") == 0)
{
#if defined(ZPL2)
sZebraCfg.PrintMode = 'T';
#endif
sPrintCfg.TearMode = TRUE;
sPrintCfg.PrintOutMode = TEAR_MODE;
}
else if (strcmp(Buffer, "PEEL") == 0)
{
#if defined(ZPL2)
sZebraCfg.PrintMode = 'P';
#endif
sPrintCfg.PrintOutMode = PEEL_MODE;
}
else if (strcmp(Buffer, "CUTTER") == 0)
{
#if defined(ZPL2)
sZebraCfg.PrintMode = 'C';
#endif
sPrintCfg.CutterBack = TRUE;
sPrintCfg.CutterPieces = 1;
sPrintCfg.PrintOutMode = CUTTER_MODE;
}
else if (strcmp(Buffer, "PARTIAL CUTTER") == 0)
{
#if defined(ZPL2)
sZebraCfg.PrintMode = 'C';
#endif
sPrintCfg.CutterBack = FALSE;
sPrintCfg.CutterPieces = 1;
sPrintCfg.PrintOutMode = CUTTER_MODE;
}
}
if (GetProfileInt(DecideKind(kind, "DIRECTION"), &data))
sPrintCfg.Direction = (BOOL)data;
if (GetProfileInt(DecideKind(kind, "MIRROR"), &data))
sPrintCfg.Mirror = (BOOL)data;
if (GetProfileInt(DecideKind(kind, "HEADOPEN"), &data))
sPrintCfg.CarriageOpen = (BOOL)data;
if (GetProfileInt(DecideKind(kind, "GAPSENSOR REVERSE"), &data))
sPrintCfg.GapReverse = (BOOL)data;
if (GetProfileInt(DecideKind(kind, "AUTOSENSOR REFERENCE"), &data))
sPrintCfg.AutoSensorRef = (BOOL)data;
if (GetProfileInt(DecideKind(kind, "MEASURE"), &data))
sPrintCfg.Measure = (BOOL)data;
if (GetProfileInt(DecideKind(kind, "CALIBRATE"), &data))
sPrintCfg.Calibrate = (BOOL)data;
if (GetProfileString(DecideKind(kind, "RIBBON WOUND"), Buffer))
{
if (strcmp(Buffer, "INSIDE") == 0)
sPrintCfg.RibbonInside = TRUE;
else if (strcmp(Buffer, "OUTSIDE") == 0)
sPrintCfg.RibbonInside = FALSE;
}
if (GetProfileInt(DecideKind(kind, "REPRINT"), &data))
sPrintCfg.Reprint = (BOOL)data;
if (GetProfileInt(DecideKind(kind, "PRINTKEY"), &data))
sPrintCfg.PrintKey = (BOOL)data;
if (GetProfileInt(DecideKind(kind, "GAP REFERENCE"), &data))
sPrintCfg.GapRef = (WORD)data;
if (GetProfileInt(DecideKind(kind, "BLINE REFERENCE"), &data))
sPrintCfg.BlineRef = (WORD)data;
if (GetProfileInt(DecideKind(kind, "REFERENCE OF CONTINUOUS"), &data))
sPrintCfg.ContinuousRef = (WORD)data;
if (GetProfileInt(DecideKind(kind, "PAPERWIDTH"), &data))
{
#if defined(DPL)
sDmxCfg.LabelWidth = (SHORT)data;
#endif
#if defined(ZPL2)
sZebraCfg.LabelWidth = (SHORT)data;
#endif
sPrintCfg.PaperWidth = (WORD)data;
}
if (GetProfileInt(DecideKind(kind, "LIMITFEED"), &data))
sPrintCfg.LimitFeed = (WORD)data;
if (GetProfileInt(DecideKind(kind, "WAITING TIME"), &data))
sPrintCfg.WaitJobTime = (WORD)(data * 1000); // unit 1 ms
if (GetProfileInt(DecideKind(kind, "OFFSET"), &data))
sPrintCfg.OffsetDis = (SHORT)data;
if (GetProfileInt(DecideKind(kind, "REFERENCE X"), &data))
sPrintCfg.ReferenceX = (SHORT)data;
if (GetProfileInt(DecideKind(kind, "REFERENCE Y"), &data))
sPrintCfg.ReferenceY = (SHORT)data;
if (GetProfileInt(DecideKind(kind, "SHIFT"), &data))
sPrintCfg.ShiftDisY = (SHORT)data;
if (GetProfileInt(DecideKind(kind, "SPEED"), &data))
{
#if defined(ZPL2)
sZebraCfg.PrintSpeed = (CHAR)data;
#endif
sPrintCfg.Speed = ToMotorSpeed(data);
}
if (GetProfileInt(DecideKind(kind, "DENSITY"), &data))
{
FLOAT Max, Min;
if (!GetProfileInt("MAXIMUM DENSITY", &Max))
Max = (FLOAT)DENSITY_MAX;
if (!GetProfileInt("MINIMUM DENSITY", &Min))
Min = (FLOAT)DENSITY_MIN;
#if defined(DPL)
sDmxCfg.Heat = (SHORT)((data - (SHORT)Min) / ((SHORT)Max - (SHORT)Min) * 30);
#endif
#if defined(ZPL2)
sZebraCfg.PrintDarkness = (SHORT)((data - (SHORT)Min) / ((SHORT)Max - (SHORT)Min) * 30);
#endif
sPrintCfg.fDensity = data;
}
if (GetProfileString(DecideKind(kind, "LANGUAGE"), Buffer))
{
#if defined(MENU_TSPL_1)
CONST STATIC CHAR *Lang[] = { "ENGLISH","TRAD.CHINESE","JAPANESE","SIMP.CHINESE","ITALIAN" };
#elif defined(MENU_TSPL_2)
CONST STATIC CHAR *Lang[] = { "ENGLISH","TRAD.CHINESE","SIMP.CHINESE","JAPANESE","POLISH" };
#elif defined(MENU_TSPL_3)
CONST STATIC CHAR *Lang[] = { "ENGLISH","TRAD.CHINESE","SIMP.CHINESE","JAPANESE","KOREAN","GERMAN",
"ITALIAN","FRENCH","RUSSIAN","POLISH","SPANISH","LITHUANIAN","CZECH" };
#elif defined(MENU_TSPL_4)
CONST STATIC CHAR *Lang[] = { "ENGLISH" };
#endif
#if defined(LCD_MODEL)
for (i = 0; i < sizeof(Lang) / sizeof(CHAR *); i++)
if (strcmp(Buffer, Lang[i]) == 0)
break;
if (i < sizeof(Lang) / sizeof(CHAR *))
sPrintCfg.Language = i;
#endif
}
#if defined(UART2_BT)
if (GetProfileString(DecideKind(kind, "BT NAME"), Buffer))
strcpy((CHAR *)sPrintCfg.BtSetting.name, Buffer);
if (GetProfileString(DecideKind(kind, "BT PIN"), Buffer))
strcpy((CHAR *)sPrintCfg.BtSetting.pin, Buffer);
#endif
if (GetProfileString(DecideKind(kind, "COUNTRY"), Buffer))
SetCountry(Buffer);
if (GetProfileString(DecideKind(kind, "CODEPAGE"), Buffer))
SetCodePage(Buffer);
if (GetProfileInt(DecideKind(kind, "GAP INTENSION"), &data))
sPrintCfg.GapInten = (BYTE)data;
//debug_printf("S:%d\n",sPrintCfg.BlineInten);
if (GetProfileInt(DecideKind(kind, "BLINE INTENSION"), &data))
{
//debug_printf("S:%d,%d\n",sPrintCfg.BlineInten,(BYTE)data);
sPrintCfg.BlineInten = (BYTE)data;
}
if (GetProfileInt(DecideKind(kind, "INTENSION OF CONTINUOUS"), &data))
sPrintCfg.ContinuousInten = (BYTE)data;
if (GetProfileInt(DecideKind(kind, "INTENSION OF RIBBON"), &data))
sPrintCfg.RibbonInten = (BYTE)data;
if (GetProfileString(DecideKind(kind, "AUTORUN"), Buffer))
{
if (strcmp(strchr(Buffer, '.'), ".BAS") == 0)
strcpy((CHAR *)sPrintCfg.AutoRun, Buffer);
}
for (i = 0; i < 4; i++)
{
sprintf(Keyword, "INPUT PREFIX %u", i + 1);
if (GetProfileString(DecideKind(kind, Keyword), Buffer))
strncpy((CHAR *)sPrintCfg.InputPrefix[i], Buffer, sizeof(sPrintCfg.InputPrefix[i]) - 1);
sprintf(Keyword, "INPUT SUFFIX %u", i + 1);
if (GetProfileString(DecideKind(kind, Keyword), Buffer))
strncpy((CHAR *)sPrintCfg.InputSuffix[i], Buffer, sizeof(sPrintCfg.InputSuffix[i]) - 1);
}
if (GetProfileString(DecideKind(kind, "INPUT PREFIX"), Buffer))
{
memset(sPrintCfg.InputPrefix, 0, sizeof(sPrintCfg.InputPrefix));
strncpy((CHAR *)sPrintCfg.InputPrefix[0], Buffer, sizeof(sPrintCfg.InputPrefix[0]) - 1);
}
if (GetProfileString(DecideKind(kind, "INPUT SUFFIX"), Buffer))
{
memset(sPrintCfg.InputSuffix, 0, sizeof(sPrintCfg.InputSuffix));
strncpy((CHAR *)sPrintCfg.InputSuffix[0], Buffer, sizeof(sPrintCfg.InputSuffix[0]) - 1);
}
#if defined(EPL2)
if (GetProfileInt(DecideKind(kind, "LINEMODE ROWSPACING"), &data))
sPrintCfg.LineSpace = (WORD)data;
if (GetProfileInt(DecideKind(kind, "LINEMODE FONTWIDTH"), &data))
sPrintCfg.LineFontWidth = (WORD)data;
if (GetProfileInt(DecideKind(kind, "LINEMODE FONTHEIGHT"), &data))
sPrintCfg.LineFontHeight = (WORD)data;
if (GetProfileString(DecideKind(kind, "LINE MODE FONTNAME"), Buffer))
strcpy((CHAR *)sPrintCfg.LineFont, Buffer);
#endif
#if defined(ZPL2)
if (GetProfileString(DecideKind(kind, "MEDIA POWERUP"), Buffer))
{
if (strcmp(Buffer, "FEED") == 0 ||
strcmp(Buffer, "CALIBRATION") == 0 ||
strcmp(Buffer, "LENGTH") == 0 ||
strcmp(Buffer, "NO MOTION") == 0)
sZebraCfg.FeedPowerUp = Buffer[0];
}
if (GetProfileString(DecideKind(kind, "HEAD CLOSE"), Buffer))
{
if (strcmp(Buffer, "FEED") == 0 ||
strcmp(Buffer, "CALIBRATION") == 0 ||
strcmp(Buffer, "LENGTH") == 0 ||
strcmp(Buffer, "NO MOTION") == 0)
sZebraCfg.FeedCloseHead = Buffer[0];
}
#endif
}
VOID InitialDefaultVar(VOID)
{
_PrintCfg savecfg = sPrintCfg;
#if defined(NUTNET)
FLOAT data;
#endif
#if defined(ZPL2)
sZebraCfg = sZebraDefault;
#endif
#if defined(DPL)
sDmxCfg = sDmxDefault;
#endif
sPrintCfg = sPrintDefault;
// Initialize after upgrading
sPrintCfg.Checksum = APP_CODE_CHECKSUM;
// Initialize after profile upgrading
sPrintCfg.ProfileChecksum = GetProfileChecksum();
// Keep the diagnostic tool's password
memcpy(sPrintCfg.DiagPassword, savecfg.DiagPassword, sizeof(sPrintCfg.DiagPassword));
#if defined(NUTNET)
if (GetProfileInt("KEEP IPSETTINGS", &data) == FALSE)
data = 1;
if (data && savecfg.confnet.cd_size == sizeof(CONFNET) && strcmp(savecfg.confnet.cd_name, DEV_ETHER_NAME) == 0)
sPrintCfg.confnet = savecfg.confnet;
if (GetProfileInt("KEEP SMTPSETTINGS", &data) == FALSE)
data = 1;
if (data && savecfg.confsmtp.size == sizeof(CONFSMTP) && strcmp(savecfg.confsmtp.magic, "SMTP") == 0)
sPrintCfg.confsmtp = savecfg.confsmtp;
if (GetProfileInt("KEEP SNTPSETTINGS", &data) == FALSE)
data = 1;
if (data && savecfg.confsntp.size == sizeof(CONFSNTP) && strcmp(savecfg.confsntp.magic, "SNTP") == 0)
sPrintCfg.confsntp = savecfg.confsntp;
if (GetProfileInt("KEEP WEBSETTINGS", &data) == FALSE)
data = 1;
if (data && savecfg.confweb.size == sizeof(CONFWEB) && strcmp(savecfg.confweb.magic, "WEB") == 0)
sPrintCfg.confweb = savecfg.confweb;
#endif
#if defined(NUTOS)
memcpy(sPrintCfg.confos.hostname, sPrintRecord.PrintServerName, sizeof(sPrintCfg.confos.hostname));
#endif
#if defined(NUTNET)
// Load the unique Ethernet MAC
memcpy(sPrintCfg.confnet.cdn_mac, sPrintRecord.UniqueMAC, sizeof(sPrintCfg.confnet.cdn_mac));
#endif
ProfileDecideVar(PROFILE_DEFAULT_VAR);
}
VOID IsEffectiveSerialNumber(CHAR *SerialNumber,INT size)
{
CHAR *name;
INT index;
name = SerialNumber;
for (index = 0; index < size && isprint(*(name + index)); index++);
if (index != size && *(name + index) == 0)
for (; index < size && *(name + index) == 0; index++);
if (index != size || *(name + size - 1) != 0)
memset(name, 0, size);
}
VOID InitialVarBank(VOID)
{
CHAR *name;
INT index, size;
ReadVarBank();
ProfileDecideVar(PROFILE_FIXED_VAR);
sPrintRecord.PrintServerName[sizeof(sPrintRecord.PrintServerName) - 1] = '\0';
// Is it the effective Serial Number ?
IsEffectiveSerialNumber(sPrintRecord.SerialNumberName,sizeof(sPrintRecord.SerialNumberName));
IsEffectiveSerialNumber(sPrintRecord.FactorySerialNumberName,sizeof(sPrintRecord.FactorySerialNumberName));
IsEffectiveSerialNumber(sPrintRecord.TPHSerialNumberName,sizeof(sPrintRecord.TPHSerialNumberName));
sPrintCfg.UsbSerialMode = 0;
sysprintf("%s leng:%d\r\n",sPrintRecord.SerialNumberName,sPrintRecord.UsbSerial);
switch(sPrintCfg.UsbSerialMode)
{
case 1:
break;
case 2:
SetUsbSerialrRandom(0);
break;
case 0:
SetUsbSerialNumber((BYTE *)(sPrintRecord.SerialNumberName),sPrintRecord.UsbSerial);
break;
}
if(sPrintCfg.UsbSerialMode==0)
SetUsbSerialNumber((BYTE *)(sPrintRecord.SerialNumberName),sPrintRecord.UsbSerial);
#if defined(AT91SAM9260)
#if defined(TTP245P_PCB) || defined(T045_PCB)||defined(T40_PCB)
AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, // AIC base address
AT91C_ID_FIQ, // Peripheral ID
POWER_DOWN_PRIORITY, // Priority
AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE, // Level sensitive
PowerDownISR );
// Enable FIQ interrupt
AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_FIQ);
#endif
#elif defined(N3290)
gpio_setportdir(GPIO_PORTB ,BIT2, 0);
gpio_setportpull(GPIO_PORTB ,BIT2, 0);
gpio_setintmode(GPIO_PORTB ,BIT2, BIT2, 0);//~{IOI}QXVP6O~}
gpio_setsrcgrp(GPIO_PORTB ,BIT2, 3); //~{VP6OT4#3~}
gpio_setdebounce(128, 1 << 3);
gpio_setlatchtrigger(1 << 3);
sysInstallISR(FIQ_LEVEL_0, 3 + 2, (PVOID)PowerDownISR);
sysSetInterruptType(3 + 2, HIGH_LEVEL_SENSITIVE);
sysSetLocalInterrupt(ENABLE_FIQ_IRQ);
sysEnableInterrupt(3 + 2);
#endif
}
#if defined(ZPL2)
_ZebraCfg *GrabZebraDefault(VOID)
{
return (_ZebraCfg *)(&sZebraDefault);
}
_ZebraCfg *GrabZebraConfig(VOID)
{
return &sZebraCfg;
}
#endif
#if defined(DPL)
_DmxCfg *GrabDatamaxDefault(VOID)
{
return (_DmxCfg *)(&sDmxDefault);
}
_DmxCfg *GrabDatamaxConfig(VOID)
{
return &sDmxCfg;
}
#endif
_PrintCfg *GrabPrintConfig(VOID)
{
return &sPrintCfg;
}
// ch_20220607
_CalResult *GrabCalResult(VOID)
{
return &CalRslt_Save;
}
_PrintRecord *GrabPrintRecord(VOID)
{
return &sPrintRecord;
}
VOID ClrFactorySetting(VOID)
{
memset(sFactorySetting, 0, sizeof(sFactorySetting));
memset(FactoryPool, 0, sizeof(FactoryPool));
}
VOID *GetFactorySetting(CONST CHAR *name)
{
_FacSetting *setting = sFactorySetting;
_FacSetting *find = 0;
#ifdef DEBUG_PRNT
sysprintf("Enter GetFactorySetting()...\n"); // ch_20211211
#endif
while ((ULONG)setting < (ULONG)sFactorySetting + sizeof(sFactorySetting))
{
/* End of setting */
if (strlen(setting->name) == 0 || setting->size == 0)
break;
/* Find a setting by name */
if (memcmp(setting->name, name, sizeof(setting->name)) == 0)
find = setting;
setting += 1;
}
/* If not found, return 0 */
if (find == 0)
return (VOID *)0;
/* Return the data pointer */
return (VOID *)find->data;
}
VOID SetFactorySetting(CONST CHAR *name, CONST VOID *data, WORD size)
{
_FacSetting *setting = sFactorySetting;
_FacSetting *find = 0;
_FacSetting *last = 0;
#ifdef DEBUG_PRNT
sysprintf("Enter SetFactorySetting()...\n"); // ch_20211211
#endif
while ((ULONG)setting < (ULONG)sFactorySetting + sizeof(sFactorySetting))
{
/* End of setting */
if (strlen(setting->name) == 0 || setting->size == 0)
break;
/* Find a setting by name */
if (memcmp(setting->name, name, sizeof(setting->name)) == 0)
find = setting;
/* Find the last memory space */
if (last->data < setting->data)
last = setting;
setting += 1;
}
/* If not found, Add a new setting. */
if (find == 0)
find = setting;
/* Change the size of a memory block */
if (__align4(find->size) < __align4(size))
find->data = last ? ((BYTE *)last->data + __align4(last->size)) : FactoryPool;
/* Over resources */
if ((ULONG)(find + 1) >= (ULONG)sFactorySetting + sizeof(sFactorySetting))
return;
if ((ULONG)find->data + __align4(size) >= (ULONG)FactoryPool + sizeof(FactoryPool))
return;
/* Set the setting to our array */
memcpy(find->name, name, sizeof(find->name));
find->size = size;
memcpy(find->data, data, size);
}
VOID ListFactorySetting(VOID)
{
_FacSetting *setting = sFactorySetting;
INT i;
while ((ULONG)setting < (ULONG)sFactorySetting + sizeof(sFactorySetting))
{
/* End of setting */
if (strlen(setting->name) == 0 || setting->size == 0)
break;
SendPrintf("%c%c:", setting->name[0], setting->name[1]);
for (i = 0; i < setting->size; i++)
SendPrintf(" %02X", *((BYTE *)setting->data + i));
SendPrintf("\r\n");
setting += 1;
}
}
STATIC VOID LoadFactorySetting(ULONG address, ULONG length)
{
_FacSetting *setting = sFactorySetting;
BYTE *dst, *buff = FactoryPool;
ULONG src = address;
ULONG magic;
CHAR name[2];
WORD size;
INT alignSize;
#ifdef DEBUG_PRNT
sysprintf("Enter LoadFactorySetting()...\n"); // ch_20211211
#endif
/* Clear factory setting */
memset(sFactorySetting, 0, sizeof(sFactorySetting));
memset(FactoryPool, 0, sizeof(FactoryPool));
/* Load the factory magic */
dst = (BYTE *) & magic;
memcpy(dst, (VOID *)src, sizeof(magic));
src += sizeof(magic);
if (magic != FACTORY_MAGIC)
return;
while (src + sizeof(name) + sizeof(size) <= address + length)
{
/* Load the setting name */
dst = (BYTE *) & name;
memcpy(dst, (VOID *)src, sizeof(name));
src += sizeof(name);
/* Load the setting size */
dst = (BYTE *) & size;
memcpy(dst, (VOID *)src, sizeof(size));
src += sizeof(size);
/* Must be aligned with a 4-byte boundary */
alignSize = __align4(size);
/* End of setting */
if (strlen(name) == 0 || size == 0)
break;
/* Over resources */
if ((ULONG)(setting + 1) >= (ULONG)sFactorySetting + sizeof(sFactorySetting))
break;
if ((ULONG)(buff + alignSize) >= (ULONG)FactoryPool + sizeof(FactoryPool))
break;
if ((ULONG)(src + alignSize) > address + length)
break;
/* Append the setting to our array */
memcpy(setting->name, name, sizeof(name));
setting->size = size;
setting->data = buff;
setting += 1;
/* Load the setting data */
memcpy(buff, (VOID *)src, size);
buff += alignSize;
src += alignSize;
}
}
STATIC VOID SaveFactorySetting(ULONG address, ULONG length)
{
_FacSetting *setting = sFactorySetting;
ULONG magic = FACTORY_MAGIC;
ULONG dst = address;
WORD *src;
INT headSize = sizeof(setting->name) + sizeof(setting->size);
INT alignSize;
INT i;
#ifdef DEBUG_PRNT
sysprintf("Enter SaveFactorySetting()...\n"); // ch_20211211
#endif
/* Save the factory magic */
src = (WORD *) & magic;
#if defined(N3290)
memcpy((void *)dst,src,sizeof(magic));
#else
for (i = 0; i < sizeof(magic); i += sizeof(WORD))
WriteFlash(dst + i, *(src + i / sizeof(WORD)), FALSE);
#endif
dst += sizeof(magic);
while ((ULONG)setting < (ULONG)sFactorySetting + sizeof(sFactorySetting))
{
/* Must be aligned with a 4-byte boundary */
alignSize = __align4(setting->size);
/* End of setting */
if (strlen(setting->name) == 0 || setting->size == 0)
break;
/* Over resources */
if (dst + headSize + alignSize + headSize > address + length)
break;
/* Save the setting name */
src = (WORD *) & setting->name;
#if defined(N3290)
memcpy((void *)dst,src,sizeof(setting->name));
#else
for (i = 0; i < sizeof(setting->name); i += sizeof(WORD))
WriteFlash(dst + i, *(src + i / sizeof(WORD)), FALSE);
#endif
dst += sizeof(setting->name);
/* Save the setting size */
src = (WORD *) & setting->size;
#if defined(N3290)
memcpy((void *)dst,src,sizeof(setting->size));
#else
for (i = 0; i < sizeof(setting->size); i += sizeof(WORD))
WriteFlash(dst + i, *(src + i / sizeof(WORD)), FALSE);
#endif
dst += sizeof(setting->size);
/* Save the setting data */
src = (WORD *)setting->data;
#if defined(N3290)
memcpy((void *)dst,src,alignSize);
#else
for (i = 0; i < alignSize; i += sizeof(WORD))
WriteFlash(dst + i, *(src + i / sizeof(WORD)), FALSE);
#endif
dst += alignSize;
setting += 1;
}
/* Save the setting end */
#if defined(N3290)
memset((void *)dst,0,headSize);
//spiFlashPDMAWrite(address-FLASH_START_BUFFER_ADDR+BOOT_FLASH_ADDR_END,dst-(address),(UINT32 *)(address));
spiFlashWrite((address-FLASH_START_BUFFER_ADDR)+BOOT_FLASH_ADDR_END,dst-(address),(UINT32 *)(address));
#else
for (i = 0; i < headSize; i += sizeof(WORD))
WriteFlash(dst + i, 0, FALSE);
#endif
}
///
STATIC WORD ReadFlashData(ULONG addr) //机器开机会进来执行1次
{
BYTE *src, *dst;
/*
* Read the record block.
*/
src = (BYTE *)(addr + RECORD_SAVE_OFFSET);
dst = (BYTE *) & sPrintRecord;
memcpy(dst, src, sizeof(sPrintRecord));
src += sizeof(sPrintRecord);
//sysprintf("Enter ReadFlashData()...\n");
/*
* Read the factory block.
*/
LoadFactorySetting(addr + FACTORY_SAVE_OFFSET, CONFIG_SAVE_OFFSET - FACTORY_SAVE_OFFSET);
/*
* Read the configuration block.
*/
src = (BYTE *)(addr + CONFIG_SAVE_OFFSET);
dst = (BYTE *) & sPrintCfg;
memcpy(dst, src, sizeof(sPrintCfg));
src += sizeof(sPrintCfg);
//
// ch_20220607
src = (BYTE *)(addr + CAL_SAVE_OFFSET);
dst = (BYTE *) &CalRslt_Save;
memcpy(dst, src, sizeof(CalRslt_Save));
src += sizeof(CalRslt_Save);
//sysprintf("CalRslt_%d/%d/%d/%d/%d\n", CalRslt_Save.SensorMode, (WORD)CalRslt_Save.fGapSize, (WORD)CalRslt_Save.fBlineSize, CalRslt_Save.DownFilterAvg, CalRslt_Save.UpFilterAvg);
InitializeCalRslt(&CalRslt_Save); // ch_20220705
//
#if defined(ZPL2)
dst = (BYTE *) & sZebraCfg;
memcpy(dst, src, sizeof(sZebraCfg));
src += sizeof(sZebraCfg);
#endif
#if defined(DPL)
dst = (BYTE *) & sDmxCfg;
memcpy(dst, src, sizeof(sDmxCfg));
src += sizeof(sDmxCfg);
#endif
return *((WORD *)src);
}
///
STATIC VOID WriteFlashData(ULONG addr, WORD checksum) //机器开机会进来执行1次
{
ULONG dst;
WORD *src;
INT i;
_CalResult *pCalResult = NULL; // ch_20220607
#ifdef DEBUG_PRNT
sysprintf("Enter WriteFlashData()...\n"); // ch_20211211
#endif
sysprintf("Enter WriteFlashData()...\n");
/*
* Write the record block.
*/
dst = addr + RECORD_SAVE_OFFSET;
src = (WORD *) & sPrintRecord;
#if defined(N3290)
memcpy((void *)dst,src,sizeof(sPrintRecord));
#else
for (i = 0; i < sizeof(sPrintRecord); i += sizeof(WORD))
WriteFlash(dst + i, *(src + i / sizeof(WORD)), FALSE);
#endif
dst += sizeof(sPrintRecord);
/*
* Write the factory block.
*/
SaveFactorySetting(addr + FACTORY_SAVE_OFFSET, CONFIG_SAVE_OFFSET - FACTORY_SAVE_OFFSET);
/*
* Write the configuration block.
*/
dst = addr + CONFIG_SAVE_OFFSET;
src = (WORD *) & sPrintCfg;
#if defined(N3290)
memcpy((void *)dst,src,sizeof(sPrintCfg));
#else
for (i = 0; i < sizeof(sPrintCfg); i += sizeof(WORD))
WriteFlash(dst + i, *(src + i / sizeof(WORD)), FALSE);
#endif
dst += sizeof(sPrintCfg);
// ch_20220607
dst = addr + CAL_SAVE_OFFSET;
if (GetCalibratedStat()) {
pCalResult = GetCalResult();
CalRslt_Save.fGapSize = pCalResult->fGapSize;
CalRslt_Save.fBlineSize = pCalResult->fBlineSize; // ch_20220719
CalRslt_Save.SensorMode = pCalResult->SensorMode; // ch_20220705
CalRslt_Save.DownFilterAvg = pCalResult->DownFilterAvg; // ch_20220719
CalRslt_Save.UpFilterAvg = pCalResult->UpFilterAvg; // ch_20220719
}
//sysprintf("W_CalRslt_%d\n", (WORD)CalRslt_Save.fGapSize);
src = (WORD *) &CalRslt_Save;
memcpy((void *)dst, src, sizeof(CalRslt_Save));
dst += sizeof(CalRslt_Save);
#if defined(ZPL2)
src = (WORD *) & sZebraCfg;
#if defined(N3290)
memcpy((void *)dst,src,sizeof(sZebraCfg));
#else
for (i = 0; i < sizeof(sZebraCfg); i += sizeof(WORD))
WriteFlash(dst + i, *(src + i / sizeof(WORD)), FALSE);
#endif
dst += sizeof(sZebraCfg);
#endif
#if defined(DPL)
src = (WORD *) & sDmxCfg;
#if defined(N3290)
memcpy((void *)dst,src,sizeof(sDmxCfg));
#else
for (i = 0; i < sizeof(sDmxCfg); i += sizeof(WORD))
WriteFlash(dst + i, *(src + i / sizeof(WORD)), FALSE);
#endif
dst += sizeof(sDmxCfg);
#endif
#if defined(N3290)
memcpy((void *)dst,&checksum,sizeof(checksum));
dst+=sizeof(checksum);
SPI_SwitchToFlash();
spiFlashWrite((addr+RECORD_SAVE_OFFSET-FLASH_START_BUFFER_ADDR)+BOOT_FLASH_ADDR_END,dst-(addr + RECORD_SAVE_OFFSET),(UINT32 *)(addr+RECORD_SAVE_OFFSET));
#else
WriteFlash(dst, checksum, FALSE);
#endif
}
STATIC WORD CalculateStructChecksum(VOID)
{
WORD sum = 0;
BYTE *src;
INT i;
src = (BYTE *) & sPrintCfg;
for (i = 0; i < sizeof(sPrintCfg); i++)
sum += *(src + i);
#if defined(ZPL2)
src = (BYTE *) & sZebraCfg;
for (i = 0; i < sizeof(sZebraCfg); i++)
sum += *(src + i);
#endif
#if defined(DPL)
src = (BYTE *) & sDmxCfg;
for (i = 0; i < sizeof(sDmxCfg); i++)
sum += *(src + i);
#endif
return (sum ^ CHECKSUM_XOR);
}
STATIC VOID VarBankSectorErase(DWORD Address)
{
#if defined(N3290)
SPI_SwitchToFlash();
spiFlashEraseSector(Address-FLASH_START_BUFFER_ADDR+BOOT_FLASH_ADDR_END,2);
#else
DWORD EraseAddr = Address & 0xFFFFF000;
DWORD EraseLength = 0;
_FlashInfo *info;
INT sector;
if ((info = GetFlashInfo(EraseAddr)) == _NULL)
return;
sector = SearchFlashSector(info, EraseAddr);
while (EraseLength < 0x2000) // 8 KB
{
SectorErase(info->Start[sector], FALSE);
EraseLength += info->Size[sector];
sector += 1;
}
#endif
}
/*
* Calling this function, must prevent ISR from occurring in flash.
*/
VOID SaveVarBank(VOID)
{
WORD wCheckSum;
INT imask;
#ifdef DEBUG_PRNT
sysprintf("Enter SaveVarBank()...\n"); // ch_20211211
#endif
wCheckSum = CalculateStructChecksum();
imask = DisableInterrupt(FLASH_IMASK);
WriteFlashData(FIRST_SAVE_ADDR, wCheckSum);
EnableInterrupt(imask);
}
VOID ReadVarBank(VOID)
{
WORD wChecksum;
BOOL EraseFlag = TRUE;
INT imask;
#ifdef DEBUG_PRNT
sysprintf("Enter ReadVarBank()...\n"); // ch_20211211
#endif
wChecksum = ReadFlashData(FIRST_SAVE_ADDR);
// if get first sector data is not ok
debug_printf("wChecksum:%d,%d\n",wChecksum,CalculateStructChecksum());
if (wChecksum != CalculateStructChecksum())
{
wChecksum = ReadFlashData(SECOND_SAVE_ADDR);
debug_printf("SECOND_wChecksum:%d,%d\n",wChecksum,CalculateStructChecksum());
if(wChecksum != CalculateStructChecksum())
{
// Clear the diagnostic tool's password
memset(sPrintCfg.DiagPassword, 0, sizeof(sPrintCfg.DiagPassword));
InitialDefaultVar();
wChecksum = CalculateStructChecksum();
}
else
EraseFlag = FALSE;
}
// After upgrading
if (sPrintCfg.ProfileChecksum != GetProfileChecksum() ||
sPrintCfg.Checksum != APP_CODE_CHECKSUM)
{
debug_printf("Profile_wChecksum:%d,%d,%d\n",sPrintCfg.ProfileChecksum,sPrintCfg.Checksum,GetProfileChecksum());
InitialDefaultVar();
}
imask = DisableInterrupt(INTERRUPT_MASK);
if (EraseFlag == TRUE)
{
debug_printf("Erase\n");
VarBankSectorErase(SECOND_SAVE_ADDR);
WriteFlashData(SECOND_SAVE_ADDR, wChecksum);
}
VarBankSectorErase(FIRST_SAVE_ADDR);
EnableInterrupt(imask);
}
VOID CloseStrongCurrent(VOID)
{
StopTPH();
StopMotor();
StopCutter();
DisableBuzzer();
}
//#define LED1_DARK AT91F_PIO_ClearOutput(AT91C_BASE_PIOC, AT91C_PIO_PC6)
//#define LED2_DARK AT91F_PIO_ClearOutput(AT91C_BASE_PIOC, AT91C_PIO_PC7)
//#define LED1_LIGHT AT91F_PIO_SetOutput(AT91C_BASE_PIOC, AT91C_PIO_PC6)
//#define LED2_LIGHT AT91F_PIO_SetOutput(AT91C_BASE_PIOC, AT91C_PIO_PC7)
VOID PowerDownISR(VOID)
{
ULONG i;
// ch_20220120 : commented
ch_20211229
//#ifdef DEBUG_NUTOS
//NUTTHREADINFO *tdp;
//sysprintf("Enter PowerDownISR()...\n"); // ch_20211211
//while (nutThreadList)
//{
// sysprintf("%s\t", nutThreadList->td_name);
// nutThreadList = nutThreadList->td_next;
//}
//sysprintf("\nrunningThread : %s\n", runningThread->td_name);
//runQueue = *(NUTTHREADINFO **) (tdp->td_queue);
//while (runQueue/*nutThreadList*/)
//{
// sysprintf("%s\t", runQueue->td_name);
// runQueue = runQueue->td_qnxt;
//}
//sysprintf("\n");
//#endif
CLOSE_WATCH_DOG;
DisableInterrupt(INTERRUPT_MASK);
CloseStrongCurrent();
// ch_20220409
//#if defined(MONO_LED)
// ShowLED(HID_LED_IDLE, HID_LED_OFF, HID_LED_IDLE);
//#elif defined(POLY_LED)
// ShowLED(HID_LED_DARK);
//#endif
// if (!GetJobErrorState()) { // ch_20220815 : cannot save the parameters sometimes. // ch_20220510
// DisableInterrupt(INTERRUPT_MASK); // ch_20220815 : cannot save the parameters sometimes.
SaveVarBank();
// }
#if defined(MONO_LED)
ShowLED(HID_LED_IDLE, HID_LED_ON, HID_LED_IDLE);
#elif defined(POLY_LED)
// ShowLED(HID_LED_GREEN); // ch_20220409
#endif
#if defined(LCD_MODEL)
LcdSetStatus(FALSE);
#endif
while (1)
{
// ch_20220815 : cannot save the parameters sometimes.
//#if defined(MONO_LED)
// ShowLED(HID_LED_OFF, HID_LED_OFF, HID_LED_ON);
// for (i = 0; i < POWER_DOWN_DELAY_TIME; i++);
// ShowLED(HID_LED_ON, HID_LED_OFF, HID_LED_OFF);
// for (i = 0; i < POWER_DOWN_DELAY_TIME; i++);
//#elif defined(POLY_LED)
// ShowLED(HID_LED_RED);
// for (i = 0; i < POWER_DOWN_DELAY_TIME; i++);
// ShowLED(HID_LED_DARK);
// for (i = 0; i < POWER_DOWN_DELAY_TIME; i++);
//#endif
}
}
VarBank.h 。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
#ifndef VARBANK_H
/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define VARBANK_H
/******************************************************************************
* *
* C O M P I L E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* U S E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
#include "XKey.h"
#include "XNutOS.h"
#include "XEthernet.h"
#include "XComm.h"
#include "XFileSys.h"
#include "XPrtEng.h"
#include "XFuncType.h"
#include "XParser.h"
#include "XBt.h"
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
/******************************************************************************
* *
* G L O B A L D E F I N E S *
* *
******************************************************************************/
#define FACTORY_DISPLAY_CONTRAST "DC"
/******************************************************************************
* *
* S T R U C T U R E D E F I N I T I O N S *
* *
******************************************************************************/
#if defined(ZPL2)
typedef struct
{
SHORT AdjustPosition;
SHORT PrintDarkness;
SHORT MaxLabelLength;
SHORT MaxLogPaperOut;
SHORT MaxPhysPaperOut;
SHORT MaxRibbonOut;
SHORT LabelHomeX;
SHORT LabelHomeY;
SHORT LabelWidth;
SHORT LabelShift;
SHORT LabelTop;
CHAR LabelReverse;
CHAR PrintSpeed;
CHAR SlewSpeed;
CHAR BackfeedSpeed;
CHAR BackfeedSequence;
CHAR PrintMode;
CHAR Prepeel;
CHAR FeedPowerUp;
CHAR FeedCloseHead;
CHAR AutoDetectType;
CHAR CaretChar;
CHAR TildeChar;
CHAR DelimiterChar;
CHAR DotsMillimeter;
CHAR MemoryAliasB;
CHAR MemoryAliasE;
CHAR MemoryAliasR;
CHAR MemoryAliasA;
CHAR EncodingDevice;
CHAR EncodingName[13];
}_ZebraCfg;
#endif
#if defined(DPL)
typedef struct
{
CHAR ControlCodes; // (CC)
CHAR CommHeatCommands; // (CH)
CHAR CommSpeedCommands; // (CS)
CHAR CommTOFCommands; // (CT)
CHAR ESCSequences; // (ES)
CHAR IgnoreControlCodes; // (IC)
CHAR IgnoreDistances; // (IE)
CHAR DisableSymbolSet; // (NS)
CHAR MaximumLengthIgnore; // (SM)
CHAR SoftwareSwitch; // (SV)
CHAR SingleByteSymbolSet[2]; // (AS)
CHAR DoubleByteSymbolSet[2]; // (DS)
CHAR PrintSpeed; // (pS)
CHAR FeedSpeed; // (SS) or (sS)
CHAR ReverseSpeed; // (BS) or (bS)
CHAR SlewSpeed; // (FS)
CHAR CutterEquipped; // (CE)
CHAR PresentSensorEquipped; // (PS)
CHAR RibbonSaverEquipped; // (RE)
CHAR RewinderEquipped; // (RM)
CHAR VerifierEquipped; // (VE)
CHAR BackupLabel; // (BL)
CHAR EndOfPrint; // (EP) Output
CHAR StartOfPrint; // (EQ) Input
CHAR GPIOSlew; // (GS)
CHAR RibbonLowSignal; // (RS) Output
CHAR MediaType; // (MT)
CHAR SensorType; // (ST)
CHAR LabelAlignment; // (LA)
SHORT AlignmentLength; // (AL) Units:dot
SHORT ContinuousLabelLength; // (CL) Units:dot
SHORT LabelWidth; // (LW) Units:dot
SHORT MaximumLength; // (ML) Units:dot
SHORT PaperEmpty; // (PO) Units:dot
SHORT RibbonLowDiameter; // (RL) Units:dot
SHORT TOFBias; // (TB)
SHORT TOFDelta; // (TD)
SHORT TOFGain; // (TG)
SHORT NoPaperMin; // (TN)
SHORT ReflectiveTOFBias; // (RB)
SHORT ReflectiveTOFDelta; // (RD)
SHORT ReflectiveTOFGain; // (RG)
SHORT ReflectiveNoPaperMin; // (RN)
SHORT PaperValue; // (PV)
SHORT GapMarkValue; // (GM)
SHORT SensorGainValue; // (SG)
SHORT ReflectivePaperValue; // (RV)
SHORT MarkValue; // (MV)
SHORT GainReflectiveValue; // (GR)
SHORT EmptySensorLevel; // (EV)
SHORT ColumnAdjust; // (CA) Units:dot
SHORT ColumnAdjustFineTune; // (CF) Units:dot
SHORT ColumnOffset; // (CO) Units:dot
SHORT RowAdjust; // (RA) Units:dot
SHORT RowAdjustFineTune; // (RF) Units:dot
SHORT RowOffset; // (RO) Units:dot
SHORT PresentAdjust; // (PA) Units:dot
SHORT PresentAdjustFineTune; // (PJ) Units:dot
SHORT PresentDistance; // (PD) Units:dot
SHORT Heat; // (HE)
SHORT Darkness; // (DK)
SHORT PrintContrast; // (PC)
CHAR BackupAfterPrint; // (BA)
SHORT BackupDelay; // (BD) Units:ms
CHAR BritishPound; // (BP)
CHAR BuzzerEnable; // (BZ)
SHORT CutBehind; // (CB)
SHORT DPIEmulation; // (DE) Units:DPI
CHAR DefaultModule; // (DM)
SHORT DelayRate; // (DR) Units:sec
CHAR InputMode; // (EM)
CHAR ExactTime; // (ET)
CHAR FormatAttributes; // (FA)
CHAR FontEmulation; // (FE)
SHORT VoidDistance; // (FHD) Units:dot
CHAR InteractionLevel; // (FHL)
SHORT RetryCount; // (FHR)
CHAR FeedbackMode; // (FM)
CHAR GPIOEquipped; // (GE)
CHAR HeadBias; // (HB)
SHORT HeadCleaning; // (HC)
SHORT HostTimeout; // (HT) Units:sec
CHAR ImagingMode; // (IL)
SHORT InternalModule; // (IM) Units:KB
CHAR LegacyEmulation; // (LE)
CHAR LabelRotation; // (LR)
CHAR LanguageSelect[16]; // (LS)
CHAR LabelStore; // (LM)
SHORT SizeModuleG; // (MCCG) Units:KB
SHORT SizeModuleZ; // (MCCZ) Units:KB
CHAR MenuMode; // (MM)
CHAR NoReprint; // (NR)
CHAR OptionFeedback; // (OF)
CHAR PeelMode; // (PE)
CHAR PrinterLevel[3]; // (PL)
CHAR PauseMode; // (PM)
CHAR Password[4]; // (PW)
CHAR RibbonLowPause; // (RP)
SHORT RewinderAdjust; // (RR)
SHORT RetractDelay; // (RW) Units:ms
SHORT SOPAdjust; // (SA) Units:dot
SHORT ScalableCache; // (SC) Units:KB
CHAR SOPEmulation; // (SE)
SHORT ScalableHeap; // (SH) Units:KB
CHAR SecurityLock; // (Sl)
CHAR StopLocation; // (SL)
CHAR TOFPrecedence; // (TP)
CHAR UnitMeasure; // (UM)
CHAR VerifierType; // (VT)
CHAR EnableDHCP; // (NTD)
CHAR EnableSNMP; // (NTT)
CHAR EnableWiFi; // (NTw)
USHORT PortNumber; // (NTP)
ULONG AddressIP; // (NTI)
ULONG SubnetMask; // (NTS)
ULONG AddressGateway; // (NTG)
ULONG AddressSNMP; // (NTN)
ULONG AddressWINS1; // (NTW)
ULONG AddressWINS2; // (NTU)
ULONG AddressDNS1; // (NTY)
ULONG AddressDNS2; // (NTZ)
CHAR WiFiSSID[8]; // (WEA)
CHAR WiFiChannel; // (WEC)
CHAR WiFiEnableDHCP; // (WEF)
ULONG WiFiAddressIP; // (WEI)
SHORT WiFiAcquireTimeDHCP; // (WEL) Units:sec
CHAR WiFiMaximumRate; // (WEM)
CHAR WiFiClientName[33]; // (WEN)
CHAR WiFiPointDensity; // (WEP)
CHAR WiFiRegion[2]; // (WER)
CHAR WiFiType; // (WET)
SHORT WiFiRetransmitDHCP; // (WEV) Units:sec
CHAR WiFiEnableMAC; // (WEX)
CHAR WiFiSecurity; // (WS)
}_DmxCfg;
#endif
typedef struct//sPrintDefault
{
#if defined(NUTOS)
CONFOS confos; // Nut/OS configuration
#endif
#if defined(NUTNET)
CONFNET confnet; // Network configuration
CONFSMTP confsmtp; // SMTP configuration
CONFSNTP confsntp; // SNTP configuration
CONFWEB confweb; // WEB configuration
#endif
#if defined(UART2_BT)
_BtSetting BtSetting;
#endif
_GPISetting GPInSetting[GPI_TOTAL]; // GPIO input function setting
_GPOSetting GPOutSetting[GPO_TOTAL]; // GPIO output function setting
_KeySetting KeySetting[KEY_TOTAL]; // Key function setting
_UartSetting UartSetting; // Uart Setting
_eSensorMode SensorMode; // Sensor mode
_eMotorDir MotorDir; // MotorDirection
_ePrintOutMode PrintOutMode; // Print Out Mode
_eDebugMode DebugMode; // DEBUG mode
FLOAT fDensity; // Print Density
FLOAT fPaperSize; // Paper Size
FLOAT fGapSize; // Gap Size
FLOAT fBlineSize; // Bline Size
FLOAT fGapOffset; // Gap size offset
FLOAT fBlineOffset; // Bline size offset
ULONG Direction:1, // Direction
Mirror:1, // Mirror
CarriageOpen:1, // Carriage Open enable or not
TestBurn:1, // Factory Test Flag
TearMode:1, // Tear Mode Flag
GapReverse:1, // Reverse the gap sensor signal
AutoSensorRef:1, // Automatic sensor reference
Measure:1, // Measure before printing
Calibrate:1, // Calibrate before printing
RibbonFlag:1, // Ribbon Mode Flag
RibbonEncoder:1, // Ribbon Encoder Flag
RibbonInside:1, // Ribbon inside
IgnoreAutoRun:1, // Ignore AUTO.BAS
Reprint:1, // Reprint enable or disable
PrintKey:1, // Print key Func
ReprintKey:1, // Reprint key Func
Verifier:1, // Barcode verifier
CutterBack:1, // Return after finishing cutting
CutterTPU:1, //TPU function
CutterContinuous:1,
SuppressBack:1, // Suppress backfeed
Dummy:11; // Dummy // ch_20220623 : changed to 11 from 13.
ULONG Checksum; // Firmware checksum
ULONG ProfileChecksum; // Profile checksum
ULONG CutterPieces; // Cutter pieces
ULONG PrintKeyCnt; // Print key counter
ULONG ReprintKeyCnt; // Reprint key counter
ULONG LimitSpeed:2,
LimitDensity:2,
LimitPaperSize:2,
LimitPaperWidth:2,
LimitBline:2,
LimitGap:2,
LimitOutPeel:2,
LimitOutCut:2,
LimitOutOff:2,
LimitOutTear:2,
LimitDirection:2,
LimitMirror:2,
LimitCodepage:2,
LimitDummy:6;
WORD GapRef; // Gap sensor reference
WORD BlineRef; // Bline sensor reference
WORD ContinuousRef; // Continue paper sensor reference
WORD RibbonRef; // Ribbon sensor reference
WORD IgnoreSize; // Ignore small Gap & Bline Size
WORD ContinuePaperFeed; // continue paper feed length
WORD PaperWidth; // Paper Width
WORD OverHeat; // TPH Over Heat
WORD PrintHeat; // TPH can reprint
WORD MotorOverHeat; // Motor Over Heat
WORD MotorMoveHeat; // Motor can move
WORD OverHead; // Print out distance
WORD LimitFeed; // limit feed
WORD WaitJobTime; // Waiting next job time
WORD FeedLength; // Feed the length of paper
WORD NetRawPort; // Base raw port number
SHORT AdjustHead; // Adjust head position
SHORT OffsetDis; // Cutter offset
SHORT ReferenceX; // Image X shift
SHORT ReferenceY; // Image Y shift
SHORT ShiftDisX; // Print X shift
SHORT ShiftDisY; // Print Y shift
BYTE UsbSerialMode; //Usb Serial Mode
BYTE Speed; // Print Speed
BYTE Language; // Display language
BYTE Country; // Country code
BYTE CodePage; // Code Page
BYTE GapInten; // Gap sensor intension
BYTE BlineInten; // Bline sensor intension
BYTE ContinuousInten; // Continue paper sensor intension
BYTE RibbonInten; // Ribbon sensor intension
BYTE LedSelect; // LED set flag
BYTE AutoRun[FILENAME_LENGTH]; // File name of auto run
BYTE DiagPassword[32]; // Diagnostic tool's password
BYTE InputPrefix[4][16]; // INPUT prefix for MIDAMERICA
BYTE InputSuffix[4][16]; // INPUT suffix for MIDAMERICA
BYTE CounterData[10][32]; // Keep counter data
INT CounterStep[10]; // Keep counter step
#if defined(EPL2)
WORD LineSpace; // Line mode row spacing (in dot)
WORD LineFontWidth; // Line mode font width
WORD LineFontHeight; // Line mode font height
BYTE LineFont[FILENAME_LENGTH]; // Line mode font name
BYTE EplDataBit; // Epl code page data bit
BYTE EplCodePage; // Epl Code Page
BYTE EplCountryCode; // Epl Country code
BYTE EuroReplace; // Epl Euro replace
BYTE WaitPrint; // Epl single buffer wait print
BYTE WinDriver; // Windows driver enable flag
BYTE ClrBuffer; // When Error Clear image buffer
BYTE ErrorReport; // Auto Error Report
BYTE ErrorAuto; // Auto error response
BYTE ErrorStart; // Error Start character
volatile BYTE my_encode_flag;
volatile INT my_encode_count;
volatile INT my_last_en_count;
#endif
}_PrintCfg;//sPrintDefault
typedef struct
{
INT LabelMilage;
INT DotMilage;
BYTE UniqueMAC[6];
CHAR PrintServerName[16];
CHAR SerialNumberName[26];
CHAR FactorySerialNumberName[26];
CHAR TPHSerialNumberName[26];
INT UnRegMilage;
BYTE UidName[8];
INT CutCounter;
INT UsbSerial;
}_PrintRecord;
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - N O I N I T I A L I Z E R S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* G L O B A L V A R I A B L E S - I N I T I A L I Z E R S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
VOID InitialDefaultVar(VOID);
VOID InitialVarBank(VOID);
#if defined(ZPL2)
_ZebraCfg *GrabZebraDefault(VOID);
_ZebraCfg *GrabZebraConfig(VOID);
#endif
#if defined(DPL)
_DmxCfg *GrabDatamaxDefault(VOID);
_DmxCfg *GrabDatamaxConfig(VOID);
#endif
_PrintCfg *GrabPrintConfig(VOID);
_CalResult *GrabCalResult(VOID); // ch_20220607
_PrintRecord *GrabPrintRecord(VOID);
VOID ClrFactorySetting(VOID);
VOID *GetFactorySetting(CONST CHAR *name);
VOID SetFactorySetting(CONST CHAR *, CONST VOID *, WORD);
VOID ListFactorySetting(VOID);
VOID SaveVarBank(VOID);
VOID ReadVarBank(VOID);
VOID CloseStrongCurrent(VOID);
VOID PowerDownISR(VOID);
FLOAT ProfileLimit(CHAR *);
//INT spiFlashPDMAWrite(UINT32 addr, UINT32 len, UINT32 *buf);
#ifdef __cplusplus
} /* End of extern "C" { */
#endif /* __cplusplus */
#endif