Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: LED_Demo LED_Demo2 LED_Demo
Fork of BMP180 by
MAX44000 Class Reference
MAX44000 Ambient Light and Infrared Proximity Sensor. More...
#include <MAX44000.h>
Detailed Description
MAX44000 Ambient Light and Infrared Proximity Sensor.
#include <stdio.h> #include "mbed.h" #include "MAX44000.h" I2C i2c(I2C_SDA, I2C_SCL); MAX44000 max44000(&i2c); int main(void) { while(1) { if (max44000.init(MAX44000::MODE_ALS_PROX, MAX44000::ALSTIM_1X, MAX44000::ALSPGA_128X, MAX44000::DRV_110) != 0) { printf("Error communicating with MAX44000\n"); } else { printf("Initialized MAX44000\n"); break; } wait(1); } while(1) { int alsValue = max44000.readALS(); if(alsValue < 0) { printf("Error reading ALS value\n"); continue; } int proxValue = max44000.readReg(MAX44000::REG_PRX_DATA); if(proxValue < 0) { printf("Error reading proximity value\n"); continue; } printf("ALS = 0x%04X Proximity = 0x%02X\n", alsValue, proxValue); wait(1); } }
Definition at line 81 of file MAX44000.h.
Member Enumeration Documentation
| enum alspga_t |
alspga_t - MAX44000 Ambient Light Measurement Gain
- Enumerator:
ALSPGA_1X 0.03125 lux/lsb
ALSPGA_4X 0.125 lux/lsb
ALSPGA_16X 0.5 lux/lsb
ALSPGA_128X 4 lux/lsb
Definition at line 141 of file MAX44000.h.
| enum alstim_t |
ALS ADC Conversion Time.
MAX44000 Ambient Light Sensor ADC Conversion Time
- Enumerator:
ALSTIM_1X 100ms, 16,384 counts, 14 bit resolution
ALSTIM_4X 25ms, 4096 counts, 12 bit resolution
ALSTIM_16X 6.25ms, 1024 counts, 10 bit resolution
ALSTIM_64X 1.5625ms, 256 counts, 8 bit resolution
Definition at line 130 of file MAX44000.h.
| enum drive_t |
LED Driver Current.
MAX44000 LED Driver Current Settings
- Enumerator:
Definition at line 153 of file MAX44000.h.
| enum modes_t |
Operating Modes.
Enumerated MAX44000 operating modes
- Enumerator:
Definition at line 114 of file MAX44000.h.
| enum persist_t |
Persist Times.
MAX44000 ALS/PROX Threshold Persist Timer Settings
- Enumerator:
PST_1 1 trigger before interrupt
PST_2 2 consecutive triggers before interrupt
PST_4 4 consecutive triggers before interrupt
PST_16 16 consecutive triggers before interrupt
Definition at line 177 of file MAX44000.h.
| enum registers_t |
Register Addresses.
Enumerated MAX44000 register addresses
- Enumerator:
Definition at line 90 of file MAX44000.h.
Constructor & Destructor Documentation
| MAX44000 | ( | PinName | sda, |
| PinName | scl | ||
| ) |
MAX44000 constructor.
- Parameters:
-
sda mbed pin to use for SDA line of I2C interface. scl mbed pin to use for SCL line of I2C interface.
Definition at line 40 of file MAX44000.cpp.
| MAX44000 | ( | I2C * | i2c ) |
| ~MAX44000 | ( | ) |
MAX44000 destructor.
Definition at line 56 of file MAX44000.cpp.
Member Function Documentation
| int init | ( | MAX44000::modes_t | mode, |
| MAX44000::alstim_t | alstim, | ||
| MAX44000::alspga_t | alspga, | ||
| MAX44000::drive_t | drive | ||
| ) |
Initialize MAX44000.
Gets the device ID and saves the calibration values.
- Parameters:
-
mode Operating Mode alstim Ambient Light ADC Conversion Time alspga Ambient Light Measurement Gain drive LED Driver Current
- Returns:
- 0 if no errors, -1 if error.
Definition at line 64 of file MAX44000.cpp.
| int readALS | ( | void | ) |
Read ALS Data.
Reads both ALS data registers and returns combined value
- Returns:
- data if no errors, -1 if error.
Definition at line 121 of file MAX44000.cpp.
| int readReg | ( | MAX44000::registers_t | reg_addr ) |
Read Register.
Reads data from MAX44000 register
- Parameters:
-
reg_addr Register to read
- Returns:
- data if no errors, -1 if error.
Definition at line 104 of file MAX44000.cpp.
| int writeReg | ( | MAX44000::registers_t | reg_addr, |
| char | reg_data | ||
| ) |
Write Register.
Writes data to MAX44000 register
- Parameters:
-
reg_addr Register to write reg_data Data to write
- Returns:
- 0 if no errors, -1 if error.
Definition at line 90 of file MAX44000.cpp.
Generated on Thu Jul 21 2022 14:13:30 by
1.7.2

Ambient Light and Proximity Sensor MAX44000