Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - acjacques

Pages: [1] 2 3
1
I have finished a code to read all functions of a Logitech F310 gamepad.
Then I am sharing the code:
Code: QB64: [Select]
  1.  'This code read all functions of a Logitech F310 gamepad. The back switch is on X position.
  2. 'Writed by ACJacques     acj@infolink.com.br    June/2020
  3.     FUNCTION joyGetPosEx& (BYVAL uJoyID AS _UNSIGNED INTEGER, joyref AS LONG)
  4.  
  5. TYPE JOYINFOEX
  6.     dwSize AS LONG
  7.     dwFlags AS LONG
  8.     dwXpos AS LONG
  9.     dwYpos AS LONG
  10.     dwZpos AS LONG
  11.     dwRpos AS LONG
  12.     dwUpos AS LONG
  13.     dwVpos AS LONG
  14.     dwButtons AS LONG
  15.     dwButtonNumber AS LONG
  16.     dwPOV AS LONG
  17.     dwReserved1 AS LONG
  18.     dwReserved2 AS LONG
  19.  
  20. DIM Joy1 AS JOYINFOEX
  21. Joy1.dwSize = LEN(Joy1)
  22.  
  23.     x& = joyGetPosEx(0, Joy1.dwSize) 'using Windows DLL to get better resolution
  24.  
  25.     LOCATE 1, 1:
  26.  
  27.     PRINT USING "####"; (Joy1.dwXpos / 64) 'j esquerdo h    left joystick horizontal       all converted to 10 bits     1024
  28.     PRINT USING "####"; (Joy1.dwYpos / 64) 'j esquerdo v    left joystick vertical
  29.     PRINT USING "####"; (Joy1.dwUpos / 64) 'j direto h      right joystick horizontal
  30.     PRINT USING "####"; (Joy1.dwRpos / 64) 'j direito v     right joystick vertical
  31.     PRINT USING "####"; (Joy1.dwZpos / 64) 'lt  rt
  32.     PRINT STRIG(1) 'botao A                       'using native  QB64  to get buttons
  33.     PRINT STRIG(5) 'botao B
  34.     PRINT STRIG(9) 'botao X
  35.     PRINT STRIG(13) 'botao Y
  36.     PRINT STRIG(17) 'botao lb
  37.     PRINT STRIG(21) 'botao rb
  38.     PRINT STRIG(25) 'botao back
  39.     PRINT STRIG(29) 'botao start
  40.     PRINT USING "###"; STICK(1, 3) ' Switches  Horizontal
  41.     PRINT USING "###"; STICK(0, 4) ' Switches  Vertical
  42.  
  43.  

2
Thanks. Yes . The microcontroller and a USB-UART TTL converter seems like the most practical solution for a notebook.
 I dont know if an USB - LPT converter would work.

3
Thanks . Did you know it it could accept older LPT control commands like the bellow?


https://www.aaroncake.net/electronics/qblpt.htm

4
QB64 Discussion / Re: Help with Serial Port Capture data
« on: May 10, 2020, 04:07:14 pm »
i need to decode each incoming serial message .  The messages are  receiving at  about 1 hz. It is to control data in the display.

5
Since new PCs does not have LPT ports what hardware could be used with QB64 to interact with external I/0 pins to set and read pins states ?

Any suggestion ?

6
QB64 Discussion / Help with Serial Port Capture data
« on: May 10, 2020, 11:54:42 am »
How capture a serial port data as strings  starting with an specific character, fields coma separated  and  ending with CR/LF  ?

Example raw data :   "#XYZ, 123.567, ABCD, 48*FF" followed by CR/LF" 

fields to be captured after  starting character "#"
string 1    =  XYZ
string 2    =  123.567
string 3    =  ABCD
string 4    =  48
string 5    =  FF

after "ABCD", need the capture the  "48" and "FF" fields as separated strings . Then the "*" should also be considered same as a coma ","

7
QB64 Discussion / Re: Help on Code to emulate SPI or I2C thru USB COM ports
« on: November 03, 2019, 05:18:08 pm »
SPI= Serial Parallel Interface   = Protocol used for some chips to control and communications
I2C = Inter Integrated Circuit =  Bus developed by Philips to connect some electronics 
Both are very similar
They are serial synchonous communication

8
QB64 Discussion / Help on Code to emulate SPI or I2C thru USB COM ports
« on: November 03, 2019, 04:13:15 pm »
Dear Friends
;
Bellow is the GOSUB (500-700) code that emulates  SPI communication thru native COM port to MAXIM186 ADC  8ch 12bit analog converter IC  . It was writed for the  old QB45/QB71 and desktop PC ...

I was mind if is possible this code works with USB COM ports of W10 notebooks...

