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 "vt100.h"
Rhyme 0:774324cbc5a6 3 #include "afLib.h"
Rhyme 0:774324cbc5a6 4 #include "af_mgr.h"
Rhyme 0:774324cbc5a6 5 #include "edge_mgr.h"
Rhyme 0:774324cbc5a6 6 #include "edge_time.h"
Rhyme 0:774324cbc5a6 7 #include "edge_reset_mgr.h"
Rhyme 0:774324cbc5a6 8 /**
Rhyme 0:774324cbc5a6 9 * afero poc1.5 25-Dec-2017 version
Rhyme 0:774324cbc5a6 10 * from this version, watch dog timer joined again.
Rhyme 0:774324cbc5a6 11 */
Rhyme 0:774324cbc5a6 12
Rhyme 0:774324cbc5a6 13 vt100 *tty = 0 ;
Rhyme 0:774324cbc5a6 14 uint32_t wait_tolerance = 500 ; /* 5sec */
Rhyme 0:774324cbc5a6 15 uint32_t connect_tolerance = 60 ; /* after 60 trials, reboot */
Rhyme 0:774324cbc5a6 16 uint32_t wait_count = 0 ;
Rhyme 0:774324cbc5a6 17 uint32_t connect_trial_count = 0 ;
Rhyme 0:774324cbc5a6 18
Rhyme 0:774324cbc5a6 19 /**
Rhyme 0:774324cbc5a6 20 * wait_connection
Rhyme 0:774324cbc5a6 21 * When gConnected == false, which is connection is lost.
Rhyme 0:774324cbc5a6 22 * Each 5sec check attribute ATTR_WIFI_STDY_STATE to see
Rhyme 0:774324cbc5a6 23 * if the connection has recovered.
Rhyme 0:774324cbc5a6 24 * Meantime even if connection is established communicated
Rhyme 0:774324cbc5a6 25 * data is invalid, so AF_SYSTEM_ASR_STATE is also
Rhyme 0:774324cbc5a6 26 * checked for gLinked ;
Rhyme 0:774324cbc5a6 27 * And in case connect_tolerance trials failed
Rhyme 0:774324cbc5a6 28 * try to reboot the system if it can improve the situation.
Rhyme 0:774324cbc5a6 29 */
Rhyme 0:774324cbc5a6 30 void wait_connection(void)
Rhyme 0:774324cbc5a6 31 {
Rhyme 0:774324cbc5a6 32 int result ;
Rhyme 0:774324cbc5a6 33 wait_count++ ;
Rhyme 0:774324cbc5a6 34 if (wait_count > wait_tolerance) {
Rhyme 0:774324cbc5a6 35 reset_watch_dog() ;
Rhyme 0:774324cbc5a6 36 if (gConnected == false) {
Rhyme 0:774324cbc5a6 37 result = afero->getAttribute(ATTR_WIFI_STDY_STATE) ;
Rhyme 0:774324cbc5a6 38 if (result != afSUCCESS) {
Rhyme 0:774324cbc5a6 39 print_af_error(result) ;
Rhyme 0:774324cbc5a6 40 }
Rhyme 0:774324cbc5a6 41 }
Rhyme 0:774324cbc5a6 42 if (gLinked == false) {
Rhyme 0:774324cbc5a6 43 result = afero->getAttribute(AF_SYSTEM_ASR_STATE) ;
Rhyme 0:774324cbc5a6 44 if (result != afSUCCESS) {
Rhyme 0:774324cbc5a6 45 print_af_error(result) ;
Rhyme 0:774324cbc5a6 46 }
Rhyme 0:774324cbc5a6 47 }
Rhyme 0:774324cbc5a6 48 connect_trial_count++ ;
Rhyme 0:774324cbc5a6 49 if (connect_trial_count > connect_tolerance) {
Rhyme 0:774324cbc5a6 50 reboot_edge() ;
Rhyme 0:774324cbc5a6 51 }
Rhyme 0:774324cbc5a6 52 wait_count = 0 ;
Rhyme 0:774324cbc5a6 53 }
Rhyme 0:774324cbc5a6 54 }
Rhyme 0:774324cbc5a6 55
Rhyme 0:774324cbc5a6 56 void init_hardware(void)
Rhyme 0:774324cbc5a6 57 {
Rhyme 0:774324cbc5a6 58 int i ;
Rhyme 0:774324cbc5a6 59 int result ;
Rhyme 0:774324cbc5a6 60
Rhyme 0:774324cbc5a6 61 reset_watch_dog() ;
Rhyme 0:774324cbc5a6 62 init_display() ;
Rhyme 0:774324cbc5a6 63 reset_watch_dog() ;
Rhyme 0:774324cbc5a6 64 init_aflib() ;
Rhyme 0:774324cbc5a6 65 reset_watch_dog() ;
Rhyme 0:774324cbc5a6 66 init_sensors() ;
Rhyme 0:774324cbc5a6 67 reset_watch_dog() ;
Rhyme 0:774324cbc5a6 68 init_timer() ;
Rhyme 0:774324cbc5a6 69
Rhyme 0:774324cbc5a6 70 while(true) {
Rhyme 0:774324cbc5a6 71 reset_watch_dog() ;
Rhyme 0:774324cbc5a6 72 for (i = 0 ; i < 10 ; i++ ) {
Rhyme 0:774324cbc5a6 73 afero->loop() ;
Rhyme 0:774324cbc5a6 74 reset_watch_dog() ;
Rhyme 0:774324cbc5a6 75 }
Rhyme 0:774324cbc5a6 76 if ((gLinked == true)&&(gConnected == true)) {
Rhyme 0:774324cbc5a6 77 wait_count = 0 ;
Rhyme 0:774324cbc5a6 78 connect_trial_count = 0 ;
Rhyme 0:774324cbc5a6 79 if (afero->isIdle()) {
Rhyme 0:774324cbc5a6 80 result = init_edge_attribute() ;
Rhyme 0:774324cbc5a6 81 if (result == 0) {
Rhyme 0:774324cbc5a6 82 break ;
Rhyme 0:774324cbc5a6 83 }
Rhyme 0:774324cbc5a6 84 }
Rhyme 0:774324cbc5a6 85 } else { /* gLinked == false */
Rhyme 0:774324cbc5a6 86 wait_connection() ;
Rhyme 0:774324cbc5a6 87 }
Rhyme 0:774324cbc5a6 88 wait_ms(10) ;
Rhyme 0:774324cbc5a6 89 }
Rhyme 0:774324cbc5a6 90 do {
Rhyme 0:774324cbc5a6 91 // while(!afero->isIdle()) {
Rhyme 0:774324cbc5a6 92 reset_watch_dog() ;
Rhyme 0:774324cbc5a6 93 for (i = 0 ; i < 10 ; i++ ) {
Rhyme 0:774324cbc5a6 94 afero->loop() ;
Rhyme 0:774324cbc5a6 95 wait_ms(100) ;
Rhyme 0:774324cbc5a6 96 }
Rhyme 0:774324cbc5a6 97 } while(!afero->isIdle()) ;
Rhyme 0:774324cbc5a6 98 edge_mgr_status = EDGE_MGR_RUNNING ;
Rhyme 0:774324cbc5a6 99 }
Rhyme 0:774324cbc5a6 100
Rhyme 0:774324cbc5a6 101 // main() runs in its own thread in the OS
Rhyme 0:774324cbc5a6 102 int main() {
Rhyme 0:774324cbc5a6 103 static uint32_t count_robin = 0 ;
Rhyme 0:774324cbc5a6 104
Rhyme 0:774324cbc5a6 105 tty = new vt100() ;
Rhyme 0:774324cbc5a6 106 // tty->cls() ;
Rhyme 0:774324cbc5a6 107 printf("Afero test program (ver. %s) started\n", __DATE__) ;
Rhyme 0:774324cbc5a6 108 printf("=== Reset Reason ===\n") ;
Rhyme 0:774324cbc5a6 109 print_reset_reason() ;
Rhyme 0:774324cbc5a6 110 printf("====================\n") ;
Rhyme 0:774324cbc5a6 111
Rhyme 0:774324cbc5a6 112 init_hardware() ;
Rhyme 0:774324cbc5a6 113
Rhyme 0:774324cbc5a6 114 edge_splash() ;
Rhyme 0:774324cbc5a6 115
Rhyme 0:774324cbc5a6 116 while (true) {
Rhyme 0:774324cbc5a6 117 count_robin++ ;
Rhyme 0:774324cbc5a6 118 afero->loop() ;
Rhyme 0:774324cbc5a6 119 if ((gLinked == true)&&(gConnected == true)) {
Rhyme 0:774324cbc5a6 120 wait_count = 0 ;
Rhyme 0:774324cbc5a6 121 connect_trial_count = 0 ;
Rhyme 0:774324cbc5a6 122 if (afero->isIdle()) {
Rhyme 0:774324cbc5a6 123 edge_loop(count_robin) ;
Rhyme 0:774324cbc5a6 124 }
Rhyme 0:774324cbc5a6 125 } else { /* gLinked == false */
Rhyme 0:774324cbc5a6 126 wait_connection() ;
Rhyme 0:774324cbc5a6 127 }
Rhyme 0:774324cbc5a6 128 wait_ms(10) ;
Rhyme 0:774324cbc5a6 129 }
Rhyme 0:774324cbc5a6 130 }