-
-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2758617
commit 96a39b7
Showing
9 changed files
with
167 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
Submodule Melopero_AMG8833
added at
b144e5
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,33 @@ | ||
AMG8833 | ||
======= | ||
|
||
.. highlight:: c++ | ||
|
||
Introduction | ||
------------ | ||
|
||
A library to communicate with the cheap `thermal sensor AMG8833 <https://mediap.industry.panasonic.eu/assets/imported/industrial.panasonic.com/cdbs/www-data/pdf/ADI8000/ADI8000C66.pdf>`_. | ||
|
||
Using | ||
----- | ||
|
||
1. Add ``COMPONENT_DEPENDS += AMG8833`` to your application componenent.mk file. | ||
2. Add these lines to your application:: | ||
|
||
#include <Melopero_AMG8833.h> | ||
namespace | ||
{ | ||
Melopero_AMG8833 sensor; | ||
// ... | ||
} // namespace | ||
void init() | ||
{ | ||
Wire.begin(); | ||
sensor.initI2C(); | ||
// ... | ||
} |
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,4 @@ | ||
COMPONENT_SUBMODULES := Melopero_AMG8833 | ||
|
||
COMPONENT_SRCDIRS := $(COMPONENT_SUBMODULES)/src | ||
COMPONENT_INCDIRS := $(COMPONENT_SRCDIRS) |
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,9 @@ | ||
##################################################################### | ||
#### Please don't change this file. Use component.mk instead #### | ||
##################################################################### | ||
|
||
ifndef SMING_HOME | ||
$(error SMING_HOME is not set: please configure it as an environment variable) | ||
endif | ||
|
||
include $(SMING_HOME)/project.mk |
12 changes: 12 additions & 0 deletions
12
Sming/Libraries/AMG8833/samples/TemperatureMatrix/README.rst
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,12 @@ | ||
Temperature Matrix | ||
================== | ||
|
||
A simple demonstrating how to handle interrupts with the Melopero AMG8833 sensor. | ||
The sensor communicates through I2C. Connection scheme:: | ||
Microcontroller ----------- Melopero AMG8833 | ||
3.3V ----------- VIN | ||
GND ----------- GND | ||
SCL ----------- SCL | ||
SDA ----------- SDA | ||
a valid INT Pin----------- INT |
Empty file.
103 changes: 103 additions & 0 deletions
103
Sming/Libraries/AMG8833/samples/TemperatureMatrix/app/application.cpp
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,103 @@ | ||
#include <SmingCore.h> | ||
#include <Melopero_AMG8833.h> | ||
|
||
Melopero_AMG8833 sensor; | ||
|
||
namespace | ||
{ | ||
const byte interruptPin = 2; | ||
|
||
Timer procTimer; | ||
bool state = true; | ||
|
||
bool interruptOccurred = false; | ||
|
||
//The high and low temperature thresholds. If a temperature that exceeds | ||
//these values is detected an interrupt will be triggered. The temperatures | ||
//are expressed in Celsius degrees. | ||
float highThreshold = 26.5; | ||
float lowThreshold = 10; | ||
|
||
void onInterrupt() | ||
{ | ||
interruptOccurred = true; | ||
} | ||
|
||
void loop() | ||
{ | ||
//Update the sensors thermistor temperature and print it. | ||
Serial.print("Updating thermistor temperature ... "); | ||
int statusCode = sensor.updateThermistorTemperature(); | ||
Serial.println(sensor.getErrorDescription(statusCode)); | ||
|
||
Serial.print("Thermistor temp: "); | ||
Serial.print(sensor.thermistorTemperature); | ||
Serial.println("°C"); | ||
|
||
//Check if an interrupt occurred. | ||
//The interrupt occurred flag gets set by the interrupt service routine | ||
//each time an interrupt is triggered. | ||
if(interruptOccurred) { | ||
interruptOccurred = false; | ||
Serial.println("Interrupt triggered!"); | ||
|
||
//Update the interrupt matrix to know which pixels triggered the interrupt. | ||
Serial.print("Updating interrupt matrix ... "); | ||
statusCode = sensor.updateInterruptMatrix(); | ||
Serial.println(sensor.getErrorDescription(statusCode)); | ||
|
||
//Print out the interrupt matrix. | ||
Serial.println("Interrupt Matrix: "); | ||
for(int x = 0; x < 8; x++) { | ||
for(int y = 0; y < 8; y++) { | ||
Serial.print(sensor.interruptMatrix[y][x]); | ||
Serial.print(" "); | ||
} | ||
Serial.println(); | ||
} | ||
} | ||
} | ||
|
||
} // namespace | ||
|
||
void init() | ||
{ | ||
Wire.begin(); | ||
sensor.initI2C(); | ||
// To use Wire1 (I2C-1): | ||
// Wire1.begin(); | ||
// sensor.initI2C(AMG8833_I2C_ADDRESS_B, Wire1); | ||
|
||
//Reset the device flags and settings and read the returned status code. | ||
Serial.print("Resetting sensor ... "); | ||
int statusCode = sensor.resetFlagsAndSettings(); | ||
|
||
//Check if there were any problems. | ||
Serial.println(sensor.getErrorDescription(statusCode)); | ||
|
||
//Setting the FPS_MODE this can be: FPS_MODE::FPS_10 or FPS_MODE::FPS_1 | ||
Serial.print("Setting FPS ... "); | ||
statusCode = sensor.setFPSMode(FPS_MODE::FPS_10); | ||
Serial.println(sensor.getErrorDescription(statusCode)); | ||
|
||
//Setting the threshold values | ||
Serial.print("Setting threshold values ... "); | ||
statusCode = sensor.setInterruptThreshold(lowThreshold, highThreshold); | ||
Serial.println(sensor.getErrorDescription(statusCode)); | ||
Serial.print("low threshold : "); | ||
Serial.print(lowThreshold); | ||
Serial.print(" high threshold : "); | ||
Serial.println(highThreshold); | ||
|
||
//Enable the interrupt. | ||
Serial.print("Enabling interrupt ... "); | ||
statusCode = sensor.enableInterrupt(); | ||
Serial.println(sensor.getErrorDescription(statusCode)); | ||
|
||
//Configuring the interrupt pin to listen for the interrupt. | ||
pinMode(interruptPin, INPUT_PULLUP); | ||
//Attaching our function onInterrupt to the interrupt. | ||
attachInterrupt(interruptPin, onInterrupt, CHANGE); | ||
|
||
procTimer.initializeMs(100, loop).start(); | ||
} |
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 @@ | ||
COMPONENT_DEPENDS := AMG8833 |