#!/usr/bin/env python
# coding=utf-8

# clear && python3 /home/scripts_python/test_06.py

SCD41_COMMANDS = [ 																							\
					[0x21, 0xb1, 0, 0,  0.000, True ], 		 #  0: start_periodic_measurement				\
					[0xec, 0x05, 0, 3,  0.001, False], 		 #  1: read_measurement							\
					[0x3f, 0x86, 0, 0,  0.500, False],		 #  2: stop_periodic_measurement				\
					[0x24, 0x1d, 1, 0,  0.001, True ],		 #  3: set_temperature_offset					\
					[0x23, 0x18, 0, 1,  0.001, True ],		 #  4: get_temperature_offset					\
					[0x24, 0x27, 1, 0,  0.001, True ],		 #  5: set_sensor_altitude						\
					[0x23, 0x22, 0, 1,  0.001, True ],		 #  6: set_sensor_altitude						\
					[0xe0, 0x00, 1, 0,  0.001, False],		 #  7: set_ambient_pressure						\
					[0x36, 0x2f, 1, 1,  0.400, True ],		 #  8: perform_forced_recalibration				\
					[0x24, 0x16, 1, 0,  0.001, True ],		 #  9: set_automatic_self_calibration_enabled	\    
					[0x23, 0x13, 0, 1,  0.001, True ],		 # 10: get_automatic_self_calibration_enabled	\  
					[0x21, 0xac, 0, 0,  0.000, True ],		 # 11: start_low_power_periodic_measurement		\
					[0xe4, 0xb8, 0, 1,  0.001, False],		 # 12: get_data_ready_status					\
					[0x36, 0x15, 0, 0,  0.800, True ],		 # 13: persist_settings							\
					[0x36, 0x82, 0, 3,  0.001, True ],		 # 14: get_serial_number						\
					[0x36, 0x39, 0, 1, 10.000, True ],		 # 15: perform_self_test						\
					[0x36, 0x32, 0, 0,  1.200, True ],		 # 16: perform_factory_reset					\
					[0x36, 0x46, 0, 0,  0.020, True ],		 # 17: reinit									\
				 ]

print( SCD41_COMMANDS[2][0] )
print( SCD41_COMMANDS[2][1] )
print( SCD41_COMMANDS[2][2] )
print( SCD41_COMMANDS[2][3] )
print( SCD41_COMMANDS[2][4] )
print(" ")


SCD41_COMMANDS = [																\
[0x21, 0xb1, 0, 0,  0.000, True ],#  0: start_periodic_measurement				\
[0xec, 0x05, 0, 9,  0.001, False],#  1: read_measurement						\
[0x3f, 0x86, 0, 0,  0.500, False],#  2: stop_periodic_measurement				\
[0x24, 0x1d, 3, 0,  0.001, True ],#  3: set_temperature_offset					\
[0x23, 0x18, 0, 3,  0.001, True ],#  4: get_temperature_offset					\
[0x24, 0x27, 3, 0,  0.001, True ],#  5: set_sensor_altitude						\
[0x23, 0x22, 0, 3,  0.001, True ],#  6: get_sensor_altitude						\
[0xe0, 0x00, 3, 0,  0.001, False],#  7: set_ambient_pressure					\
[0x36, 0x2f, 3, 3,  0.400, True ],#  8: perform_forced_recalibration			\
[0x24, 0x16, 3, 0,  0.001, True ],#  9: set_automatic_self_calibration_enabled	\
[0x23, 0x13, 0, 3,  0.001, True ],# 10: get_automatic_self_calibration_enabled	\  
[0x21, 0xac, 0, 0,  0.000, True ],# 11: start_low_power_periodic_measurement	\
[0xe4, 0xb8, 0, 3,  0.001, False],# 12: get_data_ready_status					\
[0x36, 0x15, 0, 0,  0.800, True ],# 13: persist_settings						\
[0x36, 0x82, 0, 9,  0.001, True ],# 14: get_serial_number						\
[0x36, 0x39, 0, 3, 10.000, True ],# 15: perform_self_test						\
[0x36, 0x32, 0, 0,  1.200, True ],# 16: perform_factory_reset					\
[0x36, 0x46, 0, 0,  0.020, True ],# 17: reinit									\
]

			globals.RPi.i2c_write_device(handle_i2c_SCD41, [SCD41_COMMANDS[][0], SCD41_COMMANDS[][1]])
			time.sleep(SCD41_COMMANDS[][4])
			
			(count, data) = globals.RPi.i2c_read_device(handle_i2c_SCD41, SCD41_COMMANDS[][3])
			if ( count == SCD41_COMMANDS[][3] ) :
