Release candidate version. The pointer in GAS Pressure display is changed to a triangle.

Dependencies:   UniGraphic mbed vt100

Please note, at 2-Mar-2018 the current version of mbed-lib has a defect in Ticker.
https://os.mbed.com/forum/bugs-suggestions/topic/29287/

So, mbed lib version 157 is intentionally being used.
Please do not update mbed library until the problem in the above URL is fixed.

In this version, format of GAS Pressure Display has been changed.
/media/uploads/Rhyme/low.jpg

/media/uploads/Rhyme/good.jpg

/media/uploads/Rhyme/high.jpg

moto

Committer:
Rhyme
Date:
Fri Mar 02 07:56:09 2018 +0000
Revision:
0:774324cbc5a6
Release candidate version. GAS Pressure pointer is now a triangle.; Some source file clean-up was done.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:774324cbc5a6 1 #include "mbed.h"
Rhyme 0:774324cbc5a6 2 #include "LM75B.h"
Rhyme 0:774324cbc5a6 3 #include "edge_reset_mgr.h"
Rhyme 0:774324cbc5a6 4 #include "edge_sensor.h"
Rhyme 0:774324cbc5a6 5 #include "edge_temp.h"
Rhyme 0:774324cbc5a6 6 #include "edge_chart.h"
Rhyme 0:774324cbc5a6 7
Rhyme 0:774324cbc5a6 8 float *current_temp = 0 ;
Rhyme 0:774324cbc5a6 9
Rhyme 0:774324cbc5a6 10 edge_temp::edge_temp(LM75B *temp1, SMTC502AT *temp2, SMTC502AT *temp3, LM75B *temp4)
Rhyme 0:774324cbc5a6 11 {
Rhyme 0:774324cbc5a6 12 _temp1 = temp1 ;
Rhyme 0:774324cbc5a6 13 _temp2 = temp2 ;
Rhyme 0:774324cbc5a6 14 _temp3 = temp3 ;
Rhyme 0:774324cbc5a6 15 _temp4 = temp4 ;
Rhyme 0:774324cbc5a6 16 _ftemp[0] = _ftemp[1] = _ftemp[2] = _ftemp[3] = 0.0 ;
Rhyme 0:774324cbc5a6 17 _interval = 30 ;
Rhyme 0:774324cbc5a6 18 current_temp = &_ftemp[1] ; /* use before for current temp */
Rhyme 0:774324cbc5a6 19 }
Rhyme 0:774324cbc5a6 20
Rhyme 0:774324cbc5a6 21 edge_temp::~edge_temp(void)
Rhyme 0:774324cbc5a6 22 {
Rhyme 0:774324cbc5a6 23 if (_temp1) {
Rhyme 0:774324cbc5a6 24 delete _temp1 ;
Rhyme 0:774324cbc5a6 25 }
Rhyme 0:774324cbc5a6 26 if (_temp2) {
Rhyme 0:774324cbc5a6 27 delete _temp2 ;
Rhyme 0:774324cbc5a6 28 }
Rhyme 0:774324cbc5a6 29 if (_temp3) {
Rhyme 0:774324cbc5a6 30 delete _temp3 ;
Rhyme 0:774324cbc5a6 31 }
Rhyme 0:774324cbc5a6 32 if (_temp4) {
Rhyme 0:774324cbc5a6 33 delete _temp4 ;
Rhyme 0:774324cbc5a6 34 }
Rhyme 0:774324cbc5a6 35 }
Rhyme 0:774324cbc5a6 36
Rhyme 0:774324cbc5a6 37 void edge_temp::reset(void)
Rhyme 0:774324cbc5a6 38 {
Rhyme 0:774324cbc5a6 39 }
Rhyme 0:774324cbc5a6 40
Rhyme 0:774324cbc5a6 41 void edge_temp::prepare(void)
Rhyme 0:774324cbc5a6 42 {
Rhyme 0:774324cbc5a6 43 }
Rhyme 0:774324cbc5a6 44
Rhyme 0:774324cbc5a6 45 int edge_temp::sample(void)
Rhyme 0:774324cbc5a6 46 {
Rhyme 0:774324cbc5a6 47 int result ;
Rhyme 0:774324cbc5a6 48 if (_temp1) {
Rhyme 0:774324cbc5a6 49 result = _temp1->getTemp(&_ftemp[0]) ;
Rhyme 0:774324cbc5a6 50 }
Rhyme 0:774324cbc5a6 51 if (_temp2) {
Rhyme 0:774324cbc5a6 52 _ftemp[1] = _temp2->getTemp() ;
Rhyme 0:774324cbc5a6 53 }
Rhyme 0:774324cbc5a6 54 if (_temp3) {
Rhyme 0:774324cbc5a6 55 _ftemp[2] = _temp3->getTemp() ;
Rhyme 0:774324cbc5a6 56 }
Rhyme 0:774324cbc5a6 57 if (_temp4) {
Rhyme 0:774324cbc5a6 58 _temp4->getTemp(&_ftemp[3]) ;
Rhyme 0:774324cbc5a6 59 }
Rhyme 0:774324cbc5a6 60 _sampled_time = edge_time ;
Rhyme 0:774324cbc5a6 61 return( result ) ;
Rhyme 0:774324cbc5a6 62 }
Rhyme 0:774324cbc5a6 63
Rhyme 0:774324cbc5a6 64 int edge_temp::deliver(void)
Rhyme 0:774324cbc5a6 65 {
Rhyme 0:774324cbc5a6 66 int result ;
Rhyme 0:774324cbc5a6 67 char timestr[16] ;
Rhyme 0:774324cbc5a6 68
Rhyme 0:774324cbc5a6 69 print_time() ;
Rhyme 0:774324cbc5a6 70 printf(" temp: ") ;
Rhyme 0:774324cbc5a6 71 if (_temp1) {
Rhyme 0:774324cbc5a6 72 printf("LM75B1 = %.2f ", _ftemp[0]) ;
Rhyme 0:774324cbc5a6 73 }
Rhyme 0:774324cbc5a6 74 if (_temp2) {
Rhyme 0:774324cbc5a6 75 printf("before = %.2f ", _ftemp[1]) ;
Rhyme 0:774324cbc5a6 76 }
Rhyme 0:774324cbc5a6 77 if (_temp3) {
Rhyme 0:774324cbc5a6 78 printf("after = %.2f ", _ftemp[2]) ;
Rhyme 0:774324cbc5a6 79 }
Rhyme 0:774324cbc5a6 80 if (_temp4) {
Rhyme 0:774324cbc5a6 81 printf("LM75B2 = %.2f ", _ftemp[3]) ;
Rhyme 0:774324cbc5a6 82 }
Rhyme 0:774324cbc5a6 83 printf("\n") ;
Rhyme 0:774324cbc5a6 84 time2seq(_sampled_time, timestr) ;
Rhyme 0:774324cbc5a6 85 sprintf(_str_buf,
Rhyme 0:774324cbc5a6 86 "{\"DEVICE\":\"TEMP04\",\"VAL_1\":\"%.1f\",\"VAL_2\":\"%.1f\",\"VAL_3\":\"%.1f\",\"T\":\"%s\",\"E\":\"%d\"}",
Rhyme 0:774324cbc5a6 87 _ftemp[0], _ftemp[1], _ftemp[2], timestr, _error_count) ;
Rhyme 0:774324cbc5a6 88 result = afero->setAttribute(1, _str_buf) ;
Rhyme 0:774324cbc5a6 89 return( result == afSUCCESS ) ;
Rhyme 0:774324cbc5a6 90 }
Rhyme 0:774324cbc5a6 91
Rhyme 0:774324cbc5a6 92 int temp_v2y(float value, edge_chart_type *p)
Rhyme 0:774324cbc5a6 93 {
Rhyme 0:774324cbc5a6 94 int y ;
Rhyme 0:774324cbc5a6 95 if (value < p->min) {
Rhyme 0:774324cbc5a6 96 value = p->min ;
Rhyme 0:774324cbc5a6 97 } else if (value > p->max) {
Rhyme 0:774324cbc5a6 98 value = p->max ;
Rhyme 0:774324cbc5a6 99 }
Rhyme 0:774324cbc5a6 100 y = p->top + p->height - 1
Rhyme 0:774324cbc5a6 101 - (int)((p->height - 2) * (value - p->min) /(p->max - p->min)) ;
Rhyme 0:774324cbc5a6 102 return( y ) ;
Rhyme 0:774324cbc5a6 103 }
Rhyme 0:774324cbc5a6 104
Rhyme 0:774324cbc5a6 105 void edge_temp::show(void)
Rhyme 0:774324cbc5a6 106 {
Rhyme 0:774324cbc5a6 107 edge_chart_type *p = &edge_chart[ _id ] ;
Rhyme 0:774324cbc5a6 108 int x, temp, before, after ;
Rhyme 0:774324cbc5a6 109 reset_watch_dog() ;
Rhyme 0:774324cbc5a6 110 if (display) {
Rhyme 0:774324cbc5a6 111 switch(display_mode) {
Rhyme 0:774324cbc5a6 112 case DISPLAY_MODE_SUMMARY:
Rhyme 0:774324cbc5a6 113 display->BusEnable(true) ;
Rhyme 0:774324cbc5a6 114 display->set_font((unsigned char*) Arial12x12);
Rhyme 0:774324cbc5a6 115 display->set_font_zoom(2, 2) ;
Rhyme 0:774324cbc5a6 116 display->foreground(White) ;
Rhyme 0:774324cbc5a6 117 display->locate(EDGE_SUMMARY_X, EDGE_SUMMARY_TIME_Y) ;
Rhyme 0:774324cbc5a6 118 displayTime(_sampled_time) ;
Rhyme 0:774324cbc5a6 119 display->locate(EDGE_SUMMARY_X, EDGE_SUMMARY_TEMP_Y) ;
Rhyme 0:774324cbc5a6 120 display->printf("Temp : %.2f %.2f %.2f",_ftemp[0], _ftemp[1], _ftemp[2]) ;
Rhyme 0:774324cbc5a6 121 display->BusEnable(false) ;
Rhyme 0:774324cbc5a6 122 reset_watch_dog() ;
Rhyme 0:774324cbc5a6 123 break ;
Rhyme 0:774324cbc5a6 124 case DISPLAY_MODE_CHART:
Rhyme 0:774324cbc5a6 125 x = p->left + p->index + 1;
Rhyme 0:774324cbc5a6 126 temp = temp_v2y(_ftemp[0], p) ;
Rhyme 0:774324cbc5a6 127 before = temp_v2y(_ftemp[1], p) ;
Rhyme 0:774324cbc5a6 128 after = temp_v2y(_ftemp[2], p) ;
Rhyme 0:774324cbc5a6 129 display->BusEnable(true) ;
Rhyme 0:774324cbc5a6 130 if (p->index == 0) {
Rhyme 0:774324cbc5a6 131 draw_chart_frame(p) ;
Rhyme 0:774324cbc5a6 132 }
Rhyme 0:774324cbc5a6 133 display->pixel(x, temp, White) ;
Rhyme 0:774324cbc5a6 134 display->pixel(x, before, Red) ;
Rhyme 0:774324cbc5a6 135 display->pixel(x, after, Blue) ;
Rhyme 0:774324cbc5a6 136 display->BusEnable(false) ;
Rhyme 0:774324cbc5a6 137 p->index = (p->index + 1) % (p->width - 2) ;
Rhyme 0:774324cbc5a6 138 break ;
Rhyme 0:774324cbc5a6 139 }
Rhyme 0:774324cbc5a6 140 }
Rhyme 0:774324cbc5a6 141 reset_watch_dog() ;
Rhyme 0:774324cbc5a6 142 }
Rhyme 0:774324cbc5a6 143