Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #28, add consts for individual segments. #29

Merged
merged 5 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ 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, kudos to DeflateAwning
- add **demo_scrolling.ino**
- update readme.md


## [0.4.0] - 2023-12-05
- refactor API, begin()
- update readme.md
Expand Down
2 changes: 1 addition & 1 deletion HT16K33.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
27 changes: 24 additions & 3 deletions HT16K33.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -40,6 +40,27 @@
#define HT16K33_NONE 99


// Raw segments, See #28
//
// HEX codes 7 segment
//
// A 0x01
// F B 0x20 0x02
// G 0x40
// E C 0x10 0x04
// D dp 0x08 0x80
//
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:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -124,21 +120,18 @@ 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.
- **bool displayFixedPoint1(float f)** displays values -99.9 .. 999.9 with 1 decimals.
- **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.
Expand All @@ -148,6 +141,13 @@ 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, for the **displayRaw()**
one can use the individual segments SEG_A..SEG_G and SEG_DP.

![layout](https://upload.wikimedia.org/wikipedia/commons/0/02/7_segment_display_labeled.svg "").

_Image courtesey wikimedia_


#### Extra LEDs table

Expand Down Expand Up @@ -226,7 +226,6 @@ Mainly for a 0.4.x
#### Should



#### Could

- VU metering using halve bars allows two VU from 0..8 **new**
Expand Down
74 changes: 74 additions & 0 deletions examples/demo_scrolling/demo_scrolling.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// FILE: demo_scrolling.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 --
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=HT16K33
version=0.4.0
version=0.4.1
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino Library for HT16K33 I2C 4x7segment display
Expand Down
Loading