| 52 | Here is an example of a complete sample application: |
| 53 | |
| 54 | repeatmulti.h: |
| 55 | {{{ |
| 56 | #ifndef REPEATMULTI_H_ |
| 57 | #define REPEATMULTI_H_ |
| 58 | |
| 59 | EVENT(MainScreenShow); |
| 60 | |
| 61 | BACKGROUND_EVENT(Comm); |
| 62 | |
| 63 | MNBD_EVENT(MultiRcv); |
| 64 | EVENT(Exit); |
| 65 | |
| 66 | |
| 67 | #endif /* REPEATMULTI_H_ */ |
| 68 | |
| 69 | }}} |
| 70 | |
| 71 | repeatmulti.cpp: |
| 72 | |
| 73 | {{{ |
| 74 | #include <stdio.h> |
| 75 | #include <stdlib.h> |
| 76 | |
| 77 | #include "cardinal825.h" |
| 78 | |
| 79 | #include "repeatmulti.h" |
| 80 | |
| 81 | int main() |
| 82 | { |
| 83 | InitLCD(); |
| 84 | |
| 85 | SetCurColor(COLOR_ATTENTION); |
| 86 | DisplayText(0, 0, "Repeat Multi Example"); |
| 87 | |
| 88 | ReadTouchCal(); |
| 89 | OpenBeeper(); |
| 90 | OpenTouch(); |
| 91 | |
| 92 | MnBdStartup(); |
| 93 | |
| 94 | MnBdSetEvent(MNBD_REQ_REP_MULTI, MnBdEventMultiRcv); |
| 95 | |
| 96 | SetBackgroundEvent(BackgroundEventComm); |
| 97 | |
| 98 | if(StartRepeatMulti(100) != OK) |
| 99 | { |
| 100 | DisplayText(0, FONT_HEIGHT, "Error starting repeat multi"); |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | FORM_INIT(Main, EventMainScreenShow, NULL, NULL, NULL, nFormFlgNone); |
| 105 | |
| 106 | FORM_ADD_BUTTON(Main, Zero, 0, FONT_HEIGHT * 12, " Exit ", 'X', EventExit, FORM_BUTTON_INVERT); |
| 107 | |
| 108 | FORM_SHOW(Main); |
| 109 | FORM_RUN(Main); |
| 110 | FORM_HIDE(Main); |
| 111 | |
| 112 | StopRepeatMulti(); |
| 113 | SetBackgroundEvent(NULL); |
| 114 | |
| 115 | MnBdShutdown(); |
| 116 | |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | EVENT(MainScreenShow) |
| 121 | { |
| 122 | SetCurColor(COLOR_ATTENTION); |
| 123 | DisplayText(0, 0, "Repeat Multi Example"); |
| 124 | |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | EVENT(Exit) |
| 129 | { |
| 130 | return 1; // return non-zero to exit form |
| 131 | } |
| 132 | |
| 133 | MNBD_EVENT(MultiRcv) |
| 134 | { |
| 135 | int n; |
| 136 | for(n = 1; n <= GetNumScales(); n++) |
| 137 | { |
| 138 | if(IsGrossWtChanged(n)) |
| 139 | { |
| 140 | DisplayText(0, (FONT_HEIGHT * n) + FONT_HEIGHT, GetChangedGrossWt(n)); |
| 141 | } |
| 142 | } |
| 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | BACKGROUND_EVENT(Comm) |
| 147 | { |
| 148 | // Use MnBdRead directly to prevent overhead of MnBdProcess |
| 149 | // MnBdRead will call event MultiRcv that we registered previously when scale and DIO status is received |
| 150 | |
| 151 | int n; |
| 152 | // in case we have more I/O cards than scales change this |
| 153 | for(n = 0; n <= GetNumScales(); n++) |
| 154 | { |
| 155 | // 0 = MNBD_DEV, 1 .. Scales and I/O cards |
| 156 | MnBdRead(n); |
| 157 | } |
| 158 | |
| 159 | return 0; |
| 160 | } |
| 161 | |
| 162 | }}} |
| 163 | |