Share My Creation OBD2 Rev Counter USB ELM327

Rev counter using OBD2. Rquests RPM (PID 010C) every 0.2 sec. ELM327 V1.5 to USB.

rpm_usb330.png
 

Attachments

  • rpm_usb.zip
    93.9 KB · Views: 96
Last edited:

emexes

Expert
Licensed User
If you cast the needle to be a B4XView then you might be able to rotate the needle directly rather than having to paint it into a bitmap.

On the other hand, painting a double-size needle into a bitmap probably does nicer scaling eg anti-aliasing.
 

moty22

Active Member
Licensed User
If you cast the needle to be a B4XView then you might be able to rotate the needle directly rather than having to paint it into a bitmap.

On the other hand, painting a double-size needle into a bitmap probably does nicer scaling eg anti-aliasing.
I know too little about B4X to make a useful comment. I will study and try B4XView. I imagine that rotational movement is slow for the CPU because of complex calculations (sine, cosine) in compare to a movement in straight line.
 

moty22

Active Member
Licensed User
If you cast the needle to be a B4XView
I looked at B4XView and it looks like it will be much faster because only the pixels of the needle are drawn. My needle is a bitmap of 90000 pixels and it takes much longer to redraw. If in the future I'll need more than one dial I will use B4XView or draw the needle on minimal size rectangle. Thanks for your hint.
 

emexes

Expert
Licensed User
I imagine that rotational movement is slow for the CPU because of complex calculations (sine, cosine) in compare to a movement in straight line.

Actually it just has to use the "expensive" functions a few times, basically to work out where the corners move to, and then after that it's 99.9% adds, and a good half of those are add-ones ie increment. Plus AFAIK every phone's got a GPU nowadays, and rotation is one of the tasks that can be offloaded to that (by using the B4XView.Rotation property)

1666364911294.png


edit: you can probably even do PaneWithNoRotationProperty.As(B4XView).Rotation = ... but I can't test because el slacko here still hasn't gotten around to updating B4J
 
Last edited:

moty22

Active Member
Licensed User
I fail to understand your explanation. If you have an image of a vertical line 1 pixel wide and you rotate it 45 degrees then the new line has only about 0.7 number of pixels as the vertical line. How do you decide which pixel stays and which goes?
 

emexes

Expert
Licensed User
10-pixel line rotated to 7-pixel line:
  0123456789      0123456789
0 ABCDEFGHIJ    0 A
1               1  B
2               2   D
3               3    E
4               4     G
5               5      H
6               6       J
7               7
8               8
9               9

The end coordinates of the destination line only needs to be calculated (ie using sine & cosine) once.

You'd have a source pixel pointer, starting at (0, 0), increment by (9/6, 0) each pass through the loop,
and a destination pixel pointer, starting at (0, 0), increment by (1, 1) each pass through the loop,
number of loops is number of destination pixels, which is max of horizontal and vertical lengths of destination line

Copying 10-pixel line to (rotated) 7-pixel line:
               Source              Destination
            ============           ============         
              X      Y     Pixel     X      Y
=========   =====  =====   =====   =====  =====     
Increment     9/6  1               1      1

Start       0+0/6  0         A     0      0
            1+3/6  0         B     1      1
            3+0/6  0         D     2      2
            4+3/6  0         E     3      3
            6+0/6  0         G     4      4
            7+3/6  0         H     5      5
Finish      9+0/6  0         J     6      6

Note that not only does this rotate the line, but by starting the destination line somewhere other than (0, 0) you can also translate/displace/move the line at the same time, plus the same transformation can scale/resize the line larger or smaller, at the same time... bonus!!!

Rectangular transformations are just repeated line transformations, with the starting and destination points incremented for each scan line.
 
Last edited:

anonimo

New Member
@moty22
Hi.
I would like to know if there is any way to increase the buffer of an ELM327 USB.
I'm trying to reprogram my Medianav multimedia using the ddt4all program on my notebook but the configuration parameters are overflowing the ELM327 buffer.
Before buying another scanner, I'm looking to see if there is a way to increase its buffer.
Thank you for any help
 

Alessandro71

Well-Known Member
Licensed User
Longtime User
@moty22
I would like to know if there is any way to increase the buffer of an ELM327 USB.
if you are referring to the BUFFER FULL message you see in the OBD receive stream, then there's no way other than using a higher quality adapter.
cheap ones have a small data buffer.
 
Top