Commit Graph

717 Commits

Author SHA1 Message Date
Joe Finney 95c1fc7f05 Fix Calculation of Pitch/Roll. Fixes #371
This patch:

 - Corrects the getPitch() and getRoll() methods to use normalized data from accelerometer sensors.
 - Provides a compile time option (default: enabled) to provide full range 0..360 degree pitch data
   that is consistent with the rage of the roll data.
 - Updates the tilt compensated compass heading calculation to use normalized data from accelerometer sensors.
2018-09-04 23:43:32 +01:00
microbit-carlos ab9e6fc550 When updateGesture() creates a SHAKE event also register it as the last gesture detected
Background info:
https://github.com/lancaster-university/microbit-dal/issues/372#issuecomment-417731360
2018-09-03 10:33:40 +00:00
Sam Kent 26d7b6d420 Partial Flashing disabled by default. Enabled for MakeCode builds 2018-08-29 19:14:08 +01:00
James Devine 74a7f7e63b add the ability to add / ignore based on the cb_arg
This commit introduces differentiation of listeners based on the cb_arg. This means that multiple listeners can be registered for the same event source and value, but with different cb_args.

Upon listener deletion, the listener_deletion_callback is invoked if non-NULL.

Motivation:
MakeCode uses cb_arg as context for higher level function pointer mapping (key / value), it can currently hold only one function pointer due to dal limitations.
MakeCode currently has an indirection layer for events that could be first class listener invocations, this is due to omitting cb_arg when ignoring / adding listeners.

Implementation:
there is probably a "cooler" way of doing this, i.e. a meta listener where the cb arg is set with a pointer to the listener being removed.
reasons why a callback function is superior:
1) fast and immediate
2) requires far less configuration (could be really complex with a meta listener)
3) smaller memory and processing overhead
2018-08-26 22:51:09 -07:00
James Devine 9fcfe937ae Added listener_deletion_callback member to EventModel
In upcoming commits I will add the ability to add/ignore listeners based also on the given listener cb_arg. With the possibility of multiple handlers being deleted at once, it's useful to application developers to be able to inspect what is being removed.
2018-08-26 22:45:03 -07:00
James Devine 84cc68903c corrected bad indentation 2018-08-26 19:29:33 -07:00
Martin Williams 00689525a0 Change MicroBitMemoryMap::findHashes() to set MakeCode startAddress 2018-08-26 18:27:39 +01:00
Martin Williams 9f5d5802ed Fix MicroBitPartialFlashingService blockPacketCount increment. If the 5th packet goes missing, the recovery code would have set packetCount based on the wrong blockPacketCount, expecting the same packet numbers again. 2018-08-26 18:10:41 +01:00
Sam Kent f385db52d5 Error 050: Accelerometer unavailable; 051: Magnetometer unavailable 2018-08-20 11:32:05 +01:00
Sam Kent f7f4887285 Even better logo 2018-08-08 12:04:41 +01:00
Sam Kent 27c5654db2 Fix BT Logo 2018-08-08 11:52:05 +01:00
Mark dd449ade48
Update README.md
updated links to reference microbit.org
2018-08-08 08:38:09 +01:00
Philipp Henkel 4ac7a3b861 Always read from the serial to clear the RX interrupt 2018-07-25 08:45:10 +02:00
Joe Finney 5d40fcf479
Merge pull request #362 from Taylor-Woodcock/dal-integration
Fixed sample period lookup issue in MAG3110 and MMA8653 drivers.
2018-07-24 15:31:07 +01:00
Taylor-Woodcock 679801153a Fixed issue with sample period lookup not being multiplied by 1000 in the MAG3110 and MMA8653 drivers, and set the default compass sample rate back to 10Hz. 2018-07-24 15:10:44 +01:00
Jonny Austin e3188e315a Add SoftDevice values for S130v1
These values are determined from
http://infocenter.nordicsemi.com/pdf/S130_SDS_v1.0.pdf
pg 41

It appears using S130v2 would allow even lower memory consumption

