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.
main.cpp
00001 #include "mbed.h" 00002 #include "MAX44008.h" 00003 00004 #define MAX44008_I2C_ADDRESS (0x41) 00005 00006 #if defined (TARGET_KL25Z) 00007 #define PIN_SCL PTE1 00008 #define PIN_SDA PTE0 00009 #elif defined (TARGET_KL46Z) 00010 #define PIN_SCL PTE1 00011 #define PIN_SDA PTE0 00012 #elif defined (TARGET_K64F) 00013 #define PIN_SCL PTE24 00014 #define PIN_SDA PTE25 00015 #elif defined (TARGET_K22F) 00016 #define PIN_SCL PTE1 00017 #define PIN_SDA PTE0 00018 #elif defined (TARGET_KL05Z) 00019 #define PIN_SCL PTB3 00020 #define PIN_SDA PTB4 00021 #elif define (TARGET_F411RE) 00022 #define PIN_SCL PB_8 00023 #define PIN_SDA PB_9 00024 #else 00025 #error TARGET NOT DEFINED 00026 #endif 00027 00028 MAX44008 *max44008 = 0 ; 00029 00030 void reportMAX44008(MAX44008 *max44008) 00031 { 00032 uint16_t amb_c, amb_r, amb_g, amb_b, amb_ir, amb_ircomp, amb_temp ; 00033 amb_c = max44008->getAMB_CLEAR() ; 00034 amb_r = max44008->getAMB_RED() ; 00035 amb_g = max44008->getAMB_GREEN() ; 00036 amb_b = max44008->getAMB_BLUE() ; 00037 amb_ir = max44008->getIR() ; 00038 amb_ircomp = max44008->getIRCOMP() ; 00039 amb_temp = max44008->getTEMP() ; 00040 printf("--- MAX44008 ---\n") ; 00041 printf(" C[ %04X ]\n", amb_c) ; 00042 printf("R[ %04X ] G[ %04X ] B[ %04X ]\n",amb_r, amb_g, amb_b) ; 00043 printf("IR[ %04X ] IRCOMP [ %04X ]\n",amb_ir, amb_ircomp) ; 00044 printf(" TEMP [ %04X ]\n",amb_temp) ; 00045 printf("\n") ; 00046 } 00047 00048 #define MODE_CLEAR_RGB_IR 0x02 00049 00050 int main() { 00051 max44008 = new MAX44008(PIN_SDA, PIN_SCL, MAX44008_I2C_ADDRESS) ; 00052 max44008->setMode(MODE_CLEAR_RGB_IR) ; 00053 00054 while(1) { 00055 reportMAX44008(max44008) ; 00056 wait(1) ; 00057 } 00058 }
Generated on Sat Jul 23 2022 16:05:35 by
1.7.2