Any adaption or suggestion how emulate SPI or I2C  communications ?

Thanks for your comments


Code: QB64: [Select]
  1.  
  2. 5 DIM V(8)
  3. 10 BA = &H2F8: REM COM2
  4. 20 OUT (BA + 3), 64
  5.  
  6. 120 FOR N = 0 TO 7: REM *****AQUI SELECIONA O NUMERO DE CANAIS*******
  7. 130 SEL = 7 - (N \ 2) - 4 * (N AND 1)
  8. 140 GOSUB 500: REM aquisita canais
  9.  
  10. 500 REM *************Aquisita canais MAX186 ******
  11. 510 CMD = 128 + 16 * SEL + 8 + 4 + 2
  12. 520 BIT = 128
  13. 530 FOR B = 1 TO 8
  14. 540 IF (CMD AND BIT) = BIT THEN RTS = 2 ELSE RTS = 0
  15. 550 OUT (BA + 4), RTS
  16. 560 OUT (BA + 4), RTS + 1
  17. 570 OUT (BA + 4), RTS
  18. 580 BIT = BIT \ 2
  19. 590 NEXT B
  20. 595 OUT (BA + 4), 0
  21. 600 FOR t = 1 TO 10: NEXT t
  22. 610 BIT = 2048: AUS = 0
  23. 630 FOR B = 1 TO 16
  24. 640 OUT (BA + 4), 1
  25. 650 OUT (BA + 4), 0
  26. 660 IF ((INP(BA + 6) AND 16) = 16) THEN AUS = AUS + BIT
  27. 670 BIT = BIT \ 2
  28. 680 NEXT B
  29. 692 V(N + 1) = AUS / 1000
  30. 700 RETURN
  31.  
  32.  

bellow is a I2C  code of BasicStamp  to read CH0  of MAX186

control is over 4 pins:

CS
DIN
DOUT
SCLK


read1: 'le canal 0 e armazena na  variavel AD(0): read ch 0 and store as variable AD(0)
low CS 'bring CS low
shiftout din,sclk,1,[%10001111] 'send the init string ' the high nibble is the channel number
shiftin dout,sclk,2,[AD(0)\12] 'get the 12 bit result
high CS 'bring CS high

9
QB64 Discussion / Re: Sometimes unexpected strong lags
« on: November 01, 2019, 07:44:30 pm »
Works fine for me too . Very good !

10
QB64 Discussion / Re: How could thicken the compass needle line ?
« on: November 01, 2019, 07:33:15 pm »
I made some mods :  Resizeable screen
Visual changes
Text fixed at center


