From 304504bdfa5a7fff5598c85264de9bc5b7ed12c6 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 15 Feb 2012 19:34:31 -0600 Subject: [PATCH] initial commit --- .cdtbuild | 77 ++ .cdtproject | 18 + .project | 84 ++ auto-generated.mk | 72 ++ package.psml | 14 + rsc/AppResources.xrd | 357 ++++++++ rsc/bitmaps/AppIcon_Large-1.bmp | Bin 0 -> 150 bytes rsc/bitmaps/AppIcon_Large-2.bmp | Bin 0 -> 382 bytes rsc/bitmaps/AppIcon_Large-8.bmp | Bin 0 -> 1606 bytes rsc/bitmaps/AppIcon_Small-1.bmp | Bin 0 -> 98 bytes rsc/bitmaps/AppIcon_Small-2.bmp | Bin 0 -> 190 bytes rsc/bitmaps/AppIcon_Small-8.bmp | Bin 0 -> 1222 bytes src/AppMain.c | 962 ++++++++++++++++++++ src/AppMain.h | 25 + src/AppResources.h | 65 ++ src/BCS2ScannerLib.h | 526 +++++++++++ src/JanamExtended.h | 58 ++ src/JanamExtendedDef.h | 231 +++++ src/JanamExtendedStruct.h | 342 +++++++ src/JanamScnCompatible.h | 124 +++ src/MeazuraLib_V305.h | 1496 +++++++++++++++++++++++++++++++ src/ScanMgr.h | 231 +++++ src/ScanMgrDef.h | 237 +++++ src/ScanMgrStruct.h | 299 ++++++ src/ScanWedge.h | 72 ++ 25 files changed, 5290 insertions(+) create mode 100644 .cdtbuild create mode 100644 .cdtproject create mode 100644 .project create mode 100644 auto-generated.mk create mode 100644 package.psml create mode 100644 rsc/AppResources.xrd create mode 100644 rsc/bitmaps/AppIcon_Large-1.bmp create mode 100644 rsc/bitmaps/AppIcon_Large-2.bmp create mode 100644 rsc/bitmaps/AppIcon_Large-8.bmp create mode 100644 rsc/bitmaps/AppIcon_Small-1.bmp create mode 100644 rsc/bitmaps/AppIcon_Small-2.bmp create mode 100644 rsc/bitmaps/AppIcon_Small-8.bmp create mode 100644 src/AppMain.c create mode 100644 src/AppMain.h create mode 100644 src/AppResources.h create mode 100644 src/BCS2ScannerLib.h create mode 100644 src/JanamExtended.h create mode 100644 src/JanamExtendedDef.h create mode 100644 src/JanamExtendedStruct.h create mode 100644 src/JanamScnCompatible.h create mode 100644 src/MeazuraLib_V305.h create mode 100644 src/ScanMgr.h create mode 100644 src/ScanMgrDef.h create mode 100644 src/ScanMgrStruct.h create mode 100644 src/ScanWedge.h diff --git a/.cdtbuild b/.cdtbuild new file mode 100644 index 0000000..9107c1f --- /dev/null +++ b/.cdtbuild @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.cdtproject b/.cdtproject new file mode 100644 index 0000000..4b3049e --- /dev/null +++ b/.cdtproject @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..bbe19fa --- /dev/null +++ b/.project @@ -0,0 +1,84 @@ + + + RattailPalm + + + + + + com.palmsource.eclipse.palmoscore.palmOSBuildToolsVerifier + + + + + com.palmsource.eclipse.palmoscore.palmOSMakeBuilder + + + DATABASE_RESET + + + + DATABASE_BUNDLE + + + + CREATOR_ID + RTTL + + + DATABASE_BACKUP + -b + + + DB_TYPE + appl + + + PROJECT_VERSION + 10100 + + + DATABASE_PROTECT + + + + SDK + com.palmsource.eclipse.sdk.palmos5 + + + DB_NAME + Rattail + + + DATABASE_HIDDEN + + + + DATABASE_VERSION + 1 + + + OS_API + 68K + + + PROJECT_TYPE + appl + + + + + com.palmsource.eclipse.palmos4dev.palmOS4GeneratedMakefileBuilder + + + + + + com.palmsource.eclipse.palmos4dev.palmOS68KManagedNature + com.palmsource.eclipse.palmoscore.palmOSManagedNature + com.palmsource.eclipse.palmoscore.palmOSNature + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.core.ccnature + + diff --git a/auto-generated.mk b/auto-generated.mk new file mode 100644 index 0000000..7efba20 --- /dev/null +++ b/auto-generated.mk @@ -0,0 +1,72 @@ +# This file auto-generated by Garnet OS Make builder. Don't modify directly!!! + +# This value is unescaped. Either quote the value or escape special characters when you use it. +ifeq ($(TOOLS_DIR), ) + TOOLS_DIR = C:/Program Files/ACCESS/Garnet OS Development Suite/PalmOSTools/ +endif + +# This value is unescaped. Either quote the value or escape special characters when you use it. +ifeq ($(SDK_LOCATION), ) + SDK_LOCATION = C:/Program Files/ACCESS/Garnet OS Development Suite/sdk-5r4/ +endif + +ifeq ($(SDK_VERSION), ) + SDK_VERSION = sdk-5r4 +endif + +ifeq ($(DATABASE_BUNDLE), ) + DATABASE_BUNDLE = +endif + +ifeq ($(DATABASE_RESET), ) + DATABASE_RESET = +endif + +ifeq ($(CREATOR_ID), ) + CREATOR_ID = RTTL +endif + +ifeq ($(DATABASE_BACKUP), ) + DATABASE_BACKUP = -b +endif + +ifeq ($(DB_TYPE), ) + DB_TYPE = appl +endif + +ifeq ($(PROJECT_VERSION), ) + PROJECT_VERSION = 10100 +endif + +ifeq ($(SDK), ) + SDK = com.palmsource.eclipse.sdk.palmos5 +endif + +ifeq ($(DATABASE_PROTECT), ) + DATABASE_PROTECT = +endif + +ifeq ($(DB_NAME), ) + DB_NAME = Rattail +endif + +ifeq ($(DATABASE_HIDDEN), ) + DATABASE_HIDDEN = +endif + +ifeq ($(DATABASE_VERSION), ) + DATABASE_VERSION = 1 +endif + +ifeq ($(OS_API), ) + OS_API = 68K +endif + +ifeq ($(PROJECT_TYPE), ) + PROJECT_TYPE = appl +endif + +ifeq ($(ARTIFACT_NAME), ) + ARTIFACT_NAME = RattailPalm +endif + diff --git a/package.psml b/package.psml new file mode 100644 index 0000000..ab1f867 --- /dev/null +++ b/package.psml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/rsc/AppResources.xrd b/rsc/AppResources.xrd new file mode 100644 index 0000000..762a6f8 --- /dev/null +++ b/rsc/AppResources.xrd @@ -0,0 +1,357 @@ + + + + + + INFORMATION_ALERT + 0 + 0 + "Testing Things" + "OMGWTFBBQ !!" + + "OK" + + + + + + + 22 + 22 + 1 + NONE + FALSE + FALSE + "./bitmaps/AppIcon_Large-1.bmp" + + + 22 + 22 + 2 + NONE + FALSE + FALSE + "./bitmaps/AppIcon_Large-2.bmp" + + + 22 + 22 + 8 + NONE + TRUE + + 0xD2 + + FALSE + "./bitmaps/AppIcon_Large-8.bmp" + + + + + + + + 15 + 9 + 1 + NONE + FALSE + FALSE + "./bitmaps/AppIcon_Small-1.bmp" + + + 15 + 9 + 2 + NONE + FALSE + FALSE + "./bitmaps/AppIcon_Small-2.bmp" + + + 15 + 9 + 8 + NONE + TRUE + + 0xCC + + FALSE + "./bitmaps/AppIcon_Small-8.bmp" + + + + + + "Rattail" + + + + 1000 + + 0 + 0 + 160 + 160 + + TRUE + FALSE + FALSE + 0 + 1000 + 0 + FALSE + FALSE + + + "Rattail" + + + 1000 + + 1 + 148 + 75 + 12 + + TRUE + TRUE + TRUE + FALSE + SOLID_UNDERLINE + LEFT_ALIGN + TRUE + FALSE + FALSE + 14 + STD_FONT + 0 + + + 1001 + + 140 + 148 + 18 + 12 + + TRUE + TRUE + TRUE + FALSE + SOLID_UNDERLINE + RIGHT_ALIGN + FALSE + FALSE + TRUE + 3 + STD_FONT + 0 + + + 1002 + + 123 + 148 + 19 + 12 + + TRUE + TRUE + "" + STD_FONT + 0 + FALSE + + + 1003 + + 99 + 148 + 18 + 12 + + TRUE + TRUE + TRUE + FALSE + SOLID_UNDERLINE + RIGHT_ALIGN + FALSE + FALSE + TRUE + 3 + STD_FONT + 0 + + + 1004 + + 82 + 148 + 19 + 12 + + TRUE + TRUE + "" + STD_FONT + 0 + FALSE + + + 1005 + + 0 + 16 + 153 + 120 + + FALSE + + 80 + 30 + 30 + + + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + + + + 1006 + + 153 + 16 + 7 + 120 + + TRUE + 0 + 0 + 0 + 11 + + + + + + 1100 + + 2 + 2 + 156 + 156 + + TRUE + TRUE + TRUE + 0 + 0 + 0 + FALSE + FALSE + + + "About Rattail" + + + 1102 + + 38 + 27 + + TRUE + LARGE_BOLD_FONT + "Rattail for Palm" + + + 1103 + + 16 + 78 + + TRUE + STD_FONT + "Copyright © 2012 Lance Edgar" + + + 1104 + + 50 + 53 + + TRUE + BOLD_FONT + "Version 1.0" + + + 1105 + + 58 + 139 + 40 + 12 + + TRUE + TRUE + "OK" + TRUE + STD_FONT + STANDARD_BUTTON_FRAME + + + 1000 + + 26 + 105 + + TRUE + STD_FONT + "http://rattail.edbob.org/" + + + + + + TRUE + + + "Options" + FALSE + + 6 + 14 + 100 + 11 + + + 4 + 0 + 47 + 12 + + + + 1000 + "About Rattail" + "" + FALSE + + + + + + + diff --git a/rsc/bitmaps/AppIcon_Large-1.bmp b/rsc/bitmaps/AppIcon_Large-1.bmp new file mode 100644 index 0000000000000000000000000000000000000000..854ed815a382ad3b6dae91e432b03146cfba73de GIT binary patch literal 150 zcmZ?royGtGc0fu4h{d3ok%18+0VIXEAs8+IWc>gCpW%N41H&KY4-6le|1k6bv4j5~ z2EP4&7=G0MVfgs}55r?1<_BUs{yz*A?0*;v-TyEYssCYc1G3eC^yK${7#_$2)!YAJ P_%9#B@c#qI+y({!WKk}r literal 0 HcmV?d00001 diff --git a/rsc/bitmaps/AppIcon_Large-2.bmp b/rsc/bitmaps/AppIcon_Large-2.bmp new file mode 100644 index 0000000000000000000000000000000000000000..53f66e2b332470c61b8e933640671cba50d0d7ea GIT binary patch literal 382 zcmY+9F>-@26hxO9tBDH_E^+{>^xVKh>lrn_QIn1%gf2B#prfJD6}SRd;0koE@vdYt zu|{7kyN|EW?fzRJtskCWtj|{!I3-`l^_=T4_I<~;ZCKY8%d%jeXT%sW3| z+ZJYqrfE>uHL9vYS(ZnO_ooG-CeI~B?eulSB0;Bow$DxD2WbJs<$T5g(Y4+SyFZnN0pn?7wjNVc* EPjhHLD*ylh literal 0 HcmV?d00001 diff --git a/rsc/bitmaps/AppIcon_Large-8.bmp b/rsc/bitmaps/AppIcon_Large-8.bmp new file mode 100644 index 0000000000000000000000000000000000000000..3b9fa9e0b6291114a79fdc3ba2b7ca1a5abbee73 GIT binary patch literal 1606 zcmc(cyKNmY5Jks;VHj{E2L_lba?Al-fFU?@s213QQiW<^3fM#~C{Y2-h4*&(Yd|fm z&u~{Yn2WnlIwbGR-2MIc&lj2N*JqKR{PpA1C;578@c#bo&eq(1hBSQ%(;zovNc!pJi{|Q z!!z7(7~J3nH@Lz5+4qDGGL(=aN%$amhG%$&XSl%)Zg7Je+~E7J_#i_GDH6p8!81I= zGd#l$Zg7Je+~5W$HhhqwgcR`+h!P(Jr#wCgPQ3UaI4$9W;0dF|rNn_m{)zm3GKDK# z;R;u{cRCAu5jTW$5Et&yOrmh2NFx74{+@)w6|QiFE8HiW&3mKX6r4leJwBvF^NB_i z`6u%Cfgc}} zUms^46uG&%k=xr_xx2fQ`}=!&czBSfrzd%SewLS)7b&I4`}@1RzP@tlaX!4{5&fUl zyVpJ5X9skj1X!Fql5q-(n{f6+^(_B6(YR17(*?!ly;4w_1;?x zO{CUP1v4*YmnUBxrbCoz&A};mA-7EO&Aq4O{t!vj7{3=#*)0|34+ B4c7nw literal 0 HcmV?d00001 diff --git a/rsc/bitmaps/AppIcon_Small-2.bmp b/rsc/bitmaps/AppIcon_Small-2.bmp new file mode 100644 index 0000000000000000000000000000000000000000..07881eb37f9858f952219b701b4219664a074eae GIT binary patch literal 190 zcmZ?r-Nyg{Wk5;;i1~q-6NniZSb!u12yrtofG`aF|No!i-Me=TckkY1ICJIFqk@I3)6y9g=}G3U<*nVIhq#Of?7DeIZA*F zFwDcppSQQOyK~a7-+w-?{q@7=ci+CsXZf%`?LKeczTEQ;+qSK(r6eW9)x3H0=FOWI zFJ8QO@tPT%(Uy{w5Hp%LZ{EE5T*ZqQFJ8Q6g-x}Vl9Z4c;mw;jZ$2}M7cXAC_*~nT z>PSgS$VzpDH*em&dGX@Kix)4xZJ~~oq=c+cM|kt*&6^i5Uc7km;@YN;l%#}s2wJI* zaLcPBTzl0KZcFM2PleK?bVKTY>i?W9c<|uCgU?R)g=di|$la)lIX06PPK%`er~XeT zf(H*CJoub!-~4QJHpSgEyH`h-Y(8x?^*{B0Iu|^6@ZiCx6MF;ZuyZi(hB>V|sg5{o z>VNA0T)~3}4<0=D-o$CxG>03U?x2r>=-?-M{a9GFVah*=5bv~ch!^6Y6TrTT+y{@OH zr**sC*2~MwdVYR3>2bfjtw;G^FaMj}Kj*c7^SAi+^A7WSAAP&yU;KVAI7{v8{k{Gx DNL!v^ literal 0 HcmV?d00001 diff --git a/src/AppMain.c b/src/AppMain.c new file mode 100644 index 0000000..1c32aa2 --- /dev/null +++ b/src/AppMain.c @@ -0,0 +1,962 @@ +/****************************************************************************** + * + * Copyright (c) 2007, ACCESS Systems Americas, Inc. All Rights Reserved. + * + * File: AppMain.c + * + *****************************************************************************/ + +#include + +// BCS2 Scanner +#include "BCS2ScannerLib.h" + +// Janam Scanner +#include "JanamScnCompatible.h" +#include "ScanMgr.h" + +// Rattail App +#include "AppResources.h" +#include "AppMain.h" + + +/*********************************************************************** + * + * Entry Points + * + ***********************************************************************/ + + +/*********************************************************************** + * + * Internal Constants + * + ***********************************************************************/ +#define appFileCreator 'RTTL' // register your own at http://www.palmos.com/dev/creatorid/ +#define appVersionNum 0x01 +#define appPrefID 0x00 +#define appPrefVersionNum 0x01 +#define appDbRattail "Rattail" +#define appDbRattailScan "Rattail_Scan" + +#define COLUMN_BARCODE 0 +#define COLUMN_CASES 1 +#define COLUMN_UNITS 2 + + +/*********************************************************************** + * + * Global Variables + * + ***********************************************************************/ +UInt16 cardNo = 0; +UInt16 gBcs2RefNum = 0; +Boolean gBabbo = false; +//UInt16 gNumCols = 3; +//UInt16 gNumRows = 11; +//MemHandle gHandles[11][3]; +Int16 gTopVisibleRecord = -1; + + +/*********************************************************************** + * + * FUNCTION: AppHandleEvent + * + * DESCRIPTION: This routine loads form resources and set the event + * handler for the form loaded. + * + * PARAMETERS: event - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean AppHandleEvent(EventType* pEvent) +{ + UInt16 formId; + FormType* pForm; + Boolean handled = false; + + if (pEvent->eType == frmLoadEvent) { + // Load the form resource. + formId = pEvent->data.frmLoad.formID; + + pForm = FrmInitForm(formId); + FrmSetActiveForm(pForm); + + // Set the event handler for the form. The handler of the currently + // active form is called by FrmHandleEvent each time is receives an + // event. + switch (formId) { + case MainForm: + FrmSetEventHandler(pForm, MainFormHandleEvent); + break; + + default: + break; + } + handled = true; + } + + return handled; +} + + +/*********************************************************************** + * + * FUNCTION: AppStart + * + * DESCRIPTION: Get the current application's preferences. + * + * PARAMETERS: nothing + * + * RETURNED: Err value errNone if nothing went wrong + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Err AppStart(void) +{ + OpenBCS2Scanner(); + //OpenBabboScanner(); + + FrmGotoForm(MainForm); + return errNone; +} + + +/*********************************************************************** + * + * FUNCTION: AppStop + * + * DESCRIPTION: Save the current state of the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + ***********************************************************************/ +static void AppStop(void) +{ + CloseBCS2Scanner(); + //CloseBabboScanner(); + + FrmCloseAllForms(); +} + + +/*********************************************************************** + * + * FUNCTION: AppEventLoop + * + * DESCRIPTION: This routine is the event loop for the application. + * + * PARAMETERS: nothing + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static void AppEventLoop(void) +{ + Err error; + EventType event; + + do { + EvtGetEvent(&event, evtWaitForever); + + if (SysHandleEvent(&event)) + continue; + + if (MenuHandleEvent(0, &event, &error)) + continue; + + if (AppHandleEvent(&event)) + continue; + + FrmDispatchEvent(&event); + + } while (event.eType != appStopEvent); +} + + +/*********************************************************************** + * + * FUNCTION: CloseBabboScanner + * + ***********************************************************************/ +/* +static void CloseBabboScanner() +{ + if (! gBabbo) + return; + + ScnCmdScanDisable(); + ScnCloseDecoder(); + gBabbo = false; +} +*/ + + +/*********************************************************************** + * + * FUNCTION: CloseBCS2Scanner + * + ***********************************************************************/ + +static void CloseBCS2Scanner() +{ + LocalID dbId; + + if (! gBcs2RefNum) + return; + + dbId = DmFindDatabase(cardNo, appDbRattail); + if (dbId) + SysNotifyUnregister(cardNo, dbId, BCS2BarCodeReadyNotification, + sysNotifyNormalPriority); + BCS2LibClose(gBcs2RefNum); + SysLibRemove(gBcs2RefNum); + gBcs2RefNum = 0; +} + + +/*********************************************************************** + * + * FUNCTION: CreateScanDatabase + * + ***********************************************************************/ + +static DmOpenRef CreateScanDatabase() +{ + Err err; + LocalID dbId; + UInt16 attrs, version; + DmOpenRef db; + + err = DmCreateDatabase(cardNo, appDbRattailScan, appFileCreator, 'SCAN', false); + if (err != errNone) + return NULL; + + dbId = DmFindDatabase(cardNo, appDbRattailScan); + if (dbId == 0) + return NULL; + + // Set backup flag, version for database. + attrs = dmHdrAttrBackup; + version = 1; + DmSetDatabaseInfo(cardNo, dbId, NULL, &attrs, &version, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL); + + db = DmOpenDatabase(cardNo, dbId, dmModeWrite); + if (db == 0) + return NULL; + + return db; +} + + +/*********************************************************************** + * + * FUNCTION: DrawCustomTableItem + * + ***********************************************************************/ + +static void DrawCustomTableItem(void* table, Int16 row, Int16 col, RectangleType* bounds) +{ + Char * text; + UInt16 size; + Coord x; + + text = (Char *) TblGetItemPtr(table, row, col); + if (*text != 0) { + size = StrLen(text); + + if (col == 0) { // barcode + WinDrawChars(text, size, bounds->topLeft.x, bounds->topLeft.y); + + } else { // cases or units + + // Only draw value if nonzero. + if (StrCompareAscii(text, "0") != 0) { + + // Draw value right-aligned. + x = bounds->topLeft.x + bounds->extent.x - FntCharsWidth(text, size); + WinDrawChars(text, size, x, bounds->topLeft.y); + } + } + + } +} + + +/*********************************************************************** + * + * FUNCTION: GetActiveFieldId + * + ***********************************************************************/ + +static UInt16 GetActiveFieldId(FormPtr form) +{ + FieldPtr field; + UInt16 index; + + field = FrmGetActiveField(form); + if (field == NULL) { + return NULL; + } + + index = FrmGetObjectIndexFromPtr(form, field); + if (index == frmInvalidObjectId) { + return NULL; + } + + return FrmGetObjectId(form, index); +} + +/*********************************************************************** + * + * FUNCTION: GetCheckedValue + * + ***********************************************************************/ + +static Int16 GetCheckedValue(UInt16 objId) +{ + FormPtr form; + ControlPtr check; + + form = FrmGetActiveForm(); + check = GetObjectPtrById(form, objId); + if (check == NULL) { + return false; + } + + return CtlGetValue(check); +} + +/*********************************************************************** + * + * FUNCTION: GetObjectPtrById + * + ***********************************************************************/ + +static void *GetObjectPtrById(FormPtr form, UInt16 objId) +{ + UInt16 index; + + index = FrmGetObjectIndex(form, objId); + if (index == frmInvalidObjectId) { + return NULL; + } + + return FrmGetObjectPtr(form, index); +} + + +/*********************************************************************** + * + * FUNCTION: MainFormDoCommand + * + * DESCRIPTION: This routine performs the menu command specified. + * + * PARAMETERS: command - menu item id + * + * RETURNED: nothing + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormDoCommand(UInt16 command) +{ + Boolean handled = false; + FormType * pForm; + + switch (command) { + case MainOptionsAboutStarterApp: + pForm = FrmInitForm(AboutForm); + FrmDoDialog(pForm); // Display the About Box. + FrmDeleteForm(pForm); + handled = true; + break; + + } + + return handled; +} + + +/*********************************************************************** + * + * FUNCTION: MainFormHandleEvent + * + * DESCRIPTION: This routine is the event handler for the + * "MainForm" of this application. + * + * PARAMETERS: pEvent - a pointer to an EventType structure + * + * RETURNED: true if the event has handle and should not be passed + * to a higher level handler. + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +static Boolean MainFormHandleEvent(EventPtr event) +{ + Boolean handled = false; + FormPtr form; + TablePtr table; + UInt16 objId; + + switch (event->eType) { + + case frmOpenEvent: + form = FrmGetActiveForm(); + MainFormInit(form); + FrmDrawForm(form); + handled = true; + break; + + case menuEvent: + handled = MainFormDoCommand(event->data.menu.itemID); + break; + + case sclRepeatEvent: + if (event->data.sclRepeat.newValue > event->data.sclRepeat.value) + gTopVisibleRecord += (event->data.sclRepeat.newValue - event->data.sclRepeat.value); + else { + gTopVisibleRecord -= (event->data.sclRepeat.value - event->data.sclRepeat.newValue); + } + form = FrmGetActiveForm(); + table = GetObjectPtrById(form, MainFormScanRecords); + MainFormLoadTable(table, false); + TblRedrawTable(table); + break; + + case keyDownEvent: + form = FrmGetActiveForm(); + + // Pressing the ENTER (line feed) key will either advance focus + // to the next quantity field marked to be stopped upon, or else + // will validate and store the current data as a new scan record. + if (event->data.keyDown.chr == 10) { // line feed (ENTER) + objId = GetActiveFieldId(form); + if (objId == MainFormBarcode) { + ProcessScan(); + } else if (objId == MainFormCases) { + if (GetCheckedValue(MainFormStopOnUnits)) { + SetFieldFocus(MainFormUnits); + } else { + StoreScanData(); + } + } else if (objId == MainFormUnits) { + StoreScanData(); + } + + // Until I have more to go on, I'm assuming that if a handheld has + // a BCS2-capable scanner, then it is an Aceeca Meazura, and that its + // "center" navigational (hardware) key should be used as the scan + // trigger. + } else if (event->data.keyDown.chr == MzVCentreKey) { + if (gBcs2RefNum) { + if (FrmGetFocus(form) == FrmGetObjectIndex(form, MainFormBarcode)) + BCS2LibTriggerOn(gBcs2RefNum); + } + + /* + // Handle Babbo key + } else if ((event->data.keyDown.chr & vchrScanKey && + (event->data.keyDown.keyCode == scanBitHard1)) || + ((event->data.keyDown.chr & vchrScanKey) && + (event->data.keyDown.keyCode == scanBitHard2))) { + if (gBabbo) { + if (ScnCmdStartDecode() != STATUS_OK) { + SysFatalAlert("Start decode failed!"); + } + handled = true; + } + */ + } + break; + + /* + // This event is passed by Babbo scanners (Janam handhelds). + case scanDecodeEvent: + if (gBabbo) { // just to be sure? + if (ScnCmdBeep(One_Short_Low) != STATUS_OK) { + SysFatalAlert("Beep failed!"); + } + } + break; + */ + + default: + break; + } + + return handled; +} + + +/*********************************************************************** + * + * FUNCTION: MainFormInit + * + ***********************************************************************/ + +static void MainFormInit(FormPtr form) +{ + TablePtr table; + Int16 cols, col, rows, row; + UInt16 index; + ControlPtr ctrl; + + table = GetObjectPtrById(form, MainFormScanRecords); + //TblHasScrollBar(table, true); + + cols = TblGetNumberOfColumns(table); + rows = TblGetNumberOfRows(table); + for (col = 0; col < cols; col++) { + TblSetCustomDrawProcedure(table, col, DrawCustomTableItem); + TblSetColumnUsable(table, col, true); + for (row = 0; row < rows; row++) { + TblSetItemStyle(table, row, col, customTableItem); + TblSetRowUsable(table, row, false); + } + } + + MainFormLoadTable(table, true); + TblRedrawTable(table); + + index = FrmGetObjectIndex(form, MainFormCases); + ctrl = FrmGetObjectPtr(form, index); + FldInsert((FieldPtr) ctrl, "0", 1); + + // Unit quantity field is "stoppable" by default, unless the scanner is + // BCS2-capable, in which case I assume the handheld is an Aceeca Meazura + // model. Since this model doesn't have numeric keys, I figure it can't + // really support counting (yet?). + if (! gBcs2RefNum) { + index = FrmGetObjectIndex(form, MainFormStopOnUnits); + ctrl = FrmGetObjectPtr(form, index); + CtlSetValue(ctrl, 1); + } + + index = FrmGetObjectIndex(form, MainFormUnits); + ctrl = FrmGetObjectPtr(form, index); + FldInsert((FieldPtr) ctrl, "1", 1); + + index = FrmGetObjectIndex(form, MainFormBarcode); + FrmSetFocus(form, index); +} + + +/*********************************************************************** + * + * FUNCTION: MainFormLoadTable + * + ***********************************************************************/ + +static void MainFormLoadTable(TablePtr table, Boolean updateScroll) +{ + DmOpenRef db; + UInt16 numRecords; + MemHandle recordH; + RatScanDbRecord* recordP; + UInt16 rows, row, rowId; + FormPtr form; + ScrollBarPtr scroll; + + db = OpenScanDatabase(); + if (db == NULL) + return; + + numRecords = DmNumRecords(db); + rows = (numRecords < 12) ? numRecords : 12; + if (gTopVisibleRecord < 0) + gTopVisibleRecord = (numRecords > 12) ? (numRecords - 12) : 0; + + for (row = 0; row < rows; row++) { + rowId = gTopVisibleRecord + row; + recordH = DmGetRecord(db, rowId); + recordP = (MemPtr) MemHandleLock(recordH); + TblSetItemPtr(table, row, 0, &recordP->barcode); + if (StrCompareAscii(recordP->cases, "0") != 0) + TblSetItemPtr(table, row, 1, &recordP->cases); + else + TblSetItemPtr(table, row, 1, ""); + if (StrCompareAscii(recordP->units, "0") != 0) + TblSetItemPtr(table, row, 2, &recordP->units); + else + TblSetItemPtr(table, row, 2, ""); + MemHandleUnlock(recordH); + DmReleaseRecord(db, rowId, false); + TblSetRowID(table, row, rowId); + TblSetRowUsable(table, row, true); + } + + DmCloseDatabase(db); + TblMarkTableInvalid(table); + + if (updateScroll) { + form = FrmGetActiveForm(); + scroll = GetObjectPtrById(form, MainFormScroller); + if (numRecords <= 12) + SclSetScrollBar(scroll, 0, 0, 0, 0); + else + SclSetScrollBar(scroll, gTopVisibleRecord, 0, numRecords - 12, 11); + } +} + + +/*********************************************************************** + * + * FUNCTION: OpenBabboScanner + * + ***********************************************************************/ +/* +static Boolean OpenBabboScanner() +{ + Err err; + + if (! ScnIsJanamUnit()) { + SysFatalAlert("Not a Janam unit!"); + return false; + } + + err = ScnOpenDecoder(); + if (err) { + SysFatalAlert("Open decoder failed!"); + return false; + } + + if (ScnCmdScanEnable() != STATUS_OK) { + SysFatalAlert("Enable scanner failed!"); + ScnCloseDecoder(); + return false; + } + + gBabbo = true; + return true; +} +*/ + + +/*********************************************************************** + * + * FUNCTION: OpenBCS2Scanner + * + ***********************************************************************/ + +static Boolean OpenBCS2Scanner() +{ + Err err; + LocalID dbId; + + err = SysLibLoad('libr', 'BcAp', &gBcs2RefNum); + if (err) { + /* + switch (err) { + case sysErrLibNotFound: + SysFatalAlert("BCS2 library not found!"); + break; + case sysErrNoFreeRAM: + SysFatalAlert("Out of memory (RAM)!"); + break; + case sysErrNoFreeLibSlots: + SysFatalAlert("No free library slots!"); + break; + default: + SysFatalAlert("BCS2 library load failed!"); + break; + } + */ + gBcs2RefNum = 0; + return false; + } + + err = BCS2LibOpen(gBcs2RefNum); + if (err) { + /* + switch (err) { + case errBCS2MemoryError: + SysFatalAlert("BCS2 threw memory error"); + break; + default: + SysFatalAlert("BCS2 library open failed!"); + break; + } + */ + SysLibRemove(gBcs2RefNum); + gBcs2RefNum = 0; + return false; + } + + dbId = DmFindDatabase(cardNo, appDbRattail); + if (! dbId) { + /* + SysFatalAlert("Find database failed!"); + */ + SysLibRemove(gBcs2RefNum); + gBcs2RefNum = 0; + return false; + } + + err = SysNotifyRegister(cardNo, dbId, + BCS2BarCodeReadyNotification, NULL, + sysNotifyNormalPriority, NULL); + if (err != errNone) { + /* + SysFatalAlert("Notify registration failed!"); + */ + SysLibRemove(gBcs2RefNum); + gBcs2RefNum = 0; + return false; + } + + return true; +} + + +/*********************************************************************** + * + * FUNCTION: OpenScanDatabase + * + ***********************************************************************/ + +static DmOpenRef OpenScanDatabase() +{ + LocalID dbId; + DmOpenRef db; + + dbId = DmFindDatabase(cardNo, appDbRattailScan); + if (dbId == 0) + return CreateScanDatabase(); + + db = DmOpenDatabase(cardNo, dbId, dmModeWrite); + if (db == 0) + return NULL; + + return db; +} + + +/*********************************************************************** + * + * FUNCTION: ProcessScan + * + ***********************************************************************/ + +static void ProcessScan() +{ + if (GetCheckedValue(MainFormStopOnCases)) { + SetFieldFocus(MainFormCases); + } else if (GetCheckedValue(MainFormStopOnUnits)) { + SetFieldFocus(MainFormUnits); + } +} + + +/*********************************************************************** + * + * FUNCTION: SetFieldFocus + * + ***********************************************************************/ + +static void SetFieldFocus(UInt16 objId) +{ + FormPtr form; + UInt16 index; + FieldPtr field; + + form = FrmGetActiveForm(); + if (form == NULL) { + return; + } + + index = FrmGetObjectIndex(form, objId); + if (index == frmInvalidObjectId) { + return; + } + + field = FrmGetObjectPtr(form, index); + FldSetSelection(field, 0, FldGetTextLength(field)); + FrmSetFocus(form, index); +} + + +/*********************************************************************** + * + * FUNCTION: StoreScanData + * + ***********************************************************************/ + +static Boolean StoreScanData() +{ + FormPtr form; + FieldPtr barcode, cases, units; + UInt16 fieldIndex; + UInt32 size, offset; + DmOpenRef db; + UInt16 recordIndex; + MemHandle recordH; + MemPtr recordP; + TablePtr table; + UInt16 row; + + // Get form and barcode field pointers. + form = FrmGetActiveForm(); + barcode = GetObjectPtrById(form, MainFormBarcode); + if (barcode == NULL) + return false; + + // Set focus to barcode field if empty. + size = FldGetTextLength(barcode); + if (size == 0) { + fieldIndex = FrmGetObjectIndex(form, MainFormBarcode); + if (fieldIndex != frmInvalidObjectId) + FrmSetFocus(form, fieldIndex); + return false; + } + + // Get case and unit field pointers. + cases = GetObjectPtrById(form, MainFormCases); + if (cases == NULL) + return false; + units = GetObjectPtrById(form, MainFormUnits); + if (units == NULL) + return false; + + // Open the database and create a new record. + db = OpenScanDatabase(); + if (db == NULL) + return false; + recordIndex = dmMaxRecordIndex; + recordH = DmNewRecord(db, &recordIndex, sizeof(RatScanDbRecord)); + if (recordH == 0) { + DmCloseDatabase(db); + return false; + } + + // Write scan data to the record... + recordP = MemHandleLock(recordH); + offset = 0; + + size = FldGetTextLength(barcode); + DmWrite(recordP, offset, FldGetTextPtr(barcode), size); + offset += size; + + size = 15 - size; + DmSet(recordP, offset, size, 0); + offset += size; + + size = FldGetTextLength(cases); + DmWrite(recordP, offset, FldGetTextPtr(cases), size); + offset += size; + + size = 4 - size; + DmSet(recordP, offset, size, 0); + offset += size; + + size = FldGetTextLength(units); + DmWrite(recordP, offset, FldGetTextPtr(units), size); + offset += size; + + size = 4 - size; + DmSet(recordP, offset, size, 0); + + // ...then close the record and database. + MemHandleUnlock(recordH); + DmReleaseRecord(db, recordIndex, false); + DmCloseDatabase(db); + + // Redraw the table. + table = GetObjectPtrById(form, MainFormScanRecords); + row = TblGetLastUsableRow(table); + if (row == tblUnusableRow) + gTopVisibleRecord = 0; + else if (row == 11) + gTopVisibleRecord = TblGetRowID(table, 1); + MainFormLoadTable(table, true); + TblRedrawTable(table); + + SetFieldFocus(MainFormBarcode); + return true; +} + + +/*********************************************************************** + * + * FUNCTION: PilotMain + * + * DESCRIPTION: This is the main entry point for the application. + * + * PARAMETERS: cmd - word value specifying the launch code. + * cmdPB - pointer to a structure that is associated with the launch code. + * launchFlags - word value providing extra information about the launch. + * RETURNED: Result of launch + * + * REVISION HISTORY: + * + * + ***********************************************************************/ +UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) +{ + Err error = errNone; + SysNotifyParamType* notifyParams = (SysNotifyParamType *) cmdPBP; + FormPtr form; + FieldPtr barcode; + MemHandle barcodeH; + MemPtr barcodeP; + Char * scancode; + + switch (cmd) { + case sysAppLaunchCmdNormalLaunch: + if ((error = AppStart()) == 0) { + AppEventLoop(); + AppStop(); + } + break; + + case sysAppLaunchCmdNotify: + if (notifyParams->notifyType == BCS2BarCodeReadyNotification) { + scancode = (Char *) notifyParams->notifyDetailsP + 1; + if (StrCompareAscii(scancode, "NO READ")) { // (means good read) + form = FrmGetActiveForm(); + barcode = GetObjectPtrById(form, MainFormBarcode); + barcodeH = FldGetTextHandle(barcode); + FldSetTextHandle(barcode, NULL); + if (! barcodeH) + barcodeH = MemHandleNew(15); // ugh + barcodeP = MemHandleLock(barcodeH); + StrCopy((Char *) barcodeP, scancode); + MemHandleUnlock(barcodeH); + FldSetTextHandle(barcode, barcodeH); + FldDrawField(barcode); + if (GetCheckedValue(MainFormStopOnCases)) + SetFieldFocus(MainFormCases); + else if (GetCheckedValue(MainFormStopOnUnits)) + SetFieldFocus(MainFormUnits); + else { + if (StoreScanData()) + SndPlaySystemSound(sndInfo); + } + } + } + break; + + default: + break; + } + + return error; +} + + diff --git a/src/AppMain.h b/src/AppMain.h new file mode 100644 index 0000000..764e5d4 --- /dev/null +++ b/src/AppMain.h @@ -0,0 +1,25 @@ + + +typedef struct { + Char barcode[15]; + Char cases[4]; + Char units[4]; +} RatScanDbRecord; + + +//static void CloseBabboScanner(); +static void CloseBCS2Scanner(); +static DmOpenRef CreateScanDatabase(); +static void DrawCustomTableItem(void* table, Int16 row, Int16 col, RectangleType* bounds); +static UInt16 GetActiveFieldId(FormPtr form); +static Int16 GetCheckedValue(UInt16 objId); +static void *GetObjectPtrById(FormPtr form, UInt16 objId); +static Boolean MainFormHandleEvent(EventPtr event); +static void MainFormInit(FormPtr form); +static void MainFormLoadTable(TablePtr table, Boolean updateScroll); +//static Boolean OpenBabboScanner(); +static Boolean OpenBCS2Scanner(); +static DmOpenRef OpenScanDatabase(); +static void ProcessScan(); +static void SetFieldFocus(UInt16 objId); +static Boolean StoreScanData(); diff --git a/src/AppResources.h b/src/AppResources.h new file mode 100644 index 0000000..3cb43bd --- /dev/null +++ b/src/AppResources.h @@ -0,0 +1,65 @@ +// +// Palm App Name: "BasicApp" +// +// Palm App Version: "1.0" + + +// Resource: tFRM 1000 +#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0) + +#define MainFormScroller 1006 +#define MainFormScanRecords 1005 +#define MainFormBarcode 1000 +#define MainFormStopOnCases 1004 +#define MainFormCases 1003 +#define MainFormStopOnUnits 1002 +#define MainFormUnits 1001 + +#define AlertTest 1000 + +// Resource: tFRM 1100 +#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0) +#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 139, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard) +#define AboutTitleLabel 1102 //(Left Origin = 54, Top Origin = 25, Usable = 1, Font = Bold 12) +#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 54, Usable = 1, Font = Standard) +#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold) + + +// Resource: Talt 1001 +#define RomIncompatibleAlert 1001 +#define RomIncompatibleOK 0 + + +// Resource: MBAR 1000 +#define MainFormMenuBar 1000 + + +// Resource: MENU 1000 +#define MainOptionsMenu 1000 +#define MainOptionsAboutStarterApp 1000 + + +// Resource: PICT 1001 +#define Bitmap 1001 + +// Resource: PICT 1002 +#define Bitmap2 1002 + +// Resource: PICT 1008 +#define Bitmap3 1008 + +// Resource: PICT 1011 +#define Bitmap4 1011 + +// Resource: PICT 1012 +#define Bitmap5 1012 + +// Resource: PICT 1018 +#define Bitmap6 1018 + + +// Resource: taif 1000 +#define Largeicons12and8bitsAppIconFamily 1000 + +// Resource: taif 1001 +#define Smallicons12and8bitsAppIconFamily 1001 diff --git a/src/BCS2ScannerLib.h b/src/BCS2ScannerLib.h new file mode 100644 index 0000000..9b407fc --- /dev/null +++ b/src/BCS2ScannerLib.h @@ -0,0 +1,526 @@ +/*---------------------------------------------------------------------------------------------------- + Copyright (c) 2003 ACEECA Limited. All rights reserved. + + File: BCS2ScannerLib.h + + Version: 1.4.3b + + Release: 16th March 2005 + + Description: + + Header file for the BCS2 laser barcode scanner API library. Use this file in conjunction + with your project file to incorporate the bar code functionality of an IDV-BCS2 + unit from ACEECA Limited. The library checks the hardware to make sure the + Meazura features are present, an error code is returned otherwise. Below is a + summary of the functions included in the library: + + BCS2LibOpen: + Opens the BarCodeScanner library, creates and initializes the globals. + This function must be called before any other BarCodeScanner Library functions, + with the exception of BCS2LibGetLibAPIVersion. This library requires at least the + MeazuraLib_V200b.prc shared library to work - an error message will + be returned if the library is of the wrong version. BCS2LibClose must be called + if this is the case. + + BCS2LibClose: + Closes the BarCodeScanner libary, frees globals. If other applications still + have the library open, decrements the reference count and returns errBCS2LibStillOpen. + + BCS2LibSleep: + Handles system sleep event. + + BCS2LibWake: + Handles system wake event. + + BCS2LibGetLibAPIVersion: + Get the BCS2 library API version. + + BCS2LibTriggerOn: + Triggers the BCS2 module to start reading a barcode. When a valid barcode is received, a + BCS2BarCodeReadyNotification notification will be broadcast to whoever has registered to + receive it. The registering of the notification should be done before calling this function. + Please refer to the "Notification Manager" on page 711 of the Palm OS Programmers' API Reference + for more information on how to use notifications. + + BCS2LibTriggerOff: + Tells the BCS2 module to stop triggering immediately. + + BCS2LibReset: + Resets the BCS2 module. This function may be useful if the module doesn't seem to respond and may + have gone into a unknown state. + + BCS2LibSetToFactoryDefaults: + Sets the BCS2 module to its ACEECA's factory defaults. This will set up the module + with the same settings as it left ACEECA Limited. It has been included for cases where the + module have been reconfigured by a third party and factory defaults are required. + + BCS2LibChangeSettings: + This allows the caller to change the barcode scanner module settings eg. symbologies etc. + It accepts configuration strings that will be provided. + + History: + 03-dec-03 HD: Release beta version BarCodeScannerLib_V100b.prc (120303-1325) + 10-dec-03 HD: Modified the library so that the triggering can be better controlled, ie trigger on, + release off. Released as BarCodeScannerLib_V110b.prc (121103-1019) + 22-Jan-04 HD: Corrected issue of fatal exceptions when a barcode was received before + trigger button was pressed. + 23-Jan-04 HD: Found that UART interrupts were turning off when power was turned off, this is now fixed. + 23-Feb-04 HD: Added BCS2LibChangeSettings which allows developers access to configuring the + barcode scanner module using a configuration string. + HD: Also made this header file compatible with GCC compilers. +----------------------------------------------------------------------------------------------------*/ + +#ifndef __BCS2_LIB_H__ +#define __BCS2_LIB_H__ + + +// If we're actually compiling the library code, then we need to +// eliminate the trap glue that would otherwise be generated from +// this header file in order to prevent compiler errors in CW Pro 2. +#ifdef BUILDING_SAMPLE_LIB + #define SAMPLE_LIB_TRAP(trapNum) +#else + #define SAMPLE_LIB_TRAP(trapNum) SYS_TRAP(trapNum) +#endif + + +// Palm OS common definitions +#include +#include + +#ifdef __MWERKS__ +#pragma mark Library Version +#endif +// LIBRARY VERSION +// +// The library version scheme follows the system versioning scheme. +// See sysMakeROMVersion and friends in SystemMgr.h. +// +// For reference: +// +// 0xMMmfsbbb, where MM is major version, m is minor version +// f is bug fix, s is stage: 3-release,2-beta,1-alpha,0-development, +// bbb is build number for non-releases +// V1.12b3 would be: 0x01122003 +// V2.00a2 would be: 0x02001002 +// V1.01 would be: 0x01013000 +#define BCS2LibVersion sysMakeROMVersion(1, 4, 3, sysROMStageBeta, 1) + + +#ifdef __MWERKS__ +#pragma mark Creator Codes +#endif +/******************************************************************** + * Type and creator of BarCodeScanner Library database + ********************************************************************/ +#define BCS2LibCreatorID 'BcAp' // Bar Code scanner Library database creator +#define BCS2LibTypeID 'libr' // Standard library database type + +/******************************************************************** + * Internal library name which can be passed to SysLibFind() + ********************************************************************/ +#define BCS2LibName "BCS2 API Library" + +#ifdef __MWERKS__ +#pragma mark Notifications +#endif +/******************************************************************** + * BCS2 notification + ********************************************************************/ +#define BCS2BarCodeReadyNotification 'BcsN' // Bar code scanner notification + + +#ifdef __MWERKS__ +#pragma mark Error Codes +#endif +/************************************************************ + * Bar Code Scanner Library error codes + *************************************************************/ +#define errBCS2ParamError (appErrorClass | 0x1) // invalid parameter +#define errBCS2LibNotOpen (appErrorClass | 0x2) // returned if library is not openned +#define errBCS2LibStillOpen (appErrorClass | 0x3) // returned from MzLibClose() if the library is still open by others +#define errBCS2MemoryError (appErrorClass | 0x4) // memory error occurred +#define errBCS2HwFuncNotSupported (appErrorClass | 0x5) // the function being accessed is not available on the current hardware +#define errBCS2WrongMzLibVersion (appErrorClass | 0x6) // the wrong Meazura library version has been loaded +#define errBCS2MzLibLoadError (appErrorClass | 0x7) // an error occured opening the meazura library +#define errBCS2MzScannerError (appErrorClass | 0x8) // scanner engine comms error + +/******************************************************************** + * Meazura key bit definitions + ********************************************************************/ +#define MzLeftKeyBit keyBitHard1 +#define MzCentreKeyBit keyBitHard2 +#define MzRightKeyBit keyBitHard3 +#define MzUpKeyBit keyBitPageUp +#define MzDownKeyBit keyBitPageDown +#define MzPowerKeyBit keyBitPower + +/******************************************************************** + * Meazura virtual keys definitions + ********************************************************************/ +#define MzVLeftKey chrLeftArrow +#define MzVCentreKey vchrHard1 +#define MzVRightKey chrRightArrow +#define MzVUpKey vchrPageUp +#define MzVDownKey vchrPageDown +#define MzVPowerKey vchrAutoOff + + +#ifdef __MWERKS__ +#pragma mark Library Traps +#endif +#define BCS2LibTrapGetLibAPIVersion (sysLibTrapCustom + 0) +#define BCS2LibTrapTriggerOn (sysLibTrapCustom + 1) +#define BCS2LibTrapTriggerOff (sysLibTrapCustom + 2) +#define BCS2LibTrapReset (sysLibTrapCustom + 3) +#define BCS2LibTrapSetToFactoryDefaults (sysLibTrapCustom + 4) +#define BCS2LibTrapChangeSettings (sysLibTrapCustom + 5) +#define BCS2LibTrapLast (sysLibTrapCustom + 6) + + +#ifdef __MWERKS__ +#pragma mark Public Definitions +#endif +/******************************************************************** + * Public Definitions + ********************************************************************/ +#define BCS2MaxBarCodeSize 100 + +/******************************************************************** + * API Prototypes + ********************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + + +//-------------------------------------------------- +// Standard library open, close, sleep and wake functions +//-------------------------------------------------- +#ifdef __MWERKS__ +#pragma mark Function Prototypes +#endif + +/************************************************************ + * + * FUNCTION: BCS2LibOpen + * + * DESCRIPTION: Opens the BarCodeScanner library, creates and initializes the globals. + * This function must be called before any other BarCodeScanner Library functions, + * with the exception of BCS2LibGetLibAPIVersion. + * Does not turn on module power + * + * If BCS2LibOpen fails, do not call any other BarCodeScanner library API functions. + * If BCS2LibOpen succeeds, call BCS2LibClose when you are done using + * the library to enable it to release critical system resources. + * + * LIBRARY DEVELOPER NOTES: + * + * The library's "open" and "close" functions should *not* take an excessive + * amount of time to complete. If the processing time for either of these + * is lengthy, consider creating additional library API function(s) to handle + * the time-consuming chores. + * + * + * PARAMETERS: + * refNum -- BarCodeScanner library reference number returned by SysLibLoad() + * or SysLibFind(). + * + * CALLED BY: anyone who wants to use this library + * + * RETURNS: 0 -- no error + * errBCS2MemoryError -- not enough memory to initialize + * + * + * CREATED: 2-Dec-03 + * + * BY: Hemon Dey + * + * REVISION HISTORY: + * Name Date Description + * ---- ---- ----------- + * + *************************************************************/ +extern Err BCS2LibOpen(UInt16 refNum) + SAMPLE_LIB_TRAP(sysLibTrapOpen); + +/************************************************************ + * + * FUNCTION: BCS2LibClose + * + * DESCRIPTION: Closes the BarCodeScanner libary, frees globals. + * Turns off module power + * + * ***IMPORTANT*** + * May be called only if BCS2LibOpen succeeded. + * + * If other applications still have the library open, decrements + * the reference count and returns errBCS2LibStillOpen. + * + * LIBRARY DEVELOPER NOTES: + * + * The library's "open" and "close" functions should *not* take an excessive + * amount of time to complete. If the processing time for either of these + * is lengthy, consider creating additional library API function(s) to handle + * the time-consuming chores. + * + * PARAMETERS: + * refNum -- BarCodeScanner library reference number returned by SysLibLoad() + * or SysLibFind(). + * + * CALLED BY: Whoever wants to close the BarCodeScanner library + * + * RETURNS: errNone -- no error + * errBCS2LibStillOpen -- library is still open by others (no error) + * + * CREATED: 2-Dec-2003 + * + * BY: Hemon Dey + * + * REVISION HISTORY: + * Name Date Description + * ---- ---- ----------- + * + *************************************************************/ + extern Err BCS2LibClose(UInt16 refNum) + SAMPLE_LIB_TRAP(sysLibTrapClose); + +/************************************************************ + * + * FUNCTION: BCS2LibSleep + * + * DESCRIPTION: Handles system sleep notification. + * Turns off module power + * + * PARAMETERS: refNum -- BarCodeScanner library reference number + * + * CALLED BY: System + * + * RETURNS: errNone -- no error + * + * CREATED: 2-Dec-03 + * + * BY: Hemon Dey + * + * REVISION HISTORY: + * Name Date Description + * ---- ---- ----------- + * + *************************************************************/ +extern Err BCS2LibSleep(UInt16 refNum) + SAMPLE_LIB_TRAP(sysLibTrapSleep); + +/************************************************************ + * + * FUNCTION: BCS2LibWake + * + * DESCRIPTION: Handles system wake notification + * Does not turn on module power + * + * PARAMETERS: refNum -- BarCodeScanner library reference number + * + * CALLED BY: System + * + * RETURNS: errNone -- no error + * + * CREATED: 2-Dec-03 + * + * BY: Hemon Dey + * + * REVISION HISTORY: + * Name Date Description + * ---- ---- ----------- + * + *************************************************************/ +extern Err BCS2LibWake(UInt16 refNum) + SAMPLE_LIB_TRAP(sysLibTrapWake); + + +//-------------------------------------------------- +// Custom library API functions +//-------------------------------------------------- + +/************************************************************ + * + * FUNCTION: BCS2LibGetLibAPIVersion + * + * DESCRIPTION: Get the BCS2 library API version. + * + * PARAMETERS: refNum -- BarCodeScanner library reference number + * dwVerP -- pointer to variable for storing the version number + * + * CALLED BY: Anyone wishing to get our library API version + * + * RETURNS: errNone -- no error + * + * CREATED: 2-Dec-03 + * + * BY: Hemon Dey + * + * LIBRARY VERSION + * + * The library version scheme follows the system versioning scheme. + * See sysMakeROMVersion and friends in SystemMgr.h. + * + * For reference: + * + * 0xMMmfsbbb, where MM is major version, m is minor version + * f is bug fix, s is stage: 3-release,2-beta,1-alpha,0-development, + * bbb is build number for non-releases + * V1.12b3 would be: 0x01122003 + * V2.00a2 would be: 0x02001002 + * V1.01 would be: 0x01013000 + * + * REVISION HISTORY: + * Name Date Description + * ---- ---- ----------- + *************************************************************/ +extern Err BCS2LibGetLibAPIVersion(UInt16 refNum, UInt32 * dwVerP) + SAMPLE_LIB_TRAP(BCS2LibTrapGetLibAPIVersion); + +/************************************************************ + * + * FUNCTION: BCS2LibTriggerOn + * + * DESCRIPTION: Trigger on the BCS2 module. + * Turns on scanner power if not already on + * + * PARAMETERS: refNum -- BarCodeScanner library reference number + * + * CALLED BY: Anyone wishing to trigger the BCS2 module to start scanning + * + * RETURNS: errNone -- no error + * errBCS2LibNotOpen -- the library is not open + * + * + * CREATED: 2-Dec-03 + * + * BY: Hemon Dey + * + * REVISION HISTORY: + * Name Date Description + * ---- ---- ----------- + * + *************************************************************/ +extern Err BCS2LibTriggerOn(UInt16 refNum) + SAMPLE_LIB_TRAP(BCS2LibTrapTriggerOn); + +/************************************************************ + * + * FUNCTION: BCS2LibTriggerOff + * + * DESCRIPTION: This function does nothing. Just here for compatibility with BCS1 + * + * PARAMETERS: refNum -- BarCodeScanner library reference number + * + * CALLED BY: Anyone wishing to trigger the BCS2 module to start scanning + * + * RETURNS: errNone -- no error + * errBCS2LibNotOpen -- the library is not open + * + * + * CREATED: 2-Dec-03 + * + * BY: Hemon Dey + * + * REVISION HISTORY: + * Name Date Description + * ---- ---- ----------- + * + *************************************************************/ +extern Err BCS2LibTriggerOff(UInt16 refNum) + SAMPLE_LIB_TRAP(BCS2LibTrapTriggerOff); + + +/************************************************************ + * + * FUNCTION: BCS2LibReset + * + * DESCRIPTION: Resets the BCS2 module (cycles power to scanner module) + * + * PARAMETERS: refNum -- BarCodeScanner library reference number + * + * CALLED BY: Anyone wishing to reset the BCS2 module. + * + * RETURNS: errNone -- no error + * errBCS2LibNotOpen -- the library is not open + * + * CREATED: 2-Dec-03 + * + * BY: Hemon Dey + * + * REVISION HISTORY: + * Name Date Description + * ---- ---- ----------- + * + *************************************************************/ +extern Err BCS2LibReset(UInt16 refNum) + SAMPLE_LIB_TRAP(BCS2LibTrapReset); + + +/************************************************************ + * + * FUNCTION: BCS2LibSetToFactoryDefaults + * + * DESCRIPTION: Sets the BCS2 module to its ACEECA's factory defaults. + * NB. These are the same as Metrologic defaults + * + * PARAMETERS: refNum -- BarCodeScanner library reference number + * + * CALLED BY: Anyone wishing set the BCS module to its factory defaults. + * + * RETURNS: errNone -- no error + * errBCS2LibNotOpen -- the library is not open + * + * CREATED: 2-Dec-03 + * + * BY: Hemon Dey + * + * REVISION HISTORY: + * Name Date Description + * ---- ---- ----------- + * + *************************************************************/ +extern Err BCS2LibSetToFactoryDefaults(UInt16 refNum) + SAMPLE_LIB_TRAP(BCS2LibTrapSetToFactoryDefaults); + +/************************************************************ + * + * FUNCTION: BCS2LibChangeSettings + * + * DESCRIPTION: Changes the settings to the BCS2 module. + * + * PARAMETERS: refNum -> BarCodeScanner library reference number + * str -> The configuration string (one or more 3-charcter commands for IS4120) + * numBytes -> The size of the configuration string (3,6,9,...) + * + * CALLED BY: Anyone wishing to reconfigure the BCS module. + * + * RETURNS: errNone -- no error + * errBCS2LibNotOpen -- the library is not open + * + * CREATED: 2-Dec-03 + * + * BY: Hemon Dey + * + * REVISION HISTORY: + * Name Date Description + * ---- ---- ----------- + * + *************************************************************/ +extern Err BCS2LibChangeSettings(UInt16 refNum, UInt8* str, UInt16 numBytes) + SAMPLE_LIB_TRAP(BCS2LibTrapChangeSettings); + + +// For loading the library in Palm OS Mac emulation mode +extern Err BCS2LibInstall(UInt16 refNum, SysLibTblEntryPtr entryP); + + +#ifdef __cplusplus +} +#endif + + +#endif // __BCS2_LIB_H__ diff --git a/src/JanamExtended.h b/src/JanamExtended.h new file mode 100644 index 0000000..de6ec86 --- /dev/null +++ b/src/JanamExtended.h @@ -0,0 +1,58 @@ +/****************************************************************************** + * + * Extended Functions header + * + * Copyright (c) 2008 Janam Partners LLC. All rights reserved. + * + * File: JanamExtended.h + * + * Release: Palm OS 5.x + * + * Description: Extended Function Supported by BABBO + * + * History: + * Version 1.0 PT, JL Oct, 2006 + * Version 1.1 PT, JL May, 2007 + * -Add ScnCmdGetSetExposureSettings function + * Version 1.2 PT, JL Sep, 2008 + * -Add ScnCmdGetSetDecodeCenteringWindow function + *****************************************************************************/ + +// Extended functions supported by BABBO devices + +#ifndef __JANAMEXTENDED_H__ +#define __JANAMEXTENDED_H__ + +#include "JanamExtendedStruct.h" + + +//Read Write Symbology Config +Int16 ScnCmdReadSymbologyConfig(UInt8 Query, Int16 nSymId, SymFlagsRange_t *pSymStruct); +Int16 ScnCmdWriteSymbologyConfig(Int16 nSymId, SymFlagsRange_t *pvSym); + +//OCR Support +Int16 ScnCmdSetupOCR(UInt8 nFont, char* pszTemplate, char* pszGroupG, char* pszGroupH, char* pszCheckChar); +Int16 ScnCmdGetSetupOCR(UInt8 QueryType, UInt8* pnFont, char* pszTemplate, char* pszGroupG, char* pszGroupH, char* pszCheckChar); + +//On Off Aimer and Illum Lights +Int16 ScnCmdAimerOn(Int8 bEnable); +Int16 ScnCmdLightsOn(Int8 bEnable); + +//Set the light mode during scan +Int16 ScnCmdGetSetLightsMode(Int8 Set,UInt8 QueryType, UInt8 *pLightsMode); + +//ScanWedge +void ScnCmdScanWedge(Boolean state); + +//Set the exposure setting of the Scanner +Int16 ScnCmdGetSetExposureMode(Int8 Set, Int8 *pExpMode); +Int16 ScnCmdGetSetExposureSettings(Int8 Set, Int32 * pArray, Int32 dwArrayLength); + +//GetSet the decode options +Int16 ScnCmdGetSetDecodeOptions(Int8 Set,UInt8 QueryType, DecodeOptions_t *pDecodeOptions); + +//GetSet the centering option +Int16 ScnCmdGetSetDecodeCenteringWindow(Int8 bSet, UInt8 QueryType, Int8 *pbEnabled, RECT *pInt16ersectRect); + + +#endif \ No newline at end of file diff --git a/src/JanamExtendedDef.h b/src/JanamExtendedDef.h new file mode 100644 index 0000000..8f04f61 --- /dev/null +++ b/src/JanamExtendedDef.h @@ -0,0 +1,231 @@ +/****************************************************************************** + * + * Barcode Scanner Common Defines. + * + * Copyright (c) 2006 Janam Partners LLC. All rights reserved. + * + * File: JanamExtendedDef.h + * + * Release: Palm OS 5.x + * + * Description: Extended Defines for using the BABBO devices + * + * History: + * Version 1.0 PT, JL Oct, 2006 + * + *****************************************************************************/ + +#ifndef __JANAMEXTENDEDDEF_H__ +#define __JANAMEXTENDEDDEF_H__ + +//Type Defines +#define LONG long +#define WORD Int16 +#define DWORD Int32 + +//The Max BarCode Length +#define MAXBARCODELENGTH 3750 +//----------------------------------------------------------------------------- + +//Barcode data types returned + +//Added to the current library +#define BCTYPE_CODE32 0x20 +#define BCTYPE_PDF417 0x11 + +//Extended support by BABBO +//Defined at a range of 0x31-0x3F, 0x60-0x6D +#define BCTYPE_AZTEC 0x31 +#define BCTYPE_CODE11 0x32 +#define BCTYPE_CODE49 0x33 +#define BCTYPE_COMPOSITE 0x34 +#define BCTYPE_DATAMATRIX 0x35 +#define BCTYPE_MAXICODE 0x36 +#define BCTYPE_MICROPDF 0x37 +#define BCTYPE_POSTNET 0x38 +#define BCTYPE_OCR 0x39 +#define BCTYPE_QR 0x3A +#define BCTYPE_RSS 0x3B +#define BCTYPE_ISBT 0x3C +#define BCTYPE_BPO 0x3D +#define BCTYPE_CANPOST 0x3E +#define BCTYPE_AUSPOST 0x3F + +#define BCTYPE_IATA25 0x60 +#define BCTYPE_CODABLOCK 0x61 +#define BCTYPE_JAPOST 0x62 +#define BCTYPE_PLANET 0x63 +#define BCTYPE_DUTCHPOST 0x64 +#define BCTYPE_MATRIX25 0x65 +#define BCTYPE_CHINAPOST 0x66 +#define BCTYPE_KOREAPOST 0x67 +#define BCTYPE_TELEPEN 0x68 +#define BCTYPE_CODE16K 0x69 +#define BCTYPE_POSICODE 0x6A +#define BCTYPE_COUPONCODE 0x6B +#define BCTYPE_USPS4CB 0x6C +#define BCTYPE_IDTAG 0x6D + +//----------------------------------------------------------------------------- +// Decoder configuration definitions for each symbology +#define SYMBOLOGY_ENABLE 0x00000001 // Enable Symbology bit +#define SYMBOLOGY_CHECK_ENABLE 0x00000002 // Enable usage of check character +#define SYMBOLOGY_CHECK_TRANSMIT 0x00000004 // Send check character +#define SYMBOLOGY_START_STOP_XMIT 0x00000008 // Include the start and stop characters in the decoded result string +#define SYMBOLOGY_ENABLE_APPEND_MODE 0x00000010 // Code39 append mode +#define SYMBOLOGY_ENABLE_FULLASCII 0x00000020 // Enable Code39 Full ASCII +#define SYMBOLOGY_ENABLE_BASE32 0x00000040 // Code32 (PARAF) enable +#define SYMBOLOGY_NUM_SYS_TRANSMIT 0x00000040 // UPC-A/UPC-e Send Num Sys +#define SYMBOLOGY_2_DIGIT_ADDENDA 0x00000080 // Enable 2 digit Addenda (UPC & EAN) +#define SYMBOLOGY_5_DIGIT_ADDENDA 0x00000100 // Enable 5 digit Addenda (UPC & EAN) +#define SYMBOLOGY_ADDENDA_REQUIRED 0x00000200 // Only allow codes with addenda (UPC & EAN) +#define SYMBOLOGY_ADDENDA_SEPARATOR 0x00000400 // Include Addenda separator space in returned string. +#define SYMBOLOGY_EXPANDED_UPCE 0x00000800 // Extended UPC-E +#define SYMBOLOGY_ISBT_CONCATENATE 0x00000040 // C128 ISBT concatenation +#define SYMBOLOGY_COMPOSITE_UPC 0x00002000 // Enable UPC composite codes +#define SYMBOLOGY_AZTEC_RUNE 0x00004000 // Enable Aztec Run +#define SYMBOLOGY_AUSTRALIAN_BAR_WIDTH 0x00010000 // Include australian postal bar data in string +// Telepen and PosiCode +#define SYMBOLOGY_TELEPEN_OLD_STYLE 0x04000000 // Telepen Old Style mode. +#define SYMBOLOGY_POSICODE_LIMITED_1 0x08000000 // PosiCode Limited of 1 +#define SYMBOLOGY_POSICODE_LIMITED_2 0x10000000 // PosiCode Limited of 2 +#define SYMBOLOGY_CODABAR_CONCATENATE 0x20000000 // Codabar concatenate. +#define SYMBOLOGY_CODABAR_CONCAT_REQ 0x40000000 // Codabar concatenate required. +#define SYMBOLOGY_EAN13_ISBN_XLATE 0x00080000 // EAN 13-Bookland- ISBN + + +//----------------------------------------------------------------------------- + +// Symbology structure set masks +#define SYM_MASK_FLAGS 0x00000001 // Flags are valid +#define SYM_MASK_MIN_LEN 0x00000002 // Min Length valid +#define SYM_MASK_MAX_LEN 0x00000004 // Max Length valid +#define SYM_MASK_ALL 0x00000007 // All fields valid + +//----------------------------------------------------------------------------- + +// Define aliases for each symbology structure +#define AZTEC_T SymFlagsRange_t +#define CODABAR_T SymFlagsRange_t +#define CODE11_T SymFlagsRange_t +#define CODE128_T SymFlagsRange_t +#define CODE39_T SymFlagsRange_t +#define CODE49_T SymFlagsRange_t +#define CODE93_T SymFlagsRange_t +#define COMPOSITE_T SymFlagsRange_t +#define DATAMATRIX_T SymFlagsRange_t +#define EAN8_T SymFlagsOnly_t +#define EAN13_T SymFlagsOnly_t +#define INT25_T SymFlagsRange_t +#define MAXICODE_T SymFlagsRange_t +#define MICROPDF_T SymFlagsRange_t +#define PDF417_T SymFlagsRange_t +#define POSTNET_T SymFlagsOnly_t +#define QR_T SymFlagsRange_t +#define RSS_T SymFlagsOnly_t +#define RSSLIM_T SymFlagsOnly_t +#define RSSEXP_T SymFlagsRange_t +#define UPCA_T SymFlagsOnly_t +#define UPCE_T SymFlagsOnly_t +#define UPCE1_T SymFlagsOnly_t +#define BPO_T SymFlagsOnly_t +#define CANPOST_T SymFlagsOnly_t +#define AUSPOST_T SymFlagsOnly_t +#define IATA25_T SymFlagsRange_t +#define CODABLOCK_T SymFlagsRange_t +#define JAPOST_T SymFlagsOnly_t +#define PLANET_T SymFlagsOnly_t +#define DUTCHPOST_T SymFlagsOnly_t +#define MSI_T SymFlagsRange_t +#define TLCODE39_T SymFlagsOnly_t +#define MATRIX25_T SymFlagsRange_t +#define KORPOST_T SymFlagsRange_t +#define TRIOPTIC_T SymFlagsOnly_t +#define CODE25_T SymFlagsRange_t +#define PLESSEY_T SymFlagsRange_t +#define CHINAPOST_T SymFlagsRange_t +#define TELEPEN_T SymFlagsRange_t +#define CODE16K_T SymFlagsRange_t +#define POSICODE_T SymFlagsRange_t +#define COUPONCODE_T SymFlagsOnly_t +#define USPS4STATE_T SymFlagsOnly_t +#define IDTAG_T SymFlagsOnly_t + +//define for exposure settings +#define DEC_ES_EXPOSURE_METHOD 0 +#define DEC_ES_TARGET_VALUE 1 +#define DEC_ES_TARGET_PERCENTILE 2 +#define DEC_ES_TARGET_ACCEPT_GAP 3 +#define DEC_ES_MAX_EXP 4 +#define DEC_ES_MAX_GAIN 5 +#define DEC_ES_STARTING_EXP 6 +#define DEC_ES_STARTING_GAIN 7 +#define DEC_ES_FRAME_RATE 8 +#define DEC_ES_CONFORM_IMAGE 9 +#define DEC_ES_CONFORM_TRIES 10 +#define DEC_ES_SPECULAR_EXCLUSION 11 +#define DEC_ES_SPECULAR_SAT 12 +#define DEC_ES_SPECULAR_LIMIT 13 +#define DEC_ES_FIXED_EXP 14 +#define DEC_ES_FIXED_GAIN 15 +#define DEC_ES_FIXED_FRAME_RATE 16 +#define DEC_ES_CENTER_SAMPLE_WINDOW_TOP 18 +#define DEC_ES_CENTER_SAMPLE_WINDOW_BOT 19 +#define DEC_ES_CENTER_SAMPLE_WINDOW_LFT 20 +#define DEC_ES_CENTER_SAMPLE_WINDOW_RGT 21 +#define DEC_ES_CENTER_SAMPLE_WINDOW_H_PER 22 +#define DEC_ES_CENTER_SAMPLE_WINDOW_V_PER 23 +#define DEC_ES_MIN_EXP 24 + +#define DEC_MIN_ES_EXPOSURE_METHOD 0 +#define DEC_MAX_ES_EXPOSURE_METHOD 2 +#define DEC_MIN_ES_TARGET_VALUE 1 +#define DEC_MAX_ES_TARGET_VALUE 255 +#define DEC_MIN_ES_TARGET_PERCENTILE 1 +#define DEC_MAX_ES_TARGET_PERCENTILE 99 +#define DEC_MIN_ES_TARGET_ACCEPT_GAP 1 +#define DEC_MAX_ES_TARGET_ACCEPT_GAP 50 +#define DEC_MIN_ES_MAX_EXP 1 +#define DEC_MAX_ES_MAX_EXP 7874 +#define DEC_MIN_ES_MAX_GAIN 1 +#define DEC_MAX_ES_MAX_GAIN 4 +#define DEC_MIN_ES_FRAME_RATE 1 +#define DEC_MAX_ES_FRAME_RATE 30 +#define DEC_MIN_ES_CONFORM_IMAGE 0 +#define DEC_MAX_ES_CONFORM_IMAGE 1 +#define DEC_MIN_ES_CONFORM_TRIES 1 +#define DEC_MAX_ES_CONFORM_TRIES 8 +#define DEC_MIN_ES_SPECULAR_EXCLUSION 0 +#define DEC_MAX_ES_SPECULAR_EXCLUSION 4 +#define DEC_MIN_ES_SPECULAR_SAT 200 +#define DEC_MAX_ES_SPECULAR_SAT 255 +#define DEC_MIN_ES_SPECULAR_LIMIT 1 +#define DEC_MAX_ES_SPECULAR_LIMIT 5 +#define DEC_MIN_ES_FIXED_EXP 1 +#define DEC_MAX_ES_FIXED_EXP 7874 +#define DEC_MIN_ES_FIXED_GAIN 1 +#define DEC_MAX_ES_FIXED_GAIN 4 +#define DEC_MIN_ES_FIXED_FRAME_RATE 1 +#define DEC_MAX_ES_FIXED_FRAME_RATE 30 +#define DEC_MIN_ES_CENTER_SAMPLE_WINDOW_TOP 0 +#define DEC_MAX_ES_CENTER_SAMPLE_WINDOW_TOP 479 +#define DEC_MIN_ES_CENTER_SAMPLE_WINDOW_BOT 0 +#define DEC_MAX_ES_CENTER_SAMPLE_WINDOW_BOT 479 +#define DEC_MIN_ES_CENTER_SAMPLE_WINDOW_LFT 0 +#define DEC_MAX_ES_CENTER_SAMPLE_WINDOW_LFT 751 +#define DEC_MIN_ES_CENTER_SAMPLE_WINDOW_RGT 0 +#define DEC_MAX_ES_CENTER_SAMPLE_WINDOW_RGT 751 +#define DEC_MIN_ES_CENTER_SAMPLE_WINDOW_H_PER 4 +#define DEC_MAX_ES_CENTER_SAMPLE_WINDOW_H_PER 748 +#define DEC_MIN_ES_CENTER_SAMPLE_WINDOW_V_PER 1 +#define DEC_MAX_ES_CENTER_SAMPLE_WINDOW_V_PER 751 +#define DEC_MIN_ES_MIN_EXP 1 +#define DEC_MAX_ES_MIN_EXP 7874 + +#define DEC_AE_METHOD_UNIFORM 0 +#define DEC_AE_METHOD_CENTER_ONLY 1 +#define DEC_AE_METHOD_CENTER_WEIGHTED 2 + +//----------------------------------------------------------------------------- + +#endif diff --git a/src/JanamExtendedStruct.h b/src/JanamExtendedStruct.h new file mode 100644 index 0000000..9f909c7 --- /dev/null +++ b/src/JanamExtendedStruct.h @@ -0,0 +1,342 @@ +/****************************************************************************** + * + * Barcode Scanner Extended Struct Defines. + * + * Copyright (c) 2006 Janam Partners LLC. All rights reserved. + * + * File: JanamExtendedStruct.h + * + * Release: Palm OS 5.x + * + * Description: Extended Struct and Enum for using BABBO devices + * + * History: + * Version 1.0 PT, JL Oct, 2006 + * + *****************************************************************************/ + + +#ifndef __JANAMEXTENDEDSTRUCT_H__ +#define __JANAMEXTENDEDSTRUCT_H__ + + +// Image formats Enum +typedef enum +{ + IF_RAW_BINARY = 0, + IF_RAW_GRAY +} ImageFormat_t; + +// OCR Mode Enum +typedef enum +{ + OCR_DISABLED = 0, + OCR_A, + OCR_B, + OCR_MONEY, + OCR_MICR +}OCRMode_t; + +// Query Type Enum +typedef enum +{ + QT_DEFAULT = 0, + QT_CURRENT +} QueryType_t; + +//----------------------------------------------------------------------------- +// Lights mode used during WaitForDecode function calls. +//----------------------------------------------------------------------------- +typedef enum +{ + LM_ILLUM_AIMER_OFF=0, // Neither aimers or illumination + LM_AIMER_ONLY, // Aimer only + LM_ILLUM_ONLY, // Illum only + LM_ILLUM_AIMER // Alternating Aimer & illumination(default) +} LightsMode_t; + + //----------------------------------------------------------------------------- + + +// Structure for symbologies with no specified min or max length. +typedef struct _tagSymFlagsOnly +{ + Int32 dwStructSize; // Set to sizeof( SymFlagsOnly_t ); + Int32 dwMask; + Int32 dwFlags; + +} SymFlagsOnly_t, *PSymFlagsOnly_t; + + +// Structure for symbologies with min & max length. +typedef struct _tagSymFlagsRange +{ + Int32 dwStructSize; // Set to sizeof( SymFlagsRange_t ); + Int32 dwMask; + Int32 dwFlags; + Int32 dwMinLen; + Int32 dwMaxLen; + +} SymFlagsRange_t, *PSymFlagsRange_t; + +// Structure of structures, one for each symbology. +typedef struct _tagSymCfg +{ + Int32 dwStructSize; // Set to sizeof( SymCfg_t ); + // Linear Codes // Flags supported for this code + //--------------------------------------------------------------- + CODABAR_T codabar; // Enable,Check,CheckSend,StartStop,Concatenate + CODE11_T code11; // Enable,Check,CheckSend + CODE128_T code128; // Enable + CODE39_T code39; // Enable,Check,CheckSend,StartStop,Append,FullAscii + CODE49_T code49; // Enable + CODE93_T code93; // Enable + COMPOSITE_T composite; // Enable,CompositeUPC + DATAMATRIX_T datamatrix; // Enable + EAN8_T ean8; // Enable,Check,Addenda2,Addenda5,AddendaReq,AddendaSep + EAN13_T ean13; // Enable,Check,Addenda2,Addenda5,AddendaReq,AddendaSep,ISBN Translate + IATA25_T iata25; // Enable + INT25_T int2of5; // Enable,Check,CheckSend + MSI_T msi; // Enable,Check + UPCA_T upcA; // Enable,check,NumSysTrans,Addenda2,Addenda5,AddendaReq,AddendaSep + UPCE_T upcE; // Enable,check,NumSysTrans,Addenda2,Addenda5,AddendaReq,AddendaSep,ExpandedE, + UPCE1_T upcE1; // Enable + // Postal Codes + AUSPOST_T australiaPost; // Enable,AustralianBar + BPO_T britishPost; // Enable + CANPOST_T canadaPost; // Enable + DUTCHPOST_T dutchPost; // Enable + JAPOST_T japanPost; // Enable + PLANET_T usPlanet; // Enable,Check + POSTNET_T usPostnet; // Enable,Check + // 2D Codes + AZTEC_T aztec; // Enable,AztecRune + CODABLOCK_T codablock; // Enable + MAXICODE_T maxicode; // Enable + MICROPDF_T microPDF; // Enable + PDF417_T pdf417; // Enable + QR_T qr; // Enable + RSS_T rss; // Enable + TLCODE39_T tlCode39; // Enable + // New codes + MATRIX25_T matrix25; // Enable, + KORPOST_T koreaPost; // Enable + TRIOPTIC_T triopticCode; // Enable + CODE25_T code2of5; // Enable + PLESSEY_T plesseyCode; // Enable + CHINAPOST_T chinaPost; // Enable + TELEPEN_T telepen; // Enable,OldStyle? + CODE16K_T code16k; // Enable + POSICODE_T posiCode; // Enable,Limited 1 and 2 + COUPONCODE_T couponCode; // Enable + USPS4STATE_T usps4Post; // Enable + IDTAG_T idtagPost; // Enable + RSSLIM_T rssLim; // Enable + RSSEXP_T rssExp; // Enable +} SymCfg_t, *PSymCfg_t; + + +// Intell Img Structure +typedef struct +{ + int AspectRatio; // ratioof barcode height to narrow elem width + int OffsetX; // offset in X direction, relative to barcode center + int OffsetY; // offset in Y direction + unsigned int width; // width of image in IntellBarcodeUnits + unsigned int height; // height of image + int resolution; // # pixels/IntellBarcodeUnits + ImageFormat_t format; + unsigned int destNaturalWidthInPixels; // (OUT) base to report native DPI + unsigned int destNaturalHeightInPixels; + unsigned int destWidthInPixels; // (IN) alternative to resolution (if resolution = 0) + unsigned int destHeightInPixels; +} IntellImgDesc_t; + +// Image Properties Structure +typedef struct +{ + DWORD dwSize; + DWORD dwEngineID; + DWORD dwImagerRows; + DWORD dwImagerCols; + DWORD dwBitsPerPixel; + DWORD dwRotation; + DWORD dwAimerXoffset; + DWORD dwAimerYoffset; + DWORD dwYDepth; +} ImagerProperties_t; + +//Image Atributes Structure +typedef struct +{ + int Size; // Size of image + int Exposure; // + int Gain; // + int IllumValue; // + int IllumMax; // + int IllumClip; // +} ImageAttributes_t; + + +//Decode RAW data Structure +typedef struct +{ + Int8* pchMessage; + Int8 chCodeID; + Int8 chSymLetter; + Int8 chSymModifier; + Int16 nLength; +} DecodeMsgRaw_t; + + +//RECT structure +typedef struct _RECT { + LONG left; + LONG top; + LONG right; + LONG bottom; +} RECT, *PRECT, *LPRECT; + + + typedef enum + { + ES_EXPOSURE_METHOD, /* How should we do this */ + ES_TARGET_VALUE, /* This is the target pixel count we shoot for */ + ES_TARGET_PERCENTILE, /* This goes along with Value, the target value should be at this percentile */ + ES_TARGET_ACCEPT_GAP, /* How close to the target value must we be */ + ES_MAX_EXP, /* This is the maximum exposure we're allowed to use */ + ES_MAX_GAIN, /* This is the maximum gain we're allowed to use */ + ES_STARTING_EXP, /* When scanning starts, this is the first exposure that we try (updated when scanning stops)*/ + ES_STARTING_GAIN, /* When scanning starts, this is the first gain that we try (updated when scanning stops)*/ + ES_FRAME_RATE, /* This is essentially the frame rate to use, I call it divide because that's what it does */ + ES_CONFORM_IMAGE, /* The image must conform to the auto-exposure requirements, if not, it's rejected. */ + ES_CONFORM_TRIES, /* The number of times we'll attempt to conform. */ + ES_SPECULAR_EXCLUSION, /* Do we exclude specular? to what degree? */ + ES_SPECULAR_SAT, /* These next two only come into play if somebody specifies nSpecularExclusion*/ + ES_SPECULAR_LIMIT, /* to be HHPSD_SPECULAR_EXCLUSION_SPECIAL. */ + ES_FIXED_EXP, + ES_FIXED_GAIN, + ES_FIXED_FRAME_RATE, + ES_ADJUST_EXP_WHEN_ILLUM_OFF, + ES_CENTER_SAMPLE_WINDOW_TOP, + ES_CENTER_SAMPLE_WINDOW_BOT, + ES_CENTER_SAMPLE_WINDOW_LFT, + ES_CENTER_SAMPLE_WINDOW_RGT, + ES_CENTER_SAMPLE_WINDOW_H_PER, + ES_CENTER_SAMPLE_WINDOW_V_PER, + ES_MIN_EXP, + ES_NUM_EXPOSURE_ITEMS + } HHP_IMAGER_EXPOSURE_TAG; + +typedef enum { + HHPSD_IOCTL_START_SCANNING, + HHPSD_IOCTL_STOP_SCANNING, + HHPSD_IOCTL_GET_NEW_SCAN, + HHPSD_IOCTL_UNREGISTER_SCAN_BUFFER, + HHPSD_IOCTL_REGISTER_SCAN_BUFFER, + HHPSD_IOCTL_GET_SCAN_HEIGHT, + HHPSD_IOCTL_GET_SCAN_WIDTH, + HHPSD_IOCTL_SET_ILLUMINATORS_STATE, + HHPSD_IOCTL_SET_AIMER_STATE, + HHPSD_IOCTL_SET_EXPOSURE_SETTINGS, + HHPSD_IOCTL_GET_EXPOSURE_SETTINGS, + HHPSD_IOCTL_RETURN_SCAN, + HHPSD_IOCTL_SET_SCAN_LIGHTS_MODE, + HHPSD_IOCTL_GET_ENGINE_TYPE, + HHPSD_IOCTL_SET_EXPOSURE_MODE, + HHPSD_IOCTL_SET_ILLUMINATOR_INTENSITY, + HHPSD_IOCTL_SET_AIMER_INTENSITY, + HHPSD_IOCTL_NEW_IMAGE_AVAILABLE, + HHPSD_IOCTL_PREVENT_AIMER_IN_IMAGES, + HHPSD_IOCTL_GET_IMAGE_ATTRIBUTES, + HHPSD_IOCTL_RECONFIG_ENGINE, + HHPSD_IOCTL_SINGLE_FRAME_CAPTURE, + HHPSD_IOCTL_GET_REVISION_STRING, + HHPSD_IOCTL_GET_IMAGER_PROPERTIES, + HHPSD_IOCTL_POWER_OFF_IMAGER, + HHPSD_IOCTL_SET_ENGINE_CONFIG, + HHPSD_IOCTL_GET_ENGINE_CONFIG, + HHPSD_IOCTL_WRITE_PSOC_REG, + HHPSD_IOCTL_READ_PSOC_REG, + HHPSD_IOCTL_WRITE_PSOC, + HHPSD_IOCTL_READ_PSOC +// HHPSD_IOCTL_WRITE_I2C_PSOC, +// HHPSD_IOCTL_READ_I2C_PSOC +}HHPScanDriverIOCTL_t; + +typedef enum { + HHPSD_EXPOSURE_FIXED, + HHPSD_AUTOEXPOSURE_USE_ONCHIP, + HHPSD_AUTOEXPOSURE_USE_HHP +}HHPScanDriverAutoExposureMode_t; + +typedef enum { + HHPSD_ILLUM_AIMER_OFF, + HHPSD_ILLUM_ONLY_ON, + HHPSD_AIMER_ONLY_ON, + HHPSD_ILLUM_AIMER_ON +} HHPScanDriverIlluminationStates_t; + +typedef enum { + HHPSD_AE_METHOD_UNIFORM, + HHPSD_AE_METHOD_CENTER_ONLY, + HHPSD_AE_METHOD_CENTER_WEIGHTED +} HHPScanDriverHHPExposureMethod; + +typedef enum { + HHPSD_SPECULAR_EXCLUSION_OFF, + HHPSD_SPECULAR_EXCLUSION_MINIMAL, + HHPSD_SPECULAR_EXCLUSION_MODERATE, + HHPSD_SPECULAR_EXCLUSION_AGGRESSIVE, + HHPSD_SPECULAR_EXCLUSION_SPECIAL +} HHPScanDriverHHPExposureSpecularExclusion; + +typedef enum { + HHPSD_ENGINE_IMAGER_OV7120, + HHPSD_ENGINE_IMAGER_ICMEDIA, + HHPSD_ENGINE_LINEAR_IMAGER_TOSHIBA, + HHPSD_ENGINE_IMAGER_ALD_ICMEDIA, + HHPSD_ENGINE_IMAGER_MI1300, + HHPSD_ENGINE_IMAGER_STM_VC700, + HHPSD_ENGINE_IMAGER_STM_VC602, + HHPSD_ENGINE_IMAGER_MICRON_MT9V022 + } HHPScanDriverEngineType_t; + +typedef enum { + HHPSD_IMAGE_STAT_EXPOSURE, + HHPSD_IMAGE_STAT_GAIN, + HHPSD_IMAGE_STAT_ILLUM_VALUE, + HHPSD_IMAGE_STAT_ILLUM_MAXIMUM, + HHPSD_IMAGE_STAT_ILLUM_CLIP, + HHPSD_IMAGE_STAT_HEIGHT, + HHPSD_IMAGE_STAT_WIDTH +} HHPScanDriverImageAttributes_t; + + +typedef enum { + IP_SIZE, + IP_ENGINE_ID, + IP_NUM_ROWS, + IP_NUM_COLS, + IP_BITS_PER_PIXEL, + IP_ROTATION, + IP_AIMER_X_OFFSET, + IP_AIMER_Y_OFFSET, + IP_YDEPTH +} HHPScanDriverImagerProperties_t; + + +typedef enum { + HHPSD_ILLUMINATION_TYPE, + HHPSD_LED_CONTROL_MODE, + HHPSD_PIXEL_CLOCK_FREQUENCY, + HHPSD_ENGINE_ID, + HHPSD_ENGINE_FW_CKSUM, + HHPSD_ENGINE_FW_VERSION, + HHPSD_ENGINE_AIMER_X_CENTER, + HHPSD_ENGINE_AIMER_Y_CENTER, + HHSD_NUM_ENGINE_CFG_ITEMS +} HHPScanDriverEngineConfiguration_t; + + +#endif diff --git a/src/JanamScnCompatible.h b/src/JanamScnCompatible.h new file mode 100644 index 0000000..98f68d7 --- /dev/null +++ b/src/JanamScnCompatible.h @@ -0,0 +1,124 @@ +/****************************************************************************** + * + * Conversion between old functions to new functions + * + * Copyright (c) 2006 Janam Partners LLC. All rights reserved. + * + * File: JanamExtendedStruct.h + * + * Release: Palm OS 5.x + * + * Description: Extended Struct for using BABBO devices + * + * History: + * Version 1.0 PT, JL Oct, 2006 + * + *****************************************************************************/ + + +#define ScanOpenDecoder ScnOpenDecoder +#define ScanCloseDecoder ScnCloseDecoder +#define ScanCmdScanDisable ScnCmdScanDisable +#define ScanCmdScanEnable ScnCmdScanEnable +#define ScanCmdStartDecode ScnCmdStartDecode +#define ScanCmdStopDecode ScnCmdStopDecode +#define ScanCmdAimOn ScnCmdAimOn +#define ScanCmdAimOff ScnCmdAimOff +#define ScanCmdSendParams ScnCmdSendParams +#define ScanCmdGetAllParams ScnCmdGetAllParams +#define ScanCmdBeep ScnCmdBeep +#define ScanGetDecodedData ScnGetDecodedData +#define ScanGetExtendedDecodedData ScnGetExtendedDecodedData +#define ScanCmdParamDefaults ScnCmdParamDefaults +#define ScanGetDecoderVersion ScnGetDecoderVersion +#define ScanGetScanManagerVersion ScnGetScanManagerVersion +#define ScanGetScanPortDriverVersion ScnGetScanPortDriverVersion +#define ScanSetBarcodeEnabled ScnSetBarcodeEnabled +#define ScanGetBarcodeEnabled ScnGetBarcodeEnabled +#define ScanSetDecodeUpcEanSupplementals ScnSetDecodeUpcEanSupplementals +#define ScanGetDecodeUpcEanSupplementals ScnGetDecodeUpcEanSupplementals +#define ScanSetDecodeUpcEanRedundancy ScnSetDecodeUpcEanRedundancy +#define ScanGetDecodeUpcEanRedundancy ScnGetDecodeUpcEanRedundancy +#define ScanSetTransmitCheckDigit ScnSetTransmitCheckDigit +#define ScanGetTransmitCheckDigit ScnGetTransmitCheckDigit +#define ScanSetUpcPreamble ScnSetUpcPreamble +#define ScanGetUpcPreamble ScnGetUpcPreamble +#define ScanSetConvert ScnSetConvert +#define ScanGetConvert ScnGetConvert +#define ScanSetEanZeroExtend ScnSetEanZeroExtend +#define ScanGetEanZeroExtend ScnGetEanZeroExtend +#define ScanSetUpcEanSecurityLevel ScnSetUpcEanSecurityLevel +#define ScanGetUpcEanSecurityLevel ScnGetUpcEanSecurityLevel +#define ScanSetCode32Prefix ScnSetCode32Prefix +#define ScanGetCode32Prefix ScnGetCode32Prefix +#define ScanSetBarcodeLengths ScnSetBarcodeLengths +#define ScanGetBarcodeLengths ScnGetBarcodeLengths +#define ScanSetCode39CheckDigitVerification ScnSetCode39CheckDigitVerification +#define ScanGetCode39CheckDigitVerification ScnGetCode39CheckDigitVerification +#define ScanSetI2of5CheckDigitVerification ScnSetI2of5CheckDigitVerification +#define ScanGetI2of5CheckDigitVerification ScnGetI2of5CheckDigitVerification +#define ScanSetClsiEditing ScnSetClsiEditing +#define ScanGetClsiEditing ScnGetClsiEditing +#define ScanSetNotisEditing ScnSetNotisEditing +#define ScanGetNotisEditing ScnGetNotisEditing +#define ScanSetMsiPlesseyCheckDigits ScnSetMsiPlesseyCheckDigits +#define ScanGetMsiPlesseyCheckDigits ScnGetMsiPlesseyCheckDigits +#define ScanSetMsiPlesseyCheckDigitAlgorithm ScnSetMsiPlesseyCheckDigitAlgorithm +#define ScanGetMsiPlesseyCheckDigitAlgorithm ScnGetMsiPlesseyCheckDigitAlgorithm +#define ScanSetLaserOnTime ScnSetLaserOnTime +#define ScanGetLaserOnTime ScnGetLaserOnTime +#define ScanSetAimDuration ScnSetAimDuration +#define ScanGetAimDuration ScnGetAimDuration +#define ScanSetTriggeringModes ScnSetTriggeringModes +#define ScanGetTriggeringModes ScnGetTriggeringModes +#define ScanSetTimeOutBetweenSameSymbol ScnSetTimeOutBetweenSameSymbol +#define ScanGetTimeOutBetweenSameSymbol ScnGetTimeOutBetweenSameSymbol +#define ScanSetParameterScanning ScnSetParameterScanning +#define ScanGetParameterScanning ScnGetParameterScanning +#define ScanSetLinearCodeTypeSecurityLevel ScnSetLinearCodeTypeSecurityLevel +#define ScanGetLinearCodeTypeSecurityLevel ScnGetLinearCodeTypeSecurityLevel +#define ScanSetBidirectionalRedundancy ScnSetBidirectionalRedundancy +#define ScanGetBidirectionalRedundancy ScnGetBidirectionalRedundancy +#define ScanSetTransmitCodeIdCharacter ScnSetTransmitCodeIdCharacter +#define ScanGetTransmitCodeIdCharacter ScnGetTransmitCodeIdCharacter +#define ScanSetPrefixSuffixValues ScnSetPrefixSuffixValues +#define ScanGetPrefixSuffixValues ScnGetPrefixSuffixValues +#define ScanSetScanDataTransmissionFormat ScnSetScanDataTransmissionFormat +#define ScanSetAngle ScnSetAngle +#define ScanGetAngle ScnGetAngle +#define ScanGetScanDataTransmissionFormat ScnGetScanDataTransmissionFormat +#define ScanCmdLedOn ScnCmdLedOn +#define ScanCmdLedOff ScnCmdLedOff +#define ScanSetHostSerialResponseTimeOut ScnSetHostSerialResponseTimeOut +#define ScanGetHostSerialResponseTimeOut ScnGetHostSerialResponseTimeOut +#define ScanSetHostCharacterTimeOut ScnSetHostCharacterTimeOut +#define ScanGetHostCharacterTimeOut ScnGetHostCharacterTimeOut +#define ScanSetIntercharacterDelay ScnSetIntercharacterDelay +#define ScanGetIntercharacterDelay ScnGetIntercharacterDelay +#define ScanSetBeepAfterGoodDecode ScnSetBeepAfterGoodDecode +#define ScanGetBeepAfterGoodDecode ScnGetBeepAfterGoodDecode +#define ScanSetBeepDuration ScnSetBeepDuration +#define ScanGetBeepDuration ScnGetBeepDuration +#define ScanSetBeepFrequency ScnSetBeepFrequency +#define ScanGetBeepFrequency ScnGetBeepFrequency +#define ScanSetDecodeLedOnTime ScnSetDecodeLedOnTime +#define ScanGetDecodeLedOnTime ScnGetDecodeLedOnTime +#define ScanGetAimMode ScnGetAimMode +#define ScanGetScanEnabled ScnGetScanEnabled +#define ScanGetLedState ScnGetLedState +#define ScanIsPalmSymbolUnit ScnIsJanamUnit +#define ScanSetCode39FullAscii ScnSetCode39FullAscii +#define ScanGetCode39FullAscii ScnGetCode39FullAscii +#define ScanCmdTrigSledOn ScnCmdTrigSledOn +#define ScanCmdTrigSledOff ScnCmdTrigSledOff +#define ScanGetTrigSledMode ScnGetTrigSledMode + +//The followings are extended functions supported by BABBO devices +//Define as ScanCmd are only for convenience +#define ScanCmdReadSymbologyConfig ScnCmdReadSymbologyConfig +#define ScanCmdWriteSymbologyConfig ScnCmdWriteSymbologyConfig +#define ScanCmdSetupOCR ScnCmdSetupOCR +#define ScanCmdGetSetupOCR ScnCmdGetSetupOCR +#define ScanCmdAimerOn ScnCmdAimerOn +#define ScanCmdLightsOn ScnCmdLightsOn + diff --git a/src/MeazuraLib_V305.h b/src/MeazuraLib_V305.h new file mode 100644 index 0000000..c9e2e3f --- /dev/null +++ b/src/MeazuraLib_V305.h @@ -0,0 +1,1496 @@ +/****************************************************************************** + * + * Copyright (c) 2003, ACEECA Limited. All rights reserved. + * + * File: MeazuraLib_V300b.h + * + * Release: 8th June 2004, + * MzLibVersion = 3,0,0,sysROMStageBeta,5 + * + * Description: + * Meazura library API definitions. + * + * History: + * V300b: + * 19-Dec-03 HD: Swapped the definitions for PeripheralUSBCradle and PeripheralRS232Cradle + * to agree with the API. + * 20-Jan-04 HD: Added more baudrate enumerations for UARTcontrolCodeSetBaudRate. + * 18-Feb-04 HD: Incorporated two new enumerations for MzParallelControl which are: + * ParallelControlCodeEnableCS0 and ParallelControlCodeDisableCS0. + * These new enumerations will give the developer the ability to disable + * CS0 and use it as a GPIO pin if required. + * 18-Feb-04 HD: Added ParallelControlCodeGPIOSetCS1, ParallelControlCodeGPIOGetCS1, + * ParallelControlCodeGPIOSetCS0, ParallelControlCodeGPIOGetCS0 to the + * Parallel control enumerations. + * 20-Feb-04 HD: Improved the header document to be more compatible with GCC compilers as + * well as adding better descriptions for the *value parameter for each enumeration. + * 23-Feb-04 HD: Changed MOD_PWR and MOD_RESET to be inputs pulled low on exit of the API + * library. They were previously being driven low. + * 30-Mar-04 HD: Was not checking null pointer errors for ModuleControlCodeUART2ViaModule. + * The enumeration now returns mzNullPointerError if the boolean value given is a + * NULL pointer. + * 30-Mar-04 HD: Incorporated checking of requested MZIO functionality to see if it being currently + * used by the system. If the function requested is being used by the system the + * mzHwFunctionBusy error is returned. This checking incurs a small overhead on all the + * routines listed to the right. + * V301b + * 1-Apr-04 HD: Added a UARTcontrolCodeSetCustomBaudrate so that the caller can set a custom baudrate + * if the standard baudrates listed are insufficient. + * 19-Apr-04 HD: Changed numberOfBytes in MzSPITransferData and MzSPIReceiveData to be numberOfWords. + * HD: Changed the documentation to make clear the arguments in MzSPITransferData, MzSPIReceiveData + * MzUARTTrasmitData and MzUARTReceiveData. + * 22-Apr-04 HD: SPIcontrolCodeEnablePort now checks for a NULL pointer error on valueP. + * HD: ParallelControlCodeGPIOSetCS1, ParallelControlCodeGPIOGetCS1, ParallelControlCodeGPIOGetCS0, ParallelControlCodeGPIOSetCS0 + * now check for NULL pointers before using valueP. + * HD: MzLibSleep and MzLibWake now check for NULL pointers when accessing the library globals structure. + * 12-May-04 HD: Fixed bug in V300b library where when changing UART1 baudrate, debugging data was being + * output from the library via UART1 port. + * V302b + * 4-Jun-04 HD: Corrected the bug where the signals returned from MzGPIOGetValue for the UART_TX and UART_RX masks were + * swapped around. + * 8-Jun-04 HD: Corrected the bug where non-zero bit values were being returned by MzGPIOGetValue for the un-masked bits. + * The function now only returns the bit field representing the GPIO lines defined in the mask fiel, + * all other bits are zeroed. + * HD: Corrected the bug where ModuleControlCodeMOD_PWRGet was setting the MOD_POWER pin to dedicated functions instead + * of GPIO. + * HD: ParallelControlCodeGPIOGetCS1 and ParallelControlCodeGPIOGetCS0 have been modified to return + * a true boolean value when returning the state of the corresponding pin. + * + * V303b + * 7-Oct-04 HD: UARTcontrolCodeSetBaudRate for baudrates greater than UARTBaudRate230400 in the enum list + * was causing a problem when checking for a valid baudrate value. This has now been changed + * to reference the maximum enum to UARTBaudRateLast. + * 24-Nov-04 HD: Found that external 100K pull downs on MOD_RESET and MOD_PWR were not sufficient to keep + * these lines low resulting in ~1.5V on the pins. On MOD_PWR this can sometimes result in + * the unit losing power overnight as it is drained by the module. The software now pushes + * these lines low when the library exits. Please note that if these pins are driven high + * from an external source, there is a potential to short circuit the pin causing undesirable + * results. It is advised that if the pins are being used as GPIO inputs, series resistors + * be placed on the respective lines to limit the current into the pins. + * HD: Instead of generating a fatal exception alert, now MeazuraErrParam is returned when + * the version pointer is a NULL value. + * 18-Jan-05 HD: Will now always check the peripheral resistor data is up to date by reading the value of the + * resistor directly. Was previously relying on the value of updated globals. + * HD: Corrected a bug in MzGetPeripheralID where by PeripheralNoDevicePresent was being returned in + * the place of Peripheral560K. + * 15-Mar-05 HD: Changed MzLibClose to NOT set UART2 to channel to the cradle interface by default. It now remains sticky + * even when the Meazura API library is closed. + * 31-Mar-05 HD: Modified the ParallelControlSetCS1Size opcode in MzParallelControl so that it doesn't + * always return an error code. The error code was being returned even if the hardware + * wasn't busy, hence not changing the size of the chip select. + * + * V304b + * 9-May-05 HD: Found that ParallelControlCodeEnableCS1 and ParallelControlCodeDisableCS1 were only addressing + * reconfiguration of the physical pin to be routed via the chip select function. The actual chip + * select was however not being enabled. Upon reset, the chip select was set to be enabled + * by the HAL and hence didn't cause a problem previously. However now that compact flash + * specifically disables the chip select if a CF card is not found, an bus error is + * generated causing Fatal Exception alerts. This has now been addresssed. + * + * V305 + * 02-Sep-05 HD: Incorporated error checking in MzLibGetVersion if SysGetROMToken fails, such as times when the + * token doesn't exist. + * + * + * + *****************************************************************************/ + +#ifndef __MEAZURA_LIB_H__ +#define __MEAZURA_LIB_H__ + +// If we're actually compiling the library code, then we need to +// eliminate the trap glue that would otherwise be generated from +// this header file in order to prevent compiler errors in CW Pro 2. +#ifdef BUILDING_Meazura_LIB + #define Meazura_LIB_TRAP(trapNum) +#else + #define Meazura_LIB_TRAP(trapNum) SYS_TRAP(trapNum) +#endif + + +#ifdef __MWERKS__ +#pragma mark Library Version +#endif +/******************************************************************** + * Library Version + ********************************************************************/ +// The library version scheme follows the system versioning scheme. +// See sysMakeROMVersion and friends in SystemMgr.h. +// +// For reference: +// +// 0xMMmfsbbb, where MM is major version, m is minor version +// f is bug fix, s is stage: 3-release,2-beta,1-alpha,0-development, +// bbb is build number for non-releases +// V1.12b3 would be: 0x01122003 +// V2.00a2 would be: 0x02001002 +// V1.01 would be: 0x01013000 +#define MzLibVersion sysMakeROMVersion(3, 0, 0, sysROMStageBeta, 5) + + +/******************************************************************** + * Meazura Feature Numbers + ********************************************************************/ +#define MzFeatureCreator 'AFtr' // ACEECA's feature creator + + +// Feature number for ROM version +#define MzFeatureIDVersion 'rs' // Feature number for ROM version + +// Feature number for flash disk +#define MzFeatureFlashDiskVersion 2 // Feature number for flash disk + + +/******************************************************************** + * Type and creator of Meazura Library database + ********************************************************************/ +#define MzLibCreatorID 'MAPI' // Meazura Library database creator +#define MzLibTypeID 'libr' // Standard library database type + +/******************************************************************** + * Internal library name which can be passed to SysLibFind() + ********************************************************************/ +#define MzLibName "MeazuraAPILibrary" + +/******************************************************************** + * Registered Meazura notifications + ********************************************************************/ +#ifdef __MWERKS__ +#pragma mark Meazura Notifications +#endif +#define MzAlmNotification 'MZAL' // External alarm notification +#define MzPerpNotification 'MZPE' // Peripheral change notification +#define MzModuleNotification 'MZMD' // Module interrupt notification +#define MzWakeupNotification 'MZWK' // Wakeup notification + +// Note: +// All of these notifications have NULL notify data pointers, ie. no system data +// returned with the notification. They however support user data pointers that +// can be set up using SysNotifyRegister. +// +// When catching a MzPerNotification you can request peripheral information +// using the MzGetPeripheralID API. +// + +#ifdef __MWERKS__ +#pragma mark Meazura Key Bit definitions +#endif +/******************************************************************** + * Meazura key bit definitions + ********************************************************************/ +#define MzLeftKeyBit keyBitHard1 +#define MzCentreKeyBit keyBitHard2 +#define MzRightKeyBit keyBitHard3 +#define MzUpKeyBit keyBitPageUp +#define MzDownKeyBit keyBitPageDown +#define MzPowerKeyBit keyBitPower + +#ifdef __MWERKS__ +#pragma mark Meazura Virtual Key definitions +#endif +/******************************************************************** + * Meazura virtual keys definitions + ********************************************************************/ +#define MzVLeftKey chrLeftArrow +#define MzVCentreKey vchrHard1 +#define MzVRightKey chrRightArrow +#define MzVUpKey vchrPageUp +#define MzVDownKey vchrPageDown +#define MzVPowerKey vchrAutoOff + +#define MzVirtualKeyMin 0x1D00 +#define MzVirtualKeyMax 0x1D0F +#define MzBarcodeReceivedKey 0x1D00 // enqueued when a valid barcode is received +#define MzBatteryTriggerOn 0x1D01 // enqueued when the trigger +#define MzBatteryTriggerOff 0x1D02 // enqueued when the trigger + + +/************************************************************ + * Meazura Library result codes + * (appErrorClass is reserved for 3rd party apps/libraries. + * It is defined in SystemMgr.h) + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark Error Codes +#endif + +#define MeazuraErrParam (oemErrorClass | 0x1) // invalid parameter +#define MeazuraErrNotOpen (oemErrorClass | 0x2) // library is not open +#define mzLibAlreadyOpen (oemErrorClass | 0x3) // returned from MzLibClose() if the library is still open by others +#define mzMemoryError (oemErrorClass | 0x4) // memory error occurred +#define mzHwFunctionNotSupported (oemErrorClass | 0x5) // the function being accessed is not available on the current hardware +#define mzHwFunctionBusy (oemErrorClass | 0x6) // the function being accessed is being accessed by someone else + +// API error codes +#define mzNullPointerError (oemErrorClass | 0xA) // Error setting the alarm +#define mzSetAlarmError (oemErrorClass | 0xB) // Error setting the alarm +#define mzCommsError (oemErrorClass | 0xC) // Error communicating with external processor +#define mzControlCodeError (oemErrorClass | 0xD) // Unrecognised control code +#define mzTimeOutError (oemErrorClass | 0xE) // Baud rate to SPI controller unrecognised +#define mzBadBaudRateError (oemErrorClass | 0x10) // Baud rate unrecognised +#define mzConfigError (oemErrorClass | 0x11) // Error setting up the configuration + +#define mzNullCallbackProcPtrError (oemErrorClass | 0x12) // Null callback function pointer +#define mzNullCallbackDataPtrError (oemErrorClass | 0x13) // Null callback data pointer + +#define mzUARTOverrunError (oemErrorClass | 0x14) // UART has received an overrun error +#define mzUARTFrameError (oemErrorClass | 0x15) // UART has received a frame error +#define mzUARTParityError (oemErrorClass | 0x16) // UART has received parity error + +#define mzParallelChipSelectError (oemErrorClass | 0x17) // Unrecognised chip select +#define mzParallelOffsetError (oemErrorClass | 0x18) // Offset is out of range +#define mzParallelDataSizeError (oemErrorClass | 0x19) // The size and offset specified is out of the addressable chip select range + +#define mzGPIOPinBusyError (oemErrorClass | 0x1A) // The pin is currently being used by some dedicated function + +#define mzNoFIFODataError (oemErrorClass | 0x1B) // This error is returned when there is no data in the receive FIFO +#define mzPortNotOpenError (oemErrorClass | 0x1C) // Returned when the port is not openned. + + +#ifdef __MWERKS__ +#pragma mark - +#endif +/******************************************************************** + * Callback function prototypes + ********************************************************************/ +typedef void (*ModuleCallbackPtr) (MemPtr userData); +typedef void (*SPICallbackPtr) (UInt8 SPIIntStatus, MemPtr userData); +typedef void (*UARTCallbackPtr) (UInt8 UARTIntStatus, MemPtr userData); + +/******************************************************************** + * Public Structures + ********************************************************************/ +typedef struct MzCallbackType +{ + void* callbackProcPtr; // pointer to a callback procedure when SPI interrupt occurs + void* callbackDataPtr; // pointer to a user specified callback data structure passed to the interrupt +} MzCallbackType; +typedef MzCallbackType* MzCallbackPtr; + +typedef struct MzVersion +{ + UInt32 APIVersion; // The version of the API + UInt32 PICVersion; // The firmware version of the keypad board processor + UInt32 ROMVersion; // The ROM OS version + UInt32 HardwareVersion; // The hardware version, format 0xMMxxxbbb, MM - major version, bbb - minor version, x - don't care +} MzVersion; +typedef MzVersion* MzVersionPtr; + + + +#ifdef __MWERKS__ +#pragma mark Alarm API structures +#endif +// -------------------------------------------------------------------// +// Alarm API structures +// -------------------------------------------------------------------// +typedef struct MzAlarmType +{ + Int8 second; // start time second (00 - 59) + Int8 minute; // start time minute (00 - 59) + Int8 hour; // start time hour (00 - 23) + Int8 day; // start time day (1 - 31), see notes + Int8 prdUnits; // period units, see description below + Int8 period; // period (0 - 255) + Int16 maxAlarmCnt; // maximum alarm count (0 = no limit) + Int8 almConfig; // Alarm configuration register +} MzAlarmType; +typedef MzAlarmType* MzAlarmPtr; + +// Periodic units supported +#define tenMsUnits 0x40 // 10ms unit +#define secondsUnits 0x01 // seconds unit +#define minutesUnits 0x02 // minutes unit +#define hoursUnits 0x04 // hourly unit +#define daysUnits 0x08 // daily unit +#define weeksUnits 0x10 // weekly unit +#define monthsUnits 0x20 // montly unit + +// Alarm configuration types +#define wakeOS_onAlarm 0x01 +#define wakeModule_onAlarm 0x02 +#define powerupUnit_onAlarm 0x04 // Not currently supported +#define kybSleep_afterAlarm 0x08 + +#ifdef __MWERKS__ +#pragma mark SPI API structures +#endif +// -------------------------------------------------------------------// +// SPI API structures +// -------------------------------------------------------------------// +typedef enum MzSPIControlCodeEnum +{ + SPIcontrolCodeEnablePort, + // Enables the SPI hardware. This should be done before accessing + // other SPI configurations. + // *valueP = (UInt8) Pins to be used for SPI (see GPIO control API structures) eg. SPI_MOSI etc. + + SPIcontrolCodeDisablePort, + // Disables the SPI hardware + // valueP = NULL + + SPIcontrolCodeEnableInterrupts, + // Enables interrupts in the interruptType register + // *valueP = (UInt8) Interrupt types supported, eg. SPITxFIFOEmpty etc. + + SPIcontrolCodeDisableInterrupts, + // Disables all currently configured SPI interrupts + // valueP = NULL + + SPIcontrolCodeSetConfiguration, + // Sets the configuration bits in the config register + // *valueP = (UInt16) configuration tuple eg. SPIPortIsMaster etc. + + SPIcontrolCodeSetBaudRate, + // Sets the baud rate divisor in the baudRate register + // *valueP = (UInt16) baud rate tuple eg. SPIbaudRateSysClkDiv4 etc. + + SPIcontrolCodeSetSamplePeriod, + // Sets the amount of time between samples in master mode. + // *valueP = (UInt16) sample period value. Bitwise OR with samplePeriodSelect32khz + // to get the 32kHz clock instead of SPI clock (33Mhz/divisor) + + SPIcontrolCodeSetBitsToTransfer, + // Sets the number of bits to transfer in the numberOfBits register + // *valueP = (UInt8) number of bits to transfer (1 to 16) + + SPIcontrolCodeFlushReceiveFIFO, + // Flushes the receive fifo of the SPI + // valueP = NULL + + SPIcontrolCodeSetCallbackProc + // Sets the callback function for SPI interrupt processing + // *valueP = (MzCallbackPtr) callback data information callbackProcPtr, callbackDataPtr +} MzSPIControlCodeEnum; + +// Divisors for SPI baudRate (SPICONT1 register), SYSCLK= 33Mhz +#define SPIbaudRateSysClkDiv4 0x0000 +#define SPIbaudRateSysClkDiv8 0x2000 +#define SPIbaudRateSysClkDiv16 0x4000 +#define SPIbaudRateSysClkDiv32 0x6000 +#define SPIbaudRateSysClkDiv64 0x8000 +#define SPIbaudRateSysClkDiv128 0xA000 +#define SPIbaudRateSysClkDiv256 0xC000 +#define SPIbaudRateSysClkDiv512 0xE000 +#define SPIbaudRateMask 0xE000 // Data Rate mask + +// SPI interrupt types supported (high byte of SPIINTCS register) +#define SPITxFIFOEmpty 0x01 // Interrupts when the transmit FIFO is empty +#define SPITxFIFOHalf 0x02 // Interrupts when the transmit FIFO has 4 words or fewer +#define SPITxFIFOFull 0x04 // Interrupts when the transmit FIFO is full +#define SPIRxFIFOReady 0x08 // Interrupts when the receive FIFO is ready with at least 1 byte/word of data +#define SPIRxFIFOHalf 0x10 // Interrupts when the receive FIFO has at least 4 words +#define SPIRxFIFOFull 0x20 // Interrupts when the receive FIFO is full +#define SPIRxFIFOOverflow 0x40 // Interrupts when the receive FIFO overflows +#define SPIBitCountOverflow 0x80 // Interrupts when the bit count overflows, see note 1 + +// SPI configuration types (SPICONT1 register) +#define SPIDRActiveLow 0x1000 // Configures Data Ready to be active low +#define SPIDRFallingEdge 0x0800 // Configures Data Ready to be falling edge +#define SPIPortIsMaster 0x0400 // Configures the SPI to be the master +#define SPISSPolarityIsHigh 0x0080 // Makes the SS active high +#define SPISSWaveformSelect 0x0040 // See note 2 below +#define SPIPhaseBitSet 0x0020 // See note 3 below +#define SPIPolarityBitSet 0x0010 // + +// SPI bits to transfer mask (SPICONT1 register) +#define SPIBitCountMask 0x000F + +// Sampling period clock type (SPISPC register) +#define samplePeriodSelect32khz 0x8000 // If set=32kHz selected, otherwise SPICLK selected. +#define sampleNumberOfClocksMask 0x7FFF // 15-bits for setting up how many clocks between samples +/* +// -------------------------------------------------------------------// + Notes: +// -------------------------------------------------------------------// + 1: + BitCountOverflow interrupt + This interrupt is generated if the SPI controller is place in slave mode where + the SPI receive FIFO is advanced by the SS rising edge. An interrupt occurs if + at least 1 of the data locations in the receive FIFO had received more than 16 bits + in one burst. This interrupt can be cleared by reading the SPI data. There is + nothing to indicate which data word has overflowed, hence the bad data word may + still be in the receive FIFO if it is not empty. + + 2: + SPISSWaveformSelect + In master mode this bit selects the output wave form for the SS signal. + In slave mode, this bit controls RxFIFO advancement. + Master Mode: + 0 = SS stays low between SPI 1 bursts + 1 = Insert pulse between SPI 1 bursts + Slave Mode: + 0 = RxFIFO advanced by Bit Count + 1 = RxFIFO advanced by SS rising edge + + 3: + SPIPhaseBitSet and SPIPolarityBitSet + + SPIPolarityBitSet = 1, SPIPhaseBitSet = 1 + ______ ___ ___ ___ _ ________ + |___| |___| |___| |_.... |___| + + SPIPolarityBitSet = 1, SPIPhaseBitSet = 0 + __________ ___ ___ _ _____ ____ + |___| |___| |___| .... |___| + + SPIPolarityBitSet = 0, SPIPhaseBitSet = 1 + ___ ___ ___ _ ___ + ______| |___| |___| |___| ...._| |________ + + SPIPolarityBitSet = 0, SPIPhaseBitSet = 0 + ___ ___ ___ ___ + __________| |___| |___| |_...._____| |____ + + ______ _______ _______ _______ _______ ____ + |__DN___||__DN-1_||__DN-2_|....|__D0___| + +*/ + +#ifdef __MWERKS__ +#pragma mark UART API structures +#endif +// -------------------------------------------------------------------// +// UART API structures +// -------------------------------------------------------------------// +typedef enum MzUARTControlCodeEnum +{ + UARTcontrolCodeEnablePort, + // Enables the UART hardware. This should be done before accessing + // other UART configurations. + // *valueP = (UInt8) UART configuration tuple, eg. UARTReceiverEnable etc + + UARTcontrolCodeDisablePort, + // Disables the UART hardware + // valueP = NULL + + UARTcontrolCodeEnableInterrupts, + // Enables interrupts in the interruptType register + // *valueP = (UInt8) Interrupt type tuple eg. UARTTxFIFOAvailable + + UARTcontrolCodeDisableInterrupts, + // Disables all currently configured UART interrupts + // valueP = NULL + + UARTcontrolCodeSetBaudRate, + // Sets the baud rate of the UART in bits/s + // *valueP = (UInt8) baud rate enum, eg. UARTBaudRate2400 etc. + + UARTcontrolCodeFlushReceiveFifo, + // Flushes the receive fifo + // valueP = NULL + + UARTcontrolCodeSetCallbackProc, + // Sets the callback function and data pointers for interrupt processing + // *valueP = (MzCallbackPtr) callback data information callbackProcPtr, callbackDataPtr + + UARTcontrolCodeSetCustomBaudrate + // Sets a custom baudrate for UART1 + // *valueP = (UInt32) baudrate in bits per second, eg. 115K2 == *valueP = 115200 +} MzUARTControlCodeEnum; + +typedef enum MzUARTBaudRateEnum +{ + UARTBaudRate2400 = 1, + UARTBaudRate9600, + UARTBaudRate19200, + UARTBaudRate57600, + UARTBaudRate115200, + UARTBaudRate230400, + UARTBaudRate1200, + UARTBaudRate4800, + UARTBaudRate14400, + UARTBaudRate28800, + UARTBaudRate38400, + UARTBaudRateLast +} MzUARTBaudRateEnum; + +// UART interrupt types supported +#define UARTTxFIFOAvailable 0x01 // TxFIFO has at least 1 slot empty +#define UARTTxFIFOHalf 0x02 // TxFIFO is less than half full +#define UARTTxFIFOEmpty 0x04 // TxFIFO is empty +#define UARTRxFIFOReady 0x20 // RxFIFO has at least 1 byte +#define UARTRxFIFOHalf 0x40 // RxFIFO has 4 or fewer slots remaining +#define UARTRxFIFOFull 0x80 // RxFIFO is full and may overrun + +// UART configurations types +#define UARTReceiverEnable 0x40 // Enables the UART receiver +#define UARTTransmitterEnable 0x20 // Enables the UART transmitter +#define UARTParityEnable 0x08 // Enables parity checking +#define UARTOddParitySelected 0x04 // If set, odd parity selected. Otherwise even parity selected. +#define UARTTwoStopBitsSelected 0x02 // If set, two stop bits selected. Otherwise one stop bit selected. +#define UART8BitTransmitReceive 0x01 // If set, 8 bit transmit and receive length selected, otherwise 7 bit. + + + +#ifdef __MWERKS__ +#pragma mark Parallel interface API structures +#endif +// -------------------------------------------------------------------// +// Parallel interface API structures +// -------------------------------------------------------------------// +typedef enum MzParallelControlCodeEnum +{ + ParallelControlGetCS1Size, + // Returns the size of CS1 in the mappedSize register + // *valueP = (UInt8) MzParallelCSSizeEnum of the CS1 size. + + ParallelControlSetCS1Size, + // Sets the size of CS1 relative to the mappedSize register + // *valueP = (UInt8) MzParallelCSSizeEnum of the CS1 size. + + ParallelControlCodeConfigureCS1, + // Sets up the configuration of the chip select, + // *valueP = (UInt16) parallel configuration tuple eg. ParallelReadOnly etc + + ParallelControlCodeSetWaitstate, + // Sets up the number of waitstates for the chip select + // *valueP = (UInt16) parallel waitstate enum eg. ParallelWaitState0 etc + + ParallelControlCodeEnableCS1, + // Enables Chip Select 1 of the MZIO bus + // valueP = NULL + + ParallelControlCodeDisableCS1, + // Disables Chip Select 1 of the MZIO bus, sets CS1 pin as input pulled high + // valueP = NULL + + ParallelControlCodeEnableCS0, + // Enables Chip Select 0 of the MZIO bus + // valueP = NULL + + ParallelControlCodeDisableCS0, + // Disables Chip Select 0 of the MZIO bus, sets CS0 pin as input pulled high + // valueP = NULL + + ParallelControlCodeGPIOSetCS1, + // Sets the CS1 chip select pin based on valueP. This will only work if the chip select + // function is disabled, use ParallelControlCodeDisableCS1. + // *valueP = (Boolean) true or false sets the pin accordingly. + + ParallelControlCodeGPIOGetCS1, + // Gets the CS1 chip select pin and returns it to valueP. This will only work if the chip select + // function is disabled, use ParallelControlCodeDisableCS1. + // *valueP = (Boolean) true or false for the state of the pin. + + ParallelControlCodeGPIOSetCS0, + // Sets the CS0 chip select pin based on valueP. This will only work if the chip select + // function is disabled, use ParallelControlCodeDisableCS0. + // *valueP = (Boolean) true or false sets the pin accordingly. + + ParallelControlCodeGPIOGetCS0 + // Gets the CS0 chip select pin and returns it to valueP. This will only work if the chip select + // function is disabled, use ParallelControlCodeDisableCS0. + // *valueP = (Boolean) true or false for the state of the pin. + +} MzParallelControlCodeEnum; + +// Parallel interface configuration types +#define ParallelReadOnly 0x8000 // Makes the chip select read only +#define ParallelFLASHSupport 0x0100 // When set, forces the WE* signal to go active after the chip select line +#define Parallel16BitBus 0x0080 // When set, forces the bus to be 16 bit, otherwise 8 bit bus, this is currently not supported + +// Waitstates supported +typedef enum MzParallelWaitstateEnum +{ + ParallelWaitState0 = 0, // Zero wait states + ParallelWaitState2, // Two wait states + ParallelWaitState4, // Four wait states + ParallelWaitState6, // Six wait states + ParallelWaitState8, // Eight wait states + ParallelWaitState10, // Ten wait states + ParallelWaitState12 // Twelve wait states +} MzParallelWaitstateEnum; + + +// Chip select mapping sizes supported +typedef enum MzParallelCSSizeEnum +{ + ParallelMappingSize32K = 0, + ParallelMappingSize64K, + ParallelMappingSize128K, + ParallelMappingSize256K, + ParallelMappingSize512K, + ParallelMappingSize1M, + ParallelMappingSize2M, + ParallelMappingSize4M +} MzParallelCSSizeEnum; + + + +/* +// -------------------------------------------------------------------// + Notes: +// -------------------------------------------------------------------// + 1: + CS0 chip select limitation + This chip select is currently grouped with the chip select for flash + memory. This means that this chip select is always selected to be 8Mbytes + with zero wait states, configured for flash support and 16 bit wide. +*/ + + +#ifdef __MWERKS__ +#pragma mark PWM control API structures +#endif +// -------------------------------------------------------------------// +// PWM control API structures +// -------------------------------------------------------------------// +typedef enum MzPWMControlCodeEnum +{ + PWMControlCodeEnable, + // Enables the PWM controller + // valueP = NULL + + PWMControlCodeDisable, + // Disables the PWM controller + // valueP = NULL + + PWMControlCodeSetClockDivider, + // Sets up the clock divider (MzPWMClockDividerEnum) + // *valueP = (UInt8) MzPWMClockDividerEnum enum eg. PWMbaudRateSysClkDiv4 + + PWMControlCodeSetPolarity, + // Value=1 inverts the polarity, defaults to zero + // *valueP = (Boolean) true or false for setting polarity + + PWMControlCodeSetPeriod, + // Sets the 16-bit period value + // *valueP = (UInt16) PWM period to set eg. 500 (clock cycles) + + PWMControlCodeSetPulseWidth, + // Set the 16-bit pulse width value + // *valueP = (UInt16) PWM pulse width to period eg. 250 => 50% + + PWMControlCodeGetPin, + // Returns the value of the PWM pin + // *valueP = (Boolean) On or Off for state of the PWM pin + + PWMControlCodeGetCounter + // Returns the PWM counter value + // *valueP = (UInt16) PWM counter value +} MzPWMControlCodeEnum; + +typedef enum MzPWMClockDividerEnum +{ + PWMbaudRateSysClkDiv4 = 0, + PWMbaudRateSysClkDiv8, + PWMbaudRateSysClkDiv16, + PWMbaudRateSysClkDiv32, + PWMbaudRateSysClkDiv64, + PWMbaudRateSysClkDiv128, + PWMbaudRateSysClkDiv256, + PWMbaudRateSysClkDiv512 +} MzPWMClockDividerEnum; + + +#ifdef __MWERKS__ +#pragma mark Module control API structures +#endif +// -------------------------------------------------------------------// +// Module control API structures +// -------------------------------------------------------------------// +typedef enum MzModuleControlCodeEnum +{ + ModuleControlCodeEnableModuleInterrupt, + // Enables the MOD_IREQ* interrupts + // valueP = NULL + + ModuleControlCodeDisableModuleInterrupt, + // Disables the MOD_IREQ* interrupt + // valueP = NULL + + ModuleControlCodeMOD_IREQGet, + // Gets MOD_IREQ + // *valueP = (Boolean) On of Off for MOD_IREQ + + ModuleControlCodeMOD_RESETSet, + // Sets MOD_RESET to the valueP + // *valueP = (Boolean) On of Off for MOD_RESET + + ModuleControlCodeMOD_RESETGet, + // Get MOD_RESET current state + // *valueP = (Boolean) On of Off for MOD_RESET + + ModuleControlCodeMOD_PWRSet, + // Sets MOD_PWR to valueP + // *valueP = (Boolean) On of Off for MOD_PWR + + ModuleControlCodeMOD_PWRGet, + // Get MOD_PWR current state + // *valueP = (Boolean) On of Off for MOD_PWR + + ModuleControlCodeUART2ViaModule, + // If true will enable UART2 to communiate via the MZIO bus, default is false. + // *valueP = (Boolean) On of Off for UART2ViaModule + + ModuleControlCodeSetCallbackProc + // Sets the callback function and data pointer for interrupt processing + // *valueP = (MzCallbackPtr) callback data information callbackProcPtr, callbackDataPtr +} MzModuleControlCodeEnum; + + +#ifdef __MWERKS__ +#pragma mark GPIO control API structures +#endif +// -------------------------------------------------------------------// +// GPIO control API structures +// -------------------------------------------------------------------// +// Note that these GPIO signals will not toggle if the corresponding signals are used +// in either SPI or UART modes of operation. +#define SPI_MOSI 0x01 +#define SPI_MISO 0x02 +#define SPI_CLK 0x04 +#define SPI_SS 0x08 + +#define SPI_DR 0x10 +#define UART_TX 0x20 +#define UART_RX 0x40 + + +#ifdef __MWERKS__ +#pragma mark Peripheral ID enumeration tags +#endif +// -------------------------------------------------------------------// +// Peripheral ID enumeration tags +// -------------------------------------------------------------------// +typedef enum MzPeripheralIDEnum +{ + PeripheralError = 0, + Peripheral22K, // USB Charging cradle + Peripheral27K, // RS232 Charging cradle + Peripheral33K, + Peripheral39K, + Peripheral47K, // USB Comms cable + Peripheral56K, // RS232 Comms cable + Peripheral68K, + Peripheral82K, + Peripheral100K, + Peripheral120K, + Peripheral150K, + Peripheral180K, + Peripheral220K, + Peripheral270K, + Peripheral330K, + Peripheral390K, + Peripheral470K, + Peripheral560K, + PeripheralNoDevicePresent +} MzPeripheralIDEnum; + +#define PeripheralUSBCable Peripheral47K +#define PeripheralUSBCradle Peripheral22K +#define PeripheralRS232Cable Peripheral56K +#define PeripheralRS232Cradle Peripheral27K +#define PeripheralRS232Keybd Peripheral68K + + +#ifdef __MWERKS__ +#pragma mark - +#endif +/******************************************************************** + * API Prototypes + ********************************************************************/ +#ifdef __cplusplus +extern "C" { +#endif +//-------------------------------------------------- +// Standard library open, close, sleep and wake functions +//-------------------------------------------------- + +extern Err MzLibOpen(UInt16 refNum) + Meazura_LIB_TRAP(sysLibTrapOpen); + +extern Err MzLibClose(UInt16 refNum) + Meazura_LIB_TRAP(sysLibTrapClose); + +extern Err MzLibSleep(UInt16 refNum) + Meazura_LIB_TRAP(sysLibTrapSleep); + +extern Err MzLibWake(UInt16 refNum) + Meazura_LIB_TRAP(sysLibTrapWake); + + +//-------------------------------------------------- +// Custom library API functions +//-------------------------------------------------- +//----------------------------------------------------------------------------- +// Meazura library function trap ID's. Each library call gets a trap number: +// MeazuraLibTrapXXXX which serves as an index into the library's dispatch table. +// The constant sysLibTrapCustom is the first available trap number after +// the system predefined library traps Open,Close,Sleep & Wake. +//----------------------------------------------------------------------------- +#ifdef __MWERKS__ +#pragma mark API Traps +#endif + +#define meazuraLibTrapMzLibGetVersion (sysLibTrapCustom + 0) +#define meazuraLibTrapMzAlmSetAlarm (sysLibTrapCustom + 1) +#define meazuraLibTrapMzAlmStopAlarm (sysLibTrapCustom + 2) +#define meazuraLibTrapMzSPIControl (sysLibTrapCustom + 3) +#define meazuraLibTrapMzSPITransferData (sysLibTrapCustom + 4) +#define meazuraLibTrapMzSPIReadData (sysLibTrapCustom + 5) +#define meazuraLibTrapMzSPIGetFIFOStatus (sysLibTrapCustom + 6) +#define meazuraLibTrapMzUARTControl (sysLibTrapCustom + 7) +#define meazuraLibTrapMzUARTSendData (sysLibTrapCustom + 8) +#define meazuraLibTrapMzUARTReceiveData (sysLibTrapCustom + 9) +#define meazuraLibTrapMzUARTGetFIFOStatus (sysLibTrapCustom + 10) +#define meazuraLibTrapMzParallelControl (sysLibTrapCustom + 11) +#define meazuraLibTrapMzParallelSendData (sysLibTrapCustom + 12) +#define meazuraLibTrapMzParallelReadData (sysLibTrapCustom + 13) +#define meazuraLibTrapMzModuleControl (sysLibTrapCustom + 14) +#define meazuraLibTrapMzGPIOGetValue (sysLibTrapCustom + 15) +#define meazuraLibTrapMzGPIOSetValue (sysLibTrapCustom + 16) +#define meazuraLibTrapMzGetPeripheralID (sysLibTrapCustom + 17) +#define meazuraLibTrapMzPWMControl (sysLibTrapCustom + 18) +#define MeazuraLibTrapLast (sysLibTrapCustom + 19) + +#ifdef __MWERKS__ +#pragma mark - +#endif + +/************************************************************ + * + * FUNCTION: MzLibGetVersions + * + * DESCRIPTION: Get our library API version. The Sample library does not + * need to be "opened" to call MzLibGetLibAPIVersion. + * + * PARAMETERS: refNum Sample library reference number + * version Pointer to a structure for storing the version numbers + * + * CALLED BY: Anyone wishing to get our library API version + * + * RETURNS: errNone no error + * + * REVISION HISTORY: + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzLibGetVersion +#endif +extern Err MzLibGetVersion(UInt16 refNum, MzVersionPtr version) + Meazura_LIB_TRAP(meazuraLibTrapMzLibGetVersion); + +// Alarm APIs +/************************************************************ + * + * ACEECA API + * FUNCTION: MzAlmSetAlarm() + * + * DESCRIPTION: + * This function serves to set up the external alarms. + * It supports repeating alarms for 10 miliseconds,seconds, + * minutes, hours, day, weeks and months. The function sets up + * an initial start time, and periodic alarms occur after that point. + * If the start day is NULL, the alarms will be immediately + * started. Also supports waking up the device after a #max + * number of alarms. If this number is NULL, the system will + * keep on getting alarms. + * + * + * PARAMETERS: + * -> refNum reference number of the library + * -> alarmsP pointer to a MzAlarmType structure + * + * RETURNS: + * errNone No error + * mzSetAlarmError Error in setting the alarm. + * mzCommsError Communications error whilst setting the alarm. + * mzHwFunctionNotSupported This function is not available on the current hardware + * + * CALLED BY: + * Anybody who wants to set up external Alarms + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzAlmSetAlarm +#endif + extern Err MzAlmSetAlarm(UInt16 refNum, MzAlarmPtr alarmsP) + Meazura_LIB_TRAP(meazuraLibTrapMzAlmSetAlarm); + +/************************************************************ + * + * ACEECA API + * FUNCTION: MzAlmStopAlarm() + * + * DESCRIPTION: + * Stop alarms in Meazura keyboard alarm module + * + * + * PARAMETERS: + * -> refNum reference number of the library + * + * RETURNS: + * errNone No error + * mzCommsError Communications error whilst setting the alarm. + * mzHwFunctionNotSupported This function is not available on the current hardware + * + * CALLED BY: + * Anybody who wants to stop external Alarms + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzAlmStopAlarm +#endif +extern Err MzAlmStopAlarm(UInt16 refNum) + Meazura_LIB_TRAP(meazuraLibTrapMzAlmStopAlarm); + + + +// SPI APIs +/************************************************************ + * + * ACEECA API + * FUNCTION: MzSPIControl() + * + * DESCRIPTION: + * This function is a driver to interface to the VZ's SPI 1 port + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * -> controlCode Enumerated control code to control the function (MzSPIControlCodeEnum) + * -> valueP pointer to a data value or structure. + * + * RETURNS: + * errNone No error + * mzControlCodeError Unrecognised control code. + * mzBadBaudRateError Error setting up the baud rate. + * mzConfigError Error setting up the configuration. + * mzNullPointerError Null pointer error. + * mzNullCallbackProcPtrError Null callback function pointer error. + * mzNullCallbackDataPtrError Null callback data pointer error. + * mzHwFunctionNotSupported This function is not available on the current hardware + * mzHwFunctionBusy The SPI function is in use by the system + * + * CALLED BY: + * Anybody who wants to set up the SPI controller + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzSPIControl +#endif +extern Err MzSPIControl(UInt16 refNum, UInt16 controlCode, void* valueP) + Meazura_LIB_TRAP(meazuraLibTrapMzSPIControl); + +/************************************************************ + * + * ACEECA API + * FUNCTION: MzSPITransferData() + * + * DESCRIPTION: + * This function loads words into the SPI fifo. If the fifo + * is full, the function will try until all words have been + * placed in the TxFIFO. If 0 words specified, the function + * will transfer 1 word. This function also checks to see if the + * port is opened. + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * -> dataPtr Pointer to data words to transfer. + * -> numberOfWords Pointer to number of words to transfer. Returns number of words + * left to transfer. Word width is set between 1 and 16 bits + * using the SPIcontrolCodeSetBitsToTransfer in the MzSPIControl API. + * + * RETURNS: + * errNone No error + * mzPortNotOpenError Port is not openned error. + * mzHwFunctionBusy The SPI function is in use by the system + * + * CALLED BY: + * Anybody who wants to send SPI data to the SPI transmit fifo. + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzSPITransferData +#endif +extern Err MzSPITransferData(UInt16 refNum, UInt16* dataPtr, UInt16 *numberOfWords) + Meazura_LIB_TRAP(meazuraLibTrapMzSPITransferData); + +/************************************************************ + * + * ACEECA API + * FUNCTION: MzSPIReadData() + * + * DESCRIPTION: + * This function reads words from the SPI receive fifo. If the fifo + * is empty, the function will return an error immediately. + * If 0 words specified, the function will read 1 word. + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * -> dataPtr Double pointer to the buffer to receive data into. The address it is pointing to + * is updated as words are read from the receive FIFO and added to the buffer. + * -> numberOfWords Number of words to receive. Returns number of words + * left to be received. Word width is set between 1 and 16 bits + * using the SPIcontrolCodeSetBitsToTransfer in the MzSPIControl API. + * + * RETURNS: + * errNone No error + * mzNoFIFODataError RxFIFO has no data + * mzHwFunctionBusy The SPI function is in use by the system + * + * CALLED BY: + * Anybody who wants to read SPI data to the SPI receive fifo. + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzSPIReadData +#endif +extern Err MzSPIReadData(UInt16 refNum, UInt16** dataPtr, UInt16 *numberOfWords) + Meazura_LIB_TRAP(meazuraLibTrapMzSPIReadData); + +/************************************************************ + * + * ACEECA API + * FUNCTION: MzSPIGetFIFOStatus() + * + * DESCRIPTION: + * Gets the status of both the receive and transmit FIFOs of the SPI controller + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * + * RETURNS: + * UInt8 FIFO status + * + * CALLED BY: + * Anybody who wants to obtain the status of the transmit and receive fifos. + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzSPIGetFIFOStatus +#endif +extern UInt8 MzSPIGetFIFOStatus(UInt16 refNum) + Meazura_LIB_TRAP(meazuraLibTrapMzSPIGetFIFOStatus); + + +// UART APIs +/************************************************************ + * + * ACEECA API + * FUNCTION: MzUARTControl() + * + * DESCRIPTION: + * This function is a driver to interface to the VZ's UART 1 port + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * -> controlCode Enumerated control code to control the function (MzUARTControlCodeEnum) + * -> valueP pointer to a data value or structure. + * + * RETURNS: + * errNone No error + * mzControlCodeError Unrecognised control code. + * mzBadBaudRateError Error setting up the baud rate. + * mzConfigError Error setting up the configuration. + * mzNullPointerError Null pointer error. + * mzNullCallbackProcPtrError Null callback function pointer error. + * mzNullCallbackDataPtrError Null callback data pointer error. + * mzHwFunctionNotSupported This function is not available on the current hardware + * mzHwFunctionBusy The UART1 function is in use by the system + * + * CALLED BY: + * Anybody who wants to set up external Alarms + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzUARTControl +#endif +extern Err MzUARTControl(UInt16 refNum, UInt16 controlCode, void* valueP) + Meazura_LIB_TRAP(meazuraLibTrapMzUARTControl); + +/************************************************************ + * + * ACEECA API + * FUNCTION: MzUARTSendData() + * + * DESCRIPTION: + * This function loads bytes into the UART TxFIFO. If the fifo + * is full, the function will try until all bytes have been placed + * in the TxFIFO. If 0 words specified, the function will transfer 1 byte. + * This function will send as many bytes requested without a timeout. + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * -> dataPtr Pointer to data words to transfer. + * -> numberOfBytes Number of words to transfer. Returns the number of bytes + * left to transfer. + * + * RETURNS: + * errNone No error + * mzPortNotOpenError Port is not opened error. + * mzHwFunctionBusy The UART1 function is in use by the system + * + * CALLED BY: + * Anybody who wants to send UART data to the UART transmit fifo. + * + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzUARTSendData +#endif +extern Err MzUARTSendData(UInt16 refNum, UInt8* dataPtr, UInt16* numberOfBytes) + Meazura_LIB_TRAP(meazuraLibTrapMzUARTSendData); + +/************************************************************ + * + * ACEECA API + * FUNCTION: MzUARTReceiveData() + * + * DESCRIPTION: + * This function reads bytes from the UART RxFIFO. If the RxFIFO + * is empty, the function will return immediately with an error. + * If 0 words specified, the function will transfer 1 word. + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * -> dataPtr Double pointer to the buffer to receive data into. The address it is pointing to + * is updated as words are read from the receive FIFO and added to the buffer. + * -> numberOfBytes Number of words to transfer. Returns number of bytes + * left to receive. + * + * RETURNS: + * errNone No error + * mzNoFIFODataError RxFIFO has no data + * mzUARTOverrunError UART has received an overrun error + * mzUARTFrameError UART has received a frame error + * mzUARTParityError UART has received parity error + * mzHwFunctionBusy The UART1 function is in use by the system + * + * CALLED BY: + * Anybody who wants to read UART data from the UART receive fifo. + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzUARTReceiveData +#endif +extern Err MzUARTReceiveData(UInt16 refNum, UInt8** dataPtr, UInt16* numberOfBytes) + Meazura_LIB_TRAP(meazuraLibTrapMzUARTReceiveData); + +/************************************************************ + * + * ACEECA API + * FUNCTION: MzUARTGetFIFOStatus() + * + * DESCRIPTION: + * Gets the status of the UART TxFIFO only. There is a hardware limitation + * to get the UART RxFIFO status information without taking the byte out from + * the RxFIFO. The use RxFIFO status is only available using interrupts. + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * + * RETURNS: + * UInt8 TxFIFO status + * + * CALLED BY: + * Anybody who wants to obtain the status of the transmit and receive fifos. + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzUARTGetFIFOStatus +#endif +extern UInt8 MzUARTGetFIFOStatus(UInt16 refNum) + Meazura_LIB_TRAP(meazuraLibTrapMzUARTGetFIFOStatus); + + +// Parallel Interface APIs +/************************************************************ + * + * ACEECA API + * FUNCTION: MzParallelControl() + * + * DESCRIPTION: + * This function is a driver to interface to the parallel interface on + * a MZIO module. + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * -> controlCode Enumerated control code to control the function (MzParallelControlCodeEnum) + * -> valueP pointer to a data value or structure. + * + * RETURNS: + * errNone No error + * mzControlCodeError Unrecognised control code. + * mzConfigError Error setting up the configuration. + * mzNullPointerError Null pointer error. + * mzHwFunctionNotSupported This function is not available on the current hardware + * mzHwFunctionBusy The parallel function is in use by the system + * + * CALLED BY: + * Anybody who wants to set up parallel control. + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzParallelControl +#endif +extern Err MzParallelControl(UInt16 refNum, UInt16 controlCode, void* valueP) + Meazura_LIB_TRAP(meazuraLibTrapMzParallelControl); + +/************************************************************ + * + * ACEECA API + * FUNCTION: MzParallelSendData() + * + * DESCRIPTION: + * This function writes sizeOfData number of bytes or words + * via parallel adressing on the MZIO bus. One of two chip selects + * can be selected to do the job. If 0 words specified, the function + * will transfer 1 word. + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * -> chipSelect Points to which chip select to send data to, 0 or 1. + * -> offset The offset relative to the base of the chip select to start sending data to. + * -> dataPtr Pointer to data bytes or words to transfer. + * -> sizeOfData Number of data elements to transfer, will limit transfer beyond size of + * chip select. + * + * RETURNS: + * errNone No error + * mzNullPointerError Null pointer error + * mzParallelChipSelectError Unrecognised chip select + * mzParallelOffsetError Offset is out of chip select range + * mzParallelDataSizeError sizeOfData + offset is out of chip select range + * mzHwFunctionBusy The parallel function is in use by the system + * + * CALLED BY: + * Anybody who wants to send data to the module on the parallel interface. + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzParallelSendData +#endif +extern Err MzParallelSendData(UInt16 refNum, UInt8 chipSelect, UInt32 offset, UInt16* dataPtr, UInt32 sizeOfData) + Meazura_LIB_TRAP(meazuraLibTrapMzParallelSendData); + +/************************************************************ + * + * ACEECA API + * FUNCTION: MzParallelReadData() + * + * DESCRIPTION: + * This function reads sizeOfData number of bytes from the MZIO + * parallel interface. Reads can be performed on one or the other of the chip selects + * available.If 0 words specified, the function will transfer 1 word. + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * -> chipSelect Points to which chip select to read data from, 0 or 1. + * -> offset The offset relative to the base of the chip select to start reading data. + * -> dataPtr Pointer to data bytes or words to read. + * -> sizeOfData Number of bytes to transfer, will limit transfer beyond size of + * chip select. + * + * RETURNS: + * errNone No error + * mzNullPointerError Null pointer error + * mzParallelChipSelectError Unrecognised chip select + * mzParallelOffsetError Offset is out of chip select range + * mzParallelDataSizeError sizeOfData + offset is out of chip select range + * mzHwFunctionBusy The parallel function is in use by the system + * + * CALLED BY: + * Anybody who wants to read data from a module via the parallel interface. + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzParallelReadData +#endif +extern Err MzParallelReadData(UInt16 refNum, UInt8 chipSelect, UInt32 offset, UInt16* dataPtr, UInt32 sizeOfData) + Meazura_LIB_TRAP(meazuraLibTrapMzParallelReadData); + +// Module Control APIs +/************************************************************ + * + * ACEECA API + * FUNCTION: MzModuleControl() + * + * DESCRIPTION: + * This function controls various functionalities on a MZIO module. + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * -> controlCode Enumerated control code to control the function (MzParallelControlCodeEnum) + * -> valueP pointer to a data value or structure. + * + * RETURNS: + * errNone No error + * mzControlCodeError Unrecognised control code. + * mzConfigError Error setting up the configuration. + * mzNullPointerError Null pointer error. + * mzNullCallbackProcPtrError Null callback function pointer error. + * mzNullCallbackDataPtrError Null callback data pointer error. + * mzHwFunctionNotSupported This function is not available on the current hardware + * mzHwFunctionBusy The module control function is in use by the system + * + * CALLED BY: + * Anybody who wants to set up external Alarms + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzModuleControl +#endif +extern Err MzModuleControl(UInt16 refNum, UInt16 controlCode, void* valueP) + Meazura_LIB_TRAP(meazuraLibTrapMzModuleControl); + +// GPIO Control APIs +/************************************************************ + * + * ACEECA API + * FUNCTION: MzGPIOGetValue() + * + * DESCRIPTION: + * This function gets the value of a set of GPIO pins that + * are currently not used by either the SPI or UART modules. + * If the SPI_DR* or PWM function is in use then an error code will be returned. + * This function will set the GPIO pins as inputs with internal pullups enabled. + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * -> mask A byte bitfield containing the GPIO pins to get. + * -> value Pointer to the returned byte value of the GPIO pins. + * + * RETURNS: + * errNone No error + * mzNullPointerError Returned if a null pointer is given. + * mzGPIOPinBusyError Pin in use by PWM or SPI_DR* dedicated function + * mzHwFunctionNotSupported This function is not available on the current hardware + * mzHwFunctionBusy The GPIO function is in use by the system + * + * CALLED BY: + * Anybody who wants to read GPIO pins. + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzGPIOGetValue +#endif +extern Err MzGPIOGetValue(UInt16 refNum, UInt8 mask, UInt8 *value) + Meazura_LIB_TRAP(meazuraLibTrapMzGPIOGetValue); + +/************************************************************ + * + * ACEECA API + * FUNCTION: MzGPIOSetValue() + * + * DESCRIPTION: + * This function sets the value of a set of GPIO pins that + * are currently not used by either the SPI or UART modules. + * The pins are automatically configured as output GPIO if available. + * Pins that are configured as dedicated functions (UART or SPI) will not be affected + * If the SPI_DR* or PWM function is in use then an error code will be returned + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * -> mask A byte bitfield containing the GPIO pins to set. + * -> value The value for which to set the GPIO pins to. + * + * RETURNS: + * errNone No error + * mzGPIOPinBusyError Pin in use by PWM or SPI_DR* dedicated function + * mzHwFunctionNotSupported This function is not available on the current hardware + * mzHwFunctionBusy The GPIO function is in use by the system + * + * CALLED BY: + * Anybody who wants to set GPIO pins. + * + * Written by: + * Hemon Dey + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzGPIOSetValue +#endif +extern Err MzGPIOSetValue(UInt16 refNum, UInt8 mask, UInt8 value) + Meazura_LIB_TRAP(meazuraLibTrapMzGPIOSetValue); + +// Get peripheral ID +/************************************************************ + * + * ACEECA API + * FUNCTION: MzGetPeripheralID() + * + * DESCRIPTION: + * This function returns the value of the peripheral ID interms of + * the Peripheral ID enumeration type. + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * + * RETURNS: + * MzPeripheralIDEnum Returned enumeration of the peripheral ID + * + * CALLED BY: + * Anybody who wants to get peripheral ID. + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzGetPeripheralID +#endif +extern UInt8 MzGetPeripheralID(UInt16 refNum) + Meazura_LIB_TRAP(meazuraLibTrapMzGetPeripheralID); + +/************************************************************ + * + * ACEECA API + * FUNCTION: MzPWMControl() + * + * DESCRIPTION: + * This function gives control over the PWM module which is + * currently multiplexed with the DATA Ready pin of the SPI + * controller. When this controller is enabled, the Data ready pin + * is configured as an output pin, and will operate as the PWM + * output. + * + * PARAMETERS: + * + * -> refNum Reference number of the library + * -> controlCode Enumerated control code to control the function + * -> valueP pointer to a data value or structure. + * + * RETURNS: + * errNone No error + * mzControlCodeError Unrecognised control code. + * mzNullPointerError Null pointer error. + * mzHwFunctionNotSupported This function is not available on the current hardware + * mzHwFunctionBusy The PWM function is in use by the system + * + * CALLED BY: + * Anybody who wants enable and control the PWM module. + * + *************************************************************/ +#ifdef __MWERKS__ +#pragma mark MzPWMControl +#endif +extern Err MzPWMControl(UInt16 refNum, UInt16 controlCode, void* valueP) + Meazura_LIB_TRAP(meazuraLibTrapMzPWMControl); + + +// For loading the library in Palm OS Mac emulation mode +extern Err MeazuraLibInstall(UInt16 refNum, SysLibTblEntryPtr entryP); + + +#ifdef __cplusplus +} +#endif + + + + + +#endif // __MEAZURA_LIB_H__ diff --git a/src/ScanMgr.h b/src/ScanMgr.h new file mode 100644 index 0000000..0d1277e --- /dev/null +++ b/src/ScanMgr.h @@ -0,0 +1,231 @@ +/****************************************************************************** + * + * Barcode Scanner Demo Application + * + * Copyright (c) 2006 Janam Partners LLC. All rights reserved. + * + * File: ScanMgr.h + * + * Release: Palm OS 5.x + * + * Description: Reserved for backward compatible + * Utility functions header + * + * History: + * Version 1.0 PT, JL Oct, 2006 + * + *****************************************************************************/ + +//#pragma once +#ifndef __SCANMGR_H__ +#define __SCANMGR_H__ + +#ifdef __cplusplus + extern "C" { +#endif + +#include "ScanMgrStruct.h" +#include "ScanMgrDef.h" +#include "ScanWedge.h" +#include "JanamExtended.h" + + +//-------------------------------------------------------------------------------------------------- +//Check if it is a Janam device +Int16 ScnIsJanamUnit(); + +//-------------------------------------------------------------------------------------------------- + +//Connect or disconnect the barcode scanner library +Int16 ScnOpenDecoder(); +Int16 ScnCloseDecoder(); + +//Send or retrieve parameters +Int16 ScnCmdSendParams( BeepType beep ); +Int16 ScnCmdGetAllParams( UInt8* pbParams, UInt16 max_length ); + +//Inquire current scanner/decoder/port driver versions +Int16 ScnGetScanManagerVersion( Char * pszVer, UInt16 max_length ); +Int16 ScnGetScanPortDriverVersion( Char * pszVer, UInt16 max_length ); +Int16 ScnGetDecoderVersion( Char * pszVer, UInt16 max_length); + +//Get the decode and extended data +Int16 ScnGetDecodedData( MESSAGE *ptr); +Int16 ScnGetExtendedDecodedData( Int16 length, Int16 *type, UInt8 *extendedData); + +//Enable or disable a barcode symbology +Int16 ScnSetBarcodeEnabled( BarType barcodeType, Boolean bEnable ); +Int16 ScnGetBarcodeEnabled( BarType barcodeType ); + +//Set and get the barcode length of a barcode symbology +Int16 ScnSetBarcodeLengths( BarType barcodeType, UInt16 lengthType, UInt16 length1, UInt16 length2 ); +Int16 ScnGetBarcodeLengths( BarType barcodeType, UInt16* pLengthType, UInt16* pLength1, UInt16* pLength2 ); + +//-------------------------------------------------------------------------------------------------- + +//UpcPreamble +Int16 ScnSetUpcPreamble( BarType barcodeType, Int16 preamble); +Int16 ScnGetUpcPreamble( BarType barcodeType); + +//Prefix Suffix +Int16 ScnSetPrefixSuffixValues( Int8 prefix, Int8 suffix_1, Int8 suffix_2 ); +Int16 ScnGetPrefixSuffixValues( Char * pPrefix, Char * pSuffix_1, Char * pSuffix_2 ); + +//Code32 +Int16 ScnSetCode32Prefix( Boolean bEnable ); +Int16 ScnGetCode32Prefix(void); + +//Conversion +Int16 ScnSetConvert( ConvertType conversion, Boolean bEnable); +Int16 ScnGetConvert( ConvertType conversion); + +//Check Digit +Int16 ScnSetTransmitCheckDigit( BarType barType, UInt16 check_digit ); +Int16 ScnGetTransmitCheckDigit( BarType barType ); + +//Code 39 Check Digit Verification +Int16 ScnSetCode39CheckDigitVerification(UInt16 check_digit); +Int16 ScnGetCode39CheckDigitVerification(void); + +//I2of5 Check Digit Verification +Int16 ScnSetI2of5CheckDigitVerification( UInt16 check_digit ); +Int16 ScnGetI2of5CheckDigitVerification(void); + +//Msi Plessy Check Digit +Int16 ScnSetMsiPlesseyCheckDigits( UInt16 check_digits ); +Int16 ScnGetMsiPlesseyCheckDigits(); + +//Msi Plessy Check Algorithm +Int16 ScnSetMsiPlesseyCheckDigitAlgorithm( UInt16 algorithm ); +Int16 ScnGetMsiPlesseyCheckDigitAlgorithm(); + +//Upc Ean Supplementals +Int16 ScnSetDecodeUpcEanSupplementals( UInt16 supplementals ); +Int16 ScnGetDecodeUpcEanSupplementals(); + +//Upc Ean Reducdancy +Int16 ScnSetDecodeUpcEanRedundancy( UInt16 supplemental_redundancy ); +Int16 ScnGetDecodeUpcEanRedundancy(); + +//Code 39 Full ASCII +Int16 ScnSetCode39FullAscii( Boolean bEnable ); +Int16 ScnGetCode39FullAscii(void); + +//CLSI Editing +Int16 ScnSetClsiEditing( Boolean bEnable ); +Int16 ScnGetClsiEditing(); + +//Notis Editing +Int16 ScnSetNotisEditing( Boolean bEnable ); +Int16 ScnGetNotisEditing(); + +//UPC EAN Security Level +Int16 ScnSetUpcEanSecurityLevel( UInt16 security_level ); +Int16 ScnGetUpcEanSecurityLevel(); + +//EAN Zero Extend +Int16 ScnSetEanZeroExtend( Boolean bEnable ); +Int16 ScnGetEanZeroExtend(); + +//Time out +Int16 ScnSetHostSerialResponseTimeOut( UInt16 time_out ); +Int16 ScnGetHostSerialResponseTimeOut(); + +//-------------------------------------------------------------------------------------------------- + +//Reset to factory default +Int16 ScnCmdParamDefaults(); + +//Enable or disable Scanning function +Int16 ScnCmdScanEnable(); +Int16 ScnCmdScanDisable(); + +//Start or stop decode function +Int16 ScnCmdStartDecode(); +Int16 ScnCmdStopDecode(); + +//LED On Off +Int16 ScnCmdLedOn(); +Int16 ScnCmdLedOff(); + +//Aimer On Off +Int16 ScnCmdAimOn(); +Int16 ScnCmdAimOff(); + +//Get current status +Int16 ScnGetAimMode(); +Int16 ScnGetScanEnabled(); +Int16 ScnGetLedState(); + +//-------------------------------------------------------------------------------------------------- + +//Set Laser +Int16 ScnSetLaserOnTime( UInt16 laser_on_time); +Int16 ScnGetLaserOnTime(); + +//Set decode led on time +Int16 ScnSetDecodeLedOnTime( UInt16 led_on_time); +Int16 ScnGetDecodeLedOnTime(); + +//Set Angle +Int16 ScnSetAngle( UInt16 scan_angle ); +Int16 ScnGetAngle(); + +//Set aim duration +Int16 ScnSetAimDuration( UInt16 aim_duration); +Int16 ScnGetAimDuration(); + +//Set triggering modes +Int16 ScnSetTriggeringModes( UInt16 triggering_mode); +Int16 ScnGetTriggeringModes(); + +//Set time out +Int16 ScnSetTimeOutBetweenSameSymbol( UInt16 time_out ); +Int16 ScnGetTimeOutBetweenSameSymbol(); + +//Set Linear Security Level +Int16 ScnSetLinearCodeTypeSecurityLevel( UInt16 security_level ); +Int16 ScnGetLinearCodeTypeSecurityLevel(); + +//Set Bidirectional Redundancy +Int16 ScnSetBidirectionalRedundancy( UInt16 redundancy ); +Int16 ScnGetBidirectionalRedundancy(); + +//Set Transmit Code Id Character +Int16 ScnSetTransmitCodeIdCharacter( UInt16 code_id ); +Int16 ScnGetTransmitCodeIdCharacter(); + +//Set Scan Data Transmission +Int16 ScnSetScanDataTransmissionFormat( UInt16 transmission_format ); +Int16 ScnGetScanDataTransmissionFormat(); + +//-------------------------------------------------------------------------------------------------- + +//Beep Sound +Int16 ScnCmdBeep( BeepType beep ); + +//Set beep sound for decoding +Int16 ScnSetBeepAfterGoodDecode( Boolean bEnableBeep ); +Int16 ScnGetBeepAfterGoodDecode(); + +//Set beep sound frequency +Int16 ScnSetBeepFrequency( FrequencyType type, Int16 beep_freq ); +Int16 ScnGetBeepFrequency( FrequencyType type ); + +//Set beep duration +Int16 ScnSetBeepDuration( DurationType type, Int16 beep_duration ); +Int16 ScnGetBeepDuration( DurationType type ); + +//-------------------------------------------------------------------------------------------------- + +//Set sled function +Int16 ScnCmdTrigSledOn(); +Int16 ScnCmdTrigSledOff(); +Int16 ScnGetTrigSledMode(); + + +#ifdef __cplusplus + } +#endif + +#endif \ No newline at end of file diff --git a/src/ScanMgrDef.h b/src/ScanMgrDef.h new file mode 100644 index 0000000..2cd913f --- /dev/null +++ b/src/ScanMgrDef.h @@ -0,0 +1,237 @@ +/****************************************************************************** + * + * Barcode Scanner Common Defines. + * + * Copyright (c) 2006 Janam Partners LLC. All rights reserved. + * + * File: ScanMgrDef.h + * + * Release: Palm OS 5.x + * + * Description: Reserved for backward compatible + * Common defines for the scanner library + * Extended defines are in JanamExtendedDef.h + * History: + * Version 1.0 PT, JL Oct, 2006 + * + *****************************************************************************/ + +#ifndef __SCANMGRDEF_H__ +#define __SCANMGRDEF_H__ + +//#pragma once + +#include "JanamExtendedDef.h" + +/******************************************************************* + * Symbol unit hardware token (checked in ScanIsPalmSymbolUnit) + *******************************************************************/ + #ifdef __cplusplus + extern "C" { +#endif + +#define SymbolROMToken 'scnr' + +//----------------------------------------------------------------------------- +//Defines for Backward Compatible + +//Beep Frequecy and Duration +#define MIN_BEEP_DURATION 0 +#define MAX_BEEP_DURATION 10000 +#define MIN_BEEP_FREQUENCY 0 +#define MAX_BEEP_FREQUENCY 15000 +#define MIN_UPCEAN_REDUNDANCY 2 +#define MAX_UPCEAN_REDUNDANCY 20 +#define MIN_LASER_ON_TIME 5 +#define MAX_LASER_ON_TIME 99 +#define MAX_AIM_DURATION 99 +#define MAX_TIMEOUT_BETWEEN_SYMBOL 10 +#define MAX_DECODE_LED_ON_TIME 100 + +//----------------------------------------------------------------------------- +//Beep and Scanner Range Values +#define SHORT_BEEP_DUR 0x20 +#define MEDIUM_BEEP_DUR 0x21 +#define LONG_BEEP_DUR 0x22 +#define HIGH_FREQ 0x23 +#define MEDIUM_FREQ 0x24 +#define LOW_FREQ 0x25 +#define DECODE_BEEP_DUR 0x27 +#define DECODE_BEEP_FREQ 0x28 + +//----------------------------------------------------------------------------- +//Error Code Returns +#define STATUS_OK 0 +#define NOT_SUPPORTED -2 +#define COMMUNICATIONS_ERROR -3 +#define BAD_PARAM -4 +#define BATCH_ERROR -5 +#define ERROR_UNDEFINED -6 + +//----------------------------------------------------------------------------- +//Triggering Modes +#define LEVEL 0x00 +#define PULSE 0x02 +#define HOST 0x08 + +//----------------------------------------------------------------------------- +//Enable or Disable +#define DISABLE 0x00 +#define ENABLE 0x01 + +//----------------------------------------------------------------------------- +//Security Levels +#define SECURITY_LEVEL0 0x00 +#define SECURITY_LEVEL1 0x01 +#define SECURITY_LEVEL2 0x02 +#define SECURITY_LEVEL3 0x03 +#define SECURITY_LEVEL4 0x04 + +//----------------------------------------------------------------------------- +//Supplementals +#define IGNORE_SUPPLEMENTALS 0x00 +#define DECODE_SUPPLEMENTALS 0x01 +#define AUTODISCRIMINATE_SUPPLEMENTALS 0x02 + +//----------------------------------------------------------------------------- +//Transmit Check Digit +#define DO_NOT_TRANSMIT_CHECK_DIGIT 0x00 +#define TRANSMIT_CHECK_DIGIT 0x01 + +//----------------------------------------------------------------------------- +//Preamble +#define NO_PREAMBLE 0x00 +#define SYSTEM_CHARACTER 0x01 +#define SYSTEM_CHARACTER_COUNTRY_CODE 0x02 + +//----------------------------------------------------------------------------- +//Discrete Length +#define ANY_LENGTH 0x00 +#define ONE_DISCRETE_LENGTH 0x01 +#define TWO_DISCRETE_LENGTHS 0x02 +#define LENGTH_WITHIN_RANGE 0x03 + +//----------------------------------------------------------------------------- +//Check Digit Verification +#define DISABLE_CHECK_DIGIT 0x00 +#define USS_CHECK_DIGIT 0x01 +#define OPCC_CHECK_DIGIT 0x02 + +//----------------------------------------------------------------------------- +// MSI Plessy Check Digits +#define ONE_CHECK_DIGIT 0x00 +#define TWO_CHECK_DIGITS 0x01 + +//----------------------------------------------------------------------------- +// MSI Plessey check digit algorithms +#define MOD10_MOD11 0x00 +#define MOD10_MOD10 0x01 + +//----------------------------------------------------------------------------- +// Aimer Code ID +#define AIM_CODE_ID_CHARACTER 0x01 +#define SYMBOL_CODE_ID_CHARACTER 0x02 + +//----------------------------------------------------------------------------- +// Prefix and Suffix Values +#define PREFIX_SUFFIX_VALUES_P 0x69 +#define PREFIX_SUFFIX_VALUES_S1 0x68 +#define PREFIX_SUFFIX_VALUES_S2 0x6A + +//----------------------------------------------------------------------------- +// Scan Data Formats +#define DATA_AS_IS 0x00 +#define DATA_SUFFIX1 0x01 +#define DATA_SUFFIX2 0x02 +#define DATA_SUFFIX1_SUFFIX2 0x03 +#define PREFIX_DATA 0x04 +#define PREFIX_DATA_SUFFIX1 0x05 +#define PREFIX_DATA_SUFFIX2 0x06 +#define PREFIX_DATA_SUFFIX1_SUFFIX2 0x07 + +//----------------------------------------------------------------------------- +// Scan Angles +#define SCAN_ANGLE_WIDE 0xB6 +#define SCAN_ANGLE_NARROW 0xB5 + + +//----------------------------------------------------------------------------- +// Barcode data types returned +#define BCTYPE_NOT_APPLICABLE 0x00 +#define BCTYPE_CODE39 0x01 +#define BCTYPE_CODABAR 0x02 +#define BCTYPE_CODE128 0x03 +#define BCTYPE_D2OF5 0x04 +#define BCTYPE_IATA2OF5 0x05 +#define BCTYPE_I2OF5 0x06 +#define BCTYPE_CODE93 0x07 +#define BCTYPE_UPCA 0x08 +#define BCTYPE_UPCA_2SUPPLEMENTALS 0x48 +#define BCTYPE_UPCA_5SUPPLEMENTALS 0x88 +#define BCTYPE_UPCE0 0x09 +#define BCTYPE_UPCE0_2SUPPLEMENTALS 0x49 +#define BCTYPE_UPCE0_5SUPPLEMENTALS 0x89 +#define BCTYPE_EAN8 0x0A +#define BCTYPE_EAN8_2SUPPLEMENTALS 0x4A +#define BCTYPE_EAN13_5SUPPLEMENTALS 0x8B +#define BCTYPE_EAN8_5SUPPLEMENTALS 0x8A +#define BCTYPE_EAN13 0x0B +#define BCTYPE_EAN13_2SUPPLEMENTALS 0x4B +#define BCTYPE_MSI_PLESSEY 0x0E +#define BCTYPE_EAN128 0x0F +#define BCTYPE_UPCE1 0x10 +#define BCTYPE_UPCE1_2SUPPLEMENTALS 0x50 +#define BCTYPE_UPCE1_5SUPPLEMENTALS 0x90 +#define BCTYPE_CODE39_FULL_ASCII 0x13 +#define BCTYPE_TRIOPTIC_CODE39 0x15 +#define BCTYPE_BOOKLAND_EAN 0x16 +#define BCTYPE_COUPON_CODE 0x17 +#define BCTYPE_ISBT128 0x19 + + +//----------------------------------------------------------------------------- +#define EXTENDED_DATA_FLAG 0x01 + + +typedef enum tagSymbolEvent +{ + scanDecodeEvent = 0x7fffU + 0x800, // A decode event has finished + scanBatteryErrorEvent, // Low Battery + scanTriggerEvent, // A scan attempt was initiated + s24BatteryErrorEvent, + symbolRFUA, + symbolRFUB, + symbolRFUC, + symbolRFUD, + symbolRFUE, + symbolRFUF, + symbolRFUG, + symbolRFUH, + + WanLowBatteryEvent, + WanBatteryErrorEvent, + + lastSymbolEvent + +} SymbolEvents; + + +enum scanMgrErr +{ + scanMgrErrParam = appErrorClass+1, + scanMgrErrNotOpen, + scanMgrErrStillOpen, + scanMgrErrMemory, + scanMgrErrLowBatt +}; + + + +#ifdef __cplusplus + } +#endif +/******************************************************************* + * end of file * + *******************************************************************/ + +#endif // __SCANMGRDEF_H__ diff --git a/src/ScanMgrStruct.h b/src/ScanMgrStruct.h new file mode 100644 index 0000000..43a84e4 --- /dev/null +++ b/src/ScanMgrStruct.h @@ -0,0 +1,299 @@ +/****************************************************************************** + * + * Barcode Scanner Common Defines. + * + * Copyright (c) 2006 Janam Partners LLC. All rights reserved. + * + * File: ScanMgrStruct.h + * + * Release: Palm OS 5.x + * + * Description: Reserved for backward compatible + * Common structure for using the Scanner Library + * + * History: + * Version 1.0 PT, JL Oct, 2006 + * + *****************************************************************************/ + +#ifndef __SCANMGRSTRUCT_H__ +#define __SCANMGRSTRUCT_H__ + +//#pragma once on + +#ifdef __cplusplus + extern "C" { +#endif + +#include "ScanMgrDef.h" + +//extended defines and structure +#include "JanamExtendedDef.h" +#include "JanamExtendedStruct.h" + +//ScanEvent Structure +typedef struct +{ + eventsEnum eType; + Boolean penDown; + Int16 screenX; + Int16 screenY; + union scanData + { + struct scanGen + { + UInt16 data1; + UInt16 data2; + UInt16 data3; + UInt16 data4; + UInt16 data5; + UInt16 data6; + UInt16 data7; + UInt16 data8; + } scanGen; + + struct + { + UInt16 batteryLevel; + UInt16 batteryErrorType; + } batteryError; + + } scanData; // End of union + +} ScanEventType; +typedef ScanEventType *ScanEventPtr; + +//----------------------------------------------------------------------------- +//Maximum Packet Length +#define MAX_PACKET_LENGTH 258 + +//Barcode Message Structure +typedef struct tagMESSAGE +{ + Int16 length; //data length + Int16 type; //barcode type + Int16 status; //decode status + UInt8 data[MAX_PACKET_LENGTH]; //barcode data +} MESSAGE; + +//----------------------------------------------------------------------------- +#define MAX_DCD_LENGTH 258 + +//DCD Message Structure +typedef struct tagMESSAGE_Dcd +{ + Int16 length; // length of the data + Int16 type; // contains the barcode type when the msg is DecodeData + Int16 status; // should be STATUS_OK + UInt8 symLetter; + UInt8 symModifier; + UInt8 data[MAX_DCD_LENGTH]; // the message data +} MESSAGE_Dcd; + +//----------------------------------------------------------------------------- +//Batch Structure +#define MAX_BATCH_PARAM 247 +typedef struct tagBATCH +{ + Int16 length; + Int16 data[MAX_BATCH_PARAM + 3]; +} BATCH; + +//----------------------------------------------------------------------------- +//Comm Structure. No longer in use +typedef struct tagCOMM_STRUCT +{ + Int16 port; + Int16 baud; + Int16 parity; + Int16 stop_bits; + Int16 host_timeout; +} COMM_STRUCT; + +//----------------------------------------------------------------------------- +//Beep Sound enum +typedef enum tagBeepType +{ + No_Beep = 0x00, + One_Short_High, + Two_Short_High, + Three_Short_High, + Four_Short_High, + Five_Short_High, + + One_Short_Low, + Two_Short_Low, + Three_Short_Low, + Four_Short_Low, + Five_Short_Low, + + One_Long_High, + Two_Long_High, + Three_Long_High, + Four_Long_High, + Five_Long_High, + + One_Long_Low, + Two_Long_Low, + Three_Long_Low, + Four_Long_Low, + Five_Long_Low, + + Fast_Warble, + Slow_Warble, + Mix1, + Mix2, + Mix3, + Mix4, + + Decode_Beep, + Bootup_Beep, + Parameter_Entry_Error_Beep, + Parameter_Defaults_Beep, + Parameter_Entered_Beep, + Host_Convert_Error_Beep, + Transmit_Error_Beep, + Parity_Error_Beep, + + Last_Beep +} BeepType; + +//----------------------------------------------------------------------------- +//Conversion enum +typedef enum tagConvertType +{ + convertUpcEtoUpcA, + convertUpcE1toUpcA, + convertCode39toCode32, + convertEan8toEan13, + convertI2of5toEan13 +} ConvertType; + +//----------------------------------------------------------------------------- +//Beep Duration enum +typedef enum +{ + decodeDuration = DECODE_BEEP_DUR, + shortDuration = SHORT_BEEP_DUR, + mediumDuration = MEDIUM_BEEP_DUR, + longDuration = LONG_BEEP_DUR +} DurationType; + +//Beep Frequency enum +typedef enum +{ + decodeFrequency = DECODE_BEEP_FREQ, + lowFrequency = LOW_FREQ, + mediumFrequency = MEDIUM_FREQ, + highFrequency = HIGH_FREQ +} FrequencyType; + +//----------------------------------------------------------------------------- +//Button Type enum +typedef enum +{ + buttonDateBook = 0, + buttonAddressBook, + buttonTodoList, + buttonMemoPad +} ButtonType; + +//----------------------------------------------------------------------------- +//Launch Code enum +typedef enum { + myAppCmdBatteryAlert = sysAppLaunchCmdCustomBase, + myAppCmdS24BatteryAlert, + myAppCmdNotUsed +} MyAppCustomActionCodes; + +//----------------------------------------------------------------------------- +//Decode Parameters +#define PACKET_CONTINUATION 0x0002 +#define MAX_DECODER_PARMS 3750 + + +//----------------------------------------------------------------------------- +//Bar Code Enum Types with Extended Codes provided by Janam +typedef enum tagBarType +{ + barCODE39 = 0x00, + barUPCA = 0x01, + barUPCE = 0x02, + barEAN13 = 0x03, + barEAN8 = 0x04, + barD25 = 0x05, + barI2OF5 = 0x06, + barCODABAR = 0x07, + barCODE128 = 0x08, + barCODE93 = 0x09, + barTRIOPTIC39 = 0x0D, + barUCC_EAN128 = 0x0E, + barMSI_PLESSEY = 0x0B, + barUPCE1 = 0x0C, + barBOOKLAND_EAN = 0x53, + barISBT128 = 0x54, + barCOUPON = 0x55, + barCode32 = 0x56, +//EXTENDED Support + barAZTEC = 0xC0, + barCODE11 = 0xC1, + barCODE49 = 0xC2, + barCOMPOSITE = 0xC3, + barDATAMAXTRIX = 0xC4, + barMAXICODE = 0xC5, + barMICROPDF = 0xC6, + barOCR = 0xC7, + barPDF417 = 0xC8, + barPOSTNET = 0xC9, + barQR = 0xCA, + barRSS = 0xCB, + barBPO = 0xCC, + barCANPOST = 0xCD, + barAUSPOST = 0xCE, + barIATA25 = 0xCF, + barCODABLOCK = 0xD0, + barJAPOST = 0xD1, + barPLANET = 0xD2, + barDUTCHPOST = 0xD3, + barTLCODE39 = 0xD4, + barMATRIX25 = 0xD5, + barCHINAPOST = 0xD6, + barKOREAPOST = 0xD7, + barTELEPEN = 0xD8, + barCODE16K = 0xD9, + barPOSICODE = 0xDA, + barUSPS4CB = 0xDB, + barIDTAG = 0xDC, + barRSS_LIM = 0xDD, + barRSS_EXP = 0xDE, + barMSI = 0xA0, + barPlessey = 0xA1, + barALL = 0xFF +} BarType; + +//----------------------------------------------------------------------------- +//Decode Option Structure +#define DEC_DECODE_OPTIONS_VER 0x03 +typedef struct +{ + Int32 Version; + Int32 PrintWeight; // Valid range is 1-7 + Int32 DecodeMode; // Full Omni, Reduced Omni, ALD + Int32 LinearRange; // Valid range 1-6 + Int32 VideoReverse; // 0=disabled, 1=enabled + Int32 DecAttemptLimit; // 0 = disabled, Valid range 1-10,000 + Int32 SearchLimit; // 0 = disabled, Valid range 1-10,000 + unsigned short AddendaDelay; // (search time for addenda in ms) + unsigned short UpcComDelay; // (search time for 2D symbol in UPC COM mode) + unsigned short ConcatDelay; // (search time for ISBT/Codabar concatenation) + unsigned short MldEnaMask; // Per symbology MLD control + Int32 Flags; // special flags +} DecodeOptions_t; + + +#ifdef __cplusplus + } +#endif + + +#endif \ No newline at end of file diff --git a/src/ScanWedge.h b/src/ScanWedge.h new file mode 100644 index 0000000..6355e3d --- /dev/null +++ b/src/ScanWedge.h @@ -0,0 +1,72 @@ +/****************************************************************************** + * + * Barcode Scanner Demo Application + * + * Copyright (c) 2006 Janam Partners LLC. All rights reserved. + * + * File: SetupDlgs.h + * + * Release: Palm OS 5.x + * + * Description: Header define for the Barcode Scanner Demo Application + * + * History: + * Version 1.0 PT, JL Oct, 2006 + * + *****************************************************************************/ + +#ifndef __SCANWEDGE_H__ +#define __SCANWEDGE_H__ + +#ifdef __cplusplus + extern "C" { +#endif + +#define kScanWedgePanelCreator 'ScnW' +#define kScanWedgePreferencesId 1 +#define kScanWedgeOpenId 2 +#define ScanWedgeEnabled 0x1 + + + +#define BARCODE 0 +#define CARRIGE_RETURN 1 +#define LINE_FEED 2 +#define TAB 3 +#define PREFIX 4 +#define SUFFIX 5 +#define TEMINATE 9 + + + +#define MAX_INSERT_CHAR 6 +#define MAX_PREFIX_CHAR 18 +#define MAX_SUFFIX_CHAR 18 + + +typedef struct + { + UInt32 ScanWedge; + UInt8 ScanWedgeInsertCharOption[MAX_INSERT_CHAR]; //current max is combination of 4 types + char ScanWedgePrefix[MAX_PREFIX_CHAR+1]; + char ScanWedgeSuffix[MAX_SUFFIX_CHAR+1]; + } ScanWedgePreferencesType; + +#define BC_STRING "" +#define CR_STRING "" +#define LF_STRING "" +#define TAB_STRING "" +#define PREFIX_STRING "" +#define SUFFIX_STRING "" + + +#define OPTION_PREFIX 1 +#define OPTION_SUFFIX 2 + + + +#ifdef __cplusplus + } +#endif + +#endif \ No newline at end of file