Code : Tout sélectionner
DO:LOCATE 0,0,0:INPEN X,Y:? X,Y:LOOP
Modérateurs : Papy.G, fneck, Carl
Code : Tout sélectionner
DO:LOCATE 0,0,0:INPEN X,Y:? X,Y:LOOP
Voila voilà, ça marche. Il faut que je degote un soft ou le pointeur est visible sur tout l'écran (bizarreries dans colorpaint sur certains éléments de la barre d'outils) et besoin de trouver de quoi faire des tempos plus précises que la microseconde car a date en X 1us c'est des sauts de plusieurs pixels.La souris est cable et le fw mis à jour. Je teste dans l'après midi...
Je n'ai pas de souris Thomson ni même de TO8 sous la main. J'ai essayé le code suivant dans dcmoto (2019.06.26) :
Code : Tout sélectionner
DO:LOCATE 0,0,0:INPEN X,Y: INMOUSE A,B:? A-X,B-Y:LOOP
Par contre, sauf en BASIC 512, le TO8 ne peut pas utiliser ces deux périphériques en même temps et a besoin de savoir lequel vous voulez utiliser.
Oui. Il faut "Choisir le crayon optique" et là INMOUSE donne la position de la souris, mais INPEN donne alors lui le crayon optique (-1 quand il ne pointe pas dans la zone écran pour info).Est-ce que "physiquement" je peux utiliser sur TO8 un crayon optique et une souris et récupérer (d'une manière ou d'une autre) les positions indépendantes des deux périphériques ?
Code : Tout sélectionner
/************************************************************************************************************
*
* PS2 Mouse to Optical Pen
*
************************************************************************************************************
*
* Feel free to do whatevever you want with this code as long as (usual recommandations) you share your
* modifications, keep a reference whatsoever to this initial work and do not make any commercial use of it
* or the underlying "HW" behind it. That being said, I doubt it will make you richer in any way :)
*
* Cyril Catalanotto (ccapublic@free.fr) - 2021-04-04
*
*************************************************************************************************************
* CREDITS
*
* Thanks to polulu for his simple yet great FastGPIO library (https://github.com/pololu/fastgpio-arduino)
* Thanks to jazzycamel for his PS2 mouse library (https://github.com/jazzycamel/PS2Mouse)
* Thanks to my wife for dealing with this weird time consuming hobby without yelling... too much... :)
* Thanks to the kids for testing :)
*
*************************************************************************************************************
* WIRING
*
* (FAR TOO LONG) INTRODUCTION
* ***************************
*
* This is ongoing - and still piggy - work.
*
* As of today I decided not to modify my TO7/70 at all to make this work. That means :
*
* 1/ I do not grab HSYNC & VSYNC signals from motherboard, but reconstruct them from SCART signals instead.
* 2/ I do not rely on stimulating internal optical pen connector signals.
* 3/ I do not add a connector to the TO7/70 to have those said signals out of the casing.
* 4/ I decided to stimulate the pen phototransistor with a LED instead (work ongoing to stimulate button).
*
* NO, this is definitely NOT the easiest, cleanest, most integrated (add whatever superlative here) way of
* doing it :)
*
* To those who own a machine with connector for external optical pen (like MO5), I did not yet document how
* to interface to such connector, nor did I check whether or not the code would be impacted (after all, at
* the time of writing I've been working on this idea for 2 days only). But I will in the near future if
* some show interest in this work (it's really straightforward with little HW/FW knowledge).
*
* To those who would be willing to fully integrate this work into their machine (have all HW inside casing
* and add a panel PS2 connector), I don't have the time (not the will to be frank) to work on each and
* every motherboard, but with sufficient HW skills it shall be quite easy too.
*
* VIDEO SYNCHRO
* *************
*
* Tested only with TO7/70 which produces ~3.5V SYNC-only signal on SCART pin #20. This eases interfacing
* to the arduino for a start. Do not get rid of the resistor or your TV will probably clamp signal to ~1V
* and nothing will work. I'll be putting together a simple but better interfacing method someday :)
*
* 1.2K
* From TO7/70 SCART pin #20 -----/\/\/\----- To TV SCART pin #20
* |_____________ To any arduino pin (check PIN_SYNCHRO define)
*
* All other pins go through "as is".
*
*
* OPTICAL PEN (light sensor)
* ***********
*
*
* 5V Arduino --------------------/\/\/\-------|>|----------------
* 4.7 Green LED |
* 68 |/ C
* From any Arduino pin (check PIN_PEN_LED define) ---/\/\/\---| BC547
* |\ E
* |
* GND Arduino ---------------------------------------------------
*
*
* OPTICAL PEN (button)
* ********************
*
* TO BE DONE (for now I press enter :P)
*
*
* PS2 MOUSE
* *********
*
* Female (PC side) connector, front view :
*
* NC (6) o U o (5) Any Arduino pin (check PIN_MOUSE_CLOCK define)
* 5V Arduino (4) o o (3) GND Arduino
* NC (2) o o (1) Any Arduino pin (check PIN_MOUSE_DATA define)
*
*
************************************************************************************************************
* VERSION HISTORY
************************************************************************************************************
*
* v0.1 (2021-04-04)
* =================
*
* o Very first "public" release : very little tested, expect thermonuclear explosions - at least !
* o Most operations are blocking :
* . No video synchro => deadlock
* . Mouse not detected => deadlock
* . Whatever goes wrong => guess what
* o Synchro : Timings, boundaries, scaling,... were all defined and verified... "au doigt mouillé"...
* o Pen button : Handled but not yet tested (not done HW interfacing yet)
*
************************************************************************************************************/
Donc le choix souris/crayon n'affecte que le comportement de la routine en ROM correspondant aux INMOUSE/INPEN du basic. Je ne sais pas si des programmes comme colorpaint ou paragraphe font en pratique appel à cette routine.
Oui, mais souvent les logiciels utilisant le light-pen(*) n'affichent pas de réticule (pointeur-souris) sur l'écran car on est supposé savoir directement où l'on pointe. Avec une souris sans ce réticule, et bien, on ne sait pas où l'on est à l'écran et on click au petit bonheur la chance.