This is for use in conjunction with the
bbc-microbot-classic-gcc-s130
target, which also needs a fix before it will work.
2018-07-12 09:29:07 +01:00
Joe Finney 52e308658f Merge branch 'partial-flashing' into dal-integration 2018-07-06 17:42:09 +01:00
Sam Kent e13d31c27a Fix whitespace 2018-07-06 16:57:59 +01:00
Joe Finney 28dec2ca9b Update module version to identify dal-integration branch 2018-07-06 16:56:40 +01:00
Sam Kent 36dff6e73f Fix GATT Table. Replace CortexContextSwitch.s 2018-07-06 16:43:14 +01:00
Joe Finney 82a91852d0 Bump version to v2.1.0-rc2 2018-07-06 16:35:47 +01:00
Joe Finney ec180b70f4 Merge remote-tracking branch 'upstream/microbit1.4' into microbit1.5 2018-07-06 04:43:06 +01:00
Joe Finney 13459857a5 Disable DEBUG, pending beta release 2018-07-06 04:28:13 +01:00
Joe Finney 57e2485861 Introduce optional persistent storage functionality into
MicroBitCompassCalibrator

  - A new form of constructor now allows for a persistent storage object to be
    provided. If present, compass calibration data will be automatically
    stored and retrieved from FLASH when needed.
2018-07-06 04:18:34 +01:00
Joe Finney 5d4c397311 Remove redundant Matrix4 Class.
- Matrix4 was used only for the least mean squres calculation as part of the
    MicroBitCompassCalibrator. This has now been replace with an itereative
approximation algorithm.
2018-07-06 03:39:02 +01:00
Joe Finney 81b85e1335 Backward compatibility for ::updateSample() methods in sensors. 2018-07-06 03:32:08 +01:00
Joe Finney 2d46e9dabd Remove reduntant code in MicroBitAccelerometer
Also removes a potential recursive loop, as noted by @dpgeorge.
2018-07-06 03:19:42 +01:00
Joe Finney e770f34636 Add Backward Compatibility for CompassSample type. 2018-07-06 03:17:03 +01:00
Joe Finney d58396aa12 Updates to Compass Calibration and Compass Heading Calculation
- Add mutator to allow accelerometer to be added to a compass after construction
- Use floating point values for Sample3D:dSquared() operations to resmove possible overflow
- Change compass calibration hill climb algorithm to use 100 unit steps to converge faster.
- Update autodetect functions to register accelerometer instances with compass instances upon detection
- Clean and fix axis alignments for tilt compensation algorithm
2018-07-06 03:08:06 +01:00
Joe Finney bbf56210ed Introduce Updates to Compass Calibration Algorithm and UX
- Updated compass calibration algorithm, based on iterative approximation
  - Updated calibration UX
2018-07-05 23:48:41 +01:00
Joe Finney e79284d797 Introduce accelerometer/magnetometer autodetection
- Autodetection logic added to MicroBitAccelerometer/MicroBitCompass
  - Added single byte I2C read utility function into MicroBitI2C
  - Added isDetected() method into sensor drivers
2018-06-15 18:39:56 +01:00
microbit-carlos 3890f223af Tag release 2.1.0-rc1 2018-06-14 08:52:29 +00:00
Sam Kent 289c4b85d7 Removed packetNum < packetCount check 2018-06-13 17:55:56 +01:00
Sam Kent ac14383c28 packetCount: 0 index; no longer stuck after 256 packets 2018-06-13 11:05:57 +01:00
Joe Finney f8ee57bd26 Use correct WHO_AM_I value for LSM303 magnetometer sensor 2018-06-07 17:37:53 +01:00
Joe Finney a4b803d3e7 Updates to configure for FXOS8700 driver on microbit v1.5
- Add pin mapping for third interrupt line as used by FXOS8700
 - Move FXOS to open drain interrupt configuration
 - Add pullup onto interrupt line to FXOS
