Neptune_170620

Dependencies:   mbed

Committer:
Picmon
Date:
Wed Jun 17 10:11:19 2020 +0000
Revision:
0:20b4b057fa7f
Neptune;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Picmon 0:20b4b057fa7f 1 #include <cstdlib>
Picmon 0:20b4b057fa7f 2 #include <string>
Picmon 0:20b4b057fa7f 3 #include "main.h"
Picmon 0:20b4b057fa7f 4 #include "Functions.h"
Picmon 0:20b4b057fa7f 5 #include "Definitions.h"
Picmon 0:20b4b057fa7f 6 #include "Boolean.h"
Picmon 0:20b4b057fa7f 7 #include "NextionLCD.h"
Picmon 0:20b4b057fa7f 8 #include "mbed.h"
Picmon 0:20b4b057fa7f 9 #include "platform/CircularBuffer.h"
Picmon 0:20b4b057fa7f 10 #include "rtos.h"
Picmon 0:20b4b057fa7f 11 #include "Threads.h"
Picmon 0:20b4b057fa7f 12 #include "Languages.h"
Picmon 0:20b4b057fa7f 13 #include "Ser25lcxxx.h"
Picmon 0:20b4b057fa7f 14 #include "NVM.h"
Picmon 0:20b4b057fa7f 15 #include "Watchdog.h"
Picmon 0:20b4b057fa7f 16 #include "NextionPages.h"
Picmon 0:20b4b057fa7f 17 #include "Controls.h"
Picmon 0:20b4b057fa7f 18 #include "FastPWM.h"
Picmon 0:20b4b057fa7f 19 #include "MotorControl.h"
Picmon 0:20b4b057fa7f 20
Picmon 0:20b4b057fa7f 21 /*
Picmon 0:20b4b057fa7f 22
Picmon 0:20b4b057fa7f 23 _/ _/ _/_/_/_/ _/_/_/ _/_/_/ _/_/_/_/ _/_/_/ _/_/_/ _/_/ _/_/_/
Picmon 0:20b4b057fa7f 24 _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
Picmon 0:20b4b057fa7f 25 _/ _/ _/_/_/ _/_/_/ _/ _/ _/_/_/ _/_/_/ _/ _/ _/ _/ _/_/
Picmon 0:20b4b057fa7f 26 _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
Picmon 0:20b4b057fa7f 27 _/ _/_/_/_/ _/ _/ _/_/_/ _/_/_/_/ _/ _/ _/_/_/ _/_/ _/_/_/
Picmon 0:20b4b057fa7f 28
Picmon 0:20b4b057fa7f 29 */
Picmon 0:20b4b057fa7f 30
Picmon 0:20b4b057fa7f 31 //================================================================================================================================
Picmon 0:20b4b057fa7f 32 // COMPANY : Verderflex
Picmon 0:20b4b057fa7f 33 //
Picmon 0:20b4b057fa7f 34 // PROJECT : Verder DOS Peristaltic Pump
Picmon 0:20b4b057fa7f 35 // DATE : 3rd March 2020
Picmon 0:20b4b057fa7f 36
Picmon 0:20b4b057fa7f 37 string HARDWARE = "Hardware Version : HVDOS X1.00";
Picmon 0:20b4b057fa7f 38 string SOFTWARE = "Software Version : SVDOS X1.00";
Picmon 0:20b4b057fa7f 39 string AUTHOR = "Author : Jim Lowe";
Picmon 0:20b4b057fa7f 40
Picmon 0:20b4b057fa7f 41 /*
Picmon 0:20b4b057fa7f 42 * Firmware Numbering Scheme, V Major.Minor.Bugfix
Picmon 0:20b4b057fa7f 43 *
Picmon 0:20b4b057fa7f 44 * Major : Major Changes to function
Picmon 0:20b4b057fa7f 45 * Minor : Minor Changes to function
Picmon 0:20b4b057fa7f 46 * Bugfix : Firmware fixes to function
Picmon 0:20b4b057fa7f 47 *
Picmon 0:20b4b057fa7f 48 */
Picmon 0:20b4b057fa7f 49
Picmon 0:20b4b057fa7f 50 // HARDWARE : NUCLEO-F746ZG + Nextion 4.3" Display
Picmon 0:20b4b057fa7f 51 //
Picmon 0:20b4b057fa7f 52 // COMPILER : Mbed Studio
Picmon 0:20b4b057fa7f 53
Picmon 0:20b4b057fa7f 54 //================================================================================================================================
Picmon 0:20b4b057fa7f 55 //************************************************ Code Status / Changes ********************************************************
Picmon 0:20b4b057fa7f 56 //================================================================================================================================
Picmon 0:20b4b057fa7f 57
Picmon 0:20b4b057fa7f 58 /*
Picmon 0:20b4b057fa7f 59 *
Picmon 0:20b4b057fa7f 60 * NOTES on Nextion Displays:
Picmon 0:20b4b057fa7f 61 * Nextion Push event is generated when the touch screen is PRESSED
Picmon 0:20b4b057fa7f 62 * Nextion Pop event is generated when the touch screen is RELEASED
Picmon 0:20b4b057fa7f 63
Picmon 0:20b4b057fa7f 64 * Firmware Log, Initial Software Development Phase
Picmon 0:20b4b057fa7f 65
Picmon 0:20b4b057fa7f 66 09/05/19 itoa() now working
Picmon 0:20b4b057fa7f 67 09/05/19_E Nextion now running at 115200 Baud
Picmon 0:20b4b057fa7f 68 13/05/19_D Ported over to Nucleo-F746ZG
Picmon 0:20b4b057fa7f 69 15/05/19_A First version working on Mbed Studio
Picmon 0:20b4b057fa7f 70 15/05/19_F Nextion RX Interrupt message decoder started
Picmon 0:20b4b057fa7f 71 16/05/19_A Increment / Decrement arrow work but project need to be cleaned up before going further
Picmon 0:20b4b057fa7f 72 16/05/19_A Push & Pop functions for touch buttons are working.
Picmon 0:20b4b057fa7f 73 17/05/19_A Adding debugging functions
Picmon 0:20b4b057fa7f 74 17/05/19_A Created a debug thread seems to work ok
Picmon 0:20b4b057fa7f 75 17/05/19_B Success Nextion slider is working
Picmon 0:20b4b057fa7f 76 17/05/19_B Flow rate / RPM selection now working
Picmon 0:20b4b057fa7f 77 17/05/19_C PWM now working, needs scaling factors to represent 100% for 1250 RPM etc
Picmon 0:20b4b057fa7f 78 17/05/19_C Progress bar working
Picmon 0:20b4b057fa7f 79 20/05/19_A Peripheral Pin List added
Picmon 0:20b4b057fa7f 80 20/05/19_D PWM frequency changed to 24kHz, this was found to be the frequency used on the DRV8306EVM BLDC Demo board
Picmon 0:20b4b057fa7f 81 20/05/19_D BLDC Motor working under PWM control, now reaches the same build level as QAD with Mbed
Picmon 0:20b4b057fa7f 82 28/05/19_A STM32 does not have any EEPROM, need EEPROM for NVM capability, adding EEPROM capabilities to project
Picmon 0:20b4b057fa7f 83 28/05/19_A Add digital motor control
Picmon 0:20b4b057fa7f 84 28/05/19_A Motor direction control working, other I/O need to be done when schematics arrive from TI
Picmon 0:20b4b057fa7f 85 28/05/19_B Nextion back light dim now working, it is fussy about where it is executed
Picmon 0:20b4b057fa7f 86 29/05/19_B EEPROM testing thread proves EEPROM can be accessed and read correctly, removing EEPROM result in all 00, with EEPROM pattern is repeatable.
Picmon 0:20b4b057fa7f 87 29/05/19_E Good demo code for NVM, needs tidying up
Picmon 0:20b4b057fa7f 88 30/05/19_A Can read full NVM, can write single bytes to NVM
Picmon 0:20b4b057fa7f 89 30/05/19_B This EEPROM library cannot write a single byte to a memory location, it does not work, you have to write the entire NVM which is not good
Picmon 0:20b4b057fa7f 90 31/05/19_A Other EEPROM library no good, will try this again
Picmon 0:20b4b057fa7f 91 31/05/19_A now working in a way to develop the NVM feature properly, this will be pursued after my holiday
Picmon 0:20b4b057fa7f 92 10/06/19_A Continue with NVM development
Picmon 0:20b4b057fa7f 93 10/06/19_B NVM ready for Nextion menu to be taken to next level to feature NVM settings
Picmon 0:20b4b057fa7f 94 12/06/19_A Rotation arrow on menu was not controlling motor rotation, it had been broken by adding other menu buttons, and this is something I am aware of now and to watch out for
Picmon 0:20b4b057fa7f 95 13/06/19_B Culled the amount of project in Mbed Studio as this was too big for the resources for Mbed Studio causing it to not recognize the target as an Mbed enabled device
Picmon 0:20b4b057fa7f 96 13/06/19_B Though I could get away with doing the NVM update in the RX ISR but this causes a run time error crashing the processor, I will place the NVM update in a thread
Picmon 0:20b4b057fa7f 97 14/06/19_A This code is broken trying to transition to better way to implement metering units selection, use next code or previous code
Picmon 0:20b4b057fa7f 98 14/06/19_C Taken most of the day but now NVM RAM is being written to from EEPROM, due to char* pointer this mechanism not working as thought, I have a working method now.
Picmon 0:20b4b057fa7f 99 17/06/18_A First implementation of working NVM, needs some refinement
Picmon 0:20b4b057fa7f 100 17/06/19_D Good refinement achieved for Metering Units NVM
Picmon 0:20b4b057fa7f 101 17/06/19_E memcpy() replaces for loop, implemented free() to free up dynamically created pointer memory after use as eepro.read() uses malloc()
Picmon 0:20b4b057fa7f 102 27/06/19_A Pre work ONLY for 4-20mA, setup of button membrane, 4-20mA control inputs
Picmon 0:20b4b057fa7f 103 01/07/19_A Pre work ONLY for 4-20mA, Open Drain outputs setup and default to off at power up
Picmon 0:20b4b057fa7f 104 02/07/19_A Adding map function
Picmon 0:20b4b057fa7f 105 12/07/19_A Assigned new I/O for start/stop buttons and start/stop LEDS as I/O I has assigned might be required later on as they are part of USB and ST_LINK stuff.
Picmon 0:20b4b057fa7f 106 15/07/19_A Grey Box build all working correctly, phew
Picmon 0:20b4b057fa7f 107 15/07/19_A Need to implement start / stop button control, added state machine
Picmon 0:20b4b057fa7f 108 15/07/19_A Motor thread commented out, motor control part of state machine
Picmon 0:20b4b057fa7f 109 15/07/19_B Not sure how text box b2 is displaying RPM when stopped, I have overridden this for now
Picmon 0:20b4b057fa7f 110 15/07/19_C Stop/Start operational
Picmon 0:20b4b057fa7f 111 16/07/19_A Scaling for RPM, ml/min and % working perfectly
Picmon 0:20b4b057fa7f 112 16/07/19_A_TEXT This is the first version that uses TEXT for displaying metering digits using printf
Picmon 0:20b4b057fa7f 113 17/07/19_C Issues with nextion, this version look ok
Picmon 0:20b4b057fa7f 114 18/07/19_A Page component IDs definitions had changed on Nextion HMI code again when I created 16/07/19_A_TEXT version, its a really crappy and stops your working code from working
Picmon 0:20b4b057fa7f 115 19/07/19_A 3 Second Watchdog implemented and working
Picmon 0:20b4b057fa7f 116 19/07/19_A Nextion power control added and working
Picmon 0:20b4b057fa7f 117 19/07/19_A 1ms timer implemented and working, not uses at present
Picmon 0:20b4b057fa7f 118 22/07/19_A Fit 4-20mA Module and connect up to system
Picmon 0:20b4b057fa7f 119 22/07/19_A DAC pins already use I will have to re-assign pins to be able to use DAC
Picmon 0:20b4b057fa7f 120 22/07/19_A ADC is now measuring mV, ADC is 12bit so more noise than 10bit ADC
Picmon 0:20b4b057fa7f 121 23/07/19_B 4-20mA is outputting to debug screen and is scaled using mapF, look fairly stable and no averaging has been applied yet.
Picmon 0:20b4b057fa7f 122 24/07/19_A Look at ways to make analogue reading more stable
Picmon 0:20b4b057fa7f 123 24/07/19_A Speed control using LoopMate achieved, although values from ain.read_u16() do not seem to make any sense at this time, was expecting 0 - 4095?
Picmon 0:20b4b057fa7f 124 25/07/19_A Good results displayed on debug screen without any software smoothing applied.
Picmon 0:20b4b057fa7f 125 25/07/19_B Working really well now I have add the moving average algorithm, this adds a nice ramp rate to the product
Picmon 0:20b4b057fa7f 126 26/07/19_A Full motor speed does not seem to be there, need to fix this and create a function for motor control via 4-20mA
Picmon 0:20b4b057fa7f 127 26/07/19_A Motor speed is ok now, used mapF() to make sure motor has stopped at 4.0mA, previously it would only stop at 0.0mA
Picmon 0:20b4b057fa7f 128 26/07/19_A Wow, showing excellent stability at 10uA resolution
Picmon 0:20b4b057fa7f 129 26/07/19_A Metering unit displayed against mA, cool
Picmon 0:20b4b057fa7f 130 29/07/19_A Rough ramp rate applied when change of motor direction, this code is only an experiment and is blocking and needs to be refined in to non-blocking code
Picmon 0:20b4b057fa7f 131 01/08/19_A Create functions for manual and 4-20mA
Picmon 0:20b4b057fa7f 132 01/08/19_A Nextion definition need changing for updated display GUI featuring QDOS type menu system
Picmon 0:20b4b057fa7f 133 02/08/19_A Created Timers.cpp to hold all timer functions and structures
Picmon 0:20b4b057fa7f 134 05/08/19_A Trying to implement manual control with dual speed inc/dec functionality
Picmon 0:20b4b057fa7f 135 05/08/19_A I have inc/dec functionality working, tidy code up and move forward
Picmon 0:20b4b057fa7f 136 05/08/19_C meter val changed to int16_t data type from uint16_t so abs() can be used for zeroing negative numbers
Picmon 0:20b4b057fa7f 137 05/08/19_C Nextion screen initializes on page 33 wher no buttons are, page 1 is called when start button is press, stop button calls page 33
Picmon 0:20b4b057fa7f 138 06/08/19_A Threads remove until required, all processing done in main and nextion RX ISR, all working.
Picmon 0:20b4b057fa7f 139 07/08/19_A Can now display flow units retrieval from NVM
Picmon 0:20b4b057fa7f 140 08/08/19_A Implement flow unit selection and storage to EEPROM
Picmon 0:20b4b057fa7f 141 08/08/19_A flow unit can not be see using extern!
Picmon 0:20b4b057fa7f 142 08/08/19_B Flow unit can be written and read from EEPROM
Picmon 0:20b4b057fa7f 143 08/08/19_C Implement manual and analogue operating mode stored in EEPROM
Picmon 0:20b4b057fa7f 144 12/08/19_A Analogue function need to support all flow units
Picmon 0:20b4b057fa7f 145 12/08/19_C This version can demo flow units change, analogue and manual mode selected from menu system
Picmon 0:20b4b057fa7f 146 12/08/19_D meterVal, minScale, maxScale are now floats to give resolution required, this version is not full working at this time
Picmon 0:20b4b057fa7f 147 13/08/19_A displayed info in p1left not correct, need to implement incDecSpeed variable so when the touch key is held the inc/dec speed increases
Picmon 0:20b4b057fa7f 148 14/08/19_A Beware EEPROM value had somehow been changed for run.mode stopping normal program from running, suspect power glitch, as a consequence
Picmon 0:20b4b057fa7f 149 it has taken all morning to figure out the problem.
Picmon 0:20b4b057fa7f 150 14/08/19_B System can now be re-booted by pressing and holding down the ON button for 3 seconds
Picmon 0:20b4b057fa7f 151 15/08/19_A Add some diagnostics to check EEPROM contents
Picmon 0:20b4b057fa7f 152 16/08/19_A Change state machine structure so meter screen is correctly updated on return from Nextion pages
Picmon 0:20b4b057fa7f 153 27/08/19_B Inc/Dec indexer needs improvement
Picmon 0:20b4b057fa7f 154 28/08/19_B Inc/Dec control has been improved, speed can be set manually some tweaking may still be required at later point, moving on to analogue out now.
Picmon 0:20b4b057fa7f 155 28/08/19_C Start of DAC implementation to provide analogue output
Picmon 0:20b4b057fa7f 156 28/08/19_C SPI moved from SPI1 on CN7 to SPI14 on CN9, this is required to allow connection to DACs required for analogue output
Picmon 0:20b4b057fa7f 157 28/08/19_C I have verified that the SPI NVM is working after moving to other microcontroller pins for SPI14
Picmon 0:20b4b057fa7f 158 28/08/19_C I am able to set analogue output currents for test purposes.
Picmon 0:20b4b057fa7f 159 28/08/19_E Analogue output development started
Picmon 0:20b4b057fa7f 160 29/08/19_B Manual speed adjustment improved further now.
Picmon 0:20b4b057fa7f 161 29/08/19_B Stop LED used to prompt user to number indexer when setting flow rates
Picmon 0:20b4b057fa7f 162 02/09/19_A Accurate analogue output when in manual mode can be demonstrated
Picmon 0:20b4b057fa7f 163 02/09/19_B Two dimensional array created for ALL VDOS flow rate types
Picmon 0:20b4b057fa7f 164 02/09/19_B Can store and retrieve floats to EEPROM as an experiment, need to implement this in analogue cal routine
Picmon 0:20b4b057fa7f 165 04/09/19_A Able to switch in and out of ANA_CAL state read for analogue menus
Picmon 0:20b4b057fa7f 166 05/09/19_A WARNING page 1 component ID have changed
Picmon 0:20b4b057fa7f 167 06/09/19_B Almost finished improved flow unit manual inc/dec control
Picmon 0:20b4b057fa7f 168 09/09/19_A I need to be moving forward with analogue calibration so I have put on hold development o inc/dec control for now
Picmon 0:20b4b057fa7f 169 12/09/19_A Floats can be written to and read from EEPROM for mA high, flow high, mA low, flow low calibrations
Picmon 0:20b4b057fa7f 170 12/09/19_B % / mA graph working as initial demo
Picmon 0:20b4b057fa7f 171 16/09/19_A Calibration graph line generation now done on Nextion by timer so no resources are required for this micro.
Picmon 0:20b4b057fa7f 172 17/09/19_A IncDecControl function created that can be used for all inc/dec controls on all pages
Picmon 0:20b4b057fa7f 173 17/09/19_A Clear out functions that are not used general tidy up of code
Picmon 0:20b4b057fa7f 174 18/09/19_A Working on calibration graph, good progress made here
Picmon 0:20b4b057fa7f 175 19/09/19_A struct settingsNVM has been updated to include calibration variables
Picmon 0:20b4b057fa7f 176 20/09/19_A Hysteresis add to 4-20 pump motor start threshold
Picmon 0:20b4b057fa7f 177 20/09/19_A Re-declaration of constants to give accurate rage #define ADC_MIN_V 0.013, #define ADC_MAX_V 2.9012//V
Picmon 0:20b4b057fa7f 178 23/09/19_B full NVM RAM loaded into NVM structure in READ_NVM
Picmon 0:20b4b057fa7f 179 23/09/19_B USB ISOLATOR TO BE USED FROM NOW ON TO STOP USB GND EFFECTING THE UNIT
Picmon 0:20b4b057fa7f 180 23/09/19_B Calibration is working, checking all aspects of calibration
Picmon 0:20b4b057fa7f 181 24/09/19_A anaOut_mA(mapF(ana_mA, I_3MA, I_20MA, nvm.mA_low, nvm.mA_high)); APPEARS TO BE WORKING NOW, TESTING REQUIRED
Picmon 0:20b4b057fa7f 182 25/09/19_B Calibarion, analogue output, displayed flow units all appear to be match well to QDOS
Picmon 0:20b4b057fa7f 183 26/09/19_B Works like QDOS for calibration now and analogue in/out, issue when leaving calibration normal running does not resume correctly
Picmon 0:20b4b057fa7f 184 27/09/19_A Calibration graph has refresh problem when adjusting flow rate %
Picmon 0:20b4b057fa7f 185 30/09/19_A I hope the issue above in now fixed, this was done by erasing the RED line before going to the next calibration screen
Picmon 0:20b4b057fa7f 186 30/09/19_B Start looking at speed feedback from tacho output on motor controller
Picmon 0:20b4b057fa7f 187 30/09/19_B Tacko from fGout processed by isr test working
Picmon 0:20b4b057fa7f 188 01/10/19_A General code tidy, removal of unused variables, add ISR module
Picmon 0:20b4b057fa7f 189 03/10/19_A Implement motor stall detection
Picmon 0:20b4b057fa7f 190 07/10/19_A Motor development put on hold as present motor controller cannot produce high torque at low speed as QDOS 20 does
Picmon 0:20b4b057fa7f 191 07/10/19_A Remote Start / Stop implemented
Picmon 0:20b4b057fa7f 192 07/10/19_A Remote Fluid Recover, reverses motor in analogue mode, will check more when we receive new QDOS with this feature
Picmon 0:20b4b057fa7f 193 07/10/19_A Open Collector outputs now function, they have to be allocated to status and alarm software functions yet
Picmon 0:20b4b057fa7f 194 10/10/19_A Remote run/stop operational, code tidy now required
Picmon 0:20b4b057fa7f 195 10/10/19_A Need to store and retrieve the speed setting
Picmon 0:20b4b057fa7f 196 11/10/19_A configure Neptune motor for shaft speed range of 100 - 2500 RPM
Picmon 0:20b4b057fa7f 197 14/10/19_A Motor controller is on hold for now, I will concentrate of delivering the features of QDOS 20
Picmon 0:20b4b057fa7f 198 14/10/19_A Implement Auto-restart feature
Picmon 0:20b4b057fa7f 199 14/10/19_A Flow units in manual mode saved and retreived from NVM after power loss
Picmon 0:20b4b057fa7f 200 16/10/19_B State machine does not work as intended causing problem for auto-restart and flow unit change over, re-do state machine
Picmon 0:20b4b057fa7f 201 18/10/19_A flow rate can be switched from one to another matching the percentage as QDOS does
Picmon 0:20b4b057fa7f 202 21/10/19_A Auto-Restart, remote inputs and O/C outputs working, read for checking with QDOS 30
Picmon 0:20b4b057fa7f 203 22/10/19_A Motor rotation is CCW but QDOS arrow is CW, Neptune will be set the same
Picmon 0:20b4b057fa7f 204 22/10/19_A FastPWM library added, leave PWM prescaler at 1 so that that the smallest speed inc/dec results in a measureable PWM change,
Picmon 0:20b4b057fa7f 205 resolution is 12 bit (4096), measured bit width is ~20ns/bit, pwm period is 1/10000 = 100us, so 100us / 20ns = 5000
Picmon 0:20b4b057fa7f 206 22/10/19_B Implement MAX prime function
Picmon 0:20b4b057fa7f 207 23/10/19_A To allow the touch button to be active at the stop screen as with QDOS the nexKeyScan() need to be call in the main loop
Picmon 0:20b4b057fa7f 208 23/10/19_A New motor ramp time added to motor function, need to connect up nBrake to motor controller
Picmon 0:20b4b057fa7f 209 24/10/19_A New readNVM() created to hide complexity and improve readability, working on motor ramp time parameter
Picmon 0:20b4b057fa7f 210 25/10/19_A Nextion display has failed, as extra protection tristate TX & RX line until Nextion has powered up
Picmon 0:20b4b057fa7f 211 30/10/19_A New Nextion display fitted, 1K resistor mod added to RX line
Picmon 0:20b4b057fa7f 212 30/10/19_B QDOS 30 flow units added to replace QDOS 20 flow units
Picmon 0:20b4b057fa7f 213 31/10/19_A Removed ramNVM so epprom data is transferred to and from direct to NVM data structure
Picmon 0:20b4b057fa7f 214 01/11/19_A NVM memory working good and more easy to understand and use now
Picmon 0:20b4b057fa7f 215 01/11/19_B PWM is now incremented / decremented at 0.1 resolution, so a change of 0.1% alter the PWM
Picmon 0:20b4b057fa7f 216 01/11/19_B Cannot find any problems with this version, best version so far
Picmon 0:20b4b057fa7f 217 05/11/19_A Calibration Menu cannot be accessed after initial calibration.
Picmon 0:20b4b057fa7f 218 11/11/19_A Work required for remote control inputs
Picmon 0:20b4b057fa7f 219 11/11/19_A Adding output1&2 settings
Picmon 0:20b4b057fa7f 220 12/11/19_A Discovery that SPI frequency was set to 1000 Hz, I forgot about this
Picmon 0:20b4b057fa7f 221 18/11/19_A Various icon indicators added to page 1 top line
Picmon 0:20b4b057fa7f 222 20/11/19_A Implementation of control settings
Picmon 0:20b4b057fa7f 223 21/11/19_A Provide a version of software to use USB USART1 (PA9 & PA10) on product ONLY as product will not have ST-LINK
Picmon 0:20b4b057fa7f 224 02/12/19_A Method of programming via USB has been designed in hardware, trap software in while loop and it will re-boot via watchdog timer with boot0 connected to vdd
Picmon 0:20b4b057fa7f 225 03/12/19_A #ifdef BOOTLOADER setup for production bootloader without USB/ST-LINK
Picmon 0:20b4b057fa7f 226 05/12/19_A Microcontroller pin assignment checked with Kevin Moon's work, all ok.
Picmon 0:20b4b057fa7f 227 06/12/19_A Continue with control settings menu, EEPROM variables for control settings
Picmon 0:20b4b057fa7f 228 11/12/19_A Output 1 NVM working
Picmon 0:20b4b057fa7f 229 02/01/20_A Output 1 & 2 appears to be working, NVM setting is being saved and retrieved correctly for displayed string names
Picmon 0:20b4b057fa7f 230 06/01/20_A Trying to fix return from analogue cal routine, the nvm.flowUnitVal is being set to minium value
Picmon 0:20b4b057fa7f 231 06/01/20_B The above is fixed, reset() was clearing nvm.flowUnitVal, this has been commeted out for now.
Picmon 0:20b4b057fa7f 232 08/01/20_A Code refactoring
Picmon 0:20b4b057fa7f 233 13/01/20_A Control Setting output 1&2, tick boxes for High and Low logic under development
Picmon 0:20b4b057fa7f 234 13/01/20_A High & Low output logic setting now stored in nvm, develop function for remote inputs and O/C outputs
Picmon 0:20b4b057fa7f 235 16/01/20_A Start/Stop input Pump Stop logic NVM tick boxes working.
Picmon 0:20b4b057fa7f 236 17/02/20_A 4-20mA Scale NVM tick boxes working.
Picmon 0:20b4b057fa7f 237 03/02/20_A Remote pump Ster/Stop working same as QDOS
Picmon 0:20b4b057fa7f 238 04/02/20_A Improve Nextion driver so that only updated data is sent to Nextion, if the data is the same nothing is done.
Picmon 0:20b4b057fa7f 239 04/02/20_B Demonstrated code working for alarm outputs, continue this tomorrow
Picmon 0:20b4b057fa7f 240 10/02/20_A Rotation arrow issues now resolved
Picmon 0:20b4b057fa7f 241 12/02/20_A Control setting, inputs, o/c outputs, mA output scale all working
Picmon 0:20b4b057fa7f 242 13/02/20_A DEBUG_LCD added to improve loop time further by being able to see if any LCD functions are being called continuoisly.
Picmon 0:20b4b057fa7f 243 24/02/20_A Problem with with inc/dec controls, this is related to the speedLimit variable introduced
Picmon 0:20b4b057fa7f 244 24/02/20_A SpeedLimit now operates from nvm.speedLimit, speed limit menu need to be implemented
Picmon 0:20b4b057fa7f 245 28/02/20_A Improvements made to pause/stop symbol fucntion and output1 & 2 logic, test concur operation same as QDOS
Picmon 0:20b4b057fa7f 246 28/02/20_B Staring investigatory work for ED motor controller controler support, setup an serial interface for rs232 motor control
Picmon 0:20b4b057fa7f 247 28/02/20_C Communication established on usart6 for motor control
Picmon 0:20b4b057fa7f 248 28/02/20_C Speeded up tremendously the serial communiucations on all at usarts, they all work at 921600 Baud, Nextion seem not to
Picmon 0:20b4b057fa7f 249 have a problem with this unimate fast baud, if I start to see problems I will slow the baud down.
Picmon 0:20b4b057fa7f 250
Picmon 0:20b4b057fa7f 251 */
Picmon 0:20b4b057fa7f 252
Picmon 0:20b4b057fa7f 253 /*
Picmon 0:20b4b057fa7f 254
Picmon 0:20b4b057fa7f 255 ***** TARGET CAN BE LOST FROM USB FOR NO REASON, ONLY WAY TO GET IT BACK IS TO RE-BOOT PC AND SELECT ACTIVE PROGRAM AGAIN *****
Picmon 0:20b4b057fa7f 256
Picmon 0:20b4b057fa7f 257 Nextion text for mA readings will have to be set txt_maxl = 4 to limit precision
Picmon 0:20b4b057fa7f 258
Picmon 0:20b4b057fa7f 259 Analogue read is ~15us
Picmon 0:20b4b057fa7f 260
Picmon 0:20b4b057fa7f 261 Find relationship between RPM and PWM, make sure we have 4000 RPM, measure with tachometer
Picmon 0:20b4b057fa7f 262 Ramping need to be implemented so there is no abrupt stop and start at high speed
Picmon 0:20b4b057fa7f 263 Hide away complexity in functions
Picmon 0:20b4b057fa7f 264 Review all function, trim out useless functions
Picmon 0:20b4b057fa7f 265
Picmon 0:20b4b057fa7f 266 Measured 4426 RPM unloaded
Picmon 0:20b4b057fa7f 267
Picmon 0:20b4b057fa7f 268 Neptune requirement is 120 Litres/Hour = 2000ml/min
Picmon 0:20b4b057fa7f 269
Picmon 0:20b4b057fa7f 270 Meeting today 16/8/19
Picmon 0:20b4b057fa7f 271
Picmon 0:20b4b057fa7f 272 US Flow Units, DB
Picmon 0:20b4b057fa7f 273 Screen RED for alarm
Picmon 0:20b4b057fa7f 274 Screen saver
Picmon 0:20b4b057fa7f 275 Cooling fan as standard
Picmon 0:20b4b057fa7f 276 Digital Dosing Pump
Picmon 0:20b4b057fa7f 277 Heads Left & Right fitment, rotation direction fixed based on which head is selected
Picmon 0:20b4b057fa7f 278 Sep 2020 exhibition
Picmon 0:20b4b057fa7f 279
Picmon 0:20b4b057fa7f 280 QDOS 20 & 30 are the initial target
Picmon 0:20b4b057fa7f 281
Picmon 0:20b4b057fa7f 282 PA_4 and PA_5 are DAC1 & DAC2 outputs, these are presently used for SPI, I am going to have to move the SPI in order to use the DACs
Picmon 0:20b4b057fa7f 283
Picmon 0:20b4b057fa7f 284 */
Picmon 0:20b4b057fa7f 285
Picmon 0:20b4b057fa7f 286 //PERIPHERAL PINS
Picmon 0:20b4b057fa7f 287 //https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/TARGET_STM32F7/TARGET_STM32F746xG/TARGET_NUCLEO_F746ZG/PeripheralPins.capabilities
Picmon 0:20b4b057fa7f 288
Picmon 0:20b4b057fa7f 289 /*
Picmon 0:20b4b057fa7f 290 25LC010AT
Picmon 0:20b4b057fa7f 291
Picmon 0:20b4b057fa7f 292 1K SPI EEPROM (128 x 8)
Picmon 0:20b4b057fa7f 293
Picmon 0:20b4b057fa7f 294 EEPROM 3V3 ok
Picmon 0:20b4b057fa7f 295 ---------
Picmon 0:20b4b057fa7f 296 SCK |1 6| VDD
Picmon 0:20b4b057fa7f 297 VSS |2 5| /CS
Picmon 0:20b4b057fa7f 298 SI |3 4| SO
Picmon 0:20b4b057fa7f 299 ---------
Picmon 0:20b4b057fa7f 300
Picmon 0:20b4b057fa7f 301 PA_7 MOSI// Connected to RMII_CRS_DV [LAN8742A-CZ-TR_CRS_DV]
Picmon 0:20b4b057fa7f 302 PA_6 MISO
Picmon 0:20b4b057fa7f 303 PA_5 SCLK
Picmon 0:20b4b057fa7f 304 PA_4 SSEL
Picmon 0:20b4b057fa7f 305 */
Picmon 0:20b4b057fa7f 306
Picmon 0:20b4b057fa7f 307 //Objects
Picmon 0:20b4b057fa7f 308
Picmon 0:20b4b057fa7f 309
Picmon 0:20b4b057fa7f 310 /*USART
Picmon 0:20b4b057fa7f 311
Picmon 0:20b4b057fa7f 312 USART1 = VERDERBUS
Picmon 0:20b4b057fa7f 313 USART2 = NEXTION DISPLAY
Picmon 0:20b4b057fa7f 314 USART3 = BOOTLOADER
Picmon 0:20b4b057fa7f 315 USART6 = MOTOR CONTROL
Picmon 0:20b4b057fa7f 316
Picmon 0:20b4b057fa7f 317
Picmon 0:20b4b057fa7f 318 */
Picmon 0:20b4b057fa7f 319
Picmon 0:20b4b057fa7f 320 #ifdef BOOTLOADER//USB TO UART BOOTLOADER
Picmon 0:20b4b057fa7f 321 /*
Picmon 0:20b4b057fa7f 322 Physical connections PB10, PB11 USART3 required for Bootloader
Picmon 0:20b4b057fa7f 323 RXPC <- PB10 OUTPUT TXN
Picmon 0:20b4b057fa7f 324 TXPC -> PB11 INPUT RXN
Picmon 0:20b4b057fa7f 325 These become Virtual Com Port PD_8, PD_9
Picmon 0:20b4b057fa7f 326 */
Picmon 0:20b4b057fa7f 327 Serial pc(SERIAL_TX, SERIAL_RX);//Bootloader port
Picmon 0:20b4b057fa7f 328 #else//MBED VIA ST-LINK
Picmon 0:20b4b057fa7f 329 /*
Picmon 0:20b4b057fa7f 330 Physical connections PD_8, PD_9 {USART3} debug port
Picmon 0:20b4b057fa7f 331 RXPC <- PD_8 OUTPUT TXN
Picmon 0:20b4b057fa7f 332 TXPC -> PD_9 INPUT RXN
Picmon 0:20b4b057fa7f 333 */
Picmon 0:20b4b057fa7f 334 Serial pc(USBTX, USBRX);//Virtual Com Port PD_8, PD_9 Debug port required for MBED
Picmon 0:20b4b057fa7f 335 #endif
Picmon 0:20b4b057fa7f 336
Picmon 0:20b4b057fa7f 337 NextionLCD lcd(USART2_TX, USART2_RX);//Tx, Rx, Nextion Port {USART2}
Picmon 0:20b4b057fa7f 338
Picmon 0:20b4b057fa7f 339 Serial usart6(USART6_TX, USART6_RX);//Tx, Rx Motor Controller {USART6}
Picmon 0:20b4b057fa7f 340
Picmon 0:20b4b057fa7f 341 SPI spi(MOSI,MISO,SCLK);//MOSI, MISO, SCLK, SSEL
Picmon 0:20b4b057fa7f 342 Ser25LCxxx eeprom(&spi,SSEL,BYTE_SIZE,PAGE_SIZE);
Picmon 0:20b4b057fa7f 343 Watchdog wd;
Picmon 0:20b4b057fa7f 344
Picmon 0:20b4b057fa7f 345 Timer tPop;//touch button release timer
Picmon 0:20b4b057fa7f 346 Timer tPush;//touch button press timer
Picmon 0:20b4b057fa7f 347 Timer tRst;//reset timer
Picmon 0:20b4b057fa7f 348 Timer tSpeed;//numerical update rate of flow units
Picmon 0:20b4b057fa7f 349
Picmon 0:20b4b057fa7f 350 volatile float ml = 0;
Picmon 0:20b4b057fa7f 351 bool maxBtnPress = false;//Prime buttOn (MAX)
Picmon 0:20b4b057fa7f 352 uint8_t storedTask = false;//Remember the previous state machine state
Picmon 0:20b4b057fa7f 353 bool rmtFlag = false;//Remote input flag
Picmon 0:20b4b057fa7f 354 char *readbuf;
Picmon 0:20b4b057fa7f 355 bool maxFlag = true;
Picmon 0:20b4b057fa7f 356 bool arrowFlag = false;
Picmon 0:20b4b057fa7f 357
Picmon 0:20b4b057fa7f 358 ///////////////////////////////////////////////////////////////////////////////
Picmon 0:20b4b057fa7f 359 //VARIABLES
Picmon 0:20b4b057fa7f 360 ///////////////////////////////////////////////////////////////////////////////
Picmon 0:20b4b057fa7f 361 float minScale = 0;
Picmon 0:20b4b057fa7f 362 float maxScale = 0;//Max Scale variable to stop max RPM, max ml/min and max %
Picmon 0:20b4b057fa7f 363
Picmon 0:20b4b057fa7f 364 ///////////////////////////////////////////////////////////////////////////////
Picmon 0:20b4b057fa7f 365 // ARRAYS
Picmon 0:20b4b057fa7f 366 ///////////////////////////////////////////////////////////////////////////////
Picmon 0:20b4b057fa7f 367
Picmon 0:20b4b057fa7f 368 ///////////////////////////////////////////////////////////////////////////////
Picmon 0:20b4b057fa7f 369 // CONSTANTS
Picmon 0:20b4b057fa7f 370 ///////////////////////////////////////////////////////////////////////////////
Picmon 0:20b4b057fa7f 371
Picmon 0:20b4b057fa7f 372 ///////////////////////////////////////////////////////////////////////////////
Picmon 0:20b4b057fa7f 373 // STRUCTURE DEFINITIONS
Picmon 0:20b4b057fa7f 374 ///////////////////////////////////////////////////////////////////////////////
Picmon 0:20b4b057fa7f 375 struct settingsNVM nvm;
Picmon 0:20b4b057fa7f 376
Picmon 0:20b4b057fa7f 377 ///////////////////////////////////////////////////////////////////////////////
Picmon 0:20b4b057fa7f 378 // DEBUG
Picmon 0:20b4b057fa7f 379 ///////////////////////////////////////////////////////////////////////////////
Picmon 0:20b4b057fa7f 380
Picmon 0:20b4b057fa7f 381 ///////////////////////////////////////////////////////////////////////////////
Picmon 0:20b4b057fa7f 382 // MAIN
Picmon 0:20b4b057fa7f 383 ///////////////////////////////////////////////////////////////////////////////
Picmon 0:20b4b057fa7f 384 int main(){
Picmon 0:20b4b057fa7f 385
Picmon 0:20b4b057fa7f 386 uint8_t task;
Picmon 0:20b4b057fa7f 387
Picmon 0:20b4b057fa7f 388 task = INITIALISE;
Picmon 0:20b4b057fa7f 389
Picmon 0:20b4b057fa7f 390 while(1){
Picmon 0:20b4b057fa7f 391
Picmon 0:20b4b057fa7f 392 switch(task){
Picmon 0:20b4b057fa7f 393
Picmon 0:20b4b057fa7f 394 case INITIALISE:
Picmon 0:20b4b057fa7f 395 sysInit();
Picmon 0:20b4b057fa7f 396 task = STOP_SCRN;
Picmon 0:20b4b057fa7f 397 //task = DIAGS;
Picmon 0:20b4b057fa7f 398 dbgStates(task);
Picmon 0:20b4b057fa7f 399 break;
Picmon 0:20b4b057fa7f 400
Picmon 0:20b4b057fa7f 401 case STOP_SCRN:
Picmon 0:20b4b057fa7f 402 ml=ZERO;
Picmon 0:20b4b057fa7f 403 lcd.nexChgPage(PAGE_1_HOME);
Picmon 0:20b4b057fa7f 404 /*
Picmon 0:20b4b057fa7f 405 lcd.nexDispSymbol("key", ON);
Picmon 0:20b4b057fa7f 406 lcd.nexDispSymbol("leak", ON);
Picmon 0:20b4b057fa7f 407 lcd.nexDispSymbol("update", ON);
Picmon 0:20b4b057fa7f 408 lcd.nexDispSymbol("error", ON);
Picmon 0:20b4b057fa7f 409 lcd.nexDispSymbol("wifi", ON);
Picmon 0:20b4b057fa7f 410 lcd.nexDispSymbol("locked", ON);
Picmon 0:20b4b057fa7f 411 lcd.nexDispSymbol("unlocked", ON);
Picmon 0:20b4b057fa7f 412 lcd.nexDispSymbol("temp", ON);
Picmon 0:20b4b057fa7f 413 lcd.nexDispSymbol("stop", ON);
Picmon 0:20b4b057fa7f 414 lcd.nexDispSymbol("pause", ON);
Picmon 0:20b4b057fa7f 415 */
Picmon 0:20b4b057fa7f 416 lcd.nexDispSymbol("stop", ON);
Picmon 0:20b4b057fa7f 417 lcd.nexDispSymbol("pause", OFF);
Picmon 0:20b4b057fa7f 418 lcd.nexDispSymbol("unlocked", ON);
Picmon 0:20b4b057fa7f 419 decodeByteNVM(nvm.flowUnits, &precision);
Picmon 0:20b4b057fa7f 420
Picmon 0:20b4b057fa7f 421 lcd.nexSendTxt("p1left","VDOS");//page 1 middle text box
Picmon 0:20b4b057fa7f 422 lcd.nexSetFontCol("p1mid",RED);
Picmon 0:20b4b057fa7f 423 lcd.nexSendTxt("p1mid","Manual Mode");//page 1 middle text box
Picmon 0:20b4b057fa7f 424
Picmon 0:20b4b057fa7f 425 lcd.nexSendFloat("meter", nvm.flowUnitVal, precision);//display the flow units
Picmon 0:20b4b057fa7f 426 stopBtn(BTN_BYPASS_TRUE);//button disasbled LEDs only
Picmon 0:20b4b057fa7f 427 motor(ZERO, CCW, BRAKE_OFF, MOTOR_DISABLE, 1);
Picmon 0:20b4b057fa7f 428
Picmon 0:20b4b057fa7f 429 storedTask = STOP_SCRN;//this state
Picmon 0:20b4b057fa7f 430 task = START;
Picmon 0:20b4b057fa7f 431 dbgStates(task);
Picmon 0:20b4b057fa7f 432 break;
Picmon 0:20b4b057fa7f 433
Picmon 0:20b4b057fa7f 434 case START:
Picmon 0:20b4b057fa7f 435 anaOut_mA(I_3MA);
Picmon 0:20b4b057fa7f 436 task = startUpMode(nvm.runMode);
Picmon 0:20b4b057fa7f 437 storedTask = START;
Picmon 0:20b4b057fa7f 438
Picmon 0:20b4b057fa7f 439 dbgStates(task);
Picmon 0:20b4b057fa7f 440 break;
Picmon 0:20b4b057fa7f 441
Picmon 0:20b4b057fa7f 442 case MANUAL_SET: //Setup for Manual running mode
Picmon 0:20b4b057fa7f 443 lcd.nexChgPage(PAGE_1_HOME);
Picmon 0:20b4b057fa7f 444 lcd.nexDispSymbol("unlocked", ON);
Picmon 0:20b4b057fa7f 445 //lcd.nexSetFontCol("p1mid",BLACK);
Picmon 0:20b4b057fa7f 446 //lcd.nexSendTxt("p1mid","Manual Mode");//page 1 middle text box
Picmon 0:20b4b057fa7f 447
Picmon 0:20b4b057fa7f 448 lcd.nexSetCrop("inc",PAGE_1_HOME);//restore inc button image required for manual mode
Picmon 0:20b4b057fa7f 449 lcd.nexSetCrop("dec",PAGE_1_HOME);//restore dec button image required for manual mode
Picmon 0:20b4b057fa7f 450 decodeByteNVM(nvm.flowUnits, &precision);//display the flow unit symbol
Picmon 0:20b4b057fa7f 451 lcd.nexSendFloat("meter", nvm.flowUnitVal, precision);//display the flow unit value
Picmon 0:20b4b057fa7f 452
Picmon 0:20b4b057fa7f 453 storedTask = MANUAL_SET;//this state
Picmon 0:20b4b057fa7f 454 task = RUNNING;//next state
Picmon 0:20b4b057fa7f 455 dbgStates(task);
Picmon 0:20b4b057fa7f 456 break;
Picmon 0:20b4b057fa7f 457
Picmon 0:20b4b057fa7f 458 case ANALOGUE_SET: //Setup for Analogue running mode
Picmon 0:20b4b057fa7f 459 lcd.nexChgPage(PAGE_1_HOME);
Picmon 0:20b4b057fa7f 460 lcd.nexDispSymbol("unlocked", ON);
Picmon 0:20b4b057fa7f 461 lcd.nexSetFontCol("p1mid",RED);
Picmon 0:20b4b057fa7f 462
Picmon 0:20b4b057fa7f 463 lcd.nexSendTxt("p1mid","4-20mA Input Mode");//page 1 middle text box
Picmon 0:20b4b057fa7f 464 lcd.nexSetCrop("inc",CLEAR_INC_DEC);//remove inc button image not required for analogue mode
Picmon 0:20b4b057fa7f 465 lcd.nexSetCrop("dec",CLEAR_INC_DEC);//remove dec button image not required for analogue mode
Picmon 0:20b4b057fa7f 466 decodeByteNVM(nvm.flowUnits, &precision);
Picmon 0:20b4b057fa7f 467
Picmon 0:20b4b057fa7f 468 storedTask = ANALOGUE_SET;
Picmon 0:20b4b057fa7f 469 task = RUNNING;
Picmon 0:20b4b057fa7f 470 dbgStates(task);
Picmon 0:20b4b057fa7f 471 break;
Picmon 0:20b4b057fa7f 472
Picmon 0:20b4b057fa7f 473 case RUNNING:
Picmon 0:20b4b057fa7f 474 switch(runModeNVM(nvm.runMode)){
Picmon 0:20b4b057fa7f 475 case MANUAL_SET: task = manual(); break;
Picmon 0:20b4b057fa7f 476 case ANALOGUE_SET: task = anaIn(); break;
Picmon 0:20b4b057fa7f 477 //case FLOW_CAL: task = flowCalMode(); break;
Picmon 0:20b4b057fa7f 478 //case CONTACT_SET: task = contactMode(); break;
Picmon 0:20b4b057fa7f 479 //case FLUIDREC_SET: task = fluidRecMode(); break;
Picmon 0:20b4b057fa7f 480
Picmon 0:20b4b057fa7f 481 default:;
Picmon 0:20b4b057fa7f 482 }
Picmon 0:20b4b057fa7f 483
Picmon 0:20b4b057fa7f 484 task = STOP;
Picmon 0:20b4b057fa7f 485 dbgStates(task);
Picmon 0:20b4b057fa7f 486 break;
Picmon 0:20b4b057fa7f 487
Picmon 0:20b4b057fa7f 488 case STOP:
Picmon 0:20b4b057fa7f 489 if(((rmtRunStop == LO)&&(rmtFlag == true))||stopBtn(BTN_BYPASS_FALSE)){
Picmon 0:20b4b057fa7f 490
Picmon 0:20b4b057fa7f 491 lcd.nexDispSymbol("stop", OFF);
Picmon 0:20b4b057fa7f 492
Picmon 0:20b4b057fa7f 493 task = STOP_SCRN;
Picmon 0:20b4b057fa7f 494 }
Picmon 0:20b4b057fa7f 495 else
Picmon 0:20b4b057fa7f 496 task = RUNNING;
Picmon 0:20b4b057fa7f 497
Picmon 0:20b4b057fa7f 498 dbgStates(task);
Picmon 0:20b4b057fa7f 499 break;
Picmon 0:20b4b057fa7f 500
Picmon 0:20b4b057fa7f 501 case ANA_CAL:
Picmon 0:20b4b057fa7f 502 task = anaCal();
Picmon 0:20b4b057fa7f 503 dbgStates(task);
Picmon 0:20b4b057fa7f 504 break;
Picmon 0:20b4b057fa7f 505
Picmon 0:20b4b057fa7f 506 case STALL: while(1);
Picmon 0:20b4b057fa7f 507
Picmon 0:20b4b057fa7f 508 break;
Picmon 0:20b4b057fa7f 509
Picmon 0:20b4b057fa7f 510 case FAULT:
Picmon 0:20b4b057fa7f 511 break;
Picmon 0:20b4b057fa7f 512
Picmon 0:20b4b057fa7f 513 case DIAGS:
Picmon 0:20b4b057fa7f 514
Picmon 0:20b4b057fa7f 515 break;
Picmon 0:20b4b057fa7f 516
Picmon 0:20b4b057fa7f 517 default: pc.printf("Error Main : Last task = %d",task);
Picmon 0:20b4b057fa7f 518
Picmon 0:20b4b057fa7f 519 //////////////////////////////////////while(1)
Picmon 0:20b4b057fa7f 520 //////////////////////////////////////////////////////wd.Service();//Kick the dog
Picmon 0:20b4b057fa7f 521 }
Picmon 0:20b4b057fa7f 522
Picmon 0:20b4b057fa7f 523 #ifdef LOOP_TIME
Picmon 0:20b4b057fa7f 524 loopTimeMeasure();
Picmon 0:20b4b057fa7f 525 #endif
Picmon 0:20b4b057fa7f 526
Picmon 0:20b4b057fa7f 527 #ifndef WDT_TEST
Picmon 0:20b4b057fa7f 528 if(!startBtn(OFF))//holding the start button will re-boot the system
Picmon 0:20b4b057fa7f 529 wd.Service();//Kick the dog
Picmon 0:20b4b057fa7f 530 #endif
Picmon 0:20b4b057fa7f 531
Picmon 0:20b4b057fa7f 532 outPuts(leakIn, &nvm);
Picmon 0:20b4b057fa7f 533 task = nexKeyScan(task, storedTask);//read nextion touch keys
Picmon 0:20b4b057fa7f 534 }
Picmon 0:20b4b057fa7f 535 }