GY-63_MS5611/libraries/HT16K33/HT16K33.h

84 lines
2.4 KiB
C
Raw Normal View History

2020-07-17 06:34:54 -04:00
#pragma once
//
// FILE: HT16K33.h
// AUTHOR: Rob Tillaart
2020-11-27 05:16:22 -05:00
// VERSION: 0.3.0
// DATE: 2019-02-07
2020-07-17 06:34:54 -04:00
// PURPOSE: Arduino Library for HT16K33 4x7segment display
// http://www.adafruit.com/products/1002
2020-07-17 06:34:54 -04:00
// URL: https://github.com/RobTillaart/HT16K33.git
//
#include "Arduino.h"
#include "Wire.h"
2020-11-27 05:16:22 -05:00
#define HT16K33_LIB_VERSION "0.3.0"
class HT16K33
{
2020-07-17 06:34:54 -04:00
public:
HT16K33(const uint8_t address); // 0x70 .. 0x77
#if defined (ESP8266) || defined(ESP32)
void begin(uint8_t sda, uint8_t scl);
#endif
void begin();
void reset();
2020-11-27 05:16:22 -05:00
// default _cache is true as it is ~3x faster but if one has noise
// on the I2C and wants to force refresh one can disable caching
// for one or more calls.
void clearCache();
void cacheOn() { _cache = true; };
void cacheOff() { _cache = false; };
void displayOn();
void displayOff();
2020-07-17 06:34:54 -04:00
void brightness(uint8_t val); // 0 .. 15
void blink(uint8_t val); // 0 .. 3 0 = off
2020-07-17 06:34:54 -04:00
2020-11-27 05:16:22 -05:00
// 0,1,2,3,4 digits - will replace suppressLeadingZeroPlaces
void setDigits(uint8_t val);
2020-07-17 06:34:54 -04:00
// 0 = off, 1,2,3,4 digits space iso 0
2020-11-27 05:16:22 -05:00
void suppressLeadingZeroPlaces(uint8_t val); // will be obsolete
void displayClear();
2020-11-27 05:16:22 -05:00
void displayInt(int n); // -999 .. 9999
void displayHex(uint16_t n); // 0000 .. FFFF
2020-11-27 05:16:22 -05:00
// Date could be {month.day} or {day.hour} . as separator
// Time could be hh:mm or mm:ss or ss:uu (hundreds : as separator
//
void displayDate(uint8_t left, uint8_t right); // 00.00 .. 99.99
void displayTime(uint8_t left, uint8_t right); // 00:00 .. 99:99
2020-11-27 05:16:22 -05:00
void displayFloat(float f); // -999 .. 0.000 .. 9999
2020-07-17 06:34:54 -04:00
void display(uint8_t *arr); // array with 4 elements
void display(uint8_t *arr, uint8_t pt); // pt = digit with . (0..3)
void displayColon(uint8_t on); // 0 = off
2020-11-27 05:16:22 -05:00
void displayRaw(uint8_t *arr, bool colon = false); // max control
2020-07-17 06:34:54 -04:00
void displayVULeft(uint8_t val); // 0..8
void displayVURight(uint8_t val); // 0..8
2020-11-27 05:16:22 -05:00
// DEBUG
void displayTest(uint8_t del);
void dumpSerial(uint8_t *arr, uint8_t pnt);
2020-07-17 06:34:54 -04:00
private:
void writeCmd(uint8_t cmd);
void writePos(uint8_t pos, uint8_t mask);
void writePos(uint8_t pos, uint8_t mask, bool pnt);
uint8_t _addr;
uint8_t _displayCache[5]; // for performance
2020-11-27 05:16:22 -05:00
bool _cache = true;
uint8_t _digits = 0;
2020-07-17 06:34:54 -04:00
uint8_t _bright;
};
2020-07-17 06:34:54 -04:00
// -- END OF FILE --