dev: add interface for opt4048 lux/colour sensor

This commit is contained in:
A.M. Rowsell 2026-07-04 15:41:48 -04:00
commit 93788beab4
Signed by: amr
GPG key ID: E0879EDBDB0CA7B1
3 changed files with 115 additions and 0 deletions

23
include/opt4048.h Normal file
View file

@ -0,0 +1,23 @@
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2026 A.M. Rowsell <amr@frzn.dev>
#ifndef OPT4048_H
#define OPT4048_H
#include "hardware/i2c.h"
#define OPT_ADDR 0x44
/* Structure to hold the calculated color and lux data */
typedef struct {
float x;
float y;
float z;
float lux;
} OPT4048_Data;
OPT4048_Data calculate_color_data(float ch0, float ch1, float ch2);
int initOPT(i2c_inst_t *i2c);
int getOPTData(i2c_inst_t *i2c, float *ch0, float *ch1, float *ch2);
#endif // OPT4048_H