Skip to content

Commit 0bd7585

Browse files
committed
1.3
1 parent 64ecece commit 0bd7585

File tree

10 files changed

+104
-10
lines changed

10 files changed

+104
-10
lines changed

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<a id="disp"></a>
4040
## Документация
4141
### Поддерживаемые дисплеи
42-
> Если вы нашли хороший модуль дисплея, который не поддерживается библиотекой - пишите. Закажу, протестирую, добавлю в библиотеку.
42+
> Если вы нашли хороший модуль дисплея, который не поддерживается библиотекой - пишите. Закажу, протестирую, добавлю.
4343
4444
| Фото | Контроллер | Размер | AliExpress | Класс |
4545
|-----------------------------------------------------|------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------|-----------------|
@@ -51,7 +51,8 @@
5151
| ![Disp1637_6-0.56](/img/Disp1637_6-0.56.webp) | TM1637 | 0.56" | [ссылка](https://fas.st/i0dmi?erid=LatgBbQo6) | `Disp1637_6` |
5252
| ![Disp595_4](/img/Disp595_4.webp) | 74HC595 | 0.36" | [ссылка](https://fas.st/WC-EE?erid=LatgBbQo6), [ссылка](https://fas.st/5d6JH?erid=LatgBbQo6), [ссылка](https://fas.st/UT6RqC?erid=LatgBbQo6) | `Disp595_4` |
5353
| ![Disp595_8](/img/Disp595_8.webp) | 74HC595 | 0.36" | [ссылка](https://fas.st/SzV0w?erid=LatgBbQo6), [ссылка](https://fas.st/YM7Fu?erid=LatgBbQo6) | `Disp595_8` |
54-
| ![Disp595_8](/img/Disp595_8v2.webp) | 74HC595 | 0.36"/0.56" | [ссылка](https://fas.st/6x9q9R?erid=LatgBbQo6) | `Disp595_8v2` |
54+
| ![Disp595_8v2](/img/Disp595_8v2.webp) | 74HC595 | 0.36"/0.56" | [ссылка](https://fas.st/6x9q9R?erid=LatgBbQo6) | `Disp595_8v2` |
55+
| ![Disp595_8s](/img/Disp595Static.webp) | 74HC595 | 0.56" | [ссылка](https://fas.st/wlOjS?erid=LatgBbQo6), [ссылка](https://fas.st/9eA7PC?erid=LatgBbQo6), [ссылка](https://fas.st/U6eEnq?erid=LatgBbQo6) | `Disp595Static` |
5556
| ![Disp7219](/img/Disp7219.webp) | MAX7219 | 0.36" | [ссылка](https://fas.st/_ugxv1?erid=LatgBbQo6), [ссылка](https://fas.st/IqQly3?erid=LatgBbQo6) | `Disp7219` |
5657

5758
### Как устроена библиотека
@@ -85,9 +86,10 @@ void colon(bool show); // вкл-выкл двоеточие
8586

8687
### 74HC595
8788
```cpp
88-
Disp595_4(uint8_t DIO, uint8_t SCLK, uint8_t RCLK); // Модуль 4 цифры
89-
Disp595_8(uint8_t DIO, uint8_t SCLK, uint8_t RCLK); // Модуль 8 цифр
90-
Disp595_8v2(uint8_t DIO, uint8_t SCLK, uint8_t RCLK); // Модуль 8 цифр, другая разводка
89+
Disp595_4(uint8_t DIO, uint8_t SCLK, uint8_t RCLK); // Модуль 4 цифры
90+
Disp595_8(uint8_t DIO, uint8_t SCLK, uint8_t RCLK); // Модуль 8 цифр
91+
Disp595_8v2(uint8_t DIO, uint8_t SCLK, uint8_t RCLK); // Модуль 8 цифр, другая разводка
92+
Disp595Static<int amount> (uint8_t SDI, uint8_t SCLK, uint8_t LOAD); // любое кол-во цифр. Статическая индикация!
9193

9294
// у всех
9395
uint8_t tick(); // тикер динамической индикации, вызывать в loop
@@ -99,10 +101,12 @@ void brightness(uint8_t bright); // установить яркость (0..
99101
#define GS_EXP_TIME 100 // время экспонирования знакоместа
100102
```
101103
104+
> `Disp595Static` работает без вызова `tick`. Но если нужно управление яркостью - нужно вызывать `tick`!
105+
102106
### MAX7219
103107
```cpp
104108
// Модуль 8 цифр
105-
Disp7219<uint8_t amount>(uint8_t DIN, uint8_t CLK, uint8_t CS, bool reverse = true);
109+
Disp7219<int amount>(uint8_t DIN, uint8_t CLK, uint8_t CS, bool reverse = true);
106110
107111
void begin(); // инициализировать (нужно после сброса питания модуля)
108112
void brightness(uint8_t value); // установить яркость (0.. 15)
@@ -543,6 +547,8 @@ class MyDisp : public SegBuffer {
543547
// объявление дисплеев. Выбери любой
544548
Disp595_4 disp(DIO_PIN, CLK_PIN, LAT_PIN);
545549
// Disp595_8 disp(DIO_PIN, CLK_PIN, LAT_PIN);
550+
// Disp595_8v2 disp(DIO_PIN, CLK_PIN, LAT_PIN);
551+
// Disp595Static<4> disp(DIO_PIN, CLK_PIN, LAT_PIN);
546552
// Disp1637_4 disp(DIO_PIN, CLK_PIN);
547553
// Disp1637_6 disp(DIO_PIN, CLK_PIN);
548554
// Disp1637Colon disp(DIO_PIN, CLK_PIN);
@@ -601,6 +607,7 @@ void loop() {
601607
- Переписан драйвер яркости для динамических дисплеев. Снижена нагрузка на процессор, повышена стабильность
602608
- Добавлен ручной тикер для динамических дисплеев
603609
- v1.3 - добавлена поддержка дисплея Disp595_8v2
610+
- v1.4 - добавлена поддержка дисплея Disp595Static
604611
605612
<a id="install"></a>
606613
## Установка

examples/basic/basic.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// объявление дисплеев. Выбери любой
99
Disp595_4 disp(DIO_PIN, CLK_PIN, LAT_PIN);
1010
// Disp595_8 disp(DIO_PIN, CLK_PIN, LAT_PIN);
11+
// Disp595_8v2 disp(DIO_PIN, CLK_PIN, LAT_PIN);
12+
// Disp595Static<4> disp(DIO_PIN, CLK_PIN, LAT_PIN);
1113
// Disp1637_4 disp(DIO_PIN, CLK_PIN);
1214
// Disp1637_6 disp(DIO_PIN, CLK_PIN);
1315
// Disp1637Colon disp(DIO_PIN, CLK_PIN);

img/Disp595Static.webp

21.1 KB
Loading

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ SegRunner KEYWORD1
1515
Disp595_4 KEYWORD1
1616
Disp595_8 KEYWORD1
1717
Disp595_8v2 KEYWORD1
18+
Disp595Static KEYWORD1
1819
Disp1637_4 KEYWORD1
1920
Disp1637_6 KEYWORD1
2021
Disp1637Colon KEYWORD1

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=GyverSegment
2-
version=1.3
2+
version=1.4
33
author=AlexGyver <[email protected]>
44
maintainer=AlexGyver <[email protected]>
55
sentence=Powerful library for controlling 7-segment indicators

src/GyverSegment.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "display/Disp595_4.h"
99
#include "display/Disp595_8.h"
1010
#include "display/Disp595_8v2.h"
11+
#include "display/Disp595Static.h"
1112
#include "display/Driver595.h"
1213
//
1314
#include "display/Disp1637Colon.h"

src/display/Disp595Static.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#pragma once
2+
#include <Arduino.h>
3+
#include <GyverIO.h>
4+
5+
#include "utils/SegBuffer.h"
6+
#include "utils/SegDuty.h"
7+
8+
// задержка клока в мкс
9+
10+
#ifndef DISP595_CLK_DELAY
11+
#define DISP595_CLK_DELAY 0
12+
#endif
13+
14+
template <uint8_t amount>
15+
class Disp595Static : public SegDuty, public SegBuffer {
16+
public:
17+
Disp595Static(uint8_t DIO, uint8_t SCLK, uint8_t RCLK) : SegBuffer(buffer, amount, 1) {
18+
_dio = DIO;
19+
_clk = SCLK;
20+
_latch = RCLK;
21+
pinMode(_dio, OUTPUT);
22+
pinMode(_clk, OUTPUT);
23+
pinMode(_latch, OUTPUT);
24+
update();
25+
}
26+
27+
// управление питанием (true вкл, false выкл)
28+
void power(bool state) {
29+
if (state) update();
30+
else _clear();
31+
_power = state;
32+
}
33+
34+
// обновить дисплей
35+
void update() {
36+
gio::low(_latch);
37+
for (uint8_t i = 0; i < amount; i++) {
38+
gio::shift::send_byte(_dio, _clk, MSBFIRST, ~buffer[amount - i - 1], DISP595_CLK_DELAY);
39+
}
40+
gio::high(_latch);
41+
_on_f = 1;
42+
}
43+
44+
uint8_t tick() {
45+
if (!_power) return 0;
46+
if (SegDuty::isMax()) {
47+
if (!_on_f) update();
48+
} else {
49+
if (SegDuty::tout()) tickManual();
50+
}
51+
return 0;
52+
}
53+
54+
uint8_t tickManual() {
55+
if (!_power) return 0;
56+
if (SegDuty::skip()) return 0;
57+
58+
if (_on_f && SegDuty::begin()) _clear();
59+
else update();
60+
return 0;
61+
}
62+
63+
uint8_t buffer[amount] = {0};
64+
65+
private:
66+
uint8_t _dio, _clk, _latch;
67+
bool _power = 1;
68+
bool _on_f = 0;
69+
70+
void _clear() {
71+
gio::low(_latch);
72+
for (uint8_t i = 0; i < amount; i++) {
73+
gio::shift::send_byte(_dio, _clk, MSBFIRST, 0xff, DISP595_CLK_DELAY);
74+
}
75+
gio::high(_latch);
76+
_on_f = 0;
77+
}
78+
};

src/display/Disp595_4.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Disp595_4 : public Driver595, public SegBuffer {
1818
_buf[i] = ~buffer[4 - 1 - i];
1919
}
2020
}
21-
21+
2222
// тикер динамической индикации, вызывать в loop постоянно
2323
uint8_t tick() {
2424
Driver595::tick(_buf, 4);

src/display/Driver595.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ class Driver595 : public SegDuty {
3939
}
4040

4141
void tick(uint8_t* buffer, uint8_t size) {
42-
if (!_power) return;
43-
if (SegDuty::tout()) tickManual(buffer, size);
42+
if (_power) {
43+
if (SegDuty::tout()) tickManual(buffer, size);
44+
}
4445
}
4546

4647
void tickManual(uint8_t* buffer, uint8_t size) {

src/utils/SegDuty.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ class SegDuty {
6868
return 0;
6969
}
7070

71+
bool isMax() {
72+
return !_top;
73+
}
74+
7175
private:
7276
// _top == 0 - макс яркость
7377
uint8_t _count = 0, _top = 0;

0 commit comments

Comments
 (0)