Merge pull request #931 from pimoroni/driver/as7343
AS7343: New driver for the 14 channel spectrometer
This commit is contained in:
commit
0b133c750e
|
@ -40,6 +40,15 @@ namespace pimoroni {
|
|||
i2c_write_blocking(i2c, address, buffer, 2, false);
|
||||
}
|
||||
|
||||
void I2C::reg_write_uint16(uint8_t address, uint8_t reg, uint16_t value) {
|
||||
uint8_t buffer[3] = {
|
||||
reg,
|
||||
(uint8_t)((value & 0xff00) >> 8),
|
||||
(uint8_t)(value & 0x00ff)
|
||||
};
|
||||
i2c_write_blocking(i2c, address, buffer, 3, false);
|
||||
}
|
||||
|
||||
uint8_t I2C::reg_read_uint8(uint8_t address, uint8_t reg) {
|
||||
uint8_t value;
|
||||
i2c_write_blocking(i2c, address, ®, 1, false);
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace pimoroni {
|
|||
i2c_inst_t* pin_to_inst(uint pin);
|
||||
|
||||
void reg_write_uint8(uint8_t address, uint8_t reg, uint8_t value);
|
||||
void reg_write_uint16(uint8_t address, uint8_t reg, uint16_t value);
|
||||
uint8_t reg_read_uint8(uint8_t address, uint8_t reg);
|
||||
uint16_t reg_read_uint16(uint8_t address, uint8_t reg);
|
||||
int16_t reg_read_int16(uint8_t address, uint8_t reg);
|
||||
|
|
|
@ -16,6 +16,7 @@ add_subdirectory(is31fl3731)
|
|||
add_subdirectory(fatfs)
|
||||
add_subdirectory(sdcard)
|
||||
add_subdirectory(as7262)
|
||||
add_subdirectory(as7343)
|
||||
add_subdirectory(bh1745)
|
||||
add_subdirectory(bme68x)
|
||||
add_subdirectory(bmp280)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
include(as7343.cmake)
|
|
@ -0,0 +1,10 @@
|
|||
set(DRIVER_NAME as7343)
|
||||
add_library(${DRIVER_NAME} INTERFACE)
|
||||
|
||||
target_sources(${DRIVER_NAME} INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/${DRIVER_NAME}.cpp)
|
||||
|
||||
target_include_directories(${DRIVER_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
# Pull in pico libraries that we need
|
||||
target_link_libraries(${DRIVER_NAME} INTERFACE pico_stdlib hardware_i2c pimoroni_i2c)
|
|
@ -0,0 +1,160 @@
|
|||
#include <cstdlib>
|
||||
#include <math.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
|
||||
#include "as7343.hpp"
|
||||
|
||||
namespace pimoroni {
|
||||
|
||||
bool AS7343::init() {
|
||||
if(interrupt != PIN_UNUSED) {
|
||||
gpio_set_function(interrupt, GPIO_FUNC_SIO);
|
||||
gpio_set_dir(interrupt, GPIO_IN);
|
||||
gpio_pull_up(interrupt);
|
||||
}
|
||||
|
||||
uint8_t aux_id, revision_id, hardware_id;
|
||||
get_version(aux_id, revision_id, hardware_id);
|
||||
|
||||
if(hardware_id != HARDWARE_ID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reset();
|
||||
|
||||
bank_select(0);
|
||||
|
||||
// Enable all 7 channels in output FIFO
|
||||
i2c->set_bits(address, reg::FIFO_MAP, 0, FIFO_MAP_CH5 | FIFO_MAP_CH4 | FIFO_MAP_CH3 | FIFO_MAP_CH2 | FIFO_MAP_CH1 | FIFO_MAP_CH0 | FIFO_MAP_ASTATUS);
|
||||
|
||||
// Set the PON bit
|
||||
i2c->reg_write_uint8(address, reg::ENABLE, ENABLE_WEN | ENABLE_SMUXEN | ENABLE_SP_EN | ENABLE_PON);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AS7343::reset() {
|
||||
i2c->reg_write_uint8(address, reg::CONTROL, CONTROL_SW_RESET);
|
||||
sleep_ms(1000);
|
||||
}
|
||||
|
||||
i2c_inst_t* AS7343::get_i2c() const {
|
||||
return i2c->get_i2c();
|
||||
}
|
||||
|
||||
int AS7343::get_sda() const {
|
||||
return i2c->get_sda();
|
||||
}
|
||||
|
||||
int AS7343::get_scl() const {
|
||||
return i2c->get_scl();
|
||||
}
|
||||
|
||||
int AS7343::get_int() const {
|
||||
return interrupt;
|
||||
}
|
||||
|
||||
void AS7343::bank_select(uint8_t bank) {
|
||||
if(bank == 1) {
|
||||
i2c->set_bits(address, reg::CFG0, 0, CFG0_BANK);
|
||||
} else {
|
||||
i2c->clear_bits(address, reg::CFG0, 0, CFG0_BANK);
|
||||
}
|
||||
}
|
||||
|
||||
void AS7343::get_version(uint8_t &auxid, uint8_t &revid, uint8_t &hwid) {
|
||||
bank_select(1);
|
||||
auxid = i2c->reg_read_uint8(address, reg::AUXID) & 0b00001111;
|
||||
revid = i2c->reg_read_uint8(address, reg::REVID) & 0b00000111;
|
||||
hwid = i2c->reg_read_uint8(address, reg::ID);
|
||||
bank_select(0);
|
||||
}
|
||||
|
||||
void AS7343::set_gain(float gain) {
|
||||
if(gain == 0.5f) {
|
||||
i2c->reg_write_uint8(address, reg::CFG1, 0);
|
||||
} else {
|
||||
uint16_t ugain = (uint16_t)gain;
|
||||
uint16_t bitlength = 0;
|
||||
while(ugain > 0) {
|
||||
bitlength++;
|
||||
ugain >>= 1;
|
||||
}
|
||||
i2c->reg_write_uint8(address, reg::CFG1, bitlength & 0x1f);
|
||||
}
|
||||
}
|
||||
|
||||
void AS7343::set_channels(channel_count channel_count) {
|
||||
this->read_cycles = uint8_t(channel_count) / 6;
|
||||
this->ch_count = (uint8_t)channel_count;
|
||||
uint8_t temp = i2c->reg_read_uint8(address, reg::CFG20) & ~CFG20_18_CH;
|
||||
switch(channel_count) {
|
||||
case channel_count::SIX_CHANNEL:
|
||||
temp |= CFG20_6_CH;
|
||||
break;
|
||||
case channel_count::TWELVE_CHANNEL:
|
||||
temp |= CFG20_12_CH;
|
||||
break;
|
||||
case channel_count::EIGHTEEN_CHANNEL:
|
||||
temp |= CFG20_18_CH;
|
||||
break;
|
||||
}
|
||||
i2c->reg_write_uint8(address, reg::CFG20, temp);
|
||||
}
|
||||
|
||||
void AS7343::set_illumination_current(float current) {
|
||||
current -= 4;
|
||||
current /= 2.0f;
|
||||
uint8_t temp = i2c->reg_read_uint8(address, reg::LED) & 0b10000000;
|
||||
temp |= (uint8_t)current;
|
||||
i2c->reg_write_uint8(address, reg::LED, temp);
|
||||
}
|
||||
|
||||
void AS7343::set_illumination_led(bool state) {
|
||||
uint8_t temp = i2c->reg_read_uint8(address, reg::LED) & 0b01111111;
|
||||
temp |= state ? 0x80 : 0x00;
|
||||
i2c->reg_write_uint8(address, reg::LED, temp);
|
||||
}
|
||||
|
||||
void AS7343::set_measurement_time(float measurement_time_ms) {
|
||||
constexpr float resolution = 2.78f;
|
||||
i2c->reg_write_uint8(address, reg::WTIME, (uint8_t)((measurement_time_ms - resolution) / resolution));
|
||||
}
|
||||
|
||||
void AS7343::set_integration_time(float integration_time_us, uint8_t repeat) {
|
||||
constexpr float resolution = 2.78f;
|
||||
constexpr float max_astep = (65534 + 1) * resolution;
|
||||
|
||||
if (integration_time_us <= max_astep) {
|
||||
i2c->reg_write_uint8(address, reg::ATIME, repeat - 1);
|
||||
i2c->reg_write_uint16(address, reg::ASTEP, (uint16_t)((integration_time_us - resolution) / resolution) & 0xfffe);
|
||||
} else {
|
||||
// Time out of range...
|
||||
}
|
||||
}
|
||||
|
||||
void AS7343::read_fifo(uint16_t *buf) {
|
||||
uint16_t expected_results = read_cycles * 7;
|
||||
uint16_t result_slot = 0;
|
||||
|
||||
while (i2c->reg_read_uint8(address, reg::FIFO_LVL) < expected_results) {
|
||||
sleep_ms(1);
|
||||
}
|
||||
|
||||
while (i2c->reg_read_uint8(address, reg::FIFO_LVL) > 0 && expected_results > 0) {
|
||||
buf[result_slot] = i2c->reg_read_uint16(address, reg::FDATA);
|
||||
expected_results--;
|
||||
result_slot++;
|
||||
}
|
||||
}
|
||||
|
||||
AS7343::reading AS7343::read() {
|
||||
reading result;
|
||||
read_fifo((uint16_t *)&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "hardware/i2c.h"
|
||||
#include "hardware/gpio.h"
|
||||
#include "common/pimoroni_common.hpp"
|
||||
#include "common/pimoroni_i2c.hpp"
|
||||
#include "as7343_regs.hpp"
|
||||
|
||||
namespace pimoroni {
|
||||
|
||||
class AS7343 {
|
||||
//--------------------------------------------------
|
||||
// Constants
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
static const uint8_t DEFAULT_I2C_ADDRESS = 0x39;
|
||||
|
||||
//--------------------------------------------------
|
||||
// Enums
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
enum class channel_count : uint8_t {
|
||||
SIX_CHANNEL = 6,
|
||||
TWELVE_CHANNEL = 12,
|
||||
EIGHTEEN_CHANNEL = 18
|
||||
};
|
||||
/*
|
||||
enum class COMPENSATION_GAIN : float {
|
||||
F1 = 1.84f,
|
||||
F2 = 6.03f,
|
||||
FZ = 4.88f,
|
||||
F3 = 13.74f,
|
||||
F4 = 3.37f,
|
||||
FY = 2.82f,
|
||||
F5 = 6.72f,
|
||||
FXL = 2.22f,
|
||||
F6 = 3.17f,
|
||||
F7 = 1.95f,
|
||||
F8 = 12.25f,
|
||||
NIR = 1.00f,
|
||||
};
|
||||
*/
|
||||
|
||||
//--------------------------------------------------
|
||||
// Substructures
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
struct reading {
|
||||
// Cycle 1
|
||||
uint16_t FZ = 0; // 428-480 nm
|
||||
uint16_t FY = 0; // 534-593 nm
|
||||
uint16_t FXL = 0; // 593-628 nm
|
||||
uint16_t NIR = 0; // 849-903 nm
|
||||
|
||||
uint16_t c1_vis_tl = 0; // Visible top-left
|
||||
uint16_t c1_vis_br = 0; // Visible bottom-right
|
||||
uint16_t c1_astatus = 0; // (c1_astatus >> 8) & 0b10001111
|
||||
// 0b10000000 = saturated
|
||||
// 0b00001111 = gain lowest nibble
|
||||
|
||||
// Cycle 2
|
||||
uint16_t F2 = 0; // 408-448 nm
|
||||
uint16_t F3 = 0; // 448-500 mn
|
||||
uint16_t F4 = 0; // 500-534 nm
|
||||
uint16_t F6 = 0; // 618-665 nm
|
||||
|
||||
uint16_t c2_vis_tl = 0;
|
||||
uint16_t c2_vis_br = 0;
|
||||
uint16_t c2_astatus = 0;
|
||||
|
||||
// Cycle 3
|
||||
uint16_t F1 = 0; // 396-408 nm
|
||||
uint16_t F5 = 0; // 531-594 nm
|
||||
uint16_t F7 = 0; // 685-715 nm
|
||||
uint16_t F8 = 0; // 715-766 nm
|
||||
|
||||
uint16_t c3_vis_tl = 0;
|
||||
uint16_t c3_vis_br = 0;
|
||||
uint16_t c3_astatus = 0;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Variables
|
||||
//--------------------------------------------------
|
||||
private:
|
||||
I2C *i2c;
|
||||
|
||||
// interface pins with our standard defaults where appropriate
|
||||
int8_t address = DEFAULT_I2C_ADDRESS;
|
||||
uint interrupt = PIN_UNUSED;
|
||||
|
||||
uint8_t read_cycles = 1;
|
||||
uint8_t ch_count = (uint8_t)channel_count::SIX_CHANNEL;
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Constructors/Destructor
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
AS7343(uint interrupt = PIN_UNUSED) : AS7343(new I2C(), interrupt) {};
|
||||
|
||||
AS7343(I2C *i2c, uint interrupt = PIN_UNUSED) : i2c(i2c), interrupt(interrupt) {}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Methods
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
bool init();
|
||||
void reset();
|
||||
|
||||
// For print access in micropython
|
||||
i2c_inst_t* get_i2c() const;
|
||||
int get_sda() const;
|
||||
int get_scl() const;
|
||||
int get_int() const;
|
||||
|
||||
void get_version(uint8_t &auxid, uint8_t &revid, uint8_t &hwid);
|
||||
|
||||
reading read();
|
||||
|
||||
void read_fifo(uint16_t *buf);
|
||||
|
||||
void set_gain(float gain);
|
||||
void set_illumination_current(float current);
|
||||
void set_illumination_led(bool state);
|
||||
void set_measurement_time(float measurement_time_ms);
|
||||
void set_integration_time(float integration_time_us, uint8_t repeat=1);
|
||||
|
||||
void set_channels(channel_count channel_count);
|
||||
|
||||
private:
|
||||
void bank_select(uint8_t bank=0);
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
namespace pimoroni {
|
||||
/***** Device registers and masks here *****/
|
||||
|
||||
enum reg {
|
||||
// Bank 1
|
||||
AUXID = 0x58, // AUXID = 0b00001111
|
||||
REVID = 0x59, // REVID = 0b00000111
|
||||
ID = 0x5A, // ID = 0b11111111
|
||||
CFG12 = 0x66, // SP_TH_CH = 0b00000111
|
||||
|
||||
// Bank 0
|
||||
ENABLE = 0x80, // FDEN = 0b01000000
|
||||
// SMUXEN = 0b00010000
|
||||
// WEN = 0b00001000
|
||||
// SP_EN = 0b00000010
|
||||
// PON = 0b00000001
|
||||
ATIME = 0x81, // ATIME = 0b11111111
|
||||
// Integration Time Step Size
|
||||
// 0 = 2.87us
|
||||
// n 2.87us x (n + 1)
|
||||
ASTEP = 0xD4, // STEP = 0xFFFF
|
||||
// Spectral Measurement Wait Time
|
||||
// 0 = 1 cycle = 2.78ms
|
||||
// n = 2.78ms x (n + 1)
|
||||
WTIME = 0x83, // WTIME = 0b11111111
|
||||
SP_TH = 0x84, // SP_TH_L = 0xFFFF0000 Spectral Low Threshold
|
||||
// SP_TH_H = 0x0000FFFF Spectral High Threshold
|
||||
STATUS = 0x93, // ASAT = 0b10000000 Spectral Saturation (if ASIEN set)
|
||||
// AINT = 0b00001000 Spectral Channel Interrupt (if SP_IEN set)
|
||||
// FINT = 0b00000100 FIFO Buffer Interrupt
|
||||
// SINT = 0b00000001 System Interrupt
|
||||
ASTATUS = 0x94,// ASAT = 0b10000000 Saturation Status
|
||||
// AGAIN = 0b00000111 Gain Status
|
||||
DATA = 0x95, // 36 bytes, fields 0 to 17 (2 bytes eac)
|
||||
STATUS2 = 0x90,// AVALID = 0b01000000 Spectral Data Valid
|
||||
// ASAT_DIG = 0b00010000 Digital Saturation
|
||||
// ASAT_ANA = 0b00001000 Analog Saturation
|
||||
// FDSAT_ANA= 0b00000010 Flicker Analog Saturation
|
||||
// FDSAT_DIG= 0b00000001 Flicker Digital Saturation
|
||||
STATUS3 = 0x91,// INT_SP_H = 0b00100000 Spectral Above High Threshold
|
||||
// INT_SP_L = 0b00010000 Spectral Below Low Threshold
|
||||
STATUS5 = 0xBB,// SINT_FD = 0b00001000 Flicker Detect Interrupt (if SIEN_FD set)
|
||||
// SINT_SMUX= 0b00000100 SMUS Operation Interrupt (SMUX exec finished)
|
||||
STATUS4 = 0xBC,// FIFO_OV = 0b10000000 FIFO Buffer Overflow
|
||||
// OVTEMP = 0b00100000 Over Temperature
|
||||
// FD_TRIG = 0b00010000 Flicker Detect Trigger Error
|
||||
// SD_TRIG = 0b00000100 Spectral Trigger Error
|
||||
// SAI_ACT = 0b00000010 Sleep After Interrupt Active
|
||||
// INT_BUSY = 0b00000001 Initialization busy (1 for ~300us after power on)
|
||||
CFG0 = 0xBF, // LOW_POWER= 0b00100000
|
||||
// REG_BANK = 0b00010000 0 - Register 0x80 and above
|
||||
// 1 - Register 0x20 to 0x7f
|
||||
// WLONG = 0b00000100 Increase WTIME by factor of 16
|
||||
// Spectral Engines Gain Setting
|
||||
// 0 = 0.5x, # 1 = 1x, 2 = 2x, 12 = 2048x
|
||||
// GAINx = 1 << (n - 1)
|
||||
CFG1 = 0xC6,
|
||||
CFG3 = 0xC7, // SAI = 0b00100000 Sleep after interrupt
|
||||
CFG6 = 0xF5, // SMUS_CMD = 0b00011000 0 - ROM_init
|
||||
// 1 - Read_SMUX
|
||||
// 2 - Write_SMUX
|
||||
CFG8 = 0xC9, // FIFO_TH = 0b11000000 0b00, 0b01, 0b10, 0b11
|
||||
CFG9 = 0xCA, // SIEN_FD = 0b01000000 System Interrupt Flicker Detection
|
||||
// SIEN_SMUX= 0b00010000 System Interrupt SMUX Operation
|
||||
CFG10 = 0x65, // FD_PERS = 0b00000111 Flicker Detect Persistence
|
||||
// Number of results that must differ before status change
|
||||
PERS = 0xCF, // APERS = 0b00001111
|
||||
GPIO = 0x6B, // GPIO_INV = 0b00001000 Invert GPIO output
|
||||
// GPIO_IN_EN=0b00000100 Enable GPIO input
|
||||
// GPIO_OUT = 0b00000010 GPIO Output
|
||||
// GPIO_IN = 0b00000001 GPIO Input
|
||||
CFG20 = 0xD6, // FD_FIFO_8b=0b10000000 Enable 8bit FIFO mode for Flicker Detect (FD_TIME < 256)
|
||||
// auto_SMUX= 0b01100000 Auto channel read-out
|
||||
LED = 0xCD, // LED_ACT = 0b10000000 External LED (LDR) Control
|
||||
// LED_DRIVE= 0b01111111 External LED drive strength (N - 4) >> 1
|
||||
// Flicker Detection AGC Gain Max
|
||||
// Max = 2^N (0 = 0.5x)
|
||||
AGC_GAIN_MAX = 0xD7, // ADC_FD_GAIN_MAX = 0b11110000
|
||||
AZ_CONFIG = 0xDE, // AT_NTH_ITERATION = 0b11111111 Auto-zero Frequency
|
||||
// 0 - Never (Not Recommended)
|
||||
// n - Every n integration cycles
|
||||
// 255 - only before first measurement cycle
|
||||
FD_TIME_1 = 0xE0, // FD_TIME=0b11111111 Flicker Detection Integration Time (Do not change if FDEN = 1 & PON = 1)
|
||||
FD_TIME_2 = 0xE2, // FD_GAIN=0b11111000 Flicker Detection Gain (0 = 0.5x, 1 = 1x, 2 = 2x, 12 = 2048x)
|
||||
// FD_TIME=0b00000111 Flicker Detection Time (Do not change if FDEN = 1 & PON = 1)
|
||||
FD_CFG0 = 0xDF, // FIFO_WRITE_FD = 0b10000000 Write flicker raw data to FIFO (1 byte per sample)
|
||||
FD_STATUS = 0xE3, // FD_VALID=0b00100000
|
||||
// FD_SAT = 0b00010000
|
||||
// FD_120HZ_VALID = 0b00001000
|
||||
// FD_100HZ_VALID = 0b00000100
|
||||
// FD_120HZ = 0b00000010
|
||||
// FD_100HZ = 0b00000001
|
||||
INTERNAB = 0xF9, // ASIEN = 0b10000000 Saturation Interrupt Enable
|
||||
// SP_IEN = 0b00001000 Spectral Interrupt Enable
|
||||
// FIEN = 0b00000100 FIFO Buffer Interrupt Enable
|
||||
// SIEN = 0b00000001 System Interrupt Enable
|
||||
CONTROL = 0xFA, // SW_RESET = 0b00001000 Software Reset
|
||||
// SP_MAN_AZ= 0b00000100 Spectral Manual Auto-zero
|
||||
// FIFO_CLR = 0b00000010 FIFO Buffer Clear
|
||||
// CLEAR_SAI_ACT = 0b00000001 Clear sleep-after-interrupt
|
||||
FIFO_MAP = 0xFC, // CH5 = 0b01000000
|
||||
// CH4 = 0b00100000
|
||||
// CH3 = 0b00010000
|
||||
// CH2 = 0b00001000
|
||||
// CH1 = 0b00000100
|
||||
// CH0 = 0b00000010
|
||||
// ASTATUS = 0b00000001
|
||||
FIFO_LVL = 0xFD,
|
||||
FDATA = 0xFE // 0xFFFF
|
||||
};
|
||||
|
||||
constexpr uint8_t HARDWARE_ID = 0b10000001;
|
||||
|
||||
constexpr uint8_t CFG0_LOW_POWER = 0b00100000;
|
||||
constexpr uint8_t CFG0_BANK = 0b00010000;
|
||||
constexpr uint8_t CFG0_WLONG = 0b00000100;
|
||||
|
||||
constexpr uint8_t CFG20_6_CH = 0b00000000;
|
||||
constexpr uint8_t CFG20_12_CH = 0b01000000;
|
||||
constexpr uint8_t CFG20_18_CH = 0b01100000;
|
||||
|
||||
constexpr uint8_t ENABLE_FDEN = 0b01000000;
|
||||
constexpr uint8_t ENABLE_SMUXEN = 0b00010000;
|
||||
constexpr uint8_t ENABLE_WEN = 0b00001000;
|
||||
constexpr uint8_t ENABLE_SP_EN = 0b00000010;
|
||||
constexpr uint8_t ENABLE_PON = 0b00000001;
|
||||
|
||||
constexpr uint8_t FD_CFG0_FIFO_WRITE = 0b10000000;
|
||||
|
||||
constexpr uint8_t FD_VALID = 0b00100000;
|
||||
constexpr uint8_t FD_SAT = 0b00010000;
|
||||
constexpr uint8_t FD_120HZ_VALID = 0b00001000;
|
||||
constexpr uint8_t FD_100HZ_VALID = 0b00000100;
|
||||
constexpr uint8_t FD_120HZ = 0b00000010;
|
||||
constexpr uint8_t FD_100HZ = 0b00000001;
|
||||
|
||||
constexpr uint8_t INTERNAB_ASIEN = 0b10000000;
|
||||
constexpr uint8_t INTERNAB_SP_IEN = 0b00001000;
|
||||
constexpr uint8_t INTERNAB_FIEN = 0b00000100;
|
||||
constexpr uint8_t INTERNAB_SIEN = 0b00000001;
|
||||
|
||||
constexpr uint8_t CONTROL_SW_RESET = 0b00001000;
|
||||
constexpr uint8_t CONTROL_SP_MAN_AZ = 0b00000100;
|
||||
constexpr uint8_t CONTROL_FIFO_CLR = 0b00000010;
|
||||
constexpr uint8_t CONTROL_CLEAR_SAI_ACT = 0b00000001;
|
||||
|
||||
constexpr uint8_t FIFO_MAP_CH5 = 0b01000000;
|
||||
constexpr uint8_t FIFO_MAP_CH4 = 0b00100000;
|
||||
constexpr uint8_t FIFO_MAP_CH3 = 0b00010000;
|
||||
constexpr uint8_t FIFO_MAP_CH2 = 0b00001000;
|
||||
constexpr uint8_t FIFO_MAP_CH1 = 0b00000100;
|
||||
constexpr uint8_t FIFO_MAP_CH0 = 0b00000010;
|
||||
constexpr uint8_t FIFO_MAP_ASTATUS = 0b00000001;
|
||||
}
|
|
@ -19,6 +19,7 @@ add_subdirectory(breakout_bme688)
|
|||
add_subdirectory(breakout_bmp280)
|
||||
add_subdirectory(breakout_bme280)
|
||||
add_subdirectory(breakout_as7262)
|
||||
add_subdirectory(as7343)
|
||||
add_subdirectory(breakout_bh1745)
|
||||
add_subdirectory(breakout_icp10125)
|
||||
add_subdirectory(breakout_scd41)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
include("${CMAKE_CURRENT_LIST_DIR}/as7343_demo.cmake")
|
|
@ -0,0 +1,16 @@
|
|||
set(OUTPUT_NAME as7343_demo)
|
||||
|
||||
add_executable(
|
||||
${OUTPUT_NAME}
|
||||
as7343_demo.cpp
|
||||
)
|
||||
|
||||
# enable usb output, disable uart output
|
||||
pico_enable_stdio_usb(${OUTPUT_NAME} 1)
|
||||
pico_enable_stdio_uart(${OUTPUT_NAME} 1)
|
||||
|
||||
# Pull in pico libraries that we need
|
||||
target_link_libraries(${OUTPUT_NAME} pico_stdlib as7343)
|
||||
|
||||
# create map/bin/hex file etc.
|
||||
pico_add_extra_outputs(${OUTPUT_NAME})
|
|
@ -0,0 +1,69 @@
|
|||
#include "pico/stdlib.h"
|
||||
#include "common/pimoroni_common.hpp"
|
||||
|
||||
#include "as7343.hpp"
|
||||
|
||||
using namespace pimoroni;
|
||||
|
||||
I2C i2c(6, 7);
|
||||
AS7343 as7343(&i2c);
|
||||
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
|
||||
printf("AS7343 Demo\n");
|
||||
as7343.init();
|
||||
printf("Init done...\n");
|
||||
|
||||
uint8_t aux_id;
|
||||
uint8_t revision_id;
|
||||
uint8_t hardware_id;
|
||||
|
||||
as7343.get_version(aux_id, revision_id, hardware_id);
|
||||
|
||||
printf("Aux: %d, Rev: %d, HW: %d\n", aux_id, revision_id, hardware_id);
|
||||
|
||||
printf("set_channels\n");
|
||||
as7343.set_channels(AS7343::channel_count::EIGHTEEN_CHANNEL);
|
||||
|
||||
printf("set_gain\n");
|
||||
as7343.set_gain(1024);
|
||||
|
||||
printf("set_measurement_time\n");
|
||||
as7343.set_measurement_time(500);
|
||||
|
||||
printf("set_integration_time\n");
|
||||
as7343.set_integration_time(27800);
|
||||
|
||||
printf("set_illumination_current\n");
|
||||
as7343.set_illumination_current(4);
|
||||
|
||||
printf("set_illumination_led\n");
|
||||
as7343.set_illumination_led(true);
|
||||
|
||||
printf("start...\n");
|
||||
while(true) {
|
||||
|
||||
AS7343::reading reading = as7343.read();
|
||||
printf("FZ: %d FY: %d FXL: %d NIR: %d F2 %d F3: %d F4: %d F5: %d F1: %d F5: %d F7: %d F8: %d \n",
|
||||
reading.FZ,
|
||||
reading.FY,
|
||||
reading.FXL,
|
||||
reading.NIR,
|
||||
|
||||
reading.F2,
|
||||
reading.F3,
|
||||
reading.F4,
|
||||
reading.F6,
|
||||
|
||||
reading.F1,
|
||||
reading.F5,
|
||||
reading.F7,
|
||||
reading.F8
|
||||
);
|
||||
|
||||
sleep_ms(1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
from picographics import PicoGraphics, DISPLAY_TUFTY_2040, PEN_P4
|
||||
from breakout_as7343 import BreakoutAS7343
|
||||
from pimoroni_i2c import PimoroniI2C
|
||||
|
||||
|
||||
display = PicoGraphics(DISPLAY_TUFTY_2040, pen_type=PEN_P4, rotate=90)
|
||||
|
||||
WIDTH, HEIGHT = display.get_bounds()
|
||||
|
||||
BLACK = display.create_pen(0, 0, 0)
|
||||
|
||||
FZ = display.create_pen(0, 0, 128)
|
||||
FY = display.create_pen(0, 255, 0)
|
||||
FXL = display.create_pen(255, 128, 0)
|
||||
NIR = display.create_pen(128, 0, 0)
|
||||
F2 = display.create_pen(128, 0, 128)
|
||||
F3 = display.create_pen(0, 0, 255)
|
||||
F4 = display.create_pen(0, 128, 255)
|
||||
F6 = display.create_pen(128, 64, 0)
|
||||
|
||||
F1 = display.create_pen(196, 0, 196)
|
||||
F5 = display.create_pen(64, 255, 64)
|
||||
F7 = display.create_pen(255, 0, 0)
|
||||
F8 = display.create_pen(196, 0, 0)
|
||||
|
||||
WHITE = display.create_pen(255, 255, 255)
|
||||
|
||||
i2c = PimoroniI2C(sda=4, scl=5)
|
||||
as7343 = BreakoutAS7343(i2c)
|
||||
|
||||
as7343.set_channels(18)
|
||||
as7343.set_gain(1024)
|
||||
as7343.set_measurement_time(33) # Roughly 30fps at 16ms/measurement
|
||||
as7343.set_integration_time(27800)
|
||||
|
||||
as7343.set_illumination_current(4)
|
||||
as7343.set_illumination_led(True)
|
||||
|
||||
|
||||
BAR_WIDTH = 18
|
||||
BAR_SPACING = 4
|
||||
MARGIN = display.measure_text("NIR") + 2
|
||||
BAR_HEIGHT = WIDTH - MARGIN
|
||||
|
||||
OFFSET_LEFT = int((HEIGHT - ((BAR_WIDTH + BAR_SPACING) * 12)) / 2)
|
||||
|
||||
# Satrting max values for auto-ranging
|
||||
# From figure 8 of the datasheet
|
||||
MAX_VALUES = [
|
||||
2711,
|
||||
4684,
|
||||
5970,
|
||||
13226,
|
||||
2371,
|
||||
962,
|
||||
3926,
|
||||
4170,
|
||||
7760,
|
||||
1967,
|
||||
6774,
|
||||
1166
|
||||
]
|
||||
|
||||
LABELS = [
|
||||
"FZ",
|
||||
"FY",
|
||||
"FXL",
|
||||
"NIR",
|
||||
"F2",
|
||||
"F3",
|
||||
"F4",
|
||||
"F6",
|
||||
"F1",
|
||||
"F5",
|
||||
"F7",
|
||||
"F8"
|
||||
]
|
||||
|
||||
|
||||
while True:
|
||||
display.set_pen(0)
|
||||
display.clear()
|
||||
readings = as7343.read()
|
||||
for i, reading in enumerate(readings):
|
||||
MAX_VALUES[i] = max(reading, MAX_VALUES[i])
|
||||
scaled = int(reading / MAX_VALUES[i] * BAR_HEIGHT)
|
||||
|
||||
y = i * (BAR_WIDTH + BAR_SPACING)
|
||||
y += OFFSET_LEFT
|
||||
|
||||
display.set_pen(i + 1)
|
||||
display.rectangle(MARGIN, y, scaled, BAR_WIDTH)
|
||||
|
||||
display.set_pen(WHITE)
|
||||
display.text(LABELS[i], 0, y + 1)
|
||||
|
||||
display.update()
|
|
@ -0,0 +1,79 @@
|
|||
#include "breakout_as7343.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BreakoutAS7343 Class
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/***** Methods *****/
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutAS7343_reset_obj, BreakoutAS7343_reset);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutAS7343_version_obj, BreakoutAS7343_version);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutAS7343_read_obj, BreakoutAS7343_read);
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutAS7343_set_gain_obj, BreakoutAS7343_set_gain);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutAS7343_set_integration_time_obj, BreakoutAS7343_set_integration_time);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutAS7343_set_measurement_time_obj, BreakoutAS7343_set_measurement_time);
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutAS7343_set_illumination_current_obj, BreakoutAS7343_set_illumination_current);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutAS7343_set_illumination_led_obj, BreakoutAS7343_set_illumination_led);
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutAS7343_set_channels_obj, BreakoutAS7343_set_channels);
|
||||
|
||||
/***** Binding of Methods *****/
|
||||
STATIC const mp_rom_map_elem_t BreakoutAS7343_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&BreakoutAS7343_reset_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_version), MP_ROM_PTR(&BreakoutAS7343_version_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&BreakoutAS7343_read_obj) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_set_gain), MP_ROM_PTR(&BreakoutAS7343_set_gain_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_set_measurement_time), MP_ROM_PTR(&BreakoutAS7343_set_measurement_time_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_set_integration_time), MP_ROM_PTR(&BreakoutAS7343_set_integration_time_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_set_illumination_current), MP_ROM_PTR(&BreakoutAS7343_set_illumination_current_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_set_illumination_led), MP_ROM_PTR(&BreakoutAS7343_set_illumination_led_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_set_channels), MP_ROM_PTR(&BreakoutAS7343_set_channels_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(BreakoutAS7343_locals_dict, BreakoutAS7343_locals_dict_table);
|
||||
|
||||
/***** Class Definition *****/
|
||||
#ifdef MP_DEFINE_CONST_OBJ_TYPE
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
breakout_as7343_BreakoutAS7343_type,
|
||||
MP_QSTR_BreakoutAS7343,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
make_new, BreakoutAS7343_make_new,
|
||||
locals_dict, (mp_obj_dict_t*)&BreakoutAS7343_locals_dict
|
||||
);
|
||||
#else
|
||||
const mp_obj_type_t breakout_as7343_BreakoutAS7343_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_BreakoutAS7343,
|
||||
.make_new = BreakoutAS7343_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&BreakoutAS7343_locals_dict,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// breakout_as7343 Module
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/***** Globals Table *****/
|
||||
STATIC const mp_map_elem_t breakout_as7343_globals_table[] = {
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_breakout_as7343) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_BreakoutAS7343), (mp_obj_t)&breakout_as7343_BreakoutAS7343_type },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(mp_module_breakout_as7343_globals, breakout_as7343_globals_table);
|
||||
|
||||
/***** Module Definition *****/
|
||||
const mp_obj_module_t breakout_as7343_user_cmodule = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t*)&mp_module_breakout_as7343_globals,
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if MICROPY_VERSION <= 70144
|
||||
MP_REGISTER_MODULE(MP_QSTR_breakout_as7343, breakout_as7343_user_cmodule, MODULE_BREAKOUT_AS7343_ENABLED);
|
||||
#else
|
||||
MP_REGISTER_MODULE(MP_QSTR_breakout_as7343, breakout_as7343_user_cmodule);
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,140 @@
|
|||
#include "drivers/as7343/as7343.hpp"
|
||||
#include "common/pimoroni_i2c.hpp"
|
||||
#include "micropython/modules/util.hpp"
|
||||
|
||||
|
||||
using namespace pimoroni;
|
||||
|
||||
extern "C" {
|
||||
#include "breakout_as7343.h"
|
||||
#include "pimoroni_i2c.h"
|
||||
|
||||
/***** Variables Struct *****/
|
||||
typedef struct _breakout_as7343_BreakoutAS7343_obj_t {
|
||||
mp_obj_base_t base;
|
||||
AS7343 *breakout;
|
||||
_PimoroniI2C_obj_t *i2c;
|
||||
} breakout_as7343_BreakoutAS7343_obj_t;
|
||||
|
||||
|
||||
|
||||
/***** Constructor *****/
|
||||
mp_obj_t BreakoutAS7343_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||
breakout_as7343_BreakoutAS7343_obj_t *self = nullptr;
|
||||
|
||||
enum { ARG_i2c, ARG_int };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_i2c, MP_ARG_OBJ, {.u_obj = nullptr} },
|
||||
{ MP_QSTR_interrupt, MP_ARG_INT, {.u_int = PIN_UNUSED} },
|
||||
};
|
||||
|
||||
// Parse args.
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
self = m_new_obj(breakout_as7343_BreakoutAS7343_obj_t);
|
||||
self->base.type = &breakout_as7343_BreakoutAS7343_type;
|
||||
|
||||
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
|
||||
|
||||
self->breakout = m_new_class(AS7343, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_int].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutAS7343: breakout not found when initialising");
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
/***** Methods *****/
|
||||
mp_obj_t BreakoutAS7343_reset(mp_obj_t self_in) {
|
||||
breakout_as7343_BreakoutAS7343_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_as7343_BreakoutAS7343_obj_t);
|
||||
self->breakout->reset();
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutAS7343_version(mp_obj_t self_in) {
|
||||
breakout_as7343_BreakoutAS7343_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_as7343_BreakoutAS7343_obj_t);
|
||||
|
||||
uint8_t aux_id, revision_id, hardware_id;
|
||||
self->breakout->get_version(aux_id, revision_id, hardware_id);
|
||||
|
||||
mp_obj_t tuple[3];
|
||||
tuple[0] = mp_obj_new_int(aux_id);
|
||||
tuple[1] = mp_obj_new_int(revision_id);
|
||||
tuple[2] = mp_obj_new_int(hardware_id);
|
||||
return mp_obj_new_tuple(3, tuple);
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutAS7343_read(mp_obj_t self_in) {
|
||||
breakout_as7343_BreakoutAS7343_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_as7343_BreakoutAS7343_obj_t);
|
||||
AS7343::reading reading = self->breakout->read();
|
||||
|
||||
mp_obj_t tuple[12];
|
||||
tuple[0] = mp_obj_new_float(reading.FZ);
|
||||
tuple[1] = mp_obj_new_float(reading.FY);
|
||||
tuple[2] = mp_obj_new_float(reading.FXL);
|
||||
tuple[3] = mp_obj_new_float(reading.NIR);
|
||||
|
||||
tuple[4] = mp_obj_new_float(reading.F2);
|
||||
tuple[5] = mp_obj_new_float(reading.F3);
|
||||
tuple[6] = mp_obj_new_float(reading.F4);
|
||||
tuple[7] = mp_obj_new_float(reading.F6);
|
||||
|
||||
tuple[8] = mp_obj_new_float(reading.F1);
|
||||
tuple[9] = mp_obj_new_float(reading.F5);
|
||||
tuple[10] = mp_obj_new_float(reading.F7);
|
||||
tuple[11] = mp_obj_new_float(reading.F8);
|
||||
|
||||
return mp_obj_new_tuple(12, tuple);
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutAS7343_set_gain(mp_obj_t self_in, mp_obj_t value_in) {
|
||||
breakout_as7343_BreakoutAS7343_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_as7343_BreakoutAS7343_obj_t);
|
||||
|
||||
self->breakout->set_gain(mp_obj_get_int(value_in));
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutAS7343_set_measurement_time(mp_obj_t self_in, mp_obj_t value_in) {
|
||||
breakout_as7343_BreakoutAS7343_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_as7343_BreakoutAS7343_obj_t);
|
||||
|
||||
self->breakout->set_measurement_time(mp_obj_get_float(value_in));
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutAS7343_set_integration_time(mp_obj_t self_in, mp_obj_t value_in) {
|
||||
breakout_as7343_BreakoutAS7343_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_as7343_BreakoutAS7343_obj_t);
|
||||
|
||||
self->breakout->set_integration_time(mp_obj_get_float(value_in));
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutAS7343_set_illumination_current(mp_obj_t self_in, mp_obj_t value_in) {
|
||||
breakout_as7343_BreakoutAS7343_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_as7343_BreakoutAS7343_obj_t);
|
||||
|
||||
self->breakout->set_illumination_current(mp_obj_get_int(value_in));
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutAS7343_set_illumination_led(mp_obj_t self_in, mp_obj_t value_in) {
|
||||
breakout_as7343_BreakoutAS7343_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_as7343_BreakoutAS7343_obj_t);
|
||||
|
||||
self->breakout->set_illumination_led(value_in == mp_const_true);
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutAS7343_set_channels(mp_obj_t self_in, mp_obj_t value_in) {
|
||||
breakout_as7343_BreakoutAS7343_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_as7343_BreakoutAS7343_obj_t);
|
||||
|
||||
self->breakout->set_channels((AS7343::channel_count)mp_obj_get_int(value_in));
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
// Include MicroPython API.
|
||||
#include "py/runtime.h"
|
||||
|
||||
/***** Constants *****/
|
||||
|
||||
|
||||
/***** Extern of Class Definition *****/
|
||||
extern const mp_obj_type_t breakout_as7343_BreakoutAS7343_type;
|
||||
|
||||
/***** Extern of Class Methods *****/
|
||||
extern mp_obj_t BreakoutAS7343_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
|
||||
extern mp_obj_t BreakoutAS7343_reset(mp_obj_t self_in);
|
||||
extern mp_obj_t BreakoutAS7343_version(mp_obj_t self_in);
|
||||
extern mp_obj_t BreakoutAS7343_read(mp_obj_t self_in);
|
||||
|
||||
extern mp_obj_t BreakoutAS7343_set_gain(mp_obj_t self_in, mp_obj_t value_in);
|
||||
extern mp_obj_t BreakoutAS7343_set_measurement_time(mp_obj_t self_in, mp_obj_t value_in);
|
||||
extern mp_obj_t BreakoutAS7343_set_integration_time(mp_obj_t self_in, mp_obj_t value_in);
|
||||
|
||||
extern mp_obj_t BreakoutAS7343_set_illumination_current(mp_obj_t self_in, mp_obj_t value_in);
|
||||
extern mp_obj_t BreakoutAS7343_set_illumination_led(mp_obj_t self_in, mp_obj_t value_in);
|
||||
|
||||
extern mp_obj_t BreakoutAS7343_set_channels(mp_obj_t self_in, mp_obj_t value_in);
|
|
@ -0,0 +1,19 @@
|
|||
set(MOD_NAME breakout_as7343)
|
||||
string(TOUPPER ${MOD_NAME} MOD_NAME_UPPER)
|
||||
add_library(usermod_${MOD_NAME} INTERFACE)
|
||||
|
||||
target_sources(usermod_${MOD_NAME} INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/${MOD_NAME}.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/${MOD_NAME}.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../../drivers/as7343/as7343.cpp
|
||||
)
|
||||
|
||||
target_include_directories(usermod_${MOD_NAME} INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(usermod_${MOD_NAME} INTERFACE
|
||||
-DMODULE_${MOD_NAME_UPPER}_ENABLED=1
|
||||
)
|
||||
|
||||
target_link_libraries(usermod INTERFACE usermod_${MOD_NAME})
|
|
@ -4,6 +4,7 @@ include(breakout_encoder_wheel/micropython)
|
|||
include(breakout_ioexpander/micropython)
|
||||
include(breakout_ltr559/micropython)
|
||||
include(breakout_as7262/micropython)
|
||||
include(breakout_as7343/micropython)
|
||||
include(breakout_rgbmatrix5x5/micropython)
|
||||
include(breakout_matrix11x7/micropython)
|
||||
include(breakout_msa301/micropython)
|
||||
|
|
Loading…
Reference in New Issue