Weighing Functions
- CheckWIM * DEPRECATED - New apps should use MnBdSetWIM *
- DLCRepeatMultiIncludeCellWts
- FormatGrossWt
- FormatNetWt
- FormatTareWt
- FormatWt
- GetBelowZero
- GetCapacity
- GetCenterZero
- GetCurUnitsLabel
- GetDecimal
- GetGrossWt
- GetInterval
- GetMotion
- GetNetWt
- GetNumScales
- GetOverCap
- GetProcessScale
- GetSecUnitsLabel
- GetTareWt
- GetUnitsLabel
- GetWtError
- IsGrossWtChanged
- IsNetWtChanged
- IsTareWtChanged
- IsWtStatusChanged
- IsWtUnitsChanged
- MnBdClearEvent
- MnBdClose
- MnBdGetErr
- MnBdGetErrMsg
- MnBdGetErrMsgStr
- MnBdOpen
- MnBdProcess * DEPRECATED - New apps should use StartRepeatMulti *
- MnBdRead
- MnBdRequest
- MnBdSetEvent
- MnBdSetWIM
- MnBdShutdown
- MnBdStartup
- RequestWt * DEPRECATED - New apps should use StartRepeatMulti *
- ResetPrevGrossWt
- ResetPrevNetWt
- ResetPrevTareWt
- ResetPrevWtStatus
- ResetPrevWtUnits
- SetTareCurrent
- SetTareValue
- SetWIM * DEPRECATED - New apps should use MnBdSetWIM *
- StartRepeatMulti
- StartRepeatWt * DEPRECATED - New apps should use StartRepeatMulti *
- StopRepeatMulti
- StopRepeatWt * DEPRECATED - New apps should use StopRepeatMulti *
- ZeroScale
Minimal Weight Indicator Sample Program
This is an example of a very simple weight indicator program to display the gross weight. "Zero" and "Quit" buttons are provided. This is a minimal program for demonstration purposes. An application to be used in a production environment should have additional code to display scale status such as "Motion" and blank weight display on over capacity or weight error.
simple_ind.h:
#ifndef SIMPLE_IND_H_ #define SIMPLE_IND_H_ EVENT(MainScreenShow); EVENT(Zero); EVENT(Quit); BACKGROUND_EVENT(Comm); MNBD_EVENT(MultiRcv); EVENT(Exit); #endif /* SIMPLE_IND_H_ */
simple_ind.cpp:
#include "cardinal825.h" #include "simple_ind.h" int main() { InitLCD(); SetCurColor(COLOR_ATTENTION); DisplayText(0, 0, "Simple Indicator Example"); ReadTouchCal(); OpenBeeper(); OpenTouch(); MnBdStartup(); MnBdSetEvent(MNBD_REQ_REP_MULTI, MnBdEventMultiRcv); SetBackgroundEvent(BackgroundEventComm); if(StartRepeatMulti(100) != OK) { DisplayText(0, FONT_HEIGHT, "Error starting repeat multi"); return 0; } FORM_INIT(Main, EventMainScreenShow, NULL, NULL, NULL, nFormFlgNone); FORM_ADD_BUTTON(Main, Exit, 0, FONT_HEIGHT * 12, " Exit ", 'X', EventExit, FORM_BUTTON_INVERT); FORM_ADD_BUTTON(Main, Zero, 0, 120, "Zero", 'Z', EventZero, FORM_BUTTON_OUTLINE); FORM_ADD_BUTTON(Main, Quit, 0, 200, "Quit", 'Q', EventQuit, FORM_BUTTON_OUTLINE); FORM_SHOW(Main); FORM_RUN(Main); FORM_HIDE(Main); MnBdClearCommEvent(); StopRepeatMulti(); SetBackgroundEvent(NULL); MnBdShutdown(); return 0; } EVENT(MainScreenShow) { ClearLCD(); SetCurColor(COLOR_ATTENTION); DisplayText(0, 0, "Simple Weight Indicator"); ResetPrevGrossWt(); return 0; } EVENT(Exit) { return 1; // return non-zero to exit form } MNBD_EVENT(MultiRcv) { int n; int y = FONT_HEIGHT; for(n = 1; n <= GetNumScales(); n++) { if(IsGrossWtChanged(n)) { DisplayText((FONT_WIDTH * 10), y, GetChangedGrossWt(n), 0, BIG_FONT); } y += (FONT_HEIGHT * 2); } return 0; } BACKGROUND_EVENT(Comm) { // This gets called every few milliseconds or so when main code is in a CForm run or a SleepSeconds statement. // MnBdRead must be called to process any messages received from the mainboard. // MnBdRead will call event MultiRcv that we registered previously when scale and DIO status is // received. int n; // in case we have more I/O cards than scales change this for(n = 0; n <= GetNumScales(); n++) { // 0 = MNBD_DEV, 1 .. Scales and I/O cards MnBdRead(n); } return 0; } EVENT(Zero) { ZeroScale(1); return 0; } EVENT(Quit) { // Return non-zero to exit the form return 1; }
Last modified
5 years ago
Last modified on 02/26/20 07:42:59
Attachments (1)
-
simple_ind.png
(12.6 KB
) - added by 14 years ago.
Screen image of simple_ind program
Download all attachments as: .zip
Note:
See TracWiki
for help on using the wiki.