Hello Bowei,
We use a PIC18F47K40 micro in our mcu.
Sample program loop as follows:
———————————————————————–
main_loop:
‘Gosub calculate sensor values….
‘Calculate percentage of sensor capacity (sensor value/capacity x 100) – the result will be the value to be sent to the progress_bar
Serial_out, baud_rate, [Sensor_1, Sensor_2, etc…] – display the sensor values
Serial_out, baud_rate, [ ST<{“cmd_code”:”set_value”,”type”:”progress_bar”,”widget”:”progress_bar”,”value”:sensor_percentage_result}>ET] – send value to progress_bar
Serial_in, baud_rate, [button_press_arrays] – wait for button press and jump to next code if button press is detected
If button_press = “AA” then jump to subroutine A…
If button_press = “BB” then jump to subroutine B…
Goto main_loop – keep on looping while no button is pressed
———————————————————————–
Above is a simple representation of our program code. What happens is the progress_bar also sends back data/values (which I don’t need) and these values sometimes cause a problem with the serial_in command. For example, a button will be pressed by itself and jump to a subroutine even without pressing it physically. This is because the serial_in command continuously monitors and reads data, including the progress_bar.
I have tried filtering the data being received by the serial_in command, but still some data from the progress_bar comes through and cause problems.
It would really be nice if the progress_bar doesn’t send data/value back when you send the “set_value” command to it.
If I need the data/value, then I should just be able to use “get_value” command.
Thanks.