-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/pkg_arduino_adafruit_sensor: add test app
f
- Loading branch information
Showing
5 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include ../Makefile.tests_common | ||
|
||
USEPKG += arduino_adafruit_sensor | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
BOARD_INSUFFICIENT_MEMORY := \ | ||
arduino-duemilanove \ | ||
arduino-uno \ | ||
arduino-nano \ | ||
nucleo-l011k4 \ | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# this file enables modules defined in Kconfig. Do not use this file for | ||
# application configuration. This is only needed during migration. | ||
CONFIG_PACKAGE_ARDUINO_ADAFRUIT_SENSOR=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (C) 2021 Gunar Schorcht <gunar@schorcht.net> | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @ingroup tests | ||
* @{ | ||
* | ||
* @file | ||
* @brief Tests the Adafruit Unified Sensor Drive | ||
* | ||
* @author Gunar Schorcht <gunar@schorcht.net> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <string.h> | ||
|
||
#include "Adafruit_Sensor.h" | ||
|
||
class ADXL345 : public Adafruit_Sensor | ||
{ | ||
public: | ||
bool getEvent(sensors_event_t *) { return false; }; | ||
void getSensor(sensor_t *sensor); | ||
}; | ||
|
||
void ADXL345::getSensor(sensor_t *s) | ||
{ | ||
memset(s, 0, sizeof(sensor_t)); | ||
strncpy(s->name, "ADXL345", ARRAY_SIZE(s->name) - 1); | ||
s->version = 1; | ||
s->sensor_id = 12345; | ||
s->type = SENSOR_TYPE_ACCELEROMETER; | ||
s->min_delay = 0; | ||
s->min_value = -156.9064F; /* -16g = 156.9064 m/s^2 */ | ||
s->max_value = 156.9064F; /* 16g = 156.9064 m/s^2 */ | ||
s->resolution = 0.03923F; /* 4mg = 0.0392266 m/s^2 */ | ||
} | ||
|
||
int main(void) | ||
{ | ||
ADXL345 adxl345; | ||
adxl345.printSensorDetails(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (C) 2021 Gunar Schorchtr <gunar@schorcht.net> | ||
# | ||
# This file is subject to the terms and conditions of the GNU Lesser | ||
# General Public License v2.1. See the file LICENSE in the top level | ||
# directory for more details. | ||
|
||
import sys | ||
from testrunner import run | ||
|
||
|
||
def testfunc(child): | ||
child.expect_exact('------------------------------------') | ||
child.expect_exact('Sensor: ADXL345') | ||
child.expect_exact('Type: Acceleration (m/s2)') | ||
child.expect_exact('Driver Ver: 1') | ||
child.expect_exact('Unique ID: 12345') | ||
child.expect_exact('Min Value: -156.90') | ||
child.expect_exact('Max Value: 156.90') | ||
child.expect_exact('Resolution: 0.03') | ||
child.expect_exact('------------------------------------') | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(run(testfunc)) |