Skip to content
This repository has been archived by the owner on Dec 23, 2021. It is now read-only.

Adding API call for motion sensor #89

Merged
merged 69 commits into from
Aug 3, 2019
Merged

Conversation

FMounz
Copy link
Contributor

@FMounz FMounz commented Aug 2, 2019

Description:

This PR adds the API call for the motion sensor. New states have been added to the simulator and an acceleration function has been written in express.py.

Type of change

  • New feature (non-breaking change which adds functionality)

Limitations:

Testing:

  • Add to code.py and example code that use cpx.acceleration. The Simulator should be updated accordingly. Example:
from adafruit_circuitplayground.express import cpx
while True:
    (x,y,z)= cpx.acceleration
    if x>35 and y< -13 and z==11:
        cpx.red_led = True
    else:
        cpx.red_led = False

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Copy link
Contributor

@Christellah Christellah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small comments to address and it should be good to go

@@ -0,0 +1,13 @@
export interface ISliderProps {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file is not being used anywhere. Has it been added by accident maybe ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes its an older version that I forgot to delete

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this pls

}

self.pixels = Pixel(self.__state)
self.__abs_path_to_code_file = ''


@property
def acceleration(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the link of the library that's being used for acceleration on the device : https://github.com/adafruit/Adafruit_CircuitPython_LIS3DH/blob/master/adafruit_lis3dh.py

I think it's worth taking a look to make sure we're matching the logic in the library is providing for the physical device

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the lines 83-84 are interesting! There using namedtuple for their return type!

# the named tuple returned by the class
AccelerationTuple = namedtuple("acceleration", ("x", "y", "z"))

Copy link
Contributor Author

@FMounz FMounz Aug 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're both right it is an interesting reading I guess I can should use a named tuple. Appart from that @Christellah it conforms to this library and particularly it's uses in the cpx.express library who uses a particular case of the acceleration (fixed range =8_G). Thanks for the reminder

Copy link
Contributor

@Christellah Christellah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and seems to work
Please delete the file src/view/components/toolbar/Toolbar_ressources.tsx before merging

Copy link
Member

@LukeSlev LukeSlev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good other than the extra file

src/view/components/toolbar/InputSlider.tsx Show resolved Hide resolved
@@ -0,0 +1,13 @@
export interface ISliderProps {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this pls

@FMounz FMounz merged commit acf1d7d into dev Aug 3, 2019
@FMounz FMounz deleted the users/t-famoun/motion_sensor_logic branch August 10, 2019 11:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants