The Trunk: EToys-eem.410.mcz

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

The Trunk: EToys-eem.410.mcz

Eliot Miranda uploaded a new version of EToys to project The Trunk:

==================== Summary ====================

Name: EToys-eem.410
Author: eem
Time: 15 October 2020, 7:35:58.395815 pm
UUID: eb60faf5-1f7d-459c-b9f9-ee9a691da3a6
Ancestors: EToys-mt.409

Add the cameraUID: primitive, and have the interruptDrivenVideoTest: incluse the camera name in its result.

=============== Diff against EToys-mt.409 ===============

Item was added:
+ ----- Method: CameraInterface class>>cameraUID: (in category 'camera ops') -----
+ cameraUID: cameraNum
+ "Answer the unique ID of the given camera. Answer nil if there is no camera with the given number."
+ <primitive: 'primCameraUID' module: 'CameraPlugin'>
+ ^ nil
+ "CameraInterface cameraUID: 1"!

Item was changed:
  ----- Method: CameraInterface class>>interruptDrivenVideoTest: (in category 'test') -----
  interruptDrivenVideoTest: camNum
  "A quick test of video input. Displays video on the screen until the mouse is pressed.
  Answer nil if the interrupt-driven interface is unavailable."
  "self interruptDrivenVideoTest: 1"
  "self interruptDrivenVideoTest: 2"
  "[self interruptDrivenVideoTest: 2] fork.
   self interruptDrivenVideoTest: 1"
  | semaphore height |
  height := 16.
  1 to: camNum - 1 do:
  [:camIndex| "N.B. the of an unopened camera is 0@0"
  height := height + (CameraInterface frameExtent: camIndex) y + 16].
  (CameraInterface cameraIsOpen: camNum) ifFalse:
  [(CameraInterface openCamera: camNum width: 352 height: 288) ifNil:
  [self inform: 'no camera'.
  semaphore := Semaphore new.
  [CameraInterface camera: camNum setSemaphore: (Smalltalk registerExternalObject: semaphore)]
  on: Error
  do: [:err|
  Smalltalk unregisterExternalObject: semaphore.
  self inform: 'interrupt-driven camera interface unavailable: ', err messageText.
  [| f n startTime frameCount msecs fps |
  [semaphore wait.
  "N.B. the frame extent may not be known until the delivery of the first frame.
+  So we have to delay initialization."
-  Si we have to delay initialization."
   startTime ifNil:
  [(self frameExtent: camNum) x = 0 ifTrue: [self inform: 'no camera'. ^nil].
  f := Form extent: (CameraInterface frameExtent: camNum) depth: 32.
  frameCount := 0.
  startTime := Time millisecondClockValue].
   Sensor anyButtonPressed] whileFalse:
  [n := CameraInterface getFrameForCamera: camNum into: f bits.
  n > 0 ifTrue:
  [frameCount := frameCount + 1.
  f displayAt: 16 @ height]].
  msecs := Time millisecondClockValue - startTime.
  fps := (frameCount * 1000) // msecs.
+ ^(CameraInterface cameraName: camNum), ': ', frameCount printString, ' frames at ', fps printString, ' frames/sec']
- ^frameCount printString, ' frames at ', fps printString, ' frames/sec']
  [CameraInterface closeCamera: camNum.
  Smalltalk unregisterExternalObject: semaphore.
  Sensor waitNoButton]!