wiki:Docs/Prog/Manual/ApplicationLibraries/lib825ev/Weight

Version 8 (modified by Don Wilson, 14 years ago) ( diff )

--

Weighing Functions

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.

simple_ind.h

#pragma once

EVENT(MainScreenShow);
EVENT(MainScreenProcess);
EVENT(Zero);
EVENT(Quit);

simple_ind.cpp

#include "cardinal825.h"

#include "simple_ind.h"

int main(int ac,char **av)
{
	InitLCD();

	ReadTouchCal();
	OpenBeeper();
	OpenTouch();

	MnBdStartup();

	FORM_INIT(Main, EventMainScreenShow, EventMainScreenProcess, NULL, NULL, nFormFlgNone);
	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);

	MnBdShutdown();

	return 0;
}

EVENT(MainScreenShow)
{
	ClearLCD();
	DisplayText(0, 0, "Simple Weight Indicator");
	return 0;
}

EVENT(MainScreenProcess)
{
	int n = MnBdProcess();
	if(n == mnbdProcWtRcv)
	{
		if(IsGrossWtChanged(1))
		{
			DisplayText(0, 40, GetChangedGrossWt(1), 0, BIG_FONT);
		}
	}

	return 0;
}

EVENT(Zero)
{
	ZeroScale(1);
	return 0;
}

EVENT(Quit)
{
	// Return non-zero to exit the form
	return 1;
}

Attachments (1)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.