Fix MICS6814 heater enable, improve demo

pull/144/head
Phil Howard 2021-05-12 20:16:42 +01:00
rodzic 4b850b9290
commit fd3ef973b6
3 zmienionych plików z 11 dodań i 6 usunięć

Wyświetl plik

@ -38,6 +38,7 @@ namespace pimoroni {
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_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_ADC = PIN_MODE_ADC; // 0b01010

Wyświetl plik

@ -1,21 +1,25 @@
#include "pico/stdlib.h"
#include "stdio.h"
#include "breakout_mics6814.hpp"
using namespace pimoroni;
BreakoutMICS6814 ioe;
BreakoutMICS6814 mics6814;
int main() {
stdio_init_all();
gpio_init(PICO_DEFAULT_LED_PIN);
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) {
gpio_put(PICO_DEFAULT_LED_PIN, true);
sleep_ms(1000);
gpio_put(PICO_DEFAULT_LED_PIN, false);
BreakoutMICS6814::Reading reading = mics6814.read_all();
printf("OX: %f Red: %f NH3: %f\n", reading.oxidising, reading.reducing, reading.nh3);
sleep_ms(1000);
}

Wyświetl plik

@ -12,7 +12,7 @@ namespace pimoroni {
ioe.set_mode(MICS_NH3, 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);
// Calculate a period large enough to get 0-255 steps at the desired brightness