kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Fix MICS6814 heater enable, improve demo
rodzic
4b850b9290
commit
fd3ef973b6
|
@ -38,6 +38,7 @@ namespace pimoroni {
|
||||||
static const uint8_t PIN_IN_PULL_UP = PIN_MODE_PU; // 0b10000
|
static const uint8_t PIN_IN_PULL_UP = PIN_MODE_PU; // 0b10000
|
||||||
static const uint8_t PIN_IN_PU = PIN_MODE_PU; // 0b10000
|
static const uint8_t PIN_IN_PU = PIN_MODE_PU; // 0b10000
|
||||||
static const uint8_t PIN_OUT = PIN_MODE_PP; // 0b00001
|
static const uint8_t PIN_OUT = PIN_MODE_PP; // 0b00001
|
||||||
|
static const uint8_t PIN_OD = PIN_MODE_OD; // 0b00001
|
||||||
static const uint8_t PIN_PWM = PIN_MODE_PWM; // 0b00101
|
static const uint8_t PIN_PWM = PIN_MODE_PWM; // 0b00101
|
||||||
static const uint8_t PIN_ADC = PIN_MODE_ADC; // 0b01010
|
static const uint8_t PIN_ADC = PIN_MODE_ADC; // 0b01010
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,25 @@
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
|
#include "stdio.h"
|
||||||
|
|
||||||
#include "breakout_mics6814.hpp"
|
#include "breakout_mics6814.hpp"
|
||||||
|
|
||||||
using namespace pimoroni;
|
using namespace pimoroni;
|
||||||
|
|
||||||
BreakoutMICS6814 ioe;
|
BreakoutMICS6814 mics6814;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
stdio_init_all();
|
||||||
|
|
||||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
|
||||||
|
|
||||||
ioe.init();
|
mics6814.init();
|
||||||
|
mics6814.set_heater(true);
|
||||||
|
mics6814.set_led(0, 0, 255);
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, true);
|
BreakoutMICS6814::Reading reading = mics6814.read_all();
|
||||||
sleep_ms(1000);
|
printf("OX: %f Red: %f NH3: %f\n", reading.oxidising, reading.reducing, reading.nh3);
|
||||||
gpio_put(PICO_DEFAULT_LED_PIN, false);
|
|
||||||
sleep_ms(1000);
|
sleep_ms(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace pimoroni {
|
||||||
ioe.set_mode(MICS_NH3, IOExpander::PIN_ADC);
|
ioe.set_mode(MICS_NH3, IOExpander::PIN_ADC);
|
||||||
ioe.set_mode(MICS_OX, IOExpander::PIN_ADC);
|
ioe.set_mode(MICS_OX, IOExpander::PIN_ADC);
|
||||||
|
|
||||||
ioe.set_mode(MICS_HEATER_EN, IOExpander::PIN_OUT);
|
ioe.set_mode(MICS_HEATER_EN, IOExpander::PIN_OD);
|
||||||
ioe.output(MICS_HEATER_EN, IOExpander::LOW);
|
ioe.output(MICS_HEATER_EN, IOExpander::LOW);
|
||||||
|
|
||||||
// Calculate a period large enough to get 0-255 steps at the desired brightness
|
// Calculate a period large enough to get 0-255 steps at the desired brightness
|
||||||
|
|
Ładowanie…
Reference in New Issue