Python Forum
How to map 360 degree angle over 1024 counts
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to map 360 degree angle over 1024 counts
#2
I didn't work with raspberry pi and embedded
python, but I suspect that PIN_DAT = [3,14] should be PIN_DAT = [3.14], if 3,14 stands for pi here...?!

def deg2count(angle, maxcount=1023):
    """ 0 <= angle <= 360 """
    return int(angle / 360.0 * maxcount)

def count2deg(count, maxcount=1023):
    return int(count / maxcount * 360)
Since your code includes series of numbers 3,1,4 (pi approx 3.14), I suspect that
angles should be given in radians; in this case my code should be changed, e.g. 360 must be replaced with, e.g. 3.1415 * 2.
Reply


Messages In This Thread
RE: How to map 360 degree angle over 1024 counts - by scidam - May-13-2019, 11:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Converting column of values into muliple columns of counts highland44 0 946 Feb-01-2024, 12:48 AM
Last Post: highland44
  Trying to get counts/sum/percentages from pandas similar to pivot table cubangt 6 3,559 Oct-06-2023, 04:32 PM
Last Post: cubangt
  Read All Emails from Outlook and add the word counts to a DataFrame sanaman_2000 0 2,857 Sep-15-2022, 07:32 AM
Last Post: sanaman_2000
  For Word, Count in List (Counts.Items()) new_coder_231013 6 7,291 Jul-21-2022, 02:51 PM
Last Post: new_coder_231013
  PyPi Download Counts and Warehouse Migration? tlee0818 1 1,898 Mar-20-2022, 07:41 PM
Last Post: snippsat
  How do I get the tangent of a degree SheeppOSU 3 7,163 Oct-24-2019, 02:13 PM
Last Post: ichabod801
  Converting Angle to X and Y Values: 90/180/270 deg qrani 1 3,521 Nov-21-2018, 06:41 PM
Last Post: woooee
  finding angle between three points on a 2d graph qrani 4 16,404 Nov-20-2018, 06:10 AM
Last Post: Gribouillis
  How do I create a timer that counts down? LavaCreeperKing 4 4,399 Jun-20-2018, 05:23 PM
Last Post: LavaCreeperKing
  Angle kripso 12 43,605 Oct-30-2017, 11:33 PM
Last Post: kripso

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020