Temporary Connector Reversed Version
Dependencies: UniGraphic mbed vt100
afero_poc15_180403R , J1 のピン配置を反転させたヴァージョンです。
Color2系を使用するためには以下のピンをジャンパで接続してください。
J1-D7 <-> J1-D0
J1-D6 <-> J1-D1
(調査中) また、こちらでテストした範囲では、
FRDM-KL25Z の V3.3 を、Modulo2 の VCC_3V3 ピンに接続してやる必要がありました。
尚、J1-D1, D0 を使用するために UART を無効にしているため
ログは表示されません。
TFTモジュールについて
aitendoのTFTモジュールはデフォルトでは8bit bus モードになっています。
半田のジャンパを変えて、SPIの設定にしてください。
サーミスタについて
POC1.5 では サーミスタは 25℃の時に抵抗値が 50.0kΩになる502AT-11 が
4.95kΩのプルアップ(実際は10kΩx2の並列)で使用されていました。
今回の試作では抵抗値が 10.0kΩの 103AT-11 が
5.1kΩのプルアップで使用されていますので、係数を合わせるために
SMTC502AT-11 のコンストラクタを
R0 = 10.0
R1 = 5.1
B = 3435
T0 = 298.15
で呼ぶように変更しました。
edge_sensor/edge_pressure.cpp@0:0b6732b53bf4, 2018-04-24 (annotated)
- Committer:
- Rhyme
- Date:
- Tue Apr 24 08:58:33 2018 +0000
- Revision:
- 0:0b6732b53bf4
Temporary Connector Reversed Version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:0b6732b53bf4 | 1 | #include "mbed.h" |
Rhyme | 0:0b6732b53bf4 | 2 | #include "edge_sensor.h" |
Rhyme | 0:0b6732b53bf4 | 3 | #include "edge_time.h" |
Rhyme | 0:0b6732b53bf4 | 4 | #include "edge_reset_mgr.h" |
Rhyme | 0:0b6732b53bf4 | 5 | #include "PSE530.h" |
Rhyme | 0:0b6732b53bf4 | 6 | #include "edge_pressure.h" |
Rhyme | 0:0b6732b53bf4 | 7 | #include <ILI9341.h> |
Rhyme | 0:0b6732b53bf4 | 8 | #include "edge_chart.h" |
Rhyme | 0:0b6732b53bf4 | 9 | // #include "SO1602A.h" |
Rhyme | 0:0b6732b53bf4 | 10 | |
Rhyme | 0:0b6732b53bf4 | 11 | // extern SO1602A *display ; /* OLED display on I2C */ |
Rhyme | 0:0b6732b53bf4 | 12 | extern ILI9341 *display ; |
Rhyme | 0:0b6732b53bf4 | 13 | |
Rhyme | 0:0b6732b53bf4 | 14 | #define LOW_THR 0.2 |
Rhyme | 0:0b6732b53bf4 | 15 | #define HIGH_THR 0.3 |
Rhyme | 0:0b6732b53bf4 | 16 | #define MIN_TEMP 12.0 |
Rhyme | 0:0b6732b53bf4 | 17 | #define MAX_TEMP 30.0 |
Rhyme | 0:0b6732b53bf4 | 18 | |
Rhyme | 0:0b6732b53bf4 | 19 | /** |
Rhyme | 0:0b6732b53bf4 | 20 | * SMC PSE530 pressure sensor |
Rhyme | 0:0b6732b53bf4 | 21 | * analog output 1.0V - 5.0V |
Rhyme | 0:0b6732b53bf4 | 22 | * 1.0V : 0 |
Rhyme | 0:0b6732b53bf4 | 23 | * 5.0V : 1MPa |
Rhyme | 0:0b6732b53bf4 | 24 | * (at 0.6V : -0.1MPa) |
Rhyme | 0:0b6732b53bf4 | 25 | * Our sensor I/F converts 0-5V to 0-1 |
Rhyme | 0:0b6732b53bf4 | 26 | * So we suppose V = Analog Float Value : Pressure |
Rhyme | 0:0b6732b53bf4 | 27 | * 0.2 = 0 |
Rhyme | 0:0b6732b53bf4 | 28 | * 1.0 = 1MPa |
Rhyme | 0:0b6732b53bf4 | 29 | */ |
Rhyme | 0:0b6732b53bf4 | 30 | |
Rhyme | 0:0b6732b53bf4 | 31 | float temp2expected(float temp) |
Rhyme | 0:0b6732b53bf4 | 32 | { |
Rhyme | 0:0b6732b53bf4 | 33 | const float coef_A = 0.089 ; |
Rhyme | 0:0b6732b53bf4 | 34 | const float coef_B = 0.831 ; |
Rhyme | 0:0b6732b53bf4 | 35 | float pressure ; |
Rhyme | 0:0b6732b53bf4 | 36 | |
Rhyme | 0:0b6732b53bf4 | 37 | pressure = temp * coef_A + coef_B ; |
Rhyme | 0:0b6732b53bf4 | 38 | return( pressure ) ; |
Rhyme | 0:0b6732b53bf4 | 39 | } |
Rhyme | 0:0b6732b53bf4 | 40 | |
Rhyme | 0:0b6732b53bf4 | 41 | edge_pressure::edge_pressure(PSE530 *pse, DigitalOut *en) |
Rhyme | 0:0b6732b53bf4 | 42 | { |
Rhyme | 0:0b6732b53bf4 | 43 | _pse = pse ; |
Rhyme | 0:0b6732b53bf4 | 44 | _en = en ; |
Rhyme | 0:0b6732b53bf4 | 45 | _value = 0.0 ; |
Rhyme | 0:0b6732b53bf4 | 46 | _interval = 30 ; |
Rhyme | 0:0b6732b53bf4 | 47 | _thr_mode = 0 ; |
Rhyme | 0:0b6732b53bf4 | 48 | _thr_high = HIGH_THR ; |
Rhyme | 0:0b6732b53bf4 | 49 | _thr_low = LOW_THR ; |
Rhyme | 0:0b6732b53bf4 | 50 | } |
Rhyme | 0:0b6732b53bf4 | 51 | |
Rhyme | 0:0b6732b53bf4 | 52 | edge_pressure::~edge_pressure(void) |
Rhyme | 0:0b6732b53bf4 | 53 | { |
Rhyme | 0:0b6732b53bf4 | 54 | if (_pse) { |
Rhyme | 0:0b6732b53bf4 | 55 | delete _pse ; |
Rhyme | 0:0b6732b53bf4 | 56 | } |
Rhyme | 0:0b6732b53bf4 | 57 | _value = 0.0 ; |
Rhyme | 0:0b6732b53bf4 | 58 | } |
Rhyme | 0:0b6732b53bf4 | 59 | |
Rhyme | 0:0b6732b53bf4 | 60 | float edge_pressure::get_value(void) |
Rhyme | 0:0b6732b53bf4 | 61 | { |
Rhyme | 0:0b6732b53bf4 | 62 | float value = 0.0 ; |
Rhyme | 0:0b6732b53bf4 | 63 | value = _pse->getPressure() ; |
Rhyme | 0:0b6732b53bf4 | 64 | return( value ) ; |
Rhyme | 0:0b6732b53bf4 | 65 | } |
Rhyme | 0:0b6732b53bf4 | 66 | |
Rhyme | 0:0b6732b53bf4 | 67 | void edge_pressure::reset(void) |
Rhyme | 0:0b6732b53bf4 | 68 | { |
Rhyme | 0:0b6732b53bf4 | 69 | _value = 0.0 ; |
Rhyme | 0:0b6732b53bf4 | 70 | _sampled_time = 0 ; |
Rhyme | 0:0b6732b53bf4 | 71 | } |
Rhyme | 0:0b6732b53bf4 | 72 | |
Rhyme | 0:0b6732b53bf4 | 73 | void edge_pressure::prepare(void) |
Rhyme | 0:0b6732b53bf4 | 74 | { |
Rhyme | 0:0b6732b53bf4 | 75 | } |
Rhyme | 0:0b6732b53bf4 | 76 | |
Rhyme | 0:0b6732b53bf4 | 77 | int edge_pressure::sample(void) |
Rhyme | 0:0b6732b53bf4 | 78 | { |
Rhyme | 0:0b6732b53bf4 | 79 | int result = 0 ; |
Rhyme | 0:0b6732b53bf4 | 80 | *_en = 1 ; /* enable pressure sensor */ |
Rhyme | 0:0b6732b53bf4 | 81 | wait_ms(30) ; |
Rhyme | 0:0b6732b53bf4 | 82 | _value = get_value() ; |
Rhyme | 0:0b6732b53bf4 | 83 | _sampled_time = edge_time ; |
Rhyme | 0:0b6732b53bf4 | 84 | *_en = 0 ; /* disable pressure sensor */ |
Rhyme | 0:0b6732b53bf4 | 85 | wait_ms(10) ; /* to avoid power transition effect remaining */ |
Rhyme | 0:0b6732b53bf4 | 86 | return( result ) ; /* this always success */ |
Rhyme | 0:0b6732b53bf4 | 87 | } |
Rhyme | 0:0b6732b53bf4 | 88 | |
Rhyme | 0:0b6732b53bf4 | 89 | void edge_pressure::set_thr_high(int16_t thr_high) |
Rhyme | 0:0b6732b53bf4 | 90 | { |
Rhyme | 0:0b6732b53bf4 | 91 | switch(_thr_mode) { |
Rhyme | 0:0b6732b53bf4 | 92 | case 0: /* absolute value */ |
Rhyme | 0:0b6732b53bf4 | 93 | _thr_high = (float)thr_high/100.0 ; |
Rhyme | 0:0b6732b53bf4 | 94 | break ; |
Rhyme | 0:0b6732b53bf4 | 95 | case 1: /* persentage */ |
Rhyme | 0:0b6732b53bf4 | 96 | _thr_high = (float)(thr_high/100.0) ; |
Rhyme | 0:0b6732b53bf4 | 97 | break ; |
Rhyme | 0:0b6732b53bf4 | 98 | default: |
Rhyme | 0:0b6732b53bf4 | 99 | printf("Unknown Threshold mode %d\n", _thr_mode) ; |
Rhyme | 0:0b6732b53bf4 | 100 | _thr_high = (float)thr_high/100.0 ; |
Rhyme | 0:0b6732b53bf4 | 101 | break ; |
Rhyme | 0:0b6732b53bf4 | 102 | } |
Rhyme | 0:0b6732b53bf4 | 103 | // printf("thr_high = %.3f\n", _thr_high) ; |
Rhyme | 0:0b6732b53bf4 | 104 | } |
Rhyme | 0:0b6732b53bf4 | 105 | |
Rhyme | 0:0b6732b53bf4 | 106 | float edge_pressure::get_thr_high(float expected) |
Rhyme | 0:0b6732b53bf4 | 107 | { |
Rhyme | 0:0b6732b53bf4 | 108 | float thr_high ; |
Rhyme | 0:0b6732b53bf4 | 109 | |
Rhyme | 0:0b6732b53bf4 | 110 | switch(_thr_mode) { |
Rhyme | 0:0b6732b53bf4 | 111 | case 0: /* absolute value */ |
Rhyme | 0:0b6732b53bf4 | 112 | thr_high = expected + _thr_high ; |
Rhyme | 0:0b6732b53bf4 | 113 | break ; |
Rhyme | 0:0b6732b53bf4 | 114 | case 1: /* persentage */ |
Rhyme | 0:0b6732b53bf4 | 115 | thr_high = expected * (1.0 + _thr_high) ; |
Rhyme | 0:0b6732b53bf4 | 116 | break ; |
Rhyme | 0:0b6732b53bf4 | 117 | default: |
Rhyme | 0:0b6732b53bf4 | 118 | printf("Unknown Threshold mode %d\n", _thr_mode) ; |
Rhyme | 0:0b6732b53bf4 | 119 | thr_high = expected + _thr_high ; /* use this as default */ |
Rhyme | 0:0b6732b53bf4 | 120 | break ; |
Rhyme | 0:0b6732b53bf4 | 121 | } |
Rhyme | 0:0b6732b53bf4 | 122 | return (thr_high) ; |
Rhyme | 0:0b6732b53bf4 | 123 | } |
Rhyme | 0:0b6732b53bf4 | 124 | |
Rhyme | 0:0b6732b53bf4 | 125 | void edge_pressure::set_thr_low(int16_t thr_low) |
Rhyme | 0:0b6732b53bf4 | 126 | { |
Rhyme | 0:0b6732b53bf4 | 127 | switch(_thr_mode) { |
Rhyme | 0:0b6732b53bf4 | 128 | case 0: /* absolute value */ |
Rhyme | 0:0b6732b53bf4 | 129 | _thr_low = (float)thr_low/100.0 ; |
Rhyme | 0:0b6732b53bf4 | 130 | break ; |
Rhyme | 0:0b6732b53bf4 | 131 | case 1: /* persentage */ |
Rhyme | 0:0b6732b53bf4 | 132 | _thr_low = (float)(thr_low/100.0) ; |
Rhyme | 0:0b6732b53bf4 | 133 | break ; |
Rhyme | 0:0b6732b53bf4 | 134 | default: |
Rhyme | 0:0b6732b53bf4 | 135 | printf("Unknown Threshold mode %d\n", _thr_mode) ; |
Rhyme | 0:0b6732b53bf4 | 136 | _thr_low = (float)thr_low/100.0 ; |
Rhyme | 0:0b6732b53bf4 | 137 | break ; |
Rhyme | 0:0b6732b53bf4 | 138 | } |
Rhyme | 0:0b6732b53bf4 | 139 | //printf("thr_low = %.3f\n", _thr_low) ; |
Rhyme | 0:0b6732b53bf4 | 140 | } |
Rhyme | 0:0b6732b53bf4 | 141 | |
Rhyme | 0:0b6732b53bf4 | 142 | float edge_pressure::get_thr_low(float expected) |
Rhyme | 0:0b6732b53bf4 | 143 | { |
Rhyme | 0:0b6732b53bf4 | 144 | float thr_low ; |
Rhyme | 0:0b6732b53bf4 | 145 | |
Rhyme | 0:0b6732b53bf4 | 146 | switch(_thr_mode) { |
Rhyme | 0:0b6732b53bf4 | 147 | case 0: /* absolute value */ |
Rhyme | 0:0b6732b53bf4 | 148 | thr_low = expected - _thr_low ; |
Rhyme | 0:0b6732b53bf4 | 149 | break ; |
Rhyme | 0:0b6732b53bf4 | 150 | case 1: /* persentage */ |
Rhyme | 0:0b6732b53bf4 | 151 | thr_low = expected * (1.0 - _thr_low) ; |
Rhyme | 0:0b6732b53bf4 | 152 | break ; |
Rhyme | 0:0b6732b53bf4 | 153 | default: |
Rhyme | 0:0b6732b53bf4 | 154 | printf("Unknown Threshold mode %d\n", _thr_mode) ; |
Rhyme | 0:0b6732b53bf4 | 155 | thr_low = expected + _thr_low ; /* use this as default */ |
Rhyme | 0:0b6732b53bf4 | 156 | break ; |
Rhyme | 0:0b6732b53bf4 | 157 | } |
Rhyme | 0:0b6732b53bf4 | 158 | return (thr_low) ; |
Rhyme | 0:0b6732b53bf4 | 159 | } |
Rhyme | 0:0b6732b53bf4 | 160 | |
Rhyme | 0:0b6732b53bf4 | 161 | int edge_pressure::deliver(void) |
Rhyme | 0:0b6732b53bf4 | 162 | { |
Rhyme | 0:0b6732b53bf4 | 163 | char str_buf[32] ; |
Rhyme | 0:0b6732b53bf4 | 164 | char timestr[16] ; |
Rhyme | 0:0b6732b53bf4 | 165 | int result ; |
Rhyme | 0:0b6732b53bf4 | 166 | |
Rhyme | 0:0b6732b53bf4 | 167 | reset_watch_dog() ; |
Rhyme | 0:0b6732b53bf4 | 168 | print_time(_sampled_time) ; |
Rhyme | 0:0b6732b53bf4 | 169 | if (current_temp != 0) { |
Rhyme | 0:0b6732b53bf4 | 170 | sprintf(str_buf, "GAS: %.3f kgf/cm2 @ %.1fC", _value, *current_temp ) ; |
Rhyme | 0:0b6732b53bf4 | 171 | } else { |
Rhyme | 0:0b6732b53bf4 | 172 | sprintf(str_buf, "GAS: %.3f kgf/cm2", _value ) ; |
Rhyme | 0:0b6732b53bf4 | 173 | } |
Rhyme | 0:0b6732b53bf4 | 174 | printf(" ") ; |
Rhyme | 0:0b6732b53bf4 | 175 | printf(str_buf) ; |
Rhyme | 0:0b6732b53bf4 | 176 | |
Rhyme | 0:0b6732b53bf4 | 177 | if (current_temp != 0) { |
Rhyme | 0:0b6732b53bf4 | 178 | reset_watch_dog() ; |
Rhyme | 0:0b6732b53bf4 | 179 | _expected = temp2expected(*current_temp) ; |
Rhyme | 0:0b6732b53bf4 | 180 | _higher = get_thr_high(_expected) ; |
Rhyme | 0:0b6732b53bf4 | 181 | _lower = get_thr_low(_expected) ; |
Rhyme | 0:0b6732b53bf4 | 182 | printf(" (%.3f, %.3f) ", _higher, _lower) ; |
Rhyme | 0:0b6732b53bf4 | 183 | } |
Rhyme | 0:0b6732b53bf4 | 184 | |
Rhyme | 0:0b6732b53bf4 | 185 | reset_watch_dog() ; |
Rhyme | 0:0b6732b53bf4 | 186 | printf(" %s\n", str_buf) ; |
Rhyme | 0:0b6732b53bf4 | 187 | time2seq(_sampled_time, timestr) ; |
Rhyme | 0:0b6732b53bf4 | 188 | // printf(str_buf) ; |
Rhyme | 0:0b6732b53bf4 | 189 | // printf("\n") ; |
Rhyme | 0:0b6732b53bf4 | 190 | sprintf(_str_buf, |
Rhyme | 0:0b6732b53bf4 | 191 | "{\"DEVICE\":\"PRESS\",\"PN\":\"PSE530\",\"VAL\":\"%.3f\",\"UNIT\":\"kgf/cm2\",\"T\":\"%s\",\"E\":\"%d\"}", |
Rhyme | 0:0b6732b53bf4 | 192 | _value, timestr, _error_count) ; |
Rhyme | 0:0b6732b53bf4 | 193 | reset_watch_dog() ; |
Rhyme | 0:0b6732b53bf4 | 194 | result = afero->setAttribute(1, _str_buf) ; |
Rhyme | 0:0b6732b53bf4 | 195 | return( result == afSUCCESS ) ; |
Rhyme | 0:0b6732b53bf4 | 196 | } |
Rhyme | 0:0b6732b53bf4 | 197 | |
Rhyme | 0:0b6732b53bf4 | 198 | int v2x(float value) |
Rhyme | 0:0b6732b53bf4 | 199 | { |
Rhyme | 0:0b6732b53bf4 | 200 | int result ; |
Rhyme | 0:0b6732b53bf4 | 201 | if (value < 0) { |
Rhyme | 0:0b6732b53bf4 | 202 | result = 20 ; |
Rhyme | 0:0b6732b53bf4 | 203 | } else if (value > 4) { |
Rhyme | 0:0b6732b53bf4 | 204 | result = 300 ; |
Rhyme | 0:0b6732b53bf4 | 205 | } else { |
Rhyme | 0:0b6732b53bf4 | 206 | result = 20 + (int)(70 * value + 0.5) ; |
Rhyme | 0:0b6732b53bf4 | 207 | } |
Rhyme | 0:0b6732b53bf4 | 208 | return( result ) ; |
Rhyme | 0:0b6732b53bf4 | 209 | } |
Rhyme | 0:0b6732b53bf4 | 210 | |
Rhyme | 0:0b6732b53bf4 | 211 | int press_v2y(float value, edge_chart_type *p) |
Rhyme | 0:0b6732b53bf4 | 212 | { |
Rhyme | 0:0b6732b53bf4 | 213 | int y ; |
Rhyme | 0:0b6732b53bf4 | 214 | if (value < p->min) { |
Rhyme | 0:0b6732b53bf4 | 215 | value = p->min ; |
Rhyme | 0:0b6732b53bf4 | 216 | } else if (value > p->max) { |
Rhyme | 0:0b6732b53bf4 | 217 | value = p->max ; |
Rhyme | 0:0b6732b53bf4 | 218 | } |
Rhyme | 0:0b6732b53bf4 | 219 | y = p->top + p->height - 2 |
Rhyme | 0:0b6732b53bf4 | 220 | - (int)((p->height - 2) * ((value - p->min) /(p->max - p->min))) ; |
Rhyme | 0:0b6732b53bf4 | 221 | return( y ) ; |
Rhyme | 0:0b6732b53bf4 | 222 | } |
Rhyme | 0:0b6732b53bf4 | 223 | |
Rhyme | 0:0b6732b53bf4 | 224 | /** |
Rhyme | 0:0b6732b53bf4 | 225 | * drawPointer |
Rhyme | 0:0b6732b53bf4 | 226 | * |
Rhyme | 0:0b6732b53bf4 | 227 | * draw a triangle pointer at value place |
Rhyme | 0:0b6732b53bf4 | 228 | * in GAS pressure display mode |
Rhyme | 0:0b6732b53bf4 | 229 | */ |
Rhyme | 0:0b6732b53bf4 | 230 | void edge_pressure::drawPointer(int c) |
Rhyme | 0:0b6732b53bf4 | 231 | { |
Rhyme | 0:0b6732b53bf4 | 232 | float delta_x ; |
Rhyme | 0:0b6732b53bf4 | 233 | int x[2], y, i ; |
Rhyme | 0:0b6732b53bf4 | 234 | const int top = 75 ; |
Rhyme | 0:0b6732b53bf4 | 235 | const int pointer_height = 15 ; |
Rhyme | 0:0b6732b53bf4 | 236 | for (i = 0 ; i < pointer_height ; i++ ) { |
Rhyme | 0:0b6732b53bf4 | 237 | y = top + i ; |
Rhyme | 0:0b6732b53bf4 | 238 | delta_x = i * 5.0 / 8.0 ; |
Rhyme | 0:0b6732b53bf4 | 239 | x[0] = c - delta_x ; |
Rhyme | 0:0b6732b53bf4 | 240 | x[1] = c + delta_x ; |
Rhyme | 0:0b6732b53bf4 | 241 | display->line(x[0], y, x[1], y, White) ; |
Rhyme | 0:0b6732b53bf4 | 242 | } |
Rhyme | 0:0b6732b53bf4 | 243 | } |
Rhyme | 0:0b6732b53bf4 | 244 | |
Rhyme | 0:0b6732b53bf4 | 245 | void edge_pressure::show(void) |
Rhyme | 0:0b6732b53bf4 | 246 | { |
Rhyme | 0:0b6732b53bf4 | 247 | edge_chart_type *p = &edge_chart[ _id ] ; |
Rhyme | 0:0b6732b53bf4 | 248 | uint16_t color = White ; |
Rhyme | 0:0b6732b53bf4 | 249 | char str_buf[32] ; |
Rhyme | 0:0b6732b53bf4 | 250 | int i, x, y, l, r, c, str_x ; |
Rhyme | 0:0b6732b53bf4 | 251 | if (display) { |
Rhyme | 0:0b6732b53bf4 | 252 | reset_watch_dog() ; |
Rhyme | 0:0b6732b53bf4 | 253 | /* for debug */ |
Rhyme | 0:0b6732b53bf4 | 254 | // _value = _lower - 0.5 ; /* LOW */ |
Rhyme | 0:0b6732b53bf4 | 255 | // _value = (_higher + _lower) / 2 ; /* GOOD */ |
Rhyme | 0:0b6732b53bf4 | 256 | // _value = _higher + 0.2 ; /* HIGH */ |
Rhyme | 0:0b6732b53bf4 | 257 | |
Rhyme | 0:0b6732b53bf4 | 258 | if (_value > _higher) { |
Rhyme | 0:0b6732b53bf4 | 259 | sprintf(str_buf, "HIGH") ; |
Rhyme | 0:0b6732b53bf4 | 260 | color = Red ; |
Rhyme | 0:0b6732b53bf4 | 261 | str_x = 60 ; |
Rhyme | 0:0b6732b53bf4 | 262 | } else if (_value < _lower) { |
Rhyme | 0:0b6732b53bf4 | 263 | sprintf(str_buf, "LOW") ; |
Rhyme | 0:0b6732b53bf4 | 264 | color = Yellow ; |
Rhyme | 0:0b6732b53bf4 | 265 | str_x = 60 ; |
Rhyme | 0:0b6732b53bf4 | 266 | } else { |
Rhyme | 0:0b6732b53bf4 | 267 | sprintf(str_buf, "GOOD") ; |
Rhyme | 0:0b6732b53bf4 | 268 | color = Green ; |
Rhyme | 0:0b6732b53bf4 | 269 | str_x = 35 ; |
Rhyme | 0:0b6732b53bf4 | 270 | } |
Rhyme | 0:0b6732b53bf4 | 271 | switch(display_mode) { |
Rhyme | 0:0b6732b53bf4 | 272 | case DISPLAY_MODE_GAS: |
Rhyme | 0:0b6732b53bf4 | 273 | display->BusEnable(true) ; |
Rhyme | 0:0b6732b53bf4 | 274 | display->cls() ; |
Rhyme | 0:0b6732b53bf4 | 275 | /* printf frame */ |
Rhyme | 0:0b6732b53bf4 | 276 | display->foreground(White) ; |
Rhyme | 0:0b6732b53bf4 | 277 | display->line(20, 75, 300, 75, White) ; |
Rhyme | 0:0b6732b53bf4 | 278 | for (i = 0 ; i <= 8 ; i++ ) { |
Rhyme | 0:0b6732b53bf4 | 279 | x = 20 + i * 35 ; |
Rhyme | 0:0b6732b53bf4 | 280 | if (i & 0x01) { /* odd */ |
Rhyme | 0:0b6732b53bf4 | 281 | display->line(x, 55, x, 95, White) ; |
Rhyme | 0:0b6732b53bf4 | 282 | } else { /* even */ |
Rhyme | 0:0b6732b53bf4 | 283 | display->line(x, 45, x, 105, White) ; |
Rhyme | 0:0b6732b53bf4 | 284 | } |
Rhyme | 0:0b6732b53bf4 | 285 | } |
Rhyme | 0:0b6732b53bf4 | 286 | display->set_font((unsigned char*) Arial28x28); |
Rhyme | 0:0b6732b53bf4 | 287 | for (i = 0 ; i <= 4 ; i++ ) { |
Rhyme | 0:0b6732b53bf4 | 288 | x = 12 + i * 70 ; |
Rhyme | 0:0b6732b53bf4 | 289 | display->locate(x, 10) ; |
Rhyme | 0:0b6732b53bf4 | 290 | display->printf("%d", i) ; |
Rhyme | 0:0b6732b53bf4 | 291 | } |
Rhyme | 0:0b6732b53bf4 | 292 | /* print expected area and current pressure */ |
Rhyme | 0:0b6732b53bf4 | 293 | l = v2x(_lower) ; |
Rhyme | 0:0b6732b53bf4 | 294 | r = v2x(_higher) ; |
Rhyme | 0:0b6732b53bf4 | 295 | c = v2x(_value) ; |
Rhyme | 0:0b6732b53bf4 | 296 | // display->fillrect(l, 70, r, 80, Red) ; |
Rhyme | 0:0b6732b53bf4 | 297 | display->fillrect(l, 65, r, 74, Red) ; |
Rhyme | 0:0b6732b53bf4 | 298 | // display->fillcircle(c, 75, 10, White) ; |
Rhyme | 0:0b6732b53bf4 | 299 | drawPointer(c) ; |
Rhyme | 0:0b6732b53bf4 | 300 | |
Rhyme | 0:0b6732b53bf4 | 301 | /* print status */ |
Rhyme | 0:0b6732b53bf4 | 302 | display->locate(str_x, 140) ; |
Rhyme | 0:0b6732b53bf4 | 303 | display->set_font_zoom(3, 3) ; |
Rhyme | 0:0b6732b53bf4 | 304 | display->foreground(color) ; |
Rhyme | 0:0b6732b53bf4 | 305 | display->printf(str_buf) ; |
Rhyme | 0:0b6732b53bf4 | 306 | display->set_font_zoom(1, 1) ; |
Rhyme | 0:0b6732b53bf4 | 307 | display->BusEnable(false) ; |
Rhyme | 0:0b6732b53bf4 | 308 | break ; |
Rhyme | 0:0b6732b53bf4 | 309 | case DISPLAY_MODE_SUMMARY: |
Rhyme | 0:0b6732b53bf4 | 310 | display->BusEnable(true) ; |
Rhyme | 0:0b6732b53bf4 | 311 | display->set_font((unsigned char*) Arial12x12); |
Rhyme | 0:0b6732b53bf4 | 312 | display->set_font_zoom(2, 2) ; |
Rhyme | 0:0b6732b53bf4 | 313 | display->foreground(White) ; |
Rhyme | 0:0b6732b53bf4 | 314 | display->locate(10, EDGE_SUMMARY_TIME_Y) ; |
Rhyme | 0:0b6732b53bf4 | 315 | displayTime(_sampled_time) ; |
Rhyme | 0:0b6732b53bf4 | 316 | // display->locate(10,50) ; |
Rhyme | 0:0b6732b53bf4 | 317 | // display->printf(timestr) ; |
Rhyme | 0:0b6732b53bf4 | 318 | display->locate(10, EDGE_SUMMARY_PRESS_Y) ; |
Rhyme | 0:0b6732b53bf4 | 319 | display->printf("Press: ") ; |
Rhyme | 0:0b6732b53bf4 | 320 | display->foreground(color) ; |
Rhyme | 0:0b6732b53bf4 | 321 | display->locate(90, EDGE_SUMMARY_PRESS_Y) ; |
Rhyme | 0:0b6732b53bf4 | 322 | display->printf("%.3f ", _value) ; |
Rhyme | 0:0b6732b53bf4 | 323 | display->foreground(White) ; |
Rhyme | 0:0b6732b53bf4 | 324 | display->printf("kgf/cm2") ; |
Rhyme | 0:0b6732b53bf4 | 325 | display->BusEnable(false) ; |
Rhyme | 0:0b6732b53bf4 | 326 | break ; |
Rhyme | 0:0b6732b53bf4 | 327 | case DISPLAY_MODE_CHART: |
Rhyme | 0:0b6732b53bf4 | 328 | x = p->left + p->index + 1; |
Rhyme | 0:0b6732b53bf4 | 329 | y = press_v2y(_value, p) ; |
Rhyme | 0:0b6732b53bf4 | 330 | display->BusEnable(true) ; |
Rhyme | 0:0b6732b53bf4 | 331 | if (p->index == 0) { |
Rhyme | 0:0b6732b53bf4 | 332 | draw_chart_frame(p) ; |
Rhyme | 0:0b6732b53bf4 | 333 | } |
Rhyme | 0:0b6732b53bf4 | 334 | display->foreground(color) ; |
Rhyme | 0:0b6732b53bf4 | 335 | display->pixel(x, y, color) ; |
Rhyme | 0:0b6732b53bf4 | 336 | display->set_font((unsigned char*) Arial12x12); |
Rhyme | 0:0b6732b53bf4 | 337 | display->locate(p->left + 40, p->top + 5) ; |
Rhyme | 0:0b6732b53bf4 | 338 | display->printf("%5s", str_buf) ; |
Rhyme | 0:0b6732b53bf4 | 339 | display->foreground(White) ; |
Rhyme | 0:0b6732b53bf4 | 340 | display->BusEnable(false) ; |
Rhyme | 0:0b6732b53bf4 | 341 | p->index = (p->index + 1) % (p->width - 2) ; |
Rhyme | 0:0b6732b53bf4 | 342 | break ; |
Rhyme | 0:0b6732b53bf4 | 343 | } |
Rhyme | 0:0b6732b53bf4 | 344 | } |
Rhyme | 0:0b6732b53bf4 | 345 | reset_watch_dog() ; |
Rhyme | 0:0b6732b53bf4 | 346 | } |