| | 3 | This is an example of a very simple weight indicator that displays the gross weight and provides a "Zero" and "Quit" button. |
| | 4 | |
| | 5 | simple_ind.h |
| | 6 | {{{ |
| | 7 | #pragma once |
| | 8 | |
| | 9 | EVENT(MainScreenShow); |
| | 10 | EVENT(MainScreenProcess); |
| | 11 | EVENT(Zero); |
| | 12 | EVENT(Quit); |
| | 13 | }}} |
| | 14 | |
| | 15 | simple_ind.cpp |
| | 16 | {{{ |
| | 17 | #include "cardinal825.h" |
| | 18 | |
| | 19 | #include "simple_ind.h" |
| | 20 | |
| | 21 | int main(int ac,char **av) |
| | 22 | { |
| | 23 | InitLCD(); |
| | 24 | |
| | 25 | ReadTouchCal(); |
| | 26 | OpenBeeper(); |
| | 27 | OpenTouch(); |
| | 28 | |
| | 29 | MnBdStartup(); |
| | 30 | |
| | 31 | FORM_INIT(Main, EventMainScreenShow, EventMainScreenProcess, NULL, NULL, nFormFlgNone); |
| | 32 | FORM_ADD_BUTTON(Main, Zero, 0, 120, "Zero", 'Z', EventZero, FORM_BUTTON_OUTLINE); |
| | 33 | FORM_ADD_BUTTON(Main, Quit, 0, 200, "Quit", 'Q', EventQuit, FORM_BUTTON_OUTLINE); |
| | 34 | |
| | 35 | FORM_SHOW(Main); |
| | 36 | FORM_RUN(Main); |
| | 37 | FORM_HIDE(Main); |
| | 38 | |
| | 39 | MnBdShutdown(); |
| | 40 | |
| | 41 | return 0; |
| | 42 | } |
| | 43 | |
| | 44 | EVENT(MainScreenShow) |
| | 45 | { |
| | 46 | ClearLCD(); |
| | 47 | DisplayText(0, 0, "Simple Weight Indicator"); |
| | 48 | return 0; |
| | 49 | } |
| | 50 | |
| | 51 | EVENT(MainScreenProcess) |
| | 52 | { |
| | 53 | int n = MnBdProcess(); |
| | 54 | if(n == mnbdProcWtRcv) |
| | 55 | { |
| | 56 | if(IsGrossWtChanged(1)) |
| | 57 | { |
| | 58 | DisplayText(0, 40, GetChangedGrossWt(1), 0, BIG_FONT); |
| | 59 | } |
| | 60 | } |
| | 61 | |
| | 62 | return 0; |
| | 63 | } |
| | 64 | |
| | 65 | EVENT(Zero) |
| | 66 | { |
| | 67 | ZeroScale(1); |
| | 68 | return 0; |
| | 69 | } |
| | 70 | |
| | 71 | EVENT(Quit) |
| | 72 | { |
| | 73 | // Return non-zero to exit the form |
| | 74 | return 1; |
| | 75 | } |
| | 76 | }}} |
| | 77 | |