GY-63_MS5611/libraries/HT16K33/examples/demo_dual1/demo_dual1.ino
2021-05-26 15:01:19 +02:00

59 lines
982 B
C++

//
// FILE: demo_dual1.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.2.0
// PURPOSE: demo 2 I2C 4x7segment displays one uint32_t unsigned long
// URL: http://www.adafruit.com/products/1002
// URL: https://github.com/RobTillaart/HT16K33
#include "HT16K33.h"
HT16K33 left(0x71);
HT16K33 right(0x70);
uint32_t counter = 0;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
left.begin();
right.begin();
Wire.setClock(100000);
left.displayOn();
right.displayOn();
Serial.println("dual displayTest");
}
void loop()
{
display_ulong(counter);
delay(1);
counter++;
}
void display_ulong(uint32_t value)
{
uint16_t lval = value / 10000;
uint16_t rval = value % 10000;
// left show no digit if not needed
left.setDigits(0);
// right show at least 1 digit if value < 10000, otherwise leading zero's needed
right.setDigits(lval > 0 ? 4 : 0);
left.displayInt(lval);
right.displayInt(rval);
}
// -- END OF FILE --