How to use move_relative method in keyboard

Best Python code snippet using keyboard

FOV change.py

Source:FOV change.py Github

copy

Full Screen

...116 LEDport.write(("SPIRALKEY 0 0xFFFFFF\r").encode("ascii"))117 camera.set_exposure_time(CYTOLOGY_20X_SPIRALKEY0_EXPOSURE)118 119 # z-stack with FOV change120 z_axis.move_relative(-0.005, Units.LENGTH_MILLIMETRES)121 time.sleep(0.5)122 123 for i in range(11):124 time.sleep(0.5)125 camera.start_imaging()126 time.sleep(0.5)127 camera.capture_and_save_tiff(os.path.join(path, str(total_count) + "_" + str(i) + ".tiff"))128 camera.stop_imaging()129 z_axis.move_relative(0.001, Units.LENGTH_MILLIMETRES)130 time.sleep(0.5)131 132 133 LEDport.write(("ALL OFF\r").encode("ascii"))134 time.sleep(1)135 136 #set it back to bayer137 #camera.set_pixel_format("BayerRG12")138 print("Capturing ended")139 140 # capture of the number (total_count)th block of view has already ended141 total_count = total_count + 1 # total index increase by 1, which is the index of the next block142 if reverse == False: # if the moving direction of x_axis is to the positive143 if x_loop_count * x_step < x_detect:144 x_loop_count = x_loop_count + 1145 x_axis.move_relative(x_step, Units.LENGTH_MILLIMETRES)146 else:147 reverse = True148 if y_count * y_step < y_detect:149 print("y_count = ", y_count, " finished")150 y_count = y_count + 1151 y_axis.move_relative(y_step, Units.LENGTH_MILLIMETRES)152 else:153 print("Entire scan finished.")154 break155 else: # if the x_axis moving direction is backwards156 if x_loop_count > 1:157 x_axis.move_relative(-x_step, Units.LENGTH_MILLIMETRES)158 x_loop_count = x_loop_count - 1159 else:160 reverse = False161 if y_count * y_step < y_detect:162 print("y_count = ", y_count, " finished")163 y_count = y_count + 1164 y_axis.move_relative(y_step, Units.LENGTH_MILLIMETRES)165 else:166 print("Entire scan finished.")167 break168 ...

Full Screen

Full Screen

arrowKeys.py

Source:arrowKeys.py Github

copy

Full Screen

...30 done = True31 keys = pygame.key.get_pressed()32 if keys[pygame.K_LEFT]:33 print('+ X | left')34 robot.move_relative(increment, 0, 0, acc=linAcc)35 relativeMovement[0] += increment36 if keys[pygame.K_RIGHT]:37 print('- X | right')38 relativeMovement[0] -= increment39 robot.move_relative(-increment, 0, 0, acc=linAcc)40 if keys[pygame.K_UP]:41 print('+ Y | up')42 relativeMovement[1] += increment43 robot.move_relative(0, increment, 0, acc=linAcc)44 if keys[pygame.K_DOWN]:45 print('- Y | down')46 relativeMovement[1] -= increment47 robot.move_relative(0, -increment, 0, acc=linAcc)48 if keys[pygame.K_SLASH]:49 print('+ Z | slash')50 relativeMovement[2] += increment51 robot.move_relative(0, 0, increment, acc=linAcc)52 if keys[pygame.K_RSHIFT]:53 print('- Z | shift')54 relativeMovement[2] -= increment55 robot.move_relative(0, 0, -increment, acc=linAcc)56 if keys[pygame.K_w]:57 print('+ RX | w')58 relativeMovement[3] += increment59 robot.move_relativeb(0, 0, 0, increment, 0, 0)60 if keys[pygame.K_s]:61 print('- RX | s')62 relativeMovement[3] -= increment63 robot.move_relativeb(0, 0, 0, -increment, 0, 0)64 if keys[pygame.K_a]:65 print('+ RY | a')66 relativeMovement[4] += increment67 robot.move_relativeb(0, 0, 0, 0, increment, 0)68 if keys[pygame.K_d]:69 print('- RY | d')...

Full Screen

Full Screen

servo_test.py

Source:servo_test.py Github

copy

Full Screen

...42 sv.move(-10)43 assert sv.pos == 044 sv.move(181)45 assert sv.pos == 20046 def test_move_relative(self, mock_pub):47 sv = Servo(1, 'test', (0, 200), start_pos=50)48 # test absolute values49 sv.move_relative(10)50 assert sv.pos == 12051 sv.move_relative(-20)52 assert sv.pos == 8053 # test out of range values54 with pytest.raises(ValueError) as ex:55 sv.move_relative(-50, False)56 assert "out of range" in str(ex.value)57 with pytest.raises(ValueError) as ex:58 sv.move_relative(101, False)59 assert "out of range" in str(ex.value)60 sv.move_relative(-50)61 assert sv.pos == 062 sv.move_relative(101)63 assert sv.pos == 20064 def test_buffer(self, mock_pub):65 sv = Servo(1, 'test', (0, 2000), start_pos=50)66 sv.move(100)67 assert sv.pos == 200068 sv2 = Servo(1, 'test', (0, 2000), start_pos=50, buffer=100)69 sv2.move(100)70 assert sv2.pos == 200071 sv2.move(0)72 assert sv2.pos == 073 sequence = sv.calculate_move(100, 200)74 assert len(sequence) == 175 sequence = sv2.calculate_move(100, 200)76 # [(100, 0.1), (101.5, 0.1), (103.75, 0.1), (107.125, 0.1), (112.1875, 0.1), (119.78125, 0.1), (131.171875, 0.1), (148.2578125, 0.1), (173.88671875, 0.1), (200, 0.1)]...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run keyboard automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful