2019-11-30 08:37:53 -05:00
|
|
|
//
|
|
|
|
// FILE: demo_dual1.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: demo 2 I2C 4x7segment displays one uint32_t unsigned long
|
|
|
|
// URL: http://www.adafruit.com/products/1002
|
2020-07-16 05:08:25 -04:00
|
|
|
// URL: https://github.com/RobTillaart/HT16K33
|
2019-11-30 08:37:53 -05:00
|
|
|
|
2021-05-26 09:01:19 -04:00
|
|
|
|
2019-11-30 08:37:53 -05:00
|
|
|
#include "HT16K33.h"
|
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
HT16K33 left(0x71);
|
|
|
|
HT16K33 right(0x70);
|
2019-11-30 08:37:53 -05:00
|
|
|
|
|
|
|
uint32_t counter = 0;
|
|
|
|
|
2021-05-26 09:01:19 -04:00
|
|
|
|
2019-11-30 08:37:53 -05:00
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println(__FILE__);
|
|
|
|
|
2020-07-16 05:08:25 -04:00
|
|
|
left.begin();
|
|
|
|
right.begin();
|
2020-11-27 05:16:22 -05:00
|
|
|
|
2019-11-30 08:37:53 -05:00
|
|
|
Wire.setClock(100000);
|
|
|
|
|
|
|
|
left.displayOn();
|
|
|
|
right.displayOn();
|
2020-11-27 05:16:22 -05:00
|
|
|
|
2019-11-30 08:37:53 -05:00
|
|
|
Serial.println("dual displayTest");
|
|
|
|
}
|
|
|
|
|
2021-05-26 09:01:19 -04:00
|
|
|
|
2019-11-30 08:37:53 -05:00
|
|
|
void loop()
|
|
|
|
{
|
2020-11-27 05:16:22 -05:00
|
|
|
display_ulong(counter);
|
2019-11-30 08:37:53 -05:00
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
delay(1);
|
2019-11-30 08:37:53 -05:00
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
|
2021-05-26 09:01:19 -04:00
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
void display_ulong(uint32_t value)
|
|
|
|
{
|
|
|
|
uint16_t lval = value / 10000;
|
|
|
|
uint16_t rval = value % 10000;
|
|
|
|
|
|
|
|
// left show no digit if not needed
|
2021-12-19 09:24:23 -05:00
|
|
|
left.setDigits(0);
|
2020-11-27 05:16:22 -05:00
|
|
|
// right show at least 1 digit if value < 10000, otherwise leading zero's needed
|
2021-12-19 09:24:23 -05:00
|
|
|
right.setDigits(lval > 0 ? 4 : 0);
|
2020-11-27 05:16:22 -05:00
|
|
|
|
|
|
|
left.displayInt(lval);
|
|
|
|
right.displayInt(rval);
|
|
|
|
}
|
|
|
|
|
2021-12-19 09:24:23 -05:00
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
// -- END OF FILE --
|
2021-12-19 09:24:23 -05:00
|
|
|
|