Code: QB64: [Select]
  1. 'RESIZE:STRETCH
  2. size = 300 'enter size of window
  3. iwidth = size
  4. iheight = size
  5.  
  6. _TITLE "Compass fix and mod B+ 2019-10-31"
  7. 'MODIFIED by ACJACQUES 2019-11-02
  8.  
  9. SCREEN _NEWIMAGE(iwidth, iheight, 32)
  10. _SCREENMOVE 400, 20
  11. CX = iwidth / 2: CY = iheight / 2 'Centre of circle
  12. Radius = size / 3 'Radius
  13.  
  14.  
  15.     CLS
  16.     _MOUSESHOW "CROSSHAIR" ' will display a crosshair cursor
  17.     DO WHILE _MOUSEINPUT: LOOP 'wait for mouse
  18.     mX = _MOUSEX: mY = _MOUSEY 'get mouse xy
  19.  
  20.     ang = _ATAN2(mY - CY, mX - CX)
  21.     IF ang < 0 THEN ang = ang + _PI(2)
  22.  
  23.     X = CX + Radius * COS(ang)
  24.     Y = CY + Radius * SIN(ang)
  25.     thic CX, CY, X, Y, 3, &HFFFFFF00
  26.     da = _R2D(ang) + 90
  27.     'IF ang = 360 THEN ang = 0
  28.     IF da > 359.99 THEN da = da - 360
  29.  
  30.  
  31.     CIRCLE (CX, CY), 38, &HFFFFFFFF 'white center circle
  32.     PAINT (CX, CY), &HFFFFFFFF, &HFFFFFFFF 'filling
  33.  
  34.     CIRCLE (CX, CY), 37, &HFF000000 'black center circle
  35.     PAINT (CX, CY), &HFF000000, &HFF000000 'filling
  36.  
  37.     CIRCLE (CX, CY), Radius + 3, &HFFFFFFFF 'external white circle
  38.  
  39.     'LOCATE 10, 10:
  40.     'PRINT USING "Angle: ###.##"; da
  41.  
  42.     da = INT(da) 'make only integer
  43.     chrstr$ = STR$(da) 'convert to string
  44.  
  45.     chrstr$ = RIGHT$("00" + LTRIM$(chrstr$), 3) 'to include leading zeros
  46.     COLOR _RGB(255, 255, 0) 'color for text
  47.     _PRINTSTRING (CX - 12, CY - 6), chrstr$ ' set position relativve graphic screen with  offsets to be centered
  48.     _DISPLAY
  49.     _LIMIT 60
  50.  
  51. SUB thic (x1, y1, x2, y2, thick, K AS _UNSIGNED LONG)
  52.     PD2 = _PI / 3
  53.     DIM t2 AS SINGLE, a AS SINGLE, x3 AS SINGLE, y3 AS SINGLE, x4 AS SINGLE, y4 AS SINGLE
  54.     DIM x5 AS SINGLE, y5 AS SINGLE, x6 AS SINGLE, y6 AS SINGLE
  55.     t2 = thick / 2
  56.     IF t2 < 1 THEN t2 = 1
  57.     a = _ATAN2(y2 - y1, x2 - x1)
  58.     x3 = x1 + t2 * COS(a + PD2)
  59.     y3 = y1 + t2 * SIN(a + PD2)
  60.     x4 = x1 + t2 * COS(a - PD2)
  61.     y4 = y1 + t2 * SIN(a - PD2)
  62.     x5 = x2 + t2 * COS(a + PD2)
  63.     y5 = y2 + t2 * SIN(a + PD2)
  64.     x6 = x2 + t2 * COS(a - PD2)
  65.     y6 = y2 + t2 * SIN(a - PD2)
  66.     ftri x6, y6, x4, y4, x3, y3, K
  67.     ftri x3, y3, x5, y5, x6, y6, K
  68.  
  69. SUB ftri (x1, y1, x2, y2, x3, y3, K AS _UNSIGNED LONG)
  70.     DIM a&
  71.     a& = _NEWIMAGE(1, 1, 32)
  72.     _DEST a&
  73.     PSET (0, 0), K
  74.     _DEST 0
  75.     _MAPTRIANGLE _SEAMLESS(0, 0)-(0, 0)-(0, 0), a& TO(x1, y1)-(x2, y2)-(x3, y3)
  76.     _FREEIMAGE a& '<<< this is important!

 [ You are not allowed to view this attachment ]  

11
QB64 Discussion / How could thicken the compass needle line ?
« on: October 31, 2019, 11:30:34 am »
Hi;  How I could thicken the compass needle line ?

Code: QB64: [Select]
  1.  
  2. CX = 320: CY = 240 'Centre of circle
  3. Rad = 100 'Radius
  4.  
  5.    '_LIMIT 100
  6.     mX = _MOUSEX: mY = _MOUSEY
  7.     ang = mX
  8.   ' rad = mY
  9.  
  10.     IF ang = 360 THEN ang = 0
  11.     IF ang > 360 THEN ang = ang - 360
  12.  
  13.  
  14.     X = CX + COS(_D2R(ang - 90)) * Rad
  15.     Y = CY + SIN(_D2R(ang - 90)) * Rad
  16.  
  17.     pX = CX + COS(_D2R(ang - 90)) * (Rad + 1)
  18.     pY = CY + SIN(_D2R(ang - 90)) * (Rad + 1)
  19.     LINE (CX, CY)-(oldX, oldY), 0 'clear the old line
  20.     LINE (CX, CY)-(X, Y), 14 'yellow needle line
  21.     PSET (pX, pY)
  22.     oldX = X: oldY = Y
  23.     LOCATE 1, 10: PRINT USING "Angle: ###.##"; ang;
  24.    'PRINT " mX= "; mX
  25.     CIRCLE (CX, CY), 5, 14
  26.  
  27.  
  28.  

12
QB64 Discussion / How copy a part of screen ?
« on: October 30, 2019, 02:33:43 pm »
Friends;

How use _COPYIMAGE(0) to capture only a part of screen ?

The copied  area wil be further placed in the screen with _PUTIMAGE

Sorry for such so beginners question...

Thanks

13
OK Thanks .

SOLVED

COLOR _RGB32(255, 255, 0), _RGB32(255, 0, 255) ' first term is color foreground , second is for background

14
Thanks

now this works

COLOR (_RGB32(255, 255, 0)) 'yellow color foreground   

and for background color ?

15
How  change default foreground and background colors for  text  and graphics 

with SCREEN _NEWIMAGE (800,600,32)  ?

I have tried 

COLOR 14, 0

and _PALETTECOLOR 

but doesn't work. Just a black screen .

Works with
SCREEN 12   

but not with _NEWIMAGE







Pages: [1] 2 3