glcd: merge led/lcd/simple clock into a single source file

Origin commit data
------------------
Commit: f20ce17314
Author: vanhofen <vanhofen@gmx.de>
Date: 2020-06-21 (Sun, 21 Jun 2020)

Origin message was:
------------------
- glcd: merge led/lcd/simple clock into a single source file
This commit is contained in:
vanhofen
2020-06-21 22:00:26 +02:00
parent 5c3f2154d0
commit 946ee99969
13 changed files with 50 additions and 257 deletions

View File

@@ -975,6 +975,7 @@ glcd.standby_digital_clock Digitale Uhr
glcd.standby_lcd_clock LCD-Uhr glcd.standby_lcd_clock LCD-Uhr
glcd.standby_led_clock LED-Uhr glcd.standby_led_clock LED-Uhr
glcd.standby_settings Standby-Einstellungen glcd.standby_settings Standby-Einstellungen
glcd.standby_simple_clock Einfache Uhr
glcd.standby_weather Wetter im Standby glcd.standby_weather Wetter im Standby
glcd.start_x_position Sendungsstart x-Position glcd.start_x_position Sendungsstart x-Position
glcd.start_y_position Sendungsstart y-Position glcd.start_y_position Sendungsstart y-Position

View File

@@ -18,8 +18,6 @@ noinst_LIBRARIES = libneutrino_driver_glcd.a
libneutrino_driver_glcd_a_SOURCES = \ libneutrino_driver_glcd_a_SOURCES = \
analogclock.cpp \ analogclock.cpp \
digitalclock.cpp \ digitalclock.cpp \
lcdclock.cpp \
ledclock.cpp \
simpleclock.cpp \ simpleclock.cpp \
weather.cpp \ weather.cpp \
glcd.cpp glcd.cpp

View File

