Comments (4)
This sounds like issue #11 ?
from bluedot.
I have created a POC - https://github.com/martinohanlon/BlueDot/blob/dev/examples/click_wheel.py
It seems to work quite well, it needs some refinement, but its 90% there.
It works by splitting the dot into segments, when you pass from 1 segment to the next it is considered to have been rotated.
Im thinking a when_rotated
property which will call a function and pass a BlueDotRotation object (similar to when_pressed, when_swiped).
BlueDotRotation will have properties such as:
.value
- -1 for anti-clockwise, 1 for clockwiseanti_clockwise
- True if rotated anti clockwiseclockwise
- True if rotated clockwiseprevious_segment
- no between 1 & no_of_segments which returns where the position has moved fromcurrent_segment
- no between 1 & no_of_segments which returns where the position has moved too- anything else I think of at the time.
from bluedot.
I have been looking at this a little more this morning. Not sure where you are with implementing the click wheel functionality so I thought I would share where I am with it.
What I have not been able to implement is switching between modes. i.e. when is it a swipe/click versus drawing a circle.
What I have been able to do is implement a function that returns a negative number for anticlockwise and positive for clockwise. The function assumes you haven't moved more than 180 degrees between readings. In my tests I couldn't move that fast so it might be an OK assumption.
My function is:
def calc_rotation(prev, current):
delta = current - prev
if -180 < delta <= 180:
pass
elif delta > 180:
delta = delta - 360
elif delta <= -180:
delta = delta + 360
return delta
An example use is:
from bluedot import BlueDot
from signal import pause
bd = BlueDot()
prev_angle = 0
def calc_rotation(prev, current):
delta = current - prev
if -180 < delta <= 180:
pass
elif delta > 180:
delta = delta - 360
elif delta <= -180:
delta = delta + 360
return delta
def move(pos):
global prev_angle
current_angle = pos.angle
turn = calc_rotation(prev_angle, current_angle)
print('Moved ', turn)
prev_angle = current_angle
bd.when_moved = move
pause()
I did some tests as I was developing it:
import unittest
from click_wheel.click_wheel import calc_rotation
class GetRotation(unittest.TestCase):
def test_anti_clk(self):
self.assertEqual(calc_rotation(120, 100),
-20)
def test_clkwise(self):
self.assertEqual(calc_rotation(100, 120),
20)
def test_bndry_anti_clk(self):
self.assertEqual(calc_rotation(10, -10),
-20)
def test_bndry_clkwise(self):
self.assertEqual(calc_rotation(-10, 10),
20)
def test_south_bndry_anti_clk(self):
self.assertEqual(calc_rotation(-170, 170),
-20)
def test_south_bndry_clkwse(self):
self.assertEqual(calc_rotation(170, -170),
20)
if __name__ == '__main__':
unittest.main()
I hope this helps move this issue forward in some way.
Thanks
from bluedot.
Included in v1.2.0
from bluedot.
Related Issues (20)
- auto run from Pi's Shell HOT 6
- BLE communication between two Raspberry Pi 4 HOT 1
- Documentation: requirement for python-dbus (dbus-python) no longer directly mentioned in docs HOT 4
- Android app not able to connect to Pi HOT 2
- Unablet to connect HOT 13
- Not required "import os" in a recipe
- Web Bluetooth support and GATT HOT 5
- No Attribute AF_BLUETOOTH HOT 2
- Multiple pictures with pi cam
- not possible to check when bluetooth connexion in on HOT 2
- Send connection request from BluetoothServer side as well HOT 2
- Update BlueDot android app to latest google API level HOT 1
- Bluedot android app crashes on pi connection HOT 14
- can't bluedot be used in devices other than raspberry pi ? HOT 10
- Using Blue Dot with Raspberry Pi and HC-05 HOT 2
- Randomly getting ConnectionAbortedError on receive data and 'Transport endpoint is not connected' on send data errors HOT 1
- Raspbery Pi Pico W with Bluetooth HOT 5
- Sending feedback to android client HOT 2
- Update installation documentation for Raspberry Pi 'bookworm' OS
- Bluedot android app crashes on first launch HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bluedot.