diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c5edde..8884a22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.4.1] - 2024-01-04 +- add constants for individual segments +- add + + ## [0.4.0] - 2023-12-05 - refactor API, begin() - update readme.md diff --git a/HT16K33.cpp b/HT16K33.cpp index 6275ff0..7f6cb09 100644 --- a/HT16K33.cpp +++ b/HT16K33.cpp @@ -1,7 +1,7 @@ // // FILE: HT16K33.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.4.0 +// VERSION: 0.4.1 // DATE: 2019-02-07 // PURPOSE: Arduino Library for HT16K33 4x7segment display // URL: https://github.com/RobTillaart/HT16K33 diff --git a/HT16K33.h b/HT16K33.h index 067ad9d..b730f08 100644 --- a/HT16K33.h +++ b/HT16K33.h @@ -2,7 +2,7 @@ // // FILE: HT16K33.h // AUTHOR: Rob Tillaart -// VERSION: 0.4.0 +// VERSION: 0.4.1 // DATE: 2019-02-07 // PURPOSE: Arduino Library for HT16K33 4x7segment display // http://www.adafruit.com/products/1002 @@ -13,10 +13,10 @@ #include "Wire.h" -#define HT16K33_LIB_VERSION (F("0.4.0")) +#define HT16K33_LIB_VERSION (F("0.4.1")) -// Characters +// Supported characters #define HT16K33_0 0 #define HT16K33_1 1 #define HT16K33_2 2 @@ -40,6 +40,27 @@ #define HT16K33_NONE 99 +// Raw segments, See #28 +// +// HEX codes 7 segment +// +// A 01 +// F B 20 02 +// G 40 +// E C 10 04 +// D dp 08 80 +// +const uint8_t SEG_NONE = 0x00; +const uint8_t SEG_A = 0x01; +const uint8_t SEG_B = 0x02; +const uint8_t SEG_C = 0x04; +const uint8_t SEG_D = 0x08; +const uint8_t SEG_E = 0x10; +const uint8_t SEG_F = 0x20; +const uint8_t SEG_G = 0x40; +const uint8_t SEG_DP = 0x80; + + class HT16K33 { public: diff --git a/LICENSE b/LICENSE index 1d37494..b653d12 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019-2023 Rob Tillaart +Copyright (c) 2019-2024 Rob Tillaart Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 529616e..abb6117 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ The user has to call **Wire.begin()** and can optionally set the Wire pins before calling **begin()**. -## Perfomance +## Performance Version 0.3.0 allows one to switch the caching on/off to enforce writing all positions e.g. in case of noisy I2C bus. @@ -71,7 +71,6 @@ get leading/trailing zero's correctly. #include "HT16K33.h" ``` - #### Setup behaviour - **HT16K33(const uint8_t address)** address is 0x70..0x77 depending on the jumpers A0..A2. **0x70** is default. @@ -80,7 +79,6 @@ Returns false if address not seen on I2C bus. - **bool isConnected()** Returns false if address not seen on I2C bus. - **void reset()** resets display. - #### Cache - **void clearCache()** forced clearing of the cache, to be used to switch the cache off just for one write. @@ -97,8 +95,6 @@ Returns false if address not seen on I2C bus. - **void getBlink(uint8_t value)** values 0..3 0 = off. - **void setDigits(uint8_t value)** values 0..4, minimal number of digits shown, mandatory for large numbers on dual display. - - #### Data types The bool return value indicates that the value displayed is in range. @@ -124,7 +120,6 @@ The unitChar is a postFix character like C or F for temperature H for humidity. The unitChar must be one of the chars supported like HT16K33_C, HT16K33_TOP_C or HT16K33_DEGREE (see below). So **displayUnit(25.6, 1, HT16K33_DEGREE)** will display **23.5°**. - #### Fixed point - **bool displayFixedPoint0(float f)** displays values -999 .. 9999 without decimals. @@ -132,13 +127,11 @@ So **displayUnit(25.6, 1, HT16K33_DEGREE)** will display **23.5°**. - **bool displayFixedPoint2(float f)** displays values -9.99 .. 99.99 with 2 decimals. - **bool displayFixedPoint3(float f)** displays values 0.000 .. 9.999 with 3 decimals. - #### Special VU meters - **bool displayVULeft(uint8_t value)** display used as sort VU meter, values 0..8 Vales > 8 are treated as 8 (but return false). - **bool displayVURight(uint8_t value)** display used as sort VU meter, values 0..8 Vales > 8 are treated as 8 (but return false). - #### Lower level workers - **void display(uint8_t \* array)** array of 4 bytes to control one 7seg display. @@ -148,6 +141,10 @@ So **displayUnit(25.6, 1, HT16K33_DEGREE)** will display **23.5°**. - **void displayExtraLeds(uint8_t value)** switch on extra LEDs. value is in fact a bit mask see table below. 0 = all off. +When using the consts SEG_A etc from .h file. + +![layout](https://en.wikipedia.org/wiki/File:7_segment_display_labeled.svg ""). + #### Extra LEDs table @@ -226,7 +223,6 @@ Mainly for a 0.4.x #### Should - #### Could - VU metering using halve bars allows two VU from 0..8 **new** diff --git a/examples/demo_scrolling/demo_scrolling.ino b/examples/demo_scrolling/demo_scrolling.ino new file mode 100644 index 0000000..5a82a4d --- /dev/null +++ b/examples/demo_scrolling/demo_scrolling.ino @@ -0,0 +1,74 @@ +// +// FILE: demo_displayRaw.ino +// AUTHOR: Rob Tillaart, DeflateAwning +// PURPOSE: demo +// URL: http://www.adafruit.com/products/1002 +// URL: https://github.com/RobTillaart/HT16K33 + + +#include "HT16K33.h" + +HT16K33 display(0x70); + +uint32_t start = 0; + +void display_scrolling_press_start(uint32_t idle_start_time_ms) +{ + const int msg_len = 14; + int offset = ((millis() - idle_start_time_ms) / 500) % (msg_len); + + const uint8_t SEG_PRESS_START[] = { + SEG_A | SEG_B | SEG_F | SEG_E | SEG_G, // P + SEG_E | SEG_G, // r + SEG_A | SEG_D | SEG_E | SEG_F | SEG_G, // E + SEG_A | SEG_F | SEG_G | SEG_C | SEG_D, // S + SEG_A | SEG_F | SEG_G | SEG_C | SEG_D, // S + SEG_NONE, // [space] + SEG_A | SEG_F | SEG_G | SEG_C | SEG_D, // S + SEG_F | SEG_E | SEG_G | SEG_D, // t + SEG_A | SEG_B | SEG_C | SEG_E | SEG_F | SEG_G, // A + SEG_E | SEG_G, // r + SEG_F | SEG_E | SEG_G | SEG_D, // t + SEG_NONE, // [space] + SEG_NONE, // [space] + SEG_NONE // [space] + }; + uint8_t seg1_data[] = {SEG_D, SEG_D, SEG_D, SEG_D}; + // uint8_t seg2_data[] = {SEG_D, SEG_D, SEG_D, SEG_D}; + + for (int i = 0; i < 4; i++) { + seg1_data[i] = SEG_PRESS_START[(i + offset) % msg_len]; + // seg2_data[i] = SEG_PRESS_START[(i+offset+5)%msg_len]; + } + + display.displayRaw(seg1_data); +} + + +void setup() +{ + Serial.begin(115200); + Serial.println(__FILE__); + Serial.print("HT16K33_LIB_VERSION: "); + Serial.println(HT16K33_LIB_VERSION); + + Wire.begin(); + Wire.setClock(100000); + display.begin(); + + display.displayOn(); + display.setBrightness(2); + display.displayClear(); + + start = millis(); +} + + +void loop() +{ + display_scrolling_press_start(start); + delay(100); +} + + +// -- END OF FILE -- diff --git a/library.json b/library.json index 8b1890d..f5a0641 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/HT16K33.git" }, - "version": "0.4.0", + "version": "0.4.1", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/library.properties b/library.properties index 1aab01f..3690adc 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=HT16K33 -version=0.4.0 +version=0.4.1 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino Library for HT16K33 I2C 4x7segment display