Skip to content

Commit

Permalink
adjust cropmap function
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagohersan committed Mar 2, 2024
1 parent 48bdde1 commit 3d4003c
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions firmware/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ def pmap(x, in_min, in_max, out_min, out_max):
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min

def cropmap(x, in_min, in_max, out_min, out_max):
ress = 0
if x>=in_min and x<=in_max:
ress = (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
elif x<in_min:
ress = 0
elif x>in_max:
ress = (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
if x < in_min:
ress = out_min
elif x > in_max:
ress = out_max
return ress

Expand Down Expand Up @@ -272,9 +270,4 @@ def sms_handler(evt):
gps.off()
i2c.close(2)






#assert rsp == b'HTTP/1.1 200 OK\r\ncontent-length: 0\r\n\r\n'
#assert rsp == b'HTTP/1.1 200 OK\r\ncontent-length: 0\r\n\r\n'

0 comments on commit 3d4003c

Please sign in to comment.