2018-06-07 17:27:34 +01:00
Sam Kent 040f63b01f
Changes from code review with Joe F (#10)
* Movd MICROBIT_MODE_* defines to MicroBitConfig.h

* Search for embedded source and remove magic

* Fixed memcpy

* Change offset order

* Fixed memcpy for data
2018-06-04 16:13:20 +01:00
Joe Finney f6bee0940e minor fixes after testing 2018-05-31 17:54:33 +01:00
Joe Finney ff29f2133e Refactor Accelerometer/Magnetometer code to enable new drivers 2018-05-29 18:09:48 +01:00
Sam Kent 3413d5487d
Added Partial Flashing Service (#9)
* Memory Map + Partial Flash Service

* Moved Partial Flash Service to Management Mode

* PF Service appears in YT Build not PXT

* PF in PXT

* Swapped DFU and PF Services

* Fixing Flash Writew

* write flash via bluetooth

* Partial Flash -  Fixed Address

* Update module.json

* Adjust flash pointer

* Adjust flash start

* Adjust Flash Pointer

* Added offset to xfer

* Writing to FLASH_END

* Writing to FLASH_END

* Modified PFS read callback

* Reenable BLE Security

* removed pf

* Check diff

* Check diff

* Replaced ContextSwitch

* PF

* Test. Writing Hex File to 0x30000

* Writing to PXT empty space

* Reversed byte order

* Flash 16 bytes at once

* Copy data from static var to local var

* blocks -> bytes

* Fixed offset

* Fixed Offset

* Flash to 0x30000 + offset

* Bypass scratch page

* Changed byte order

* Write Without Response

* Without Fast BLE

* Added fast BLE

* Updated Connection Parameters

* Iterate through BLE data bytes

* Get Hashes From PXT Build

* Copy Hash from Flash

* Testing FLASH_END

* Read Hash From Flash

* Read Hash from Flash

* Reading correct hash from mem

* Endianess

* Modified MAGIC

* Fix Start Address

* Sequence #

* Write 0xdeadbeef to 0x36000 on PF Seq # error

* Group 4 packet blocks for writing

* Added error case

* Increased flash write size

* Blocks

* Fire event to write

* Decreased flash time

* Reformat

* Reduced hash size in MemoryMap

* Partial Flashing w/ Notifications

* One Characteristic - WRITE/WRITE_WOUT_RESP/NOTIFY

* Modified WRITE Notification

* Tidied - Moved end of transfer logic

* Removed VI Swap files

* Added Pairing Mode Event ID

* Modified Retransmit behaviour

* updateFlash caused stack overflow

* Removed flash write from memory map

* Instantiate Memory Map where used

* Word aligned. Added Status and Reset commands

* Fixed: storage. becomes storage->

* Fixed warnings: switch case fall through

* Fix Hash

* Rebuild Map everytime

* Hash Error

* Edited animation. Hash testing

* persistent memory map issues

* Moved EOT

* Modified BLE animation. Removed globals from PFS

* Updated MM

* Added incomplete flash flag

* Re added CCS.s
2018-04-16 17:27:14 +01:00
Sebastian Pauka 6515942542
Reset the radio module after frequency change
The nRF module requires that the radio be reset after the frequency is changed. Until this is done, we will not be able to receive packets.
2018-01-09 17:04:34 +11:00
Joe Finney 2cff906f01
Merge pull request #325 from dpgeorge/image-remove-atoi
Rewrite MicroBitImage parsing code so it doesn't depend on atoi()
2017-12-19 15:13:07 +00:00
Joe Finney 6fa716f779
Merge pull request #326 from dpgeorge/heapallocator-remove-throw
Remove "throw" exception specifications because they are deprecated.
2017-12-19 15:05:23 +00:00
Joe Finney 0fe61146ec
Merge pull request #324 from microbit-sam/flash_write_bug
flash_write - Default scratch_address & Erase scratch when overwriting flash
2017-12-19 15:03:24 +00:00
Sam Kent ed65d39246 CortexContextSwitch.s disappeared 2017-11-16 09:40:43 +00:00
Sam Kent 1e7b0a76d3 Erase scratch page when overwriting 2017-11-16 09:33:34 +00:00
Damien George d883f33c5b Remove "throw" exception specifications because they are deprecated.
The use of such specifications are deprecated since C++11.
2017-11-16 11:04:40 +11:00
Damien George fbfee4930a Rewrite MicroBitImage parsing code so it doesn't depend on atoi()
Using the function atoi() pulls in a dependency from newlib, which in turn
pulls in locale support, and locale support requires about 350 bytes of
RAM.  This patch removes such a dependency by rewriting the MicroBitImage
parsing code so that it directly converts the input string to an integer
instead of building a buffer and passing it to atoi().

This patch saves about 640 bytes of code space and 364 bytes of RAM.  It
also reduces the amount of stack space used by the MicroBitImage
constructor.
2017-11-16 10:35:20 +11:00
Sam Kent 19a51d0f21 Neater if statement 2017-11-15 16:55:48 +00:00
Sam Kent edb8f16f1d CortexContextSwitch.s 2017-11-15 16:50:03 +00:00