2020-04-10 09:02:23 +01:00
|
|
|
/*
|
2020-04-10 14:31:20 +01:00
|
|
|
xdsp_11_sevenseg.ino - Display seven segment support for Tasmota
|
2020-04-10 09:02:23 +01:00
|
|
|
|
2021-01-01 12:44:04 +00:00
|
|
|
Copyright (C) 2021 Theo Arends and Adafruit
|
2020-04-10 09:02:23 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef USE_I2C
|
|
|
|
#ifdef USE_DISPLAY
|
|
|
|
#ifdef USE_DISPLAY_SEVENSEG
|
|
|
|
|
|
|
|
#define XDSP_11 11
|
2020-04-10 14:31:20 +01:00
|
|
|
#define XI2C_47 47 // See I2CDEVICES.md
|
2020-04-10 09:02:23 +01:00
|
|
|
|
|
|
|
#include <Wire.h>
|
|
|
|
#include <Adafruit_GFX.h>
|
|
|
|
#include <Adafruit_LEDBackpack.h> // Seven segment LED
|
|
|
|
|
2020-07-12 07:16:29 +01:00
|
|
|
Adafruit_7segment *sevenseg[8];
|
|
|
|
uint8_t sevensegs = 0;
|
2020-04-10 09:02:23 +01:00
|
|
|
uint8_t sevenseg_state = 0;
|
|
|
|
|
|
|
|
/*********************************************************************************************/
|
|
|
|
|
2020-11-23 18:53:42 +00:00
|
|
|
#ifdef USE_DISPLAY_SEVENSEG_COMMON_ANODE
|
|
|
|
void bufferStuffer(uint32_t i) {
|
|
|
|
uint8_t outArray[8] = {0,0,0,0,0,0,0,0};
|
|
|
|
uint8_t v;
|
|
|
|
|
|
|
|
for (int j = 0; j < 8; j++) {
|
|
|
|
for (int k = 0; k < 8; k++) {
|
|
|
|
v = ((sevenseg[i]->displaybuffer[j] >> k) & 1);
|
|
|
|
outArray[k] |= (v << j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int j = 0; j < 8; j++) {
|
|
|
|
sevenseg[i]->displaybuffer[j] = outArray[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-04-10 09:02:23 +01:00
|
|
|
void SevensegWrite(void)
|
|
|
|
{
|
2020-07-12 07:16:29 +01:00
|
|
|
for (uint32_t i = 0; i < sevensegs; i++) {
|
2020-11-23 18:53:42 +00:00
|
|
|
#ifdef USE_DISPLAY_SEVENSEG_COMMON_ANODE
|
|
|
|
bufferStuffer(i);
|
|
|
|
#endif
|
2020-07-12 07:16:29 +01:00
|
|
|
sevenseg[i]->writeDisplay();
|
|
|
|
}
|
2020-04-10 09:02:23 +01:00
|
|
|
}
|
|
|
|
|
2021-01-01 17:17:55 +00:00
|
|
|
void SevensegLog(void)
|
|
|
|
{
|
|
|
|
// get sensor data
|
|
|
|
ResponseClear();
|
|
|
|
ResponseAppendTime();
|
|
|
|
XsnsCall(FUNC_JSON_APPEND);
|
|
|
|
ResponseJsonEnd();
|
|
|
|
|
|
|
|
// display nth sensor value on nth display
|
|
|
|
// code adapted from xdrv_13_display.ino, DisplayAnalyzeJson()
|
|
|
|
uint8_t unit = 0;
|
|
|
|
int16_t valueDecimal = 0;
|
|
|
|
double valueFloat = 0;
|
|
|
|
uint8 fDigits = 0;
|
2021-08-15 16:26:32 +01:00
|
|
|
String jsonStr = ResponseData(); // Move from stack to heap to fix watchdogs (20180626)
|
2021-01-01 17:17:55 +00:00
|
|
|
JsonParser parser((char*)jsonStr.c_str());
|
|
|
|
JsonParserObject object_root = parser.getRootObject();
|
|
|
|
if (object_root) {
|
|
|
|
for (auto key_level1 : object_root) {
|
|
|
|
JsonParserToken token_level1 = key_level1.getValue();
|
|
|
|
if (token_level1.isObject()) {
|
|
|
|
JsonParserObject object_level1 = token_level1.getObject();
|
|
|
|
for (auto key_level2 : object_level1) {
|
|
|
|
const char* value_level2 = key_level2.getValue().getStr(nullptr);
|
|
|
|
if (value_level2 != nullptr) {
|
|
|
|
if ((unit < sevensegs) && (sevenseg[unit] != nullptr)) {
|
|
|
|
if (strchr( value_level2, '.') == NULL) {
|
|
|
|
sevenseg[unit]->print(atoi(value_level2), DEC);
|
|
|
|
} else {
|
2023-01-06 13:58:19 +00:00
|
|
|
sevenseg[unit]->printFloat(CharToFloat(value_level2), 1, DEC);
|
2021-01-01 17:17:55 +00:00
|
|
|
}
|
|
|
|
sevenseg[unit]->writeDisplay();
|
|
|
|
unit++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SevensegDim(void)
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < sevensegs; i++) {
|
2021-09-14 21:40:26 +01:00
|
|
|
sevenseg[i]->setBrightness(GetDisplayDimmer16());
|
2021-01-01 17:17:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SevensegBlinkrate( void)
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < sevensegs; i++) {
|
|
|
|
sevenseg[i]->blinkRate(XdrvMailbox.payload);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-10 09:02:23 +01:00
|
|
|
void SevensegClear(void)
|
|
|
|
{
|
2020-07-12 07:16:29 +01:00
|
|
|
for (uint32_t i = 0; i < sevensegs; i++) {
|
|
|
|
sevenseg[i]->clear();
|
|
|
|
}
|
2020-04-10 09:02:23 +01:00
|
|
|
SevensegWrite();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************************/
|
|
|
|
|
|
|
|
void SevensegInitMode(void)
|
|
|
|
{
|
2020-07-12 07:16:29 +01:00
|
|
|
for (uint32_t i = 0; i < sevensegs; i++) {
|
2021-09-14 21:40:26 +01:00
|
|
|
sevenseg[i]->setBrightness(GetDisplayDimmer16());
|
2020-07-12 07:16:29 +01:00
|
|
|
sevenseg[i]->blinkRate(0);
|
|
|
|
}
|
2020-04-10 09:02:23 +01:00
|
|
|
SevensegClear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SevensegInit(uint8_t mode)
|
|
|
|
{
|
|
|
|
switch(mode) {
|
|
|
|
case DISPLAY_INIT_MODE:
|
|
|
|
case DISPLAY_INIT_PARTIAL:
|
|
|
|
case DISPLAY_INIT_FULL:
|
|
|
|
SevensegInitMode();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-17 15:26:04 +00:00
|
|
|
void SevensegInitDriver(void) {
|
|
|
|
if (!TasmotaGlobal.i2c_enabled) { return; }
|
|
|
|
|
2021-06-11 17:14:12 +01:00
|
|
|
if (!Settings->display_model) {
|
|
|
|
if (I2cSetDevice(Settings->display_address[0])) {
|
|
|
|
Settings->display_model = XDSP_11;
|
2020-04-10 09:02:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-11 17:14:12 +01:00
|
|
|
if (XDSP_11 == Settings->display_model) {
|
2020-04-10 09:02:23 +01:00
|
|
|
sevenseg_state = 1;
|
2020-07-12 07:16:29 +01:00
|
|
|
for (sevensegs = 0; sevensegs < 8; sevensegs++) {
|
2021-06-11 17:14:12 +01:00
|
|
|
if (Settings->display_address[sevensegs]) {
|
|
|
|
I2cSetActiveFound(Settings->display_address[sevensegs], "SevenSeg");
|
2020-07-12 07:16:29 +01:00
|
|
|
sevenseg[sevensegs] = new Adafruit_7segment();
|
2021-06-11 17:14:12 +01:00
|
|
|
sevenseg[sevensegs]->begin(Settings->display_address[sevensegs]);
|
2020-07-12 07:16:29 +01:00
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 13:49:24 +01:00
|
|
|
|
2021-06-11 17:14:12 +01:00
|
|
|
Settings->display_width = 4;
|
|
|
|
Settings->display_height = sevensegs;
|
2020-04-10 09:02:23 +01:00
|
|
|
|
|
|
|
SevensegInitMode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SevensegOnOff(void)
|
|
|
|
{
|
|
|
|
if (!disp_power) { SevensegClear(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
void SevensegDrawStringAt(uint16_t x, uint16_t y, char *str, uint16_t color, uint8_t flag)
|
|
|
|
{
|
2020-07-14 09:42:41 +01:00
|
|
|
enum OutNumType {DECIMAL, HEXADECIMAL, FLOAT, SEGMENTS};
|
|
|
|
int16_t number = 0;
|
|
|
|
double numberf = 0;
|
2020-04-10 09:02:23 +01:00
|
|
|
boolean hasnumber= false;
|
|
|
|
uint8_t dots= 0;
|
2020-07-14 09:42:41 +01:00
|
|
|
OutNumType outnumtype= DECIMAL;
|
|
|
|
uint8 fds = 0; // number of fractional digits for fp number
|
|
|
|
boolean done= false;
|
|
|
|
boolean s= false;
|
|
|
|
uint8_t unit= y;
|
|
|
|
char *buf;
|
|
|
|
|
2020-07-12 07:16:29 +01:00
|
|
|
if ((unit>=sevensegs) || (unit<0)) {
|
|
|
|
unit=0;
|
|
|
|
}
|
|
|
|
|
2020-04-10 09:02:23 +01:00
|
|
|
for (int i=0; (str[i]!='\0') && (!done); i++) {
|
2020-07-12 07:16:29 +01:00
|
|
|
// [optional prefix(es) chars]digits
|
2020-04-10 09:02:23 +01:00
|
|
|
// Some combinations won't make sense.
|
2020-07-14 09:42:41 +01:00
|
|
|
// Reference: https://cdn-learn.adafruit.com/downloads/pdf/adafruit-led-backpack.pdf
|
|
|
|
// This code has been tested on 1.2" and 0.56" 7-Segment LED displays, but should mostly work for others.
|
2020-08-17 13:49:24 +01:00
|
|
|
//
|
2020-07-12 07:16:29 +01:00
|
|
|
// Prefixes:
|
2020-07-14 09:42:41 +01:00
|
|
|
// x upcoming decimal integer number displayed as hex
|
2020-07-12 07:16:29 +01:00
|
|
|
// : turn on middle colon
|
2020-07-12 08:02:39 +01:00
|
|
|
// ^ turn on top left dot
|
2020-07-12 07:16:29 +01:00
|
|
|
// v turn on bottom left dot
|
|
|
|
// . turn on AM/PM/Degree dot
|
|
|
|
// s upcoming number is seconds, print as HH:MM or MM:SS
|
|
|
|
// z clear this display
|
2020-07-14 09:42:41 +01:00
|
|
|
// f upcoming number is floating point
|
|
|
|
// r raw segment based on bitmap of upcoming integer number (see reference document above)
|
2020-08-17 13:49:24 +01:00
|
|
|
//
|
2020-04-10 09:56:23 +01:00
|
|
|
// Some sample valid combinations:
|
2020-07-14 09:42:41 +01:00
|
|
|
// 787 -> 787
|
|
|
|
// x47 -> 2F
|
|
|
|
// s:241 -> 04:01
|
|
|
|
// s241 -> 4 01
|
|
|
|
// s1241 -> 20:41
|
|
|
|
// z ->
|
|
|
|
// x88 -> 58
|
|
|
|
// f8.5 -> 8.5
|
|
|
|
// f-9.34 -> -9.34
|
2020-07-14 10:35:49 +01:00
|
|
|
// f:-9.34 -> -9.:34
|
2020-07-14 09:42:41 +01:00
|
|
|
// r255 -> 8. (all 8 segments on)
|
2020-07-12 07:16:29 +01:00
|
|
|
|
2020-04-10 09:02:23 +01:00
|
|
|
switch (str[i]) {
|
|
|
|
case 'x': // print given dec value as hex
|
2020-07-14 09:42:41 +01:00
|
|
|
// hex = true;
|
|
|
|
outnumtype = HEXADECIMAL;
|
|
|
|
break;
|
|
|
|
case 'f': // given number is floating point number
|
|
|
|
// fp = true;
|
|
|
|
outnumtype = FLOAT;
|
2020-04-10 09:02:23 +01:00
|
|
|
break;
|
|
|
|
case ':': // print colon
|
|
|
|
dots |= 0x02;
|
|
|
|
break;
|
|
|
|
case '^': // print top_left_dot
|
|
|
|
dots |= 0x08;
|
|
|
|
break;
|
|
|
|
case 'v': // print bottom_left_dot
|
|
|
|
dots |= 0x04;
|
|
|
|
break;
|
|
|
|
case '.': // print ampm
|
|
|
|
dots |= 0x10;
|
|
|
|
break;
|
|
|
|
case 's': // duration in seconds
|
|
|
|
s = true;
|
|
|
|
break;
|
2020-07-14 09:42:41 +01:00
|
|
|
case '-':
|
2020-04-10 09:02:23 +01:00
|
|
|
case '0':
|
|
|
|
case '1':
|
|
|
|
case '2':
|
|
|
|
case '3':
|
|
|
|
case '4':
|
|
|
|
case '5':
|
|
|
|
case '6':
|
|
|
|
case '7':
|
|
|
|
case '8':
|
|
|
|
case '9':
|
|
|
|
hasnumber= true;
|
2020-07-14 09:42:41 +01:00
|
|
|
if (outnumtype == FLOAT) {
|
|
|
|
// Floating point number is given
|
2023-01-06 13:58:19 +00:00
|
|
|
numberf = CharToFloat(str+i);
|
2020-07-14 09:42:41 +01:00
|
|
|
// Find number of fractional digits
|
|
|
|
buf= str+i;
|
|
|
|
char *cp= strchr(buf, '.');
|
|
|
|
if (cp == NULL) {
|
|
|
|
fds= 0;
|
|
|
|
} else {
|
|
|
|
fds= buf+strlen(buf) - 1 - cp;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Integer is given
|
|
|
|
number = atoi(str+i);
|
|
|
|
}
|
2020-04-10 09:02:23 +01:00
|
|
|
done = true;
|
|
|
|
break;
|
2020-07-12 07:16:29 +01:00
|
|
|
case 'z': // Clear this display
|
|
|
|
hasnumber=false;
|
|
|
|
dots=0;
|
|
|
|
s=false;
|
|
|
|
sevenseg[unit]->clear();
|
|
|
|
break;
|
2020-07-14 09:42:41 +01:00
|
|
|
case 'r': // Raw segment
|
|
|
|
outnumtype= SEGMENTS;
|
|
|
|
break;
|
2020-04-10 09:02:23 +01:00
|
|
|
default: // unknown format, ignore
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-14 09:42:41 +01:00
|
|
|
if (hasnumber) {
|
|
|
|
if (s) {
|
|
|
|
// number is duration in seconds
|
|
|
|
int hour = number/60/60;
|
|
|
|
int minute = (number/60)%60;
|
|
|
|
|
|
|
|
if (hour) {
|
|
|
|
// HH:MM
|
|
|
|
number = hour*100 + minute;
|
|
|
|
} else {
|
|
|
|
// MM:SS
|
|
|
|
number = minute*100 + number%60;
|
|
|
|
}
|
2020-04-10 09:02:23 +01:00
|
|
|
}
|
|
|
|
|
2020-07-14 09:42:41 +01:00
|
|
|
if (outnumtype == HEXADECIMAL) {
|
|
|
|
// Hex
|
2020-07-12 07:16:29 +01:00
|
|
|
sevenseg[unit]->print(number, HEX);
|
2020-07-14 09:42:41 +01:00
|
|
|
} else if (outnumtype == FLOAT) {
|
|
|
|
// Floating point
|
|
|
|
sevenseg[unit]->printFloat(numberf, fds, 10);
|
|
|
|
} else if (outnumtype == SEGMENTS) {
|
|
|
|
// Raw segments
|
|
|
|
sevenseg[unit]->writeDigitRaw(x, number);
|
2020-04-10 09:02:23 +01:00
|
|
|
} else {
|
2020-07-14 09:42:41 +01:00
|
|
|
// Decimal
|
2020-07-12 07:16:29 +01:00
|
|
|
sevenseg[unit]->print(number, DEC);
|
2020-04-10 09:02:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dots) {
|
2020-07-12 07:16:29 +01:00
|
|
|
sevenseg[unit]->writeDigitRaw(2, dots);
|
2020-04-10 09:02:23 +01:00
|
|
|
}
|
|
|
|
|
2020-11-23 18:53:42 +00:00
|
|
|
#ifdef USE_DISPLAY_SEVENSEG_COMMON_ANODE
|
|
|
|
bufferStuffer(unit);
|
|
|
|
#endif
|
2020-07-12 07:16:29 +01:00
|
|
|
sevenseg[unit]->writeDisplay();
|
2020-04-10 09:02:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************************/
|
|
|
|
|
|
|
|
#ifdef USE_DISPLAY_MODES1TO5
|
|
|
|
void SevensegTime(boolean time_24)
|
|
|
|
{
|
2020-04-10 15:05:43 +01:00
|
|
|
|
2020-04-10 09:02:23 +01:00
|
|
|
uint hours = RtcTime.hour;
|
|
|
|
uint minutes = RtcTime.minute;
|
|
|
|
uint second = RtcTime.second;
|
|
|
|
uint16_t displayValue = hours * 100 + minutes;
|
|
|
|
uint16_t dots = 0;
|
|
|
|
|
|
|
|
// Do 24 hour to 12 hour format conversion when required.
|
|
|
|
if (!time_24) {
|
|
|
|
// Handle when hours are past 12 by subtracting 12 hours (1200 value).
|
|
|
|
if (hours > 12) {
|
|
|
|
displayValue -= 1200;
|
|
|
|
}
|
|
|
|
// Handle hour 0 (midnight) being shown as 12.
|
|
|
|
else if (hours == 0) {
|
|
|
|
displayValue += 1200;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Now print the time value to the display.
|
2020-07-12 07:16:29 +01:00
|
|
|
sevenseg[0]->print(displayValue, DEC);
|
2020-04-10 09:02:23 +01:00
|
|
|
|
|
|
|
// Add zero padding when in 24 hour mode and it's midnight.
|
|
|
|
// In this case the print function above won't have leading 0's
|
|
|
|
// which can look confusing. Go in and explicitly add these zeros.
|
|
|
|
if (time_24) {
|
|
|
|
if (hours == 0) {
|
|
|
|
// Pad hour 0.
|
2020-07-12 07:16:29 +01:00
|
|
|
sevenseg[0]->writeDigitNum(1, 0);
|
2020-04-10 09:02:23 +01:00
|
|
|
// Also pad when the 10's minute is 0 and should be padded.
|
|
|
|
if (minutes < 10) {
|
2020-07-12 07:16:29 +01:00
|
|
|
sevenseg[0]->writeDigitNum(3, 0);
|
2020-04-10 09:02:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hours < 10) {
|
|
|
|
// Always have 4 digits time
|
2020-07-12 07:16:29 +01:00
|
|
|
sevenseg[0]->writeDigitNum(0, 0);
|
2020-04-10 09:02:23 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Identify and display AM/PM
|
|
|
|
if (hours >= 12) {
|
|
|
|
dots |= 0x10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 07:16:29 +01:00
|
|
|
sevenseg[0]->writeDigitRaw(2, dots |= ((second%2) << 1));
|
2020-11-23 18:53:42 +00:00
|
|
|
#ifdef USE_DISPLAY_SEVENSEG_COMMON_ANODE
|
|
|
|
bufferStuffer(0);
|
|
|
|
#endif
|
2020-07-12 07:16:29 +01:00
|
|
|
sevenseg[0]->writeDisplay();
|
2020-04-10 09:02:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SevensegRefresh(void) // Every second
|
|
|
|
{
|
|
|
|
if (disp_power) {
|
2021-06-11 17:14:12 +01:00
|
|
|
if (Settings->display_mode) { // Mode 0 is User text
|
|
|
|
switch (Settings->display_mode) {
|
2020-04-10 09:02:23 +01:00
|
|
|
case 1: // Time 12
|
|
|
|
SevensegTime(false);
|
|
|
|
break;
|
|
|
|
case 2: // Time 24
|
|
|
|
SevensegTime(true);
|
|
|
|
break;
|
|
|
|
case 4: // Mqtt
|
|
|
|
case 3: // Local
|
|
|
|
case 5: { // Mqtt
|
2021-01-01 17:17:55 +00:00
|
|
|
SevensegLog();
|
2020-04-10 09:02:23 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-25 09:21:36 +01:00
|
|
|
#endif // USE_DISPLAY_MODES1TO5
|
|
|
|
|
2020-04-10 09:02:23 +01:00
|
|
|
/*********************************************************************************************\
|
|
|
|
* Interface
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2022-11-11 09:44:56 +00:00
|
|
|
bool Xdsp11(uint32_t function)
|
2020-04-10 09:02:23 +01:00
|
|
|
{
|
2020-04-10 14:31:20 +01:00
|
|
|
if (!I2cEnabled(XI2C_47)) { return false; }
|
2020-04-10 09:02:23 +01:00
|
|
|
|
|
|
|
bool result = false;
|
|
|
|
|
|
|
|
if (FUNC_DISPLAY_INIT_DRIVER == function) {
|
|
|
|
SevensegInitDriver();
|
|
|
|
}
|
2021-06-11 17:14:12 +01:00
|
|
|
else if (XDSP_11 == Settings->display_model) {
|
2020-04-10 09:02:23 +01:00
|
|
|
switch (function) {
|
|
|
|
case FUNC_DISPLAY_MODEL:
|
|
|
|
result = true;
|
|
|
|
break;
|
|
|
|
case FUNC_DISPLAY_INIT:
|
|
|
|
SevensegInit(dsp_init);
|
|
|
|
break;
|
|
|
|
case FUNC_DISPLAY_CLEAR:
|
|
|
|
SevensegClear();
|
|
|
|
break;
|
2020-05-25 09:21:36 +01:00
|
|
|
#ifdef USE_DISPLAY_MODES1TO5
|
2020-04-10 09:02:23 +01:00
|
|
|
case FUNC_DISPLAY_EVERY_SECOND:
|
|
|
|
SevensegRefresh();
|
|
|
|
break;
|
2020-05-25 09:21:36 +01:00
|
|
|
#endif // USE_DISPLAY_MODES1TO5
|
2020-04-10 09:02:23 +01:00
|
|
|
case FUNC_DISPLAY_POWER:
|
|
|
|
SevensegOnOff();
|
|
|
|
break;
|
|
|
|
case FUNC_DISPLAY_DRAW_STRING:
|
|
|
|
SevensegDrawStringAt(dsp_x, dsp_y, dsp_str, dsp_color, dsp_flag);
|
|
|
|
break;
|
2021-01-01 17:17:55 +00:00
|
|
|
case FUNC_DISPLAY_DIM:
|
|
|
|
SevensegDim();
|
|
|
|
break;
|
|
|
|
case FUNC_DISPLAY_BLINKRATE:
|
|
|
|
SevensegBlinkrate();
|
|
|
|
break;
|
|
|
|
|
2020-04-10 09:02:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-04-10 15:05:43 +01:00
|
|
|
#endif // USE_DISPLAY_SEVENSEG
|
2020-04-10 09:02:23 +01:00
|
|
|
#endif // USE_DISPLAY
|
|
|
|
#endif // USE_I2C
|