#version 1; November 2025
#Assumes laser has been connected with it.connect(x,9600)
#Run with: it.script("examples\\TurnLaserOnWithAbort.txt")
#---- Settings
FREQUENCY=194.56 #THz
POWER=13.2 #dBm
#-----

import time
import keyboard

it.resena(mr=1)  #reset the unit
time.sleep(3)    #wait a couple of seconds
it.fcf1(int(FREQUENCY))
it.fcf2(10000*(FREQUENCY-int(FREQUENCY)))

it.pwr(int(POWER*100))

it.resena(sena=1) #enable laser

print("Abort by pressing a")


while it.nop()[1].data()&0xff00 and not(keyboard.is_pressed("a")):  #wait until pending flags drop, with timeout
    time.sleep(1)

print("Completed, either by pressing the key a or by the laser dropping pending flags")