@@ -41,8 +41,6 @@
#include "glcd.h" #include "glcd.h"
#include "analogclock.h" #include "analogclock.h"
#include "digitalclock.h" #include "digitalclock.h"
#include "lcdclock.h"
#include "ledclock.h"
#include "simpleclock.h" #include "simpleclock.h"
#include "weather.h" #include "weather.h"
@@ -136,8 +134,6 @@ cGLCD::cGLCD()
InitAnalogClock(); InitAnalogClock();
InitDigitalClock(); InitDigitalClock();
InitLcdClock();
InitLedClock();
InitSimpleClock(); InitSimpleClock();
InitWeather(); InitWeather();
@@ -232,28 +228,18 @@ void cGLCD::Exec()
if (doStandbyTime) if (doStandbyTime)
{ {
std::string Time; std::string Time;
if (g_settings.glcd_time_in_standby == 5) if (g_settings.glcd_time_in_standby == CLOCK_ANALOG)
{ {
ShowAnalogClock(tm->tm_hour, tm->tm_min, tm->tm_sec, bitmap->Width()/2, bitmap->Height()/2); ShowAnalogClock(tm->tm_hour, tm->tm_min, tm->tm_sec, bitmap->Width()/2, bitmap->Height()/2);
} }
else if (g_settings.glcd_time_in_standby == 4) else if (g_settings.glcd_time_in_standby == CLOCK_DIGITAL)
{ {
ShowDigitalClock(tm->tm_hour, tm->tm_min); ShowDigitalClock(tm->tm_hour, tm->tm_min);
} }
else if (g_settings.glcd_time_in_standby == 3) else if (g_settings.glcd_time_in_standby > CLOCK_OFF)
{ {
Time = strftime("%H:%M", tm); Time = strftime("%H:%M", tm);
ShowLcdClock(Time); ShowSimpleClock(Time, g_settings.glcd_time_in_standby);
}
else if (g_settings.glcd_time_in_standby == 2)
{
Time = strftime("%H:%M", tm);
ShowLedClock(Time);
}
else
{
Time = strftime("%H:%M", tm);
ShowSimpleClock(Time);
} }
if (g_settings.glcd_standby_weather == 1 && g_settings.glcd_time_in_standby != 5) if (g_settings.glcd_standby_weather == 1 && g_settings.glcd_time_in_standby != 5)
{ {

View File

@@ -177,6 +177,14 @@ class cGLCD
SUB = 7, SUB = 7,
CAM = 8, CAM = 8,
}; };
enum {
CLOCK_OFF = 0,
CLOCK_SIMPLE = 1,
CLOCK_LED = 2,
CLOCK_LCD = 3,
CLOCK_DIGITAL = 4,
CLOCK_ANALOG = 5
};
GLCD::cDriver * lcd; GLCD::cDriver * lcd;
GLCD::cFont font_channel; GLCD::cFont font_channel;
GLCD::cFont font_epg; GLCD::cFont font_epg;

View File

@@ -1,74 +0,0 @@
/*
lcd clock - DBoxII-Project
Copyright (C) 2018 redblue
License: GPL
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 2 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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <global.h>
#include <neutrino.h>
#include <cstdio>
#include "lcdclock.h"
static bool fonts_initialized = false;
GLCD::cFont lcd_font_time_standby;
void InitLcdClock(void)
{
printf("[%s:%s] finish initialization\n", __file__, __func__);
}
void LcdClockUpdateFonts(void)
{
cGLCD *cglcd = cGLCD::getInstance();
SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
int fontsize_time_standby = 0;
int percent_time_standby = std::min(t.glcd_size_simple_clock, 100);
int fontsize_time_standby_new = percent_time_standby * cglcd->lcd->Height() / 100;
if (!fonts_initialized || (fontsize_time_standby_new != fontsize_time_standby)) {
fontsize_time_standby = fontsize_time_standby_new;
if (!lcd_font_time_standby.LoadFT2(FONTDIR "/oled/lcd.ttf", "UTF-8", fontsize_time_standby)) {
lcd_font_time_standby.LoadFT2(FONTDIR "/neutrino.ttf", "UTF-8", fontsize_time_standby);
}
}
fonts_initialized = true;
}
void RenderLcdClock(std::string Time, int x, int y)
{
(void) x;
cGLCD *cglcd = cGLCD::getInstance();
SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
LcdClockUpdateFonts();
cglcd->bitmap->DrawText(std::max(2,(cglcd->bitmap->Width() - 4 - lcd_font_time_standby.Width(Time))/2),
y, cglcd->bitmap->Width() - 1, Time,
&lcd_font_time_standby, cglcd->ColorConvert3to1(t.glcd_color_fg_red, t.glcd_color_fg_green, t.glcd_color_fg_blue), GLCD::cColor::Transparent);
}
void ShowLcdClock(std::string Time)
{
cGLCD *cglcd = cGLCD::getInstance();
SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
int y = g_settings.glcd_standby_weather ? t.glcd_simple_clock_y_position : (cglcd->bitmap->Height() - lcd_font_time_standby.Height(Time)) / 2;
RenderLcdClock(Time, 255, y);
}

View File

@@ -1,34 +0,0 @@
/*
LCD-Daemon - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
License: GPL
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 2 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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <glcdgraphics/bitmap.h>
#pragma GCC diagnostic warning "-Wunused-parameter"
#include "glcd.h"
void InitLcdClock();
void LcdClockUpdateFonts();
void RenderLcdClock(std::string Time, int x, int y);
void ShowLcdClock(std::string Time);

View File

@@ -1,74 +0,0 @@
/*
led clock - DBoxII-Project
Copyright (C) 2018 redblue
License: GPL
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 2 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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <global.h>
#include <neutrino.h>
#include <cstdio>
#include "ledclock.h"
static bool fonts_initialized = false;
GLCD::cFont led_font_time_standby;
void InitLedClock(void)
{
printf("[%s:%s] finish initialization\n", __file__, __func__);
}
void LedClockUpdateFonts(void)
{
cGLCD *cglcd = cGLCD::getInstance();
SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
int fontsize_time_standby = 0;
int percent_time_standby = std::min(t.glcd_size_simple_clock, 100);
int fontsize_time_standby_new = percent_time_standby * cglcd->lcd->Height() / 100;
if (!fonts_initialized || (fontsize_time_standby_new != fontsize_time_standby)) {
fontsize_time_standby = fontsize_time_standby_new;
if (!led_font_time_standby.LoadFT2(FONTDIR "/oled/led.ttf", "UTF-8", fontsize_time_standby)) {
led_font_time_standby.LoadFT2(FONTDIR "/neutrino.ttf", "UTF-8", fontsize_time_standby);
}
}
fonts_initialized = true;
}
void RenderLedClock(std::string Time, int x, int y)
{
(void) x;
cGLCD *cglcd = cGLCD::getInstance();
SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
LedClockUpdateFonts();
cglcd->bitmap->DrawText(std::max(2,(cglcd->bitmap->Width() - 4 - led_font_time_standby.Width(Time))/2),
y, cglcd->bitmap->Width() - 1, Time,
&led_font_time_standby, cglcd->ColorConvert3to1(t.glcd_color_fg_red, t.glcd_color_fg_green, t.glcd_color_fg_blue), GLCD::cColor::Transparent);
}
void ShowLedClock(std::string Time)
{
cGLCD *cglcd = cGLCD::getInstance();
SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
int y = g_settings.glcd_standby_weather ? t.glcd_simple_clock_y_position : (cglcd->bitmap->Height() - led_font_time_standby.Height(Time)) / 2;
RenderLedClock(Time, 255, y);
}

View File

@@ -1,34 +0,0 @@
/*
LCD-Daemon - DBoxII-Project
Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/
License: GPL
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 2 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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <glcdgraphics/bitmap.h>
#pragma GCC diagnostic warning "-Wunused-parameter"
#include "glcd.h"
void InitLedClock();
void LedClockUpdateFonts();
void RenderLedClock(std::string Time, int x, int y);
void ShowLedClock(std::string Time);

View File

@@ -29,8 +29,6 @@
#include <cstdio> #include <cstdio>
#include "simpleclock.h" #include "simpleclock.h"
static bool fonts_initialized = false;
GLCD::cFont font_time_standby; GLCD::cFont font_time_standby;
void InitSimpleClock(void) void InitSimpleClock(void)
@@ -38,37 +36,53 @@ void InitSimpleClock(void)
printf("[%s:%s] finish initialization\n", __file__, __func__); printf("[%s:%s] finish initialization\n", __file__, __func__);
} }
void SimpleClockUpdateFonts(void) void SimpleClockUpdateFonts(int mode)
{ {
cGLCD *cglcd = cGLCD::getInstance(); cGLCD *cglcd = cGLCD::getInstance();
SNeutrinoGlcdTheme &t = g_settings.glcd_theme; SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
std::string font = t.glcd_font;
switch (mode)
{
case cGLCD::CLOCK_LCD:
font = FONTDIR "/oled/lcd.ttf";
break;
case cGLCD::CLOCK_LED:
font = FONTDIR "/oled/led.ttf";
break;
case cGLCD::CLOCK_SIMPLE:
default:
font = t.glcd_font
;
}
int fontsize_time_standby = 0; int fontsize_time_standby = 0;
int percent_time_standby = std::min(t.glcd_size_simple_clock, 100); int percent_time_standby = std::min(t.glcd_size_simple_clock, 100);
int fontsize_time_standby_new = percent_time_standby * cglcd->lcd->Height() / 100; int fontsize_time_standby_new = percent_time_standby * cglcd->lcd->Height() / 100;
if (!fonts_initialized || (fontsize_time_standby_new != fontsize_time_standby)) { if (fontsize_time_standby_new != fontsize_time_standby) {
fontsize_time_standby = fontsize_time_standby_new; fontsize_time_standby = fontsize_time_standby_new;
if (!font_time_standby.LoadFT2(t.glcd_font, "UTF-8", fontsize_time_standby)) { if (!font_time_standby.LoadFT2(font, "UTF-8", fontsize_time_standby)) {
t.glcd_font = FONTDIR "/neutrino.ttf"; font_time_standby.LoadFT2(g_settings.font_file, "UTF-8", fontsize_time_standby);
font_time_standby.LoadFT2(t.glcd_font, "UTF-8", fontsize_time_standby);
} }
} }
fonts_initialized = true;
} }
void RenderSimpleClock(std::string Time, int x, int y) void RenderSimpleClock(std::string Time, int x, int y, int mode)
{ {
(void) x;
cGLCD *cglcd = cGLCD::getInstance(); cGLCD *cglcd = cGLCD::getInstance();
SNeutrinoGlcdTheme &t = g_settings.glcd_theme; SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
SimpleClockUpdateFonts(); SimpleClockUpdateFonts(mode);
cglcd->bitmap->DrawText(std::max(2,(cglcd->bitmap->Width() - 4 - font_time_standby.Width(Time))/2), cglcd->bitmap->DrawText(std::max(2,(cglcd->bitmap->Width() - 4 - font_time_standby.Width(Time))/2),
y, cglcd->bitmap->Width() - 1, Time, y, cglcd->bitmap->Width() - 1, Time,
&font_time_standby, cglcd->ColorConvert3to1(t.glcd_color_fg_red, t.glcd_color_fg_green, t.glcd_color_fg_blue), GLCD::cColor::Transparent); &font_time_standby, cglcd->ColorConvert3to1(t.glcd_color_fg_red, t.glcd_color_fg_green, t.glcd_color_fg_blue), GLCD::cColor::Transparent);
} }
void ShowSimpleClock(std::string Time) void ShowSimpleClock(std::string Time, int mode)
{ {
cGLCD *cglcd = cGLCD::getInstance(); cGLCD *cglcd = cGLCD::getInstance();
SNeutrinoGlcdTheme &t = g_settings.glcd_theme; SNeutrinoGlcdTheme &t = g_settings.glcd_theme;
int y = g_settings.glcd_standby_weather ? t.glcd_simple_clock_y_position : (cglcd->bitmap->Height() - font_time_standby.Height(Time)) / 2; int y = g_settings.glcd_standby_weather ? t.glcd_simple_clock_y_position : (cglcd->bitmap->Height() - font_time_standby.Height(Time)) / 2;
RenderSimpleClock(Time, 255, y); RenderSimpleClock(Time, 255, y, mode);
} }

View File

@@ -29,6 +29,6 @@
#include "glcd.h" #include "glcd.h"
void InitSimpleClock(); void InitSimpleClock();
void SimpleClockUpdateFonts(); void SimpleClockUpdateFonts(int mode);
void RenderSimpleClock(std::string Time, int x, int y); void RenderSimpleClock(std::string Time, int x, int y, int mode);
void ShowSimpleClock(std::string Time); void ShowSimpleClock(std::string Time, int mode = cGLCD::CLOCK_SIMPLE);

View File

@@ -41,12 +41,12 @@
#define ONOFFSEC_OPTION_COUNT 6 #define ONOFFSEC_OPTION_COUNT 6
static const CMenuOptionChooser::keyval ONOFFSEC_OPTIONS[ONOFFSEC_OPTION_COUNT] = { static const CMenuOptionChooser::keyval ONOFFSEC_OPTIONS[ONOFFSEC_OPTION_COUNT] = {
{ 0, LOCALE_OPTIONS_OFF }, { cGLCD::CLOCK_OFF, LOCALE_OPTIONS_OFF },
{ 1, LOCALE_OPTIONS_ON }, { cGLCD::CLOCK_SIMPLE, LOCALE_GLCD_STANDBY_SIMPLE_CLOCK },
{ 2, LOCALE_GLCD_STANDBY_LED_CLOCK }, { cGLCD::CLOCK_LED, LOCALE_GLCD_STANDBY_LED_CLOCK },
{ 3, LOCALE_GLCD_STANDBY_LCD_CLOCK }, { cGLCD::CLOCK_LCD, LOCALE_GLCD_STANDBY_LCD_CLOCK },
{ 4, LOCALE_GLCD_STANDBY_DIGITAL_CLOCK }, { cGLCD::CLOCK_DIGITAL, LOCALE_GLCD_STANDBY_DIGITAL_CLOCK },
{ 5, LOCALE_GLCD_STANDBY_ANALOG_CLOCK } { cGLCD::CLOCK_ANALOG, LOCALE_GLCD_STANDBY_ANALOG_CLOCK }
}; };
#define ONOFFPRI_OPTION_COUNT 4 #define ONOFFPRI_OPTION_COUNT 4

View File

@@ -1002,6 +1002,7 @@ typedef enum
LOCALE_GLCD_STANDBY_LCD_CLOCK, LOCALE_GLCD_STANDBY_LCD_CLOCK,
LOCALE_GLCD_STANDBY_LED_CLOCK, LOCALE_GLCD_STANDBY_LED_CLOCK,
LOCALE_GLCD_STANDBY_SETTINGS, LOCALE_GLCD_STANDBY_SETTINGS,
LOCALE_GLCD_STANDBY_SIMPLE_CLOCK,
LOCALE_GLCD_STANDBY_WEATHER, LOCALE_GLCD_STANDBY_WEATHER,
LOCALE_GLCD_START_X_POSITION, LOCALE_GLCD_START_X_POSITION,
LOCALE_GLCD_START_Y_POSITION, LOCALE_GLCD_START_Y_POSITION,

View File

@@ -1002,6 +1002,7 @@ const char * locale_real_names[] =
"glcd.standby_lcd_clock", "glcd.standby_lcd_clock",
"glcd.standby_led_clock", "glcd.standby_led_clock",
"glcd.standby_settings", "glcd.standby_settings",
"glcd.standby_simple_clock",
"glcd.standby_weather", "glcd.standby_weather",
"glcd.start_x_position", "glcd.start_x_position",
"glcd.start_y_position", "glcd.start_y_position",