add : ajoute la bibliothèque GazDisplay pour afficher sur LCD
This commit is contained in:
parent
cca20d6d1a
commit
5553c6d13e
2 changed files with 78 additions and 0 deletions
57
lib/GazDisplay/GazDisplay.cpp
Normal file
57
lib/GazDisplay/GazDisplay.cpp
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
#include "GazDisplay.h"
|
||||||
|
|
||||||
|
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST);
|
||||||
|
|
||||||
|
DisplayError displayInit()
|
||||||
|
{
|
||||||
|
if (OLED_RST >= 0)
|
||||||
|
{
|
||||||
|
pinMode(OLED_RST, OUTPUT);
|
||||||
|
digitalWrite(OLED_RST, LOW);
|
||||||
|
delay(20);
|
||||||
|
digitalWrite(OLED_RST, HIGH);
|
||||||
|
}
|
||||||
|
Wire.begin(OLED_SDA, OLED_SCL);
|
||||||
|
|
||||||
|
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))
|
||||||
|
{
|
||||||
|
Serial.println("[OLED] Ecran non détecté !");
|
||||||
|
return DisplayError::INIT_FAILED;
|
||||||
|
}
|
||||||
|
display.clearDisplay();
|
||||||
|
display.display();
|
||||||
|
|
||||||
|
return DisplayError::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void displayGasIndex(uint32_t pulses)
|
||||||
|
{
|
||||||
|
float indexM3 = pulses * 0.010f;
|
||||||
|
|
||||||
|
display.clearDisplay();
|
||||||
|
|
||||||
|
// Titre
|
||||||
|
display.setTextSize(1);
|
||||||
|
display.setTextColor(SSD1306_WHITE);
|
||||||
|
display.setCursor(0, 0);
|
||||||
|
display.println("Index gaz");
|
||||||
|
|
||||||
|
// Ligne
|
||||||
|
display.drawLine(0, 10, 128, 10, SSD1306_WHITE);
|
||||||
|
|
||||||
|
// Valeur en grand
|
||||||
|
display.setTextSize(2);
|
||||||
|
display.setCursor(0, 18);
|
||||||
|
display.printf("%.3f", indexM3);
|
||||||
|
|
||||||
|
// Unité
|
||||||
|
display.setTextSize(1);
|
||||||
|
display.setCursor(112, 25);
|
||||||
|
display.println("m3");
|
||||||
|
|
||||||
|
// Impulsions en petit
|
||||||
|
display.setCursor(0, 54);
|
||||||
|
display.printf("Impulsions : %lu", pulses);
|
||||||
|
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
21
lib/GazDisplay/GazDisplay.h
Normal file
21
lib/GazDisplay/GazDisplay.h
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Wire.h>
|
||||||
|
#include <Adafruit_GFX.h>
|
||||||
|
#include <Adafruit_SSD1306.h>
|
||||||
|
|
||||||
|
#define OLED_SDA 21
|
||||||
|
#define OLED_SCL 22
|
||||||
|
#define OLED_RST -1
|
||||||
|
|
||||||
|
#define SCREEN_WIDTH 128
|
||||||
|
#define SCREEN_HEIGHT 64
|
||||||
|
|
||||||
|
enum class DisplayError : int16_t {
|
||||||
|
OK = 0,
|
||||||
|
INIT_FAILED = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
DisplayError displayInit();
|
||||||
|
void displayGasIndex(uint32_t pulses);
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue