
import sys
if sys.version_info[0] >=3:
    unicode = str
print(sys.version_info[0])

sys.path.append("D:/projects/IBL_research/OpenSphericalCamera/python/osc/")

from osc.insta360 import insta360
import json
import time
import time

# from osc.insta360 import insta360
# shutterSpeeds = [
#     "1/8000", 
#     "1/4000", 
#     "1/2000", 
#     "1/1000", 
#     "1/500", 
#     "1/250",
#     "1/125",
#     "1/60",
#     "1/30",
#     "1/15",
#     "1/8",
#     "1/4",
#     "1/2"
#     "1",
#     ]

shutterSpeeds = [
    0.000125,
    0.00025,
    0.0005,
    0.001,
    0.002,
    0.004,
    0.008,
    0.01666666,
    0.03333333,
    0.06666666,
    0.125,
    0.25,
    0.5,
    1
]

c = insta360()
'''
    # exposure program values:
    # 0 = Not defined
    # 1 = Manual
    # 4 = Shutter priority
    # 9 = ISO priority

'''
def printAllOptions(): 
    print(c.getAllOptions())

def shootBrackets():
    c.info()
    c.state()

    c.setOption("captureMode", "image")
    c.setOption("iso", 0)
    
    c.setOption("whiteBalance", "datalight")
    c.setOption("exposureProgram", 4) 

    # c.setOption('fileFormat', {u'width': 6080, u'type': u'raw', u'height': 3040})
    # response= c.takePicture()
    # print(response)

    for i in shutterSpeeds:
        print(i)
        print(c.setOption("shutterSpeed", i))
        response = c.takePicture()

def listAllFiles():
    # this is not working
    pprint.pprint(c.listFiles(fileType="image", entryCount=150))

def latestFile():
    #  this is not working 
    pprint.pprint(c.latestFileUri())

def test():
    print(c.info())
    print(c.state())

    # c.setOption("captureMode", "image") 
    # response = c.takePicture()
    # print(response)
    # print('commandId: %s' % response['id'])
    # # print('status: %s' % c.status(response['id']))
    # c.waitForProcessing(response['id'])
shootBrackets()